diff options
| author | Matthew Petroff <matthew@mpetroff.net> | 2013-08-06 18:54:40 +0000 |
|---|---|---|
| committer | Matthew Petroff <matthew@mpetroff.net> | 2013-08-06 18:54:40 +0000 |
| commit | bb88a2cb94ec34ee838a972bab17ca05ba92d1da (patch) | |
| tree | 4b4580dbe1bec0968254d1b362611ab57ad3c223 /src/helper | |
| parent | init SPStyle better: fixes a bunch of bugs resulting from improper re-init of... (diff) | |
| parent | Fixed bug in page sizer. (diff) | |
| download | inkscape-bb88a2cb94ec34ee838a972bab17ca05ba92d1da.tar.gz inkscape-bb88a2cb94ec34ee838a972bab17ca05ba92d1da.zip | |
Merge Google Summer of Code unit refactor.
(bzr r12471)
Diffstat (limited to 'src/helper')
| -rw-r--r-- | src/helper/Makefile_insert | 12 | ||||
| -rw-r--r-- | src/helper/pixbuf-ops.cpp | 4 | ||||
| -rw-r--r-- | src/helper/unit-menu.cpp | 360 | ||||
| -rw-r--r-- | src/helper/unit-menu.h | 60 | ||||
| -rw-r--r-- | src/helper/unit-tracker.cpp | 267 | ||||
| -rw-r--r-- | src/helper/unit-tracker.h | 75 | ||||
| -rw-r--r-- | src/helper/units-test.h | 90 | ||||
| -rw-r--r-- | src/helper/units.cpp | 261 | ||||
| -rw-r--r-- | src/helper/units.h | 146 |
9 files changed, 2 insertions, 1273 deletions
diff --git a/src/helper/Makefile_insert b/src/helper/Makefile_insert index 790d87b14..4c6437f13 100644 --- a/src/helper/Makefile_insert +++ b/src/helper/Makefile_insert @@ -18,12 +18,6 @@ ink_common_sources += \ helper/png-write.h \ helper/sp-marshal.cpp \ helper/sp-marshal.h \ - helper/unit-menu.cpp \ - helper/unit-menu.h \ - helper/unit-tracker.cpp \ - helper/unit-tracker.h \ - helper/units.cpp \ - helper/units.h \ helper/window.cpp \ helper/window.h \ helper/stock-items.cpp \ @@ -46,9 +40,3 @@ helper/sp-marshal.cpp: helper/sp-marshal.list helper/sp-marshal.h else mv helper/tmp.sp-marshal.cpp helper/sp-marshal.cpp; fi helper/sp-marshal.cpp helper/sp-marshal.h: helper/sp-marshal.list - -# ###################### -# ### CxxTest stuff #### -# ###################### -CXXTEST_TESTSUITES += \ - $(srcdir)/helper/units-test.h diff --git a/src/helper/pixbuf-ops.cpp b/src/helper/pixbuf-ops.cpp index 9cd1967d8..75c002c57 100644 --- a/src/helper/pixbuf-ops.cpp +++ b/src/helper/pixbuf-ops.cpp @@ -29,7 +29,7 @@ #include "sp-root.h" #include "sp-use.h" #include "sp-defs.h" -#include "unit-constants.h" +#include "util/units.h" #include "helper/pixbuf-ops.h" @@ -121,7 +121,7 @@ GdkPixbuf *sp_generate_internal_bitmap(SPDocument *doc, gchar const */*filename* origin[Geom::X] = origin[Geom::X] + (screen[Geom::X].extent() * ((1 - padding) / 2)); origin[Geom::Y] = origin[Geom::Y] + (screen[Geom::Y].extent() * ((1 - padding) / 2)); - Geom::Scale scale( (xdpi / PX_PER_IN), (ydpi / PX_PER_IN)); + Geom::Scale scale( (xdpi / Inkscape::Util::Quantity::convert(1, "in", "px")), (ydpi / Inkscape::Util::Quantity::convert(1, "in", "px"))); Geom::Affine affine = scale * Geom::Translate(-origin * scale); /* Create ArenaItems and set transform */ diff --git a/src/helper/unit-menu.cpp b/src/helper/unit-menu.cpp deleted file mode 100644 index af07c03c1..000000000 --- a/src/helper/unit-menu.cpp +++ /dev/null @@ -1,360 +0,0 @@ -#define __SP_UNIT_MENU_C__ - -/* - * Unit selector with autupdate capability - * - * Authors: - * Lauris Kaplinski <lauris@kaplinski.com> - * bulia byak <buliabyak@users.sf.net> - * - * Copyright (C) 2000-2002 Authors - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#define noUNIT_SELECTOR_VERBOSE - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif -#include <gtk/gtk.h> -#include "helper/sp-marshal.h" -#include "helper/units.h" -#include "helper/unit-menu.h" -#include "widgets/spw-utilities.h" - -struct SPUnitSelector { - GtkHBox box; - - GtkWidget *combo_box; - GtkListStore *store; - - - guint bases; - GSList *units; - SPUnit const *unit; - gdouble ctmscale; - guint plural : 1; - guint abbr : 1; - - guint update : 1; - - GSList *adjustments; -}; - -enum {COMBO_COL_LABEL=0, COMBO_COL_UNIT}; - -struct SPUnitSelectorClass { - GtkHBoxClass parent_class; - - gboolean (* set_unit)(SPUnitSelector *us, SPUnit const *old, SPUnit const *new_unit); -}; - -enum {SET_UNIT, LAST_SIGNAL}; - -static void sp_unit_selector_finalize(GObject *object); - -static guint signals[LAST_SIGNAL] = {0}; - -G_DEFINE_TYPE(SPUnitSelector, sp_unit_selector, GTK_TYPE_HBOX); - -static void -sp_unit_selector_class_init(SPUnitSelectorClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS(klass); - - signals[SET_UNIT] = g_signal_new("set_unit", - G_TYPE_FROM_CLASS(klass), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET(SPUnitSelectorClass, set_unit), - NULL, NULL, - sp_marshal_BOOLEAN__POINTER_POINTER, - G_TYPE_BOOLEAN, 2, - G_TYPE_POINTER, G_TYPE_POINTER); - - object_class->finalize = sp_unit_selector_finalize; -} - -static void -sp_unit_selector_init(SPUnitSelector *us) -{ - us->ctmscale = 1.0; - us->abbr = FALSE; - us->plural = TRUE; - - /** - * Create a combo_box and store with 2 columns, - * a label and a pointer to a SPUnit - */ - us->store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_POINTER); - us->combo_box = gtk_combo_box_new_with_model (GTK_TREE_MODEL (us->store)); - - GtkCellRenderer *renderer = gtk_cell_renderer_text_new (); - g_object_set (renderer, "scale", 0.8, "scale-set", TRUE, NULL); - gtk_cell_renderer_set_padding (renderer, 2, 0); - gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (us->combo_box), renderer, TRUE); - gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (us->combo_box), renderer, "text", COMBO_COL_LABEL, NULL); - - gtk_widget_show (us->combo_box); - gtk_box_pack_start (GTK_BOX(us), us->combo_box, TRUE, TRUE, 0); -} - -static void -sp_unit_selector_finalize(GObject *object) -{ - SPUnitSelector *selector = SP_UNIT_SELECTOR(object); - - if (selector->combo_box) { - selector->combo_box = NULL; - } - - while (selector->adjustments) { - g_object_unref(selector->adjustments->data); - selector->adjustments = g_slist_remove(selector->adjustments, selector->adjustments->data); - } - - if (selector->units) { - sp_unit_free_list(selector->units); - } - - selector->unit = NULL; - - G_OBJECT_CLASS(sp_unit_selector_parent_class)->finalize(object); -} - -GtkWidget * -sp_unit_selector_new(guint bases) -{ - SPUnitSelector *us = SP_UNIT_SELECTOR(g_object_new(SP_TYPE_UNIT_SELECTOR, NULL)); - - sp_unit_selector_set_bases(us, bases); - - return GTK_WIDGET(us); -} - -void -sp_unit_selector_setsize(GtkWidget *us, guint w, guint h) -{ - gtk_widget_set_size_request((SP_UNIT_SELECTOR(us))->combo_box, w, h); -} - -SPUnit const * -sp_unit_selector_get_unit(SPUnitSelector const *us) -{ - g_return_val_if_fail(us != NULL, NULL); - g_return_val_if_fail(SP_IS_UNIT_SELECTOR(us), NULL); - - return us->unit; -} - - -static void -on_combo_box_changed (GtkComboBox *widget, SPUnitSelector *us) -{ - GtkTreeIter iter; - if (!gtk_combo_box_get_active_iter (widget, &iter)) { - return; - } - - SPUnit const *unit = NULL; - gtk_tree_model_get (GTK_TREE_MODEL(us->store), &iter, COMBO_COL_UNIT, &unit, -1); - - g_return_if_fail(unit != NULL); - -#ifdef UNIT_SELECTOR_VERBOSE - g_print("Old unit %s new unit %s\n", us->unit->name, unit->name); -#endif - - SPUnit const *old = us->unit; - us->unit = unit; - - us->update = TRUE; - - gboolean consumed = FALSE; - g_signal_emit(G_OBJECT(us), signals[SET_UNIT], 0, old, unit, &consumed); - - if ( !consumed - && ( unit->base == old->base - || ( unit->base == SP_UNIT_ABSOLUTE && old->base == SP_UNIT_DEVICE ) - || ( old->base == SP_UNIT_ABSOLUTE && unit->base == SP_UNIT_DEVICE ) ) ) { - // Either the same base, or absolute<->device: - /* Recalculate adjustments. */ - for (GSList *l = us->adjustments; l != NULL; l = g_slist_next(l)) { - GtkAdjustment *adj = GTK_ADJUSTMENT(l->data); - gdouble val = gtk_adjustment_get_value (adj); -#ifdef UNIT_SELECTOR_VERBOSE - g_print("Old val %g ... ", val); -#endif - val = sp_convert_distance_full(val, *old, *unit); -#ifdef UNIT_SELECTOR_VERBOSE - g_print("new val %g\n", val); -#endif - gtk_adjustment_set_value (adj, val); - } - /* need to separate the value changing from the notification - * or else the unit changes can break the calculations */ - for (GSList *l = us->adjustments; l != NULL; l = g_slist_next(l)) { - gtk_adjustment_value_changed(GTK_ADJUSTMENT(l->data)); - } - } else if (!consumed && unit->base != old->base) { - /* when the base changes, signal all the adjustments to get them - * to recalculate */ - for (GSList *l = us->adjustments; l != NULL; l = g_slist_next(l)) { - g_signal_emit_by_name(G_OBJECT(l->data), "value_changed"); - } - } - - us->update = FALSE; - -} - -static void -spus_rebuild_menu(SPUnitSelector *us) -{ - - gtk_list_store_clear(us->store); - - GtkTreeIter iter; - - gint pos = 0; - gint p = 0; - for (GSList *l = us->units; l != NULL; l = l->next) { - SPUnit const *u = static_cast<SPUnit const*>(l->data); - - // use only abbreviations in the menu - // i = gtk_menu_item_new_with_label((us->abbr) ? (us->plural) ? u->abbr_plural : u->abbr : (us->plural) ? u->plural : u->name); - gtk_list_store_append (us->store, &iter); - gtk_list_store_set (us->store, &iter, COMBO_COL_LABEL, u->abbr, COMBO_COL_UNIT, (gpointer) u, -1); - - if (u == us->unit) { - pos = p; - } - - p += 1; - } - - gtk_combo_box_set_active(GTK_COMBO_BOX(us->combo_box), pos); - g_signal_connect (G_OBJECT (us->combo_box), "changed", G_CALLBACK (on_combo_box_changed), us); -} - -void -sp_unit_selector_set_bases(SPUnitSelector *us, guint bases) -{ - g_return_if_fail(us != NULL); - g_return_if_fail(SP_IS_UNIT_SELECTOR(us)); - - if (bases == us->bases) return; - - GSList *units = sp_unit_get_list(bases); - g_return_if_fail(units != NULL); - sp_unit_free_list(us->units); - us->units = units; - us->unit = static_cast<SPUnit *>(units->data); - - spus_rebuild_menu(us); -} - -void -sp_unit_selector_add_unit(SPUnitSelector *us, SPUnit const *unit, int position) -{ - if (!g_slist_find(us->units, (gpointer) unit)) { - us->units = g_slist_insert(us->units, (gpointer) unit, position); - - spus_rebuild_menu(us); - } -} - -void -sp_unit_selector_set_unit(SPUnitSelector *us, SPUnit const *unit) -{ - g_return_if_fail(us != NULL); - g_return_if_fail(SP_IS_UNIT_SELECTOR(us)); - - if (unit == NULL) { - return; // silently return, by default a newly created selector uses pt - } - if (unit == us->unit) { - return; - } - - gint const pos = g_slist_index(us->units, (gpointer) unit); - g_return_if_fail(pos >= 0); - - gtk_combo_box_set_active(GTK_COMBO_BOX(us->combo_box), pos); - - SPUnit const *old = us->unit; - us->unit = unit; - - /* Recalculate adjustments */ - for (GSList *l = us->adjustments; l != NULL; l = l->next) { - GtkAdjustment *adj = GTK_ADJUSTMENT(l->data); - gdouble const val = sp_convert_distance_full(gtk_adjustment_get_value (adj), *old, *unit); - gtk_adjustment_set_value(adj, val); - } -} - -void -sp_unit_selector_add_adjustment(SPUnitSelector *us, GtkAdjustment *adj) -{ - g_return_if_fail(us != NULL); - g_return_if_fail(SP_IS_UNIT_SELECTOR(us)); - g_return_if_fail(adj != NULL); - g_return_if_fail(GTK_IS_ADJUSTMENT(adj)); - - g_return_if_fail(!g_slist_find(us->adjustments, adj)); - - g_object_ref(adj); - us->adjustments = g_slist_prepend(us->adjustments, adj); -} - -void -sp_unit_selector_remove_adjustment(SPUnitSelector *us, GtkAdjustment *adj) -{ - g_return_if_fail(us != NULL); - g_return_if_fail(SP_IS_UNIT_SELECTOR(us)); - g_return_if_fail(adj != NULL); - g_return_if_fail(GTK_IS_ADJUSTMENT(adj)); - - g_return_if_fail(g_slist_find(us->adjustments, adj)); - - us->adjustments = g_slist_remove(us->adjustments, adj); - g_object_unref(adj); -} - -gboolean -sp_unit_selector_update_test(SPUnitSelector const *selector) -{ - g_return_val_if_fail(selector != NULL, FALSE); - g_return_val_if_fail(SP_IS_UNIT_SELECTOR(selector), FALSE); - - return selector->update; -} - -double -sp_unit_selector_get_value_in_pixels(SPUnitSelector const *selector, GtkAdjustment *adj) -{ - g_return_val_if_fail(selector != NULL, gtk_adjustment_get_value (adj)); - g_return_val_if_fail(SP_IS_UNIT_SELECTOR(selector), gtk_adjustment_get_value (adj)); - - return sp_units_get_pixels(gtk_adjustment_get_value (adj), *(selector->unit)); -} - -void -sp_unit_selector_set_value_in_pixels(SPUnitSelector *selector, GtkAdjustment *adj, double value) -{ - g_return_if_fail(selector != NULL); - g_return_if_fail(SP_IS_UNIT_SELECTOR(selector)); - - gtk_adjustment_set_value(adj, sp_pixels_get_units(value, *(selector->unit))); -} - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/helper/unit-menu.h b/src/helper/unit-menu.h deleted file mode 100644 index b3ee6bcd1..000000000 --- a/src/helper/unit-menu.h +++ /dev/null @@ -1,60 +0,0 @@ -#ifndef SP_UNIT_MENU_H -#define SP_UNIT_MENU_H - -/* - * SPUnitMenu - * - * Generic (and quite unintelligent) grid item for gnome canvas - * - * Copyright (C) Lauris Kaplinski 2000 - * - */ - -#include <glib.h> -#include <gtk/gtk.h> - -struct SPUnit; -struct SPUnitSelector; -struct SPUnitSelectorClass; - -/* Unit selector Widget */ - -#define SP_TYPE_UNIT_SELECTOR (sp_unit_selector_get_type()) -#define SP_UNIT_SELECTOR(o) (G_TYPE_CHECK_INSTANCE_CAST((o), SP_TYPE_UNIT_SELECTOR, SPUnitSelector)) -#define SP_UNIT_SELECTOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), SP_TYPE_UNIT_SELECTOR, SPUnitSelectorClass)) -#define SP_IS_UNIT_SELECTOR(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), SP_TYPE_UNIT_SELECTOR)) -#define SP_IS_UNIT_SELECTOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), SP_TYPE_UNIT_SELECTOR)) - -GType sp_unit_selector_get_type(void); - -GtkWidget *sp_unit_selector_new(guint bases); -void sp_unit_selector_setsize(GtkWidget *us, guint w, guint h); - -SPUnit const *sp_unit_selector_get_unit(SPUnitSelector const *selector); - -void sp_unit_selector_set_bases(SPUnitSelector *selector, guint bases); -void sp_unit_selector_add_unit(SPUnitSelector *selector, SPUnit const *unit, int position); - -void sp_unit_selector_set_unit(SPUnitSelector *selector, SPUnit const *unit); -void sp_unit_selector_add_adjustment(SPUnitSelector *selector, GtkAdjustment *adjustment); -void sp_unit_selector_remove_adjustment(SPUnitSelector *selector, GtkAdjustment *adjustment); - -gboolean sp_unit_selector_update_test(SPUnitSelector const *selector); - -double sp_unit_selector_get_value_in_pixels(SPUnitSelector const *selector, GtkAdjustment *adj); -void sp_unit_selector_set_value_in_pixels(SPUnitSelector *selector, GtkAdjustment *adj, double value); - - - -#endif // SP_UNIT_MENU_H - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/helper/unit-tracker.cpp b/src/helper/unit-tracker.cpp deleted file mode 100644 index 609c2f292..000000000 --- a/src/helper/unit-tracker.cpp +++ /dev/null @@ -1,267 +0,0 @@ -/* - * Inkscape::UnitTracker - Simple mediator to synchronize changes to a set - * of possible units - * - * Authors: - * Jon A. Cruz <jon@joncruz.org> - * - * Copyright (C) 2007 Jon A. Cruz - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include <gtk/gtk.h> - -#include "unit-tracker.h" -#include "ege-select-one-action.h" - -namespace Inkscape { - -enum { - COLUMN_STRING, - COLUMN_SPUNIT, - N_COLUMNS -}; - -UnitTracker::UnitTracker( guint bases ) : - _active(0), - _isUpdating(false), - _activeUnit(0), - _store(0), - _unitList(0), - _actionList(0), - _adjList(0), - _priorValues() -{ - _store = gtk_list_store_new( N_COLUMNS, G_TYPE_STRING, G_TYPE_POINTER ); - setBase( bases ); -} - -UnitTracker::~UnitTracker() -{ - if ( _unitList ) { - sp_unit_free_list( _unitList ); - } - - // Unhook weak references to GtkActions - while ( _actionList ) { - g_signal_handlers_disconnect_by_func( G_OBJECT(_actionList->data), (gpointer)_unitChangedCB, this ); - g_object_weak_unref( G_OBJECT(_actionList->data), _actionFinalizedCB, this ); - _actionList = g_slist_delete_link( _actionList, _actionList ); - } - - // Unhook wek references to GtkAdjustments - while ( _adjList ) { - g_object_weak_unref( G_OBJECT(_adjList->data), _adjustmentFinalizedCB, this ); - _adjList = g_slist_delete_link( _adjList, _adjList ); - } -} - -void UnitTracker::setBase( guint bases ) -{ - GtkTreeIter iter; - _unitList = sp_unit_get_list( bases ); - for ( GSList* cur = _unitList; cur; cur = g_slist_next(cur) ) { - SPUnit* unit = static_cast<SPUnit*>(cur->data); - gtk_list_store_append( _store, &iter ); - gtk_list_store_set( _store, &iter, COLUMN_STRING, unit->abbr, COLUMN_SPUNIT, unit, -1 ); - } - gint count = gtk_tree_model_iter_n_children( GTK_TREE_MODEL(_store), 0 ); - if ( (count > 0) && (_active > count) ) { - _setActive( count - 1 ); - } else { - _setActive( _active ); - } -} - -void UnitTracker::addUnit( SPUnitId id, gint index ) -{ - GtkTreeIter iter; - const SPUnit* percentUnit = &sp_unit_get_by_id( id ); - gtk_list_store_insert( _store, &iter, index ); - gtk_list_store_set( _store, &iter, COLUMN_STRING, percentUnit->abbr, COLUMN_SPUNIT, percentUnit, -1 ); -} - -bool UnitTracker::isUpdating() const -{ - return _isUpdating; -} - -SPUnit const* UnitTracker::getActiveUnit() const -{ - return _activeUnit; -} - -void UnitTracker::setActiveUnit( SPUnit const *unit ) -{ - if ( unit ) { - GtkTreeIter iter; - int index = 0; - gboolean found = gtk_tree_model_get_iter_first( GTK_TREE_MODEL(_store), &iter ); - while ( found ) { - SPUnit* storedUnit = 0; - gtk_tree_model_get( GTK_TREE_MODEL(_store), &iter, COLUMN_SPUNIT, &storedUnit, -1 ); - if ( storedUnit && (storedUnit->unit_id == unit->unit_id) ) { - _setActive(index); - break; - } - - found = gtk_tree_model_iter_next( GTK_TREE_MODEL(_store), &iter ); - index++; - } - } -} - -void UnitTracker::addAdjustment( GtkAdjustment* adj ) -{ - if ( !g_slist_find( _adjList, adj ) ) { - g_object_weak_ref( G_OBJECT(adj), _adjustmentFinalizedCB, this ); - _adjList = g_slist_append( _adjList, adj ); - } -} - -void UnitTracker::setFullVal( GtkAdjustment* adj, gdouble val ) -{ - _priorValues[adj] = val; -} - -GtkAction* UnitTracker::createAction( gchar const* name, gchar const* label, gchar const* tooltip ) -{ - EgeSelectOneAction* act1 = ege_select_one_action_new( name, label, tooltip, NULL, GTK_TREE_MODEL(_store) ); - ege_select_one_action_set_label_column( act1, COLUMN_STRING ); - if ( _active ) { - ege_select_one_action_set_active( act1, _active ); - } - - ege_select_one_action_set_appearance( act1, "minimal" ); - g_object_weak_ref( G_OBJECT(act1), _actionFinalizedCB, this ); - g_signal_connect( G_OBJECT(act1), "changed", G_CALLBACK( _unitChangedCB ), this ); - _actionList = g_slist_append( _actionList, act1 ); - - return GTK_ACTION(act1); -} - -void UnitTracker::_unitChangedCB( GtkAction* action, gpointer data ) -{ - if ( action && data ) { - EgeSelectOneAction* act = EGE_SELECT_ONE_ACTION(action); - gint active = ege_select_one_action_get_active( act ); - UnitTracker* self = reinterpret_cast<UnitTracker*>(data); - self->_setActive(active); - } -} - -void UnitTracker::_actionFinalizedCB( gpointer data, GObject *where_the_object_was ) -{ - if ( data && where_the_object_was ) { - UnitTracker* self = reinterpret_cast<UnitTracker*>(data); - self->_actionFinalized( where_the_object_was ); - } -} - -void UnitTracker::_adjustmentFinalizedCB( gpointer data, GObject *where_the_object_was ) -{ - if ( data && where_the_object_was ) { - UnitTracker* self = reinterpret_cast<UnitTracker*>(data); - self->_adjustmentFinalized( where_the_object_was ); - } -} - -void UnitTracker::_actionFinalized( GObject *where_the_object_was ) -{ - GSList* target = g_slist_find( _actionList, where_the_object_was ); - if ( target ) { - _actionList = g_slist_remove( _actionList, where_the_object_was ); - } else { - g_warning("Received a finalization callback for unknown object %p", where_the_object_was ); - } -} - -void UnitTracker::_adjustmentFinalized( GObject *where_the_object_was ) -{ - GSList* target = g_slist_find( _adjList, where_the_object_was ); - if ( target ) { - _adjList = g_slist_remove( _adjList, where_the_object_was ); - } else { - g_warning("Received a finalization callback for unknown object %p", where_the_object_was ); - } -} - -void UnitTracker::_setActive( gint active ) -{ - if ( active != _active || (_activeUnit == 0) ) { - gint oldActive = _active; - - GtkTreeIter iter; - gboolean found = gtk_tree_model_iter_nth_child( GTK_TREE_MODEL(_store), &iter, NULL, oldActive ); - if ( found ) { - SPUnit* unit = 0; - gtk_tree_model_get( GTK_TREE_MODEL(_store), &iter, COLUMN_SPUNIT, &unit, -1 ); - - found = gtk_tree_model_iter_nth_child( GTK_TREE_MODEL(_store), &iter, NULL, active ); - if ( found ) { - SPUnit* newUnit = 0; - gtk_tree_model_get( GTK_TREE_MODEL(_store), &iter, COLUMN_SPUNIT, &newUnit, -1 ); - _activeUnit = newUnit; - - if ( _adjList ) { - _fixupAdjustments( unit, newUnit ); - } - - } else { - g_warning("Did not find new unit"); - } - } else { - g_warning("Did not find old unit"); - } - - _active = active; - - for ( GSList* cur = _actionList; cur; cur = g_slist_next(cur) ) { - if ( IS_EGE_SELECT_ONE_ACTION( cur->data ) ) { - EgeSelectOneAction* act = EGE_SELECT_ONE_ACTION( cur->data ); - ege_select_one_action_set_active( act, active ); - } - } - } -} - -void UnitTracker::_fixupAdjustments( SPUnit const* oldUnit, SPUnit const *newUnit ) -{ - _isUpdating = true; - for ( GSList* cur = _adjList; cur; cur = g_slist_next(cur) ) { - GtkAdjustment* adj = GTK_ADJUSTMENT(cur->data); - gdouble oldVal = gtk_adjustment_get_value(adj); - gdouble val = oldVal; - - if ((oldUnit->base == SP_UNIT_ABSOLUTE || oldUnit->base == SP_UNIT_DEVICE) - && (newUnit->base == SP_UNIT_DIMENSIONLESS)) - { - val = 1.0 / newUnit->unittobase; - _priorValues[adj] = sp_units_get_pixels( oldVal, *oldUnit ); - } else if ((oldUnit->base == SP_UNIT_DIMENSIONLESS) - && (newUnit->base == SP_UNIT_ABSOLUTE || newUnit->base == SP_UNIT_DEVICE)) { - if ( _priorValues.find(adj) != _priorValues.end() ) { - val = sp_pixels_get_units( _priorValues[adj], *newUnit ); - } - } else { - val = sp_convert_distance_full( oldVal, *oldUnit, *newUnit ); - } - - gtk_adjustment_set_value( adj, val ); - } - _isUpdating = false; -} - -} - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/helper/unit-tracker.h b/src/helper/unit-tracker.h deleted file mode 100644 index a15a0a6ca..000000000 --- a/src/helper/unit-tracker.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Inkscape::UnitTracker - Simple mediator to synchronize changes to a set - * of possible units - * - * Authors: - * Jon A. Cruz <jon@joncruz.org> - * - * Copyright (C) 2007 Jon A. Cruz - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#ifndef SEEN_INKSCAPE_UNIT_TRACKER_H -#define SEEN_INKSCAPE_UNIT_TRACKER_H - -#include <map> - -#include <gtk/gtk.h> - -#include "helper/units.h" - -namespace Inkscape { - -class UnitTracker -{ -public: - UnitTracker( guint bases = (SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE) ); - virtual ~UnitTracker(); - - void setBase( guint bases ); // SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE - void addUnit( SPUnitId id, gint index ); - - bool isUpdating() const; - - void setActiveUnit( SPUnit const *unit ); - SPUnit const* getActiveUnit() const; - - void addAdjustment( GtkAdjustment* adj ); - void setFullVal( GtkAdjustment* adj, gdouble val ); - - GtkAction* createAction( gchar const* name, gchar const* label, gchar const* tooltip ); - -private: - static void _unitChangedCB( GtkAction* action, gpointer data ); - static void _actionFinalizedCB( gpointer data, GObject *where_the_object_was ); - static void _adjustmentFinalizedCB( gpointer data, GObject *where_the_object_was ); - void _setActive( gint index ); - void _fixupAdjustments( SPUnit const* oldUnit, SPUnit const *newUnit ); - void _actionFinalized( GObject *where_the_object_was ); - void _adjustmentFinalized( GObject *where_the_object_was ); - - gint _active; - bool _isUpdating; - SPUnit* _activeUnit; - GtkListStore* _store; - GSList* _unitList; - GSList* _actionList; - GSList* _adjList; - std::map <GtkAdjustment*, gdouble> _priorValues; -}; - -} - -#endif // SEEN_INKSCAPE_UNIT_TRACKER_H - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/helper/units-test.h b/src/helper/units-test.h deleted file mode 100644 index 05bc75eff..000000000 --- a/src/helper/units-test.h +++ /dev/null @@ -1,90 +0,0 @@ -#include <cxxtest/TestSuite.h> - -#include <helper/units.h> -#include <glibmm/i18n.h> -#include <math.h> - -class UnitsTest : public CxxTest::TestSuite { -public: - - UnitsTest() - { - } - virtual ~UnitsTest() {} - -// createSuite and destroySuite get us per-suite setup and teardown -// without us having to worry about static initialization order, etc. - static UnitsTest *createSuite() { return new UnitsTest(); } - static void destroySuite( UnitsTest *suite ) { delete suite; } - - void testConversions() - { - struct Case { double x; char const *abbr; double pts; } const tests[] = { - { 1.0, "pt", 1.0 }, - { 5.0, "pt", 5.0 }, - { 1.0, "in", 72.0 }, - { 2.0, "in", 144.0 }, - { 254., "mm", 720.0 }, - { 254., "cm", 7200. }, - { 254., "m", 720000. }, - { 1.5, "mm", (15 * 72. / 254) } - }; - for (unsigned i = 0; i < G_N_ELEMENTS(tests); ++i) { - Case const &c = tests[i]; - SPUnit const &unit = *sp_unit_get_by_abbreviation(N_(c.abbr)); - - double const calc_pts = sp_units_get_points(c.x, unit); - TS_ASSERT(approx_equal(calc_pts, c.pts)); - - double const calc_x = sp_points_get_units(c.pts, unit); - TS_ASSERT(approx_equal(calc_x, c.x)); - - double tmp = c.x; - bool const converted_to_pts = sp_convert_distance(&tmp, &unit, SP_PS_UNIT); - TS_ASSERT(converted_to_pts); - TS_ASSERT(approx_equal(tmp, c.pts)); - - tmp = c.pts; - bool const converted_from_pts = sp_convert_distance(&tmp, SP_PS_UNIT, &unit); - TS_ASSERT(converted_from_pts); - TS_ASSERT(approx_equal(tmp, c.x)); - } - } - - void testUnitTable() - { - TS_ASSERT(sp_units_table_sane()); - } - -private: - /* N.B. Wrongly returns false if both near 0. (Not a problem for current users.) */ - bool approx_equal(double const x, double const y) - { - return fabs(x / y - 1) < 1e-15; - } - - double sp_units_get_points(double const x, SPUnit const &unit) - { - SPUnit const &pt_unit = sp_unit_get_by_id(SP_UNIT_PT); - double const px = sp_units_get_pixels(x, unit); - return sp_pixels_get_units(px, pt_unit); - } - - double sp_points_get_units(double const pts, SPUnit const &unit) - { - SPUnit const &pt_unit = sp_unit_get_by_id(SP_UNIT_PT); - double const px = sp_units_get_pixels(pts, pt_unit); - return sp_pixels_get_units(px, unit); - } -}; - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/helper/units.cpp b/src/helper/units.cpp deleted file mode 100644 index 1593fc131..000000000 --- a/src/helper/units.cpp +++ /dev/null @@ -1,261 +0,0 @@ -#define __SP_PAPER_C__ - -/* - * SPUnit - * - * Ported from libgnomeprint - * - * Authors: - * Dirk Luetjens <dirk@luedi.oche.de> - * Yves Arrouye <Yves.Arrouye@marin.fdn.fr> - * Lauris Kaplinski <lauris@ximian.com> - * bulia byak <buliabyak@users.sf.net> - * - * Copyright 1999-2001 Ximian, Inc. and authors - * - */ - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#include "helper/units.h" -#include <glib.h> // g_assert() -#include <glibmm/i18n.h> -#include "unit-constants.h" -#include "svg/svg-length.h" - -/* todo: use some fancy unit program */ - -/* The order determines the order of the list returned by sp_unit_get_list. - * (It can also affect string lookups if there are any duplicates in the - * current locale... hopefully none.) If you re-order this list, then you must - * also re-order the SPUnitId enum values accordingly. Run `make check' (which - * calls sp_unit_table_sane) to ensure that the two are in sync. - */ -SPUnit const sp_units[] = { - {SP_UNIT_SCALE, SP_UNIT_DIMENSIONLESS, 1.0, SP_NONE, SVGLength::NONE, N_("Unit"), "", N_("Units"), ""}, - {SP_UNIT_PT, SP_UNIT_ABSOLUTE, PX_PER_PT, SP_PT, SVGLength::PT, N_("Point"), N_("pt"), N_("Points"), N_("Pt")}, - {SP_UNIT_PC, SP_UNIT_ABSOLUTE, PX_PER_PC, SP_PC, SVGLength::PC, N_("Pica"), N_("pc"), N_("Picas"), N_("Pc")}, - {SP_UNIT_PX, SP_UNIT_DEVICE, PX_PER_PX, SP_PX, SVGLength::PX, N_("Pixel"), N_("px"), N_("Pixels"), N_("Px")}, - /* You can add new elements from this point forward */ - {SP_UNIT_PERCENT, SP_UNIT_DIMENSIONLESS, 0.01, SP_NONE, SVGLength::PERCENT, N_("Percent"), N_("%"), N_("Percents"), N_("%")}, - {SP_UNIT_MM, SP_UNIT_ABSOLUTE, PX_PER_MM, SP_MM, SVGLength::MM, N_("Millimeter"), N_("mm"), N_("Millimeters"), N_("mm")}, - {SP_UNIT_CM, SP_UNIT_ABSOLUTE, PX_PER_CM, SP_CM, SVGLength::CM, N_("Centimeter"), N_("cm"), N_("Centimeters"), N_("cm")}, - {SP_UNIT_M, SP_UNIT_ABSOLUTE, PX_PER_M, SP_M, SVGLength::NONE, N_("Meter"), N_("m"), N_("Meters"), N_("m")}, // no svg_unit - {SP_UNIT_IN, SP_UNIT_ABSOLUTE, PX_PER_IN, SP_IN, SVGLength::INCH, N_("Inch"), N_("in"), N_("Inches"), N_("in")}, - {SP_UNIT_FT, SP_UNIT_ABSOLUTE, PX_PER_FT, SP_FT, SVGLength::FOOT, N_("Foot"), N_("ft"), N_("Feet"), N_("ft")}, - /* Volatiles do not have default, so there are none here */ - // TRANSLATORS: for info, see http://www.w3.org/TR/REC-CSS2/syndata.html#length-units - {SP_UNIT_EM, SP_UNIT_VOLATILE, 1.0, SP_NONE, SVGLength::EM, N_("Em square"), N_("em"), N_("Em squares"), N_("em")}, - // TRANSLATORS: for info, see http://www.w3.org/TR/REC-CSS2/syndata.html#length-units - {SP_UNIT_EX, SP_UNIT_VOLATILE, 1.0, SP_NONE, SVGLength::EX, N_("Ex square"), N_("ex"), N_("Ex squares"), N_("ex")}, -}; - -#define sp_num_units G_N_ELEMENTS(sp_units) - -SPUnit const * -sp_unit_get_by_abbreviation(gchar const *abbreviation) -{ - g_return_val_if_fail(abbreviation != NULL, NULL); - - for (unsigned i = 0 ; i < sp_num_units ; i++) { - if (!g_ascii_strcasecmp(abbreviation, sp_units[i].abbr)) return &sp_units[i]; - if (!g_ascii_strcasecmp(abbreviation, sp_units[i].abbr_plural)) return &sp_units[i]; - } - - return NULL; -} - -gchar const * -sp_unit_get_abbreviation(SPUnit const *unit) -{ - g_return_val_if_fail(unit != NULL, NULL); - - return unit->abbr; -} - -gchar const * -sp_unit_get_plural (SPUnit const *unit) -{ - g_return_val_if_fail(unit != NULL, NULL); - - return unit->plural; -} - -SPMetric sp_unit_get_metric(SPUnit const *unit) -{ - g_return_val_if_fail(unit != NULL, SP_NONE); - - return unit->metric; -} - -guint sp_unit_get_svg_unit(SPUnit const *unit) -{ - g_return_val_if_fail(unit != NULL, SP_NONE); - - return unit->svg_unit; -} - -GSList * -sp_unit_get_list(guint bases) -{ - g_return_val_if_fail((bases & ~SP_UNITS_ALL) == 0, NULL); - - GSList *units = NULL; - for (unsigned i = sp_num_units ; i--; ) { - if (bases & sp_units[i].base) { - units = g_slist_prepend(units, (gpointer) &sp_units[i]); - } - } - - return units; -} - -void -sp_unit_free_list(GSList *units) -{ - g_slist_free(units); -} - -/* These are pure utility */ -/* Return TRUE if conversion is possible */ -gboolean -sp_convert_distance(gdouble *distance, SPUnit const *from, SPUnit const *to) -{ - g_return_val_if_fail(distance != NULL, FALSE); - g_return_val_if_fail(from != NULL, FALSE); - g_return_val_if_fail(to != NULL, FALSE); - - if (from == to) return TRUE; - if ((from->base == SP_UNIT_DIMENSIONLESS) || (to->base == SP_UNIT_DIMENSIONLESS)) { - *distance = *distance * from->unittobase / to->unittobase; - return TRUE; - } - if ((from->base == SP_UNIT_VOLATILE) || (to->base == SP_UNIT_VOLATILE)) return FALSE; - - if ((from->base == to->base) - || ((from->base == SP_UNIT_DEVICE) && (to->base == SP_UNIT_ABSOLUTE)) - || ((from->base == SP_UNIT_ABSOLUTE) && (to->base == SP_UNIT_DEVICE))) - { - *distance = *distance * from->unittobase / to->unittobase; - return TRUE; - } - - return FALSE; -} - -/** @param devicetransform for device units. */ -/* TODO: Remove the ctmscale parameter given that we no longer have SP_UNIT_USERSPACE. */ -gdouble -sp_convert_distance_full(gdouble const from_dist, SPUnit const &from, SPUnit const &to) -{ - if (&from == &to) { - return from_dist; - } - if (from.base == to.base) { - gdouble ret = from_dist; - bool const succ = sp_convert_distance(&ret, &from, &to); - g_assert(succ); - return ret; - } - if ((from.base == SP_UNIT_DIMENSIONLESS) - || (to.base == SP_UNIT_DIMENSIONLESS)) - { - return from_dist * from.unittobase / to.unittobase; - } - g_return_val_if_fail(((from.base != SP_UNIT_VOLATILE) - && (to.base != SP_UNIT_VOLATILE)), - from_dist); - - gdouble absolute; - switch (from.base) { - case SP_UNIT_ABSOLUTE: - case SP_UNIT_DEVICE: - absolute = from_dist * from.unittobase; - break; - default: - g_warning("file %s: line %d: Illegal unit (base 0x%x)", __FILE__, __LINE__, from.base); - return from_dist; - } - - gdouble ret; - switch (to.base) { - default: - g_warning("file %s: line %d: Illegal unit (base 0x%x)", __FILE__, __LINE__, to.base); - /* FALL-THROUGH */ - case SP_UNIT_ABSOLUTE: - case SP_UNIT_DEVICE: - ret = absolute / to.unittobase; - break; - } - - return ret; -} - -/* Some more convenience */ - -gdouble -sp_units_get_pixels(gdouble const units, SPUnit const &unit) -{ - if (unit.base == SP_UNIT_ABSOLUTE || unit.base == SP_UNIT_DEVICE) { - return units * unit.unittobase; - } else { - g_warning("Different unit bases: No exact unit conversion available"); - return units * unit.unittobase; - } -} - -gdouble -sp_pixels_get_units(gdouble const pixels, SPUnit const &unit) -{ - if (unit.base == SP_UNIT_ABSOLUTE || unit.base == SP_UNIT_DEVICE) { - return pixels / unit.unittobase; - } else { - g_warning("Different unit bases: No exact unit conversion available"); - return pixels / unit.unittobase; - } -} - -bool -sp_units_table_sane() -{ - for (unsigned i = 0; i < G_N_ELEMENTS(sp_units); ++i) { - if (unsigned(sp_units[i].unit_id) != i) { - return false; - } - } - return true; -} - -/** Converts angle (in deg) to compass display */ -double -angle_to_compass(double angle) -{ - double ret = 90 - angle; - if (ret < 0) - ret = 360 + ret; - return ret; -} - -/** Converts angle (in deg) to compass display */ -double -angle_from_compass(double angle) -{ - double ret = 90 - angle; - if (ret > 180) - ret = ret - 180; - return ret; -} - - -/* - Local Variables: - mode:c++ - c-file-style:"stroustrup" - c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) - indent-tabs-mode:nil - fill-column:99 - End: -*/ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : diff --git a/src/helper/units.h b/src/helper/units.h deleted file mode 100644 index 93bd70615..000000000 --- a/src/helper/units.h +++ /dev/null @@ -1,146 +0,0 @@ -#ifndef __SP_UNIT_H__ -#define __SP_UNIT_H__ - -/* - * SPUnit - * - * Ported from libgnomeprint - * - * Authors: - * Dirk Luetjens <dirk@luedi.oche.de> - * Yves Arrouye <Yves.Arrouye@marin.fdn.fr> - * Lauris Kaplinski <lauris@ximian.com> - * - * Copyright 1999-2001 Ximian, Inc. and authors - * - */ - -#include <glib.h> -#include "sp-metric.h" - - -/* - * Units and conversion methods used by libgnomeprint. - * - * You need those for certain config keys (like paper size), if you are - * interested in using these (look at gnome-print-config.h for discussion, - * why you may NOT be interested in paper size). - * - * Unit bases define set of mutually unrelated measuring systems (numbers, - * paper, screen and dimesionless user coordinates). Still, you can convert - * between those, specifying scaling factors explicitly. - * - * Paper (i.e. output) coordinates are taken as absolute real world units. - * It has some justification, because screen unit (pixel) size changes, - * if you change screen resolution, while you cannot change output on paper - * as easily (unless you have thermally contracting paper, of course). - * - */ - -struct SPUnit; -struct SPDistance; - -/* - * The base linear ("absolute") unit is 1/72th of an inch, i.e. the base unit of postscript. - */ - -/* - * Unit bases - */ -enum SPUnitBase { - SP_UNIT_DIMENSIONLESS = (1 << 0), /* For percentages and like */ - SP_UNIT_ABSOLUTE = (1 << 1), /* Real world distances - i.e. mm, cm... */ - SP_UNIT_DEVICE = (1 << 2), /* Pixels in the SVG/CSS sense. */ - SP_UNIT_VOLATILE = (1 << 3) /* em and ex */ -}; - -/* - * Units: indexes into sp_units. - */ -enum SPUnitId { - SP_UNIT_SCALE, // 1.0 == 100% - SP_UNIT_PT, // Postscript points: exactly 72 per inch - SP_UNIT_PC, // Pica; there are 12 points per pica - SP_UNIT_PX, // "Pixels" in the CSS sense; though Inkscape assumes a constant 90 per inch. - SP_UNIT_PERCENT, /* Note: In Inkscape this often means "relative to current value" (for - users to edit a value), rather than the SVG/CSS use of percentages. */ - SP_UNIT_MM, // millimetres - SP_UNIT_CM, // centimetres - SP_UNIT_M, // metres - SP_UNIT_IN, // inches - SP_UNIT_FT, // foot - SP_UNIT_EM, // font-size of relevant font - SP_UNIT_EX, // x-height of relevant font - sp_max_unit_id = SP_UNIT_EX // For bounds-checking in sp_unit_get_by_id. -}; - -/* - * Notice, that for correct menus etc. you have to use - * ngettext method family yourself. For that reason we - * do not provide translations in unit names. - * I also do not know, whether to allow user-created units, - * because this would certainly confuse textdomain. - */ - -struct SPUnit { - SPUnitId unit_id; /* used as sanity check */ - SPUnitBase base; - gdouble unittobase; /* how many base units in this unit */ - SPMetric metric; // the corresponding SPMetric from sp-metrics.h - guint svg_unit; // the corresponding SVGLengthUnit - - /* When using, you must call "gettext" on them so they're translated */ - gchar const *name; - gchar const *abbr; - gchar const *plural; - gchar const *abbr_plural; -}; - -const SPUnit *sp_unit_get_by_abbreviation (const gchar *abbreviation); -/* When using, you must call "gettext" on them so they're translated */ -const gchar *sp_unit_get_abbreviation (const SPUnit *unit); -gchar const *sp_unit_get_plural (SPUnit const *unit); - -SPMetric sp_unit_get_metric(SPUnit const *unit); -guint sp_unit_get_svg_unit(SPUnit const *unit); - -extern SPUnit const sp_units[]; - -inline SPUnit const & -sp_unit_get_by_id(SPUnitId const id) -{ - /* inline because the compiler should optimize away the g_return_val_if_fail test in the - usual case that the argument value is known at compile-time, leaving just - "return sp_units[constant]". */ - unsigned const ix = unsigned(id); - g_return_val_if_fail(ix <= sp_max_unit_id, sp_units[SP_UNIT_PX]); - return sp_units[ix]; -} - -#define SP_PS_UNIT (&sp_unit_get_by_id(SP_UNIT_PT)) - - -/** Used solely by units-test.cpp. */ -bool sp_units_table_sane(); - -#define SP_UNITS_ALL (SP_UNIT_DIMENSIONLESS | SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE | SP_UNIT_VOLATILE) - -GSList *sp_unit_get_list (guint bases); -void sp_unit_free_list (GSList *units); - -/* These are pure utility */ -/* Return TRUE if conversion is possible, FALSE if unit bases differ */ -gboolean sp_convert_distance (gdouble *distance, const SPUnit *from, const SPUnit *to); - -/* If either one is NULL, transconverting to/from that base fails */ -/* Generic conversion between volatile units would be useless anyways */ -gdouble sp_convert_distance_full(gdouble const from_dist, SPUnit const &from, SPUnit const &to); - -/* Some more convenience */ -gdouble sp_units_get_pixels(gdouble const units, SPUnit const &unit); -gdouble sp_pixels_get_units(gdouble const pixels, SPUnit const &unit); - -double angle_to_compass(double angle); -double angle_from_compass(double angle); - -#endif |
