From: johanengelen Date: Sun, 15 Apr 2007 17:05:40 +0000 (+0000) Subject: Removal of old grid code - fully enabled new grid code. X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=59a0ba05e8bea8ef8d8c905eb0232c5980ac9afa;p=inkscape.git Removal of old grid code - fully enabled new grid code. --- diff --git a/src/Makefile_insert b/src/Makefile_insert index 77bd4e7e5..9ded1945f 100644 --- a/src/Makefile_insert +++ b/src/Makefile_insert @@ -135,7 +135,6 @@ libinkpre_a_SOURCES = \ snapped-point.cpp snapped-point.h \ snapper.cpp snapper.h \ line-snapper.cpp line-snapper.h \ - grid-snapper.cpp grid-snapper.h \ guide-snapper.cpp guide-snapper.h \ object-snapper.cpp object-snapper.h \ sp-anchor.cpp sp-anchor.h \ diff --git a/src/attributes.cpp b/src/attributes.cpp index e7465a037..39f6a04f9 100644 --- a/src/attributes.cpp +++ b/src/attributes.cpp @@ -59,20 +59,10 @@ static SPStyleProp const props[] = { {SP_ATTR_INKSCAPE_VERSION, "inkscape:version"}, /* SPNamedView */ {SP_ATTR_VIEWONLY, "viewonly"}, - {SP_ATTR_SHOWGRID, "showgrid"}, {SP_ATTR_SHOWGUIDES, "showguides"}, {SP_ATTR_GRIDTOLERANCE, "gridtolerance"}, {SP_ATTR_GUIDETOLERANCE, "guidetolerance"}, {SP_ATTR_OBJECTTOLERANCE, "objecttolerance"}, - {SP_ATTR_GRIDORIGINX, "gridoriginx"}, - {SP_ATTR_GRIDORIGINY, "gridoriginy"}, - {SP_ATTR_GRIDSPACINGX, "gridspacingx"}, - {SP_ATTR_GRIDSPACINGY, "gridspacingy"}, - {SP_ATTR_GRIDCOLOR, "gridcolor"}, - {SP_ATTR_GRIDOPACITY, "gridopacity"}, - {SP_ATTR_GRIDEMPCOLOR, "gridempcolor"}, - {SP_ATTR_GRIDEMPOPACITY, "gridempopacity"}, - {SP_ATTR_GRIDEMPSPACING, "gridempspacing"}, {SP_ATTR_GUIDECOLOR, "guidecolor"}, {SP_ATTR_GUIDEOPACITY, "guideopacity"}, {SP_ATTR_GUIDEHICOLOR, "guidehicolor"}, diff --git a/src/attributes.h b/src/attributes.h index bff5d2aef..85eb00e38 100644 --- a/src/attributes.h +++ b/src/attributes.h @@ -60,20 +60,10 @@ enum SPAttributeEnum { SP_ATTR_INKSCAPE_VERSION, /* SPNamedView */ SP_ATTR_VIEWONLY, - SP_ATTR_SHOWGRID, SP_ATTR_SHOWGUIDES, SP_ATTR_GRIDTOLERANCE, SP_ATTR_GUIDETOLERANCE, SP_ATTR_OBJECTTOLERANCE, - SP_ATTR_GRIDORIGINX, - SP_ATTR_GRIDORIGINY, - SP_ATTR_GRIDSPACINGX, - SP_ATTR_GRIDSPACINGY, - SP_ATTR_GRIDCOLOR, - SP_ATTR_GRIDOPACITY, - SP_ATTR_GRIDEMPCOLOR, - SP_ATTR_GRIDEMPOPACITY, - SP_ATTR_GRIDEMPSPACING, SP_ATTR_GUIDECOLOR, SP_ATTR_GUIDEOPACITY, SP_ATTR_GUIDEHICOLOR, diff --git a/src/desktop.cpp b/src/desktop.cpp index 4236fd7d8..a9c4e5d7f 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -1429,12 +1429,7 @@ _update_snap_distances (SPDesktop *desktop) SPNamedView &nv = *desktop->namedview; - - // FIXME GRID: make one gridsnapper object that snaps to all enabled grids by calling their snappers. - nv.snap_manager.grid.setDistance(sp_convert_distance_full(nv.gridtolerance, - *nv.gridtoleranceunit, - px)); - //new grid snappers + //tell all grid snappers for ( GSList const *l = nv.grids; l != NULL; l = l->next) { Inkscape::CanvasGrid *grid = (Inkscape::CanvasGrid*) l->data; grid->snapper->setDistance(sp_convert_distance_full(nv.gridtolerance, diff --git a/src/display/canvas-grid.cpp b/src/display/canvas-grid.cpp index 6ca6b7f83..7db2d4020 100644 --- a/src/display/canvas-grid.cpp +++ b/src/display/canvas-grid.cpp @@ -240,8 +240,52 @@ CanvasGrid::on_repr_attr_changed (Inkscape::XML::Node * repr, const gchar *key, // ########################################################## // CanvasXYGrid -static void grid_hline (SPCanvasBuf *buf, gint y, gint xs, gint xe, guint32 rgba); -static void grid_vline (SPCanvasBuf *buf, gint x, gint ys, gint ye, guint32 rgba); +static void +grid_hline (SPCanvasBuf *buf, gint y, gint xs, gint xe, guint32 rgba) +{ + if ((y >= buf->rect.y0) && (y < buf->rect.y1)) { + guint r, g, b, a; + gint x0, x1, x; + guchar *p; + r = NR_RGBA32_R (rgba); + g = NR_RGBA32_G (rgba); + b = NR_RGBA32_B (rgba); + a = NR_RGBA32_A (rgba); + x0 = MAX (buf->rect.x0, xs); + x1 = MIN (buf->rect.x1, xe + 1); + p = buf->buf + (y - buf->rect.y0) * buf->buf_rowstride + (x0 - buf->rect.x0) * 3; + for (x = x0; x < x1; x++) { + p[0] = NR_COMPOSEN11_1111 (r, a, p[0]); + p[1] = NR_COMPOSEN11_1111 (g, a, p[1]); + p[2] = NR_COMPOSEN11_1111 (b, a, p[2]); + p += 3; + } + } +} + +static void +grid_vline (SPCanvasBuf *buf, gint x, gint ys, gint ye, guint32 rgba) +{ + if ((x >= buf->rect.x0) && (x < buf->rect.x1)) { + guint r, g, b, a; + gint y0, y1, y; + guchar *p; + r = NR_RGBA32_R(rgba); + g = NR_RGBA32_G (rgba); + b = NR_RGBA32_B (rgba); + a = NR_RGBA32_A (rgba); + y0 = MAX (buf->rect.y0, ys); + y1 = MIN (buf->rect.y1, ye + 1); + p = buf->buf + (y0 - buf->rect.y0) * buf->buf_rowstride + (x - buf->rect.x0) * 3; + for (y = y0; y < y1; y++) { + p[0] = NR_COMPOSEN11_1111 (r, a, p[0]); + p[1] = NR_COMPOSEN11_1111 (g, a, p[1]); + p[2] = NR_COMPOSEN11_1111 (b, a, p[2]); + p += buf->buf_rowstride; + } + } +} + /** @@ -657,313 +701,6 @@ CanvasXYGridSnapper::_getSnapLines(NR::Point const &p) const - - - - - - - - - - - - - - - - - - - - - - - - - - -enum { - ARG_0, - ARG_ORIGINX, - ARG_ORIGINY, - ARG_SPACINGX, - ARG_SPACINGY, - ARG_COLOR, - ARG_EMPCOLOR, - ARG_EMPSPACING -}; - - -static void cxygrid_class_init (CXYGridClass *klass); -static void cxygrid_init (CXYGrid *grid); -static void cxygrid_destroy (GtkObject *object); -static void cxygrid_set_arg (GtkObject *object, GtkArg *arg, guint arg_id); - -static void cxygrid_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags); -static void cxygrid_render (SPCanvasItem *item, SPCanvasBuf *buf); - -//static SPCanvasItemClass * parent_class; - -GtkType -cxygrid_get_type (void) -{ - static GtkType cxygrid_type = 0; - - if (!cxygrid_type) { - GtkTypeInfo cxygrid_info = { - "CXYGrid", - sizeof (CXYGrid), - sizeof (CXYGridClass), - (GtkClassInitFunc) cxygrid_class_init, - (GtkObjectInitFunc) cxygrid_init, - NULL, NULL, - (GtkClassInitFunc) NULL - }; - cxygrid_type = gtk_type_unique (sp_canvas_item_get_type (), &cxygrid_info); - } - return cxygrid_type; -} - -static void -cxygrid_class_init (CXYGridClass *klass) -{ - GtkObjectClass *object_class; - SPCanvasItemClass *item_class; - - object_class = (GtkObjectClass *) klass; - item_class = (SPCanvasItemClass *) klass; - - parent_class = (SPCanvasItemClass*)gtk_type_class (sp_canvas_item_get_type ()); - - gtk_object_add_arg_type ("CXYGrid::originx", GTK_TYPE_DOUBLE, GTK_ARG_WRITABLE, ARG_ORIGINX); - gtk_object_add_arg_type ("CXYGrid::originy", GTK_TYPE_DOUBLE, GTK_ARG_WRITABLE, ARG_ORIGINY); - gtk_object_add_arg_type ("CXYGrid::spacingx", GTK_TYPE_DOUBLE, GTK_ARG_WRITABLE, ARG_SPACINGX); - gtk_object_add_arg_type ("CXYGrid::spacingy", GTK_TYPE_DOUBLE, GTK_ARG_WRITABLE, ARG_SPACINGY); - gtk_object_add_arg_type ("CXYGrid::color", GTK_TYPE_INT, GTK_ARG_WRITABLE, ARG_COLOR); - gtk_object_add_arg_type ("CXYGrid::empcolor", GTK_TYPE_INT, GTK_ARG_WRITABLE, ARG_EMPCOLOR); - gtk_object_add_arg_type ("CXYGrid::empspacing", GTK_TYPE_INT, GTK_ARG_WRITABLE, ARG_EMPSPACING); - - object_class->destroy = cxygrid_destroy; - object_class->set_arg = cxygrid_set_arg; - - item_class->update = cxygrid_update; - item_class->render = cxygrid_render; -} - -static void -cxygrid_init (CXYGrid *grid) -{ - grid->origin[NR::X] = grid->origin[NR::Y] = 0.0; - grid->spacing[NR::X] = grid->spacing[NR::Y] = 8.0; - grid->color = 0x0000ff7f; - grid->empcolor = 0x3F3FFF40; - grid->empspacing = 5; -} - -static void -cxygrid_destroy (GtkObject *object) -{ - g_return_if_fail (object != NULL); - g_return_if_fail (INKSCAPE_IS_CXYGRID (object)); - - if (GTK_OBJECT_CLASS (parent_class)->destroy) - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); -} - -static void -cxygrid_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) -{ - SPCanvasItem *item = SP_CANVAS_ITEM (object); - CXYGrid *grid = INKSCAPE_CXYGRID (object); - - switch (arg_id) { - case ARG_ORIGINX: - grid->origin[NR::X] = GTK_VALUE_DOUBLE (* arg); - sp_canvas_item_request_update (item); - break; - case ARG_ORIGINY: - grid->origin[NR::Y] = GTK_VALUE_DOUBLE (* arg); - sp_canvas_item_request_update (item); - break; - case ARG_SPACINGX: - grid->spacing[NR::X] = GTK_VALUE_DOUBLE (* arg); - if (grid->spacing[NR::X] < 0.01) grid->spacing[NR::X] = 0.01; - sp_canvas_item_request_update (item); - break; - case ARG_SPACINGY: - grid->spacing[NR::Y] = GTK_VALUE_DOUBLE (* arg); - if (grid->spacing[NR::Y] < 0.01) grid->spacing[NR::Y] = 0.01; - sp_canvas_item_request_update (item); - break; - case ARG_COLOR: - grid->color = GTK_VALUE_INT (* arg); - sp_canvas_item_request_update (item); - break; - case ARG_EMPCOLOR: - grid->empcolor = GTK_VALUE_INT (* arg); - sp_canvas_item_request_update (item); - break; - case ARG_EMPSPACING: - grid->empspacing = GTK_VALUE_INT (* arg); - // std::cout << "Emphasis Spacing: " << grid->empspacing << std::endl; - sp_canvas_item_request_update (item); - break; - default: - break; - } -} - -static void -grid_hline (SPCanvasBuf *buf, gint y, gint xs, gint xe, guint32 rgba) -{ - if ((y >= buf->rect.y0) && (y < buf->rect.y1)) { - guint r, g, b, a; - gint x0, x1, x; - guchar *p; - r = NR_RGBA32_R (rgba); - g = NR_RGBA32_G (rgba); - b = NR_RGBA32_B (rgba); - a = NR_RGBA32_A (rgba); - x0 = MAX (buf->rect.x0, xs); - x1 = MIN (buf->rect.x1, xe + 1); - p = buf->buf + (y - buf->rect.y0) * buf->buf_rowstride + (x0 - buf->rect.x0) * 3; - for (x = x0; x < x1; x++) { - p[0] = NR_COMPOSEN11_1111 (r, a, p[0]); - p[1] = NR_COMPOSEN11_1111 (g, a, p[1]); - p[2] = NR_COMPOSEN11_1111 (b, a, p[2]); - p += 3; - } - } -} - -static void -grid_vline (SPCanvasBuf *buf, gint x, gint ys, gint ye, guint32 rgba) -{ - if ((x >= buf->rect.x0) && (x < buf->rect.x1)) { - guint r, g, b, a; - gint y0, y1, y; - guchar *p; - r = NR_RGBA32_R(rgba); - g = NR_RGBA32_G (rgba); - b = NR_RGBA32_B (rgba); - a = NR_RGBA32_A (rgba); - y0 = MAX (buf->rect.y0, ys); - y1 = MIN (buf->rect.y1, ye + 1); - p = buf->buf + (y0 - buf->rect.y0) * buf->buf_rowstride + (x - buf->rect.x0) * 3; - for (y = y0; y < y1; y++) { - p[0] = NR_COMPOSEN11_1111 (r, a, p[0]); - p[1] = NR_COMPOSEN11_1111 (g, a, p[1]); - p[2] = NR_COMPOSEN11_1111 (b, a, p[2]); - p += buf->buf_rowstride; - } - } -} - -/** - \brief This function renders the grid on a particular canvas buffer - \param item The grid to render on the buffer - \param buf The buffer to render the grid on - - This function gets called a touch more than you might believe, - about once per tile. This means that it could probably be optimized - and help things out. - - Basically this function has to determine where in the canvas it is, - and how that associates with the grid. It does this first by looking - at the bounding box of the buffer, and then calculates where the grid - starts in that buffer. It will then step through grid lines until - it is outside of the buffer. - - For each grid line it is drawn using the function \c sp_grid_hline - or \c sp_grid_vline. These are convience functions for the sake - of making the function easier to read. - - Also, there are emphisized lines on the grid. While the \c syg and - \c sxg variable track grid positioning, the \c xlinestart and \c - ylinestart variables track the 'count' of what lines they are. If - that count is a multiple of the line seperation between emphisis - lines, then that line is drawn in the emphisis color. -*/ -static void -cxygrid_render (SPCanvasItem * item, SPCanvasBuf * buf) -{ - CXYGrid *grid = INKSCAPE_CXYGRID (item); - - sp_canvas_prepare_buffer (buf); - - const gdouble sxg = floor ((buf->rect.x0 - grid->ow[NR::X]) / grid->sw[NR::X]) * grid->sw[NR::X] + grid->ow[NR::X]; - const gint xlinestart = (gint) Inkscape::round((sxg - grid->ow[NR::X]) / grid->sw[NR::X]); - const gdouble syg = floor ((buf->rect.y0 - grid->ow[NR::Y]) / grid->sw[NR::Y]) * grid->sw[NR::Y] + grid->ow[NR::Y]; - const gint ylinestart = (gint) Inkscape::round((syg - grid->ow[NR::Y]) / grid->sw[NR::Y]); - - gint ylinenum; - gdouble y; - for (y = syg, ylinenum = ylinestart; y < buf->rect.y1; y += grid->sw[NR::Y], ylinenum++) { - const gint y0 = (gint) Inkscape::round(y); - - if (!grid->scaled[NR::Y] && (ylinenum % grid->empspacing) == 0) { - grid_hline (buf, y0, buf->rect.x0, buf->rect.x1 - 1, grid->empcolor); - } else { - grid_hline (buf, y0, buf->rect.x0, buf->rect.x1 - 1, grid->color); - } - } - - gint xlinenum; - gdouble x; - for (x = sxg, xlinenum = xlinestart; x < buf->rect.x1; x += grid->sw[NR::X], xlinenum++) { - const gint ix = (gint) Inkscape::round(x); - if (!grid->scaled[NR::X] && (xlinenum % grid->empspacing) == 0) { - grid_vline (buf, ix, buf->rect.y0, buf->rect.y1, grid->empcolor); - } else { - grid_vline (buf, ix, buf->rect.y0, buf->rect.y1, grid->color); - } - } -} - -static void -cxygrid_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned int flags) -{ - CXYGrid *grid = INKSCAPE_CXYGRID (item); - - if (parent_class->update) - (* parent_class->update) (item, affine, flags); - - grid->ow = grid->origin * affine; - grid->sw = grid->spacing * affine; - grid->sw -= NR::Point(affine[4], affine[5]); - - for(int dim = 0; dim < 2; dim++) { - gint scaling_factor = grid->empspacing; - - if (scaling_factor <= 1) - scaling_factor = 5; - - grid->scaled[dim] = FALSE; - grid->sw[dim] = fabs (grid->sw[dim]); - while (grid->sw[dim] < 8.0) { - grid->scaled[dim] = TRUE; - grid->sw[dim] *= scaling_factor; - /* First pass, go up to the major line spacing, then - keep increasing by two. */ - scaling_factor = 2; - } - } - - if (grid->empspacing == 0) { - grid->scaled[NR::Y] = TRUE; - grid->scaled[NR::X] = TRUE; - } - - sp_canvas_request_redraw (item->canvas, - -1000000, -1000000, - 1000000, 1000000); - - item->x1 = item->y1 = -1000000; - item->x2 = item->y2 = 1000000; -} - - }; /* namespace Inkscape */ /* diff --git a/src/display/canvas-grid.h b/src/display/canvas-grid.h index 984ddad79..a4d36e361 100644 --- a/src/display/canvas-grid.h +++ b/src/display/canvas-grid.h @@ -151,53 +151,6 @@ private: CanvasXYGrid *grid; }; - - - - - - - - - - - - - - - - - - -#define INKSCAPE_TYPE_CXYGRID (Inkscape::cxygrid_get_type ()) -#define INKSCAPE_CXYGRID(obj) (GTK_CHECK_CAST ((obj), INKSCAPE_TYPE_CXYGRID, CXYGrid)) -#define INKSCAPE_CXYGRID_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), INKSCAPE_TYPE_CXYGRID, CXYGridClass)) -#define INKSCAPE_IS_CXYGRID(obj) (GTK_CHECK_TYPE ((obj), INKSCAPE_TYPE_CXYGRID)) -#define INKSCAPE_IS_CXYGRID_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), INKSCAPE_TYPE_CXYGRID)) - - -/** \brief All the variables that are tracked for a grid specific - canvas item. */ -struct CXYGrid : public SPCanvasItem{ - NR::Point origin; /**< Origin of the grid */ - NR::Point spacing; /**< Spacing between elements of the grid */ - guint32 color; /**< Color for normal lines */ - guint32 empcolor; /**< Color for emphisis lines */ - gint empspacing; /**< Spacing between emphisis lines */ - bool scaled[2]; /**< Whether the grid is in scaled mode, which can - be different in the X or Y direction, hense two - variables */ - NR::Point ow; /**< Transformed origin by the affine for the zoom */ - NR::Point sw; /**< Transformed spacing by the affine for the zoom */ -}; - -struct CXYGridClass { - SPCanvasItemClass parent_class; -}; - -/* Standard Gtk function */ -GtkType cxygrid_get_type (void); - }; /* namespace Inkscape */ diff --git a/src/grid-snapper.cpp b/src/grid-snapper.cpp deleted file mode 100644 index 818f0abd9..000000000 --- a/src/grid-snapper.cpp +++ /dev/null @@ -1,95 +0,0 @@ -/** - * \file grid-snapper.cpp - * \brief Snapping things to grids. - * - * Authors: - * Lauris Kaplinski - * Frank Felfe - * Carl Hetherington - * - * Copyright (C) 2006 Johan Engelen - * Copyright (C) 1999-2002 Authors - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include "sp-namedview.h" -#include "inkscape.h" -#include "desktop.h" -#include "display/canvas-grid.h" -#include "display/canvas-axonomgrid.h" - -/** - * \return x rounded to the nearest multiple of c1 plus c0. - * - * \note - * If c1==0 (and c0 is finite), then returns +/-inf. This makes grid spacing of zero - * mean "ignore the grid in this dimention". We're currently discussing "good" semantics - * for guide/grid snapping. - */ - -/* FIXME: move this somewhere else, perhaps */ -static double round_to_nearest_multiple_plus(double x, double const c1, double const c0) -{ - return floor((x - c0) / c1 + .5) * c1 + c0; -} - -Inkscape::GridSnapper::GridSnapper(SPNamedView const *nv, NR::Coord const d) : LineSnapper(nv, d) -{ - -} - -Inkscape::LineSnapper::LineList -Inkscape::GridSnapper::_getSnapLines(NR::Point const &p) const -{ - LineList s; - - if ( NULL == _named_view ) { - return s; - } - - CXYGrid *griditem = NULL; - for (GSList *l = _named_view->gridviews; l != NULL; l = l->next) { - // FIXME : this is a hack since there is only one view for now - // but when we'll handle multiple views, snapping should - // must be rethought and maybe only the current view - // should give back it's SHOWN lines to snap to - // For now, the last CXYGrid in _named_view->gridviews will be used. - if ( INKSCAPE_IS_CXYGRID(GTK_OBJECT(l->data)) ) { - griditem = INKSCAPE_CXYGRID(l->data); - } - } - - g_assert(griditem != NULL); - - for (unsigned int i = 0; i < 2; ++i) { - - /* This is to make sure we snap to only visible grid lines */ - double scaled_spacing = griditem->sw[i]; // this is spacing of visible lines if screen pixels - - // convert screen pixels to px - // FIXME: after we switch to snapping dist in screen pixels, this will be unnecessary - if (SP_ACTIVE_DESKTOP) { - scaled_spacing /= SP_ACTIVE_DESKTOP->current_zoom(); - } - - NR::Coord const rounded = round_to_nearest_multiple_plus(p[i], - scaled_spacing, - _named_view->gridorigin[i]); - - s.push_back(std::make_pair(NR::Dim2(i), rounded)); - } - - return s; -} - -/* - 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 : diff --git a/src/grid-snapper.h b/src/grid-snapper.h deleted file mode 100644 index 1a704dd4e..000000000 --- a/src/grid-snapper.h +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef SEEN_GRID_SNAPPER_H -#define SEEN_GRID_SNAPPER_H - -/** - * \file grid-snapper.h - * \brief Snapping things to grids. - * - * Authors: - * Lauris Kaplinski - * Frank Felfe - * Carl Hetherington - * - * Copyright (C) 2006 Johan Engelen - * Copyright (C) 1999-2002 Authors - * - * Released under GNU GPL, read the file 'COPYING' for more information - */ - -#include "line-snapper.h" - -namespace Inkscape -{ - -/// Normal 2D grid -class GridSnapper : public LineSnapper -{ -public: - GridSnapper(SPNamedView const *nv, NR::Coord const d); - -private: - LineList _getSnapLines(NR::Point const &p) const; -}; - -} - -#endif - -/* - 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 : diff --git a/src/guide-snapper.h b/src/guide-snapper.h index f4c7b2de7..37e3e3006 100644 --- a/src/guide-snapper.h +++ b/src/guide-snapper.h @@ -17,7 +17,7 @@ #include "libnr/nr-forward.h" #include "libnr/nr-coord.h" -#include "snapper.h" +#include "line-snapper.h" struct SPNamedView; diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index f8548cdc4..2b13021a2 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -1145,12 +1145,9 @@ void sp_selection_paste(bool in_place) } /* Snap the offset of the new item(s) to the grid */ - /* FIXME: this gridsnap fiddling is a hack. */ - Inkscape::GridSnapper &s = desktop->namedview->snap_manager.grid; - gdouble const curr_gridsnap = s.getDistance(); - s.setDistance(NR_HUGE); - m = s.freeSnap(Inkscape::Snapper::SNAP_POINT, m, NULL).getPoint(); - s.setDistance(curr_gridsnap); + SnapManager &sm = desktop->namedview->snap_manager; + SnapManager::SnapperList gs = sm.getGridSnappers(); + m = sm.freeSnapAlways(Inkscape::Snapper::SNAP_POINT, m, NULL, gs).getPoint(); sp_selection_move_relative(selection, m); } diff --git a/src/snap.cpp b/src/snap.cpp index 4f871e736..1714b6b67 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -33,7 +33,6 @@ */ SnapManager::SnapManager(SPNamedView const *v) : - grid(v, 0), guide(v, 0), object(v, 0), _named_view(v) @@ -45,15 +44,28 @@ SnapManager::SnapManager(SPNamedView const *v) : /** * \return List of snappers that we use. */ - -SnapManager::SnapperList SnapManager::getSnappers() const +SnapManager::SnapperList +SnapManager::getSnappers() const { SnapManager::SnapperList s; - s.push_back(&grid); s.push_back(&guide); s.push_back(&object); - //FIXME: this code should do this: add new grid snappers that are active for this desktop + SnapManager::SnapperList gs = getGridSnappers(); + s.splice(s.begin(), gs); + + return s; +} + +/** + * \return List of gridsnappers that we use. + */ +SnapManager::SnapperList +SnapManager::getGridSnappers() const +{ + SnapperList s; + + //FIXME: this code should actually do this: add new grid snappers that are active for this desktop. now it just adds all gridsnappers SPDesktop* desktop = SP_ACTIVE_DESKTOP; if (desktop && desktop->gridsEnabled()) { for ( GSList const *l = _named_view->grids; l != NULL; l = l->next) { @@ -113,10 +125,29 @@ Inkscape::SnappedPoint SnapManager::freeSnap(Inkscape::Snapper::PointType t, Inkscape::SnappedPoint SnapManager::freeSnap(Inkscape::Snapper::PointType t, NR::Point const &p, std::list const &it) const +{ + SnapperList const snappers = getSnappers(); + + return freeSnap(t, p, it, snappers); +} + +/** + * Try to snap a point to any of the specified snappers. + * + * \param t Type of point. + * \param p Point. + * \param it List of items to ignore when snapping. + * \param snappers List of snappers to try to snap to + * \return Snapped point. + */ + +Inkscape::SnappedPoint SnapManager::freeSnap(Inkscape::Snapper::PointType t, + NR::Point const &p, + std::list const &it, + SnapperList const &snappers) const { Inkscape::SnappedPoint r(p, NR_HUGE); - SnapperList const snappers = getSnappers(); for (SnapperList::const_iterator i = snappers.begin(); i != snappers.end(); i++) { Inkscape::SnappedPoint const s = (*i)->freeSnap(t, p, it); if (s.getDistance() < r.getDistance()) { @@ -127,6 +158,60 @@ Inkscape::SnappedPoint SnapManager::freeSnap(Inkscape::Snapper::PointType t, return r; } +/** + * Try to snap a point to any of the specified snappers. Snap always, ignoring the snap-distance + * + * \param t Type of point. + * \param p Point. + * \param it Item to ignore when snapping. + * \param snappers List of snappers to try to snap to + * \return Snapped point. + */ + +Inkscape::SnappedPoint +SnapManager::freeSnapAlways( Inkscape::Snapper::PointType t, + NR::Point const &p, + SPItem const *it, + SnapperList &snappers ) +{ + std::list lit; + lit.push_back(it); + return freeSnapAlways(t, p, lit, snappers); +} + +/** + * Try to snap a point to any of the specified snappers. Snap always, ignoring the snap-distance + * + * \param t Type of point. + * \param p Point. + * \param it List of items to ignore when snapping. + * \param snappers List of snappers to try to snap to + * \return Snapped point. + */ + +Inkscape::SnappedPoint +SnapManager::freeSnapAlways( Inkscape::Snapper::PointType t, + NR::Point const &p, + std::list const &it, + SnapperList &snappers ) +{ + Inkscape::SnappedPoint r(p, NR_HUGE); + + for (SnapperList::iterator i = snappers.begin(); i != snappers.end(); i++) { + gdouble const curr_gridsnap = (*i)->getDistance(); + const_cast (*i)->setDistance(NR_HUGE); + Inkscape::SnappedPoint const s = (*i)->freeSnap(t, p, it); + const_cast (*i)->setDistance(curr_gridsnap); + + if (s.getDistance() < r.getDistance()) { + r = s; + } + } + + return r; +} + + /** * Try to snap a point to any interested snappers. A snap will only occur along diff --git a/src/snap.h b/src/snap.h index 2f8e83b13..4185b051a 100644 --- a/src/snap.h +++ b/src/snap.h @@ -22,7 +22,6 @@ #include #include #include -#include "grid-snapper.h" #include "guide-snapper.h" #include "object-snapper.h" @@ -40,7 +39,9 @@ class SnapManager { public: SnapManager(SPNamedView const *v); - + + typedef std::list SnapperList; + bool willSnapSomething() const; Inkscape::SnappedPoint freeSnap(Inkscape::Snapper::PointType t, @@ -50,7 +51,22 @@ public: Inkscape::SnappedPoint freeSnap(Inkscape::Snapper::PointType t, NR::Point const &p, std::list const &it) const; - + + Inkscape::SnappedPoint freeSnap( Inkscape::Snapper::PointType t, + NR::Point const &p, + std::list const &it, + SnapperList const &snappers ) const; + + Inkscape::SnappedPoint freeSnapAlways( Inkscape::Snapper::PointType t, + NR::Point const &p, + SPItem const *it, + SnapperList &snappers ); + + Inkscape::SnappedPoint freeSnapAlways( Inkscape::Snapper::PointType t, + NR::Point const &p, + std::list const &it, + SnapperList &snappers ); + Inkscape::SnappedPoint constrainedSnap(Inkscape::Snapper::PointType t, NR::Point const &p, Inkscape::Snapper::ConstraintLine const &c, @@ -100,12 +116,11 @@ public: NR::Point const &o, NR::Dim2 d) const; - Inkscape::GridSnapper grid; ///< grid snapper Inkscape::GuideSnapper guide; ///< guide snapper Inkscape::ObjectSnapper object; ///< snapper to other objects - typedef std::list SnapperList; SnapperList getSnappers() const; + SnapperList getGridSnappers() const; protected: SPNamedView const *_named_view; diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp index a11904570..d831a50eb 100644 --- a/src/sp-namedview.cpp +++ b/src/sp-namedview.cpp @@ -55,9 +55,6 @@ static Inkscape::XML::Node *sp_namedview_write(SPObject *object, Inkscape::XML:: static void sp_namedview_setup_guides(SPNamedView * nv); -static void sp_namedview_setup_grid(SPNamedView * nv); -static void sp_namedview_setup_grid_item(SPNamedView * nv, SPCanvasItem * item); - static gboolean sp_str_to_bool(const gchar *str); static gboolean sp_nv_read_length(const gchar *str, guint base, gdouble *val, const SPUnit **unit); static gboolean sp_nv_read_opacity(const gchar *str, guint32 *color); @@ -107,7 +104,6 @@ static void sp_namedview_class_init(SPNamedViewClass * klass) static void sp_namedview_init(SPNamedView *nv) { nv->editable = TRUE; - nv->showgrid = FALSE; nv->showguides = TRUE; nv->showborder = TRUE; nv->showpageshadow = TRUE; @@ -134,20 +130,10 @@ static void sp_namedview_build(SPObject *object, SPDocument *document, Inkscape: sp_object_read_attr(object, "inkscape:document-units"); sp_object_read_attr(object, "viewonly"); - sp_object_read_attr(object, "showgrid"); sp_object_read_attr(object, "showguides"); sp_object_read_attr(object, "gridtolerance"); sp_object_read_attr(object, "guidetolerance"); sp_object_read_attr(object, "objecttolerance"); - sp_object_read_attr(object, "gridoriginx"); - sp_object_read_attr(object, "gridoriginy"); - sp_object_read_attr(object, "gridspacingx"); - sp_object_read_attr(object, "gridspacingy"); - sp_object_read_attr(object, "gridempspacing"); - sp_object_read_attr(object, "gridcolor"); - sp_object_read_attr(object, "gridempcolor"); - sp_object_read_attr(object, "gridopacity"); - sp_object_read_attr(object, "gridempopacity"); sp_object_read_attr(object, "guidecolor"); sp_object_read_attr(object, "guideopacity"); sp_object_read_attr(object, "guidehicolor"); @@ -198,11 +184,6 @@ static void sp_namedview_release(SPObject *object) namedview->guides = NULL; } - while (namedview->gridviews) { - gtk_object_unref(GTK_OBJECT(namedview->gridviews->data)); - namedview->gridviews = g_slist_remove(namedview->gridviews, namedview->gridviews->data); - } - // delete grids: while ( namedview->grids ) { Inkscape::CanvasGrid *gr = (Inkscape::CanvasGrid *)namedview->grids->data; @@ -227,13 +208,6 @@ static void sp_namedview_set(SPObject *object, unsigned int key, const gchar *va nv->editable = (!value); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; - case SP_ATTR_SHOWGRID: - nv->showgrid = sp_str_to_bool(value); - sp_namedview_setup_grid(nv); - /* Disable grid snaps if the grid is turned off */ - nv->snap_manager.grid.setEnabled(nv->showgrid); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); - break; case SP_ATTR_SHOWGUIDES: if (!value) { // show guides if not specified, for backwards compatibility nv->showguides = TRUE; @@ -267,69 +241,6 @@ static void sp_namedview_set(SPObject *object, unsigned int key, const gchar *va } object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; - case SP_ATTR_GRIDORIGINX: - case SP_ATTR_GRIDORIGINY: - { - unsigned const d = (key == SP_ATTR_GRIDORIGINY); - nv->gridunit = nv->doc_units; - nv->gridorigin[d] = 0.0; - if (value) { - sp_nv_read_length(value, SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE, &nv->gridorigin[d], &nv->gridunit); - } - nv->gridorigin[d] = sp_units_get_pixels(nv->gridorigin[d], *(nv->gridunit)); - sp_namedview_setup_grid(nv); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); - break; - } - case SP_ATTR_GRIDSPACINGX: - case SP_ATTR_GRIDSPACINGY: - { - unsigned const d = (key == SP_ATTR_GRIDSPACINGY); - nv->gridunit = nv->doc_units; - nv->gridspacing[d] = 1.0; - if (value) { - sp_nv_read_length(value, SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE, &nv->gridspacing[d], &nv->gridunit); - } - nv->gridspacing[d] = sp_units_get_pixels(nv->gridspacing[d], *(nv->gridunit)); - sp_namedview_setup_grid(nv); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); - break; - } - case SP_ATTR_GRIDCOLOR: - nv->gridcolor = (nv->gridcolor & 0xff) | (DEFAULTGRIDCOLOR & 0xffffff00); - if (value) { - nv->gridcolor = (nv->gridcolor & 0xff) | sp_svg_read_color(value, nv->gridcolor); - } - sp_namedview_setup_grid(nv); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); - break; - case SP_ATTR_GRIDEMPCOLOR: - nv->gridempcolor = (nv->gridempcolor & 0xff) | (DEFAULTGRIDEMPCOLOR & 0xffffff00); - if (value) { - nv->gridempcolor = (nv->gridempcolor & 0xff) | sp_svg_read_color(value, nv->gridempcolor); - } - sp_namedview_setup_grid(nv); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); - break; - case SP_ATTR_GRIDOPACITY: - nv->gridcolor = (nv->gridcolor & 0xffffff00) | (DEFAULTGRIDCOLOR & 0xff); - sp_nv_read_opacity(value, &nv->gridcolor); - sp_namedview_setup_grid(nv); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); - break; - case SP_ATTR_GRIDEMPOPACITY: - nv->gridempcolor = (nv->gridempcolor & 0xffffff00) | (DEFAULTGRIDEMPCOLOR & 0xff); - sp_nv_read_opacity(value, &nv->gridempcolor); - sp_namedview_setup_grid(nv); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); - break; - case SP_ATTR_GRIDEMPSPACING: - nv->gridempspacing = DEFAULTGRIDEMPSPACING; - if (value != NULL) - nv->gridempspacing = atoi(value); - sp_namedview_setup_grid(nv); - object->requestModified(SP_OBJECT_MODIFIED_FLAG); - break; case SP_ATTR_GUIDECOLOR: nv->guidecolor = (nv->guidecolor & 0xff) | (DEFAULTGUIDECOLOR & 0xffffff00); if (value) { @@ -675,11 +586,6 @@ void SPNamedView::show(SPDesktop *desktop) views = g_slist_prepend(views, desktop); - SPCanvasItem * item = sp_canvas_item_new(sp_desktop_gridgroup(desktop), INKSCAPE_TYPE_CXYGRID, NULL); - // since we're keeping a copy, we need to bump up the ref count - gtk_object_ref(GTK_OBJECT(item)); - gridviews = g_slist_prepend(gridviews, item); - // generate grids specified in SVG: Inkscape::XML::Node *repr = SP_OBJECT_REPR(this); if (repr) { @@ -689,8 +595,6 @@ void SPNamedView::show(SPDesktop *desktop) } } } - - sp_namedview_setup_grid(this); } #define MIN_ONSCREEN_DISTANCE 50 @@ -804,20 +708,6 @@ void SPNamedView::hide(SPDesktop const *desktop) views = g_slist_remove(views, desktop); - GSList *l; - for (l = gridviews; l != NULL; l = l->next) { - if (! l->data) { - continue; - } - SPCanvasItem *item = static_cast(l->data); - - if (item->canvas == sp_desktop_canvas(desktop)) { - sp_canvas_item_hide(SP_CANVAS_ITEM(l->data)); - gtk_object_unref(GTK_OBJECT(l->data)); - gridviews = g_slist_remove(gridviews, l->data); - } - } - // delete grids: while ( grids ) { Inkscape::CanvasGrid *gr = (Inkscape::CanvasGrid *)grids->data; @@ -872,48 +762,6 @@ void sp_namedview_toggle_guides(SPDocument *doc, Inkscape::XML::Node *repr) sp_document_set_undo_sensitive(doc, saved); } -void sp_namedview_toggle_grid(SPDocument *doc, Inkscape::XML::Node *repr) -{ - unsigned int v; - sp_repr_get_boolean(repr, "showgrid", &v); - v = !v; - - bool saved = sp_document_get_undo_sensitive(doc); - sp_document_set_undo_sensitive(doc, false); - - sp_repr_set_boolean(repr, "showgrid", v); - - doc->rroot->setAttribute("sodipodi:modified", "true"); - sp_document_set_undo_sensitive(doc, saved); -} - -static void sp_namedview_setup_grid(SPNamedView *nv) -{ - for (GSList *l = nv->gridviews; l != NULL; l = l->next) { - sp_namedview_setup_grid_item(nv, SP_CANVAS_ITEM(l->data)); - } -} - -static void sp_namedview_setup_grid_item(SPNamedView *nv, SPCanvasItem *item) -{ - if ( nv->showgrid ) { - sp_canvas_item_show(item); - } else { - sp_canvas_item_hide(item); - } - - sp_canvas_item_set((GtkObject *) item, - "color", nv->gridcolor, - "originx", nv->gridorigin[NR::X], - "originy", nv->gridorigin[NR::Y], - "spacingx", nv->gridspacing[NR::X], - "spacingy", nv->gridspacing[NR::Y], - "empcolor", nv->gridempcolor, - "empspacing", nv->gridempspacing, - NULL); -} - - gchar const *SPNamedView::getName() const { SPException ex; diff --git a/src/sp-namedview.h b/src/sp-namedview.h index 64b78d29c..7eefdfae5 100644 --- a/src/sp-namedview.h +++ b/src/sp-namedview.h @@ -36,7 +36,6 @@ enum { struct SPNamedView : public SPObjectGroup { unsigned int editable : 1; - unsigned int showgrid : 1; unsigned int showguides : 1; unsigned int showborder : 1; unsigned int showpageshadow : 1; @@ -51,15 +50,8 @@ struct SPNamedView : public SPObjectGroup { gint window_y; SnapManager snap_manager; - //GridManager grid_manager; GSList * grids; - SPUnit const *gridunit; - /* Grid data is in points regardless of unit */ - NR::Point gridorigin; - gdouble gridspacing[2]; - gint gridempspacing; - SPUnit const *doc_units; SPUnit const *gridtoleranceunit; @@ -75,8 +67,6 @@ struct SPNamedView : public SPObjectGroup { double connector_spacing; - guint32 gridcolor; - guint32 gridempcolor; guint32 guidecolor; guint32 guidehicolor; guint32 bordercolor; @@ -85,7 +75,6 @@ struct SPNamedView : public SPObjectGroup { GSList *guides; GSList *views; - GSList *gridviews; gint viewcount; @@ -111,8 +100,6 @@ void sp_namedview_document_from_window(SPDesktop *desktop); void sp_namedview_update_layers_from_document (SPDesktop *desktop); void sp_namedview_toggle_guides(SPDocument *doc, Inkscape::XML::Node *repr); -void sp_namedview_toggle_grid(SPDocument *doc, Inkscape::XML::Node *repr); -void sp_namedview_set_gridtype(unsigned int type, SPDocument *doc, Inkscape::XML::Node *repr); #endif /* !INKSCAPE_SP_NAMEDVIEW_H */ diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index 39b3e36b4..324b63872 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -92,7 +92,7 @@ DocumentProperties::destroy() DocumentProperties::DocumentProperties() : Dialog ("dialogs.documentoptions", SP_VERB_DIALOG_NAMEDVIEW), - _page_page(1, 1), _page_grid(1, 1), _page_guides(1, 1), + _page_page(1, 1), _page_guides(1, 1), _page_snap(1, 1), _page_grids(1, 1), _grids_button_new(_("_New"), _("Create new grid.")), _grids_button_remove(_("_Remove"), _("Remove selected grid.")), @@ -104,12 +104,12 @@ DocumentProperties::DocumentProperties() get_vbox()->pack_start (_notebook, true, true); _notebook.append_page(_page_page, _("Page")); - _notebook.append_page(_page_grid, _("Grid/Guides")); + _notebook.append_page(_page_guides, _("Guides")); _notebook.append_page(_page_snap, _("Snap")); - _notebook.append_page(_page_grids, _("Grids setup")); + _notebook.append_page(_page_grids, _("Grids")); build_page(); - build_grid(); + build_guides(); build_snap(); build_gridspage(); @@ -237,62 +237,28 @@ DocumentProperties::build_page() } void -DocumentProperties::build_grid() +DocumentProperties::build_guides() { - _page_grid.show(); + _page_guides.show(); - /// \todo FIXME: gray out snapping when grid is off. - /// Dissenting view: you want snapping without grid. - - _rcbgrid.init (_("_Show grid"), _("Show or hide grid"), "showgrid", _wr); - - _rumg.init (_("Grid _units:"), "grid_units", _wr); - _rsu_ox.init (_("_Origin X:"), _("X coordinate of grid origin"), - "gridoriginx", _rumg, _wr); - _rsu_oy.init (_("O_rigin Y:"), _("Y coordinate of grid origin"), - "gridoriginy", _rumg, _wr); - _rsu_sx.init (_("Spacing _X:"), _("Distance between vertical grid lines"), - "gridspacingx", _rumg, _wr); - _rsu_sy.init (_("Spacing _Y:"), _("Distance between horizontal grid lines"), - "gridspacingy", _rumg, _wr); - _rcp_gcol.init (_("Grid line _color:"), _("Grid line color"), - _("Color of grid lines"), "gridcolor", "gridopacity", _wr); - _rcp_gmcol.init (_("Ma_jor grid line color:"), _("Major grid line color"), - _("Color of the major (highlighted) grid lines"), - "gridempcolor", "gridempopacity", _wr); - _rsi.init (_("_Major grid line every:"), _("lines"), "gridempspacing", _wr); _rcb_sgui.init (_("Show _guides"), _("Show or hide guides"), "showguides", _wr); _rcp_gui.init (_("Guide co_lor:"), _("Guideline color"), _("Color of guidelines"), "guidecolor", "guideopacity", _wr); _rcp_hgui.init (_("_Highlight color:"), _("Highlighted guideline color"), _("Color of a guideline when it is under mouse"), "guidehicolor", "guidehiopacity", _wr); - Gtk::Label *label_grid = manage (new Gtk::Label); - label_grid->set_markup (_("Grid")); Gtk::Label *label_gui = manage (new Gtk::Label); label_gui->set_markup (_("Guides")); const Gtk::Widget* widget_array[] = { - label_grid, 0, - 0, _rcbgrid._button, - _rumg._label, _rumg._sel, - 0, _rsu_ox.getSU(), - 0, _rsu_oy.getSU(), - 0, _rsu_sx.getSU(), - 0, _rsu_sy.getSU(), - _rcp_gcol._label, _rcp_gcol._cp, - 0, 0, - _rcp_gmcol._label, _rcp_gmcol._cp, - _rsi._label, &_rsi._hbox, - 0, 0, label_gui, 0, 0, _rcb_sgui._button, _rcp_gui._label, _rcp_gui._cp, _rcp_hgui._label, _rcp_hgui._cp, }; - attach_all (_page_grid.table(), widget_array, sizeof(widget_array)); + attach_all (_page_guides.table(), widget_array, sizeof(widget_array)); } void @@ -399,6 +365,9 @@ DocumentProperties::build_gridspage() { _page_grids.show(); + /// \todo FIXME: gray out snapping when grid is off. + /// Dissenting view: you want snapping without grid. + SPDesktop *dt = SP_ACTIVE_DESKTOP; SPNamedView *nv = sp_desktop_namedview(dt); @@ -461,28 +430,6 @@ DocumentProperties::update() double const doc_h_px = sp_document_height(sp_desktop_document(dt)); _page_sizer.setDim (doc_w_px, doc_h_px); - //-----------------------------------------------------------grid page - _rcbgrid.setActive (nv->showgrid); - _rumg.setUnit (nv->gridunit); - - gdouble val; - val = nv->gridorigin[NR::X]; - val = sp_pixels_get_units (val, *(nv->gridunit)); - _rsu_ox.setValue (val); - val = nv->gridorigin[NR::Y]; - val = sp_pixels_get_units (val, *(nv->gridunit)); - _rsu_oy.setValue (val); - val = nv->gridspacing[NR::X]; - double gridx = sp_pixels_get_units (val, *(nv->gridunit)); - _rsu_sx.setValue (gridx); - val = nv->gridspacing[NR::Y]; - double gridy = sp_pixels_get_units (val, *(nv->gridunit)); - _rsu_sy.setValue (gridy); - - _rcp_gcol.setRgba32 (nv->gridcolor); - _rcp_gmcol.setRgba32 (nv->gridempcolor); - _rsi.setValue (nv->gridempspacing); - //-----------------------------------------------------------guide _rcb_sgui.setActive (nv->showguides); _rcp_gui.setRgba32 (nv->guidecolor); @@ -519,8 +466,6 @@ DocumentProperties::on_response (int id) { _rcp_bg.closeWindow(); _rcp_bord.closeWindow(); - _rcp_gcol.closeWindow(); - _rcp_gmcol.closeWindow(); _rcp_gui.closeWindow(); _rcp_hgui.closeWindow(); } diff --git a/src/ui/dialog/document-properties.h b/src/ui/dialog/document-properties.h index 439ad5701..294bbab43 100644 --- a/src/ui/dialog/document-properties.h +++ b/src/ui/dialog/document-properties.h @@ -56,7 +56,7 @@ protected: Gtk::Tooltips _tt; Gtk::Notebook _notebook; - NotebookPage _page_page, _page_grid, _page_guides; + NotebookPage _page_page, _page_guides; NotebookPage _page_snap; NotebookPage _page_grids; @@ -67,19 +67,15 @@ protected: PageSizer _page_sizer; //--------------------------------------------------------------- RegisteredCheckButton _rcbgrid; //_rcbsnbb, _rcbsnnod - RegisteredUnitMenu _rumg, _rums; - RegisteredScalarUnit _rsu_ox, _rsu_oy, _rsu_sx, _rsu_sy; - RegisteredColorPicker _rcp_gcol, _rcp_gmcol; - RegisteredSuffixedInteger _rsi; + RegisteredUnitMenu _rums; //--------------------------------------------------------------- RegisteredCheckButton _rcb_sgui; //_rcb_snpgui, _rcb_snbgui RegisteredUnitMenu _rum_gusn; - ToleranceSlider _rsu_sn, _rsu_gusn; RegisteredColorPicker _rcp_gui, _rcp_hgui; //--------------------------------------------------------------- RegisteredCheckButton _rcbsnop, _rcbsnon; //_rcbsnbo, _rcbsnnob RegisteredUnitMenu _rumso; - ToleranceSlider _rsu_sno; + ToleranceSlider _rsu_sno, _rsu_sn, _rsu_gusn; RegisteredRadioButtonPair _rrb_pix; //--------------------------------------------------------------- Gtk::Notebook _grids_notebook; diff --git a/src/ui/view/edit-widget.cpp b/src/ui/view/edit-widget.cpp index 79258283d..bac6854a1 100644 --- a/src/ui/view/edit-widget.cpp +++ b/src/ui/view/edit-widget.cpp @@ -1342,7 +1342,9 @@ EditWidget::deactivateDesktop() void EditWidget::viewSetPosition (NR::Point p) { - p -= _namedview->gridorigin; + // p -= _namedview->gridorigin; + /// \todo Why was the origin corrected for the grid origin? (johan) + double lo, up, pos, max; _top_ruler.get_range (lo, up, pos, max); _top_ruler.set_range (lo, up, p[NR::X], max); @@ -1353,18 +1355,19 @@ EditWidget::viewSetPosition (NR::Point p) void EditWidget::updateRulers() { - NR::Point origin = _namedview->gridorigin; - + //NR::Point gridorigin = _namedview->gridorigin; + /// \todo Why was the origin corrected for the grid origin? (johan) + NR::Rect const viewbox = _svg_canvas.spobj()->getViewbox(); double lo, up, pos, max; double const scale = _desktop->current_zoom(); - double s = viewbox.min()[NR::X] / scale - origin[NR::X]; - double e = viewbox.max()[NR::X] / scale - origin[NR::X]; + double s = viewbox.min()[NR::X] / scale; //- gridorigin[NR::X]; + double e = viewbox.max()[NR::X] / scale; //- gridorigin[NR::X]; _top_ruler.get_range(lo, up, pos, max); _top_ruler.set_range(s, e, pos, e); - s = viewbox.min()[NR::Y] / -scale - origin[NR::Y]; - e = viewbox.max()[NR::Y] / -scale - origin[NR::Y]; - _left_ruler.set_range(s, e, origin[NR::Y], e); + s = viewbox.min()[NR::Y] / -scale; //- gridorigin[NR::Y]; + e = viewbox.max()[NR::Y] / -scale; //- gridorigin[NR::Y]; + _left_ruler.set_range(s, e, 0 /*gridorigin[NR::Y]*/, e); /// \todo is that correct? } diff --git a/src/verbs.cpp b/src/verbs.cpp index 172b5220c..977c22cf8 100644 --- a/src/verbs.cpp +++ b/src/verbs.cpp @@ -1551,7 +1551,6 @@ ZoomVerb::perform(SPAction *action, void *data, void *pdata) sp_namedview_toggle_guides(doc, repr); break; case SP_VERB_TOGGLE_GRID: - sp_namedview_toggle_grid(doc, repr); dt->toggleGrid(); break; #ifdef HAVE_GTK_WINDOW_FULLSCREEN diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp index cc723a532..47694518c 100644 --- a/src/widgets/desktop-widget.cpp +++ b/src/widgets/desktop-widget.cpp @@ -963,7 +963,8 @@ sp_desktop_widget_new (SPNamedView *namedview) SPDesktopWidget *dtw = (SPDesktopWidget*)gtk_type_new (SP_TYPE_DESKTOP_WIDGET); dtw->dt2r = 1.0 / namedview->doc_units->unittobase; - dtw->ruler_origin = namedview->gridorigin; + + dtw->ruler_origin = NR::Point(0,0); //namedview->gridorigin; Why was the grid origin used here? dtw->desktop = new SPDesktop(); dtw->stub = new SPDesktopWidget::WidgetStub (dtw); @@ -1032,7 +1033,7 @@ sp_desktop_widget_namedview_modified (SPObject *obj, guint flags, SPDesktopWidge SPNamedView *nv=SP_NAMEDVIEW(obj); if (flags & SP_OBJECT_MODIFIED_FLAG) { dtw->dt2r = 1.0 / nv->doc_units->unittobase; - dtw->ruler_origin = nv->gridorigin; + dtw->ruler_origin = NR::Point(0,0); //nv->gridorigin; Why was the grid origin used here? sp_ruler_set_metric (GTK_RULER (dtw->vruler), nv->getDefaultMetric()); sp_ruler_set_metric (GTK_RULER (dtw->hruler), nv->getDefaultMetric());