Code

old default color values restored
[inkscape.git] / src / display / canvas-grid.cpp
1 #define INKSCAPE_CANVAS_GRID_C
3 /*
4  *
5  * Copyright (C) Johan Engelen 2006-2007 <johan@shouraizou.nl>
6  * Copyright (C) Lauris Kaplinski 2000
7  *
8  */
11 #include "sp-canvas-util.h"
12 #include "display-forward.h"
13 #include <libnr/nr-pixops.h>
14 #include "desktop-handles.h"
15 #include "helper/units.h"
16 #include "svg/svg-color.h"
17 #include "xml/node-event-vector.h"
18 #include "sp-object.h"
20 #include "sp-namedview.h"
21 #include "inkscape.h"
22 #include "desktop.h"
24 #include "../document.h"
26 #include "canvas-grid.h"
27 #include "canvas-axonomgrid.h"
29 namespace Inkscape {
31 #define DEFAULTGRIDCOLOR    0x0000FF20
32 #define DEFAULTGRIDEMPCOLOR 0x0000FF40
35 static void grid_canvasitem_class_init (GridCanvasItemClass *klass);
36 static void grid_canvasitem_init (GridCanvasItem *grid);
37 static void grid_canvasitem_destroy (GtkObject *object);
39 static void grid_canvasitem_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags);
40 static void grid_canvasitem_render (SPCanvasItem *item, SPCanvasBuf *buf);
42 static SPCanvasItemClass * parent_class;
44 GtkType
45 grid_canvasitem_get_type (void)
46 {
47     static GtkType grid_canvasitem_type = 0;
49     if (!grid_canvasitem_type) {
50         GtkTypeInfo grid_canvasitem_info = {
51             "GridCanvasItem",
52             sizeof (GridCanvasItem),
53             sizeof (GridCanvasItemClass),
54             (GtkClassInitFunc) grid_canvasitem_class_init,
55             (GtkObjectInitFunc) grid_canvasitem_init,
56             NULL, NULL,
57             (GtkClassInitFunc) NULL
58         };
59         grid_canvasitem_type = gtk_type_unique (sp_canvas_item_get_type (), &grid_canvasitem_info);
60     }
61     return grid_canvasitem_type;
62 }
64 static void
65 grid_canvasitem_class_init (GridCanvasItemClass *klass)
66 {
67     GtkObjectClass *object_class;
68     SPCanvasItemClass *item_class;
70     object_class = (GtkObjectClass *) klass;
71     item_class = (SPCanvasItemClass *) klass;
73     parent_class = (SPCanvasItemClass*)gtk_type_class (sp_canvas_item_get_type ());
75     object_class->destroy = grid_canvasitem_destroy;
77     item_class->update = grid_canvasitem_update;
78     item_class->render = grid_canvasitem_render;
79 }
81 static void
82 grid_canvasitem_init (GridCanvasItem *griditem)
83 {
84     griditem->grid = NULL;
85 }
87 static void
88 grid_canvasitem_destroy (GtkObject *object)
89 {
90     g_return_if_fail (object != NULL);
91     g_return_if_fail (INKSCAPE_IS_GRID_CANVASITEM (object));
93     if (GTK_OBJECT_CLASS (parent_class)->destroy)
94         (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
95 }
97 /**
98 */
99 static void
100 grid_canvasitem_render (SPCanvasItem * item, SPCanvasBuf * buf)
102     GridCanvasItem *gridcanvasitem = INKSCAPE_GRID_CANVASITEM (item);
104     sp_canvas_prepare_buffer (buf);
106     if (gridcanvasitem->grid) gridcanvasitem->grid->Render(buf);
109 static void
110 grid_canvasitem_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags)
112     GridCanvasItem *gridcanvasitem = INKSCAPE_GRID_CANVASITEM (item);
114     if (parent_class->update)
115         (* parent_class->update) (item, affine, flags);
117     if (gridcanvasitem->grid) {
118         gridcanvasitem->grid->Update(affine, flags);
120         sp_canvas_request_redraw (item->canvas,
121                          -1000000, -1000000,
122                          1000000, 1000000);
124         item->x1 = item->y1 = -1000000;
125         item->x2 = item->y2 = 1000000;
126     }
131 // ##########################################################
132 //   CanvasGrid
134     static Inkscape::XML::NodeEventVector const _repr_events = {
135         NULL, /* child_added */
136         NULL, /* child_removed */
137         CanvasGrid::on_repr_attr_changed,
138         NULL, /* content_changed */
139         NULL  /* order_changed */
140     };
142 CanvasGrid::CanvasGrid(SPNamedView * nv, Inkscape::XML::Node * in_repr)
144     repr = in_repr;
145     if (repr) {
146         repr->addListener (&_repr_events, this);
147     }
149     namedview = nv;
150     canvasitems = NULL;
153 CanvasGrid::~CanvasGrid()
155     if (repr) {
156         repr->removeListenerByData (this);
157     }
159     while (canvasitems) {
160         gtk_object_destroy(GTK_OBJECT(canvasitems->data));
161         canvasitems = g_slist_remove(canvasitems, canvasitems->data);
162     }
165 /*
166 *  writes an <inkscape:grid> child to repr.
167 */
168 void
169 CanvasGrid::writeNewGridToRepr(Inkscape::XML::Node * repr, const char * gridtype)
171     if (!repr) return;
172     if (!gridtype) return;
174     // first create the child xml node, then hook it to repr. This order is important, to not set off listeners to repr before the new node is complete.
176     Inkscape::XML::Document *xml_doc = sp_document_repr_doc(sp_desktop_document(SP_ACTIVE_DESKTOP));
177     Inkscape::XML::Node *newnode;
178     newnode = xml_doc->createElement("inkscape:grid");
179     newnode->setAttribute("type",gridtype);
181     repr->appendChild(newnode);
183     // FIXME: add this to history?
184 //    sp_document_done(current_document, SP_VERB_DIALOG_XML_EDITOR,
185 //                     _("Create new element node"));
188 /*
189 * Creates a new CanvasGrid object of type gridtype
190 */
191 CanvasGrid*
192 CanvasGrid::NewGrid(SPNamedView * nv, Inkscape::XML::Node * in_repr, const char * gridtype)
194     if (!in_repr) return NULL;
195     if (!gridtype) return NULL;
197     if (!strcmp(gridtype,"xygrid")) {
198         return (CanvasGrid*) new CanvasXYGrid(nv, in_repr);
199     } else if (!strcmp(gridtype,"axonometric")) {
200         return (CanvasGrid*) new CanvasAxonomGrid(nv, in_repr);
201     }
203     return NULL;
207 /**
208 *  creates a new grid canvasitem for the SPDesktop given as parameter. Keeps a link to this canvasitem in the canvasitems list.
209 */
210 GridCanvasItem *
211 CanvasGrid::createCanvasItem(SPDesktop * desktop)
213     if (!desktop) return NULL;
214     //Johan: I think for multiple desktops it is best if each has their own canvasitem, but share the same CanvasGrid object; that is what this function is for.
216     // check if there is already a canvasitem on this desktop linking to this grid
217     for (GSList *l = canvasitems; l != NULL; l = l->next) {
218         if ( sp_desktop_gridgroup(desktop) == SP_CANVAS_GROUP(SP_CANVAS_ITEM(l->data)->parent) ) {
219             return NULL;
220         }
221     }
223     GridCanvasItem * item = INKSCAPE_GRID_CANVASITEM( sp_canvas_item_new(sp_desktop_gridgroup(desktop), INKSCAPE_TYPE_GRID_CANVASITEM, NULL) );
224     item->grid = this;
225     sp_canvas_item_show(SP_CANVAS_ITEM(item));
227     gtk_object_ref(GTK_OBJECT(item));    // since we're keeping a link to this item, we need to bump up the ref count
228     canvasitems = g_slist_prepend(canvasitems, item);
230     return item;
233 void
234 CanvasGrid::on_repr_attr_changed (Inkscape::XML::Node * repr, const gchar *key, const gchar *oldval, const gchar *newval, bool is_interactive, void * data)
236     if (!data)
237         return;
239     ((CanvasGrid*) data)->onReprAttrChanged(repr, key, oldval, newval, is_interactive);
244 // ##########################################################
245 //   CanvasXYGrid
247 static void
248 grid_hline (SPCanvasBuf *buf, gint y, gint xs, gint xe, guint32 rgba)
250     if ((y >= buf->rect.y0) && (y < buf->rect.y1)) {
251         guint r, g, b, a;
252         gint x0, x1, x;
253         guchar *p;
254         r = NR_RGBA32_R (rgba);
255         g = NR_RGBA32_G (rgba);
256         b = NR_RGBA32_B (rgba);
257         a = NR_RGBA32_A (rgba);
258         x0 = MAX (buf->rect.x0, xs);
259         x1 = MIN (buf->rect.x1, xe + 1);
260         p = buf->buf + (y - buf->rect.y0) * buf->buf_rowstride + (x0 - buf->rect.x0) * 3;
261         for (x = x0; x < x1; x++) {
262             p[0] = NR_COMPOSEN11_1111 (r, a, p[0]);
263             p[1] = NR_COMPOSEN11_1111 (g, a, p[1]);
264             p[2] = NR_COMPOSEN11_1111 (b, a, p[2]);
265             p += 3;
266         }
267     }
270 static void
271 grid_vline (SPCanvasBuf *buf, gint x, gint ys, gint ye, guint32 rgba)
273     if ((x >= buf->rect.x0) && (x < buf->rect.x1)) {
274         guint r, g, b, a;
275         gint y0, y1, y;
276         guchar *p;
277         r = NR_RGBA32_R(rgba);
278         g = NR_RGBA32_G (rgba);
279         b = NR_RGBA32_B (rgba);
280         a = NR_RGBA32_A (rgba);
281         y0 = MAX (buf->rect.y0, ys);
282         y1 = MIN (buf->rect.y1, ye + 1);
283         p = buf->buf + (y0 - buf->rect.y0) * buf->buf_rowstride + (x - buf->rect.x0) * 3;
284         for (y = y0; y < y1; y++) {
285             p[0] = NR_COMPOSEN11_1111 (r, a, p[0]);
286             p[1] = NR_COMPOSEN11_1111 (g, a, p[1]);
287             p[2] = NR_COMPOSEN11_1111 (b, a, p[2]);
288             p += buf->buf_rowstride;
289         }
290     }
295 /**
296 * A DIRECT COPY-PASTE FROM DOCUMENT-PROPERTIES.CPP  TO QUICKLY GET RESULTS
298  * Helper function that attachs widgets in a 3xn table. The widgets come in an
299  * array that has two entries per table row. The two entries code for four
300  * possible cases: (0,0) means insert space in first column; (0, non-0) means
301  * widget in columns 2-3; (non-0, 0) means label in columns 1-3; and
302  * (non-0, non-0) means two widgets in columns 2 and 3.
303 **/
304 #define SPACE_SIZE_X 15
305 #define SPACE_SIZE_Y 10
306 static inline void
307 attach_all (Gtk::Table &table, const Gtk::Widget *arr[], unsigned size, int start = 0)
309     for (unsigned i=0, r=start; i<size/sizeof(Gtk::Widget*); i+=2)
310     {
311         if (arr[i] && arr[i+1])
312         {
313             table.attach (const_cast<Gtk::Widget&>(*arr[i]),   1, 2, r, r+1,
314                       Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0);
315             table.attach (const_cast<Gtk::Widget&>(*arr[i+1]), 2, 3, r, r+1,
316                       Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0);
317         }
318         else
319         {
320             if (arr[i+1])
321                 table.attach (const_cast<Gtk::Widget&>(*arr[i+1]), 1, 3, r, r+1,
322                       Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0);
323             else if (arr[i])
324             {
325                 Gtk::Label& label = reinterpret_cast<Gtk::Label&> (const_cast<Gtk::Widget&>(*arr[i]));
326                 label.set_alignment (0.0);
327                 table.attach (label, 0, 3, r, r+1,
328                       Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0);
329             }
330             else
331             {
332                 Gtk::HBox *space = manage (new Gtk::HBox);
333                 space->set_size_request (SPACE_SIZE_X, SPACE_SIZE_Y);
334                 table.attach (*space, 0, 1, r, r+1,
335                       (Gtk::AttachOptions)0, (Gtk::AttachOptions)0,0,0);
336             }
337         }
338         ++r;
339     }
342 CanvasXYGrid::CanvasXYGrid (SPNamedView * nv, Inkscape::XML::Node * in_repr)
343     : CanvasGrid(nv, in_repr), table(1, 1)
345     origin[NR::X] = origin[NR::Y] = 0.0;
346     color = DEFAULTGRIDCOLOR;
347     empcolor = DEFAULTGRIDEMPCOLOR;
348     empspacing = 5;
349     spacing[NR::X] = spacing[NR::Y] = 8.0;
350     gridunit = &sp_unit_get_by_id(SP_UNIT_PX);
352     snapper = new CanvasXYGridSnapper(this, namedview, 0);
354     // initialize widgets:
355     vbox.set_border_width(2);
356     table.set_spacings(2);
357     vbox.pack_start(table, false, false, 0);
359     _rumg.init (_("Grid _units:"), "units", _wr, repr);
360     _rsu_ox.init (_("_Origin X:"), _("X coordinate of grid origin"),
361                   "originx", _rumg, _wr, repr);
362     _rsu_oy.init (_("O_rigin Y:"), _("Y coordinate of grid origin"),
363                   "originy", _rumg, _wr, repr);
364     _rsu_sx.init (_("Spacing _X:"), _("Distance between vertical grid lines"),
365                   "spacingx", _rumg, _wr, repr);
366     _rsu_sy.init (_("Spacing _Y:"), _("Distance between horizontal grid lines"),
367                   "spacingy", _rumg, _wr, repr);
368     _rcp_gcol.init (_("Grid line _color:"), _("Grid line color"),
369                     _("Color of grid lines"), "color", "opacity", _wr, repr);
370     _rcp_gmcol.init (_("Ma_jor grid line color:"), _("Major grid line color"),
371                      _("Color of the major (highlighted) grid lines"),
372                      "empcolor", "empopacity", _wr, repr);
373     _rsi.init (_("_Major grid line every:"), _("lines"), "empspacing", _wr, repr);
375     const Gtk::Widget* widget_array[] =
376     {
377         0,                  _rcbgrid._button,
378         _rumg._label,       _rumg._sel,
379         0,                  _rsu_ox.getSU(),
380         0,                  _rsu_oy.getSU(),
381         0,                  _rsu_sx.getSU(),
382         0,                  _rsu_sy.getSU(),
383         _rcp_gcol._label,   _rcp_gcol._cp,
384         0,                  0,
385         _rcp_gmcol._label,  _rcp_gmcol._cp,
386         _rsi._label,        &_rsi._hbox,
387     };
389     attach_all (table, widget_array, sizeof(widget_array));
391     vbox.show();
393     if (repr) readRepr();
394     updateWidgets();
397 CanvasXYGrid::~CanvasXYGrid ()
399    if (snapper) delete snapper;
403 /* fixme: Collect all these length parsing methods and think common sane API */
405 static gboolean sp_nv_read_length(const gchar *str, guint base, gdouble *val, const SPUnit **unit)
407     if (!str) {
408         return FALSE;
409     }
411     gchar *u;
412     gdouble v = g_ascii_strtod(str, &u);
413     if (!u) {
414         return FALSE;
415     }
416     while (isspace(*u)) {
417         u += 1;
418     }
420     if (!*u) {
421         /* No unit specified - keep default */
422         *val = v;
423         return TRUE;
424     }
426     if (base & SP_UNIT_DEVICE) {
427         if (u[0] && u[1] && !isalnum(u[2]) && !strncmp(u, "px", 2)) {
428             *unit = &sp_unit_get_by_id(SP_UNIT_PX);
429             *val = v;
430             return TRUE;
431         }
432     }
434     if (base & SP_UNIT_ABSOLUTE) {
435         if (!strncmp(u, "pt", 2)) {
436             *unit = &sp_unit_get_by_id(SP_UNIT_PT);
437         } else if (!strncmp(u, "mm", 2)) {
438             *unit = &sp_unit_get_by_id(SP_UNIT_MM);
439         } else if (!strncmp(u, "cm", 2)) {
440             *unit = &sp_unit_get_by_id(SP_UNIT_CM);
441         } else if (!strncmp(u, "m", 1)) {
442             *unit = &sp_unit_get_by_id(SP_UNIT_M);
443         } else if (!strncmp(u, "in", 2)) {
444             *unit = &sp_unit_get_by_id(SP_UNIT_IN);
445         } else {
446             return FALSE;
447         }
448         *val = v;
449         return TRUE;
450     }
452     return FALSE;
455 static gboolean sp_nv_read_opacity(const gchar *str, guint32 *color)
457     if (!str) {
458         return FALSE;
459     }
461     gchar *u;
462     gdouble v = g_ascii_strtod(str, &u);
463     if (!u) {
464         return FALSE;
465     }
466     v = CLAMP(v, 0.0, 1.0);
468     *color = (*color & 0xffffff00) | (guint32) floor(v * 255.9999);
470     return TRUE;
475 void
476 CanvasXYGrid::readRepr()
478     gchar const* value;
479     if ( (value = repr->attribute("originx")) ) {
480         sp_nv_read_length(value, SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE, &origin[NR::X], &gridunit);
481         origin[NR::X] = sp_units_get_pixels(origin[NR::X], *(gridunit));
482     }
483     if ( (value = repr->attribute("originy")) ) {
484         sp_nv_read_length(value, SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE, &origin[NR::Y], &gridunit);
485         origin[NR::Y] = sp_units_get_pixels(origin[NR::Y], *(gridunit));
486     }
488     if ( (value = repr->attribute("spacingx")) ) {
489         sp_nv_read_length(value, SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE, &spacing[NR::X], &gridunit);
490         spacing[NR::X] = sp_units_get_pixels(spacing[NR::X], *(gridunit));
491     }
492     if ( (value = repr->attribute("spacingy")) ) {
493         sp_nv_read_length(value, SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE, &spacing[NR::Y], &gridunit);
494         spacing[NR::Y] = sp_units_get_pixels(spacing[NR::Y], *(gridunit));
495     }
497     if ( (value = repr->attribute("color")) ) {
498         color = (color & 0xff) | sp_svg_read_color(value, color);
499     }
501     if ( (value = repr->attribute("empcolor")) ) {
502         empcolor = (empcolor & 0xff) | sp_svg_read_color(value, empcolor);
503     }
505     if ( (value = repr->attribute("opacity")) ) {
506         sp_nv_read_opacity(value, &color);
507     }
508     if ( (value = repr->attribute("empopacity")) ) {
509         sp_nv_read_opacity(value, &empcolor);
510     }
512     if ( (value = repr->attribute("empspacing")) ) {
513         empspacing = atoi(value);
514     }
516     for (GSList *l = canvasitems; l != NULL; l = l->next) {
517         sp_canvas_item_request_update ( SP_CANVAS_ITEM(l->data) );
518     }
520     return;
523 /**
524  * Called when XML node attribute changed; updates dialog widgets if change was not done by widgets themselves.
525  */
526 void
527 CanvasXYGrid::onReprAttrChanged (Inkscape::XML::Node * repr, const gchar *key, const gchar *oldval, const gchar *newval, bool is_interactive)
529     readRepr();
531     if ( ! (_wr.isUpdating()) )
532         updateWidgets();
538 Gtk::Widget &
539 CanvasXYGrid::getWidget()
541     return vbox;
545 /**
546  * Update dialog widgets from object's values.
547  */
548 void
549 CanvasXYGrid::updateWidgets()
551     if (_wr.isUpdating()) return;
553     _wr.setUpdating (true);
555     _rumg.setUnit (gridunit);
557     gdouble val;
558     val = origin[NR::X];
559     val = sp_pixels_get_units (val, *(gridunit));
560     _rsu_ox.setValue (val);
561     val = origin[NR::Y];
562     val = sp_pixels_get_units (val, *(gridunit));
563     _rsu_oy.setValue (val);
564     val = spacing[NR::X];
565     double gridx = sp_pixels_get_units (val, *(gridunit));
566     _rsu_sx.setValue (gridx);
567     val = spacing[NR::Y];
568     double gridy = sp_pixels_get_units (val, *(gridunit));
569     _rsu_sy.setValue (gridy);
571     _rcp_gcol.setRgba32 (color);
572     _rcp_gmcol.setRgba32 (empcolor);
573     _rsi.setValue (empspacing);
575     _wr.setUpdating (false);
577     return;
582 void
583 CanvasXYGrid::Update (NR::Matrix const &affine, unsigned int flags)
585     ow = origin * affine;
586     sw = spacing * affine;
587     sw -= NR::Point(affine[4], affine[5]);
589     for(int dim = 0; dim < 2; dim++) {
590         gint scaling_factor = 5; //empspacing;
592         if (scaling_factor <= 1)
593             scaling_factor = 5;
595         scaled[dim] = FALSE;
596         sw[dim] = fabs (sw[dim]);
597         while (sw[dim] < 8.0) {
598             scaled[dim] = TRUE;
599             sw[dim] *= scaling_factor;
600             /* First pass, go up to the major line spacing, then
601                keep increasing by two. */
602             scaling_factor = 2;
603         }
604     }
607 void
608 CanvasXYGrid::Render (SPCanvasBuf *buf)
610     const gdouble sxg = floor ((buf->rect.x0 - ow[NR::X]) / sw[NR::X]) * sw[NR::X] + ow[NR::X];
611     const gint  xlinestart = (gint) Inkscape::round((sxg - ow[NR::X]) / sw[NR::X]);
612     const gdouble syg = floor ((buf->rect.y0 - ow[NR::Y]) / sw[NR::Y]) * sw[NR::Y] + ow[NR::Y];
613     const gint  ylinestart = (gint) Inkscape::round((syg - ow[NR::Y]) / sw[NR::Y]);
615     gint ylinenum;
616     gdouble y;
617     for (y = syg, ylinenum = ylinestart; y < buf->rect.y1; y += sw[NR::Y], ylinenum++) {
618         const gint y0 = (gint) Inkscape::round(y);
620         if (!scaled[NR::Y] && (ylinenum % 5 /*empspacing*/) == 0) {
621             grid_hline (buf, y0, buf->rect.x0, buf->rect.x1 - 1, empcolor);
622         } else {
623             grid_hline (buf, y0, buf->rect.x0, buf->rect.x1 - 1, color);
624         }
625     }
627     gint xlinenum;
628     gdouble x;
629     for (x = sxg, xlinenum = xlinestart; x < buf->rect.x1; x += sw[NR::X], xlinenum++) {
630         const gint ix = (gint) Inkscape::round(x);
631         if (!scaled[NR::X] && (xlinenum % 5 /*empspacing*/) == 0) {
632             grid_vline (buf, ix, buf->rect.y0, buf->rect.y1, empcolor);
633         } else {
634             grid_vline (buf, ix, buf->rect.y0, buf->rect.y1, color);
635         }
636     }
650 /**
651  * \return x rounded to the nearest multiple of c1 plus c0.
652  *
653  * \note
654  * If c1==0 (and c0 is finite), then returns +/-inf.  This makes grid spacing of zero
655  * mean "ignore the grid in this dimention".  We're currently discussing "good" semantics
656  * for guide/grid snapping.
657  */
659 /* FIXME: move this somewhere else, perhaps */
660 static double round_to_nearest_multiple_plus(double x, double const c1, double const c0)
662     return floor((x - c0) / c1 + .5) * c1 + c0;
665 CanvasXYGridSnapper::CanvasXYGridSnapper(CanvasXYGrid *grid, SPNamedView const *nv, NR::Coord const d) : LineSnapper(nv, d)
667     this->grid = grid;
670 LineSnapper::LineList
671 CanvasXYGridSnapper::_getSnapLines(NR::Point const &p) const
673     LineList s;
675     if ( grid == NULL ) {
676         return s;
677     }
679     for (unsigned int i = 0; i < 2; ++i) {
681         /* This is to make sure we snap to only visible grid lines */
682         double scaled_spacing = grid->sw[i]; // this is spacing of visible lines if screen pixels
684         // convert screen pixels to px
685         // FIXME: after we switch to snapping dist in screen pixels, this will be unnecessary
686         if (SP_ACTIVE_DESKTOP) {
687             scaled_spacing /= SP_ACTIVE_DESKTOP->current_zoom();
688         }
690         NR::Coord const rounded = round_to_nearest_multiple_plus(p[i],
691                                                                  scaled_spacing,
692                                                                  grid->origin[i]);
694         s.push_back(std::make_pair(NR::Dim2(i), rounded));
695     }
697     return s;
704 }; /* namespace Inkscape */
706 /*
707   Local Variables:
708   mode:c++
709   c-file-style:"stroustrup"
710   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
711   indent-tabs-mode:nil
712   fill-column:99
713   End:
714 */
715 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :