summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohan B. C. Engelen <jbc.engelen@swissonline.ch>2007-12-16 18:24:26 +0000
committerjohanengelen <johanengelen@users.sourceforge.net>2007-12-16 18:24:26 +0000
commit036d68d2970a3b4239f0aab343835e5104e61de8 (patch)
tree2549b1a61e4273b661851a82e15be064dc5b70e5 /src
parentprevent writing to xml when initializing grid. fixes not working default units. (diff)
downloadinkscape-036d68d2970a3b4239f0aab343835e5104e61de8.tar.gz
inkscape-036d68d2970a3b4239f0aab343835e5104e61de8.zip
fix default grid unit scaling, fix crash for unknown unit.
(bzr r4240)
Diffstat (limited to 'src')
-rw-r--r--src/display/canvas-axonomgrid.cpp12
-rw-r--r--src/display/canvas-grid.cpp12
2 files changed, 14 insertions, 10 deletions
diff --git a/src/display/canvas-axonomgrid.cpp b/src/display/canvas-axonomgrid.cpp
index 7fdc24192..33592a3f8 100644
--- a/src/display/canvas-axonomgrid.cpp
+++ b/src/display/canvas-axonomgrid.cpp
@@ -195,16 +195,18 @@ attach_all(Gtk::Table &table, Gtk::Widget const *const arr[], unsigned size, int
CanvasAxonomGrid::CanvasAxonomGrid (SPNamedView * nv, Inkscape::XML::Node * in_repr, SPDocument * in_doc)
: CanvasGrid(nv, in_repr, in_doc, GRID_AXONOMETRIC), table(1, 1)
{
- origin[NR::X] = prefs_get_double_attribute ("options.grids.axonom", "origin_x", 0.0);
- origin[NR::Y] = prefs_get_double_attribute ("options.grids.axonom", "origin_y", 0.0);
+ gridunit = sp_unit_get_by_abbreviation( prefs_get_string_attribute("options.grids.axonom", "units") );
+ if (!gridunit)
+ gridunit = &sp_unit_get_by_id(SP_UNIT_PX);
+ origin[NR::X] = sp_units_get_pixels( prefs_get_double_attribute ("options.grids.axonom", "origin_x", 0.0), *(gridunit) );
+ origin[NR::Y] = sp_units_get_pixels( prefs_get_double_attribute ("options.grids.axonom", "origin_y", 0.0), *(gridunit) );
color = prefs_get_int_attribute("options.grids.axonom", "color", 0x0000ff20);
empcolor = prefs_get_int_attribute("options.grids.axonom", "empcolor", 0x0000ff40);
empspacing = prefs_get_int_attribute("options.grids.axonom", "empspacing", 5);
- gridunit = sp_unit_get_by_abbreviation( prefs_get_string_attribute("options.grids.axonom", "units") );
- lengthy = prefs_get_double_attribute ("options.grids.axonom", "spacing_y", 1.0);
+ lengthy = sp_units_get_pixels( prefs_get_double_attribute ("options.grids.axonom", "spacing_y", 1.0), *(gridunit) );
angle_deg[X] = prefs_get_double_attribute ("options.grids.axonom", "angle_x", 30.0);
angle_deg[Z] = prefs_get_double_attribute ("options.grids.axonom", "angle_z", 30.0);
- angle_deg[Y] =0;
+ angle_deg[Y] = 0;
angle_rad[X] = deg_to_rad(angle_deg[X]);
tan_angle[X] = tan(angle_rad[X]);
diff --git a/src/display/canvas-grid.cpp b/src/display/canvas-grid.cpp
index ce30960fb..021a62f96 100644
--- a/src/display/canvas-grid.cpp
+++ b/src/display/canvas-grid.cpp
@@ -391,14 +391,16 @@ attach_all(Gtk::Table &table, Gtk::Widget const *const arr[], unsigned size, int
CanvasXYGrid::CanvasXYGrid (SPNamedView * nv, Inkscape::XML::Node * in_repr, SPDocument * in_doc)
: CanvasGrid(nv, in_repr, in_doc, GRID_RECTANGULAR), table(1, 1)
{
- origin[NR::X] = prefs_get_double_attribute ("options.grids.xy", "origin_x", 0.0);
- origin[NR::Y] = prefs_get_double_attribute ("options.grids.xy", "origin_y", 0.0);
+ gridunit = sp_unit_get_by_abbreviation( prefs_get_string_attribute("options.grids.xy", "units") );
+ if (!gridunit)
+ gridunit = &sp_unit_get_by_id(SP_UNIT_PX);
+ origin[NR::X] = sp_units_get_pixels( prefs_get_double_attribute ("options.grids.xy", "origin_x", 0.0), *(gridunit) );
+ origin[NR::Y] = sp_units_get_pixels( prefs_get_double_attribute ("options.grids.xy", "origin_y", 0.0), *(gridunit) );
color = prefs_get_int_attribute("options.grids.xy", "color", 0x0000ff20);
empcolor = prefs_get_int_attribute("options.grids.xy", "empcolor", 0x0000ff40);
empspacing = prefs_get_int_attribute("options.grids.xy", "empspacing", 5);
- spacing[NR::X] = prefs_get_double_attribute ("options.grids.xy", "spacing_x", 0.0);
- spacing[NR::Y] = prefs_get_double_attribute ("options.grids.xy", "spacing_y", 0.0);
- gridunit = sp_unit_get_by_abbreviation( prefs_get_string_attribute("options.grids.xy", "units") );
+ spacing[NR::X] = sp_units_get_pixels( prefs_get_double_attribute ("options.grids.xy", "spacing_x", 0.0), *(gridunit) );
+ spacing[NR::Y] = sp_units_get_pixels( prefs_get_double_attribute ("options.grids.xy", "spacing_y", 0.0), *(gridunit) );
render_dotted = prefs_get_int_attribute ("options.grids.xy", "dotted", 0) == 1;
snapper = new CanvasXYGridSnapper(this, namedview, 0);