Merge lp:~mw-triad/inkscape/polygonal-grid into lp:~inkscape.dev/inkscape/trunk

Proposed by jazzynico
Status: Needs review
Proposed branch: lp:~mw-triad/inkscape/polygonal-grid
Merge into: lp:~inkscape.dev/inkscape/trunk
Diff against target: 1118 lines (+938/-17) (has conflicts)
8 files modified
src/display/CMakeLists.txt (+1/-0)
src/display/canvas-grid.cpp (+33/-2)
src/display/canvas-grid.h (+3/-2)
src/display/canvas-ngongrid.cpp (+747/-0)
src/display/canvas-ngongrid.h (+94/-0)
src/ui/dialog/document-properties.cpp (+2/-0)
src/ui/dialog/inkscape-preferences.cpp (+46/-13)
src/ui/dialog/inkscape-preferences.h (+12/-0)
Text conflict in src/display/canvas-grid.cpp
Text conflict in src/ui/dialog/inkscape-preferences.cpp
To merge this branch: bzr merge lp:~mw-triad/inkscape/polygonal-grid
Reviewer Review Type Date Requested Status
jazzynico (community) Needs Fixing
Review via email: mp+293349@code.launchpad.net

Description of the change

Generating diff against the current trunk.

To post a comment you must log in.
Revision history for this message
jazzynico (jazzynico) wrote :

@Matthew - I know you submitted your branch a long time ago, and I'm sorry we didn't find time to review it sooner. But I'm sure it's an interesting feature and it would be great if we could port it to the current development code.
Would you be willing to fix the conflicts in canvas-grip.cpp and inkscape-preferences.cpp, or give ownership of the branch to the "Inkscape Developers" group so that we can work on it directly?
Thanks!

review: Needs Fixing

Unmerged revisions

11944. By Matthew Woehlke

fix wrong snap for grid origin != (0, 0)

Fix missing addition of grid offset, causing broken snapping to
polygonal grid when grid origin is not (0, 0).

11943. By Matthew Woehlke

implement polygonal grid snapping

Add necessary code to find the nearest relevant lines to which to snap
for the polygonal grid.

11942. By Matthew Woehlke

auto-extents improvements

Compute minimum X extent so we don't render concentric segments that
aren't needed. Add note that we could do better skipping sections that
won't be visible.

11941. By Matthew Woehlke

fix polygonal grid extents

Hook up polygonal grid extents calculation so that we always draw enough
grid to fill the viewport, rather than truncating the grid at an
arbitrary point.

11940. By Matthew Woehlke

start implementing polygonal grid renderingg

Implement basic rendering for the polygonal grid. For now, this uses an
arbitrary max extent (rather than determining max extents per section
with respect to the viewport), and doesn't attempt to clip grid lines to
the viewport. Also, snapping is not yet implemented (the old code from
the axonometric grid has been commented out for now).

11939. By Matthew Woehlke

implement UI for polygonal grid

Modify the UI for polygonal grid to have the appropriate parameters,
rather than those copied from axonometric grid. Since the grid logic has
not been changed yet, we are using the rotation angle as both angles for
the axonometric logic (which gives a degenerate grid with the default
value 0).

11938. By Matthew Woehlke

add template for polygonal grid

Create new 'polygonal' grid type. Right now this is just a copy of the
axonometric grid type, to get the necessary bits in place before
starting to develop the actual logic.

11937. By Matthew Woehlke

whitespace fix

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/display/CMakeLists.txt'
--- src/display/CMakeLists.txt 2015-12-10 05:43:23 +0000
+++ src/display/CMakeLists.txt 2016-04-29 07:04:20 +0000
@@ -5,6 +5,7 @@
5 canvas-axonomgrid.cpp5 canvas-axonomgrid.cpp
6 canvas-bpath.cpp6 canvas-bpath.cpp
7 canvas-grid.cpp7 canvas-grid.cpp
8 canvas-ngongrid.cpp
8 canvas-temporary-item-list.cpp9 canvas-temporary-item-list.cpp
9 canvas-temporary-item.cpp10 canvas-temporary-item.cpp
10 canvas-text.cpp11 canvas-text.cpp
1112
=== modified file 'src/display/canvas-grid.cpp'
--- src/display/canvas-grid.cpp 2015-05-06 11:55:31 +0000
+++ src/display/canvas-grid.cpp 2016-04-29 07:04:20 +0000
@@ -36,6 +36,7 @@
36#include "display/cairo-utils.h"36#include "display/cairo-utils.h"
37#include "display/canvas-axonomgrid.h"37#include "display/canvas-axonomgrid.h"
38#include "display/canvas-grid.h"38#include "display/canvas-grid.h"
39#include "display/canvas-ngongrid.h"
39#include "display/sp-canvas-group.h"40#include "display/sp-canvas-group.h"
40#include "document.h"41#include "document.h"
41#include "util/units.h"42#include "util/units.h"
@@ -58,11 +59,13 @@
5859
59static gchar const *const grid_name[] = {60static gchar const *const grid_name[] = {
60 N_("Rectangular grid"),61 N_("Rectangular grid"),
61 N_("Axonometric grid")62 N_("Axonometric grid"),
63 N_("Polygonal grid")
62};64};
63static gchar const *const grid_svgname[] = {65static gchar const *const grid_svgname[] = {
64 "xygrid",66 "xygrid",
65 "axonomgrid"67 "axonomgrid",
68 "ngongrid"
66};69};
6770
6871
@@ -72,7 +75,33 @@
72static void grid_canvasitem_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned int flags);75static void grid_canvasitem_update (SPCanvasItem *item, Geom::Affine const &affine, unsigned int flags);
73static void grid_canvasitem_render (SPCanvasItem *item, SPCanvasBuf *buf);76static void grid_canvasitem_render (SPCanvasItem *item, SPCanvasBuf *buf);
7477
78<<<<<<< TREE
75G_DEFINE_TYPE(GridCanvasItem, grid_canvasitem, SP_TYPE_CANVAS_ITEM);79G_DEFINE_TYPE(GridCanvasItem, grid_canvasitem, SP_TYPE_CANVAS_ITEM);
80=======
81static SPCanvasItemClass * parent_class;
82
83GType
84grid_canvasitem_get_type (void)
85{
86 static GType grid_canvasitem_type = 0;
87
88 if (!grid_canvasitem_type) {
89 GTypeInfo grid_canvasitem_info = {
90 sizeof (GridCanvasItemClass),
91 NULL, NULL,
92 (GClassInitFunc) grid_canvasitem_class_init,
93 NULL, NULL,
94 sizeof (GridCanvasItem),
95 0,
96 (GInstanceInitFunc) grid_canvasitem_init,
97 NULL
98 };
99
100 grid_canvasitem_type = g_type_register_static(SPCanvasItem::getType(), "GridCanvasItem", &grid_canvasitem_info, GTypeFlags(0));
101 }
102 return grid_canvasitem_type;
103}
104>>>>>>> MERGE-SOURCE
76105
77static void grid_canvasitem_class_init(GridCanvasItemClass *klass)106static void grid_canvasitem_class_init(GridCanvasItemClass *klass)
78{107{
@@ -263,6 +292,8 @@
263 return dynamic_cast<CanvasGrid*>(new CanvasXYGrid(nv, repr, doc));292 return dynamic_cast<CanvasGrid*>(new CanvasXYGrid(nv, repr, doc));
264 case GRID_AXONOMETRIC:293 case GRID_AXONOMETRIC:
265 return dynamic_cast<CanvasGrid*>(new CanvasAxonomGrid(nv, repr, doc));294 return dynamic_cast<CanvasGrid*>(new CanvasAxonomGrid(nv, repr, doc));
295 case GRID_POLYGONAL:
296 return dynamic_cast<CanvasGrid*>(new CanvasNGonGrid(nv, repr, doc));
266 }297 }
267298
268 return NULL;299 return NULL;
269300
=== modified file 'src/display/canvas-grid.h'
--- src/display/canvas-grid.h 2014-10-08 02:22:03 +0000
+++ src/display/canvas-grid.h 2016-04-29 07:04:20 +0000
@@ -34,9 +34,10 @@
3434
35enum GridType {35enum GridType {
36 GRID_RECTANGULAR = 0,36 GRID_RECTANGULAR = 0,
37 GRID_AXONOMETRIC = 137 GRID_AXONOMETRIC = 1,
38 GRID_POLYGONAL = 2
38};39};
39#define GRID_MAXTYPENR 140#define GRID_MAXTYPENR 2
4041
41#define INKSCAPE_TYPE_GRID_CANVASITEM (Inkscape::grid_canvasitem_get_type ())42#define INKSCAPE_TYPE_GRID_CANVASITEM (Inkscape::grid_canvasitem_get_type ())
42#define INKSCAPE_GRID_CANVASITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), INKSCAPE_TYPE_GRID_CANVASITEM, GridCanvasItem))43#define INKSCAPE_GRID_CANVASITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), INKSCAPE_TYPE_GRID_CANVASITEM, GridCanvasItem))
4344
=== added file 'src/display/canvas-ngongrid.cpp'
--- src/display/canvas-ngongrid.cpp 1970-01-01 00:00:00 +0000
+++ src/display/canvas-ngongrid.cpp 2016-04-29 07:04:20 +0000
@@ -0,0 +1,747 @@
1/*
2 * Authors:
3 * Matthew Woehlke <mw_triad@users.sourceforge.net>
4 * Johan Engelen <j.b.c.engelen@alumnus.utwente.nl>
5 *
6 * Copyright (C) 2006-2012 Authors
7 * Released under GNU GPL, read the file 'COPYING' for more information
8 */
9
10 /*
11 * Current limits are: one axis (y-axis) is always vertical. The other two
12 * axes are bound to a certain range of angles. The z-axis always has an angle
13 * smaller than 90 degrees (measured from horizontal, 0 degrees being a line extending
14 * to the right). The x-axis will always have an angle between 0 and 90 degrees.
15 */
16
17
18#include <gtkmm/box.h>
19#include <gtkmm/label.h>
20#include <gtkmm/table.h>
21#include <glibmm/i18n.h>
22
23#include "display/canvas-ngongrid.h"
24
25#include "ui/widget/registered-widget.h"
26#include "desktop.h"
27#include "desktop-handles.h"
28#include "display/cairo-utils.h"
29#include "display/canvas-grid.h"
30#include "display/sp-canvas-util.h"
31#include "display/sp-canvas.h"
32#include "document.h"
33#include "inkscape.h"
34#include "preferences.h"
35#include "sp-namedview.h"
36#include "sp-object.h"
37#include "svg/svg-color.h"
38#include "2geom/line.h"
39#include "2geom/angle.h"
40#include "util/mathfns.h"
41#include "round.h"
42#include "helper/units.h"
43
44
45/**
46 * This function calls Cairo to render a line on a particular canvas buffer.
47 * Coordinates are interpreted as SCREENcoordinates
48 */
49static void
50sp_cngongrid_drawline (SPCanvasBuf *buf, gdouble x0, gdouble y0, gdouble x1, gdouble y1, guint32 rgba)
51{
52 // Prevent aliasing of horizontal/vertical lines
53 if (Geom::are_near(x0, x1)) {
54 x0 = round(x0);
55 x1 = round(x1);
56 }
57 if (Geom::are_near(y0, y1)) {
58 y0 = round(y0);
59 y1 = round(y1);
60 }
61 //TODO: clip to viewport?
62 cairo_move_to(buf->ct, 0.5 + x0, 0.5 + y0);
63 cairo_line_to(buf->ct, 0.5 + x1, 0.5 + y1);
64 ink_cairo_set_source_rgba32(buf->ct, rgba);
65 cairo_stroke(buf->ct);
66}
67
68static gdouble
69distance(gdouble x, gdouble y, double dx, double dy)
70{
71 return (dy * x) - (dx * y);
72}
73
74static gdouble
75find_bound(Geom::Rect const &rect, double dx, double dy, gdouble const & (*bound_func)(gdouble const &, gdouble const &))
76{
77 // Note: Y+ is DOWN, not up!
78 if ( (dx > 0.0) == (dy > 0.0) ) { // Interesting points are bottom-left, top-right
79 gdouble const a = distance(rect.left(), rect.bottom(), dx, dy);
80 gdouble const b = distance(rect.right(), rect.top(), dx, dy);
81 return bound_func(a, b);
82 } else { // Interesting points are top-left, bottom-right
83 gdouble const a = distance(rect.left(), rect.top(), dx, dy);
84 gdouble const b = distance(rect.right(), rect.bottom(), dx, dy);
85 return bound_func(a, b);
86 }
87}
88
89namespace Inkscape {
90
91
92/**
93* A DIRECT COPY-PASTE FROM DOCUMENT-PROPERTIES.CPP TO QUICKLY GET RESULTS
94*
95 * Helper function that attachs widgets in a 3xn table. The widgets come in an
96 * array that has two entries per table row. The two entries code for four
97 * possible cases: (0,0) means insert space in first column; (0, non-0) means
98 * widget in columns 2-3; (non-0, 0) means label in columns 1-3; and
99 * (non-0, non-0) means two widgets in columns 2 and 3.
100**/
101#define SPACE_SIZE_X 15
102#define SPACE_SIZE_Y 10
103static inline void
104attach_all(Gtk::Table &table, Gtk::Widget const *const arr[], unsigned size, int start = 0)
105{
106 for (unsigned i=0, r=start; i<size/sizeof(Gtk::Widget*); i+=2) {
107 if (arr[i] && arr[i+1]) {
108 table.attach (const_cast<Gtk::Widget&>(*arr[i]), 1, 2, r, r+1,
109 Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0);
110 table.attach (const_cast<Gtk::Widget&>(*arr[i+1]), 2, 3, r, r+1,
111 Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0);
112 } else {
113 if (arr[i+1]) {
114 table.attach (const_cast<Gtk::Widget&>(*arr[i+1]), 1, 3, r, r+1,
115 Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0);
116 } else if (arr[i]) {
117 Gtk::Label& label = reinterpret_cast<Gtk::Label&> (const_cast<Gtk::Widget&>(*arr[i]));
118 label.set_alignment (0.0);
119 table.attach (label, 0, 3, r, r+1,
120 Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0,0,0);
121 } else {
122 Gtk::HBox *space = manage (new Gtk::HBox);
123 space->set_size_request (SPACE_SIZE_X, SPACE_SIZE_Y);
124 table.attach (*space, 0, 1, r, r+1,
125 (Gtk::AttachOptions)0, (Gtk::AttachOptions)0,0,0);
126 }
127 }
128 ++r;
129 }
130}
131
132CanvasNGonGrid::CanvasNGonGrid (SPNamedView * nv, Inkscape::XML::Node * in_repr, SPDocument * in_doc)
133 : CanvasGrid(nv, in_repr, in_doc, GRID_POLYGONAL)
134{
135 Inkscape::Preferences *prefs = Inkscape::Preferences::get();
136 gridunit = sp_unit_get_by_abbreviation( prefs->getString("/options/grids/ngon/units").data() );
137 if (!gridunit)
138 gridunit = &sp_unit_get_by_id(SP_UNIT_PX);
139 origin[Geom::X] = sp_units_get_pixels( prefs->getDouble("/options/grids/ngon/origin_x", 0.0), *gridunit );
140 origin[Geom::Y] = sp_units_get_pixels( prefs->getDouble("/options/grids/ngon/origin_y", 0.0), *gridunit );
141 sections = prefs->getInt("/options/grids/ngon/sect_n", 8);
142 lengthx = sp_units_get_pixels( prefs->getDouble("/options/grids/ngon/spacing_x", 1.0), *gridunit );
143 lengthy = sp_units_get_pixels( prefs->getDouble("/options/grids/ngon/spacing_y", 1.0), *gridunit );
144 angle_deg = prefs->getDouble("/options/grids/ngon/rotation", 0.0);
145 color = prefs->getInt("/options/grids/ngon/color", 0x0000ff20);
146 empcolor = prefs->getInt("/options/grids/ngon/empcolor", 0x0000ff40);
147 empspacing = prefs->getInt("/options/grids/ngon/empspacing", 5);
148
149 angle_rad = Geom::deg_to_rad(angle_deg);
150 se_angle_deg = 180.0 / sections;
151 se_angle_rad = Geom::deg_to_rad(se_angle_deg);
152 se_tan = tan(se_angle_rad);
153
154 snapper = new CanvasNGonGridSnapper(this, &namedview->snap_manager, 0);
155
156 if (repr) readRepr();
157}
158
159CanvasNGonGrid::~CanvasNGonGrid ()
160{
161 if (snapper) delete snapper;
162}
163
164
165/* fixme: Collect all these length parsing methods and think common sane API */
166
167static gboolean sp_nv_read_length(gchar const *str, guint base, gdouble *val, SPUnit const **unit)
168{
169 if (!str) {
170 return FALSE;
171 }
172
173 gchar *u;
174 gdouble v = g_ascii_strtod(str, &u);
175 if (!u) {
176 return FALSE;
177 }
178 while (isspace(*u)) {
179 u += 1;
180 }
181
182 if (!*u) {
183 /* No unit specified - keep default */
184 *val = v;
185 return TRUE;
186 }
187
188 if (base & SP_UNIT_DEVICE) {
189 if (u[0] && u[1] && !isalnum(u[2]) && !strncmp(u, "px", 2)) {
190 *unit = &sp_unit_get_by_id(SP_UNIT_PX);
191 *val = v;
192 return TRUE;
193 }
194 }
195
196 if (base & SP_UNIT_ABSOLUTE) {
197 if (!strncmp(u, "pt", 2)) {
198 *unit = &sp_unit_get_by_id(SP_UNIT_PT);
199 } else if (!strncmp(u, "mm", 2)) {
200 *unit = &sp_unit_get_by_id(SP_UNIT_MM);
201 } else if (!strncmp(u, "cm", 2)) {
202 *unit = &sp_unit_get_by_id(SP_UNIT_CM);
203 } else if (!strncmp(u, "m", 1)) {
204 *unit = &sp_unit_get_by_id(SP_UNIT_M);
205 } else if (!strncmp(u, "in", 2)) {
206 *unit = &sp_unit_get_by_id(SP_UNIT_IN);
207 } else if (!strncmp(u, "ft", 2)) {
208 *unit = &sp_unit_get_by_id(SP_UNIT_FT);
209 } else if (!strncmp(u, "pc", 2)) {
210 *unit = &sp_unit_get_by_id(SP_UNIT_PC);
211 } else {
212 return FALSE;
213 }
214 *val = v;
215 return TRUE;
216 }
217
218 return FALSE;
219}
220
221static gboolean sp_nv_read_opacity(gchar const *str, guint32 *color)
222{
223 if (!str) {
224 return FALSE;
225 }
226
227 gchar *u;
228 gdouble v = g_ascii_strtod(str, &u);
229 if (!u) {
230 return FALSE;
231 }
232 v = CLAMP(v, 0.0, 1.0);
233
234 *color = (*color & 0xffffff00) | (guint32) floor(v * 255.9999);
235
236 return TRUE;
237}
238
239
240
241void
242CanvasNGonGrid::readRepr()
243{
244 gchar const *value;
245 if ( (value = repr->attribute("originx")) ) {
246 sp_nv_read_length(value, SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE, &origin[Geom::X], &gridunit);
247 origin[Geom::X] = sp_units_get_pixels(origin[Geom::X], *(gridunit));
248 }
249 if ( (value = repr->attribute("originy")) ) {
250 sp_nv_read_length(value, SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE, &origin[Geom::Y], &gridunit);
251 origin[Geom::Y] = sp_units_get_pixels(origin[Geom::Y], *(gridunit));
252 }
253
254 if ( (value = repr->attribute("sections")) ) {
255 sections = atoi(value);
256 if (sections < 3) sections = 3;
257 if (sections > 360) sections = 360;
258 se_angle_deg = 180.0 / sections;
259 se_angle_rad = Geom::deg_to_rad(se_angle_deg);
260 se_tan = tan(se_angle_rad);
261 }
262
263 if ( (value = repr->attribute("spacingx")) ) {
264 sp_nv_read_length(value, SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE, &lengthx, &gridunit);
265 lengthx = sp_units_get_pixels(lengthx, *(gridunit));
266 if (lengthx < 0.0500) lengthx = 0.0500;
267 }
268
269 if ( (value = repr->attribute("spacingy")) ) {
270 sp_nv_read_length(value, SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE, &lengthy, &gridunit);
271 lengthy = sp_units_get_pixels(lengthy, *(gridunit));
272 if (lengthy < 0.0500) lengthy = 0.0500;
273 }
274
275 if ( (value = repr->attribute("rotation")) ) {
276 angle_deg = g_ascii_strtod(value, NULL);
277 double max_angle = 360.0 / sections;
278 if (fabs(angle_deg) > max_angle) angle_deg = fmod(angle_deg, max_angle);
279 angle_rad = Geom::deg_to_rad(angle_deg);
280 }
281
282 if ( (value = repr->attribute("color")) ) {
283 color = (color & 0xff) | sp_svg_read_color(value, color);
284 }
285
286 if ( (value = repr->attribute("empcolor")) ) {
287 empcolor = (empcolor & 0xff) | sp_svg_read_color(value, empcolor);
288 }
289
290 if ( (value = repr->attribute("opacity")) ) {
291 sp_nv_read_opacity(value, &color);
292 }
293 if ( (value = repr->attribute("empopacity")) ) {
294 sp_nv_read_opacity(value, &empcolor);
295 }
296
297 if ( (value = repr->attribute("empspacing")) ) {
298 empspacing = atoi(value);
299 }
300
301 if ( (value = repr->attribute("visible")) ) {
302 visible = (strcmp(value,"false") != 0 && strcmp(value, "0") != 0);
303 }
304
305 if ( (value = repr->attribute("enabled")) ) {
306 g_assert(snapper != NULL);
307 snapper->setEnabled(strcmp(value,"false") != 0 && strcmp(value, "0") != 0);
308 }
309
310 if ( (value = repr->attribute("snapvisiblegridlinesonly")) ) {
311 g_assert(snapper != NULL);
312 snapper->setSnapVisibleOnly(strcmp(value,"false") != 0 && strcmp(value, "0") != 0);
313 }
314
315 for (GSList *l = canvasitems; l != NULL; l = l->next) {
316 sp_canvas_item_request_update ( SP_CANVAS_ITEM(l->data) );
317 }
318 return;
319}
320
321/**
322 * Called when XML node attribute changed; updates dialog widgets if change was not done by widgets themselves.
323 */
324void
325CanvasNGonGrid::onReprAttrChanged(Inkscape::XML::Node */*repr*/, gchar const */*key*/, gchar const */*oldval*/, gchar const */*newval*/, bool /*is_interactive*/)
326{
327 readRepr();
328
329 if ( ! (_wr.isUpdating()) )
330 updateWidgets();
331}
332
333
334
335
336Gtk::Widget *
337CanvasNGonGrid::newSpecificWidget()
338{
339 Gtk::Table * table = Gtk::manage( new Gtk::Table(1,1) );
340 table->set_spacings(2);
341
342_wr.setUpdating (true);
343
344 Inkscape::UI::Widget::RegisteredUnitMenu *_rumg = Gtk::manage( new Inkscape::UI::Widget::RegisteredUnitMenu(
345 _("Grid _units:"), "units", _wr, repr, doc) );
346 Inkscape::UI::Widget::RegisteredScalarUnit *_rsu_ox = Gtk::manage( new Inkscape::UI::Widget::RegisteredScalarUnit(
347 _("_Origin X:"), _("X coordinate of grid origin"), "originx", *_rumg, _wr, repr, doc) );
348 Inkscape::UI::Widget::RegisteredScalarUnit *_rsu_oy = Gtk::manage( new Inkscape::UI::Widget::RegisteredScalarUnit(
349 _("O_rigin Y:"), _("Y coordinate of grid origin"), "originy", *_rumg, _wr, repr, doc) );
350 Inkscape::UI::Widget::RegisteredScalar *_rsu_ns = Gtk::manage( new Inkscape::UI::Widget::RegisteredScalar(
351 _("_Number of sections:"), "", "sections", _wr, repr, doc ) );
352 Inkscape::UI::Widget::RegisteredScalarUnit *_rsu_sx = Gtk::manage( new Inkscape::UI::Widget::RegisteredScalarUnit(
353 _("Spacing _X:"), _("Distance between concentric grid polygons"), "spacingx", *_rumg, _wr, repr, doc) );
354 Inkscape::UI::Widget::RegisteredScalarUnit *_rsu_sy = Gtk::manage( new Inkscape::UI::Widget::RegisteredScalarUnit(
355 _("Spacing _Y:"), _("Distance between semi-radial grid lines"), "spacingy", *_rumg, _wr, repr, doc) );
356 Inkscape::UI::Widget::RegisteredScalar *_rsu_ar = Gtk::manage( new Inkscape::UI::Widget::RegisteredScalar(
357 _("Ro_tation:"), _("Angle of axis rotation"), "rotation", _wr, repr, doc ) );
358
359 Inkscape::UI::Widget::RegisteredColorPicker *_rcp_gcol = Gtk::manage(
360 new Inkscape::UI::Widget::RegisteredColorPicker(
361 _("Minor grid line _color:"), _("Minor grid line color"), _("Color of the minor grid lines"),
362 "color", "opacity", _wr, repr, doc));
363
364 Inkscape::UI::Widget::RegisteredColorPicker *_rcp_gmcol = Gtk::manage(
365 new Inkscape::UI::Widget::RegisteredColorPicker(
366 _("Ma_jor grid line color:"), _("Major grid line color"),
367 _("Color of the major (highlighted) grid lines"),
368 "empcolor", "empopacity", _wr, repr, doc));
369
370 Inkscape::UI::Widget::RegisteredSuffixedInteger *_rsi = Gtk::manage( new Inkscape::UI::Widget::RegisteredSuffixedInteger(
371 _("_Major grid line every:"), "", _("lines"), "empspacing", _wr, repr, doc ) );
372
373 _rsu_ox->setDigits(5);
374 _rsu_ox->setIncrements(0.1, 1.0);
375
376 _rsu_oy->setDigits(5);
377 _rsu_oy->setIncrements(0.1, 1.0);
378
379 _rsu_ns->setDigits(0);
380 _rsu_ns->setIncrements(1, 3);
381
382 _rsu_sx->setDigits(5);
383 _rsu_sx->setIncrements(0.1, 1.0);
384
385 _rsu_sy->setDigits(5);
386 _rsu_sy->setIncrements(0.1, 1.0);
387
388 _rsu_ar->setDigits(5);
389 _rsu_ar->setIncrements(0.5, 5.0);
390
391_wr.setUpdating (false);
392
393 Gtk::Widget const *const widget_array[] = {
394 0, _rumg,
395 0, _rsu_ox,
396 0, _rsu_oy,
397 0, _rsu_ns,
398 0, _rsu_sx,
399 0, _rsu_sy,
400 0, _rsu_ar,
401 _rcp_gcol->_label, _rcp_gcol,
402 0, 0,
403 _rcp_gmcol->_label, _rcp_gmcol,
404 0, _rsi,
405 };
406
407 attach_all (*table, widget_array, sizeof(widget_array));
408
409 // set widget values
410 _rumg->setUnit (gridunit);
411
412 gdouble val;
413 val = origin[Geom::X];
414 val = sp_pixels_get_units (val, *(gridunit));
415 _rsu_ox->setValue (val);
416 val = origin[Geom::Y];
417 val = sp_pixels_get_units (val, *(gridunit));
418 _rsu_oy->setValue (val);
419 _rsu_ns->setValue (sections);
420 val = lengthx;
421 double gridx = sp_pixels_get_units (val, *(gridunit));
422 _rsu_sx->setValue (gridx);
423 val = lengthy;
424 double gridy = sp_pixels_get_units (val, *(gridunit));
425 _rsu_sy->setValue (gridy);
426
427 _rsu_ar->setValue(angle_deg);
428
429 _rcp_gcol->setRgba32 (color);
430 _rcp_gmcol->setRgba32 (empcolor);
431 _rsi->setValue (empspacing);
432
433 return table;
434}
435
436
437/**
438 * Update dialog widgets from object's values.
439 */
440void
441CanvasNGonGrid::updateWidgets()
442{
443/* if (_wr.isUpdating()) return;
444
445 _wr.setUpdating (true);
446
447 _rcb_visible.setActive(visible);
448 if (snapper != NULL) {
449 _rcb_enabled.setActive(snapper->getEnabled());
450 }
451
452 _rumg.setUnit (gridunit);
453
454 gdouble val;
455 val = origin[Geom::X];
456 val = sp_pixels_get_units (val, *(gridunit));
457 _rsu_ox->setValue (val);
458 val = origin[Geom::Y];
459 val = sp_pixels_get_units (val, *(gridunit));
460 _rsu_oy->setValue (val);
461 val = lengthx;
462 double gridx = sp_pixels_get_units (val, *(gridunit));
463 _rsu_sx->setValue (gridx);
464 val = lengthy;
465 double gridy = sp_pixels_get_units (val, *(gridunit));
466 _rsu_sy->setValue (gridy);
467
468 _rsu_ar->setValue(angle_deg);
469
470 _rcp_gcol->setRgba32 (color);
471 _rcp_gmcol->setRgba32 (empcolor);
472 _rsi->setValue (empspacing);
473
474 _wr.setUpdating (false);
475
476 return;
477 */
478}
479
480
481
482void
483CanvasNGonGrid::Update (Geom::Affine const &affine, unsigned int /*flags*/)
484{
485 ow = origin * affine;
486 sw = Geom::Point(fabs(affine[0]),fabs(affine[3]));
487 sw[Geom::X] *= lengthx;
488 sw[Geom::Y] *= lengthy;
489
490 scaled = false;
491
492 for(int dim = 0; dim < 2; dim++) {
493 gint scaling_factor = empspacing;
494
495 if (scaling_factor <= 1)
496 scaling_factor = 5;
497
498 int watchdog = 0;
499 while ( (sw[dim] < 8.0) & (watchdog < 100) ) {
500 scaled = true;
501 sw[dim] *= scaling_factor;
502 // First pass, go up to the major line spacing, then
503 // keep increasing by two.
504 scaling_factor = 2;
505 watchdog++;
506 }
507
508 }
509
510 lxw = sw[Geom::X];
511 lyw = sw[Geom::Y];
512
513 if (empspacing == 0) {
514 scaled = true;
515 }
516}
517
518void
519CanvasNGonGrid::Render (SPCanvasBuf *buf)
520{
521 //set correct coloring, depending preference (when zoomed out, always major coloring or minor coloring)
522 Inkscape::Preferences *prefs = Inkscape::Preferences::get();
523 guint32 _empcolor;
524 bool preference = prefs->getBool("/options/grids/no_emphasize_when_zoomedout", false);
525 if( scaled && preference ) {
526 _empcolor = color;
527 } else {
528 _empcolor = empcolor;
529 }
530
531 cairo_save(buf->ct);
532 cairo_translate(buf->ct, -buf->rect.left(), -buf->rect.top());
533 cairo_set_line_width(buf->ct, 1.0);
534 cairo_set_line_cap(buf->ct, CAIRO_LINE_CAP_SQUARE);
535
536 double angle_step = 360.0 / sections;
537 for (int s = 0; s < sections; ++s) {
538 //TODO: get angles from origin to viewport corners, use to test if section needs to be rendered
539 renderSection(buf, (s * angle_step) - angle_deg, _empcolor);
540 }
541
542 cairo_restore(buf->ct);
543}
544
545void
546CanvasNGonGrid::renderSection (SPCanvasBuf *buf, double section_angle_deg, guint32 _empcolor)
547{
548 // pc = preimagecoordinates (the coordinates of the section before rotation)
549 // gc = gridcoordinates (the coordinates calculated from the grids origin 'grid->ow')
550
551 Geom::Rect buf_gc(buf->rect);
552 buf_gc -= ow;
553
554 double const section_angle_rad = Geom::deg_to_rad(section_angle_deg);
555 double const section_sin = sin(section_angle_rad);
556 double const section_cos = cos(section_angle_rad);
557
558 gdouble xmin = find_bound(buf_gc, -section_sin, section_cos, &std::min) / lxw;
559 gdouble xmax = find_bound(buf_gc, -section_sin, section_cos, &std::max) / lxw;
560 if (xmax <= 0) return; // Section is entirely out of viewport
561
562 gdouble ymin = find_bound(buf_gc, -section_cos, -section_sin, &std::min) / lyw;
563 gdouble ymax = find_bound(buf_gc, -section_cos, -section_sin, &std::max) / lyw;
564
565 gdouble const lxmax = xmax * lxw;
566 gdouble const xbound = (floor(xmax) + 0.5) * lxw;
567 gdouble const ybound = (floor(ymax) + 0.5) * lyw;
568
569 // Render section edge line
570 {
571 gdouble const pc_x = lxmax;
572 gdouble const pc_y = lxmax * se_tan;
573 gdouble const gc_x1 = ( (pc_x * section_cos) - (pc_y * section_sin) ) + ow[Geom::X];
574 gdouble const gc_y1 = ( (pc_x * section_sin) + (pc_y * section_cos) ) + ow[Geom::Y];
575 sp_cngongrid_drawline (buf, ow[Geom::X], ow[Geom::Y], gc_x1, gc_y1, color);
576 }
577
578 // Render semi-radius lines
579 ymin = ceil(ymin);
580 gint xlinenum = ymin;
581 for (gdouble y = ymin * lyw; y <= ybound; y += lyw, xlinenum++) {
582 // Compute points in preimage coordinates
583 gdouble const pc_x0 = fabs(y) / se_tan;
584 gdouble const pc_x1 = lxmax;
585 if (pc_x1 <= pc_x0) continue;
586 // Compute points in grid coordinates (with rotation applied)
587 gdouble const ys = y * section_sin;
588 gdouble const yc = y * section_cos;
589 gdouble const gc_x0 = ( (pc_x0 * section_cos) - ys ) + ow[Geom::X];
590 gdouble const gc_x1 = ( (pc_x1 * section_cos) - ys ) + ow[Geom::X];
591 gdouble const gc_y0 = ( (pc_x0 * section_sin) + yc ) + ow[Geom::Y];
592 gdouble const gc_y1 = ( (pc_x1 * section_sin) + yc ) + ow[Geom::Y];
593 // Draw segment
594 guint32 const _color = ( (!scaled && (xlinenum % empspacing) != 0) ? color : _empcolor);
595 sp_cngongrid_drawline (buf, gc_x0, gc_y0, gc_x1, gc_y1, _color);
596 }
597
598 // Render concentric lines
599 xmin = std::max(1.0, ceil(xmin));
600 gint ylinenum = xmin;
601 for (gdouble x = xmin * lxw; x < xbound; x += lxw, ylinenum++) {
602 // Compute points in preimage coordinates
603 gdouble const pc_y = x * se_tan;
604 // Compute points in grid coordinates (with rotation applied)
605 gdouble const xs = x * section_sin;
606 gdouble const xc = x * section_cos;
607 gdouble const ys = pc_y * section_sin;
608 gdouble const yc = pc_y * section_cos;
609 gdouble const gc_x0 = xc + ys + ow[Geom::X];
610 gdouble const gc_x1 = xc - ys + ow[Geom::X];
611 gdouble const gc_y0 = xs - yc + ow[Geom::Y];
612 gdouble const gc_y1 = xs + yc + ow[Geom::Y];
613 // Draw segment
614 guint32 const _color = ( (!scaled && (ylinenum % empspacing) != 0) ? color : _empcolor);
615 sp_cngongrid_drawline (buf, gc_x0, gc_y0, gc_x1, gc_y1, _color);
616 }
617}
618
619CanvasNGonGridSnapper::CanvasNGonGridSnapper(CanvasNGonGrid *grid, SnapManager *sm, Geom::Coord const d) : LineSnapper(sm, d)
620{
621 this->grid = grid;
622}
623
624/**
625 * \return Snap tolerance (desktop coordinates); depends on current zoom so that it's always the same in screen pixels
626 */
627Geom::Coord CanvasNGonGridSnapper::getSnapperTolerance() const
628{
629 SPDesktop const *dt = _snapmanager->getDesktop();
630 double const zoom = dt ? dt->current_zoom() : 1;
631 return _snapmanager->snapprefs.getGridTolerance() / zoom;
632}
633
634bool CanvasNGonGridSnapper::getSnapperAlwaysSnap() const
635{
636 return _snapmanager->snapprefs.getGridTolerance() == 10000; //TODO: Replace this threshold of 10000 by a constant; see also tolerance-slider.cpp
637}
638
639LineSnapper::LineList
640CanvasNGonGridSnapper::_getSnapLines(Geom::Point const &p) const
641{
642 LineList s;
643
644 if ( grid == NULL ) {
645 return s;
646 }
647
648 double spacing_h;
649 double spacing_v;
650
651 if (getSnapVisibleOnly()) {
652 // Only snapping to visible grid lines
653 spacing_h = grid->lxw; // horizontal
654 spacing_v = grid->lyw; // vertical
655 // convert screen pixels to px
656 // FIXME: after we switch to snapping dist in screen pixels, this will be unnecessary
657 SPDesktop const *dt = _snapmanager->getDesktop();
658 if (dt) {
659 spacing_h /= dt->current_zoom();
660 spacing_v /= dt->current_zoom();
661 }
662 } else {
663 // Snapping to any grid line, whether it's visible or not
664 spacing_h = grid->lengthx;
665 spacing_v = grid->lengthy;
666 }
667
668 // In a polygonal grid, any point will be surrounded by 6 grid lines:
669 // - 4 lines of a section grid
670 // - 2 lines of the section edges
671 // Of these, we use the closer section edge, and the closer each of the grid X and Y lines
672
673 // Calculate what section the point is in
674 Geom::Point gc_point = p - grid->origin;
675 double point_angle_rad;
676 bool const x_is_zero = Geom::are_near(gc_point[Geom::X], 0.);
677 bool const y_is_zero = Geom::are_near(gc_point[Geom::Y], 0.);
678 if (Geom::are_near(p, grid->origin))
679 point_angle_rad = 0;
680 else
681 point_angle_rad = Geom::atan2(gc_point);
682 double const section_ratio = (point_angle_rad - grid->angle_rad - grid->se_angle_rad) / (2.0 * M_PI);
683 int const section = floor( grid->sections * section_ratio ) + 1;
684
685 // Compute spacing-unit vectors for section
686 double const section_angle_rad = (2.0 * section * grid->se_angle_rad) + grid->angle_rad;
687 double const section_sin = sin(section_angle_rad);
688 double const section_cos = cos(section_angle_rad);
689 Geom::Point const gc_nx(-section_sin, section_cos);
690 Geom::Point const gc_ny( section_cos, section_sin);
691 Geom::Point const gc_sx = gc_ny * spacing_h;
692 Geom::Point const gc_sy = gc_nx * spacing_v;
693
694 // Get point in section pre-image space
695 double const pc_x = ( (gc_point[Geom::Y] * section_sin) + (gc_point[Geom::X] * section_cos) ) / spacing_h;
696 double const pc_y = ( (gc_point[Geom::Y] * section_cos) - (gc_point[Geom::X] * section_sin) ) / spacing_v;
697
698 // Add the nearer section edge line
699 double const section_edge_angle_rad = section_angle_rad + ( (pc_y > 0.0 ? 1.0 : -1.0) * grid->se_angle_rad);
700 Geom::Point const section_edge_norm(-sin(section_edge_angle_rad), cos(section_edge_angle_rad));
701 s.push_back( std::make_pair(section_edge_norm, grid->origin) );
702
703 // Add the two nearer lines of the grid square
704 Geom::Point const gc_corner = (gc_sx * round(pc_x)) + (gc_sy * round(pc_y)) + grid->origin;
705 s.push_back( std::make_pair(gc_nx, gc_corner) );
706 s.push_back( std::make_pair(gc_ny, gc_corner) );
707
708 return s;
709}
710
711void CanvasNGonGridSnapper::_addSnappedLine(IntermSnapResults &isr, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, Geom::Point const normal_to_line, Geom::Point const point_on_line) const
712{
713 SnappedLine dummy = SnappedLine(snapped_point, snapped_distance, source, source_num, Inkscape::SNAPTARGET_GRID, getSnapperTolerance(), getSnapperAlwaysSnap(), normal_to_line, point_on_line);
714 isr.grid_lines.push_back(dummy);
715}
716
717void CanvasNGonGridSnapper::_addSnappedPoint(IntermSnapResults &isr, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const
718{
719 SnappedPoint dummy = SnappedPoint(snapped_point, source, source_num, Inkscape::SNAPTARGET_GRID, snapped_distance, getSnapperTolerance(), getSnapperAlwaysSnap(), constrained_snap, true);
720 isr.points.push_back(dummy);
721}
722
723void CanvasNGonGridSnapper::_addSnappedLinePerpendicularly(IntermSnapResults &isr, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const
724{
725 SnappedPoint dummy = SnappedPoint(snapped_point, source, source_num, Inkscape::SNAPTARGET_GRID_PERPENDICULAR, snapped_distance, getSnapperTolerance(), getSnapperAlwaysSnap(), constrained_snap, true);
726 isr.points.push_back(dummy);
727}
728
729bool CanvasNGonGridSnapper::ThisSnapperMightSnap() const
730{
731 return _snap_enabled && _snapmanager->snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_GRID);
732}
733
734
735}; // namespace Inkscape
736
737
738/*
739 Local Variables:
740 mode:c++
741 c-file-style:"stroustrup"
742 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
743 indent-tabs-mode:nil
744 fill-column:99
745 End:
746*/
747// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
0748
=== added file 'src/display/canvas-ngongrid.h'
--- src/display/canvas-ngongrid.h 1970-01-01 00:00:00 +0000
+++ src/display/canvas-ngongrid.h 2016-04-29 07:04:20 +0000
@@ -0,0 +1,94 @@
1#ifndef CANVAS_NGONGRID_H
2#define CANVAS_NGONGRID_H
3
4/*
5 * Authors:
6 * Matthew Woehlke <mw_triad@users.sourceforge.net>
7 * Johan Engelen <j.b.c.engelen@alumnus.utwente.nl>
8 *
9 * Copyright (C) 2006-2012 Authors
10 * Released under GNU GPL, read the file 'COPYING' for more information
11 */
12
13#include "line-snapper.h"
14#include "canvas-grid.h"
15
16class SPCanvasBuf;
17class SPDesktop;
18struct SPNamedView;
19
20namespace Inkscape {
21namespace XML {
22 class Node;
23};
24
25class CanvasNGonGrid : public CanvasGrid {
26public:
27 CanvasNGonGrid(SPNamedView * nv, Inkscape::XML::Node * in_repr, SPDocument * in_doc);
28 virtual ~CanvasNGonGrid();
29
30 void Update (Geom::Affine const &affine, unsigned int flags);
31 void Render (SPCanvasBuf *buf);
32
33 void readRepr();
34 void onReprAttrChanged (Inkscape::XML::Node * repr, const gchar *key, const gchar *oldval, const gchar *newval, bool is_interactive);
35
36 int sections; /**< Number of grid sections */
37 double lengthx; /**< Step size along concentric polygons */
38 double lengthy; /**< Step size along semi-radius lines */
39 double angle_deg; /**< Angle of rotation (degrees) */
40 double angle_rad; /**< Angle of rotation (radians) */
41 double se_angle_deg; /**< Half of section arc (degrees) */
42 double se_angle_rad; /**< Half of section arc (radians) */
43 double se_tan; /**< tan(se_angle) */
44
45 bool scaled; /**< Whether the grid is in scaled mode */
46
47protected:
48 friend class CanvasNGonGridSnapper;
49
50 Geom::Point ow; /**< Transformed origin by the affine for the zoom */
51 double lxw; /**< Transformed length x by the affine for the zoom */
52 double lyw; /**< Transformed length y by the affine for the zoom */
53
54 Geom::Point sw; /**< the scaling factors of the affine transform */
55
56 virtual Gtk::Widget * newSpecificWidget();
57
58private:
59 CanvasNGonGrid(const CanvasNGonGrid&);
60 CanvasNGonGrid& operator=(const CanvasNGonGrid&);
61
62 void updateWidgets();
63
64 void renderSection (SPCanvasBuf *buf, double section_angle_deg, guint32 _empcolor);
65};
66
67
68
69class CanvasNGonGridSnapper : public LineSnapper
70{
71public:
72 CanvasNGonGridSnapper(CanvasNGonGrid *grid, SnapManager *sm, Geom::Coord const d);
73 bool ThisSnapperMightSnap() const;
74
75 Geom::Coord getSnapperTolerance() const; //returns the tolerance of the snapper in screen pixels (i.e. independent of zoom)
76 bool getSnapperAlwaysSnap() const; //if true, then the snapper will always snap, regardless of its tolerance
77
78private:
79 LineList _getSnapLines(Geom::Point const &p) const;
80 void _addSnappedLine(IntermSnapResults &isr, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, Geom::Point const normal_to_line, const Geom::Point point_on_line) const;
81 void _addSnappedPoint(IntermSnapResults &isr, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const;
82 void _addSnappedLinePerpendicularly(IntermSnapResults &isr, Geom::Point const snapped_point, Geom::Coord const snapped_distance, SnapSourceType const &source, long source_num, bool constrained_snap) const;
83
84 CanvasNGonGrid *grid;
85};
86
87
88}; //namespace Inkscape
89
90
91
92#endif
93
94
095
=== modified file 'src/ui/dialog/document-properties.cpp'
--- src/ui/dialog/document-properties.cpp 2016-02-21 21:44:25 +0000
+++ src/ui/dialog/document-properties.cpp 2016-04-29 07:04:20 +0000
@@ -1386,6 +1386,8 @@
1386 case GRID_AXONOMETRIC:1386 case GRID_AXONOMETRIC:
1387 icon = "grid-axonometric";1387 icon = "grid-axonometric";
1388 break;1388 break;
1389 case GRID_POLYGONAL:
1390 icon = "grid-polygonal";
1389 default:1391 default:
1390 break;1392 break;
1391 }1393 }
13921394
=== modified file 'src/ui/dialog/inkscape-preferences.cpp'
--- src/ui/dialog/inkscape-preferences.cpp 2016-04-12 10:28:18 +0000
+++ src/ui/dialog/inkscape-preferences.cpp 2016-04-29 07:04:20 +0000
@@ -514,7 +514,7 @@
514 this->AddPage(_page_dropper, _("Dropper"), iter_tools, PREFS_PAGE_TOOLS_DROPPER);514 this->AddPage(_page_dropper, _("Dropper"), iter_tools, PREFS_PAGE_TOOLS_DROPPER);
515 this->AddSelcueCheckbox(_page_dropper, "/tools/dropper", true);515 this->AddSelcueCheckbox(_page_dropper, "/tools/dropper", true);
516 this->AddGradientCheckbox(_page_dropper, "/tools/dropper", true);516 this->AddGradientCheckbox(_page_dropper, "/tools/dropper", true);
517 517
518 //Connector518 //Connector
519 this->AddPage(_page_connector, _("Connector"), iter_tools, PREFS_PAGE_TOOLS_CONNECTOR);519 this->AddPage(_page_connector, _("Connector"), iter_tools, PREFS_PAGE_TOOLS_CONNECTOR);
520 this->AddSelcueCheckbox(_page_connector, "/tools/connector", true);520 this->AddSelcueCheckbox(_page_connector, "/tools/connector", true);
@@ -689,7 +689,7 @@
689689
690 _win_native.init ( _("Native open/save dialogs"), "/options/desktopintegration/value", 1, true, 0);690 _win_native.init ( _("Native open/save dialogs"), "/options/desktopintegration/value", 1, true, 0);
691 _win_gtk.init ( _("GTK open/save dialogs"), "/options/desktopintegration/value", 0, false, &_win_native);691 _win_gtk.init ( _("GTK open/save dialogs"), "/options/desktopintegration/value", 0, false, &_win_native);
692 692
693 _win_hide_task.init ( _("Dialogs are hidden in taskbar"), "/options/dialogsskiptaskbar/value", true);693 _win_hide_task.init ( _("Dialogs are hidden in taskbar"), "/options/dialogsskiptaskbar/value", true);
694 _win_save_viewport.init ( _("Save and restore documents viewport"), "/options/savedocviewport/value", true);694 _win_save_viewport.init ( _("Save and restore documents viewport"), "/options/savedocviewport/value", true);
695 _win_zoom_resize.init ( _("Zoom when window is resized"), "/options/stickyzoom/value", false);695 _win_zoom_resize.init ( _("Zoom when window is resized"), "/options/stickyzoom/value", false);
@@ -782,6 +782,7 @@
782 _page_grids.add_line( true, "", _grids_notebook, "", "", false);782 _page_grids.add_line( true, "", _grids_notebook, "", "", false);
783 _grids_notebook.append_page(_grids_xy, CanvasGrid::getName( GRID_RECTANGULAR ));783 _grids_notebook.append_page(_grids_xy, CanvasGrid::getName( GRID_RECTANGULAR ));
784 _grids_notebook.append_page(_grids_axonom, CanvasGrid::getName( GRID_AXONOMETRIC ));784 _grids_notebook.append_page(_grids_axonom, CanvasGrid::getName( GRID_AXONOMETRIC ));
785 _grids_notebook.append_page(_grids_ngon, CanvasGrid::getName( GRID_POLYGONAL ));
785 _grids_xy_units.init("/options/grids/xy/units");786 _grids_xy_units.init("/options/grids/xy/units");
786 _grids_xy.add_line( false, _("Grid units:"), _grids_xy_units, "", "", false);787 _grids_xy.add_line( false, _("Grid units:"), _grids_xy_units, "", "", false);
787 _grids_xy_origin_x.init("/options/grids/xy/origin_x", -10000.0, 10000.0, 0.1, 1.0, 0.0, false, false);788 _grids_xy_origin_x.init("/options/grids/xy/origin_x", -10000.0, 10000.0, 0.1, 1.0, 0.0, false, false);
@@ -829,6 +830,33 @@
829 _grids_axonom_empspacing.init("/options/grids/axonom/empspacing", 1.0, 1000.0, 1.0, 5.0, 5.0, true, false);830 _grids_axonom_empspacing.init("/options/grids/axonom/empspacing", 1.0, 1000.0, 1.0, 5.0, 5.0, true, false);
830 _grids_axonom.add_line( false, _("Major grid line every:"), _grids_axonom_empspacing, "", "", false);831 _grids_axonom.add_line( false, _("Major grid line every:"), _grids_axonom_empspacing, "", "", false);
831832
833 // CanvasNGonGrid properties:
834 _grids_ngon_units.init("/options/grids/ngon/units");
835 _grids_ngon.add_line( false, _("Grid units:"), _grids_ngon_units, "", "", false);
836 _grids_ngon_origin_x.init("/options/grids/ngon/origin_x", -10000.0, 10000.0, 0.1, 1.0, 0.0, false, false);
837 _grids_ngon_origin_y.init("/options/grids/ngon/origin_y", -10000.0, 10000.0, 0.1, 1.0, 0.0, false, false);
838 _grids_ngon_origin_x.set_digits(5);
839 _grids_ngon_origin_y.set_digits(5);
840 _grids_ngon.add_line( false, _("Origin X:"), _grids_ngon_origin_x, "", _("X coordinate of grid origin"), false);
841 _grids_ngon.add_line( false, _("Origin Y:"), _grids_ngon_origin_y, "", _("Y coordinate of grid origin"), false);
842 _grids_ngon_sect_n.init("/options/grids/ngon/sect_n", 3.0, 360.0, 1.0, 3.0, 8.0, true, false);
843 _grids_ngon.add_line( false, _("Number of sections:"), _grids_ngon_empspacing, "", "", false);
844 _grids_ngon_spacing_x.init("/options/grids/ngon/spacing_x", 0.0, 10000.0, 0.1, 1.0, 1.0, false, false);
845 _grids_ngon_spacing_y.init("/options/grids/ngon/spacing_y", 0.0, 10000.0, 0.1, 1.0, 1.0, false, false);
846 _grids_ngon_spacing_x.set_digits(5);
847 _grids_ngon_spacing_y.set_digits(5);
848 _grids_ngon.add_line( false, _("Spacing X:"), _grids_ngon_spacing_x, "", _("Distance between concentric grid polygons"), false);
849 _grids_ngon.add_line( false, _("Spacing Y:"), _grids_ngon_spacing_y, "", _("Distance between semi-radial grid lines"), false);
850 _grids_ngon_rotation.init("/options/grids/ngon/rotation", -360.0, 360.0, 1.0, 0.0, 0.0, false, false);
851 _grids_ngon_rotation.set_digits(5);
852 _grids_ngon.add_line( false, _("Rotation:"), _grids_ngon_rotation, "", _("Angle of axis rotation"), false);
853 _grids_ngon_color.init(_("Minor grid line color:"), "/options/grids/ngon/color", 0x0000ff20);
854 _grids_ngon.add_line( false, _("Minor grid line color:"), _grids_ngon_color, "", _("Color used for normal grid lines"), false);
855 _grids_ngon_empcolor.init(_("Major grid line color:"), "/options/grids/ngon/empcolor", 0x0000ff40);
856 _grids_ngon.add_line( false, _("Major grid line color:"), _grids_ngon_empcolor, "", _("Color used for major (highlighted) grid lines"), false);
857 _grids_ngon_empspacing.init("/options/grids/ngon/empspacing", 1.0, 1000.0, 1.0, 5.0, 5.0, true, false);
858 _grids_ngon.add_line( false, _("Major grid line every:"), _grids_ngon_empspacing, "", "", false);
859
832 this->AddPage(_page_grids, _("Grids"), iter_ui, PREFS_PAGE_UI_GRIDS);860 this->AddPage(_page_grids, _("Grids"), iter_ui, PREFS_PAGE_UI_GRIDS);
833861
834 initKeyboardShortcuts(iter_ui);862 initKeyboardShortcuts(iter_ui);
@@ -1377,28 +1405,28 @@
1377 _mask_mask_remove.init ( _("Remove clippath/mask object after applying"), "/options/maskobject/remove", true);1405 _mask_mask_remove.init ( _("Remove clippath/mask object after applying"), "/options/maskobject/remove", true);
1378 _page_mask.add_line(false, "", _mask_mask_remove, "",1406 _page_mask.add_line(false, "", _mask_mask_remove, "",
1379 _("After applying, remove the object used as the clipping path or mask from the drawing"));1407 _("After applying, remove the object used as the clipping path or mask from the drawing"));
1380 1408
1381 _page_mask.add_group_header( _("Before applying"));1409 _page_mask.add_group_header( _("Before applying"));
1382 1410
1383 _mask_grouping_none.init( _("Do not group clipped/masked objects"), "/options/maskobject/grouping", PREFS_MASKOBJECT_GROUPING_NONE, true, 0);1411 _mask_grouping_none.init( _("Do not group clipped/masked objects"), "/options/maskobject/grouping", PREFS_MASKOBJECT_GROUPING_NONE, true, 0);
1384 _mask_grouping_separate.init( _("Put every clipped/masked object in its own group"), "/options/maskobject/grouping", PREFS_MASKOBJECT_GROUPING_SEPARATE, false, &_mask_grouping_none);1412 _mask_grouping_separate.init( _("Put every clipped/masked object in its own group"), "/options/maskobject/grouping", PREFS_MASKOBJECT_GROUPING_SEPARATE, false, &_mask_grouping_none);
1385 _mask_grouping_all.init( _("Put all clipped/masked objects into one group"), "/options/maskobject/grouping", PREFS_MASKOBJECT_GROUPING_ALL, false, &_mask_grouping_none);1413 _mask_grouping_all.init( _("Put all clipped/masked objects into one group"), "/options/maskobject/grouping", PREFS_MASKOBJECT_GROUPING_ALL, false, &_mask_grouping_none);
1386 1414
1387 _page_mask.add_line(true, "", _mask_grouping_none, "",1415 _page_mask.add_line(true, "", _mask_grouping_none, "",
1388 _("Apply clippath/mask to every object"));1416 _("Apply clippath/mask to every object"));
1389 1417
1390 _page_mask.add_line(true, "", _mask_grouping_separate, "",1418 _page_mask.add_line(true, "", _mask_grouping_separate, "",
1391 _("Apply clippath/mask to groups containing single object"));1419 _("Apply clippath/mask to groups containing single object"));
1392 1420
1393 _page_mask.add_line(true, "", _mask_grouping_all, "",1421 _page_mask.add_line(true, "", _mask_grouping_all, "",
1394 _("Apply clippath/mask to group containing all objects"));1422 _("Apply clippath/mask to group containing all objects"));
1395 1423
1396 _page_mask.add_group_header( _("After releasing"));1424 _page_mask.add_group_header( _("After releasing"));
1397 1425
1398 _mask_ungrouping.init ( _("Ungroup automatically created groups"), "/options/maskobject/ungrouping", true);1426 _mask_ungrouping.init ( _("Ungroup automatically created groups"), "/options/maskobject/ungrouping", true);
1399 _page_mask.add_line(true, "", _mask_ungrouping, "",1427 _page_mask.add_line(true, "", _mask_ungrouping, "",
1400 _("Ungroup groups created when setting clip/mask"));1428 _("Ungroup groups created when setting clip/mask"));
1401 1429
1402 this->AddPage(_page_mask, _("Clippaths and masks"), iter_behavior, PREFS_PAGE_BEHAVIOR_MASKS);1430 this->AddPage(_page_mask, _("Clippaths and masks"), iter_behavior, PREFS_PAGE_BEHAVIOR_MASKS);
14031431
14041432
@@ -1896,15 +1924,20 @@
18961924
1897 /* the returned pointer should _not_ need to be deleted */1925 /* the returned pointer should _not_ need to be deleted */
1898 AspellDictInfoList *dlist = get_aspell_dict_info_list(config);1926 AspellDictInfoList *dlist = get_aspell_dict_info_list(config);
1899 1927
1900 /* config is no longer needed */1928 /* config is no longer needed */
1901 delete_aspell_config(config);1929 delete_aspell_config(config);
1902 1930
1903 AspellDictInfoEnumeration *dels = aspell_dict_info_list_elements(dlist);1931 AspellDictInfoEnumeration *dels = aspell_dict_info_list_elements(dlist);
1932<<<<<<< TREE
1904 1933
1905 languages.push_back(Glib::ustring(C_("Spellchecker language", "None")));1934 languages.push_back(Glib::ustring(C_("Spellchecker language", "None")));
1935=======
1936
1937 languages.push_back(Glib::ustring(_("None")));
1938>>>>>>> MERGE-SOURCE
1906 langValues.push_back(Glib::ustring(""));1939 langValues.push_back(Glib::ustring(""));
1907 1940
1908 const AspellDictInfo *entry;1941 const AspellDictInfo *entry;
1909 int en_index = 0;1942 int en_index = 0;
1910 int i = 0;1943 int i = 0;
19111944
=== modified file 'src/ui/dialog/inkscape-preferences.h'
--- src/ui/dialog/inkscape-preferences.h 2016-03-02 19:44:36 +0000
+++ src/ui/dialog/inkscape-preferences.h 2016-04-29 07:04:20 +0000
@@ -411,6 +411,7 @@
411 UI::Widget::PrefRadioButton _grids_emphasize_on_zoom;411 UI::Widget::PrefRadioButton _grids_emphasize_on_zoom;
412 UI::Widget::DialogPage _grids_xy;412 UI::Widget::DialogPage _grids_xy;
413 UI::Widget::DialogPage _grids_axonom;413 UI::Widget::DialogPage _grids_axonom;
414 UI::Widget::DialogPage _grids_ngon;
414 // CanvasXYGrid properties:415 // CanvasXYGrid properties:
415 UI::Widget::PrefUnit _grids_xy_units;416 UI::Widget::PrefUnit _grids_xy_units;
416 UI::Widget::PrefSpinButton _grids_xy_origin_x;417 UI::Widget::PrefSpinButton _grids_xy_origin_x;
@@ -431,6 +432,17 @@
431 UI::Widget::PrefColorPicker _grids_axonom_color;432 UI::Widget::PrefColorPicker _grids_axonom_color;
432 UI::Widget::PrefColorPicker _grids_axonom_empcolor;433 UI::Widget::PrefColorPicker _grids_axonom_empcolor;
433 UI::Widget::PrefSpinButton _grids_axonom_empspacing;434 UI::Widget::PrefSpinButton _grids_axonom_empspacing;
435 // CanvasNGonGrid properties:
436 UI::Widget::PrefUnit _grids_ngon_units;
437 UI::Widget::PrefSpinButton _grids_ngon_origin_x;
438 UI::Widget::PrefSpinButton _grids_ngon_origin_y;
439 UI::Widget::PrefSpinButton _grids_ngon_sect_n;
440 UI::Widget::PrefSpinButton _grids_ngon_spacing_x;
441 UI::Widget::PrefSpinButton _grids_ngon_spacing_y;
442 UI::Widget::PrefSpinButton _grids_ngon_rotation;
443 UI::Widget::PrefColorPicker _grids_ngon_color;
444 UI::Widget::PrefColorPicker _grids_ngon_empcolor;
445 UI::Widget::PrefSpinButton _grids_ngon_empspacing;
434446
435 // SVG Output page:447 // SVG Output page:
436 UI::Widget::PrefCheckButton _svgoutput_usenamedcolors;448 UI::Widget::PrefCheckButton _svgoutput_usenamedcolors;