diff options
| author | Johan B. C. Engelen <jbc.engelen@swissonline.ch> | 2011-12-20 22:07:22 +0000 |
|---|---|---|
| committer | Johan Engelen <goejendaagh@zonnet.nl> | 2011-12-20 22:07:22 +0000 |
| commit | 14b6891e5d84dc76829749d888e9dd769c037ebb (patch) | |
| tree | 1690b0f2187e754a3fed3ecbe2ef2a94c4af3eba /src/display/canvas-grid.cpp | |
| parent | fix bug in emphasized line drawing for axonometric grid when origin is not zero (diff) | |
| download | inkscape-14b6891e5d84dc76829749d888e9dd769c037ebb.tar.gz inkscape-14b6891e5d84dc76829749d888e9dd769c037ebb.zip | |
when resizing page, move the origin of the grids too. This way all objects will stay aligned to the grids.
(bzr r10787)
Diffstat (limited to 'src/display/canvas-grid.cpp')
| -rw-r--r-- | src/display/canvas-grid.cpp | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/display/canvas-grid.cpp b/src/display/canvas-grid.cpp index 8428a277e..734ce2043 100644 --- a/src/display/canvas-grid.cpp +++ b/src/display/canvas-grid.cpp @@ -28,6 +28,7 @@ #include "sp-namedview.h" #include "sp-object.h" #include "svg/svg-color.h" +#include "svg/stringstream.h" #include "util/mathfns.h" #include "xml/node-event-vector.h" @@ -377,6 +378,22 @@ bool CanvasGrid::isEnabled() return snapper->getEnabled(); } +void CanvasGrid::setOrigin(Geom::Point const &origin_px) +{ + Inkscape::SVGOStringStream os_x, os_y; + gdouble val; + + val = origin_px[Geom::X]; + val = sp_pixels_get_units (val, *gridunit); + os_x << val << sp_unit_get_abbreviation(gridunit); + val = origin_px[Geom::Y]; + val = sp_pixels_get_units (val, *gridunit); + os_y << val << sp_unit_get_abbreviation(gridunit); + repr->setAttribute("originx", os_x.str().c_str()); + repr->setAttribute("originy", os_y.str().c_str()); +} + + // ########################################################## // CanvasXYGrid @@ -427,8 +444,9 @@ CanvasXYGrid::CanvasXYGrid (SPNamedView * nv, Inkscape::XML::Node * in_repr, SPD { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); gridunit = sp_unit_get_by_abbreviation( prefs->getString("/options/grids/xy/units").data() ); - if (!gridunit) + if (!gridunit) { gridunit = &sp_unit_get_by_id(SP_UNIT_PX); + } origin[Geom::X] = sp_units_get_pixels(prefs->getDouble("/options/grids/xy/origin_x", 0.0), *gridunit); origin[Geom::Y] = sp_units_get_pixels(prefs->getDouble("/options/grids/xy/origin_y", 0.0), *gridunit); color = prefs->getInt("/options/grids/xy/color", 0x0000ff20); |
