Merge lp:~matthewpetroff/inkscape/gsoc-2013-unit-refactor into lp:~inkscape.dev/inkscape/trunk
- gsoc-2013-unit-refactor
- Merge into trunk
Proposed by
Matthew Petroff
Status: | Merged |
---|---|
Merged at revision: | 12471 |
Proposed branch: | lp:~matthewpetroff/inkscape/gsoc-2013-unit-refactor |
Merge into: | lp:~inkscape.dev/inkscape/trunk |
Diff against target: |
7879 lines (+1412/-2557) (has conflicts) 123 files modified
AUTHORS (+1/-0) src/CMakeLists.txt (+0/-4) src/Makefile_insert (+0/-3) src/arc-context.cpp (+4/-3) src/box3d-context.cpp (+0/-1) src/desktop-events.cpp (+0/-3) src/desktop.cpp (+0/-1) src/display/canvas-axonomgrid.cpp (+24/-77) src/display/canvas-grid.cpp (+38/-91) src/display/canvas-grid.h (+5/-1) src/document.cpp (+23/-22) src/document.h (+5/-5) src/doxygen-main.cpp (+1/-3) src/extension/internal/cairo-render-context.cpp (+2/-3) src/extension/internal/cairo-renderer-pdf-out.cpp (+2/-2) src/extension/internal/cairo-renderer.cpp (+9/-9) src/extension/internal/emf-win32-inout.cpp (+7/-7) src/extension/internal/emf-win32-print.cpp (+36/-37) src/extension/internal/gdkpixbuf-input.cpp (+2/-2) src/extension/internal/latex-pstricks.cpp (+3/-3) src/extension/internal/latex-text-renderer.cpp (+2/-2) src/extension/internal/pdfinput/pdf-parser.cpp (+4/-4) src/extension/internal/pdfinput/svg-builder.cpp (+2/-2) src/flood-context.cpp (+0/-1) src/flood-context.h (+0/-2) src/helper/Makefile_insert (+0/-12) src/helper/pixbuf-ops.cpp (+2/-2) src/helper/unit-menu.cpp (+0/-360) src/helper/unit-menu.h (+0/-60) src/helper/unit-tracker.cpp (+0/-267) src/helper/unit-tracker.h (+0/-75) src/helper/units-test.h (+0/-90) src/helper/units.cpp (+0/-261) src/helper/units.h (+0/-146) src/live_effects/lpe-path_length.cpp (+3/-3) src/live_effects/lpe-ruler.cpp (+4/-4) src/live_effects/parameter/unit.cpp (+13/-11) src/live_effects/parameter/unit.h (+9/-6) src/lpe-tool-context.cpp (+26/-5) src/lpe-tool-context.h (+0/-1) src/main.cpp (+5/-6) src/measure-context.cpp (+12/-9) src/pen-context.cpp (+8/-5) src/preferences.cpp (+2/-2) src/rect-context.cpp (+4/-3) src/selection-chemistry.cpp (+7/-8) src/seltrans.cpp (+8/-5) src/snap-preferences.h (+0/-1) src/sp-guide.cpp (+4/-5) src/sp-metric.h (+0/-28) src/sp-metrics.cpp (+0/-120) src/sp-metrics.h (+0/-20) src/sp-namedview.cpp (+22/-20) src/sp-namedview.h (+9/-8) src/sp-text.cpp (+2/-3) src/spiral-context.cpp (+2/-2) src/star-context.cpp (+2/-2) src/style.cpp (+16/-16) src/svg/svg-length.cpp (+9/-7) src/text-context.cpp (+4/-3) src/text-editing.cpp (+6/-6) src/ui/CMakeLists.txt (+2/-0) src/ui/clipboard.cpp (+4/-4) src/ui/dialog/clonetiler.cpp (+45/-32) src/ui/dialog/clonetiler.h (+18/-2) src/ui/dialog/document-properties.cpp (+1/-2) src/ui/dialog/export.cpp (+28/-49) src/ui/dialog/export.h (+7/-1) src/ui/dialog/guides.cpp (+1/-1) src/ui/dialog/inkscape-preferences.cpp (+4/-4) src/ui/dialog/print.cpp (+6/-6) src/ui/dialog/text-edit.cpp (+2/-2) src/ui/tool/node.cpp (+12/-6) src/ui/widget/Makefile_insert (+3/-1) src/ui/widget/page-sizer.cpp (+80/-89) src/ui/widget/page-sizer.h (+4/-4) src/ui/widget/registered-widget.cpp (+2/-3) src/ui/widget/registered-widget.h (+1/-2) src/ui/widget/rendering-options.cpp (+3/-3) src/ui/widget/scalar-unit.cpp (+4/-3) src/ui/widget/selected-style.cpp (+17/-12) src/ui/widget/selected-style.h (+7/-4) src/ui/widget/style-swatch.cpp (+3/-3) src/ui/widget/style-swatch.h (+6/-2) src/ui/widget/unit-menu.cpp (+9/-7) src/ui/widget/unit-menu.h (+0/-3) src/ui/widget/unit-tracker.cpp (+263/-0) src/ui/widget/unit-tracker.h (+74/-0) src/unit-constants.h (+0/-47) src/util/expression-evaluator.cpp (+2/-2) src/util/units.cpp (+169/-6) src/util/units.h (+62/-5) src/widgets/arc-toolbar.cpp (+2/-6) src/widgets/box3d-toolbar.cpp (+3/-8) src/widgets/calligraphy-toolbar.cpp (+8/-12) src/widgets/connector-toolbar.cpp (+3/-7) src/widgets/desktop-widget.cpp (+15/-13) src/widgets/dropper-toolbar.cpp (+0/-4) src/widgets/eraser-toolbar.cpp (+1/-5) src/widgets/font-selector.cpp (+0/-1) src/widgets/gradient-toolbar.cpp (+1/-1) src/widgets/lpe-toolbar.cpp (+10/-9) src/widgets/measure-toolbar.cpp (+10/-9) src/widgets/mesh-toolbar.cpp (+2/-2) src/widgets/node-toolbar.cpp (+19/-16) src/widgets/paintbucket-toolbar.cpp (+11/-10) src/widgets/pencil-toolbar.cpp (+1/-6) src/widgets/rect-toolbar.cpp (+19/-17) src/widgets/ruler.cpp (+15/-17) src/widgets/ruler.h (+8/-3) src/widgets/select-toolbar.cpp (+29/-27) src/widgets/spiral-toolbar.cpp (+3/-7) src/widgets/spray-toolbar.cpp (+6/-10) src/widgets/spw-utilities.cpp (+0/-46) src/widgets/spw-utilities.h (+0/-5) src/widgets/star-toolbar.cpp (+4/-8) src/widgets/stroke-style.cpp (+35/-90) src/widgets/stroke-style.h (+16/-8) src/widgets/text-toolbar.cpp (+0/-15) src/widgets/toolbox.cpp (+0/-8) src/widgets/toolbox.h (+0/-1) src/widgets/tweak-toolbar.cpp (+3/-7) src/widgets/zoom-toolbar.cpp (+0/-4) Text conflict in src/lpe-tool-context.cpp |
To merge this branch: | bzr merge lp:~matthewpetroff/inkscape/gsoc-2013-unit-refactor |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Inkscape Developers | Pending | ||
Review via email: mp+178151@code.launchpad.net |
Commit message
Description of the change
This branch is a refactor of Inkscape's unit support as phase one of my Google Summer of Code project. Unit support was consolidated into one implementation, residing in "util/units.*", eliminating "SPUnit", "SPMetric", and "unit-constants.h".
To post a comment you must log in.
- 12438. By Matthew Petroff
-
Fixed Windows compile bug.
- 12439. By Matthew Petroff
-
Fix UnitTracker percentage bug.
- 12440. By Matthew Petroff
-
Fixed building of tests.
- 12441. By Matthew Petroff
-
Fix handling of SVG lengths with spaces [Bug #1208002].
- 12442. By Matthew Petroff
-
Switched to global UnitTable.
- 12443. By Matthew Petroff
-
Fixed bug in page sizer.
Revision history for this message
su_v (suv-lp) wrote : | # |
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'AUTHORS' | |||
2 | --- AUTHORS 2013-07-18 11:21:06 +0000 | |||
3 | +++ AUTHORS 2013-08-06 18:46:25 +0000 | |||
4 | @@ -121,6 +121,7 @@ | |||
5 | 121 | Mitsuru Oka | 121 | Mitsuru Oka |
6 | 122 | Martin Owens | 122 | Martin Owens |
7 | 123 | Alvin Penner | 123 | Alvin Penner |
8 | 124 | Matthew Petroff | ||
9 | 124 | Jon Phillips | 125 | Jon Phillips |
10 | 125 | Zdenko Podobny | 126 | Zdenko Podobny |
11 | 126 | Alexandre Prokoudine | 127 | Alexandre Prokoudine |
12 | 127 | 128 | ||
13 | === modified file 'src/CMakeLists.txt' | |||
14 | --- src/CMakeLists.txt 2013-07-23 17:01:25 +0000 | |||
15 | +++ src/CMakeLists.txt 2013-08-06 18:46:25 +0000 | |||
16 | @@ -46,7 +46,6 @@ | |||
17 | 46 | sp-mesh-patch.cpp | 46 | sp-mesh-patch.cpp |
18 | 47 | sp-mesh-row.cpp | 47 | sp-mesh-row.cpp |
19 | 48 | sp-metadata.cpp | 48 | sp-metadata.cpp |
20 | 49 | sp-metrics.cpp | ||
21 | 50 | sp-missing-glyph.cpp | 49 | sp-missing-glyph.cpp |
22 | 51 | sp-namedview.cpp | 50 | sp-namedview.cpp |
23 | 52 | sp-object-group.cpp | 51 | sp-object-group.cpp |
24 | @@ -136,8 +135,6 @@ | |||
25 | 136 | sp-mesh-row-fns.h | 135 | sp-mesh-row-fns.h |
26 | 137 | sp-mesh-row.h | 136 | sp-mesh-row.h |
27 | 138 | sp-metadata.h | 137 | sp-metadata.h |
28 | 139 | sp-metric.h | ||
29 | 140 | sp-metrics.h | ||
30 | 141 | sp-missing-glyph.h | 138 | sp-missing-glyph.h |
31 | 142 | sp-namedview.h | 139 | sp-namedview.h |
32 | 143 | sp-object-group.h | 140 | sp-object-group.h |
33 | @@ -484,7 +481,6 @@ | |||
34 | 484 | unclump.h | 481 | unclump.h |
35 | 485 | undo-stack-observer.h | 482 | undo-stack-observer.h |
36 | 486 | unicoderange.h | 483 | unicoderange.h |
37 | 487 | unit-constants.h | ||
38 | 488 | uri-references.h | 484 | uri-references.h |
39 | 489 | uri.h | 485 | uri.h |
40 | 490 | vanishing-point.h | 486 | vanishing-point.h |
41 | 491 | 487 | ||
42 | === modified file 'src/Makefile_insert' | |||
43 | --- src/Makefile_insert 2013-08-03 15:35:41 +0000 | |||
44 | +++ src/Makefile_insert 2013-08-06 18:46:25 +0000 | |||
45 | @@ -198,8 +198,6 @@ | |||
46 | 198 | sp-mesh-patch.cpp sp-mesh-patch.h \ | 198 | sp-mesh-patch.cpp sp-mesh-patch.h \ |
47 | 199 | sp-mesh-row-fns.h \ | 199 | sp-mesh-row-fns.h \ |
48 | 200 | sp-mesh-row.cpp sp-mesh-row.h \ | 200 | sp-mesh-row.cpp sp-mesh-row.h \ |
49 | 201 | sp-metric.h \ | ||
50 | 202 | sp-metrics.cpp sp-metrics.h \ | ||
51 | 203 | sp-missing-glyph.cpp sp-missing-glyph.h \ | 201 | sp-missing-glyph.cpp sp-missing-glyph.h \ |
52 | 204 | sp-namedview.cpp sp-namedview.h \ | 202 | sp-namedview.cpp sp-namedview.h \ |
53 | 205 | sp-object.cpp sp-object.h \ | 203 | sp-object.cpp sp-object.h \ |
54 | @@ -252,7 +250,6 @@ | |||
55 | 252 | unclump.cpp unclump.h \ | 250 | unclump.cpp unclump.h \ |
56 | 253 | undo-stack-observer.h \ | 251 | undo-stack-observer.h \ |
57 | 254 | unicoderange.cpp unicoderange.h \ | 252 | unicoderange.cpp unicoderange.h \ |
58 | 255 | unit-constants.h \ | ||
59 | 256 | uri.cpp uri.h \ | 253 | uri.cpp uri.h \ |
60 | 257 | uri-references.cpp uri-references.h \ | 254 | uri-references.cpp uri-references.h \ |
61 | 258 | vanishing-point.cpp vanishing-point.h \ | 255 | vanishing-point.cpp vanishing-point.h \ |
62 | 259 | 256 | ||
63 | === modified file 'src/arc-context.cpp' | |||
64 | --- src/arc-context.cpp 2013-04-28 22:48:03 +0000 | |||
65 | +++ src/arc-context.cpp 2013-08-06 18:46:25 +0000 | |||
66 | @@ -32,7 +32,6 @@ | |||
67 | 32 | #include "desktop-handles.h" | 32 | #include "desktop-handles.h" |
68 | 33 | #include "snap.h" | 33 | #include "snap.h" |
69 | 34 | #include "pixmaps/cursor-ellipse.xpm" | 34 | #include "pixmaps/cursor-ellipse.xpm" |
70 | 35 | #include "sp-metrics.h" | ||
71 | 36 | #include "xml/repr.h" | 35 | #include "xml/repr.h" |
72 | 37 | #include "xml/node-event-vector.h" | 36 | #include "xml/node-event-vector.h" |
73 | 38 | #include "preferences.h" | 37 | #include "preferences.h" |
74 | @@ -450,8 +449,10 @@ | |||
75 | 450 | 449 | ||
76 | 451 | double rdimx = r.dimensions()[Geom::X]; | 450 | double rdimx = r.dimensions()[Geom::X]; |
77 | 452 | double rdimy = r.dimensions()[Geom::Y]; | 451 | double rdimy = r.dimensions()[Geom::Y]; |
80 | 453 | GString *xs = SP_PX_TO_METRIC_STRING(rdimx, desktop->namedview->getDefaultMetric()); | 452 | Inkscape::Util::Quantity rdimx_q = Inkscape::Util::Quantity(rdimx, "px"); |
81 | 454 | GString *ys = SP_PX_TO_METRIC_STRING(rdimy, desktop->namedview->getDefaultMetric()); | 453 | Inkscape::Util::Quantity rdimy_q = Inkscape::Util::Quantity(rdimy, "px"); |
82 | 454 | GString *xs = g_string_new(rdimx_q.string(*desktop->namedview->doc_units).c_str()); | ||
83 | 455 | GString *ys = g_string_new(rdimy_q.string(*desktop->namedview->doc_units).c_str()); | ||
84 | 455 | if (state & GDK_CONTROL_MASK) { | 456 | if (state & GDK_CONTROL_MASK) { |
85 | 456 | int ratio_x, ratio_y; | 457 | int ratio_x, ratio_y; |
86 | 457 | if (fabs (rdimx) > fabs (rdimy)) { | 458 | if (fabs (rdimx) > fabs (rdimy)) { |
87 | 458 | 459 | ||
88 | === modified file 'src/box3d-context.cpp' | |||
89 | --- src/box3d-context.cpp 2013-04-28 22:48:03 +0000 | |||
90 | +++ src/box3d-context.cpp 2013-08-06 18:46:25 +0000 | |||
91 | @@ -35,7 +35,6 @@ | |||
92 | 35 | #include "pixmaps/cursor-3dbox.xpm" | 35 | #include "pixmaps/cursor-3dbox.xpm" |
93 | 36 | #include "box3d.h" | 36 | #include "box3d.h" |
94 | 37 | #include "box3d-context.h" | 37 | #include "box3d-context.h" |
95 | 38 | #include "sp-metrics.h" | ||
96 | 39 | #include <glibmm/i18n.h> | 38 | #include <glibmm/i18n.h> |
97 | 40 | #include "xml/repr.h" | 39 | #include "xml/repr.h" |
98 | 41 | #include "xml/node-event-vector.h" | 40 | #include "xml/node-event-vector.h" |
99 | 42 | 41 | ||
100 | === modified file 'src/desktop-events.cpp' | |||
101 | --- src/desktop-events.cpp 2013-03-25 17:42:31 +0000 | |||
102 | +++ src/desktop-events.cpp 2013-08-06 18:46:25 +0000 | |||
103 | @@ -34,14 +34,11 @@ | |||
104 | 34 | #include "document-undo.h" | 34 | #include "document-undo.h" |
105 | 35 | #include "event-context.h" | 35 | #include "event-context.h" |
106 | 36 | #include "helper/action.h" | 36 | #include "helper/action.h" |
107 | 37 | #include "helper/unit-menu.h" | ||
108 | 38 | #include "helper/units.h" | ||
109 | 39 | #include "message-context.h" | 37 | #include "message-context.h" |
110 | 40 | #include "preferences.h" | 38 | #include "preferences.h" |
111 | 41 | #include "snap.h" | 39 | #include "snap.h" |
112 | 42 | #include "display/sp-canvas.h" | 40 | #include "display/sp-canvas.h" |
113 | 43 | #include "sp-guide.h" | 41 | #include "sp-guide.h" |
114 | 44 | #include "sp-metrics.h" | ||
115 | 45 | #include "sp-namedview.h" | 42 | #include "sp-namedview.h" |
116 | 46 | #include "tools-switch.h" | 43 | #include "tools-switch.h" |
117 | 47 | #include "verbs.h" | 44 | #include "verbs.h" |
118 | 48 | 45 | ||
119 | === modified file 'src/desktop.cpp' | |||
120 | --- src/desktop.cpp 2013-07-04 14:01:44 +0000 | |||
121 | +++ src/desktop.cpp 2013-08-06 18:46:25 +0000 | |||
122 | @@ -54,7 +54,6 @@ | |||
123 | 54 | #include "document.h" | 54 | #include "document.h" |
124 | 55 | #include "event-log.h" | 55 | #include "event-log.h" |
125 | 56 | #include "helper/action-context.h" | 56 | #include "helper/action-context.h" |
126 | 57 | #include "helper/units.h" | ||
127 | 58 | #include "interface.h" | 57 | #include "interface.h" |
128 | 59 | #include "inkscape-private.h" | 58 | #include "inkscape-private.h" |
129 | 60 | #include "layer-fns.h" | 59 | #include "layer-fns.h" |
130 | 61 | 60 | ||
131 | === modified file 'src/display/canvas-axonomgrid.cpp' | |||
132 | --- src/display/canvas-axonomgrid.cpp 2013-06-06 13:44:11 +0000 | |||
133 | +++ src/display/canvas-axonomgrid.cpp 2013-08-06 18:46:25 +0000 | |||
134 | @@ -51,8 +51,9 @@ | |||
135 | 51 | #include "2geom/angle.h" | 51 | #include "2geom/angle.h" |
136 | 52 | #include "util/mathfns.h" | 52 | #include "util/mathfns.h" |
137 | 53 | #include "round.h" | 53 | #include "round.h" |
139 | 54 | #include "helper/units.h" | 54 | #include "util/units.h" |
140 | 55 | 55 | ||
141 | 56 | using Inkscape::Util::unit_table; | ||
142 | 56 | 57 | ||
143 | 57 | enum Dim3 { X=0, Y, Z }; | 58 | enum Dim3 { X=0, Y, Z }; |
144 | 58 | 59 | ||
145 | @@ -160,15 +161,15 @@ | |||
146 | 160 | : CanvasGrid(nv, in_repr, in_doc, GRID_AXONOMETRIC) | 161 | : CanvasGrid(nv, in_repr, in_doc, GRID_AXONOMETRIC) |
147 | 161 | { | 162 | { |
148 | 162 | Inkscape::Preferences *prefs = Inkscape::Preferences::get(); | 163 | Inkscape::Preferences *prefs = Inkscape::Preferences::get(); |
150 | 163 | gridunit = sp_unit_get_by_abbreviation( prefs->getString("/options/grids/axonom/units").data() ); | 164 | gridunit = new Inkscape::Util::Unit(unit_table.getUnit(prefs->getString("/options/grids/axonom/units"))); |
151 | 164 | if (!gridunit) | 165 | if (!gridunit) |
155 | 165 | gridunit = &sp_unit_get_by_id(SP_UNIT_PX); | 166 | gridunit = new Inkscape::Util::Unit(unit_table.getUnit("px")); |
156 | 166 | origin[Geom::X] = sp_units_get_pixels( prefs->getDouble("/options/grids/axonom/origin_x", 0.0), *gridunit ); | 167 | origin[Geom::X] = Inkscape::Util::Quantity::convert(prefs->getDouble("/options/grids/axonom/origin_x", 0.0), *gridunit, "px"); |
157 | 167 | origin[Geom::Y] = sp_units_get_pixels( prefs->getDouble("/options/grids/axonom/origin_y", 0.0), *gridunit ); | 168 | origin[Geom::Y] = Inkscape::Util::Quantity::convert(prefs->getDouble("/options/grids/axonom/origin_y", 0.0), *gridunit, "px"); |
158 | 168 | color = prefs->getInt("/options/grids/axonom/color", 0x0000ff20); | 169 | color = prefs->getInt("/options/grids/axonom/color", 0x0000ff20); |
159 | 169 | empcolor = prefs->getInt("/options/grids/axonom/empcolor", 0x0000ff40); | 170 | empcolor = prefs->getInt("/options/grids/axonom/empcolor", 0x0000ff40); |
160 | 170 | empspacing = prefs->getInt("/options/grids/axonom/empspacing", 5); | 171 | empspacing = prefs->getInt("/options/grids/axonom/empspacing", 5); |
162 | 171 | lengthy = sp_units_get_pixels( prefs->getDouble("/options/grids/axonom/spacing_y", 1.0), *gridunit ); | 172 | lengthy = Inkscape::Util::Quantity::convert(prefs->getDouble("/options/grids/axonom/spacing_y", 1.0), *gridunit, "px"); |
163 | 172 | angle_deg[X] = prefs->getDouble("/options/grids/axonom/angle_x", 30.0); | 173 | angle_deg[X] = prefs->getDouble("/options/grids/axonom/angle_x", 30.0); |
164 | 173 | angle_deg[Z] = prefs->getDouble("/options/grids/axonom/angle_z", 30.0); | 174 | angle_deg[Z] = prefs->getDouble("/options/grids/axonom/angle_z", 30.0); |
165 | 174 | angle_deg[Y] = 0; | 175 | angle_deg[Y] = 0; |
166 | @@ -188,63 +189,6 @@ | |||
167 | 188 | if (snapper) delete snapper; | 189 | if (snapper) delete snapper; |
168 | 189 | } | 190 | } |
169 | 190 | 191 | ||
170 | 191 | |||
171 | 192 | /* fixme: Collect all these length parsing methods and think common sane API */ | ||
172 | 193 | |||
173 | 194 | static gboolean sp_nv_read_length(gchar const *str, guint base, gdouble *val, SPUnit const **unit) | ||
174 | 195 | { | ||
175 | 196 | if (!str) { | ||
176 | 197 | return FALSE; | ||
177 | 198 | } | ||
178 | 199 | |||
179 | 200 | gchar *u; | ||
180 | 201 | gdouble v = g_ascii_strtod(str, &u); | ||
181 | 202 | if (!u) { | ||
182 | 203 | return FALSE; | ||
183 | 204 | } | ||
184 | 205 | while (isspace(*u)) { | ||
185 | 206 | u += 1; | ||
186 | 207 | } | ||
187 | 208 | |||
188 | 209 | if (!*u) { | ||
189 | 210 | /* No unit specified - keep default */ | ||
190 | 211 | *val = v; | ||
191 | 212 | return TRUE; | ||
192 | 213 | } | ||
193 | 214 | |||
194 | 215 | if (base & SP_UNIT_DEVICE) { | ||
195 | 216 | if (u[0] && u[1] && !isalnum(u[2]) && !strncmp(u, "px", 2)) { | ||
196 | 217 | *unit = &sp_unit_get_by_id(SP_UNIT_PX); | ||
197 | 218 | *val = v; | ||
198 | 219 | return TRUE; | ||
199 | 220 | } | ||
200 | 221 | } | ||
201 | 222 | |||
202 | 223 | if (base & SP_UNIT_ABSOLUTE) { | ||
203 | 224 | if (!strncmp(u, "pt", 2)) { | ||
204 | 225 | *unit = &sp_unit_get_by_id(SP_UNIT_PT); | ||
205 | 226 | } else if (!strncmp(u, "mm", 2)) { | ||
206 | 227 | *unit = &sp_unit_get_by_id(SP_UNIT_MM); | ||
207 | 228 | } else if (!strncmp(u, "cm", 2)) { | ||
208 | 229 | *unit = &sp_unit_get_by_id(SP_UNIT_CM); | ||
209 | 230 | } else if (!strncmp(u, "m", 1)) { | ||
210 | 231 | *unit = &sp_unit_get_by_id(SP_UNIT_M); | ||
211 | 232 | } else if (!strncmp(u, "in", 2)) { | ||
212 | 233 | *unit = &sp_unit_get_by_id(SP_UNIT_IN); | ||
213 | 234 | } else if (!strncmp(u, "ft", 2)) { | ||
214 | 235 | *unit = &sp_unit_get_by_id(SP_UNIT_FT); | ||
215 | 236 | } else if (!strncmp(u, "pc", 2)) { | ||
216 | 237 | *unit = &sp_unit_get_by_id(SP_UNIT_PC); | ||
217 | 238 | } else { | ||
218 | 239 | return FALSE; | ||
219 | 240 | } | ||
220 | 241 | *val = v; | ||
221 | 242 | return TRUE; | ||
222 | 243 | } | ||
223 | 244 | |||
224 | 245 | return FALSE; | ||
225 | 246 | } | ||
226 | 247 | |||
227 | 248 | static gboolean sp_nv_read_opacity(gchar const *str, guint32 *color) | 192 | static gboolean sp_nv_read_opacity(gchar const *str, guint32 *color) |
228 | 249 | { | 193 | { |
229 | 250 | if (!str) { | 194 | if (!str) { |
230 | @@ -270,17 +214,20 @@ | |||
231 | 270 | { | 214 | { |
232 | 271 | gchar const *value; | 215 | gchar const *value; |
233 | 272 | if ( (value = repr->attribute("originx")) ) { | 216 | if ( (value = repr->attribute("originx")) ) { |
236 | 273 | sp_nv_read_length(value, SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE, &origin[Geom::X], &gridunit); | 217 | Inkscape::Util::Quantity q = unit_table.getQuantity(value); |
237 | 274 | origin[Geom::X] = sp_units_get_pixels(origin[Geom::X], *(gridunit)); | 218 | gridunit = q.unit; |
238 | 219 | origin[Geom::X] = unit_table.getQuantity(value).value("px"); | ||
239 | 275 | } | 220 | } |
240 | 276 | if ( (value = repr->attribute("originy")) ) { | 221 | if ( (value = repr->attribute("originy")) ) { |
243 | 277 | sp_nv_read_length(value, SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE, &origin[Geom::Y], &gridunit); | 222 | Inkscape::Util::Quantity q = unit_table.getQuantity(value); |
244 | 278 | origin[Geom::Y] = sp_units_get_pixels(origin[Geom::Y], *(gridunit)); | 223 | gridunit = q.unit; |
245 | 224 | origin[Geom::Y] = unit_table.getQuantity(value).value("px"); | ||
246 | 279 | } | 225 | } |
247 | 280 | 226 | ||
248 | 281 | if ( (value = repr->attribute("spacingy")) ) { | 227 | if ( (value = repr->attribute("spacingy")) ) { |
251 | 282 | sp_nv_read_length(value, SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE, &lengthy, &gridunit); | 228 | Inkscape::Util::Quantity q = unit_table.getQuantity(value); |
252 | 283 | lengthy = sp_units_get_pixels(lengthy, *(gridunit)); | 229 | gridunit = q.unit; |
253 | 230 | lengthy = q.value("px"); | ||
254 | 284 | if (lengthy < 0.0500) lengthy = 0.0500; | 231 | if (lengthy < 0.0500) lengthy = 0.0500; |
255 | 285 | } | 232 | } |
256 | 286 | 233 | ||
257 | @@ -419,17 +366,17 @@ | |||
258 | 419 | attach_all (*table, widget_array, sizeof(widget_array)); | 366 | attach_all (*table, widget_array, sizeof(widget_array)); |
259 | 420 | 367 | ||
260 | 421 | // set widget values | 368 | // set widget values |
262 | 422 | _rumg->setUnit (gridunit); | 369 | _rumg->setUnit (gridunit->abbr); |
263 | 423 | 370 | ||
264 | 424 | gdouble val; | 371 | gdouble val; |
265 | 425 | val = origin[Geom::X]; | 372 | val = origin[Geom::X]; |
267 | 426 | val = sp_pixels_get_units (val, *(gridunit)); | 373 | val = Inkscape::Util::Quantity::convert(val, "px", *gridunit); |
268 | 427 | _rsu_ox->setValue (val); | 374 | _rsu_ox->setValue (val); |
269 | 428 | val = origin[Geom::Y]; | 375 | val = origin[Geom::Y]; |
271 | 429 | val = sp_pixels_get_units (val, *(gridunit)); | 376 | val = Inkscape::Util::Quantity::convert(val, "px", *gridunit); |
272 | 430 | _rsu_oy->setValue (val); | 377 | _rsu_oy->setValue (val); |
273 | 431 | val = lengthy; | 378 | val = lengthy; |
275 | 432 | double gridy = sp_pixels_get_units (val, *(gridunit)); | 379 | double gridy = Inkscape::Util::Quantity::convert(val, "px", *gridunit); |
276 | 433 | _rsu_sy->setValue (gridy); | 380 | _rsu_sy->setValue (gridy); |
277 | 434 | 381 | ||
278 | 435 | _rsu_ax->setValue(angle_deg[X]); | 382 | _rsu_ax->setValue(angle_deg[X]); |
279 | @@ -458,17 +405,17 @@ | |||
280 | 458 | _rcb_enabled.setActive(snapper->getEnabled()); | 405 | _rcb_enabled.setActive(snapper->getEnabled()); |
281 | 459 | } | 406 | } |
282 | 460 | 407 | ||
284 | 461 | _rumg.setUnit (gridunit); | 408 | _rumg.setUnit (gridunit->abbr); |
285 | 462 | 409 | ||
286 | 463 | gdouble val; | 410 | gdouble val; |
287 | 464 | val = origin[Geom::X]; | 411 | val = origin[Geom::X]; |
289 | 465 | val = sp_pixels_get_units (val, *(gridunit)); | 412 | val = Inkscape::Util::Quantity::convert(val, &px, gridunit); |
290 | 466 | _rsu_ox.setValue (val); | 413 | _rsu_ox.setValue (val); |
291 | 467 | val = origin[Geom::Y]; | 414 | val = origin[Geom::Y]; |
293 | 468 | val = sp_pixels_get_units (val, *(gridunit)); | 415 | val = Inkscape::Util::Quantity::convert(val, &px, gridunit); |
294 | 469 | _rsu_oy.setValue (val); | 416 | _rsu_oy.setValue (val); |
295 | 470 | val = lengthy; | 417 | val = lengthy; |
297 | 471 | double gridy = sp_pixels_get_units (val, *(gridunit)); | 418 | double gridy = Inkscape::Util::Quantity::convert(val, &px, gridunit); |
298 | 472 | _rsu_sy.setValue (gridy); | 419 | _rsu_sy.setValue (gridy); |
299 | 473 | 420 | ||
300 | 474 | _rsu_ax.setValue(angle_deg[X]); | 421 | _rsu_ax.setValue(angle_deg[X]); |
301 | 475 | 422 | ||
302 | === modified file 'src/display/canvas-grid.cpp' | |||
303 | --- src/display/canvas-grid.cpp 2013-06-06 13:44:11 +0000 | |||
304 | +++ src/display/canvas-grid.cpp 2013-08-06 18:46:25 +0000 | |||
305 | @@ -42,7 +42,7 @@ | |||
306 | 42 | #include "display/canvas-grid.h" | 42 | #include "display/canvas-grid.h" |
307 | 43 | #include "display/sp-canvas-group.h" | 43 | #include "display/sp-canvas-group.h" |
308 | 44 | #include "document.h" | 44 | #include "document.h" |
310 | 45 | #include "helper/units.h" | 45 | #include "util/units.h" |
311 | 46 | #include "inkscape.h" | 46 | #include "inkscape.h" |
312 | 47 | #include "preferences.h" | 47 | #include "preferences.h" |
313 | 48 | #include "sp-namedview.h" | 48 | #include "sp-namedview.h" |
314 | @@ -55,6 +55,7 @@ | |||
315 | 55 | #include "display/sp-canvas.h" | 55 | #include "display/sp-canvas.h" |
316 | 56 | 56 | ||
317 | 57 | using Inkscape::DocumentUndo; | 57 | using Inkscape::DocumentUndo; |
318 | 58 | using Inkscape::Util::unit_table; | ||
319 | 58 | 59 | ||
320 | 59 | namespace Inkscape { | 60 | namespace Inkscape { |
321 | 60 | 61 | ||
322 | @@ -398,11 +399,11 @@ | |||
323 | 398 | gdouble val; | 399 | gdouble val; |
324 | 399 | 400 | ||
325 | 400 | val = origin_px[Geom::X]; | 401 | val = origin_px[Geom::X]; |
328 | 401 | val = sp_pixels_get_units (val, *gridunit); | 402 | val = Inkscape::Util::Quantity::convert(val, "px", *gridunit); |
329 | 402 | os_x << val << sp_unit_get_abbreviation(gridunit); | 403 | os_x << val << gridunit->abbr; |
330 | 403 | val = origin_px[Geom::Y]; | 404 | val = origin_px[Geom::Y]; |
333 | 404 | val = sp_pixels_get_units (val, *gridunit); | 405 | val = Inkscape::Util::Quantity::convert(val, "px", *gridunit); |
334 | 405 | os_y << val << sp_unit_get_abbreviation(gridunit); | 406 | os_y << val << gridunit->abbr; |
335 | 406 | repr->setAttribute("originx", os_x.str().c_str()); | 407 | repr->setAttribute("originx", os_x.str().c_str()); |
336 | 407 | repr->setAttribute("originy", os_y.str().c_str()); | 408 | repr->setAttribute("originy", os_y.str().c_str()); |
337 | 408 | } | 409 | } |
338 | @@ -488,17 +489,17 @@ | |||
339 | 488 | : CanvasGrid(nv, in_repr, in_doc, GRID_RECTANGULAR) | 489 | : CanvasGrid(nv, in_repr, in_doc, GRID_RECTANGULAR) |
340 | 489 | { | 490 | { |
341 | 490 | Inkscape::Preferences *prefs = Inkscape::Preferences::get(); | 491 | Inkscape::Preferences *prefs = Inkscape::Preferences::get(); |
343 | 491 | gridunit = sp_unit_get_by_abbreviation( prefs->getString("/options/grids/xy/units").data() ); | 492 | gridunit = new Inkscape::Util::Unit(unit_table.getUnit(prefs->getString("/options/grids/xy/units"))); |
344 | 492 | if (!gridunit) { | 493 | if (!gridunit) { |
346 | 493 | gridunit = &sp_unit_get_by_id(SP_UNIT_PX); | 494 | gridunit = new Inkscape::Util::Unit(unit_table.getUnit("px")); |
347 | 494 | } | 495 | } |
350 | 495 | origin[Geom::X] = sp_units_get_pixels(prefs->getDouble("/options/grids/xy/origin_x", 0.0), *gridunit); | 496 | origin[Geom::X] = Inkscape::Util::Quantity::convert(prefs->getDouble("/options/grids/xy/origin_x", 0.0), *gridunit, "px"); |
351 | 496 | origin[Geom::Y] = sp_units_get_pixels(prefs->getDouble("/options/grids/xy/origin_y", 0.0), *gridunit); | 497 | origin[Geom::Y] = Inkscape::Util::Quantity::convert(prefs->getDouble("/options/grids/xy/origin_y", 0.0), *gridunit, "px"); |
352 | 497 | color = prefs->getInt("/options/grids/xy/color", 0x0000ff20); | 498 | color = prefs->getInt("/options/grids/xy/color", 0x0000ff20); |
353 | 498 | empcolor = prefs->getInt("/options/grids/xy/empcolor", 0x0000ff40); | 499 | empcolor = prefs->getInt("/options/grids/xy/empcolor", 0x0000ff40); |
354 | 499 | empspacing = prefs->getInt("/options/grids/xy/empspacing", 5); | 500 | empspacing = prefs->getInt("/options/grids/xy/empspacing", 5); |
357 | 500 | spacing[Geom::X] = sp_units_get_pixels(prefs->getDouble("/options/grids/xy/spacing_x", 0.0), *gridunit); | 501 | spacing[Geom::X] = Inkscape::Util::Quantity::convert(prefs->getDouble("/options/grids/xy/spacing_x", 0.0), *gridunit, "px"); |
358 | 501 | spacing[Geom::Y] = sp_units_get_pixels(prefs->getDouble("/options/grids/xy/spacing_y", 0.0), *gridunit); | 502 | spacing[Geom::Y] = Inkscape::Util::Quantity::convert(prefs->getDouble("/options/grids/xy/spacing_y", 0.0), *gridunit, "px"); |
359 | 502 | render_dotted = prefs->getBool("/options/grids/xy/dotted", false); | 503 | render_dotted = prefs->getBool("/options/grids/xy/dotted", false); |
360 | 503 | 504 | ||
361 | 504 | snapper = new CanvasXYGridSnapper(this, &namedview->snap_manager, 0); | 505 | snapper = new CanvasXYGridSnapper(this, &namedview->snap_manager, 0); |
362 | @@ -511,64 +512,6 @@ | |||
363 | 511 | if (snapper) delete snapper; | 512 | if (snapper) delete snapper; |
364 | 512 | } | 513 | } |
365 | 513 | 514 | ||
366 | 514 | |||
367 | 515 | /* fixme: Collect all these length parsing methods and think common sane API */ | ||
368 | 516 | |||
369 | 517 | static gboolean | ||
370 | 518 | sp_nv_read_length(gchar const *str, guint base, gdouble *val, SPUnit const **unit) | ||
371 | 519 | { | ||
372 | 520 | if (!str) { | ||
373 | 521 | return FALSE; | ||
374 | 522 | } | ||
375 | 523 | |||
376 | 524 | gchar *u; | ||
377 | 525 | gdouble v = g_ascii_strtod(str, &u); | ||
378 | 526 | if (!u) { | ||
379 | 527 | return FALSE; | ||
380 | 528 | } | ||
381 | 529 | while (isspace(*u)) { | ||
382 | 530 | u += 1; | ||
383 | 531 | } | ||
384 | 532 | |||
385 | 533 | if (!*u) { | ||
386 | 534 | /* No unit specified - keep default */ | ||
387 | 535 | *val = v; | ||
388 | 536 | return TRUE; | ||
389 | 537 | } | ||
390 | 538 | |||
391 | 539 | if (base & SP_UNIT_DEVICE) { | ||
392 | 540 | if (u[0] && u[1] && !isalnum(u[2]) && !strncmp(u, "px", 2)) { | ||
393 | 541 | *unit = &sp_unit_get_by_id(SP_UNIT_PX); | ||
394 | 542 | *val = v; | ||
395 | 543 | return TRUE; | ||
396 | 544 | } | ||
397 | 545 | } | ||
398 | 546 | |||
399 | 547 | if (base & SP_UNIT_ABSOLUTE) { | ||
400 | 548 | if (!strncmp(u, "pt", 2)) { | ||
401 | 549 | *unit = &sp_unit_get_by_id(SP_UNIT_PT); | ||
402 | 550 | } else if (!strncmp(u, "mm", 2)) { | ||
403 | 551 | *unit = &sp_unit_get_by_id(SP_UNIT_MM); | ||
404 | 552 | } else if (!strncmp(u, "cm", 2)) { | ||
405 | 553 | *unit = &sp_unit_get_by_id(SP_UNIT_CM); | ||
406 | 554 | } else if (!strncmp(u, "m", 1)) { | ||
407 | 555 | *unit = &sp_unit_get_by_id(SP_UNIT_M); | ||
408 | 556 | } else if (!strncmp(u, "in", 2)) { | ||
409 | 557 | *unit = &sp_unit_get_by_id(SP_UNIT_IN); | ||
410 | 558 | } else if (!strncmp(u, "ft", 2)) { | ||
411 | 559 | *unit = &sp_unit_get_by_id(SP_UNIT_FT); | ||
412 | 560 | } else if (!strncmp(u, "pc", 2)) { | ||
413 | 561 | *unit = &sp_unit_get_by_id(SP_UNIT_PC); | ||
414 | 562 | } else { | ||
415 | 563 | return FALSE; | ||
416 | 564 | } | ||
417 | 565 | *val = v; | ||
418 | 566 | return TRUE; | ||
419 | 567 | } | ||
420 | 568 | |||
421 | 569 | return FALSE; | ||
422 | 570 | } | ||
423 | 571 | |||
424 | 572 | static gboolean sp_nv_read_opacity(gchar const *str, guint32 *color) | 515 | static gboolean sp_nv_read_opacity(gchar const *str, guint32 *color) |
425 | 573 | { | 516 | { |
426 | 574 | if (!str) { | 517 | if (!str) { |
427 | @@ -645,28 +588,32 @@ | |||
428 | 645 | { | 588 | { |
429 | 646 | gchar const *value; | 589 | gchar const *value; |
430 | 647 | if ( (value = repr->attribute("originx")) ) { | 590 | if ( (value = repr->attribute("originx")) ) { |
433 | 648 | sp_nv_read_length(value, SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE, &origin[Geom::X], &gridunit); | 591 | Inkscape::Util::Quantity q = unit_table.getQuantity(value); |
434 | 649 | origin[Geom::X] = sp_units_get_pixels(origin[Geom::X], *(gridunit)); | 592 | gridunit = q.unit; |
435 | 593 | origin[Geom::X] = unit_table.getQuantity(value).value("px"); | ||
436 | 650 | } | 594 | } |
437 | 651 | 595 | ||
438 | 652 | if ( (value = repr->attribute("originy")) ) { | 596 | if ( (value = repr->attribute("originy")) ) { |
441 | 653 | sp_nv_read_length(value, SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE, &origin[Geom::Y], &gridunit); | 597 | Inkscape::Util::Quantity q = unit_table.getQuantity(value); |
442 | 654 | origin[Geom::Y] = sp_units_get_pixels(origin[Geom::Y], *(gridunit)); | 598 | gridunit = q.unit; |
443 | 599 | origin[Geom::Y] = unit_table.getQuantity(value).value("px"); | ||
444 | 655 | } | 600 | } |
445 | 656 | 601 | ||
446 | 657 | if ( (value = repr->attribute("spacingx")) ) { | 602 | if ( (value = repr->attribute("spacingx")) ) { |
447 | 658 | double oldVal = spacing[Geom::X]; | 603 | double oldVal = spacing[Geom::X]; |
452 | 659 | sp_nv_read_length(value, SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE, &spacing[Geom::X], &gridunit); | 604 | Inkscape::Util::Quantity q = unit_table.getQuantity(value); |
453 | 660 | validateScalar( oldVal, &spacing[Geom::X]); | 605 | gridunit = q.unit; |
454 | 661 | spacing[Geom::X] = sp_units_get_pixels(spacing[Geom::X], *(gridunit)); | 606 | spacing[Geom::X] = q.quantity; |
455 | 662 | 607 | validateScalar(oldVal, &spacing[Geom::X]); | |
456 | 608 | spacing[Geom::X] = Inkscape::Util::Quantity::convert(spacing[Geom::X], *gridunit, "px"); | ||
457 | 663 | } | 609 | } |
458 | 664 | if ( (value = repr->attribute("spacingy")) ) { | 610 | if ( (value = repr->attribute("spacingy")) ) { |
459 | 665 | double oldVal = spacing[Geom::Y]; | 611 | double oldVal = spacing[Geom::Y]; |
464 | 666 | sp_nv_read_length(value, SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE, &spacing[Geom::Y], &gridunit); | 612 | Inkscape::Util::Quantity q = unit_table.getQuantity(value); |
465 | 667 | validateScalar( oldVal, &spacing[Geom::Y]); | 613 | gridunit = q.unit; |
466 | 668 | spacing[Geom::Y] = sp_units_get_pixels(spacing[Geom::Y], *(gridunit)); | 614 | spacing[Geom::Y] = q.quantity; |
467 | 669 | 615 | validateScalar(oldVal, &spacing[Geom::Y]); | |
468 | 616 | spacing[Geom::Y] = Inkscape::Util::Quantity::convert(spacing[Geom::Y], *gridunit, "px"); | ||
469 | 670 | } | 617 | } |
470 | 671 | 618 | ||
471 | 672 | if ( (value = repr->attribute("color")) ) { | 619 | if ( (value = repr->attribute("color")) ) { |
472 | @@ -802,20 +749,20 @@ | |||
473 | 802 | attach_all (*table, widget_array, sizeof(widget_array)); | 749 | attach_all (*table, widget_array, sizeof(widget_array)); |
474 | 803 | 750 | ||
475 | 804 | // set widget values | 751 | // set widget values |
477 | 805 | _rumg->setUnit (gridunit); | 752 | _rumg->setUnit (gridunit->abbr); |
478 | 806 | 753 | ||
479 | 807 | gdouble val; | 754 | gdouble val; |
480 | 808 | val = origin[Geom::X]; | 755 | val = origin[Geom::X]; |
482 | 809 | val = sp_pixels_get_units (val, *(gridunit)); | 756 | val = Inkscape::Util::Quantity::convert(val, "px", *gridunit); |
483 | 810 | _rsu_ox->setValue (val); | 757 | _rsu_ox->setValue (val); |
484 | 811 | val = origin[Geom::Y]; | 758 | val = origin[Geom::Y]; |
486 | 812 | val = sp_pixels_get_units (val, *(gridunit)); | 759 | val = Inkscape::Util::Quantity::convert(val, "px", *gridunit); |
487 | 813 | _rsu_oy->setValue (val); | 760 | _rsu_oy->setValue (val); |
488 | 814 | val = spacing[Geom::X]; | 761 | val = spacing[Geom::X]; |
490 | 815 | double gridx = sp_pixels_get_units (val, *(gridunit)); | 762 | double gridx = Inkscape::Util::Quantity::convert(val, "px", *gridunit); |
491 | 816 | _rsu_sx->setValue (gridx); | 763 | _rsu_sx->setValue (gridx); |
492 | 817 | val = spacing[Geom::Y]; | 764 | val = spacing[Geom::Y]; |
494 | 818 | double gridy = sp_pixels_get_units (val, *(gridunit)); | 765 | double gridy = Inkscape::Util::Quantity::convert(val, "px", *gridunit); |
495 | 819 | _rsu_sy->setValue (gridy); | 766 | _rsu_sy->setValue (gridy); |
496 | 820 | 767 | ||
497 | 821 | _rcp_gcol->setRgba32 (color); | 768 | _rcp_gcol->setRgba32 (color); |
498 | @@ -851,20 +798,20 @@ | |||
499 | 851 | _rcb_enabled.setActive(snapper->getEnabled()); | 798 | _rcb_enabled.setActive(snapper->getEnabled()); |
500 | 852 | } | 799 | } |
501 | 853 | 800 | ||
503 | 854 | _rumg.setUnit (gridunit); | 801 | _rumg.setUnit (gridunit->abbr); |
504 | 855 | 802 | ||
505 | 856 | gdouble val; | 803 | gdouble val; |
506 | 857 | val = origin[Geom::X]; | 804 | val = origin[Geom::X]; |
508 | 858 | val = sp_pixels_get_units (val, *(gridunit)); | 805 | val = Inkscape::Quantity::convert(val, "px", *gridunit); |
509 | 859 | _rsu_ox.setValue (val); | 806 | _rsu_ox.setValue (val); |
510 | 860 | val = origin[Geom::Y]; | 807 | val = origin[Geom::Y]; |
512 | 861 | val = sp_pixels_get_units (val, *(gridunit)); | 808 | val = Inkscape::Quantity::convert(val, "px", *gridunit); |
513 | 862 | _rsu_oy.setValue (val); | 809 | _rsu_oy.setValue (val); |
514 | 863 | val = spacing[Geom::X]; | 810 | val = spacing[Geom::X]; |
516 | 864 | double gridx = sp_pixels_get_units (val, *(gridunit)); | 811 | double gridx = Inkscape::Quantity::convert(val, "px", *gridunit); |
517 | 865 | _rsu_sx.setValue (gridx); | 812 | _rsu_sx.setValue (gridx); |
518 | 866 | val = spacing[Geom::Y]; | 813 | val = spacing[Geom::Y]; |
520 | 867 | double gridy = sp_pixels_get_units (val, *(gridunit)); | 814 | double gridy = Inkscape::Quantity::convert(val, "px", *gridunit); |
521 | 868 | _rsu_sy.setValue (gridy); | 815 | _rsu_sy.setValue (gridy); |
522 | 869 | 816 | ||
523 | 870 | _rcp_gcol.setRgba32 (color); | 817 | _rcp_gcol.setRgba32 (color); |
524 | 871 | 818 | ||
525 | === modified file 'src/display/canvas-grid.h' | |||
526 | --- src/display/canvas-grid.h 2013-01-17 20:07:10 +0000 | |||
527 | +++ src/display/canvas-grid.h 2013-08-06 18:46:25 +0000 | |||
528 | @@ -28,6 +28,10 @@ | |||
529 | 28 | class Node; | 28 | class Node; |
530 | 29 | } | 29 | } |
531 | 30 | 30 | ||
532 | 31 | namespace Util { | ||
533 | 32 | class Unit; | ||
534 | 33 | } | ||
535 | 34 | |||
536 | 31 | enum GridType { | 35 | enum GridType { |
537 | 32 | GRID_RECTANGULAR = 0, | 36 | GRID_RECTANGULAR = 0, |
538 | 33 | GRID_AXONOMETRIC = 1 | 37 | GRID_AXONOMETRIC = 1 |
539 | @@ -88,7 +92,7 @@ | |||
540 | 88 | guint32 empcolor; /**< Color for emphasis lines */ | 92 | guint32 empcolor; /**< Color for emphasis lines */ |
541 | 89 | gint empspacing; /**< Spacing between emphasis lines */ | 93 | gint empspacing; /**< Spacing between emphasis lines */ |
542 | 90 | 94 | ||
544 | 91 | SPUnit const* gridunit; | 95 | Inkscape::Util::Unit const* gridunit; |
545 | 92 | 96 | ||
546 | 93 | Inkscape::XML::Node * repr; | 97 | Inkscape::XML::Node * repr; |
547 | 94 | SPDocument *doc; | 98 | SPDocument *doc; |
548 | 95 | 99 | ||
549 | === modified file 'src/document.cpp' | |||
550 | --- src/document.cpp 2013-07-10 00:46:51 +0000 | |||
551 | +++ src/document.cpp 2013-08-06 18:46:25 +0000 | |||
552 | @@ -49,7 +49,6 @@ | |||
553 | 49 | #include "display/drawing-item.h" | 49 | #include "display/drawing-item.h" |
554 | 50 | #include "document-private.h" | 50 | #include "document-private.h" |
555 | 51 | #include "document-undo.h" | 51 | #include "document-undo.h" |
556 | 52 | #include "helper/units.h" | ||
557 | 53 | #include "id-clash.h" | 52 | #include "id-clash.h" |
558 | 54 | #include "inkscape-private.h" | 53 | #include "inkscape-private.h" |
559 | 55 | #include "inkscape-version.h" | 54 | #include "inkscape-version.h" |
560 | @@ -63,12 +62,13 @@ | |||
561 | 63 | #include "sp-object-repr.h" | 62 | #include "sp-object-repr.h" |
562 | 64 | #include "sp-symbol.h" | 63 | #include "sp-symbol.h" |
563 | 65 | #include "transf_mat_3x4.h" | 64 | #include "transf_mat_3x4.h" |
565 | 66 | #include "unit-constants.h" | 65 | #include "util/units.h" |
566 | 67 | #include "xml/repr.h" | 66 | #include "xml/repr.h" |
567 | 68 | #include "xml/rebase-hrefs.h" | 67 | #include "xml/rebase-hrefs.h" |
568 | 69 | #include "libcroco/cr-cascade.h" | 68 | #include "libcroco/cr-cascade.h" |
569 | 70 | 69 | ||
570 | 71 | using Inkscape::DocumentUndo; | 70 | using Inkscape::DocumentUndo; |
571 | 71 | using Inkscape::Util::unit_table; | ||
572 | 72 | 72 | ||
573 | 73 | // Higher number means lower priority. | 73 | // Higher number means lower priority. |
574 | 74 | #define SP_DOCUMENT_UPDATE_PRIORITY (G_PRIORITY_HIGH_IDLE - 2) | 74 | #define SP_DOCUMENT_UPDATE_PRIORITY (G_PRIORITY_HIGH_IDLE - 2) |
575 | @@ -546,21 +546,21 @@ | |||
576 | 546 | return result; | 546 | return result; |
577 | 547 | } | 547 | } |
578 | 548 | 548 | ||
580 | 549 | void SPDocument::setWidth(gdouble width, const SPUnit *unit) | 549 | void SPDocument::setWidth(const Inkscape::Util::Quantity &width) |
581 | 550 | { | 550 | { |
582 | 551 | if (root->width.unit == SVGLength::PERCENT && root->viewBox_set) { // set to viewBox= | 551 | if (root->width.unit == SVGLength::PERCENT && root->viewBox_set) { // set to viewBox= |
584 | 552 | root->viewBox.setMax(Geom::Point(root->viewBox.left() + sp_units_get_pixels (width, *unit), root->viewBox.bottom())); | 552 | root->viewBox.setMax(Geom::Point(root->viewBox.left() + width.value("px"), root->viewBox.bottom())); |
585 | 553 | } else { // set to width= | 553 | } else { // set to width= |
586 | 554 | gdouble old_computed = root->width.computed; | 554 | gdouble old_computed = root->width.computed; |
588 | 555 | root->width.computed = sp_units_get_pixels (width, *unit); | 555 | root->width.computed = width.value("px"); |
589 | 556 | /* SVG does not support meters as a unit, so we must translate meters to | 556 | /* SVG does not support meters as a unit, so we must translate meters to |
590 | 557 | * cm when writing */ | 557 | * cm when writing */ |
593 | 558 | if (!strcmp(unit->abbr, "m")) { | 558 | if (*width.unit == unit_table.getUnit("m")) { |
594 | 559 | root->width.value = 100*width; | 559 | root->width.value = width.value("cm"); |
595 | 560 | root->width.unit = SVGLength::CM; | 560 | root->width.unit = SVGLength::CM; |
596 | 561 | } else { | 561 | } else { |
599 | 562 | root->width.value = width; | 562 | root->width.value = width.quantity; |
600 | 563 | root->width.unit = (SVGLength::Unit) sp_unit_get_svg_unit(unit); | 563 | root->width.unit = (SVGLength::Unit) width.unit->svgUnit(); |
601 | 564 | } | 564 | } |
602 | 565 | 565 | ||
603 | 566 | if (root->viewBox_set) | 566 | if (root->viewBox_set) |
604 | @@ -582,21 +582,21 @@ | |||
605 | 582 | return result; | 582 | return result; |
606 | 583 | } | 583 | } |
607 | 584 | 584 | ||
609 | 585 | void SPDocument::setHeight(gdouble height, const SPUnit *unit) | 585 | void SPDocument::setHeight(const Inkscape::Util::Quantity &height) |
610 | 586 | { | 586 | { |
611 | 587 | if (root->height.unit == SVGLength::PERCENT && root->viewBox_set) { // set to viewBox= | 587 | if (root->height.unit == SVGLength::PERCENT && root->viewBox_set) { // set to viewBox= |
613 | 588 | root->viewBox.setMax(Geom::Point(root->viewBox.right(), root->viewBox.top() + sp_units_get_pixels (height, *unit))); | 588 | root->viewBox.setMax(Geom::Point(root->viewBox.right(), root->viewBox.top() + height.value("px"))); |
614 | 589 | } else { // set to height= | 589 | } else { // set to height= |
615 | 590 | gdouble old_computed = root->height.computed; | 590 | gdouble old_computed = root->height.computed; |
617 | 591 | root->height.computed = sp_units_get_pixels (height, *unit); | 591 | root->height.computed = height.value("px"); |
618 | 592 | /* SVG does not support meters as a unit, so we must translate meters to | 592 | /* SVG does not support meters as a unit, so we must translate meters to |
619 | 593 | * cm when writing */ | 593 | * cm when writing */ |
622 | 594 | if (!strcmp(unit->abbr, "m")) { | 594 | if (*height.unit == unit_table.getUnit("m")) { |
623 | 595 | root->height.value = 100*height; | 595 | root->height.value = height.value("cm"); |
624 | 596 | root->height.unit = SVGLength::CM; | 596 | root->height.unit = SVGLength::CM; |
625 | 597 | } else { | 597 | } else { |
628 | 598 | root->height.value = height; | 598 | root->height.value = height.quantity; |
629 | 599 | root->height.unit = (SVGLength::Unit) sp_unit_get_svg_unit(unit); | 599 | root->height.unit = (SVGLength::Unit) height.unit->svgUnit(); |
630 | 600 | } | 600 | } |
631 | 601 | 601 | ||
632 | 602 | if (root->viewBox_set) | 602 | if (root->viewBox_set) |
633 | @@ -631,7 +631,7 @@ | |||
634 | 631 | double const h = rect.height(); | 631 | double const h = rect.height(); |
635 | 632 | 632 | ||
636 | 633 | double const old_height = getHeight(); | 633 | double const old_height = getHeight(); |
638 | 634 | SPUnit const &px(sp_unit_get_by_id(SP_UNIT_PX)); | 634 | Inkscape::Util::Unit const px = unit_table.getUnit("px"); |
639 | 635 | 635 | ||
640 | 636 | /* in px */ | 636 | /* in px */ |
641 | 637 | double margin_top = 0.0; | 637 | double margin_top = 0.0; |
642 | @@ -644,9 +644,10 @@ | |||
643 | 644 | if (with_margins && nv) { | 644 | if (with_margins && nv) { |
644 | 645 | if (nv != NULL) { | 645 | if (nv != NULL) { |
645 | 646 | gchar const * const units_abbr = nv->getAttribute("units"); | 646 | gchar const * const units_abbr = nv->getAttribute("units"); |
647 | 647 | SPUnit const *margin_units = NULL; | 647 | Inkscape::Util::Unit const *margin_units = NULL; |
648 | 648 | if (units_abbr != NULL) { | 648 | if (units_abbr != NULL) { |
650 | 649 | margin_units = sp_unit_get_by_abbreviation(units_abbr); | 649 | Inkscape::Util::Unit mu = unit_table.getUnit(units_abbr); |
651 | 650 | margin_units = μ | ||
652 | 650 | } | 651 | } |
653 | 651 | if (margin_units == NULL) { | 652 | if (margin_units == NULL) { |
654 | 652 | margin_units = &px; | 653 | margin_units = &px; |
655 | @@ -663,8 +664,8 @@ | |||
656 | 663 | rect.max() + Geom::Point(margin_right, margin_top)); | 664 | rect.max() + Geom::Point(margin_right, margin_top)); |
657 | 664 | 665 | ||
658 | 665 | 666 | ||
661 | 666 | setWidth(rect_with_margins.width(), &px); | 667 | setWidth(Inkscape::Util::Quantity(rect_with_margins.width(), "px")); |
662 | 667 | setHeight(rect_with_margins.height(), &px); | 668 | setHeight(Inkscape::Util::Quantity(rect_with_margins.height(), "px")); |
663 | 668 | 669 | ||
664 | 669 | Geom::Translate const tr( | 670 | Geom::Translate const tr( |
665 | 670 | Geom::Point(0, old_height - rect_with_margins.height()) | 671 | Geom::Point(0, old_height - rect_with_margins.height()) |
666 | @@ -964,7 +965,7 @@ | |||
667 | 964 | if (root->viewBox_set) { // if set, take from viewBox | 965 | if (root->viewBox_set) { // if set, take from viewBox |
668 | 965 | ctx->viewport = root->viewBox; | 966 | ctx->viewport = root->viewBox; |
669 | 966 | } else { // as a last resort, set size to A4 | 967 | } else { // as a last resort, set size to A4 |
671 | 967 | ctx->viewport = Geom::Rect::from_xywh(0, 0, 210 * PX_PER_MM, 297 * PX_PER_MM); | 968 | ctx->viewport = Geom::Rect::from_xywh(0, 0, 210 * Inkscape::Util::Quantity::convert(1, "mm", "px"), 297 * Inkscape::Util::Quantity::convert(1, "mm", "px")); |
672 | 968 | } | 969 | } |
673 | 969 | ctx->i2vp = Geom::identity(); | 970 | ctx->i2vp = Geom::identity(); |
674 | 970 | } | 971 | } |
675 | 971 | 972 | ||
676 | === modified file 'src/document.h' | |||
677 | --- src/document.h 2013-07-10 00:46:51 +0000 | |||
678 | +++ src/document.h 2013-08-06 18:46:25 +0000 | |||
679 | @@ -35,7 +35,6 @@ | |||
680 | 35 | class SPObject; | 35 | class SPObject; |
681 | 36 | struct SPGroup; | 36 | struct SPGroup; |
682 | 37 | struct SPRoot; | 37 | struct SPRoot; |
683 | 38 | struct SPUnit; | ||
684 | 39 | 38 | ||
685 | 40 | namespace Inkscape { | 39 | namespace Inkscape { |
686 | 41 | struct Application; | 40 | struct Application; |
687 | @@ -47,6 +46,9 @@ | |||
688 | 47 | struct Document; | 46 | struct Document; |
689 | 48 | class Node; | 47 | class Node; |
690 | 49 | } | 48 | } |
691 | 49 | namespace Util { | ||
692 | 50 | class Quantity; | ||
693 | 51 | } | ||
694 | 50 | } | 52 | } |
695 | 51 | 53 | ||
696 | 52 | class SPDefs; | 54 | class SPDefs; |
697 | @@ -229,8 +231,8 @@ | |||
698 | 229 | gdouble getHeight() const; | 231 | gdouble getHeight() const; |
699 | 230 | Geom::Point getDimensions() const; | 232 | Geom::Point getDimensions() const; |
700 | 231 | Geom::OptRect preferredBounds() const; | 233 | Geom::OptRect preferredBounds() const; |
703 | 232 | void setWidth(gdouble width, const SPUnit *unit); | 234 | void setWidth(const Inkscape::Util::Quantity &width); |
704 | 233 | void setHeight(gdouble height, const SPUnit *unit); | 235 | void setHeight(const Inkscape::Util::Quantity &height); |
705 | 234 | void requestModified(); | 236 | void requestModified(); |
706 | 235 | gint ensureUpToDate(); | 237 | gint ensureUpToDate(); |
707 | 236 | bool addResource(const gchar *key, SPObject *object); | 238 | bool addResource(const gchar *key, SPObject *object); |
708 | @@ -254,8 +256,6 @@ | |||
709 | 254 | void setupViewport(SPItemCtx *ctx); | 256 | void setupViewport(SPItemCtx *ctx); |
710 | 255 | }; | 257 | }; |
711 | 256 | 258 | ||
712 | 257 | struct SPUnit; | ||
713 | 258 | |||
714 | 259 | /* | 259 | /* |
715 | 260 | * Ideas: How to overcome style invalidation nightmare | 260 | * Ideas: How to overcome style invalidation nightmare |
716 | 261 | * | 261 | * |
717 | 262 | 262 | ||
718 | === modified file 'src/doxygen-main.cpp' | |||
719 | --- src/doxygen-main.cpp 2013-07-23 16:54:03 +0000 | |||
720 | +++ src/doxygen-main.cpp 2013-08-06 18:46:25 +0000 | |||
721 | @@ -334,8 +334,6 @@ | |||
722 | 334 | * | 334 | * |
723 | 335 | * Inkscape::GC | 335 | * Inkscape::GC |
724 | 336 | * | 336 | * |
725 | 337 | * [\ref sp-metrics.cpp, \ref sp-metrics.h] | ||
726 | 338 | * | ||
727 | 339 | * [\ref prefs-utils.cpp] [\ref print.cpp] | 337 | * [\ref prefs-utils.cpp] [\ref print.cpp] |
728 | 340 | * | 338 | * |
729 | 341 | * - Inkscape::GZipBuffer [\ref streams-gzip.h] | 339 | * - Inkscape::GZipBuffer [\ref streams-gzip.h] |
730 | @@ -350,7 +348,7 @@ | |||
731 | 350 | * Inkscape::Whiteboard::UndoStackObserver [\ref undo-stack-observer.cpp, \ref composite-undo-stack-observer.cpp] | 348 | * Inkscape::Whiteboard::UndoStackObserver [\ref undo-stack-observer.cpp, \ref composite-undo-stack-observer.cpp] |
732 | 351 | * [\ref document-undo.cpp] | 349 | * [\ref document-undo.cpp] |
733 | 352 | * | 350 | * |
735 | 353 | * {\ref dialogs/} [\ref decimal-round.h] [\ref enums.h] [\ref unit-constants.h] | 351 | * {\ref dialogs/} [\ref decimal-round.h] [\ref enums.h] |
736 | 354 | */ | 352 | */ |
737 | 355 | 353 | ||
738 | 356 | 354 | ||
739 | 357 | 355 | ||
740 | === modified file 'src/extension/internal/cairo-render-context.cpp' | |||
741 | --- src/extension/internal/cairo-render-context.cpp 2013-08-05 21:07:35 +0000 | |||
742 | +++ src/extension/internal/cairo-render-context.cpp 2013-08-06 18:46:25 +0000 | |||
743 | @@ -44,12 +44,11 @@ | |||
744 | 44 | #include "sp-pattern.h" | 44 | #include "sp-pattern.h" |
745 | 45 | #include "sp-mask.h" | 45 | #include "sp-mask.h" |
746 | 46 | #include "sp-clippath.h" | 46 | #include "sp-clippath.h" |
747 | 47 | #include "util/units.h" | ||
748 | 47 | #ifdef WIN32 | 48 | #ifdef WIN32 |
749 | 48 | #include "libnrtype/FontFactory.h" // USE_PANGO_WIN32 | 49 | #include "libnrtype/FontFactory.h" // USE_PANGO_WIN32 |
750 | 49 | #endif | 50 | #endif |
751 | 50 | 51 | ||
752 | 51 | #include <unit-constants.h> | ||
753 | 52 | |||
754 | 53 | #include "cairo-render-context.h" | 52 | #include "cairo-render-context.h" |
755 | 54 | #include "cairo-renderer.h" | 53 | #include "cairo-renderer.h" |
756 | 55 | #include "extension/system.h" | 54 | #include "extension/system.h" |
757 | @@ -855,7 +854,7 @@ | |||
758 | 855 | _surface = surface; | 854 | _surface = surface; |
759 | 856 | 855 | ||
760 | 857 | if (_vector_based_target) { | 856 | if (_vector_based_target) { |
762 | 858 | cairo_scale(_cr, PT_PER_PX, PT_PER_PX); | 857 | cairo_scale(_cr, Inkscape::Util::Quantity::convert(1, "px", "pt"), Inkscape::Util::Quantity::convert(1, "px", "pt")); |
763 | 859 | } else if (cairo_surface_get_content(_surface) != CAIRO_CONTENT_ALPHA) { | 858 | } else if (cairo_surface_get_content(_surface) != CAIRO_CONTENT_ALPHA) { |
764 | 860 | // set background color on non-alpha surfaces | 859 | // set background color on non-alpha surfaces |
765 | 861 | // TODO: bgcolor should be derived from SPDocument | 860 | // TODO: bgcolor should be derived from SPDocument |
766 | 862 | 861 | ||
767 | === modified file 'src/extension/internal/cairo-renderer-pdf-out.cpp' | |||
768 | --- src/extension/internal/cairo-renderer-pdf-out.cpp 2013-08-05 21:07:35 +0000 | |||
769 | +++ src/extension/internal/cairo-renderer-pdf-out.cpp 2013-08-06 18:46:25 +0000 | |||
770 | @@ -39,7 +39,7 @@ | |||
771 | 39 | #include <2geom/affine.h> | 39 | #include <2geom/affine.h> |
772 | 40 | #include "document.h" | 40 | #include "document.h" |
773 | 41 | 41 | ||
775 | 42 | #include "unit-constants.h" | 42 | #include "util/units.h" |
776 | 43 | 43 | ||
777 | 44 | namespace Inkscape { | 44 | namespace Inkscape { |
778 | 45 | namespace Extension { | 45 | namespace Extension { |
779 | @@ -197,7 +197,7 @@ | |||
780 | 197 | 197 | ||
781 | 198 | float new_bleedmargin_px = 0.; | 198 | float new_bleedmargin_px = 0.; |
782 | 199 | try { | 199 | try { |
784 | 200 | new_bleedmargin_px = mod->get_param_float("bleed") * PX_PER_MM; | 200 | new_bleedmargin_px = mod->get_param_float("bleed") * Inkscape::Util::Quantity::convert(1, "mm", "px"); |
785 | 201 | } | 201 | } |
786 | 202 | catch(...) { | 202 | catch(...) { |
787 | 203 | g_warning("Parameter <bleed> might not exist"); | 203 | g_warning("Parameter <bleed> might not exist"); |
788 | 204 | 204 | ||
789 | === modified file 'src/extension/internal/cairo-renderer.cpp' | |||
790 | --- src/extension/internal/cairo-renderer.cpp 2012-10-28 18:19:43 +0000 | |||
791 | +++ src/extension/internal/cairo-renderer.cpp 2013-08-06 18:46:25 +0000 | |||
792 | @@ -55,7 +55,7 @@ | |||
793 | 55 | #include "sp-mask.h" | 55 | #include "sp-mask.h" |
794 | 56 | #include "sp-clippath.h" | 56 | #include "sp-clippath.h" |
795 | 57 | 57 | ||
797 | 58 | #include <unit-constants.h> | 58 | #include "util/units.h" |
798 | 59 | #include "helper/png-write.h" | 59 | #include "helper/png-write.h" |
799 | 60 | #include "helper/pixbuf-ops.h" | 60 | #include "helper/pixbuf-ops.h" |
800 | 61 | 61 | ||
801 | @@ -442,7 +442,7 @@ | |||
802 | 442 | */ | 442 | */ |
803 | 443 | res = ctx->getBitmapResolution(); | 443 | res = ctx->getBitmapResolution(); |
804 | 444 | if(res == 0) { | 444 | if(res == 0) { |
806 | 445 | res = PX_PER_IN; | 445 | res = Inkscape::Util::Quantity::convert(1, "in", "px"); |
807 | 446 | } | 446 | } |
808 | 447 | TRACE(("sp_asbitmap_render: resolution: %f\n", res )); | 447 | TRACE(("sp_asbitmap_render: resolution: %f\n", res )); |
809 | 448 | 448 | ||
810 | @@ -463,8 +463,8 @@ | |||
811 | 463 | } | 463 | } |
812 | 464 | 464 | ||
813 | 465 | // The width and height of the bitmap in pixels | 465 | // The width and height of the bitmap in pixels |
816 | 466 | unsigned width = ceil(bbox->width() * (res / PX_PER_IN)); | 466 | unsigned width = ceil(bbox->width() * (res / Inkscape::Util::Quantity::convert(1, "in", "px"))); |
817 | 467 | unsigned height = ceil(bbox->height() * (res / PX_PER_IN)); | 467 | unsigned height = ceil(bbox->height() * (res / Inkscape::Util::Quantity::convert(1, "in", "px"))); |
818 | 468 | 468 | ||
819 | 469 | if (width == 0 || height == 0) return; | 469 | if (width == 0 || height == 0) return; |
820 | 470 | 470 | ||
821 | @@ -477,7 +477,7 @@ | |||
822 | 477 | double shift_y = bbox->max()[Geom::Y]; | 477 | double shift_y = bbox->max()[Geom::Y]; |
823 | 478 | 478 | ||
824 | 479 | // For default 90 dpi, snap bitmap to pixel grid | 479 | // For default 90 dpi, snap bitmap to pixel grid |
826 | 480 | if (res == PX_PER_IN) { | 480 | if (res == Inkscape::Util::Quantity::convert(1, "in", "px")) { |
827 | 481 | shift_x = round (shift_x); | 481 | shift_x = round (shift_x); |
828 | 482 | shift_y = -round (-shift_y); // Correct rounding despite coordinate inversion. | 482 | shift_y = -round (-shift_y); // Correct rounding despite coordinate inversion. |
829 | 483 | // Remove the negations when the inversion is gone. | 483 | // Remove the negations when the inversion is gone. |
830 | @@ -629,7 +629,7 @@ | |||
831 | 629 | 629 | ||
832 | 630 | if (ctx->_vector_based_target) { | 630 | if (ctx->_vector_based_target) { |
833 | 631 | // convert from px to pt | 631 | // convert from px to pt |
835 | 632 | d *= Geom::Scale(PT_PER_PX); | 632 | d *= Geom::Scale(Inkscape::Util::Quantity::convert(1, "px", "pt")); |
836 | 633 | } | 633 | } |
837 | 634 | 634 | ||
838 | 635 | ctx->_width = d.width(); | 635 | ctx->_width = d.width(); |
839 | @@ -647,11 +647,11 @@ | |||
840 | 647 | } else { | 647 | } else { |
841 | 648 | double high = doc->getHeight(); | 648 | double high = doc->getHeight(); |
842 | 649 | if (ctx->_vector_based_target) | 649 | if (ctx->_vector_based_target) |
844 | 650 | high *= PT_PER_PX; | 650 | high *= Inkscape::Util::Quantity::convert(1, "px", "pt"); |
845 | 651 | 651 | ||
846 | 652 | // this transform translates the export drawing to a virtual page (0,0)-(width,height) | 652 | // this transform translates the export drawing to a virtual page (0,0)-(width,height) |
849 | 653 | Geom::Affine tp(Geom::Translate(-d.left() * (ctx->_vector_based_target ? PX_PER_PT : 1.0), | 653 | Geom::Affine tp(Geom::Translate(-d.left() * (ctx->_vector_based_target ? Inkscape::Util::Quantity::convert(1, "pt", "px") : 1.0), |
850 | 654 | (d.bottom() - high) * (ctx->_vector_based_target ? PX_PER_PT : 1.0))); | 654 | (d.bottom() - high) * (ctx->_vector_based_target ? Inkscape::Util::Quantity::convert(1, "pt", "px") : 1.0))); |
851 | 655 | ctx->transform(tp); | 655 | ctx->transform(tp); |
852 | 656 | } | 656 | } |
853 | 657 | } | 657 | } |
854 | 658 | 658 | ||
855 | === modified file 'src/extension/internal/emf-win32-inout.cpp' | |||
856 | --- src/extension/internal/emf-win32-inout.cpp 2013-08-05 21:07:35 +0000 | |||
857 | +++ src/extension/internal/emf-win32-inout.cpp 2013-08-06 18:46:25 +0000 | |||
858 | @@ -37,9 +37,9 @@ | |||
859 | 37 | #include "extension/output.h" | 37 | #include "extension/output.h" |
860 | 38 | #include "display/drawing.h" | 38 | #include "display/drawing.h" |
861 | 39 | #include "display/drawing-item.h" | 39 | #include "display/drawing-item.h" |
862 | 40 | #include "unit-constants.h" | ||
863 | 41 | #include "clear-n_.h" | 40 | #include "clear-n_.h" |
864 | 42 | #include "document.h" | 41 | #include "document.h" |
865 | 42 | #include "util/units.h" | ||
866 | 43 | 43 | ||
867 | 44 | #define WIN32_LEAN_AND_MEAN | 44 | #define WIN32_LEAN_AND_MEAN |
868 | 45 | #include <windows.h> | 45 | #include <windows.h> |
869 | @@ -60,7 +60,7 @@ | |||
870 | 60 | namespace Extension { | 60 | namespace Extension { |
871 | 61 | namespace Internal { | 61 | namespace Internal { |
872 | 62 | 62 | ||
874 | 63 | static float device_scale = DEVICESCALE; | 63 | static float device_scale = Inkscape::Util::Quantity::convert(1, "px", "pt"); |
875 | 64 | static float device_x; | 64 | static float device_x; |
876 | 65 | static float device_y; | 65 | static float device_y; |
877 | 66 | static RECTL rc_old; | 66 | static RECTL rc_old; |
878 | @@ -781,18 +781,18 @@ | |||
879 | 781 | 781 | ||
880 | 782 | d->dc[d->level].PixelsInX = pEmr->rclFrame.right - pEmr->rclFrame.left; | 782 | d->dc[d->level].PixelsInX = pEmr->rclFrame.right - pEmr->rclFrame.left; |
881 | 783 | d->dc[d->level].PixelsInY = pEmr->rclFrame.bottom - pEmr->rclFrame.top; | 783 | d->dc[d->level].PixelsInY = pEmr->rclFrame.bottom - pEmr->rclFrame.top; |
884 | 784 | device_x = pEmr->rclFrame.left/100.0*PX_PER_MM; | 784 | device_x = pEmr->rclFrame.left/100.0*Inkscape::Util::Quantity::convert(1, "mm", "px"); |
885 | 785 | device_y = pEmr->rclFrame.top/100.0*PX_PER_MM; | 785 | device_y = pEmr->rclFrame.top/100.0*Inkscape::Util::Quantity::convert(1, "mm", "px"); |
886 | 786 | 786 | ||
887 | 787 | d->MMX = d->dc[d->level].PixelsInX / 100.0; | 787 | d->MMX = d->dc[d->level].PixelsInX / 100.0; |
888 | 788 | d->MMY = d->dc[d->level].PixelsInY / 100.0; | 788 | d->MMY = d->dc[d->level].PixelsInY / 100.0; |
889 | 789 | 789 | ||
892 | 790 | d->dc[d->level].PixelsOutX = d->MMX * PX_PER_MM; | 790 | d->dc[d->level].PixelsOutX = d->MMX * Inkscape::Util::Quantity::convert(1, "mm", "px"); |
893 | 791 | d->dc[d->level].PixelsOutY = d->MMY * PX_PER_MM; | 791 | d->dc[d->level].PixelsOutY = d->MMY * Inkscape::Util::Quantity::convert(1, "mm", "px"); |
894 | 792 | 792 | ||
895 | 793 | // calculate ratio of Inkscape dpi/device dpi | 793 | // calculate ratio of Inkscape dpi/device dpi |
896 | 794 | if (pEmr->szlMillimeters.cx && pEmr->szlDevice.cx) | 794 | if (pEmr->szlMillimeters.cx && pEmr->szlDevice.cx) |
898 | 795 | device_scale = PX_PER_MM*pEmr->szlMillimeters.cx/pEmr->szlDevice.cx; | 795 | device_scale = Inkscape::Util::Quantity::convert(1, "mm", "px")*pEmr->szlMillimeters.cx/pEmr->szlDevice.cx; |
899 | 796 | 796 | ||
900 | 797 | tmp_outdef << | 797 | tmp_outdef << |
901 | 798 | " width=\"" << d->MMX << "mm\"\n" << | 798 | " width=\"" << d->MMX << "mm\"\n" << |
902 | 799 | 799 | ||
903 | === modified file 'src/extension/internal/emf-win32-print.cpp' | |||
904 | --- src/extension/internal/emf-win32-print.cpp 2013-08-05 21:07:35 +0000 | |||
905 | +++ src/extension/internal/emf-win32-print.cpp 2013-08-06 18:46:25 +0000 | |||
906 | @@ -36,6 +36,7 @@ | |||
907 | 36 | #include "helper/geom.h" | 36 | #include "helper/geom.h" |
908 | 37 | #include "helper/geom-curves.h" | 37 | #include "helper/geom-curves.h" |
909 | 38 | #include "sp-item.h" | 38 | #include "sp-item.h" |
910 | 39 | #include "util/units.h" | ||
911 | 39 | 40 | ||
912 | 40 | #include "style.h" | 41 | #include "style.h" |
913 | 41 | #include "inkscape-version.h" | 42 | #include "inkscape-version.h" |
914 | @@ -43,8 +44,6 @@ | |||
915 | 43 | 44 | ||
916 | 44 | #include "emf-win32-print.h" | 45 | #include "emf-win32-print.h" |
917 | 45 | 46 | ||
918 | 46 | #include "unit-constants.h" | ||
919 | 47 | |||
920 | 48 | #include "extension/system.h" | 47 | #include "extension/system.h" |
921 | 49 | #include "extension/print.h" | 48 | #include "extension/print.h" |
922 | 50 | #include "document.h" | 49 | #include "document.h" |
923 | @@ -129,7 +128,7 @@ | |||
924 | 129 | if (bbox) d = *bbox; | 128 | if (bbox) d = *bbox; |
925 | 130 | } | 129 | } |
926 | 131 | 130 | ||
928 | 132 | d *= Geom::Scale(IN_PER_PX); | 131 | d *= Geom::Scale(Inkscape::Util::Quantity::convert(1, "px", "in")); |
929 | 133 | 132 | ||
930 | 134 | float dwInchesX = d.width(); | 133 | float dwInchesX = d.width(); |
931 | 135 | float dwInchesY = d.height(); | 134 | float dwInchesY = d.height(); |
932 | @@ -196,7 +195,7 @@ | |||
933 | 196 | snprintf(buff, sizeof(buff)-1, "Screen=%dx%dpx, %dx%dmm", PixelsX, PixelsY, MMX, MMY); | 195 | snprintf(buff, sizeof(buff)-1, "Screen=%dx%dpx, %dx%dmm", PixelsX, PixelsY, MMX, MMY); |
934 | 197 | GdiComment(hdc, strlen(buff), (BYTE*) buff); | 196 | GdiComment(hdc, strlen(buff), (BYTE*) buff); |
935 | 198 | 197 | ||
937 | 199 | snprintf(buff, sizeof(buff)-1, "Drawing=%.1lfx%.1lfpx, %.1lfx%.1lfmm", _width, _height, dwInchesX * MM_PER_IN, dwInchesY * MM_PER_IN); | 198 | snprintf(buff, sizeof(buff)-1, "Drawing=%.1lfx%.1lfpx, %.1lfx%.1lfmm", _width, _height, dwInchesX * Inkscape::Util::Quantity::convert(1, "in", "mm"), dwInchesY * Inkscape::Util::Quantity::convert(1, "in", "mm")); |
938 | 200 | GdiComment(hdc, strlen(buff), (BYTE*) buff); | 199 | GdiComment(hdc, strlen(buff), (BYTE*) buff); |
939 | 201 | } | 200 | } |
940 | 202 | 201 | ||
941 | @@ -304,7 +303,7 @@ | |||
942 | 304 | 303 | ||
943 | 305 | double scale = sqrt( (p[X]*p[X]) + (p[Y]*p[Y]) ) / sqrt(2); | 304 | double scale = sqrt( (p[X]*p[X]) + (p[Y]*p[Y]) ) / sqrt(2); |
944 | 306 | 305 | ||
946 | 307 | DWORD linewidth = MAX( 1, (DWORD) (scale * style->stroke_width.computed * IN_PER_PX * dwDPI) ); | 306 | DWORD linewidth = MAX( 1, (DWORD) (scale * style->stroke_width.computed * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI) ); |
947 | 308 | 307 | ||
948 | 309 | if (style->stroke_linecap.computed == 0) { | 308 | if (style->stroke_linecap.computed == 0) { |
949 | 310 | linecap = PS_ENDCAP_FLAT; | 309 | linecap = PS_ENDCAP_FLAT; |
950 | @@ -341,7 +340,7 @@ | |||
951 | 341 | n_dash = style->stroke_dash.n_dash; | 340 | n_dash = style->stroke_dash.n_dash; |
952 | 342 | dash = new DWORD[n_dash]; | 341 | dash = new DWORD[n_dash]; |
953 | 343 | for (i = 0; i < style->stroke_dash.n_dash; i++) { | 342 | for (i = 0; i < style->stroke_dash.n_dash; i++) { |
955 | 344 | dash[i] = (DWORD) (style->stroke_dash.dash[i] * IN_PER_PX * dwDPI); | 343 | dash[i] = (DWORD) (style->stroke_dash.dash[i] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI); |
956 | 345 | } | 344 | } |
957 | 346 | } | 345 | } |
958 | 347 | } | 346 | } |
959 | @@ -544,8 +543,8 @@ | |||
960 | 544 | 543 | ||
961 | 545 | Geom::Point p0 = pit->initialPoint(); | 544 | Geom::Point p0 = pit->initialPoint(); |
962 | 546 | 545 | ||
965 | 547 | p0[X] = (p0[X] * IN_PER_PX * dwDPI); | 546 | p0[X] = (p0[X] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI); |
966 | 548 | p0[Y] = (p0[Y] * IN_PER_PX * dwDPI); | 547 | p0[Y] = (p0[Y] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI); |
967 | 549 | 548 | ||
968 | 550 | LONG const x0 = (LONG) round(p0[X]); | 549 | LONG const x0 = (LONG) round(p0[X]); |
969 | 551 | LONG const y0 = (LONG) round(rc.bottom-p0[Y]); | 550 | LONG const y0 = (LONG) round(rc.bottom-p0[Y]); |
970 | @@ -564,10 +563,10 @@ | |||
971 | 564 | //Geom::Point p0 = cit->initialPoint(); | 563 | //Geom::Point p0 = cit->initialPoint(); |
972 | 565 | Geom::Point p1 = cit->finalPoint(); | 564 | Geom::Point p1 = cit->finalPoint(); |
973 | 566 | 565 | ||
978 | 567 | //p0[X] = (p0[X] * IN_PER_PX * dwDPI); | 566 | //p0[X] = (p0[X] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI); |
979 | 568 | p1[X] = (p1[X] * IN_PER_PX * dwDPI); | 567 | p1[X] = (p1[X] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI); |
980 | 569 | //p0[Y] = (p0[Y] * IN_PER_PX * dwDPI); | 568 | //p0[Y] = (p0[Y] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI); |
981 | 570 | p1[Y] = (p1[Y] * IN_PER_PX * dwDPI); | 569 | p1[Y] = (p1[Y] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI); |
982 | 571 | 570 | ||
983 | 572 | //LONG const x0 = (LONG) round(p0[X]); | 571 | //LONG const x0 = (LONG) round(p0[X]); |
984 | 573 | //LONG const y0 = (LONG) round(rc.bottom-p0[Y]); | 572 | //LONG const y0 = (LONG) round(rc.bottom-p0[Y]); |
985 | @@ -586,14 +585,14 @@ | |||
986 | 586 | Geom::Point p2 = points[2]; | 585 | Geom::Point p2 = points[2]; |
987 | 587 | Geom::Point p3 = points[3]; | 586 | Geom::Point p3 = points[3]; |
988 | 588 | 587 | ||
997 | 589 | //p0[X] = (p0[X] * IN_PER_PX * dwDPI); | 588 | //p0[X] = (p0[X] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI); |
998 | 590 | p1[X] = (p1[X] * IN_PER_PX * dwDPI); | 589 | p1[X] = (p1[X] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI); |
999 | 591 | p2[X] = (p2[X] * IN_PER_PX * dwDPI); | 590 | p2[X] = (p2[X] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI); |
1000 | 592 | p3[X] = (p3[X] * IN_PER_PX * dwDPI); | 591 | p3[X] = (p3[X] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI); |
1001 | 593 | //p0[Y] = (p0[Y] * IN_PER_PX * dwDPI); | 592 | //p0[Y] = (p0[Y] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI); |
1002 | 594 | p1[Y] = (p1[Y] * IN_PER_PX * dwDPI); | 593 | p1[Y] = (p1[Y] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI); |
1003 | 595 | p2[Y] = (p2[Y] * IN_PER_PX * dwDPI); | 594 | p2[Y] = (p2[Y] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI); |
1004 | 596 | p3[Y] = (p3[Y] * IN_PER_PX * dwDPI); | 595 | p3[Y] = (p3[Y] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI); |
1005 | 597 | 596 | ||
1006 | 598 | //LONG const x0 = (LONG) round(p0[X]); | 597 | //LONG const x0 = (LONG) round(p0[X]); |
1007 | 599 | //LONG const y0 = (LONG) round(rc.bottom-p0[Y]); | 598 | //LONG const y0 = (LONG) round(rc.bottom-p0[Y]); |
1008 | @@ -716,8 +715,8 @@ | |||
1009 | 716 | 715 | ||
1010 | 717 | Geom::Point p0 = pit->initialPoint(); | 716 | Geom::Point p0 = pit->initialPoint(); |
1011 | 718 | 717 | ||
1014 | 719 | p0[X] = (p0[X] * IN_PER_PX * dwDPI); | 718 | p0[X] = (p0[X] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI); |
1015 | 720 | p0[Y] = (p0[Y] * IN_PER_PX * dwDPI); | 719 | p0[Y] = (p0[Y] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI); |
1016 | 721 | 720 | ||
1017 | 722 | LONG const x0 = (LONG) round(p0[X]); | 721 | LONG const x0 = (LONG) round(p0[X]); |
1018 | 723 | LONG const y0 = (LONG) round(rc.bottom-p0[Y]); | 722 | LONG const y0 = (LONG) round(rc.bottom-p0[Y]); |
1019 | @@ -734,10 +733,10 @@ | |||
1020 | 734 | //Geom::Point p0 = cit->initialPoint(); | 733 | //Geom::Point p0 = cit->initialPoint(); |
1021 | 735 | Geom::Point p1 = cit->finalPoint(); | 734 | Geom::Point p1 = cit->finalPoint(); |
1022 | 736 | 735 | ||
1027 | 737 | //p0[X] = (p0[X] * IN_PER_PX * dwDPI); | 736 | //p0[X] = (p0[X] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI); |
1028 | 738 | p1[X] = (p1[X] * IN_PER_PX * dwDPI); | 737 | p1[X] = (p1[X] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI); |
1029 | 739 | //p0[Y] = (p0[Y] * IN_PER_PX * dwDPI); | 738 | //p0[Y] = (p0[Y] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI); |
1030 | 740 | p1[Y] = (p1[Y] * IN_PER_PX * dwDPI); | 739 | p1[Y] = (p1[Y] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI); |
1031 | 741 | 740 | ||
1032 | 742 | //LONG const x0 = (LONG) round(p0[X]); | 741 | //LONG const x0 = (LONG) round(p0[X]); |
1033 | 743 | //LONG const y0 = (LONG) round(rc.bottom-p0[Y]); | 742 | //LONG const y0 = (LONG) round(rc.bottom-p0[Y]); |
1034 | @@ -754,14 +753,14 @@ | |||
1035 | 754 | Geom::Point p2 = points[2]; | 753 | Geom::Point p2 = points[2]; |
1036 | 755 | Geom::Point p3 = points[3]; | 754 | Geom::Point p3 = points[3]; |
1037 | 756 | 755 | ||
1046 | 757 | //p0[X] = (p0[X] * IN_PER_PX * dwDPI); | 756 | //p0[X] = (p0[X] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI); |
1047 | 758 | p1[X] = (p1[X] * IN_PER_PX * dwDPI); | 757 | p1[X] = (p1[X] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI); |
1048 | 759 | p2[X] = (p2[X] * IN_PER_PX * dwDPI); | 758 | p2[X] = (p2[X] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI); |
1049 | 760 | p3[X] = (p3[X] * IN_PER_PX * dwDPI); | 759 | p3[X] = (p3[X] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI); |
1050 | 761 | //p0[Y] = (p0[Y] * IN_PER_PX * dwDPI); | 760 | //p0[Y] = (p0[Y] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI); |
1051 | 762 | p1[Y] = (p1[Y] * IN_PER_PX * dwDPI); | 761 | p1[Y] = (p1[Y] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI); |
1052 | 763 | p2[Y] = (p2[Y] * IN_PER_PX * dwDPI); | 762 | p2[Y] = (p2[Y] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI); |
1053 | 764 | p3[Y] = (p3[Y] * IN_PER_PX * dwDPI); | 763 | p3[Y] = (p3[Y] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI); |
1054 | 765 | 764 | ||
1055 | 766 | //LONG const x0 = (LONG) round(p0[X]); | 765 | //LONG const x0 = (LONG) round(p0[X]); |
1056 | 767 | //LONG const y0 = (LONG) round(rc.bottom-p0[Y]); | 766 | //LONG const y0 = (LONG) round(rc.bottom-p0[Y]); |
1057 | @@ -829,7 +828,7 @@ | |||
1058 | 829 | LOGFONTW *lf = (LOGFONTW*)g_malloc(sizeof(LOGFONTW)); | 828 | LOGFONTW *lf = (LOGFONTW*)g_malloc(sizeof(LOGFONTW)); |
1059 | 830 | g_assert(lf != NULL); | 829 | g_assert(lf != NULL); |
1060 | 831 | 830 | ||
1062 | 832 | lf->lfHeight = -style->font_size.computed * IN_PER_PX * dwDPI; | 831 | lf->lfHeight = -style->font_size.computed * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI; |
1063 | 833 | lf->lfWidth = 0; | 832 | lf->lfWidth = 0; |
1064 | 834 | lf->lfEscapement = rot; | 833 | lf->lfEscapement = rot; |
1065 | 835 | lf->lfOrientation = rot; | 834 | lf->lfOrientation = rot; |
1066 | @@ -878,8 +877,8 @@ | |||
1067 | 878 | SetBkMode(hdc, TRANSPARENT); | 877 | SetBkMode(hdc, TRANSPARENT); |
1068 | 879 | 878 | ||
1069 | 880 | Geom::Point p2 = p * tf; | 879 | Geom::Point p2 = p * tf; |
1072 | 881 | p2[Geom::X] = (p2[Geom::X] * IN_PER_PX * dwDPI); | 880 | p2[Geom::X] = (p2[Geom::X] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI); |
1073 | 882 | p2[Geom::Y] = (p2[Geom::Y] * IN_PER_PX * dwDPI); | 881 | p2[Geom::Y] = (p2[Geom::Y] * Inkscape::Util::Quantity::convert(1, "px", "in") * dwDPI); |
1074 | 883 | 882 | ||
1075 | 884 | LONG const xpos = (LONG) round(p2[Geom::X]); | 883 | LONG const xpos = (LONG) round(p2[Geom::X]); |
1076 | 885 | LONG const ypos = (LONG) round(rc.bottom - p2[Geom::Y]); | 884 | LONG const ypos = (LONG) round(rc.bottom - p2[Geom::Y]); |
1077 | 886 | 885 | ||
1078 | === modified file 'src/extension/internal/gdkpixbuf-input.cpp' | |||
1079 | --- src/extension/internal/gdkpixbuf-input.cpp 2012-09-20 06:15:42 +0000 | |||
1080 | +++ src/extension/internal/gdkpixbuf-input.cpp 2013-08-06 18:46:25 +0000 | |||
1081 | @@ -12,7 +12,7 @@ | |||
1082 | 12 | #include "selection-chemistry.h" | 12 | #include "selection-chemistry.h" |
1083 | 13 | #include "sp-image.h" | 13 | #include "sp-image.h" |
1084 | 14 | #include "document-undo.h" | 14 | #include "document-undo.h" |
1086 | 15 | #include "unit-constants.h" | 15 | #include "util/units.h" |
1087 | 16 | #include "image-resolution.h" | 16 | #include "image-resolution.h" |
1088 | 17 | #include <set> | 17 | #include <set> |
1089 | 18 | 18 | ||
1090 | @@ -79,7 +79,7 @@ | |||
1091 | 79 | 79 | ||
1092 | 80 | double width = gdk_pixbuf_get_width(pb); | 80 | double width = gdk_pixbuf_get_width(pb); |
1093 | 81 | double height = gdk_pixbuf_get_height(pb); | 81 | double height = gdk_pixbuf_get_height(pb); |
1095 | 82 | double defaultxdpi = prefs->getDouble("/dialogs/import/defaultxdpi/value", PX_PER_IN); | 82 | double defaultxdpi = prefs->getDouble("/dialogs/import/defaultxdpi/value", Inkscape::Util::Quantity::convert(1, "in", "px")); |
1096 | 83 | bool forcexdpi = prefs->getBool("/dialogs/import/forcexdpi"); | 83 | bool forcexdpi = prefs->getBool("/dialogs/import/forcexdpi"); |
1097 | 84 | ImageResolution *ir = 0; | 84 | ImageResolution *ir = 0; |
1098 | 85 | double xscale = 1; | 85 | double xscale = 1; |
1099 | 86 | 86 | ||
1100 | === modified file 'src/extension/internal/latex-pstricks.cpp' | |||
1101 | --- src/extension/internal/latex-pstricks.cpp 2012-04-18 07:02:24 +0000 | |||
1102 | +++ src/extension/internal/latex-pstricks.cpp 2013-08-06 18:46:25 +0000 | |||
1103 | @@ -21,7 +21,7 @@ | |||
1104 | 21 | #include <2geom/hvlinesegment.h> | 21 | #include <2geom/hvlinesegment.h> |
1105 | 22 | #include <errno.h> | 22 | #include <errno.h> |
1106 | 23 | #include <signal.h> | 23 | #include <signal.h> |
1108 | 24 | #include <unit-constants.h> | 24 | #include "util/units.h" |
1109 | 25 | #include "helper/geom-curves.h" | 25 | #include "helper/geom-curves.h" |
1110 | 26 | 26 | ||
1111 | 27 | #include "extension/print.h" | 27 | #include "extension/print.h" |
1112 | @@ -117,8 +117,8 @@ | |||
1113 | 117 | } | 117 | } |
1114 | 118 | 118 | ||
1115 | 119 | // width and height in pt | 119 | // width and height in pt |
1118 | 120 | _width = doc->getWidth() * PT_PER_PX; | 120 | _width = doc->getWidth() * Inkscape::Util::Quantity::convert(1, "px", "pt"); |
1119 | 121 | _height = doc->getHeight() * PT_PER_PX; | 121 | _height = doc->getHeight() * Inkscape::Util::Quantity::convert(1, "px", "pt"); |
1120 | 122 | 122 | ||
1121 | 123 | if (res >= 0) { | 123 | if (res >= 0) { |
1122 | 124 | 124 | ||
1123 | 125 | 125 | ||
1124 | === modified file 'src/extension/internal/latex-text-renderer.cpp' | |||
1125 | --- src/extension/internal/latex-text-renderer.cpp 2012-10-28 14:10:22 +0000 | |||
1126 | +++ src/extension/internal/latex-text-renderer.cpp 2013-08-06 18:46:25 +0000 | |||
1127 | @@ -39,7 +39,7 @@ | |||
1128 | 39 | #include "sp-rect.h" | 39 | #include "sp-rect.h" |
1129 | 40 | #include "text-editing.h" | 40 | #include "text-editing.h" |
1130 | 41 | 41 | ||
1132 | 42 | #include <unit-constants.h> | 42 | #include "util/units.h" |
1133 | 43 | 43 | ||
1134 | 44 | #include "extension/system.h" | 44 | #include "extension/system.h" |
1135 | 45 | 45 | ||
1136 | @@ -611,7 +611,7 @@ | |||
1137 | 611 | // scaling of the image when including it in LaTeX | 611 | // scaling of the image when including it in LaTeX |
1138 | 612 | 612 | ||
1139 | 613 | os << " \\ifx\\svgwidth\\undefined%\n"; | 613 | os << " \\ifx\\svgwidth\\undefined%\n"; |
1141 | 614 | os << " \\setlength{\\unitlength}{" << d.width() * PT_PER_PX << "bp}%\n"; // note: 'bp' is the Postscript pt unit in LaTeX, see LP bug #792384 | 614 | os << " \\setlength{\\unitlength}{" << d.width() * Inkscape::Util::Quantity::convert(1, "px", "pt") << "bp}%\n"; // note: 'bp' is the Postscript pt unit in LaTeX, see LP bug #792384 |
1142 | 615 | os << " \\ifx\\svgscale\\undefined%\n"; | 615 | os << " \\ifx\\svgscale\\undefined%\n"; |
1143 | 616 | os << " \\relax%\n"; | 616 | os << " \\relax%\n"; |
1144 | 617 | os << " \\else%\n"; | 617 | os << " \\else%\n"; |
1145 | 618 | 618 | ||
1146 | === modified file 'src/extension/internal/pdfinput/pdf-parser.cpp' | |||
1147 | --- src/extension/internal/pdfinput/pdf-parser.cpp 2013-08-05 21:07:35 +0000 | |||
1148 | +++ src/extension/internal/pdfinput/pdf-parser.cpp 2013-08-06 18:46:25 +0000 | |||
1149 | @@ -34,7 +34,7 @@ | |||
1150 | 34 | #include "svg-builder.h" | 34 | #include "svg-builder.h" |
1151 | 35 | #include "Gfx.h" | 35 | #include "Gfx.h" |
1152 | 36 | #include "pdf-parser.h" | 36 | #include "pdf-parser.h" |
1154 | 37 | #include "unit-constants.h" | 37 | #include "util/units.h" |
1155 | 38 | 38 | ||
1156 | 39 | #include "goo/gmem.h" | 39 | #include "goo/gmem.h" |
1157 | 40 | #include "goo/GooTimer.h" | 40 | #include "goo/GooTimer.h" |
1158 | @@ -279,14 +279,14 @@ | |||
1159 | 279 | ignoreUndef = 0; | 279 | ignoreUndef = 0; |
1160 | 280 | operatorHistory = NULL; | 280 | operatorHistory = NULL; |
1161 | 281 | builder = builderA; | 281 | builder = builderA; |
1164 | 282 | builder->setDocumentSize(state->getPageWidth()*PX_PER_PT, | 282 | builder->setDocumentSize(state->getPageWidth()*Inkscape::Util::Quantity::convert(1, "pt", "px"), |
1165 | 283 | state->getPageHeight()*PX_PER_PT); | 283 | state->getPageHeight()*Inkscape::Util::Quantity::convert(1, "pt", "px")); |
1166 | 284 | 284 | ||
1167 | 285 | double *ctm = state->getCTM(); | 285 | double *ctm = state->getCTM(); |
1168 | 286 | double scaledCTM[6]; | 286 | double scaledCTM[6]; |
1169 | 287 | for (int i = 0; i < 6; ++i) { | 287 | for (int i = 0; i < 6; ++i) { |
1170 | 288 | baseMatrix[i] = ctm[i]; | 288 | baseMatrix[i] = ctm[i]; |
1172 | 289 | scaledCTM[i] = PX_PER_PT * ctm[i]; | 289 | scaledCTM[i] = Inkscape::Util::Quantity::convert(1, "pt", "px") * ctm[i]; |
1173 | 290 | } | 290 | } |
1174 | 291 | saveState(); | 291 | saveState(); |
1175 | 292 | builder->setTransform((double*)&scaledCTM); | 292 | builder->setTransform((double*)&scaledCTM); |
1176 | 293 | 293 | ||
1177 | === modified file 'src/extension/internal/pdfinput/svg-builder.cpp' | |||
1178 | --- src/extension/internal/pdfinput/svg-builder.cpp 2013-08-05 21:07:35 +0000 | |||
1179 | +++ src/extension/internal/pdfinput/svg-builder.cpp 2013-08-06 18:46:25 +0000 | |||
1180 | @@ -33,7 +33,7 @@ | |||
1181 | 33 | #include "svg/css-ostringstream.h" | 33 | #include "svg/css-ostringstream.h" |
1182 | 34 | #include "svg/svg-color.h" | 34 | #include "svg/svg-color.h" |
1183 | 35 | #include "color.h" | 35 | #include "color.h" |
1185 | 36 | #include "unit-constants.h" | 36 | #include "util/units.h" |
1186 | 37 | #include "io/stringstream.h" | 37 | #include "io/stringstream.h" |
1187 | 38 | #include "io/base64stream.h" | 38 | #include "io/base64stream.h" |
1188 | 39 | #include "display/nr-filter-utils.h" | 39 | #include "display/nr-filter-utils.h" |
1189 | @@ -793,7 +793,7 @@ | |||
1190 | 793 | Geom::Affine pat_matrix(matrix[0], matrix[1], matrix[2], matrix[3], | 793 | Geom::Affine pat_matrix(matrix[0], matrix[1], matrix[2], matrix[3], |
1191 | 794 | matrix[4], matrix[5]); | 794 | matrix[4], matrix[5]); |
1192 | 795 | if ( !for_shading && _is_top_level ) { | 795 | if ( !for_shading && _is_top_level ) { |
1194 | 796 | Geom::Affine flip(1.0, 0.0, 0.0, -1.0, 0.0, _height * PT_PER_PX); | 796 | Geom::Affine flip(1.0, 0.0, 0.0, -1.0, 0.0, _height * Inkscape::Util::Quantity::convert(1, "px", "pt")); |
1195 | 797 | pat_matrix *= flip; | 797 | pat_matrix *= flip; |
1196 | 798 | } | 798 | } |
1197 | 799 | gchar *transform_text = sp_svg_transform_write(pat_matrix); | 799 | gchar *transform_text = sp_svg_transform_write(pat_matrix); |
1198 | 800 | 800 | ||
1199 | === modified file 'src/flood-context.cpp' | |||
1200 | --- src/flood-context.cpp 2013-07-01 20:04:32 +0000 | |||
1201 | +++ src/flood-context.cpp 2013-08-06 18:46:25 +0000 | |||
1202 | @@ -54,7 +54,6 @@ | |||
1203 | 54 | #include "sp-defs.h" | 54 | #include "sp-defs.h" |
1204 | 55 | #include "sp-item.h" | 55 | #include "sp-item.h" |
1205 | 56 | #include "splivarot.h" | 56 | #include "splivarot.h" |
1206 | 57 | #include "sp-metrics.h" | ||
1207 | 58 | #include "sp-namedview.h" | 57 | #include "sp-namedview.h" |
1208 | 59 | #include "sp-object.h" | 58 | #include "sp-object.h" |
1209 | 60 | #include "sp-path.h" | 59 | #include "sp-path.h" |
1210 | 61 | 60 | ||
1211 | === modified file 'src/flood-context.h' | |||
1212 | --- src/flood-context.h 2013-03-14 23:24:17 +0000 | |||
1213 | +++ src/flood-context.h 2013-08-06 18:46:25 +0000 | |||
1214 | @@ -15,8 +15,6 @@ | |||
1215 | 15 | #include <sigc++/sigc++.h> | 15 | #include <sigc++/sigc++.h> |
1216 | 16 | #include <gtk/gtk.h> | 16 | #include <gtk/gtk.h> |
1217 | 17 | #include "event-context.h" | 17 | #include "event-context.h" |
1218 | 18 | #include "helper/unit-menu.h" | ||
1219 | 19 | #include "helper/units.h" | ||
1220 | 20 | 18 | ||
1221 | 21 | #define SP_TYPE_FLOOD_CONTEXT (sp_flood_context_get_type ()) | 19 | #define SP_TYPE_FLOOD_CONTEXT (sp_flood_context_get_type ()) |
1222 | 22 | #define SP_FLOOD_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_FLOOD_CONTEXT, SPFloodContext)) | 20 | #define SP_FLOOD_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_FLOOD_CONTEXT, SPFloodContext)) |
1223 | 23 | 21 | ||
1224 | === modified file 'src/helper/Makefile_insert' | |||
1225 | --- src/helper/Makefile_insert 2013-07-01 20:04:32 +0000 | |||
1226 | +++ src/helper/Makefile_insert 2013-08-06 18:46:25 +0000 | |||
1227 | @@ -18,12 +18,6 @@ | |||
1228 | 18 | helper/png-write.h \ | 18 | helper/png-write.h \ |
1229 | 19 | helper/sp-marshal.cpp \ | 19 | helper/sp-marshal.cpp \ |
1230 | 20 | helper/sp-marshal.h \ | 20 | helper/sp-marshal.h \ |
1231 | 21 | helper/unit-menu.cpp \ | ||
1232 | 22 | helper/unit-menu.h \ | ||
1233 | 23 | helper/unit-tracker.cpp \ | ||
1234 | 24 | helper/unit-tracker.h \ | ||
1235 | 25 | helper/units.cpp \ | ||
1236 | 26 | helper/units.h \ | ||
1237 | 27 | helper/window.cpp \ | 21 | helper/window.cpp \ |
1238 | 28 | helper/window.h \ | 22 | helper/window.h \ |
1239 | 29 | helper/stock-items.cpp \ | 23 | helper/stock-items.cpp \ |
1240 | @@ -46,9 +40,3 @@ | |||
1241 | 46 | else mv helper/tmp.sp-marshal.cpp helper/sp-marshal.cpp; fi | 40 | else mv helper/tmp.sp-marshal.cpp helper/sp-marshal.cpp; fi |
1242 | 47 | 41 | ||
1243 | 48 | helper/sp-marshal.cpp helper/sp-marshal.h: helper/sp-marshal.list | 42 | helper/sp-marshal.cpp helper/sp-marshal.h: helper/sp-marshal.list |
1244 | 49 | |||
1245 | 50 | # ###################### | ||
1246 | 51 | # ### CxxTest stuff #### | ||
1247 | 52 | # ###################### | ||
1248 | 53 | CXXTEST_TESTSUITES += \ | ||
1249 | 54 | $(srcdir)/helper/units-test.h | ||
1250 | 55 | 43 | ||
1251 | === modified file 'src/helper/pixbuf-ops.cpp' | |||
1252 | --- src/helper/pixbuf-ops.cpp 2013-03-25 17:42:31 +0000 | |||
1253 | +++ src/helper/pixbuf-ops.cpp 2013-08-06 18:46:25 +0000 | |||
1254 | @@ -29,7 +29,7 @@ | |||
1255 | 29 | #include "sp-root.h" | 29 | #include "sp-root.h" |
1256 | 30 | #include "sp-use.h" | 30 | #include "sp-use.h" |
1257 | 31 | #include "sp-defs.h" | 31 | #include "sp-defs.h" |
1259 | 32 | #include "unit-constants.h" | 32 | #include "util/units.h" |
1260 | 33 | 33 | ||
1261 | 34 | #include "helper/pixbuf-ops.h" | 34 | #include "helper/pixbuf-ops.h" |
1262 | 35 | 35 | ||
1263 | @@ -121,7 +121,7 @@ | |||
1264 | 121 | origin[Geom::X] = origin[Geom::X] + (screen[Geom::X].extent() * ((1 - padding) / 2)); | 121 | origin[Geom::X] = origin[Geom::X] + (screen[Geom::X].extent() * ((1 - padding) / 2)); |
1265 | 122 | origin[Geom::Y] = origin[Geom::Y] + (screen[Geom::Y].extent() * ((1 - padding) / 2)); | 122 | origin[Geom::Y] = origin[Geom::Y] + (screen[Geom::Y].extent() * ((1 - padding) / 2)); |
1266 | 123 | 123 | ||
1268 | 124 | Geom::Scale scale( (xdpi / PX_PER_IN), (ydpi / PX_PER_IN)); | 124 | Geom::Scale scale( (xdpi / Inkscape::Util::Quantity::convert(1, "in", "px")), (ydpi / Inkscape::Util::Quantity::convert(1, "in", "px"))); |
1269 | 125 | Geom::Affine affine = scale * Geom::Translate(-origin * scale); | 125 | Geom::Affine affine = scale * Geom::Translate(-origin * scale); |
1270 | 126 | 126 | ||
1271 | 127 | /* Create ArenaItems and set transform */ | 127 | /* Create ArenaItems and set transform */ |
1272 | 128 | 128 | ||
1273 | === removed file 'src/helper/unit-menu.cpp' | |||
1274 | --- src/helper/unit-menu.cpp 2013-01-26 19:33:04 +0000 | |||
1275 | +++ src/helper/unit-menu.cpp 1970-01-01 00:00:00 +0000 | |||
1276 | @@ -1,360 +0,0 @@ | |||
1277 | 1 | #define __SP_UNIT_MENU_C__ | ||
1278 | 2 | |||
1279 | 3 | /* | ||
1280 | 4 | * Unit selector with autupdate capability | ||
1281 | 5 | * | ||
1282 | 6 | * Authors: | ||
1283 | 7 | * Lauris Kaplinski <lauris@kaplinski.com> | ||
1284 | 8 | * bulia byak <buliabyak@users.sf.net> | ||
1285 | 9 | * | ||
1286 | 10 | * Copyright (C) 2000-2002 Authors | ||
1287 | 11 | * | ||
1288 | 12 | * Released under GNU GPL, read the file 'COPYING' for more information | ||
1289 | 13 | */ | ||
1290 | 14 | |||
1291 | 15 | #define noUNIT_SELECTOR_VERBOSE | ||
1292 | 16 | |||
1293 | 17 | #ifdef HAVE_CONFIG_H | ||
1294 | 18 | # include "config.h" | ||
1295 | 19 | #endif | ||
1296 | 20 | #include <gtk/gtk.h> | ||
1297 | 21 | #include "helper/sp-marshal.h" | ||
1298 | 22 | #include "helper/units.h" | ||
1299 | 23 | #include "helper/unit-menu.h" | ||
1300 | 24 | #include "widgets/spw-utilities.h" | ||
1301 | 25 | |||
1302 | 26 | struct SPUnitSelector { | ||
1303 | 27 | GtkHBox box; | ||
1304 | 28 | |||
1305 | 29 | GtkWidget *combo_box; | ||
1306 | 30 | GtkListStore *store; | ||
1307 | 31 | |||
1308 | 32 | |||
1309 | 33 | guint bases; | ||
1310 | 34 | GSList *units; | ||
1311 | 35 | SPUnit const *unit; | ||
1312 | 36 | gdouble ctmscale; | ||
1313 | 37 | guint plural : 1; | ||
1314 | 38 | guint abbr : 1; | ||
1315 | 39 | |||
1316 | 40 | guint update : 1; | ||
1317 | 41 | |||
1318 | 42 | GSList *adjustments; | ||
1319 | 43 | }; | ||
1320 | 44 | |||
1321 | 45 | enum {COMBO_COL_LABEL=0, COMBO_COL_UNIT}; | ||
1322 | 46 | |||
1323 | 47 | struct SPUnitSelectorClass { | ||
1324 | 48 | GtkHBoxClass parent_class; | ||
1325 | 49 | |||
1326 | 50 | gboolean (* set_unit)(SPUnitSelector *us, SPUnit const *old, SPUnit const *new_unit); | ||
1327 | 51 | }; | ||
1328 | 52 | |||
1329 | 53 | enum {SET_UNIT, LAST_SIGNAL}; | ||
1330 | 54 | |||
1331 | 55 | static void sp_unit_selector_finalize(GObject *object); | ||
1332 | 56 | |||
1333 | 57 | static guint signals[LAST_SIGNAL] = {0}; | ||
1334 | 58 | |||
1335 | 59 | G_DEFINE_TYPE(SPUnitSelector, sp_unit_selector, GTK_TYPE_HBOX); | ||
1336 | 60 | |||
1337 | 61 | static void | ||
1338 | 62 | sp_unit_selector_class_init(SPUnitSelectorClass *klass) | ||
1339 | 63 | { | ||
1340 | 64 | GObjectClass *object_class = G_OBJECT_CLASS(klass); | ||
1341 | 65 | |||
1342 | 66 | signals[SET_UNIT] = g_signal_new("set_unit", | ||
1343 | 67 | G_TYPE_FROM_CLASS(klass), | ||
1344 | 68 | G_SIGNAL_RUN_LAST, | ||
1345 | 69 | G_STRUCT_OFFSET(SPUnitSelectorClass, set_unit), | ||
1346 | 70 | NULL, NULL, | ||
1347 | 71 | sp_marshal_BOOLEAN__POINTER_POINTER, | ||
1348 | 72 | G_TYPE_BOOLEAN, 2, | ||
1349 | 73 | G_TYPE_POINTER, G_TYPE_POINTER); | ||
1350 | 74 | |||
1351 | 75 | object_class->finalize = sp_unit_selector_finalize; | ||
1352 | 76 | } | ||
1353 | 77 | |||
1354 | 78 | static void | ||
1355 | 79 | sp_unit_selector_init(SPUnitSelector *us) | ||
1356 | 80 | { | ||
1357 | 81 | us->ctmscale = 1.0; | ||
1358 | 82 | us->abbr = FALSE; | ||
1359 | 83 | us->plural = TRUE; | ||
1360 | 84 | |||
1361 | 85 | /** | ||
1362 | 86 | * Create a combo_box and store with 2 columns, | ||
1363 | 87 | * a label and a pointer to a SPUnit | ||
1364 | 88 | */ | ||
1365 | 89 | us->store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_POINTER); | ||
1366 | 90 | us->combo_box = gtk_combo_box_new_with_model (GTK_TREE_MODEL (us->store)); | ||
1367 | 91 | |||
1368 | 92 | GtkCellRenderer *renderer = gtk_cell_renderer_text_new (); | ||
1369 | 93 | g_object_set (renderer, "scale", 0.8, "scale-set", TRUE, NULL); | ||
1370 | 94 | gtk_cell_renderer_set_padding (renderer, 2, 0); | ||
1371 | 95 | gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (us->combo_box), renderer, TRUE); | ||
1372 | 96 | gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (us->combo_box), renderer, "text", COMBO_COL_LABEL, NULL); | ||
1373 | 97 | |||
1374 | 98 | gtk_widget_show (us->combo_box); | ||
1375 | 99 | gtk_box_pack_start (GTK_BOX(us), us->combo_box, TRUE, TRUE, 0); | ||
1376 | 100 | } | ||
1377 | 101 | |||
1378 | 102 | static void | ||
1379 | 103 | sp_unit_selector_finalize(GObject *object) | ||
1380 | 104 | { | ||
1381 | 105 | SPUnitSelector *selector = SP_UNIT_SELECTOR(object); | ||
1382 | 106 | |||
1383 | 107 | if (selector->combo_box) { | ||
1384 | 108 | selector->combo_box = NULL; | ||
1385 | 109 | } | ||
1386 | 110 | |||
1387 | 111 | while (selector->adjustments) { | ||
1388 | 112 | g_object_unref(selector->adjustments->data); | ||
1389 | 113 | selector->adjustments = g_slist_remove(selector->adjustments, selector->adjustments->data); | ||
1390 | 114 | } | ||
1391 | 115 | |||
1392 | 116 | if (selector->units) { | ||
1393 | 117 | sp_unit_free_list(selector->units); | ||
1394 | 118 | } | ||
1395 | 119 | |||
1396 | 120 | selector->unit = NULL; | ||
1397 | 121 | |||
1398 | 122 | G_OBJECT_CLASS(sp_unit_selector_parent_class)->finalize(object); | ||
1399 | 123 | } | ||
1400 | 124 | |||
1401 | 125 | GtkWidget * | ||
1402 | 126 | sp_unit_selector_new(guint bases) | ||
1403 | 127 | { | ||
1404 | 128 | SPUnitSelector *us = SP_UNIT_SELECTOR(g_object_new(SP_TYPE_UNIT_SELECTOR, NULL)); | ||
1405 | 129 | |||
1406 | 130 | sp_unit_selector_set_bases(us, bases); | ||
1407 | 131 | |||
1408 | 132 | return GTK_WIDGET(us); | ||
1409 | 133 | } | ||
1410 | 134 | |||
1411 | 135 | void | ||
1412 | 136 | sp_unit_selector_setsize(GtkWidget *us, guint w, guint h) | ||
1413 | 137 | { | ||
1414 | 138 | gtk_widget_set_size_request((SP_UNIT_SELECTOR(us))->combo_box, w, h); | ||
1415 | 139 | } | ||
1416 | 140 | |||
1417 | 141 | SPUnit const * | ||
1418 | 142 | sp_unit_selector_get_unit(SPUnitSelector const *us) | ||
1419 | 143 | { | ||
1420 | 144 | g_return_val_if_fail(us != NULL, NULL); | ||
1421 | 145 | g_return_val_if_fail(SP_IS_UNIT_SELECTOR(us), NULL); | ||
1422 | 146 | |||
1423 | 147 | return us->unit; | ||
1424 | 148 | } | ||
1425 | 149 | |||
1426 | 150 | |||
1427 | 151 | static void | ||
1428 | 152 | on_combo_box_changed (GtkComboBox *widget, SPUnitSelector *us) | ||
1429 | 153 | { | ||
1430 | 154 | GtkTreeIter iter; | ||
1431 | 155 | if (!gtk_combo_box_get_active_iter (widget, &iter)) { | ||
1432 | 156 | return; | ||
1433 | 157 | } | ||
1434 | 158 | |||
1435 | 159 | SPUnit const *unit = NULL; | ||
1436 | 160 | gtk_tree_model_get (GTK_TREE_MODEL(us->store), &iter, COMBO_COL_UNIT, &unit, -1); | ||
1437 | 161 | |||
1438 | 162 | g_return_if_fail(unit != NULL); | ||
1439 | 163 | |||
1440 | 164 | #ifdef UNIT_SELECTOR_VERBOSE | ||
1441 | 165 | g_print("Old unit %s new unit %s\n", us->unit->name, unit->name); | ||
1442 | 166 | #endif | ||
1443 | 167 | |||
1444 | 168 | SPUnit const *old = us->unit; | ||
1445 | 169 | us->unit = unit; | ||
1446 | 170 | |||
1447 | 171 | us->update = TRUE; | ||
1448 | 172 | |||
1449 | 173 | gboolean consumed = FALSE; | ||
1450 | 174 | g_signal_emit(G_OBJECT(us), signals[SET_UNIT], 0, old, unit, &consumed); | ||
1451 | 175 | |||
1452 | 176 | if ( !consumed | ||
1453 | 177 | && ( unit->base == old->base | ||
1454 | 178 | || ( unit->base == SP_UNIT_ABSOLUTE && old->base == SP_UNIT_DEVICE ) | ||
1455 | 179 | || ( old->base == SP_UNIT_ABSOLUTE && unit->base == SP_UNIT_DEVICE ) ) ) { | ||
1456 | 180 | // Either the same base, or absolute<->device: | ||
1457 | 181 | /* Recalculate adjustments. */ | ||
1458 | 182 | for (GSList *l = us->adjustments; l != NULL; l = g_slist_next(l)) { | ||
1459 | 183 | GtkAdjustment *adj = GTK_ADJUSTMENT(l->data); | ||
1460 | 184 | gdouble val = gtk_adjustment_get_value (adj); | ||
1461 | 185 | #ifdef UNIT_SELECTOR_VERBOSE | ||
1462 | 186 | g_print("Old val %g ... ", val); | ||
1463 | 187 | #endif | ||
1464 | 188 | val = sp_convert_distance_full(val, *old, *unit); | ||
1465 | 189 | #ifdef UNIT_SELECTOR_VERBOSE | ||
1466 | 190 | g_print("new val %g\n", val); | ||
1467 | 191 | #endif | ||
1468 | 192 | gtk_adjustment_set_value (adj, val); | ||
1469 | 193 | } | ||
1470 | 194 | /* need to separate the value changing from the notification | ||
1471 | 195 | * or else the unit changes can break the calculations */ | ||
1472 | 196 | for (GSList *l = us->adjustments; l != NULL; l = g_slist_next(l)) { | ||
1473 | 197 | gtk_adjustment_value_changed(GTK_ADJUSTMENT(l->data)); | ||
1474 | 198 | } | ||
1475 | 199 | } else if (!consumed && unit->base != old->base) { | ||
1476 | 200 | /* when the base changes, signal all the adjustments to get them | ||
1477 | 201 | * to recalculate */ | ||
1478 | 202 | for (GSList *l = us->adjustments; l != NULL; l = g_slist_next(l)) { | ||
1479 | 203 | g_signal_emit_by_name(G_OBJECT(l->data), "value_changed"); | ||
1480 | 204 | } | ||
1481 | 205 | } | ||
1482 | 206 | |||
1483 | 207 | us->update = FALSE; | ||
1484 | 208 | |||
1485 | 209 | } | ||
1486 | 210 | |||
1487 | 211 | static void | ||
1488 | 212 | spus_rebuild_menu(SPUnitSelector *us) | ||
1489 | 213 | { | ||
1490 | 214 | |||
1491 | 215 | gtk_list_store_clear(us->store); | ||
1492 | 216 | |||
1493 | 217 | GtkTreeIter iter; | ||
1494 | 218 | |||
1495 | 219 | gint pos = 0; | ||
1496 | 220 | gint p = 0; | ||
1497 | 221 | for (GSList *l = us->units; l != NULL; l = l->next) { | ||
1498 | 222 | SPUnit const *u = static_cast<SPUnit const*>(l->data); | ||
1499 | 223 | |||
1500 | 224 | // use only abbreviations in the menu | ||
1501 | 225 | // i = gtk_menu_item_new_with_label((us->abbr) ? (us->plural) ? u->abbr_plural : u->abbr : (us->plural) ? u->plural : u->name); | ||
1502 | 226 | gtk_list_store_append (us->store, &iter); | ||
1503 | 227 | gtk_list_store_set (us->store, &iter, COMBO_COL_LABEL, u->abbr, COMBO_COL_UNIT, (gpointer) u, -1); | ||
1504 | 228 | |||
1505 | 229 | if (u == us->unit) { | ||
1506 | 230 | pos = p; | ||
1507 | 231 | } | ||
1508 | 232 | |||
1509 | 233 | p += 1; | ||
1510 | 234 | } | ||
1511 | 235 | |||
1512 | 236 | gtk_combo_box_set_active(GTK_COMBO_BOX(us->combo_box), pos); | ||
1513 | 237 | g_signal_connect (G_OBJECT (us->combo_box), "changed", G_CALLBACK (on_combo_box_changed), us); | ||
1514 | 238 | } | ||
1515 | 239 | |||
1516 | 240 | void | ||
1517 | 241 | sp_unit_selector_set_bases(SPUnitSelector *us, guint bases) | ||
1518 | 242 | { | ||
1519 | 243 | g_return_if_fail(us != NULL); | ||
1520 | 244 | g_return_if_fail(SP_IS_UNIT_SELECTOR(us)); | ||
1521 | 245 | |||
1522 | 246 | if (bases == us->bases) return; | ||
1523 | 247 | |||
1524 | 248 | GSList *units = sp_unit_get_list(bases); | ||
1525 | 249 | g_return_if_fail(units != NULL); | ||
1526 | 250 | sp_unit_free_list(us->units); | ||
1527 | 251 | us->units = units; | ||
1528 | 252 | us->unit = static_cast<SPUnit *>(units->data); | ||
1529 | 253 | |||
1530 | 254 | spus_rebuild_menu(us); | ||
1531 | 255 | } | ||
1532 | 256 | |||
1533 | 257 | void | ||
1534 | 258 | sp_unit_selector_add_unit(SPUnitSelector *us, SPUnit const *unit, int position) | ||
1535 | 259 | { | ||
1536 | 260 | if (!g_slist_find(us->units, (gpointer) unit)) { | ||
1537 | 261 | us->units = g_slist_insert(us->units, (gpointer) unit, position); | ||
1538 | 262 | |||
1539 | 263 | spus_rebuild_menu(us); | ||
1540 | 264 | } | ||
1541 | 265 | } | ||
1542 | 266 | |||
1543 | 267 | void | ||
1544 | 268 | sp_unit_selector_set_unit(SPUnitSelector *us, SPUnit const *unit) | ||
1545 | 269 | { | ||
1546 | 270 | g_return_if_fail(us != NULL); | ||
1547 | 271 | g_return_if_fail(SP_IS_UNIT_SELECTOR(us)); | ||
1548 | 272 | |||
1549 | 273 | if (unit == NULL) { | ||
1550 | 274 | return; // silently return, by default a newly created selector uses pt | ||
1551 | 275 | } | ||
1552 | 276 | if (unit == us->unit) { | ||
1553 | 277 | return; | ||
1554 | 278 | } | ||
1555 | 279 | |||
1556 | 280 | gint const pos = g_slist_index(us->units, (gpointer) unit); | ||
1557 | 281 | g_return_if_fail(pos >= 0); | ||
1558 | 282 | |||
1559 | 283 | gtk_combo_box_set_active(GTK_COMBO_BOX(us->combo_box), pos); | ||
1560 | 284 | |||
1561 | 285 | SPUnit const *old = us->unit; | ||
1562 | 286 | us->unit = unit; | ||
1563 | 287 | |||
1564 | 288 | /* Recalculate adjustments */ | ||
1565 | 289 | for (GSList *l = us->adjustments; l != NULL; l = l->next) { | ||
1566 | 290 | GtkAdjustment *adj = GTK_ADJUSTMENT(l->data); | ||
1567 | 291 | gdouble const val = sp_convert_distance_full(gtk_adjustment_get_value (adj), *old, *unit); | ||
1568 | 292 | gtk_adjustment_set_value(adj, val); | ||
1569 | 293 | } | ||
1570 | 294 | } | ||
1571 | 295 | |||
1572 | 296 | void | ||
1573 | 297 | sp_unit_selector_add_adjustment(SPUnitSelector *us, GtkAdjustment *adj) | ||
1574 | 298 | { | ||
1575 | 299 | g_return_if_fail(us != NULL); | ||
1576 | 300 | g_return_if_fail(SP_IS_UNIT_SELECTOR(us)); | ||
1577 | 301 | g_return_if_fail(adj != NULL); | ||
1578 | 302 | g_return_if_fail(GTK_IS_ADJUSTMENT(adj)); | ||
1579 | 303 | |||
1580 | 304 | g_return_if_fail(!g_slist_find(us->adjustments, adj)); | ||
1581 | 305 | |||
1582 | 306 | g_object_ref(adj); | ||
1583 | 307 | us->adjustments = g_slist_prepend(us->adjustments, adj); | ||
1584 | 308 | } | ||
1585 | 309 | |||
1586 | 310 | void | ||
1587 | 311 | sp_unit_selector_remove_adjustment(SPUnitSelector *us, GtkAdjustment *adj) | ||
1588 | 312 | { | ||
1589 | 313 | g_return_if_fail(us != NULL); | ||
1590 | 314 | g_return_if_fail(SP_IS_UNIT_SELECTOR(us)); | ||
1591 | 315 | g_return_if_fail(adj != NULL); | ||
1592 | 316 | g_return_if_fail(GTK_IS_ADJUSTMENT(adj)); | ||
1593 | 317 | |||
1594 | 318 | g_return_if_fail(g_slist_find(us->adjustments, adj)); | ||
1595 | 319 | |||
1596 | 320 | us->adjustments = g_slist_remove(us->adjustments, adj); | ||
1597 | 321 | g_object_unref(adj); | ||
1598 | 322 | } | ||
1599 | 323 | |||
1600 | 324 | gboolean | ||
1601 | 325 | sp_unit_selector_update_test(SPUnitSelector const *selector) | ||
1602 | 326 | { | ||
1603 | 327 | g_return_val_if_fail(selector != NULL, FALSE); | ||
1604 | 328 | g_return_val_if_fail(SP_IS_UNIT_SELECTOR(selector), FALSE); | ||
1605 | 329 | |||
1606 | 330 | return selector->update; | ||
1607 | 331 | } | ||
1608 | 332 | |||
1609 | 333 | double | ||
1610 | 334 | sp_unit_selector_get_value_in_pixels(SPUnitSelector const *selector, GtkAdjustment *adj) | ||
1611 | 335 | { | ||
1612 | 336 | g_return_val_if_fail(selector != NULL, gtk_adjustment_get_value (adj)); | ||
1613 | 337 | g_return_val_if_fail(SP_IS_UNIT_SELECTOR(selector), gtk_adjustment_get_value (adj)); | ||
1614 | 338 | |||
1615 | 339 | return sp_units_get_pixels(gtk_adjustment_get_value (adj), *(selector->unit)); | ||
1616 | 340 | } | ||
1617 | 341 | |||
1618 | 342 | void | ||
1619 | 343 | sp_unit_selector_set_value_in_pixels(SPUnitSelector *selector, GtkAdjustment *adj, double value) | ||
1620 | 344 | { | ||
1621 | 345 | g_return_if_fail(selector != NULL); | ||
1622 | 346 | g_return_if_fail(SP_IS_UNIT_SELECTOR(selector)); | ||
1623 | 347 | |||
1624 | 348 | gtk_adjustment_set_value(adj, sp_pixels_get_units(value, *(selector->unit))); | ||
1625 | 349 | } | ||
1626 | 350 | |||
1627 | 351 | /* | ||
1628 | 352 | Local Variables: | ||
1629 | 353 | mode:c++ | ||
1630 | 354 | c-file-style:"stroustrup" | ||
1631 | 355 | c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) | ||
1632 | 356 | indent-tabs-mode:nil | ||
1633 | 357 | fill-column:99 | ||
1634 | 358 | End: | ||
1635 | 359 | */ | ||
1636 | 360 | // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : | ||
1637 | 361 | 0 | ||
1638 | === removed file 'src/helper/unit-menu.h' | |||
1639 | --- src/helper/unit-menu.h 2011-12-08 11:53:54 +0000 | |||
1640 | +++ src/helper/unit-menu.h 1970-01-01 00:00:00 +0000 | |||
1641 | @@ -1,60 +0,0 @@ | |||
1642 | 1 | #ifndef SP_UNIT_MENU_H | ||
1643 | 2 | #define SP_UNIT_MENU_H | ||
1644 | 3 | |||
1645 | 4 | /* | ||
1646 | 5 | * SPUnitMenu | ||
1647 | 6 | * | ||
1648 | 7 | * Generic (and quite unintelligent) grid item for gnome canvas | ||
1649 | 8 | * | ||
1650 | 9 | * Copyright (C) Lauris Kaplinski 2000 | ||
1651 | 10 | * | ||
1652 | 11 | */ | ||
1653 | 12 | |||
1654 | 13 | #include <glib.h> | ||
1655 | 14 | #include <gtk/gtk.h> | ||
1656 | 15 | |||
1657 | 16 | struct SPUnit; | ||
1658 | 17 | struct SPUnitSelector; | ||
1659 | 18 | struct SPUnitSelectorClass; | ||
1660 | 19 | |||
1661 | 20 | /* Unit selector Widget */ | ||
1662 | 21 | |||
1663 | 22 | #define SP_TYPE_UNIT_SELECTOR (sp_unit_selector_get_type()) | ||
1664 | 23 | #define SP_UNIT_SELECTOR(o) (G_TYPE_CHECK_INSTANCE_CAST((o), SP_TYPE_UNIT_SELECTOR, SPUnitSelector)) | ||
1665 | 24 | #define SP_UNIT_SELECTOR_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), SP_TYPE_UNIT_SELECTOR, SPUnitSelectorClass)) | ||
1666 | 25 | #define SP_IS_UNIT_SELECTOR(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), SP_TYPE_UNIT_SELECTOR)) | ||
1667 | 26 | #define SP_IS_UNIT_SELECTOR_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), SP_TYPE_UNIT_SELECTOR)) | ||
1668 | 27 | |||
1669 | 28 | GType sp_unit_selector_get_type(void); | ||
1670 | 29 | |||
1671 | 30 | GtkWidget *sp_unit_selector_new(guint bases); | ||
1672 | 31 | void sp_unit_selector_setsize(GtkWidget *us, guint w, guint h); | ||
1673 | 32 | |||
1674 | 33 | SPUnit const *sp_unit_selector_get_unit(SPUnitSelector const *selector); | ||
1675 | 34 | |||
1676 | 35 | void sp_unit_selector_set_bases(SPUnitSelector *selector, guint bases); | ||
1677 | 36 | void sp_unit_selector_add_unit(SPUnitSelector *selector, SPUnit const *unit, int position); | ||
1678 | 37 | |||
1679 | 38 | void sp_unit_selector_set_unit(SPUnitSelector *selector, SPUnit const *unit); | ||
1680 | 39 | void sp_unit_selector_add_adjustment(SPUnitSelector *selector, GtkAdjustment *adjustment); | ||
1681 | 40 | void sp_unit_selector_remove_adjustment(SPUnitSelector *selector, GtkAdjustment *adjustment); | ||
1682 | 41 | |||
1683 | 42 | gboolean sp_unit_selector_update_test(SPUnitSelector const *selector); | ||
1684 | 43 | |||
1685 | 44 | double sp_unit_selector_get_value_in_pixels(SPUnitSelector const *selector, GtkAdjustment *adj); | ||
1686 | 45 | void sp_unit_selector_set_value_in_pixels(SPUnitSelector *selector, GtkAdjustment *adj, double value); | ||
1687 | 46 | |||
1688 | 47 | |||
1689 | 48 | |||
1690 | 49 | #endif // SP_UNIT_MENU_H | ||
1691 | 50 | |||
1692 | 51 | /* | ||
1693 | 52 | Local Variables: | ||
1694 | 53 | mode:c++ | ||
1695 | 54 | c-file-style:"stroustrup" | ||
1696 | 55 | c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) | ||
1697 | 56 | indent-tabs-mode:nil | ||
1698 | 57 | fill-column:99 | ||
1699 | 58 | End: | ||
1700 | 59 | */ | ||
1701 | 60 | // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : | ||
1702 | 61 | 0 | ||
1703 | === removed file 'src/helper/unit-tracker.cpp' | |||
1704 | --- src/helper/unit-tracker.cpp 2011-06-03 10:44:52 +0000 | |||
1705 | +++ src/helper/unit-tracker.cpp 1970-01-01 00:00:00 +0000 | |||
1706 | @@ -1,267 +0,0 @@ | |||
1707 | 1 | /* | ||
1708 | 2 | * Inkscape::UnitTracker - Simple mediator to synchronize changes to a set | ||
1709 | 3 | * of possible units | ||
1710 | 4 | * | ||
1711 | 5 | * Authors: | ||
1712 | 6 | * Jon A. Cruz <jon@joncruz.org> | ||
1713 | 7 | * | ||
1714 | 8 | * Copyright (C) 2007 Jon A. Cruz | ||
1715 | 9 | * | ||
1716 | 10 | * Released under GNU GPL, read the file 'COPYING' for more information | ||
1717 | 11 | */ | ||
1718 | 12 | |||
1719 | 13 | #include <gtk/gtk.h> | ||
1720 | 14 | |||
1721 | 15 | #include "unit-tracker.h" | ||
1722 | 16 | #include "ege-select-one-action.h" | ||
1723 | 17 | |||
1724 | 18 | namespace Inkscape { | ||
1725 | 19 | |||
1726 | 20 | enum { | ||
1727 | 21 | COLUMN_STRING, | ||
1728 | 22 | COLUMN_SPUNIT, | ||
1729 | 23 | N_COLUMNS | ||
1730 | 24 | }; | ||
1731 | 25 | |||
1732 | 26 | UnitTracker::UnitTracker( guint bases ) : | ||
1733 | 27 | _active(0), | ||
1734 | 28 | _isUpdating(false), | ||
1735 | 29 | _activeUnit(0), | ||
1736 | 30 | _store(0), | ||
1737 | 31 | _unitList(0), | ||
1738 | 32 | _actionList(0), | ||
1739 | 33 | _adjList(0), | ||
1740 | 34 | _priorValues() | ||
1741 | 35 | { | ||
1742 | 36 | _store = gtk_list_store_new( N_COLUMNS, G_TYPE_STRING, G_TYPE_POINTER ); | ||
1743 | 37 | setBase( bases ); | ||
1744 | 38 | } | ||
1745 | 39 | |||
1746 | 40 | UnitTracker::~UnitTracker() | ||
1747 | 41 | { | ||
1748 | 42 | if ( _unitList ) { | ||
1749 | 43 | sp_unit_free_list( _unitList ); | ||
1750 | 44 | } | ||
1751 | 45 | |||
1752 | 46 | // Unhook weak references to GtkActions | ||
1753 | 47 | while ( _actionList ) { | ||
1754 | 48 | g_signal_handlers_disconnect_by_func( G_OBJECT(_actionList->data), (gpointer)_unitChangedCB, this ); | ||
1755 | 49 | g_object_weak_unref( G_OBJECT(_actionList->data), _actionFinalizedCB, this ); | ||
1756 | 50 | _actionList = g_slist_delete_link( _actionList, _actionList ); | ||
1757 | 51 | } | ||
1758 | 52 | |||
1759 | 53 | // Unhook wek references to GtkAdjustments | ||
1760 | 54 | while ( _adjList ) { | ||
1761 | 55 | g_object_weak_unref( G_OBJECT(_adjList->data), _adjustmentFinalizedCB, this ); | ||
1762 | 56 | _adjList = g_slist_delete_link( _adjList, _adjList ); | ||
1763 | 57 | } | ||
1764 | 58 | } | ||
1765 | 59 | |||
1766 | 60 | void UnitTracker::setBase( guint bases ) | ||
1767 | 61 | { | ||
1768 | 62 | GtkTreeIter iter; | ||
1769 | 63 | _unitList = sp_unit_get_list( bases ); | ||
1770 | 64 | for ( GSList* cur = _unitList; cur; cur = g_slist_next(cur) ) { | ||
1771 | 65 | SPUnit* unit = static_cast<SPUnit*>(cur->data); | ||
1772 | 66 | gtk_list_store_append( _store, &iter ); | ||
1773 | 67 | gtk_list_store_set( _store, &iter, COLUMN_STRING, unit->abbr, COLUMN_SPUNIT, unit, -1 ); | ||
1774 | 68 | } | ||
1775 | 69 | gint count = gtk_tree_model_iter_n_children( GTK_TREE_MODEL(_store), 0 ); | ||
1776 | 70 | if ( (count > 0) && (_active > count) ) { | ||
1777 | 71 | _setActive( count - 1 ); | ||
1778 | 72 | } else { | ||
1779 | 73 | _setActive( _active ); | ||
1780 | 74 | } | ||
1781 | 75 | } | ||
1782 | 76 | |||
1783 | 77 | void UnitTracker::addUnit( SPUnitId id, gint index ) | ||
1784 | 78 | { | ||
1785 | 79 | GtkTreeIter iter; | ||
1786 | 80 | const SPUnit* percentUnit = &sp_unit_get_by_id( id ); | ||
1787 | 81 | gtk_list_store_insert( _store, &iter, index ); | ||
1788 | 82 | gtk_list_store_set( _store, &iter, COLUMN_STRING, percentUnit->abbr, COLUMN_SPUNIT, percentUnit, -1 ); | ||
1789 | 83 | } | ||
1790 | 84 | |||
1791 | 85 | bool UnitTracker::isUpdating() const | ||
1792 | 86 | { | ||
1793 | 87 | return _isUpdating; | ||
1794 | 88 | } | ||
1795 | 89 | |||
1796 | 90 | SPUnit const* UnitTracker::getActiveUnit() const | ||
1797 | 91 | { | ||
1798 | 92 | return _activeUnit; | ||
1799 | 93 | } | ||
1800 | 94 | |||
1801 | 95 | void UnitTracker::setActiveUnit( SPUnit const *unit ) | ||
1802 | 96 | { | ||
1803 | 97 | if ( unit ) { | ||
1804 | 98 | GtkTreeIter iter; | ||
1805 | 99 | int index = 0; | ||
1806 | 100 | gboolean found = gtk_tree_model_get_iter_first( GTK_TREE_MODEL(_store), &iter ); | ||
1807 | 101 | while ( found ) { | ||
1808 | 102 | SPUnit* storedUnit = 0; | ||
1809 | 103 | gtk_tree_model_get( GTK_TREE_MODEL(_store), &iter, COLUMN_SPUNIT, &storedUnit, -1 ); | ||
1810 | 104 | if ( storedUnit && (storedUnit->unit_id == unit->unit_id) ) { | ||
1811 | 105 | _setActive(index); | ||
1812 | 106 | break; | ||
1813 | 107 | } | ||
1814 | 108 | |||
1815 | 109 | found = gtk_tree_model_iter_next( GTK_TREE_MODEL(_store), &iter ); | ||
1816 | 110 | index++; | ||
1817 | 111 | } | ||
1818 | 112 | } | ||
1819 | 113 | } | ||
1820 | 114 | |||
1821 | 115 | void UnitTracker::addAdjustment( GtkAdjustment* adj ) | ||
1822 | 116 | { | ||
1823 | 117 | if ( !g_slist_find( _adjList, adj ) ) { | ||
1824 | 118 | g_object_weak_ref( G_OBJECT(adj), _adjustmentFinalizedCB, this ); | ||
1825 | 119 | _adjList = g_slist_append( _adjList, adj ); | ||
1826 | 120 | } | ||
1827 | 121 | } | ||
1828 | 122 | |||
1829 | 123 | void UnitTracker::setFullVal( GtkAdjustment* adj, gdouble val ) | ||
1830 | 124 | { | ||
1831 | 125 | _priorValues[adj] = val; | ||
1832 | 126 | } | ||
1833 | 127 | |||
1834 | 128 | GtkAction* UnitTracker::createAction( gchar const* name, gchar const* label, gchar const* tooltip ) | ||
1835 | 129 | { | ||
1836 | 130 | EgeSelectOneAction* act1 = ege_select_one_action_new( name, label, tooltip, NULL, GTK_TREE_MODEL(_store) ); | ||
1837 | 131 | ege_select_one_action_set_label_column( act1, COLUMN_STRING ); | ||
1838 | 132 | if ( _active ) { | ||
1839 | 133 | ege_select_one_action_set_active( act1, _active ); | ||
1840 | 134 | } | ||
1841 | 135 | |||
1842 | 136 | ege_select_one_action_set_appearance( act1, "minimal" ); | ||
1843 | 137 | g_object_weak_ref( G_OBJECT(act1), _actionFinalizedCB, this ); | ||
1844 | 138 | g_signal_connect( G_OBJECT(act1), "changed", G_CALLBACK( _unitChangedCB ), this ); | ||
1845 | 139 | _actionList = g_slist_append( _actionList, act1 ); | ||
1846 | 140 | |||
1847 | 141 | return GTK_ACTION(act1); | ||
1848 | 142 | } | ||
1849 | 143 | |||
1850 | 144 | void UnitTracker::_unitChangedCB( GtkAction* action, gpointer data ) | ||
1851 | 145 | { | ||
1852 | 146 | if ( action && data ) { | ||
1853 | 147 | EgeSelectOneAction* act = EGE_SELECT_ONE_ACTION(action); | ||
1854 | 148 | gint active = ege_select_one_action_get_active( act ); | ||
1855 | 149 | UnitTracker* self = reinterpret_cast<UnitTracker*>(data); | ||
1856 | 150 | self->_setActive(active); | ||
1857 | 151 | } | ||
1858 | 152 | } | ||
1859 | 153 | |||
1860 | 154 | void UnitTracker::_actionFinalizedCB( gpointer data, GObject *where_the_object_was ) | ||
1861 | 155 | { | ||
1862 | 156 | if ( data && where_the_object_was ) { | ||
1863 | 157 | UnitTracker* self = reinterpret_cast<UnitTracker*>(data); | ||
1864 | 158 | self->_actionFinalized( where_the_object_was ); | ||
1865 | 159 | } | ||
1866 | 160 | } | ||
1867 | 161 | |||
1868 | 162 | void UnitTracker::_adjustmentFinalizedCB( gpointer data, GObject *where_the_object_was ) | ||
1869 | 163 | { | ||
1870 | 164 | if ( data && where_the_object_was ) { | ||
1871 | 165 | UnitTracker* self = reinterpret_cast<UnitTracker*>(data); | ||
1872 | 166 | self->_adjustmentFinalized( where_the_object_was ); | ||
1873 | 167 | } | ||
1874 | 168 | } | ||
1875 | 169 | |||
1876 | 170 | void UnitTracker::_actionFinalized( GObject *where_the_object_was ) | ||
1877 | 171 | { | ||
1878 | 172 | GSList* target = g_slist_find( _actionList, where_the_object_was ); | ||
1879 | 173 | if ( target ) { | ||
1880 | 174 | _actionList = g_slist_remove( _actionList, where_the_object_was ); | ||
1881 | 175 | } else { | ||
1882 | 176 | g_warning("Received a finalization callback for unknown object %p", where_the_object_was ); | ||
1883 | 177 | } | ||
1884 | 178 | } | ||
1885 | 179 | |||
1886 | 180 | void UnitTracker::_adjustmentFinalized( GObject *where_the_object_was ) | ||
1887 | 181 | { | ||
1888 | 182 | GSList* target = g_slist_find( _adjList, where_the_object_was ); | ||
1889 | 183 | if ( target ) { | ||
1890 | 184 | _adjList = g_slist_remove( _adjList, where_the_object_was ); | ||
1891 | 185 | } else { | ||
1892 | 186 | g_warning("Received a finalization callback for unknown object %p", where_the_object_was ); | ||
1893 | 187 | } | ||
1894 | 188 | } | ||
1895 | 189 | |||
1896 | 190 | void UnitTracker::_setActive( gint active ) | ||
1897 | 191 | { | ||
1898 | 192 | if ( active != _active || (_activeUnit == 0) ) { | ||
1899 | 193 | gint oldActive = _active; | ||
1900 | 194 | |||
1901 | 195 | GtkTreeIter iter; | ||
1902 | 196 | gboolean found = gtk_tree_model_iter_nth_child( GTK_TREE_MODEL(_store), &iter, NULL, oldActive ); | ||
1903 | 197 | if ( found ) { | ||
1904 | 198 | SPUnit* unit = 0; | ||
1905 | 199 | gtk_tree_model_get( GTK_TREE_MODEL(_store), &iter, COLUMN_SPUNIT, &unit, -1 ); | ||
1906 | 200 | |||
1907 | 201 | found = gtk_tree_model_iter_nth_child( GTK_TREE_MODEL(_store), &iter, NULL, active ); | ||
1908 | 202 | if ( found ) { | ||
1909 | 203 | SPUnit* newUnit = 0; | ||
1910 | 204 | gtk_tree_model_get( GTK_TREE_MODEL(_store), &iter, COLUMN_SPUNIT, &newUnit, -1 ); | ||
1911 | 205 | _activeUnit = newUnit; | ||
1912 | 206 | |||
1913 | 207 | if ( _adjList ) { | ||
1914 | 208 | _fixupAdjustments( unit, newUnit ); | ||
1915 | 209 | } | ||
1916 | 210 | |||
1917 | 211 | } else { | ||
1918 | 212 | g_warning("Did not find new unit"); | ||
1919 | 213 | } | ||
1920 | 214 | } else { | ||
1921 | 215 | g_warning("Did not find old unit"); | ||
1922 | 216 | } | ||
1923 | 217 | |||
1924 | 218 | _active = active; | ||
1925 | 219 | |||
1926 | 220 | for ( GSList* cur = _actionList; cur; cur = g_slist_next(cur) ) { | ||
1927 | 221 | if ( IS_EGE_SELECT_ONE_ACTION( cur->data ) ) { | ||
1928 | 222 | EgeSelectOneAction* act = EGE_SELECT_ONE_ACTION( cur->data ); | ||
1929 | 223 | ege_select_one_action_set_active( act, active ); | ||
1930 | 224 | } | ||
1931 | 225 | } | ||
1932 | 226 | } | ||
1933 | 227 | } | ||
1934 | 228 | |||
1935 | 229 | void UnitTracker::_fixupAdjustments( SPUnit const* oldUnit, SPUnit const *newUnit ) | ||
1936 | 230 | { | ||
1937 | 231 | _isUpdating = true; | ||
1938 | 232 | for ( GSList* cur = _adjList; cur; cur = g_slist_next(cur) ) { | ||
1939 | 233 | GtkAdjustment* adj = GTK_ADJUSTMENT(cur->data); | ||
1940 | 234 | gdouble oldVal = gtk_adjustment_get_value(adj); | ||
1941 | 235 | gdouble val = oldVal; | ||
1942 | 236 | |||
1943 | 237 | if ((oldUnit->base == SP_UNIT_ABSOLUTE || oldUnit->base == SP_UNIT_DEVICE) | ||
1944 | 238 | && (newUnit->base == SP_UNIT_DIMENSIONLESS)) | ||
1945 | 239 | { | ||
1946 | 240 | val = 1.0 / newUnit->unittobase; | ||
1947 | 241 | _priorValues[adj] = sp_units_get_pixels( oldVal, *oldUnit ); | ||
1948 | 242 | } else if ((oldUnit->base == SP_UNIT_DIMENSIONLESS) | ||
1949 | 243 | && (newUnit->base == SP_UNIT_ABSOLUTE || newUnit->base == SP_UNIT_DEVICE)) { | ||
1950 | 244 | if ( _priorValues.find(adj) != _priorValues.end() ) { | ||
1951 | 245 | val = sp_pixels_get_units( _priorValues[adj], *newUnit ); | ||
1952 | 246 | } | ||
1953 | 247 | } else { | ||
1954 | 248 | val = sp_convert_distance_full( oldVal, *oldUnit, *newUnit ); | ||
1955 | 249 | } | ||
1956 | 250 | |||
1957 | 251 | gtk_adjustment_set_value( adj, val ); | ||
1958 | 252 | } | ||
1959 | 253 | _isUpdating = false; | ||
1960 | 254 | } | ||
1961 | 255 | |||
1962 | 256 | } | ||
1963 | 257 | |||
1964 | 258 | /* | ||
1965 | 259 | Local Variables: | ||
1966 | 260 | mode:c++ | ||
1967 | 261 | c-file-style:"stroustrup" | ||
1968 | 262 | c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) | ||
1969 | 263 | indent-tabs-mode:nil | ||
1970 | 264 | fill-column:99 | ||
1971 | 265 | End: | ||
1972 | 266 | */ | ||
1973 | 267 | // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : | ||
1974 | 268 | 0 | ||
1975 | === removed file 'src/helper/unit-tracker.h' | |||
1976 | --- src/helper/unit-tracker.h 2011-06-03 10:44:52 +0000 | |||
1977 | +++ src/helper/unit-tracker.h 1970-01-01 00:00:00 +0000 | |||
1978 | @@ -1,75 +0,0 @@ | |||
1979 | 1 | /* | ||
1980 | 2 | * Inkscape::UnitTracker - Simple mediator to synchronize changes to a set | ||
1981 | 3 | * of possible units | ||
1982 | 4 | * | ||
1983 | 5 | * Authors: | ||
1984 | 6 | * Jon A. Cruz <jon@joncruz.org> | ||
1985 | 7 | * | ||
1986 | 8 | * Copyright (C) 2007 Jon A. Cruz | ||
1987 | 9 | * | ||
1988 | 10 | * Released under GNU GPL, read the file 'COPYING' for more information | ||
1989 | 11 | */ | ||
1990 | 12 | |||
1991 | 13 | #ifndef SEEN_INKSCAPE_UNIT_TRACKER_H | ||
1992 | 14 | #define SEEN_INKSCAPE_UNIT_TRACKER_H | ||
1993 | 15 | |||
1994 | 16 | #include <map> | ||
1995 | 17 | |||
1996 | 18 | #include <gtk/gtk.h> | ||
1997 | 19 | |||
1998 | 20 | #include "helper/units.h" | ||
1999 | 21 | |||
2000 | 22 | namespace Inkscape { | ||
2001 | 23 | |||
2002 | 24 | class UnitTracker | ||
2003 | 25 | { | ||
2004 | 26 | public: | ||
2005 | 27 | UnitTracker( guint bases = (SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE) ); | ||
2006 | 28 | virtual ~UnitTracker(); | ||
2007 | 29 | |||
2008 | 30 | void setBase( guint bases ); // SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE | ||
2009 | 31 | void addUnit( SPUnitId id, gint index ); | ||
2010 | 32 | |||
2011 | 33 | bool isUpdating() const; | ||
2012 | 34 | |||
2013 | 35 | void setActiveUnit( SPUnit const *unit ); | ||
2014 | 36 | SPUnit const* getActiveUnit() const; | ||
2015 | 37 | |||
2016 | 38 | void addAdjustment( GtkAdjustment* adj ); | ||
2017 | 39 | void setFullVal( GtkAdjustment* adj, gdouble val ); | ||
2018 | 40 | |||
2019 | 41 | GtkAction* createAction( gchar const* name, gchar const* label, gchar const* tooltip ); | ||
2020 | 42 | |||
2021 | 43 | private: | ||
2022 | 44 | static void _unitChangedCB( GtkAction* action, gpointer data ); | ||
2023 | 45 | static void _actionFinalizedCB( gpointer data, GObject *where_the_object_was ); | ||
2024 | 46 | static void _adjustmentFinalizedCB( gpointer data, GObject *where_the_object_was ); | ||
2025 | 47 | void _setActive( gint index ); | ||
2026 | 48 | void _fixupAdjustments( SPUnit const* oldUnit, SPUnit const *newUnit ); | ||
2027 | 49 | void _actionFinalized( GObject *where_the_object_was ); | ||
2028 | 50 | void _adjustmentFinalized( GObject *where_the_object_was ); | ||
2029 | 51 | |||
2030 | 52 | gint _active; | ||
2031 | 53 | bool _isUpdating; | ||
2032 | 54 | SPUnit* _activeUnit; | ||
2033 | 55 | GtkListStore* _store; | ||
2034 | 56 | GSList* _unitList; | ||
2035 | 57 | GSList* _actionList; | ||
2036 | 58 | GSList* _adjList; | ||
2037 | 59 | std::map <GtkAdjustment*, gdouble> _priorValues; | ||
2038 | 60 | }; | ||
2039 | 61 | |||
2040 | 62 | } | ||
2041 | 63 | |||
2042 | 64 | #endif // SEEN_INKSCAPE_UNIT_TRACKER_H | ||
2043 | 65 | |||
2044 | 66 | /* | ||
2045 | 67 | Local Variables: | ||
2046 | 68 | mode:c++ | ||
2047 | 69 | c-file-style:"stroustrup" | ||
2048 | 70 | c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) | ||
2049 | 71 | indent-tabs-mode:nil | ||
2050 | 72 | fill-column:99 | ||
2051 | 73 | End: | ||
2052 | 74 | */ | ||
2053 | 75 | // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : | ||
2054 | 76 | 0 | ||
2055 | === removed file 'src/helper/units-test.h' | |||
2056 | --- src/helper/units-test.h 2010-11-17 02:12:56 +0000 | |||
2057 | +++ src/helper/units-test.h 1970-01-01 00:00:00 +0000 | |||
2058 | @@ -1,90 +0,0 @@ | |||
2059 | 1 | #include <cxxtest/TestSuite.h> | ||
2060 | 2 | |||
2061 | 3 | #include <helper/units.h> | ||
2062 | 4 | #include <glibmm/i18n.h> | ||
2063 | 5 | #include <math.h> | ||
2064 | 6 | |||
2065 | 7 | class UnitsTest : public CxxTest::TestSuite { | ||
2066 | 8 | public: | ||
2067 | 9 | |||
2068 | 10 | UnitsTest() | ||
2069 | 11 | { | ||
2070 | 12 | } | ||
2071 | 13 | virtual ~UnitsTest() {} | ||
2072 | 14 | |||
2073 | 15 | // createSuite and destroySuite get us per-suite setup and teardown | ||
2074 | 16 | // without us having to worry about static initialization order, etc. | ||
2075 | 17 | static UnitsTest *createSuite() { return new UnitsTest(); } | ||
2076 | 18 | static void destroySuite( UnitsTest *suite ) { delete suite; } | ||
2077 | 19 | |||
2078 | 20 | void testConversions() | ||
2079 | 21 | { | ||
2080 | 22 | struct Case { double x; char const *abbr; double pts; } const tests[] = { | ||
2081 | 23 | { 1.0, "pt", 1.0 }, | ||
2082 | 24 | { 5.0, "pt", 5.0 }, | ||
2083 | 25 | { 1.0, "in", 72.0 }, | ||
2084 | 26 | { 2.0, "in", 144.0 }, | ||
2085 | 27 | { 254., "mm", 720.0 }, | ||
2086 | 28 | { 254., "cm", 7200. }, | ||
2087 | 29 | { 254., "m", 720000. }, | ||
2088 | 30 | { 1.5, "mm", (15 * 72. / 254) } | ||
2089 | 31 | }; | ||
2090 | 32 | for (unsigned i = 0; i < G_N_ELEMENTS(tests); ++i) { | ||
2091 | 33 | Case const &c = tests[i]; | ||
2092 | 34 | SPUnit const &unit = *sp_unit_get_by_abbreviation(N_(c.abbr)); | ||
2093 | 35 | |||
2094 | 36 | double const calc_pts = sp_units_get_points(c.x, unit); | ||
2095 | 37 | TS_ASSERT(approx_equal(calc_pts, c.pts)); | ||
2096 | 38 | |||
2097 | 39 | double const calc_x = sp_points_get_units(c.pts, unit); | ||
2098 | 40 | TS_ASSERT(approx_equal(calc_x, c.x)); | ||
2099 | 41 | |||
2100 | 42 | double tmp = c.x; | ||
2101 | 43 | bool const converted_to_pts = sp_convert_distance(&tmp, &unit, SP_PS_UNIT); | ||
2102 | 44 | TS_ASSERT(converted_to_pts); | ||
2103 | 45 | TS_ASSERT(approx_equal(tmp, c.pts)); | ||
2104 | 46 | |||
2105 | 47 | tmp = c.pts; | ||
2106 | 48 | bool const converted_from_pts = sp_convert_distance(&tmp, SP_PS_UNIT, &unit); | ||
2107 | 49 | TS_ASSERT(converted_from_pts); | ||
2108 | 50 | TS_ASSERT(approx_equal(tmp, c.x)); | ||
2109 | 51 | } | ||
2110 | 52 | } | ||
2111 | 53 | |||
2112 | 54 | void testUnitTable() | ||
2113 | 55 | { | ||
2114 | 56 | TS_ASSERT(sp_units_table_sane()); | ||
2115 | 57 | } | ||
2116 | 58 | |||
2117 | 59 | private: | ||
2118 | 60 | /* N.B. Wrongly returns false if both near 0. (Not a problem for current users.) */ | ||
2119 | 61 | bool approx_equal(double const x, double const y) | ||
2120 | 62 | { | ||
2121 | 63 | return fabs(x / y - 1) < 1e-15; | ||
2122 | 64 | } | ||
2123 | 65 | |||
2124 | 66 | double sp_units_get_points(double const x, SPUnit const &unit) | ||
2125 | 67 | { | ||
2126 | 68 | SPUnit const &pt_unit = sp_unit_get_by_id(SP_UNIT_PT); | ||
2127 | 69 | double const px = sp_units_get_pixels(x, unit); | ||
2128 | 70 | return sp_pixels_get_units(px, pt_unit); | ||
2129 | 71 | } | ||
2130 | 72 | |||
2131 | 73 | double sp_points_get_units(double const pts, SPUnit const &unit) | ||
2132 | 74 | { | ||
2133 | 75 | SPUnit const &pt_unit = sp_unit_get_by_id(SP_UNIT_PT); | ||
2134 | 76 | double const px = sp_units_get_pixels(pts, pt_unit); | ||
2135 | 77 | return sp_pixels_get_units(px, unit); | ||
2136 | 78 | } | ||
2137 | 79 | }; | ||
2138 | 80 | |||
2139 | 81 | /* | ||
2140 | 82 | Local Variables: | ||
2141 | 83 | mode:c++ | ||
2142 | 84 | c-file-style:"stroustrup" | ||
2143 | 85 | c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) | ||
2144 | 86 | indent-tabs-mode:nil | ||
2145 | 87 | fill-column:99 | ||
2146 | 88 | End: | ||
2147 | 89 | */ | ||
2148 | 90 | // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : | ||
2149 | 91 | 0 | ||
2150 | === removed file 'src/helper/units.cpp' | |||
2151 | --- src/helper/units.cpp 2012-10-27 18:15:53 +0000 | |||
2152 | +++ src/helper/units.cpp 1970-01-01 00:00:00 +0000 | |||
2153 | @@ -1,261 +0,0 @@ | |||
2154 | 1 | #define __SP_PAPER_C__ | ||
2155 | 2 | |||
2156 | 3 | /* | ||
2157 | 4 | * SPUnit | ||
2158 | 5 | * | ||
2159 | 6 | * Ported from libgnomeprint | ||
2160 | 7 | * | ||
2161 | 8 | * Authors: | ||
2162 | 9 | * Dirk Luetjens <dirk@luedi.oche.de> | ||
2163 | 10 | * Yves Arrouye <Yves.Arrouye@marin.fdn.fr> | ||
2164 | 11 | * Lauris Kaplinski <lauris@ximian.com> | ||
2165 | 12 | * bulia byak <buliabyak@users.sf.net> | ||
2166 | 13 | * | ||
2167 | 14 | * Copyright 1999-2001 Ximian, Inc. and authors | ||
2168 | 15 | * | ||
2169 | 16 | */ | ||
2170 | 17 | |||
2171 | 18 | #ifdef HAVE_CONFIG_H | ||
2172 | 19 | # include "config.h" | ||
2173 | 20 | #endif | ||
2174 | 21 | |||
2175 | 22 | #include "helper/units.h" | ||
2176 | 23 | #include <glib.h> // g_assert() | ||
2177 | 24 | #include <glibmm/i18n.h> | ||
2178 | 25 | #include "unit-constants.h" | ||
2179 | 26 | #include "svg/svg-length.h" | ||
2180 | 27 | |||
2181 | 28 | /* todo: use some fancy unit program */ | ||
2182 | 29 | |||
2183 | 30 | /* The order determines the order of the list returned by sp_unit_get_list. | ||
2184 | 31 | * (It can also affect string lookups if there are any duplicates in the | ||
2185 | 32 | * current locale... hopefully none.) If you re-order this list, then you must | ||
2186 | 33 | * also re-order the SPUnitId enum values accordingly. Run `make check' (which | ||
2187 | 34 | * calls sp_unit_table_sane) to ensure that the two are in sync. | ||
2188 | 35 | */ | ||
2189 | 36 | SPUnit const sp_units[] = { | ||
2190 | 37 | {SP_UNIT_SCALE, SP_UNIT_DIMENSIONLESS, 1.0, SP_NONE, SVGLength::NONE, N_("Unit"), "", N_("Units"), ""}, | ||
2191 | 38 | {SP_UNIT_PT, SP_UNIT_ABSOLUTE, PX_PER_PT, SP_PT, SVGLength::PT, N_("Point"), N_("pt"), N_("Points"), N_("Pt")}, | ||
2192 | 39 | {SP_UNIT_PC, SP_UNIT_ABSOLUTE, PX_PER_PC, SP_PC, SVGLength::PC, N_("Pica"), N_("pc"), N_("Picas"), N_("Pc")}, | ||
2193 | 40 | {SP_UNIT_PX, SP_UNIT_DEVICE, PX_PER_PX, SP_PX, SVGLength::PX, N_("Pixel"), N_("px"), N_("Pixels"), N_("Px")}, | ||
2194 | 41 | /* You can add new elements from this point forward */ | ||
2195 | 42 | {SP_UNIT_PERCENT, SP_UNIT_DIMENSIONLESS, 0.01, SP_NONE, SVGLength::PERCENT, N_("Percent"), N_("%"), N_("Percents"), N_("%")}, | ||
2196 | 43 | {SP_UNIT_MM, SP_UNIT_ABSOLUTE, PX_PER_MM, SP_MM, SVGLength::MM, N_("Millimeter"), N_("mm"), N_("Millimeters"), N_("mm")}, | ||
2197 | 44 | {SP_UNIT_CM, SP_UNIT_ABSOLUTE, PX_PER_CM, SP_CM, SVGLength::CM, N_("Centimeter"), N_("cm"), N_("Centimeters"), N_("cm")}, | ||
2198 | 45 | {SP_UNIT_M, SP_UNIT_ABSOLUTE, PX_PER_M, SP_M, SVGLength::NONE, N_("Meter"), N_("m"), N_("Meters"), N_("m")}, // no svg_unit | ||
2199 | 46 | {SP_UNIT_IN, SP_UNIT_ABSOLUTE, PX_PER_IN, SP_IN, SVGLength::INCH, N_("Inch"), N_("in"), N_("Inches"), N_("in")}, | ||
2200 | 47 | {SP_UNIT_FT, SP_UNIT_ABSOLUTE, PX_PER_FT, SP_FT, SVGLength::FOOT, N_("Foot"), N_("ft"), N_("Feet"), N_("ft")}, | ||
2201 | 48 | /* Volatiles do not have default, so there are none here */ | ||
2202 | 49 | // TRANSLATORS: for info, see http://www.w3.org/TR/REC-CSS2/syndata.html#length-units | ||
2203 | 50 | {SP_UNIT_EM, SP_UNIT_VOLATILE, 1.0, SP_NONE, SVGLength::EM, N_("Em square"), N_("em"), N_("Em squares"), N_("em")}, | ||
2204 | 51 | // TRANSLATORS: for info, see http://www.w3.org/TR/REC-CSS2/syndata.html#length-units | ||
2205 | 52 | {SP_UNIT_EX, SP_UNIT_VOLATILE, 1.0, SP_NONE, SVGLength::EX, N_("Ex square"), N_("ex"), N_("Ex squares"), N_("ex")}, | ||
2206 | 53 | }; | ||
2207 | 54 | |||
2208 | 55 | #define sp_num_units G_N_ELEMENTS(sp_units) | ||
2209 | 56 | |||
2210 | 57 | SPUnit const * | ||
2211 | 58 | sp_unit_get_by_abbreviation(gchar const *abbreviation) | ||
2212 | 59 | { | ||
2213 | 60 | g_return_val_if_fail(abbreviation != NULL, NULL); | ||
2214 | 61 | |||
2215 | 62 | for (unsigned i = 0 ; i < sp_num_units ; i++) { | ||
2216 | 63 | if (!g_ascii_strcasecmp(abbreviation, sp_units[i].abbr)) return &sp_units[i]; | ||
2217 | 64 | if (!g_ascii_strcasecmp(abbreviation, sp_units[i].abbr_plural)) return &sp_units[i]; | ||
2218 | 65 | } | ||
2219 | 66 | |||
2220 | 67 | return NULL; | ||
2221 | 68 | } | ||
2222 | 69 | |||
2223 | 70 | gchar const * | ||
2224 | 71 | sp_unit_get_abbreviation(SPUnit const *unit) | ||
2225 | 72 | { | ||
2226 | 73 | g_return_val_if_fail(unit != NULL, NULL); | ||
2227 | 74 | |||
2228 | 75 | return unit->abbr; | ||
2229 | 76 | } | ||
2230 | 77 | |||
2231 | 78 | gchar const * | ||
2232 | 79 | sp_unit_get_plural (SPUnit const *unit) | ||
2233 | 80 | { | ||
2234 | 81 | g_return_val_if_fail(unit != NULL, NULL); | ||
2235 | 82 | |||
2236 | 83 | return unit->plural; | ||
2237 | 84 | } | ||
2238 | 85 | |||
2239 | 86 | SPMetric sp_unit_get_metric(SPUnit const *unit) | ||
2240 | 87 | { | ||
2241 | 88 | g_return_val_if_fail(unit != NULL, SP_NONE); | ||
2242 | 89 | |||
2243 | 90 | return unit->metric; | ||
2244 | 91 | } | ||
2245 | 92 | |||
2246 | 93 | guint sp_unit_get_svg_unit(SPUnit const *unit) | ||
2247 | 94 | { | ||
2248 | 95 | g_return_val_if_fail(unit != NULL, SP_NONE); | ||
2249 | 96 | |||
2250 | 97 | return unit->svg_unit; | ||
2251 | 98 | } | ||
2252 | 99 | |||
2253 | 100 | GSList * | ||
2254 | 101 | sp_unit_get_list(guint bases) | ||
2255 | 102 | { | ||
2256 | 103 | g_return_val_if_fail((bases & ~SP_UNITS_ALL) == 0, NULL); | ||
2257 | 104 | |||
2258 | 105 | GSList *units = NULL; | ||
2259 | 106 | for (unsigned i = sp_num_units ; i--; ) { | ||
2260 | 107 | if (bases & sp_units[i].base) { | ||
2261 | 108 | units = g_slist_prepend(units, (gpointer) &sp_units[i]); | ||
2262 | 109 | } | ||
2263 | 110 | } | ||
2264 | 111 | |||
2265 | 112 | return units; | ||
2266 | 113 | } | ||
2267 | 114 | |||
2268 | 115 | void | ||
2269 | 116 | sp_unit_free_list(GSList *units) | ||
2270 | 117 | { | ||
2271 | 118 | g_slist_free(units); | ||
2272 | 119 | } | ||
2273 | 120 | |||
2274 | 121 | /* These are pure utility */ | ||
2275 | 122 | /* Return TRUE if conversion is possible */ | ||
2276 | 123 | gboolean | ||
2277 | 124 | sp_convert_distance(gdouble *distance, SPUnit const *from, SPUnit const *to) | ||
2278 | 125 | { | ||
2279 | 126 | g_return_val_if_fail(distance != NULL, FALSE); | ||
2280 | 127 | g_return_val_if_fail(from != NULL, FALSE); | ||
2281 | 128 | g_return_val_if_fail(to != NULL, FALSE); | ||
2282 | 129 | |||
2283 | 130 | if (from == to) return TRUE; | ||
2284 | 131 | if ((from->base == SP_UNIT_DIMENSIONLESS) || (to->base == SP_UNIT_DIMENSIONLESS)) { | ||
2285 | 132 | *distance = *distance * from->unittobase / to->unittobase; | ||
2286 | 133 | return TRUE; | ||
2287 | 134 | } | ||
2288 | 135 | if ((from->base == SP_UNIT_VOLATILE) || (to->base == SP_UNIT_VOLATILE)) return FALSE; | ||
2289 | 136 | |||
2290 | 137 | if ((from->base == to->base) | ||
2291 | 138 | || ((from->base == SP_UNIT_DEVICE) && (to->base == SP_UNIT_ABSOLUTE)) | ||
2292 | 139 | || ((from->base == SP_UNIT_ABSOLUTE) && (to->base == SP_UNIT_DEVICE))) | ||
2293 | 140 | { | ||
2294 | 141 | *distance = *distance * from->unittobase / to->unittobase; | ||
2295 | 142 | return TRUE; | ||
2296 | 143 | } | ||
2297 | 144 | |||
2298 | 145 | return FALSE; | ||
2299 | 146 | } | ||
2300 | 147 | |||
2301 | 148 | /** @param devicetransform for device units. */ | ||
2302 | 149 | /* TODO: Remove the ctmscale parameter given that we no longer have SP_UNIT_USERSPACE. */ | ||
2303 | 150 | gdouble | ||
2304 | 151 | sp_convert_distance_full(gdouble const from_dist, SPUnit const &from, SPUnit const &to) | ||
2305 | 152 | { | ||
2306 | 153 | if (&from == &to) { | ||
2307 | 154 | return from_dist; | ||
2308 | 155 | } | ||
2309 | 156 | if (from.base == to.base) { | ||
2310 | 157 | gdouble ret = from_dist; | ||
2311 | 158 | bool const succ = sp_convert_distance(&ret, &from, &to); | ||
2312 | 159 | g_assert(succ); | ||
2313 | 160 | return ret; | ||
2314 | 161 | } | ||
2315 | 162 | if ((from.base == SP_UNIT_DIMENSIONLESS) | ||
2316 | 163 | || (to.base == SP_UNIT_DIMENSIONLESS)) | ||
2317 | 164 | { | ||
2318 | 165 | return from_dist * from.unittobase / to.unittobase; | ||
2319 | 166 | } | ||
2320 | 167 | g_return_val_if_fail(((from.base != SP_UNIT_VOLATILE) | ||
2321 | 168 | && (to.base != SP_UNIT_VOLATILE)), | ||
2322 | 169 | from_dist); | ||
2323 | 170 | |||
2324 | 171 | gdouble absolute; | ||
2325 | 172 | switch (from.base) { | ||
2326 | 173 | case SP_UNIT_ABSOLUTE: | ||
2327 | 174 | case SP_UNIT_DEVICE: | ||
2328 | 175 | absolute = from_dist * from.unittobase; | ||
2329 | 176 | break; | ||
2330 | 177 | default: | ||
2331 | 178 | g_warning("file %s: line %d: Illegal unit (base 0x%x)", __FILE__, __LINE__, from.base); | ||
2332 | 179 | return from_dist; | ||
2333 | 180 | } | ||
2334 | 181 | |||
2335 | 182 | gdouble ret; | ||
2336 | 183 | switch (to.base) { | ||
2337 | 184 | default: | ||
2338 | 185 | g_warning("file %s: line %d: Illegal unit (base 0x%x)", __FILE__, __LINE__, to.base); | ||
2339 | 186 | /* FALL-THROUGH */ | ||
2340 | 187 | case SP_UNIT_ABSOLUTE: | ||
2341 | 188 | case SP_UNIT_DEVICE: | ||
2342 | 189 | ret = absolute / to.unittobase; | ||
2343 | 190 | break; | ||
2344 | 191 | } | ||
2345 | 192 | |||
2346 | 193 | return ret; | ||
2347 | 194 | } | ||
2348 | 195 | |||
2349 | 196 | /* Some more convenience */ | ||
2350 | 197 | |||
2351 | 198 | gdouble | ||
2352 | 199 | sp_units_get_pixels(gdouble const units, SPUnit const &unit) | ||
2353 | 200 | { | ||
2354 | 201 | if (unit.base == SP_UNIT_ABSOLUTE || unit.base == SP_UNIT_DEVICE) { | ||
2355 | 202 | return units * unit.unittobase; | ||
2356 | 203 | } else { | ||
2357 | 204 | g_warning("Different unit bases: No exact unit conversion available"); | ||
2358 | 205 | return units * unit.unittobase; | ||
2359 | 206 | } | ||
2360 | 207 | } | ||
2361 | 208 | |||
2362 | 209 | gdouble | ||
2363 | 210 | sp_pixels_get_units(gdouble const pixels, SPUnit const &unit) | ||
2364 | 211 | { | ||
2365 | 212 | if (unit.base == SP_UNIT_ABSOLUTE || unit.base == SP_UNIT_DEVICE) { | ||
2366 | 213 | return pixels / unit.unittobase; | ||
2367 | 214 | } else { | ||
2368 | 215 | g_warning("Different unit bases: No exact unit conversion available"); | ||
2369 | 216 | return pixels / unit.unittobase; | ||
2370 | 217 | } | ||
2371 | 218 | } | ||
2372 | 219 | |||
2373 | 220 | bool | ||
2374 | 221 | sp_units_table_sane() | ||
2375 | 222 | { | ||
2376 | 223 | for (unsigned i = 0; i < G_N_ELEMENTS(sp_units); ++i) { | ||
2377 | 224 | if (unsigned(sp_units[i].unit_id) != i) { | ||
2378 | 225 | return false; | ||
2379 | 226 | } | ||
2380 | 227 | } | ||
2381 | 228 | return true; | ||
2382 | 229 | } | ||
2383 | 230 | |||
2384 | 231 | /** Converts angle (in deg) to compass display */ | ||
2385 | 232 | double | ||
2386 | 233 | angle_to_compass(double angle) | ||
2387 | 234 | { | ||
2388 | 235 | double ret = 90 - angle; | ||
2389 | 236 | if (ret < 0) | ||
2390 | 237 | ret = 360 + ret; | ||
2391 | 238 | return ret; | ||
2392 | 239 | } | ||
2393 | 240 | |||
2394 | 241 | /** Converts angle (in deg) to compass display */ | ||
2395 | 242 | double | ||
2396 | 243 | angle_from_compass(double angle) | ||
2397 | 244 | { | ||
2398 | 245 | double ret = 90 - angle; | ||
2399 | 246 | if (ret > 180) | ||
2400 | 247 | ret = ret - 180; | ||
2401 | 248 | return ret; | ||
2402 | 249 | } | ||
2403 | 250 | |||
2404 | 251 | |||
2405 | 252 | /* | ||
2406 | 253 | Local Variables: | ||
2407 | 254 | mode:c++ | ||
2408 | 255 | c-file-style:"stroustrup" | ||
2409 | 256 | c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) | ||
2410 | 257 | indent-tabs-mode:nil | ||
2411 | 258 | fill-column:99 | ||
2412 | 259 | End: | ||
2413 | 260 | */ | ||
2414 | 261 | // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : | ||
2415 | 262 | 0 | ||
2416 | === removed file 'src/helper/units.h' | |||
2417 | --- src/helper/units.h 2011-12-08 11:53:54 +0000 | |||
2418 | +++ src/helper/units.h 1970-01-01 00:00:00 +0000 | |||
2419 | @@ -1,146 +0,0 @@ | |||
2420 | 1 | #ifndef __SP_UNIT_H__ | ||
2421 | 2 | #define __SP_UNIT_H__ | ||
2422 | 3 | |||
2423 | 4 | /* | ||
2424 | 5 | * SPUnit | ||
2425 | 6 | * | ||
2426 | 7 | * Ported from libgnomeprint | ||
2427 | 8 | * | ||
2428 | 9 | * Authors: | ||
2429 | 10 | * Dirk Luetjens <dirk@luedi.oche.de> | ||
2430 | 11 | * Yves Arrouye <Yves.Arrouye@marin.fdn.fr> | ||
2431 | 12 | * Lauris Kaplinski <lauris@ximian.com> | ||
2432 | 13 | * | ||
2433 | 14 | * Copyright 1999-2001 Ximian, Inc. and authors | ||
2434 | 15 | * | ||
2435 | 16 | */ | ||
2436 | 17 | |||
2437 | 18 | #include <glib.h> | ||
2438 | 19 | #include "sp-metric.h" | ||
2439 | 20 | |||
2440 | 21 | |||
2441 | 22 | /* | ||
2442 | 23 | * Units and conversion methods used by libgnomeprint. | ||
2443 | 24 | * | ||
2444 | 25 | * You need those for certain config keys (like paper size), if you are | ||
2445 | 26 | * interested in using these (look at gnome-print-config.h for discussion, | ||
2446 | 27 | * why you may NOT be interested in paper size). | ||
2447 | 28 | * | ||
2448 | 29 | * Unit bases define set of mutually unrelated measuring systems (numbers, | ||
2449 | 30 | * paper, screen and dimesionless user coordinates). Still, you can convert | ||
2450 | 31 | * between those, specifying scaling factors explicitly. | ||
2451 | 32 | * | ||
2452 | 33 | * Paper (i.e. output) coordinates are taken as absolute real world units. | ||
2453 | 34 | * It has some justification, because screen unit (pixel) size changes, | ||
2454 | 35 | * if you change screen resolution, while you cannot change output on paper | ||
2455 | 36 | * as easily (unless you have thermally contracting paper, of course). | ||
2456 | 37 | * | ||
2457 | 38 | */ | ||
2458 | 39 | |||
2459 | 40 | struct SPUnit; | ||
2460 | 41 | struct SPDistance; | ||
2461 | 42 | |||
2462 | 43 | /* | ||
2463 | 44 | * The base linear ("absolute") unit is 1/72th of an inch, i.e. the base unit of postscript. | ||
2464 | 45 | */ | ||
2465 | 46 | |||
2466 | 47 | /* | ||
2467 | 48 | * Unit bases | ||
2468 | 49 | */ | ||
2469 | 50 | enum SPUnitBase { | ||
2470 | 51 | SP_UNIT_DIMENSIONLESS = (1 << 0), /* For percentages and like */ | ||
2471 | 52 | SP_UNIT_ABSOLUTE = (1 << 1), /* Real world distances - i.e. mm, cm... */ | ||
2472 | 53 | SP_UNIT_DEVICE = (1 << 2), /* Pixels in the SVG/CSS sense. */ | ||
2473 | 54 | SP_UNIT_VOLATILE = (1 << 3) /* em and ex */ | ||
2474 | 55 | }; | ||
2475 | 56 | |||
2476 | 57 | /* | ||
2477 | 58 | * Units: indexes into sp_units. | ||
2478 | 59 | */ | ||
2479 | 60 | enum SPUnitId { | ||
2480 | 61 | SP_UNIT_SCALE, // 1.0 == 100% | ||
2481 | 62 | SP_UNIT_PT, // Postscript points: exactly 72 per inch | ||
2482 | 63 | SP_UNIT_PC, // Pica; there are 12 points per pica | ||
2483 | 64 | SP_UNIT_PX, // "Pixels" in the CSS sense; though Inkscape assumes a constant 90 per inch. | ||
2484 | 65 | SP_UNIT_PERCENT, /* Note: In Inkscape this often means "relative to current value" (for | ||
2485 | 66 | users to edit a value), rather than the SVG/CSS use of percentages. */ | ||
2486 | 67 | SP_UNIT_MM, // millimetres | ||
2487 | 68 | SP_UNIT_CM, // centimetres | ||
2488 | 69 | SP_UNIT_M, // metres | ||
2489 | 70 | SP_UNIT_IN, // inches | ||
2490 | 71 | SP_UNIT_FT, // foot | ||
2491 | 72 | SP_UNIT_EM, // font-size of relevant font | ||
2492 | 73 | SP_UNIT_EX, // x-height of relevant font | ||
2493 | 74 | sp_max_unit_id = SP_UNIT_EX // For bounds-checking in sp_unit_get_by_id. | ||
2494 | 75 | }; | ||
2495 | 76 | |||
2496 | 77 | /* | ||
2497 | 78 | * Notice, that for correct menus etc. you have to use | ||
2498 | 79 | * ngettext method family yourself. For that reason we | ||
2499 | 80 | * do not provide translations in unit names. | ||
2500 | 81 | * I also do not know, whether to allow user-created units, | ||
2501 | 82 | * because this would certainly confuse textdomain. | ||
2502 | 83 | */ | ||
2503 | 84 | |||
2504 | 85 | struct SPUnit { | ||
2505 | 86 | SPUnitId unit_id; /* used as sanity check */ | ||
2506 | 87 | SPUnitBase base; | ||
2507 | 88 | gdouble unittobase; /* how many base units in this unit */ | ||
2508 | 89 | SPMetric metric; // the corresponding SPMetric from sp-metrics.h | ||
2509 | 90 | guint svg_unit; // the corresponding SVGLengthUnit | ||
2510 | 91 | |||
2511 | 92 | /* When using, you must call "gettext" on them so they're translated */ | ||
2512 | 93 | gchar const *name; | ||
2513 | 94 | gchar const *abbr; | ||
2514 | 95 | gchar const *plural; | ||
2515 | 96 | gchar const *abbr_plural; | ||
2516 | 97 | }; | ||
2517 | 98 | |||
2518 | 99 | const SPUnit *sp_unit_get_by_abbreviation (const gchar *abbreviation); | ||
2519 | 100 | /* When using, you must call "gettext" on them so they're translated */ | ||
2520 | 101 | const gchar *sp_unit_get_abbreviation (const SPUnit *unit); | ||
2521 | 102 | gchar const *sp_unit_get_plural (SPUnit const *unit); | ||
2522 | 103 | |||
2523 | 104 | SPMetric sp_unit_get_metric(SPUnit const *unit); | ||
2524 | 105 | guint sp_unit_get_svg_unit(SPUnit const *unit); | ||
2525 | 106 | |||
2526 | 107 | extern SPUnit const sp_units[]; | ||
2527 | 108 | |||
2528 | 109 | inline SPUnit const & | ||
2529 | 110 | sp_unit_get_by_id(SPUnitId const id) | ||
2530 | 111 | { | ||
2531 | 112 | /* inline because the compiler should optimize away the g_return_val_if_fail test in the | ||
2532 | 113 | usual case that the argument value is known at compile-time, leaving just | ||
2533 | 114 | "return sp_units[constant]". */ | ||
2534 | 115 | unsigned const ix = unsigned(id); | ||
2535 | 116 | g_return_val_if_fail(ix <= sp_max_unit_id, sp_units[SP_UNIT_PX]); | ||
2536 | 117 | return sp_units[ix]; | ||
2537 | 118 | } | ||
2538 | 119 | |||
2539 | 120 | #define SP_PS_UNIT (&sp_unit_get_by_id(SP_UNIT_PT)) | ||
2540 | 121 | |||
2541 | 122 | |||
2542 | 123 | /** Used solely by units-test.cpp. */ | ||
2543 | 124 | bool sp_units_table_sane(); | ||
2544 | 125 | |||
2545 | 126 | #define SP_UNITS_ALL (SP_UNIT_DIMENSIONLESS | SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE | SP_UNIT_VOLATILE) | ||
2546 | 127 | |||
2547 | 128 | GSList *sp_unit_get_list (guint bases); | ||
2548 | 129 | void sp_unit_free_list (GSList *units); | ||
2549 | 130 | |||
2550 | 131 | /* These are pure utility */ | ||
2551 | 132 | /* Return TRUE if conversion is possible, FALSE if unit bases differ */ | ||
2552 | 133 | gboolean sp_convert_distance (gdouble *distance, const SPUnit *from, const SPUnit *to); | ||
2553 | 134 | |||
2554 | 135 | /* If either one is NULL, transconverting to/from that base fails */ | ||
2555 | 136 | /* Generic conversion between volatile units would be useless anyways */ | ||
2556 | 137 | gdouble sp_convert_distance_full(gdouble const from_dist, SPUnit const &from, SPUnit const &to); | ||
2557 | 138 | |||
2558 | 139 | /* Some more convenience */ | ||
2559 | 140 | gdouble sp_units_get_pixels(gdouble const units, SPUnit const &unit); | ||
2560 | 141 | gdouble sp_pixels_get_units(gdouble const pixels, SPUnit const &unit); | ||
2561 | 142 | |||
2562 | 143 | double angle_to_compass(double angle); | ||
2563 | 144 | double angle_from_compass(double angle); | ||
2564 | 145 | |||
2565 | 146 | #endif | ||
2566 | 147 | 0 | ||
2567 | === modified file 'src/live_effects/lpe-path_length.cpp' | |||
2568 | --- src/live_effects/lpe-path_length.cpp 2012-10-21 18:04:54 +0000 | |||
2569 | +++ src/live_effects/lpe-path_length.cpp 2013-08-06 18:46:25 +0000 | |||
2570 | @@ -14,7 +14,7 @@ | |||
2571 | 14 | #include <glibmm/i18n.h> | 14 | #include <glibmm/i18n.h> |
2572 | 15 | 15 | ||
2573 | 16 | #include "live_effects/lpe-path_length.h" | 16 | #include "live_effects/lpe-path_length.h" |
2575 | 17 | #include "sp-metrics.h" | 17 | #include "util/units.h" |
2576 | 18 | 18 | ||
2577 | 19 | #include "2geom/sbasis-geometric.h" | 19 | #include "2geom/sbasis-geometric.h" |
2578 | 20 | 20 | ||
2579 | @@ -52,11 +52,11 @@ | |||
2580 | 52 | 52 | ||
2581 | 53 | /* convert the measured length to the correct unit ... */ | 53 | /* convert the measured length to the correct unit ... */ |
2582 | 54 | double lengthval = Geom::length(pwd2_in) * scale; | 54 | double lengthval = Geom::length(pwd2_in) * scale; |
2584 | 55 | gboolean success = sp_convert_distance(&lengthval, &sp_unit_get_by_id(SP_UNIT_PX), unit); | 55 | lengthval = Inkscape::Util::Quantity::convert(lengthval, "px", unit.get_abbreviation()); |
2585 | 56 | 56 | ||
2586 | 57 | /* ... set it as the canvas text ... */ | 57 | /* ... set it as the canvas text ... */ |
2587 | 58 | gchar *arc_length = g_strdup_printf("%.2f %s", lengthval, | 58 | gchar *arc_length = g_strdup_printf("%.2f %s", lengthval, |
2589 | 59 | display_unit ? (success ? unit.get_abbreviation() : "px") : ""); | 59 | display_unit ? unit.get_abbreviation() : ""); |
2590 | 60 | info_text.param_setValue(arc_length); | 60 | info_text.param_setValue(arc_length); |
2591 | 61 | g_free(arc_length); | 61 | g_free(arc_length); |
2592 | 62 | 62 | ||
2593 | 63 | 63 | ||
2594 | === modified file 'src/live_effects/lpe-ruler.cpp' | |||
2595 | --- src/live_effects/lpe-ruler.cpp 2013-03-13 17:30:15 +0000 | |||
2596 | +++ src/live_effects/lpe-ruler.cpp 2013-08-06 18:46:25 +0000 | |||
2597 | @@ -81,9 +81,9 @@ | |||
2598 | 81 | using namespace Geom; | 81 | using namespace Geom; |
2599 | 82 | 82 | ||
2600 | 83 | double real_mark_length = mark_length; | 83 | double real_mark_length = mark_length; |
2602 | 84 | sp_convert_distance(&real_mark_length, unit, &sp_unit_get_by_id(SP_UNIT_PX)); | 84 | real_mark_length = Inkscape::Util::Quantity::convert(real_mark_length, unit.get_abbreviation(), "px"); |
2603 | 85 | double real_minor_mark_length = minor_mark_length; | 85 | double real_minor_mark_length = minor_mark_length; |
2605 | 86 | sp_convert_distance(&real_minor_mark_length, unit, &sp_unit_get_by_id(SP_UNIT_PX)); | 86 | real_minor_mark_length = Inkscape::Util::Quantity::convert(real_minor_mark_length, unit.get_abbreviation(), "px"); |
2606 | 87 | 87 | ||
2607 | 88 | n_major = real_mark_length * n; | 88 | n_major = real_mark_length * n; |
2608 | 89 | n_minor = real_minor_mark_length * n; | 89 | n_minor = real_minor_mark_length * n; |
2609 | @@ -133,10 +133,10 @@ | |||
2610 | 133 | std::vector<double> s_cuts; | 133 | std::vector<double> s_cuts; |
2611 | 134 | 134 | ||
2612 | 135 | double real_mark_distance = mark_distance; | 135 | double real_mark_distance = mark_distance; |
2614 | 136 | sp_convert_distance(&real_mark_distance, unit, &sp_unit_get_by_id(SP_UNIT_PX)); | 136 | real_mark_distance = Inkscape::Util::Quantity::convert(real_mark_distance, unit.get_abbreviation(), "px"); |
2615 | 137 | 137 | ||
2616 | 138 | double real_offset = offset; | 138 | double real_offset = offset; |
2618 | 139 | sp_convert_distance(&real_offset, unit, &sp_unit_get_by_id(SP_UNIT_PX)); | 139 | real_offset = Inkscape::Util::Quantity::convert(real_offset, unit.get_abbreviation(), "px"); |
2619 | 140 | for (double s = real_offset; s<totlength; s+=real_mark_distance){ | 140 | for (double s = real_offset; s<totlength; s+=real_mark_distance){ |
2620 | 141 | s_cuts.push_back(s); | 141 | s_cuts.push_back(s); |
2621 | 142 | } | 142 | } |
2622 | 143 | 143 | ||
2623 | === modified file 'src/live_effects/parameter/unit.cpp' | |||
2624 | --- src/live_effects/parameter/unit.cpp 2013-03-25 17:42:31 +0000 | |||
2625 | +++ src/live_effects/parameter/unit.cpp 2013-08-06 18:46:25 +0000 | |||
2626 | @@ -10,6 +10,9 @@ | |||
2627 | 10 | #include "live_effects/parameter/unit.h" | 10 | #include "live_effects/parameter/unit.h" |
2628 | 11 | #include "live_effects/effect.h" | 11 | #include "live_effects/effect.h" |
2629 | 12 | #include "verbs.h" | 12 | #include "verbs.h" |
2630 | 13 | #include "util/units.h" | ||
2631 | 14 | |||
2632 | 15 | using Inkscape::Util::unit_table; | ||
2633 | 13 | 16 | ||
2634 | 14 | namespace Inkscape { | 17 | namespace Inkscape { |
2635 | 15 | 18 | ||
2636 | @@ -18,10 +21,10 @@ | |||
2637 | 18 | 21 | ||
2638 | 19 | UnitParam::UnitParam( const Glib::ustring& label, const Glib::ustring& tip, | 22 | UnitParam::UnitParam( const Glib::ustring& label, const Glib::ustring& tip, |
2639 | 20 | const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr, | 23 | const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr, |
2641 | 21 | Effect* effect, SPUnitId default_value) | 24 | Effect* effect, Glib::ustring default_unit) |
2642 | 22 | : Parameter(label, tip, key, wr, effect) | 25 | : Parameter(label, tip, key, wr, effect) |
2643 | 23 | { | 26 | { |
2645 | 24 | defunit = &sp_unit_get_by_id(default_value);; | 27 | defunit = new Inkscape::Util::Unit(unit_table.getUnit(default_unit)); |
2646 | 25 | unit = defunit; | 28 | unit = defunit; |
2647 | 26 | } | 29 | } |
2648 | 27 | 30 | ||
2649 | @@ -32,9 +35,8 @@ | |||
2650 | 32 | bool | 35 | bool |
2651 | 33 | UnitParam::param_readSVGValue(const gchar * strvalue) | 36 | UnitParam::param_readSVGValue(const gchar * strvalue) |
2652 | 34 | { | 37 | { |
2656 | 35 | SPUnit const *newval = sp_unit_get_by_abbreviation(strvalue); | 38 | if (strvalue) { |
2657 | 36 | if (newval) { | 39 | param_set_value(unit_table.getUnit(strvalue)); |
2655 | 37 | param_set_value(newval); | ||
2658 | 38 | return true; | 40 | return true; |
2659 | 39 | } | 41 | } |
2660 | 40 | return false; | 42 | return false; |
2661 | @@ -43,25 +45,25 @@ | |||
2662 | 43 | gchar * | 45 | gchar * |
2663 | 44 | UnitParam::param_getSVGValue() const | 46 | UnitParam::param_getSVGValue() const |
2664 | 45 | { | 47 | { |
2666 | 46 | return g_strdup(sp_unit_get_abbreviation(unit)); | 48 | return g_strdup(unit->abbr.c_str()); |
2667 | 47 | } | 49 | } |
2668 | 48 | 50 | ||
2669 | 49 | void | 51 | void |
2670 | 50 | UnitParam::param_set_default() | 52 | UnitParam::param_set_default() |
2671 | 51 | { | 53 | { |
2673 | 52 | param_set_value(defunit); | 54 | param_set_value(*defunit); |
2674 | 53 | } | 55 | } |
2675 | 54 | 56 | ||
2676 | 55 | void | 57 | void |
2678 | 56 | UnitParam::param_set_value(SPUnit const *val) | 58 | UnitParam::param_set_value(Inkscape::Util::Unit const &val) |
2679 | 57 | { | 59 | { |
2681 | 58 | unit = val; | 60 | unit = new Inkscape::Util::Unit(val); |
2682 | 59 | } | 61 | } |
2683 | 60 | 62 | ||
2684 | 61 | const gchar * | 63 | const gchar * |
2685 | 62 | UnitParam::get_abbreviation() const | 64 | UnitParam::get_abbreviation() const |
2686 | 63 | { | 65 | { |
2688 | 64 | return sp_unit_get_abbreviation(unit); | 66 | return unit->abbr.c_str(); |
2689 | 65 | } | 67 | } |
2690 | 66 | 68 | ||
2691 | 67 | Gtk::Widget * | 69 | Gtk::Widget * |
2692 | @@ -74,7 +76,7 @@ | |||
2693 | 74 | param_effect->getRepr(), | 76 | param_effect->getRepr(), |
2694 | 75 | param_effect->getSPDoc())); | 77 | param_effect->getSPDoc())); |
2695 | 76 | 78 | ||
2697 | 77 | unit_menu->setUnit(unit); | 79 | unit_menu->setUnit(unit->abbr); |
2698 | 78 | unit_menu->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change unit parameter")); | 80 | unit_menu->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change unit parameter")); |
2699 | 79 | 81 | ||
2700 | 80 | return dynamic_cast<Gtk::Widget *> (unit_menu); | 82 | return dynamic_cast<Gtk::Widget *> (unit_menu); |
2701 | 81 | 83 | ||
2702 | === modified file 'src/live_effects/parameter/unit.h' | |||
2703 | --- src/live_effects/parameter/unit.h 2013-01-17 18:23:15 +0000 | |||
2704 | +++ src/live_effects/parameter/unit.h 2013-08-06 18:46:25 +0000 | |||
2705 | @@ -10,10 +10,13 @@ | |||
2706 | 10 | */ | 10 | */ |
2707 | 11 | 11 | ||
2708 | 12 | #include "live_effects/parameter/parameter.h" | 12 | #include "live_effects/parameter/parameter.h" |
2709 | 13 | #include <helper/units.h> | ||
2710 | 14 | 13 | ||
2711 | 15 | namespace Inkscape { | 14 | namespace Inkscape { |
2712 | 16 | 15 | ||
2713 | 16 | namespace Util { | ||
2714 | 17 | class Unit; | ||
2715 | 18 | } | ||
2716 | 19 | |||
2717 | 17 | namespace LivePathEffect { | 20 | namespace LivePathEffect { |
2718 | 18 | 21 | ||
2719 | 19 | class UnitParam : public Parameter { | 22 | class UnitParam : public Parameter { |
2720 | @@ -23,22 +26,22 @@ | |||
2721 | 23 | const Glib::ustring& key, | 26 | const Glib::ustring& key, |
2722 | 24 | Inkscape::UI::Widget::Registry* wr, | 27 | Inkscape::UI::Widget::Registry* wr, |
2723 | 25 | Effect* effect, | 28 | Effect* effect, |
2725 | 26 | SPUnitId default_value = SP_UNIT_PX); | 29 | Glib::ustring default_unit = "px"); |
2726 | 27 | virtual ~UnitParam(); | 30 | virtual ~UnitParam(); |
2727 | 28 | 31 | ||
2728 | 29 | virtual bool param_readSVGValue(const gchar * strvalue); | 32 | virtual bool param_readSVGValue(const gchar * strvalue); |
2729 | 30 | virtual gchar * param_getSVGValue() const; | 33 | virtual gchar * param_getSVGValue() const; |
2730 | 31 | virtual void param_set_default(); | 34 | virtual void param_set_default(); |
2732 | 32 | void param_set_value(SPUnit const *val); | 35 | void param_set_value(Inkscape::Util::Unit const &val); |
2733 | 33 | const gchar *get_abbreviation() const; | 36 | const gchar *get_abbreviation() const; |
2734 | 34 | 37 | ||
2735 | 35 | virtual Gtk::Widget * param_newWidget(); | 38 | virtual Gtk::Widget * param_newWidget(); |
2736 | 36 | 39 | ||
2738 | 37 | operator SPUnit const *() const { return unit; } | 40 | operator Inkscape::Util::Unit const *() const { return unit; } |
2739 | 38 | 41 | ||
2740 | 39 | private: | 42 | private: |
2743 | 40 | SPUnit const *unit; | 43 | Inkscape::Util::Unit const *unit; |
2744 | 41 | SPUnit const *defunit; | 44 | Inkscape::Util::Unit const *defunit; |
2745 | 42 | 45 | ||
2746 | 43 | UnitParam(const UnitParam&); | 46 | UnitParam(const UnitParam&); |
2747 | 44 | UnitParam& operator=(const UnitParam&); | 47 | UnitParam& operator=(const UnitParam&); |
2748 | 45 | 48 | ||
2749 | === modified file 'src/lpe-tool-context.cpp' | |||
2750 | --- src/lpe-tool-context.cpp 2013-08-03 21:30:12 +0000 | |||
2751 | +++ src/lpe-tool-context.cpp 2013-08-06 18:46:25 +0000 | |||
2752 | @@ -37,10 +37,12 @@ | |||
2753 | 37 | #include "display/canvas-text.h" | 37 | #include "display/canvas-text.h" |
2754 | 38 | #include "message-stack.h" | 38 | #include "message-stack.h" |
2755 | 39 | #include "sp-path.h" | 39 | #include "sp-path.h" |
2757 | 40 | #include "helper/units.h" | 40 | #include "util/units.h" |
2758 | 41 | 41 | ||
2759 | 42 | #include "lpe-tool-context.h" | 42 | #include "lpe-tool-context.h" |
2760 | 43 | 43 | ||
2761 | 44 | using Inkscape::Util::unit_table; | ||
2762 | 45 | |||
2763 | 44 | static void sp_lpetool_context_dispose(GObject *object); | 46 | static void sp_lpetool_context_dispose(GObject *object); |
2764 | 45 | 47 | ||
2765 | 46 | static void sp_lpetool_context_setup(SPEventContext *ec); | 48 | static void sp_lpetool_context_setup(SPEventContext *ec); |
2766 | @@ -453,13 +455,17 @@ | |||
2767 | 453 | if (!show) | 455 | if (!show) |
2768 | 454 | sp_canvas_item_hide(SP_CANVAS_ITEM(canvas_text)); | 456 | sp_canvas_item_hide(SP_CANVAS_ITEM(canvas_text)); |
2769 | 455 | 457 | ||
2772 | 456 | SPUnitId unitid = static_cast<SPUnitId>(prefs->getInt("/tools/lpetool/unitid", SP_UNIT_PX)); | 458 | Inkscape::Util::Unit unit; |
2773 | 457 | SPUnit unit = sp_unit_get_by_id(unitid); | 459 | if (prefs->getString("/tools/lpetool/unit").compare("")) { |
2774 | 460 | unit = unit_table.getUnit(prefs->getString("/tools/lpetool/unit")); | ||
2775 | 461 | } else { | ||
2776 | 462 | unit = unit_table.getUnit("px"); | ||
2777 | 463 | } | ||
2778 | 458 | 464 | ||
2779 | 459 | lengthval = Geom::length(pwd2); | 465 | lengthval = Geom::length(pwd2); |
2780 | 460 | gboolean success; | 466 | gboolean success; |
2783 | 461 | success = sp_convert_distance(&lengthval, &sp_unit_get_by_id(SP_UNIT_PX), &unit); | 467 | lengthval = Inkscape::Util::Quantity::convert(lengthval, "px", unit); |
2784 | 462 | arc_length = g_strdup_printf("%.2f %s", lengthval, success ? sp_unit_get_abbreviation(&unit) : "px"); | 468 | arc_length = g_strdup_printf("%.2f %s", lengthval, unit.abbr.c_str()); |
2785 | 463 | sp_canvastext_set_text (canvas_text, arc_length); | 469 | sp_canvastext_set_text (canvas_text, arc_length); |
2786 | 464 | set_pos_and_anchor(canvas_text, pwd2, 0.5, 10); | 470 | set_pos_and_anchor(canvas_text, pwd2, 0.5, 10); |
2787 | 465 | // TODO: must we free arc_length? | 471 | // TODO: must we free arc_length? |
2788 | @@ -489,12 +495,27 @@ | |||
2789 | 489 | SPPath *path = i->first; | 495 | SPPath *path = i->first; |
2790 | 490 | SPCurve *curve = SP_SHAPE(path)->getCurve(); | 496 | SPCurve *curve = SP_SHAPE(path)->getCurve(); |
2791 | 491 | Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2 = Geom::paths_to_pw(curve->get_pathvector()); | 497 | Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2 = Geom::paths_to_pw(curve->get_pathvector()); |
2792 | 498 | <<<<<<< TREE | ||
2793 | 492 | SPUnitId unitid = static_cast<SPUnitId>(prefs->getInt("/tools/lpetool/unitid", SP_UNIT_PX)); | 499 | SPUnitId unitid = static_cast<SPUnitId>(prefs->getInt("/tools/lpetool/unitid", SP_UNIT_PX)); |
2794 | 493 | SPUnit unit = sp_unit_get_by_id(unitid); | 500 | SPUnit unit = sp_unit_get_by_id(unitid); |
2795 | 494 | double lengthval = Geom::length(pwd2); | 501 | double lengthval = Geom::length(pwd2); |
2796 | 502 | ======= | ||
2797 | 503 | Inkscape::Util::Unit unit; | ||
2798 | 504 | if (prefs->getString("/tools/lpetool/unit").compare("")) { | ||
2799 | 505 | unit = unit_table.getUnit(prefs->getString("/tools/lpetool/unit")); | ||
2800 | 506 | } else { | ||
2801 | 507 | unit = unit_table.getUnit("px"); | ||
2802 | 508 | } | ||
2803 | 509 | lengthval = Geom::length(pwd2); | ||
2804 | 510 | >>>>>>> MERGE-SOURCE | ||
2805 | 495 | gboolean success; | 511 | gboolean success; |
2806 | 512 | <<<<<<< TREE | ||
2807 | 496 | success = sp_convert_distance(&lengthval, &sp_unit_get_by_id(SP_UNIT_PX), &unit); | 513 | success = sp_convert_distance(&lengthval, &sp_unit_get_by_id(SP_UNIT_PX), &unit); |
2808 | 497 | gchar *arc_length = g_strdup_printf("%.2f %s", lengthval, success ? sp_unit_get_abbreviation(&unit) : "px"); | 514 | gchar *arc_length = g_strdup_printf("%.2f %s", lengthval, success ? sp_unit_get_abbreviation(&unit) : "px"); |
2809 | 515 | ======= | ||
2810 | 516 | lengthval = Inkscape::Util::Quantity::convert(lengthval, "px", unit); | ||
2811 | 517 | arc_length = g_strdup_printf("%.2f %s", lengthval, unit.abbr.c_str()); | ||
2812 | 518 | >>>>>>> MERGE-SOURCE | ||
2813 | 498 | sp_canvastext_set_text (SP_CANVASTEXT(i->second), arc_length); | 519 | sp_canvastext_set_text (SP_CANVASTEXT(i->second), arc_length); |
2814 | 499 | set_pos_and_anchor(SP_CANVASTEXT(i->second), pwd2, 0.5, 10); | 520 | set_pos_and_anchor(SP_CANVASTEXT(i->second), pwd2, 0.5, 10); |
2815 | 500 | // TODO: must we free arc_length? | 521 | // TODO: must we free arc_length? |
2816 | 501 | 522 | ||
2817 | === modified file 'src/lpe-tool-context.h' | |||
2818 | --- src/lpe-tool-context.h 2013-03-14 23:24:17 +0000 | |||
2819 | +++ src/lpe-tool-context.h 2013-08-06 18:46:25 +0000 | |||
2820 | @@ -16,7 +16,6 @@ | |||
2821 | 16 | */ | 16 | */ |
2822 | 17 | 17 | ||
2823 | 18 | #include "pen-context.h" | 18 | #include "pen-context.h" |
2824 | 19 | #include "helper/units.h" | ||
2825 | 20 | 19 | ||
2826 | 21 | #define SP_TYPE_LPETOOL_CONTEXT (sp_lpetool_context_get_type()) | 20 | #define SP_TYPE_LPETOOL_CONTEXT (sp_lpetool_context_get_type()) |
2827 | 22 | #define SP_LPETOOL_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_CAST((o), SP_TYPE_LPETOOL_CONTEXT, SPLPEToolContext)) | 21 | #define SP_LPETOOL_CONTEXT(o) (G_TYPE_CHECK_INSTANCE_CAST((o), SP_TYPE_LPETOOL_CONTEXT, SPLPEToolContext)) |
2828 | 23 | 22 | ||
2829 | === modified file 'src/main.cpp' | |||
2830 | --- src/main.cpp 2013-07-17 11:42:40 +0000 | |||
2831 | +++ src/main.cpp 2013-08-06 18:46:25 +0000 | |||
2832 | @@ -68,7 +68,6 @@ | |||
2833 | 68 | #include "color.h" | 68 | #include "color.h" |
2834 | 69 | #include "sp-item.h" | 69 | #include "sp-item.h" |
2835 | 70 | #include "sp-root.h" | 70 | #include "sp-root.h" |
2836 | 71 | #include "unit-constants.h" | ||
2837 | 72 | 71 | ||
2838 | 73 | #include "svg/svg.h" | 72 | #include "svg/svg.h" |
2839 | 74 | #include "svg/svg-color.h" | 73 | #include "svg/svg-color.h" |
2840 | @@ -1524,7 +1523,7 @@ | |||
2841 | 1524 | 1523 | ||
2842 | 1525 | // default dpi | 1524 | // default dpi |
2843 | 1526 | if (dpi == 0.0) { | 1525 | if (dpi == 0.0) { |
2845 | 1527 | dpi = PX_PER_IN; | 1526 | dpi = Inkscape::Util::Quantity::convert(1, "in", "px"); |
2846 | 1528 | } | 1527 | } |
2847 | 1529 | 1528 | ||
2848 | 1530 | unsigned long int width = 0; | 1529 | unsigned long int width = 0; |
2849 | @@ -1537,7 +1536,7 @@ | |||
2850 | 1537 | g_warning("Export width %lu out of range (1 - %lu). Nothing exported.", width, (unsigned long int)PNG_UINT_31_MAX); | 1536 | g_warning("Export width %lu out of range (1 - %lu). Nothing exported.", width, (unsigned long int)PNG_UINT_31_MAX); |
2851 | 1538 | return 1; | 1537 | return 1; |
2852 | 1539 | } | 1538 | } |
2854 | 1540 | dpi = (gdouble) width * PX_PER_IN / area.width(); | 1539 | dpi = (gdouble) width * Inkscape::Util::Quantity::convert(1, "in", "px") / area.width(); |
2855 | 1541 | } | 1540 | } |
2856 | 1542 | 1541 | ||
2857 | 1543 | if (sp_export_height) { | 1542 | if (sp_export_height) { |
2858 | @@ -1547,15 +1546,15 @@ | |||
2859 | 1547 | g_warning("Export height %lu out of range (1 - %lu). Nothing exported.", height, (unsigned long int)PNG_UINT_31_MAX); | 1546 | g_warning("Export height %lu out of range (1 - %lu). Nothing exported.", height, (unsigned long int)PNG_UINT_31_MAX); |
2860 | 1548 | return 1; | 1547 | return 1; |
2861 | 1549 | } | 1548 | } |
2863 | 1550 | dpi = (gdouble) height * PX_PER_IN / area.height(); | 1549 | dpi = (gdouble) height * Inkscape::Util::Quantity::convert(1, "in", "px") / area.height(); |
2864 | 1551 | } | 1550 | } |
2865 | 1552 | 1551 | ||
2866 | 1553 | if (!sp_export_width) { | 1552 | if (!sp_export_width) { |
2868 | 1554 | width = (unsigned long int) (area.width() * dpi / PX_PER_IN + 0.5); | 1553 | width = (unsigned long int) (area.width() * dpi / Inkscape::Util::Quantity::convert(1, "in", "px") + 0.5); |
2869 | 1555 | } | 1554 | } |
2870 | 1556 | 1555 | ||
2871 | 1557 | if (!sp_export_height) { | 1556 | if (!sp_export_height) { |
2873 | 1558 | height = (unsigned long int) (area.height() * dpi / PX_PER_IN + 0.5); | 1557 | height = (unsigned long int) (area.height() * dpi / Inkscape::Util::Quantity::convert(1, "in", "px") + 0.5); |
2874 | 1559 | } | 1558 | } |
2875 | 1560 | 1559 | ||
2876 | 1561 | guint32 bgcolor = 0x00000000; | 1560 | guint32 bgcolor = 0x00000000; |
2877 | 1562 | 1561 | ||
2878 | === modified file 'src/measure-context.cpp' | |||
2879 | --- src/measure-context.cpp 2013-08-03 21:30:12 +0000 | |||
2880 | +++ src/measure-context.cpp 2013-08-06 18:46:25 +0000 | |||
2881 | @@ -13,7 +13,7 @@ | |||
2882 | 13 | 13 | ||
2883 | 14 | #include <gdk/gdkkeysyms.h> | 14 | #include <gdk/gdkkeysyms.h> |
2884 | 15 | #include <boost/none_t.hpp> | 15 | #include <boost/none_t.hpp> |
2886 | 16 | #include "helper/units.h" | 16 | #include "util/units.h" |
2887 | 17 | #include "macros.h" | 17 | #include "macros.h" |
2888 | 18 | #include "display/curve.h" | 18 | #include "display/curve.h" |
2889 | 19 | #include "sp-shape.h" | 19 | #include "sp-shape.h" |
2890 | @@ -46,6 +46,7 @@ | |||
2891 | 46 | 46 | ||
2892 | 47 | using Inkscape::ControlManager; | 47 | using Inkscape::ControlManager; |
2893 | 48 | using Inkscape::CTLINE_SECONDARY; | 48 | using Inkscape::CTLINE_SECONDARY; |
2894 | 49 | using Inkscape::Util::unit_table; | ||
2895 | 49 | 50 | ||
2896 | 50 | static void sp_measure_context_setup(SPEventContext *ec); | 51 | static void sp_measure_context_setup(SPEventContext *ec); |
2897 | 51 | static void sp_measure_context_finish(SPEventContext *ec); | 52 | static void sp_measure_context_finish(SPEventContext *ec); |
2898 | @@ -514,8 +515,10 @@ | |||
2899 | 514 | std::sort(intersections.begin(), intersections.end(), GeomPointSortPredicate); | 515 | std::sort(intersections.begin(), intersections.end(), GeomPointSortPredicate); |
2900 | 515 | } | 516 | } |
2901 | 516 | 517 | ||
2904 | 517 | SPUnitId unitid = static_cast<SPUnitId>(prefs->getInt("/tools/measure/unitid", SP_UNIT_PX)); | 518 | Glib::ustring unit_name = prefs->getString("/tools/measure/unit"); |
2905 | 518 | SPUnit unit = sp_unit_get_by_id(unitid); | 519 | if (!unit_name.compare("")) { |
2906 | 520 | unit_name = "px"; | ||
2907 | 521 | } | ||
2908 | 519 | 522 | ||
2909 | 520 | double fontsize = prefs->getInt("/tools/measure/fontsize"); | 523 | double fontsize = prefs->getInt("/tools/measure/fontsize"); |
2910 | 521 | 524 | ||
2911 | @@ -526,7 +529,7 @@ | |||
2912 | 526 | for (size_t idx = 1; idx < intersections.size(); ++idx) { | 529 | for (size_t idx = 1; idx < intersections.size(); ++idx) { |
2913 | 527 | LabelPlacement placement; | 530 | LabelPlacement placement; |
2914 | 528 | placement.lengthVal = (intersections[idx] - intersections[idx - 1]).length(); | 531 | placement.lengthVal = (intersections[idx] - intersections[idx - 1]).length(); |
2916 | 529 | sp_convert_distance(&placement.lengthVal, &sp_unit_get_by_id(SP_UNIT_PX), &unit); | 532 | placement.lengthVal = Inkscape::Util::Quantity::convert(placement.lengthVal, "px", unit_name); |
2917 | 530 | placement.offset = DIMENSION_OFFSET; | 533 | placement.offset = DIMENSION_OFFSET; |
2918 | 531 | placement.start = desktop->doc2dt( (intersections[idx - 1] + intersections[idx]) / 2 ); | 534 | placement.start = desktop->doc2dt( (intersections[idx - 1] + intersections[idx]) / 2 ); |
2919 | 532 | placement.end = placement.start - (normal * placement.offset); | 535 | placement.end = placement.start - (normal * placement.offset); |
2920 | @@ -542,7 +545,7 @@ | |||
2921 | 542 | LabelPlacement &place = *it; | 545 | LabelPlacement &place = *it; |
2922 | 543 | 546 | ||
2923 | 544 | // TODO cleanup memory, Glib::ustring, etc.: | 547 | // TODO cleanup memory, Glib::ustring, etc.: |
2925 | 545 | gchar *measure_str = g_strdup_printf("%.2f %s", place.lengthVal, unit.abbr); | 548 | gchar *measure_str = g_strdup_printf("%.2f %s", place.lengthVal, unit_name.c_str()); |
2926 | 546 | SPCanvasText *canvas_tooltip = sp_canvastext_new(sp_desktop_tempgroup(desktop), | 549 | SPCanvasText *canvas_tooltip = sp_canvastext_new(sp_desktop_tempgroup(desktop), |
2927 | 547 | desktop, | 550 | desktop, |
2928 | 548 | place.end, | 551 | place.end, |
2929 | @@ -583,10 +586,10 @@ | |||
2930 | 583 | 586 | ||
2931 | 584 | { | 587 | { |
2932 | 585 | double totallengthval = (end_point - start_point).length(); | 588 | double totallengthval = (end_point - start_point).length(); |
2934 | 586 | sp_convert_distance(&totallengthval, &sp_unit_get_by_id(SP_UNIT_PX), &unit); | 589 | totallengthval = Inkscape::Util::Quantity::convert(totallengthval, "px", unit_name); |
2935 | 587 | 590 | ||
2936 | 588 | // TODO cleanup memory, Glib::ustring, etc.: | 591 | // TODO cleanup memory, Glib::ustring, etc.: |
2938 | 589 | gchar *totallength_str = g_strdup_printf("%.2f %s", totallengthval, unit.abbr); | 592 | gchar *totallength_str = g_strdup_printf("%.2f %s", totallengthval, unit_name.c_str()); |
2939 | 590 | SPCanvasText *canvas_tooltip = sp_canvastext_new(sp_desktop_tempgroup(desktop), | 593 | SPCanvasText *canvas_tooltip = sp_canvastext_new(sp_desktop_tempgroup(desktop), |
2940 | 591 | desktop, | 594 | desktop, |
2941 | 592 | end_point + desktop->w2d(Geom::Point(3*fontsize, -fontsize)), | 595 | end_point + desktop->w2d(Geom::Point(3*fontsize, -fontsize)), |
2942 | @@ -604,10 +607,10 @@ | |||
2943 | 604 | 607 | ||
2944 | 605 | if (intersections.size() > 2) { | 608 | if (intersections.size() > 2) { |
2945 | 606 | double totallengthval = (intersections[intersections.size()-1] - intersections[0]).length(); | 609 | double totallengthval = (intersections[intersections.size()-1] - intersections[0]).length(); |
2947 | 607 | sp_convert_distance(&totallengthval, &sp_unit_get_by_id(SP_UNIT_PX), &unit); | 610 | totallengthval = Inkscape::Util::Quantity::convert(totallengthval, "px", unit_name); |
2948 | 608 | 611 | ||
2949 | 609 | // TODO cleanup memory, Glib::ustring, etc.: | 612 | // TODO cleanup memory, Glib::ustring, etc.: |
2951 | 610 | gchar *total_str = g_strdup_printf("%.2f %s", totallengthval, unit.abbr); | 613 | gchar *total_str = g_strdup_printf("%.2f %s", totallengthval, unit_name.c_str()); |
2952 | 611 | SPCanvasText *canvas_tooltip = sp_canvastext_new(sp_desktop_tempgroup(desktop), | 614 | SPCanvasText *canvas_tooltip = sp_canvastext_new(sp_desktop_tempgroup(desktop), |
2953 | 612 | desktop, | 615 | desktop, |
2954 | 613 | desktop->doc2dt((intersections[0] + intersections[intersections.size()-1])/2) + normal * 60, | 616 | desktop->doc2dt((intersections[0] + intersections[intersections.size()-1])/2) + normal * 60, |
2955 | 614 | 617 | ||
2956 | === modified file 'src/pen-context.cpp' | |||
2957 | --- src/pen-context.cpp 2013-04-28 22:48:03 +0000 | |||
2958 | +++ src/pen-context.cpp 2013-08-06 18:46:25 +0000 | |||
2959 | @@ -22,7 +22,6 @@ | |||
2960 | 22 | 22 | ||
2961 | 23 | #include "pen-context.h" | 23 | #include "pen-context.h" |
2962 | 24 | #include "sp-namedview.h" | 24 | #include "sp-namedview.h" |
2963 | 25 | #include "sp-metrics.h" | ||
2964 | 26 | #include "desktop.h" | 25 | #include "desktop.h" |
2965 | 27 | #include "desktop-handles.h" | 26 | #include "desktop-handles.h" |
2966 | 28 | #include "selection.h" | 27 | #include "selection.h" |
2967 | @@ -39,7 +38,6 @@ | |||
2968 | 39 | #include "display/sp-ctrlline.h" | 38 | #include "display/sp-ctrlline.h" |
2969 | 40 | #include "display/sodipodi-ctrl.h" | 39 | #include "display/sodipodi-ctrl.h" |
2970 | 41 | #include <glibmm/i18n.h> | 40 | #include <glibmm/i18n.h> |
2971 | 42 | #include "helper/units.h" | ||
2972 | 43 | #include "macros.h" | 41 | #include "macros.h" |
2973 | 44 | #include "context-fns.h" | 42 | #include "context-fns.h" |
2974 | 45 | #include "tools-switch.h" | 43 | #include "tools-switch.h" |
2975 | @@ -1185,11 +1183,16 @@ | |||
2976 | 1185 | 1183 | ||
2977 | 1186 | SPDesktop *desktop = SP_EVENT_CONTEXT(pc)->desktop; | 1184 | SPDesktop *desktop = SP_EVENT_CONTEXT(pc)->desktop; |
2978 | 1187 | Geom::Point rel = p - pc->p[pc_point_to_compare]; | 1185 | Geom::Point rel = p - pc->p[pc_point_to_compare]; |
2980 | 1188 | GString *dist = SP_PX_TO_METRIC_STRING(Geom::L2(rel), desktop->namedview->getDefaultMetric()); | 1186 | Inkscape::Util::Quantity q = Inkscape::Util::Quantity(Geom::L2(rel), "px"); |
2981 | 1187 | GString *dist = g_string_new(q.string(*desktop->namedview->doc_units).c_str()); | ||
2982 | 1189 | double angle = atan2(rel[Geom::Y], rel[Geom::X]) * 180 / M_PI; | 1188 | double angle = atan2(rel[Geom::Y], rel[Geom::X]) * 180 / M_PI; |
2983 | 1190 | Inkscape::Preferences *prefs = Inkscape::Preferences::get(); | 1189 | Inkscape::Preferences *prefs = Inkscape::Preferences::get(); |
2986 | 1191 | if (prefs->getBool("/options/compassangledisplay/value", 0) != 0) | 1190 | if (prefs->getBool("/options/compassangledisplay/value", 0) != 0) { |
2987 | 1192 | angle = angle_to_compass (angle); | 1191 | angle = 90 - angle; |
2988 | 1192 | if (angle < 0) { | ||
2989 | 1193 | angle += 360; | ||
2990 | 1194 | } | ||
2991 | 1195 | } | ||
2992 | 1193 | 1196 | ||
2993 | 1194 | pc->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, message, angle, dist->str); | 1197 | pc->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, message, angle, dist->str); |
2994 | 1195 | g_string_free(dist, FALSE); | 1198 | g_string_free(dist, FALSE); |
2995 | 1196 | 1199 | ||
2996 | === modified file 'src/preferences.cpp' | |||
2997 | --- src/preferences.cpp 2013-02-11 23:34:59 +0000 | |||
2998 | +++ src/preferences.cpp 2013-08-06 18:46:25 +0000 | |||
2999 | @@ -28,6 +28,8 @@ | |||
3000 | 28 | 28 | ||
3001 | 29 | #define PREFERENCES_FILE_NAME "preferences.xml" | 29 | #define PREFERENCES_FILE_NAME "preferences.xml" |
3002 | 30 | 30 | ||
3003 | 31 | using Inkscape::Util::unit_table; | ||
3004 | 32 | |||
3005 | 31 | namespace Inkscape { | 33 | namespace Inkscape { |
3006 | 32 | 34 | ||
3007 | 33 | static Inkscape::XML::Document *loadImpl( std::string const& prefsFilename, Glib::ustring & errMsg ); | 35 | static Inkscape::XML::Document *loadImpl( std::string const& prefsFilename, Glib::ustring & errMsg ); |
3008 | @@ -777,8 +779,6 @@ | |||
3009 | 777 | 779 | ||
3010 | 778 | double Preferences::_extractDouble(Entry const &v, Glib::ustring const &requested_unit) | 780 | double Preferences::_extractDouble(Entry const &v, Glib::ustring const &requested_unit) |
3011 | 779 | { | 781 | { |
3012 | 780 | static Inkscape::Util::UnitTable unit_table; // load the unit_table once by making it static | ||
3013 | 781 | |||
3014 | 782 | double val = _extractDouble(v); | 782 | double val = _extractDouble(v); |
3015 | 783 | Glib::ustring unit = _extractUnit(v); | 783 | Glib::ustring unit = _extractUnit(v); |
3016 | 784 | 784 | ||
3017 | 785 | 785 | ||
3018 | === modified file 'src/rect-context.cpp' | |||
3019 | --- src/rect-context.cpp 2013-04-28 22:48:03 +0000 | |||
3020 | +++ src/rect-context.cpp 2013-08-06 18:46:25 +0000 | |||
3021 | @@ -35,7 +35,6 @@ | |||
3022 | 35 | #include "message-context.h" | 35 | #include "message-context.h" |
3023 | 36 | #include "pixmaps/cursor-rect.xpm" | 36 | #include "pixmaps/cursor-rect.xpm" |
3024 | 37 | #include "rect-context.h" | 37 | #include "rect-context.h" |
3025 | 38 | #include "sp-metrics.h" | ||
3026 | 39 | #include <glibmm/i18n.h> | 38 | #include <glibmm/i18n.h> |
3027 | 40 | #include "xml/repr.h" | 39 | #include "xml/repr.h" |
3028 | 41 | #include "xml/node-event-vector.h" | 40 | #include "xml/node-event-vector.h" |
3029 | @@ -483,8 +482,10 @@ | |||
3030 | 483 | // status text | 482 | // status text |
3031 | 484 | double rdimx = r.dimensions()[Geom::X]; | 483 | double rdimx = r.dimensions()[Geom::X]; |
3032 | 485 | double rdimy = r.dimensions()[Geom::Y]; | 484 | double rdimy = r.dimensions()[Geom::Y]; |
3035 | 486 | GString *xs = SP_PX_TO_METRIC_STRING(rdimx, desktop->namedview->getDefaultMetric()); | 485 | Inkscape::Util::Quantity rdimx_q = Inkscape::Util::Quantity(rdimx, "px"); |
3036 | 487 | GString *ys = SP_PX_TO_METRIC_STRING(rdimy, desktop->namedview->getDefaultMetric()); | 486 | Inkscape::Util::Quantity rdimy_q = Inkscape::Util::Quantity(rdimy, "px"); |
3037 | 487 | GString *xs = g_string_new(rdimx_q.string(*desktop->namedview->doc_units).c_str()); | ||
3038 | 488 | GString *ys = g_string_new(rdimy_q.string(*desktop->namedview->doc_units).c_str()); | ||
3039 | 488 | if (state & GDK_CONTROL_MASK) { | 489 | if (state & GDK_CONTROL_MASK) { |
3040 | 489 | int ratio_x, ratio_y; | 490 | int ratio_x, ratio_y; |
3041 | 490 | bool is_golden_ratio = false; | 491 | bool is_golden_ratio = false; |
3042 | 491 | 492 | ||
3043 | === modified file 'src/selection-chemistry.cpp' | |||
3044 | --- src/selection-chemistry.cpp 2013-07-04 14:01:44 +0000 | |||
3045 | +++ src/selection-chemistry.cpp 2013-08-06 18:46:25 +0000 | |||
3046 | @@ -86,11 +86,10 @@ | |||
3047 | 86 | #include <map> | 86 | #include <map> |
3048 | 87 | #include <cstring> | 87 | #include <cstring> |
3049 | 88 | #include <string> | 88 | #include <string> |
3050 | 89 | #include "helper/units.h" | ||
3051 | 90 | #include "sp-item.h" | 89 | #include "sp-item.h" |
3052 | 91 | #include "box3d.h" | 90 | #include "box3d.h" |
3053 | 92 | #include "persp3d.h" | 91 | #include "persp3d.h" |
3055 | 93 | #include "unit-constants.h" | 92 | #include "util/units.h" |
3056 | 94 | #include "xml/simple-document.h" | 93 | #include "xml/simple-document.h" |
3057 | 95 | #include "sp-filter-reference.h" | 94 | #include "sp-filter-reference.h" |
3058 | 96 | #include "gradient-drag.h" | 95 | #include "gradient-drag.h" |
3059 | @@ -3398,7 +3397,7 @@ | |||
3060 | 3398 | res = prefs_res; | 3397 | res = prefs_res; |
3061 | 3399 | } else if (0 < prefs_min) { | 3398 | } else if (0 < prefs_min) { |
3062 | 3400 | // If minsize is given, look up minimum bitmap size (default 250 pixels) and calculate resolution from it | 3399 | // If minsize is given, look up minimum bitmap size (default 250 pixels) and calculate resolution from it |
3064 | 3401 | res = PX_PER_IN * prefs_min / MIN(bbox->width(), bbox->height()); | 3400 | res = Inkscape::Util::Quantity::convert(1, "in", "px") * prefs_min / MIN(bbox->width(), bbox->height()); |
3065 | 3402 | } else { | 3401 | } else { |
3066 | 3403 | float hint_xdpi = 0, hint_ydpi = 0; | 3402 | float hint_xdpi = 0, hint_ydpi = 0; |
3067 | 3404 | Glib::ustring hint_filename; | 3403 | Glib::ustring hint_filename; |
3068 | @@ -3413,14 +3412,14 @@ | |||
3069 | 3413 | res = hint_xdpi; | 3412 | res = hint_xdpi; |
3070 | 3414 | } else { | 3413 | } else { |
3071 | 3415 | // if all else fails, take the default 90 dpi | 3414 | // if all else fails, take the default 90 dpi |
3073 | 3416 | res = PX_PER_IN; | 3415 | res = Inkscape::Util::Quantity::convert(1, "in", "px"); |
3074 | 3417 | } | 3416 | } |
3075 | 3418 | } | 3417 | } |
3076 | 3419 | } | 3418 | } |
3077 | 3420 | 3419 | ||
3078 | 3421 | // The width and height of the bitmap in pixels | 3420 | // The width and height of the bitmap in pixels |
3081 | 3422 | unsigned width = (unsigned) floor(bbox->width() * res / PX_PER_IN); | 3421 | unsigned width = (unsigned) floor(bbox->width() * res / Inkscape::Util::Quantity::convert(1, "in", "px")); |
3082 | 3423 | unsigned height =(unsigned) floor(bbox->height() * res / PX_PER_IN); | 3422 | unsigned height =(unsigned) floor(bbox->height() * res / Inkscape::Util::Quantity::convert(1, "in", "px")); |
3083 | 3424 | 3423 | ||
3084 | 3425 | // Find out if we have to run an external filter | 3424 | // Find out if we have to run an external filter |
3085 | 3426 | gchar const *run = NULL; | 3425 | gchar const *run = NULL; |
3086 | @@ -3452,7 +3451,7 @@ | |||
3087 | 3452 | 3451 | ||
3088 | 3453 | double shift_x = bbox->min()[Geom::X]; | 3452 | double shift_x = bbox->min()[Geom::X]; |
3089 | 3454 | double shift_y = bbox->max()[Geom::Y]; | 3453 | double shift_y = bbox->max()[Geom::Y]; |
3091 | 3455 | if (res == PX_PER_IN) { // for default 90 dpi, snap it to pixel grid | 3454 | if (res == Inkscape::Util::Quantity::convert(1, "in", "px")) { // for default 90 dpi, snap it to pixel grid |
3092 | 3456 | shift_x = round(shift_x); | 3455 | shift_x = round(shift_x); |
3093 | 3457 | shift_y = -round(-shift_y); // this gets correct rounding despite coordinate inversion, remove the negations when the inversion is gone | 3456 | shift_y = -round(-shift_y); // this gets correct rounding despite coordinate inversion, remove the negations when the inversion is gone |
3094 | 3458 | } | 3457 | } |
3095 | @@ -3485,7 +3484,7 @@ | |||
3096 | 3485 | // Create the repr for the image | 3484 | // Create the repr for the image |
3097 | 3486 | Inkscape::XML::Node * repr = xml_doc->createElement("svg:image"); | 3485 | Inkscape::XML::Node * repr = xml_doc->createElement("svg:image"); |
3098 | 3487 | sp_embed_image(repr, pb, "image/png"); | 3486 | sp_embed_image(repr, pb, "image/png"); |
3100 | 3488 | if (res == PX_PER_IN) { // for default 90 dpi, snap it to pixel grid | 3487 | if (res == Inkscape::Util::Quantity::convert(1, "in", "px")) { // for default 90 dpi, snap it to pixel grid |
3101 | 3489 | sp_repr_set_svg_double(repr, "width", width); | 3488 | sp_repr_set_svg_double(repr, "width", width); |
3102 | 3490 | sp_repr_set_svg_double(repr, "height", height); | 3489 | sp_repr_set_svg_double(repr, "height", height); |
3103 | 3491 | } else { | 3490 | } else { |
3104 | 3492 | 3491 | ||
3105 | === modified file 'src/seltrans.cpp' | |||
3106 | --- src/seltrans.cpp 2013-07-03 16:59:04 +0000 | |||
3107 | +++ src/seltrans.cpp 2013-08-06 18:46:25 +0000 | |||
3108 | @@ -37,7 +37,6 @@ | |||
3109 | 37 | #include "seltrans-handles.h" | 37 | #include "seltrans-handles.h" |
3110 | 38 | #include "seltrans.h" | 38 | #include "seltrans.h" |
3111 | 39 | #include "selection-chemistry.h" | 39 | #include "selection-chemistry.h" |
3112 | 40 | #include "sp-metrics.h" | ||
3113 | 41 | #include "verbs.h" | 40 | #include "verbs.h" |
3114 | 42 | #include <glibmm/i18n.h> | 41 | #include <glibmm/i18n.h> |
3115 | 43 | #include "display/sp-ctrlline.h" | 42 | #include "display/sp-ctrlline.h" |
3116 | @@ -1273,8 +1272,10 @@ | |||
3117 | 1273 | m.unSetup(); | 1272 | m.unSetup(); |
3118 | 1274 | 1273 | ||
3119 | 1275 | // status text | 1274 | // status text |
3122 | 1276 | GString *xs = SP_PX_TO_METRIC_STRING(pt[Geom::X], _desktop->namedview->getDefaultMetric()); | 1275 | Inkscape::Util::Quantity x_q = Inkscape::Util::Quantity(pt[Geom::X], "px"); |
3123 | 1277 | GString *ys = SP_PX_TO_METRIC_STRING(pt[Geom::Y], _desktop->namedview->getDefaultMetric()); | 1276 | Inkscape::Util::Quantity y_q = Inkscape::Util::Quantity(pt[Geom::Y], "px"); |
3124 | 1277 | GString *xs = g_string_new(x_q.string(*_desktop->namedview->doc_units).c_str()); | ||
3125 | 1278 | GString *ys = g_string_new(y_q.string(*_desktop->namedview->doc_units).c_str()); | ||
3126 | 1278 | _message_context.setF(Inkscape::NORMAL_MESSAGE, _("Move <b>center</b> to %s, %s"), xs->str, ys->str); | 1279 | _message_context.setF(Inkscape::NORMAL_MESSAGE, _("Move <b>center</b> to %s, %s"), xs->str, ys->str); |
3127 | 1279 | g_string_free(xs, FALSE); | 1280 | g_string_free(xs, FALSE); |
3128 | 1280 | g_string_free(ys, FALSE); | 1281 | g_string_free(ys, FALSE); |
3129 | @@ -1425,8 +1426,10 @@ | |||
3130 | 1425 | transform(move, norm); | 1426 | transform(move, norm); |
3131 | 1426 | 1427 | ||
3132 | 1427 | // status text | 1428 | // status text |
3135 | 1428 | GString *xs = SP_PX_TO_METRIC_STRING(dxy[Geom::X], _desktop->namedview->getDefaultMetric()); | 1429 | Inkscape::Util::Quantity x_q = Inkscape::Util::Quantity(dxy[Geom::X], "px"); |
3136 | 1429 | GString *ys = SP_PX_TO_METRIC_STRING(dxy[Geom::Y], _desktop->namedview->getDefaultMetric()); | 1430 | Inkscape::Util::Quantity y_q = Inkscape::Util::Quantity(dxy[Geom::Y], "px"); |
3137 | 1431 | GString *xs = g_string_new(x_q.string(*_desktop->namedview->doc_units).c_str()); | ||
3138 | 1432 | GString *ys = g_string_new(y_q.string(*_desktop->namedview->doc_units).c_str()); | ||
3139 | 1430 | _message_context.setF(Inkscape::NORMAL_MESSAGE, _("<b>Move</b> by %s, %s; with <b>Ctrl</b> to restrict to horizontal/vertical; with <b>Shift</b> to disable snapping"), xs->str, ys->str); | 1433 | _message_context.setF(Inkscape::NORMAL_MESSAGE, _("<b>Move</b> by %s, %s; with <b>Ctrl</b> to restrict to horizontal/vertical; with <b>Shift</b> to disable snapping"), xs->str, ys->str); |
3140 | 1431 | g_string_free(xs, TRUE); | 1434 | g_string_free(xs, TRUE); |
3141 | 1432 | g_string_free(ys, TRUE); | 1435 | g_string_free(ys, TRUE); |
3142 | 1433 | 1436 | ||
3143 | === modified file 'src/snap-preferences.h' | |||
3144 | --- src/snap-preferences.h 2012-02-14 20:56:34 +0000 | |||
3145 | +++ src/snap-preferences.h 2013-08-06 18:46:25 +0000 | |||
3146 | @@ -10,7 +10,6 @@ | |||
3147 | 10 | * Released under GNU GPL, read the file 'COPYING' for more information | 10 | * Released under GNU GPL, read the file 'COPYING' for more information |
3148 | 11 | */ | 11 | */ |
3149 | 12 | 12 | ||
3150 | 13 | #include "helper/units.h" | ||
3151 | 14 | #include "snap-enums.h" | 13 | #include "snap-enums.h" |
3152 | 15 | 14 | ||
3153 | 16 | namespace Inkscape | 15 | namespace Inkscape |
3154 | 17 | 16 | ||
3155 | === modified file 'src/sp-guide.cpp' | |||
3156 | --- src/sp-guide.cpp 2013-03-02 11:29:23 +0000 | |||
3157 | +++ src/sp-guide.cpp 2013-08-06 18:46:25 +0000 | |||
3158 | @@ -35,7 +35,6 @@ | |||
3159 | 35 | #include <glibmm/i18n.h> | 35 | #include <glibmm/i18n.h> |
3160 | 36 | #include <xml/repr.h> | 36 | #include <xml/repr.h> |
3161 | 37 | #include <remove-last.h> | 37 | #include <remove-last.h> |
3162 | 38 | #include "sp-metrics.h" | ||
3163 | 39 | #include "inkscape.h" | 38 | #include "inkscape.h" |
3164 | 40 | #include "desktop.h" | 39 | #include "desktop.h" |
3165 | 41 | #include "sp-namedview.h" | 40 | #include "sp-namedview.h" |
3166 | @@ -463,10 +462,10 @@ | |||
3167 | 463 | } else { | 462 | } else { |
3168 | 464 | SPNamedView *namedview = sp_document_namedview(guide->document, NULL); | 463 | SPNamedView *namedview = sp_document_namedview(guide->document, NULL); |
3169 | 465 | 464 | ||
3174 | 466 | GString *position_string_x = SP_PX_TO_METRIC_STRING(guide->point_on_line[X], | 465 | Inkscape::Util::Quantity x_q = Inkscape::Util::Quantity(guide->point_on_line[X], "px"); |
3175 | 467 | namedview->getDefaultMetric()); | 466 | Inkscape::Util::Quantity y_q = Inkscape::Util::Quantity(guide->point_on_line[Y], "px"); |
3176 | 468 | GString *position_string_y = SP_PX_TO_METRIC_STRING(guide->point_on_line[Y], | 467 | GString *position_string_x = g_string_new(x_q.string(*namedview->doc_units).c_str()); |
3177 | 469 | namedview->getDefaultMetric()); | 468 | GString *position_string_y = g_string_new(y_q.string(*namedview->doc_units).c_str()); |
3178 | 470 | 469 | ||
3179 | 471 | gchar *shortcuts = g_strdup_printf("; %s", _("<b>Shift+drag</b> to rotate, <b>Ctrl+drag</b> to move origin, <b>Del</b> to delete")); | 470 | gchar *shortcuts = g_strdup_printf("; %s", _("<b>Shift+drag</b> to rotate, <b>Ctrl+drag</b> to move origin, <b>Del</b> to delete")); |
3180 | 472 | 471 | ||
3181 | 473 | 472 | ||
3182 | === removed file 'src/sp-metric.h' | |||
3183 | --- src/sp-metric.h 2012-10-27 18:15:53 +0000 | |||
3184 | +++ src/sp-metric.h 1970-01-01 00:00:00 +0000 | |||
3185 | @@ -1,28 +0,0 @@ | |||
3186 | 1 | #ifndef INKSCAPE_SP_METRIC_H | ||
3187 | 2 | #define INKSCAPE_SP_METRIC_H | ||
3188 | 3 | |||
3189 | 4 | /** Known metrics so far. (I don't know why this doesn't include pica.) */ | ||
3190 | 5 | enum SPMetric { | ||
3191 | 6 | SP_NONE, | ||
3192 | 7 | SP_MM, | ||
3193 | 8 | SP_CM, | ||
3194 | 9 | SP_IN, | ||
3195 | 10 | SP_FT, | ||
3196 | 11 | SP_PT, | ||
3197 | 12 | SP_PC, | ||
3198 | 13 | SP_PX, | ||
3199 | 14 | SP_M | ||
3200 | 15 | }; | ||
3201 | 16 | |||
3202 | 17 | #endif /* !INKSCAPE_SP_METRIC_H */ | ||
3203 | 18 | |||
3204 | 19 | /* | ||
3205 | 20 | Local Variables: | ||
3206 | 21 | mode:c++ | ||
3207 | 22 | c-file-style:"stroustrup" | ||
3208 | 23 | c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) | ||
3209 | 24 | indent-tabs-mode:nil | ||
3210 | 25 | fill-column:99 | ||
3211 | 26 | End: | ||
3212 | 27 | */ | ||
3213 | 28 | // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : | ||
3214 | 29 | 0 | ||
3215 | === removed file 'src/sp-metrics.cpp' | |||
3216 | --- src/sp-metrics.cpp 2012-10-27 18:15:53 +0000 | |||
3217 | +++ src/sp-metrics.cpp 1970-01-01 00:00:00 +0000 | |||
3218 | @@ -1,120 +0,0 @@ | |||
3219 | 1 | #include "sp-metrics.h" | ||
3220 | 2 | #include "unit-constants.h" | ||
3221 | 3 | |||
3222 | 4 | /* | ||
3223 | 5 | * SPMetric handling and stuff | ||
3224 | 6 | * I hope this will be usefull :-) | ||
3225 | 7 | */ | ||
3226 | 8 | |||
3227 | 9 | gdouble | ||
3228 | 10 | sp_absolute_metric_to_metric (gdouble length_src, const SPMetric metric_src, const SPMetric metric_dst) | ||
3229 | 11 | { | ||
3230 | 12 | gdouble src = 1; | ||
3231 | 13 | gdouble dst = 1; | ||
3232 | 14 | |||
3233 | 15 | switch (metric_src) { | ||
3234 | 16 | case SP_M: | ||
3235 | 17 | src = M_PER_IN; | ||
3236 | 18 | break; | ||
3237 | 19 | case SP_MM: | ||
3238 | 20 | src = MM_PER_IN; | ||
3239 | 21 | break; | ||
3240 | 22 | case SP_CM: | ||
3241 | 23 | src = CM_PER_IN; | ||
3242 | 24 | break; | ||
3243 | 25 | case SP_IN: | ||
3244 | 26 | src = IN_PER_IN; | ||
3245 | 27 | break; | ||
3246 | 28 | case SP_FT: | ||
3247 | 29 | src = FT_PER_IN; | ||
3248 | 30 | break; | ||
3249 | 31 | case SP_PT: | ||
3250 | 32 | src = PT_PER_IN; | ||
3251 | 33 | break; | ||
3252 | 34 | case SP_PC: | ||
3253 | 35 | src = PC_PER_IN; | ||
3254 | 36 | break; | ||
3255 | 37 | case SP_PX: | ||
3256 | 38 | src = PX_PER_IN; | ||
3257 | 39 | break; | ||
3258 | 40 | case SP_NONE: | ||
3259 | 41 | src = 1; | ||
3260 | 42 | break; | ||
3261 | 43 | } | ||
3262 | 44 | |||
3263 | 45 | switch (metric_dst) { | ||
3264 | 46 | case SP_M: | ||
3265 | 47 | dst = M_PER_IN; | ||
3266 | 48 | break; | ||
3267 | 49 | case SP_MM: | ||
3268 | 50 | dst = MM_PER_IN; | ||
3269 | 51 | break; | ||
3270 | 52 | case SP_CM: | ||
3271 | 53 | dst = CM_PER_IN; | ||
3272 | 54 | break; | ||
3273 | 55 | case SP_IN: | ||
3274 | 56 | dst = IN_PER_IN; | ||
3275 | 57 | break; | ||
3276 | 58 | case SP_FT: | ||
3277 | 59 | dst = FT_PER_IN; | ||
3278 | 60 | break; | ||
3279 | 61 | case SP_PT: | ||
3280 | 62 | dst = PT_PER_IN; | ||
3281 | 63 | break; | ||
3282 | 64 | case SP_PC: | ||
3283 | 65 | dst = PC_PER_IN; | ||
3284 | 66 | break; | ||
3285 | 67 | case SP_PX: | ||
3286 | 68 | dst = PX_PER_IN; | ||
3287 | 69 | break; | ||
3288 | 70 | case SP_NONE: | ||
3289 | 71 | dst = 1; | ||
3290 | 72 | break; | ||
3291 | 73 | } | ||
3292 | 74 | |||
3293 | 75 | return length_src * (dst/src); | ||
3294 | 76 | } | ||
3295 | 77 | |||
3296 | 78 | /** | ||
3297 | 79 | * Create a human-readable string suitable for status-bar display. | ||
3298 | 80 | */ | ||
3299 | 81 | GString * | ||
3300 | 82 | sp_metric_to_metric_string(gdouble const length, | ||
3301 | 83 | SPMetric const metric_src, SPMetric const metric_dst, | ||
3302 | 84 | gboolean const m) | ||
3303 | 85 | { | ||
3304 | 86 | gdouble const len = sp_absolute_metric_to_metric(length, metric_src, metric_dst); | ||
3305 | 87 | GString *str = g_string_new(""); | ||
3306 | 88 | g_string_printf(str, "%0.02f", len); | ||
3307 | 89 | /* We need a fixed number of fractional digits, because otherwise the live statusbar display of | ||
3308 | 90 | * lengths will be too jerky */ | ||
3309 | 91 | |||
3310 | 92 | if (m) { | ||
3311 | 93 | char const *unit_str; | ||
3312 | 94 | switch (metric_dst) { | ||
3313 | 95 | case SP_M: unit_str = " m"; break; | ||
3314 | 96 | case SP_MM: unit_str = " mm"; break; | ||
3315 | 97 | case SP_CM: unit_str = " cm"; break; | ||
3316 | 98 | case SP_IN: unit_str = "\""; break; | ||
3317 | 99 | case SP_PT: unit_str = " pt"; break; | ||
3318 | 100 | case SP_PX: unit_str = " px"; break; | ||
3319 | 101 | default: unit_str = NULL; break; | ||
3320 | 102 | } | ||
3321 | 103 | if (unit_str) { | ||
3322 | 104 | g_string_append(str, unit_str); | ||
3323 | 105 | } | ||
3324 | 106 | } | ||
3325 | 107 | return str; | ||
3326 | 108 | } | ||
3327 | 109 | |||
3328 | 110 | |||
3329 | 111 | /* | ||
3330 | 112 | Local Variables: | ||
3331 | 113 | mode:c++ | ||
3332 | 114 | c-file-style:"stroustrup" | ||
3333 | 115 | c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) | ||
3334 | 116 | indent-tabs-mode:nil | ||
3335 | 117 | fill-column:99 | ||
3336 | 118 | End: | ||
3337 | 119 | */ | ||
3338 | 120 | // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : | ||
3339 | 121 | 0 | ||
3340 | === removed file 'src/sp-metrics.h' | |||
3341 | --- src/sp-metrics.h 2011-12-08 11:53:54 +0000 | |||
3342 | +++ src/sp-metrics.h 1970-01-01 00:00:00 +0000 | |||
3343 | @@ -1,20 +0,0 @@ | |||
3344 | 1 | #ifndef SP_METRICS_H | ||
3345 | 2 | #define SP_METRICS_H | ||
3346 | 3 | |||
3347 | 4 | #include <glib.h> | ||
3348 | 5 | #include "sp-metric.h" | ||
3349 | 6 | |||
3350 | 7 | gdouble sp_absolute_metric_to_metric (gdouble length_src, const SPMetric metric_src, const SPMetric metric_dst); | ||
3351 | 8 | GString * sp_metric_to_metric_string (gdouble length, const SPMetric metric_src, const SPMetric metric_dst, gboolean m); | ||
3352 | 9 | |||
3353 | 10 | // convenience since we mostly deal with points | ||
3354 | 11 | #define SP_METRIC_TO_PT(l,m) sp_absolute_metric_to_metric(l,m,SP_PT); | ||
3355 | 12 | #define SP_PT_TO_METRIC(l,m) sp_absolute_metric_to_metric(l,SP_PT,m); | ||
3356 | 13 | |||
3357 | 14 | #define SP_PT_TO_METRIC_STRING(l,m) sp_metric_to_metric_string(l, SP_PT, m, TRUE) | ||
3358 | 15 | #define SP_PT_TO_STRING(l,m) sp_metric_to_metric_string(l, SP_PT, m, FALSE) | ||
3359 | 16 | |||
3360 | 17 | #define SP_PX_TO_METRIC_STRING(l,m) sp_metric_to_metric_string(l, SP_PX, m, TRUE) | ||
3361 | 18 | #define SP_PX_TO_STRING(l,m) sp_metric_to_metric_string(l, SP_PX, m, FALSE) | ||
3362 | 19 | |||
3363 | 20 | #endif | ||
3364 | 21 | 0 | ||
3365 | === modified file 'src/sp-namedview.cpp' | |||
3366 | --- src/sp-namedview.cpp 2013-05-01 07:46:46 +0000 | |||
3367 | +++ src/sp-namedview.cpp 2013-08-06 18:46:25 +0000 | |||
3368 | @@ -22,7 +22,7 @@ | |||
3369 | 22 | 22 | ||
3370 | 23 | #include "display/canvas-grid.h" | 23 | #include "display/canvas-grid.h" |
3371 | 24 | #include "display/guideline.h" | 24 | #include "display/guideline.h" |
3373 | 25 | #include "helper/units.h" | 25 | #include "util/units.h" |
3374 | 26 | #include "svg/svg-color.h" | 26 | #include "svg/svg-color.h" |
3375 | 27 | #include "xml/repr.h" | 27 | #include "xml/repr.h" |
3376 | 28 | #include "attributes.h" | 28 | #include "attributes.h" |
3377 | @@ -40,6 +40,7 @@ | |||
3378 | 40 | #include <gtkmm/window.h> | 40 | #include <gtkmm/window.h> |
3379 | 41 | 41 | ||
3380 | 42 | using Inkscape::DocumentUndo; | 42 | using Inkscape::DocumentUndo; |
3381 | 43 | using Inkscape::Util::unit_table; | ||
3382 | 43 | 44 | ||
3383 | 44 | #define DEFAULTGRIDCOLOR 0x3f3fff25 | 45 | #define DEFAULTGRIDCOLOR 0x3f3fff25 |
3384 | 45 | #define DEFAULTGRIDEMPCOLOR 0x3f3fff60 | 46 | #define DEFAULTGRIDEMPCOLOR 0x3f3fff60 |
3385 | @@ -549,18 +550,19 @@ | |||
3386 | 549 | * in that they aren't in general absolute units as currently required by | 550 | * in that they aren't in general absolute units as currently required by |
3387 | 550 | * doc_units. | 551 | * doc_units. |
3388 | 551 | */ | 552 | */ |
3390 | 552 | SPUnit const *new_unit = &sp_unit_get_by_id(SP_UNIT_PX); | 553 | static Inkscape::Util::Unit px = unit_table.getUnit("px"); |
3391 | 554 | Inkscape::Util::Unit const *new_unit = new Inkscape::Util::Unit(px); | ||
3392 | 553 | 555 | ||
3393 | 554 | if (value) { | 556 | if (value) { |
3396 | 555 | SPUnit const *const req_unit = sp_unit_get_by_abbreviation(value); | 557 | Inkscape::Util::Unit u = unit_table.getUnit(value); |
3397 | 556 | if ( req_unit == NULL ) { | 558 | Inkscape::Util::Unit const *const req_unit = new Inkscape::Util::Unit(u); |
3398 | 559 | if ( !unit_table.hasUnit(value) ) { | ||
3399 | 557 | g_warning("Unrecognized unit `%s'", value); | 560 | g_warning("Unrecognized unit `%s'", value); |
3400 | 558 | /* fixme: Document errors should be reported in the status bar or | 561 | /* fixme: Document errors should be reported in the status bar or |
3401 | 559 | * the like (e.g. as per | 562 | * the like (e.g. as per |
3402 | 560 | * http://www.w3.org/TR/SVG11/implnote.html#ErrorProcessing); g_log | 563 | * http://www.w3.org/TR/SVG11/implnote.html#ErrorProcessing); g_log |
3403 | 561 | * should be only for programmer errors. */ | 564 | * should be only for programmer errors. */ |
3406 | 562 | } else if ( req_unit->base == SP_UNIT_ABSOLUTE || | 565 | } else if ( req_unit->isAbsolute() ) { |
3405 | 563 | req_unit->base == SP_UNIT_DEVICE ) { | ||
3407 | 564 | new_unit = req_unit; | 566 | new_unit = req_unit; |
3408 | 565 | } else { | 567 | } else { |
3409 | 566 | g_warning("Document units must be absolute like `mm', `pt' or `px', but found `%s'", | 568 | g_warning("Document units must be absolute like `mm', `pt' or `px', but found `%s'", |
3410 | @@ -573,18 +575,18 @@ | |||
3411 | 573 | break; | 575 | break; |
3412 | 574 | } | 576 | } |
3413 | 575 | case SP_ATTR_UNITS: { | 577 | case SP_ATTR_UNITS: { |
3415 | 576 | SPUnit const *new_unit = NULL; | 578 | Inkscape::Util::Unit const *new_unit = NULL; |
3416 | 577 | 579 | ||
3417 | 578 | if (value) { | 580 | if (value) { |
3420 | 579 | SPUnit const *const req_unit = sp_unit_get_by_abbreviation(value); | 581 | Inkscape::Util::Unit u = unit_table.getUnit(value); |
3421 | 580 | if ( req_unit == NULL ) { | 582 | Inkscape::Util::Unit const *const req_unit = new Inkscape::Util::Unit(u); |
3422 | 583 | if ( !unit_table.hasUnit(value) ) { | ||
3423 | 581 | g_warning("Unrecognized unit `%s'", value); | 584 | g_warning("Unrecognized unit `%s'", value); |
3424 | 582 | /* fixme: Document errors should be reported in the status bar or | 585 | /* fixme: Document errors should be reported in the status bar or |
3425 | 583 | * the like (e.g. as per | 586 | * the like (e.g. as per |
3426 | 584 | * http://www.w3.org/TR/SVG11/implnote.html#ErrorProcessing); g_log | 587 | * http://www.w3.org/TR/SVG11/implnote.html#ErrorProcessing); g_log |
3427 | 585 | * should be only for programmer errors. */ | 588 | * should be only for programmer errors. */ |
3430 | 586 | } else if ( req_unit->base == SP_UNIT_ABSOLUTE || | 589 | } else if ( req_unit->isAbsolute() ) { |
3429 | 587 | req_unit->base == SP_UNIT_DEVICE ) { | ||
3431 | 588 | new_unit = req_unit; | 590 | new_unit = req_unit; |
3432 | 589 | } else { | 591 | } else { |
3433 | 590 | g_warning("Document units must be absolute like `mm', `pt' or `px', but found `%s'", | 592 | g_warning("Document units must be absolute like `mm', `pt' or `px', but found `%s'", |
3434 | @@ -1101,35 +1103,35 @@ | |||
3435 | 1101 | * \return the margin size in px, else 0.0 if anything is invalid. | 1103 | * \return the margin size in px, else 0.0 if anything is invalid. |
3436 | 1102 | */ | 1104 | */ |
3437 | 1103 | double SPNamedView::getMarginLength(gchar const * const key, | 1105 | double SPNamedView::getMarginLength(gchar const * const key, |
3440 | 1104 | SPUnit const * const margin_units, | 1106 | Inkscape::Util::Unit const * const margin_units, |
3441 | 1105 | SPUnit const * const return_units, | 1107 | Inkscape::Util::Unit const * const return_units, |
3442 | 1106 | double const width, | 1108 | double const width, |
3443 | 1107 | double const height, | 1109 | double const height, |
3444 | 1108 | bool const use_width) | 1110 | bool const use_width) |
3445 | 1109 | { | 1111 | { |
3446 | 1110 | double value; | 1112 | double value; |
3447 | 1113 | Inkscape::Util::Unit percent = unit_table.getUnit("%"); | ||
3448 | 1111 | if(!this->storeAsDouble(key,&value)) { | 1114 | if(!this->storeAsDouble(key,&value)) { |
3449 | 1112 | return 0.0; | 1115 | return 0.0; |
3450 | 1113 | } | 1116 | } |
3452 | 1114 | if (margin_units == &sp_unit_get_by_id (SP_UNIT_PERCENT)) { | 1117 | if (*margin_units == percent) { |
3453 | 1115 | return (use_width)? width * value : height * value; | 1118 | return (use_width)? width * value : height * value; |
3454 | 1116 | } | 1119 | } |
3456 | 1117 | if (!sp_convert_distance (&value, margin_units, return_units)) { | 1120 | if (!margin_units->compatibleWith(*return_units)) { |
3457 | 1118 | return 0.0; | 1121 | return 0.0; |
3458 | 1119 | } | 1122 | } |
3459 | 1120 | return value; | 1123 | return value; |
3460 | 1121 | } | 1124 | } |
3461 | 1122 | 1125 | ||
3462 | 1123 | |||
3463 | 1124 | /** | 1126 | /** |
3465 | 1125 | * Returns namedview's default metric. | 1127 | * Returns namedview's default unit. |
3466 | 1126 | */ | 1128 | */ |
3468 | 1127 | SPMetric SPNamedView::getDefaultMetric() const | 1129 | Inkscape::Util::Unit const SPNamedView::getDefaultUnit() const |
3469 | 1128 | { | 1130 | { |
3470 | 1129 | if (doc_units) { | 1131 | if (doc_units) { |
3472 | 1130 | return sp_unit_get_metric(doc_units); | 1132 | return *doc_units; |
3473 | 1131 | } else { | 1133 | } else { |
3475 | 1132 | return SP_PT; | 1134 | return *(new Inkscape::Util::Unit(unit_table.getUnit("pt"))); |
3476 | 1133 | } | 1135 | } |
3477 | 1134 | } | 1136 | } |
3478 | 1135 | 1137 | ||
3479 | 1136 | 1138 | ||
3480 | === modified file 'src/sp-namedview.h' | |||
3481 | --- src/sp-namedview.h 2013-01-23 12:22:14 +0000 | |||
3482 | +++ src/sp-namedview.h 2013-08-06 18:46:25 +0000 | |||
3483 | @@ -21,16 +21,17 @@ | |||
3484 | 21 | #define SP_IS_NAMEDVIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_NAMEDVIEW)) | 21 | #define SP_IS_NAMEDVIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), SP_TYPE_NAMEDVIEW)) |
3485 | 22 | 22 | ||
3486 | 23 | #include "sp-object-group.h" | 23 | #include "sp-object-group.h" |
3487 | 24 | #include "sp-metric.h" | ||
3488 | 25 | #include "snap.h" | 24 | #include "snap.h" |
3489 | 26 | #include "document.h" | 25 | #include "document.h" |
3490 | 26 | #include "util/units.h" | ||
3491 | 27 | 27 | ||
3492 | 28 | G_BEGIN_DECLS | 28 | G_BEGIN_DECLS |
3493 | 29 | 29 | ||
3494 | 30 | struct SPUnit; | ||
3495 | 31 | |||
3496 | 32 | namespace Inkscape { | 30 | namespace Inkscape { |
3498 | 33 | class CanvasGrid; | 31 | class CanvasGrid; |
3499 | 32 | namespace Util { | ||
3500 | 33 | class Unit; | ||
3501 | 34 | } | ||
3502 | 34 | } | 35 | } |
3503 | 35 | 36 | ||
3504 | 36 | enum { | 37 | enum { |
3505 | @@ -58,8 +59,8 @@ | |||
3506 | 58 | GSList * grids; | 59 | GSList * grids; |
3507 | 59 | bool grids_visible; | 60 | bool grids_visible; |
3508 | 60 | 61 | ||
3511 | 61 | SPUnit const *doc_units; | 62 | Inkscape::Util::Unit const *doc_units; |
3512 | 62 | SPUnit const *units; | 63 | Inkscape::Util::Unit const *units; |
3513 | 63 | 64 | ||
3514 | 64 | GQuark default_layer_id; | 65 | GQuark default_layer_id; |
3515 | 65 | 66 | ||
3516 | @@ -82,7 +83,7 @@ | |||
3517 | 82 | gchar const *getName() const; | 83 | gchar const *getName() const; |
3518 | 83 | guint getViewCount(); | 84 | guint getViewCount(); |
3519 | 84 | GSList const *getViewList() const; | 85 | GSList const *getViewList() const; |
3521 | 85 | SPMetric getDefaultMetric() const; | 86 | Inkscape::Util::Unit const getDefaultUnit() const; |
3522 | 86 | 87 | ||
3523 | 87 | void translateGuides(Geom::Translate const &translation); | 88 | void translateGuides(Geom::Translate const &translation); |
3524 | 88 | void translateGrids(Geom::Translate const &translation); | 89 | void translateGrids(Geom::Translate const &translation); |
3525 | @@ -94,7 +95,7 @@ | |||
3526 | 94 | bool getGuides(); | 95 | bool getGuides(); |
3527 | 95 | 96 | ||
3528 | 96 | private: | 97 | private: |
3530 | 97 | double getMarginLength(gchar const * const key,SPUnit const * const margin_units,SPUnit const * const return_units,double const width,double const height,bool const use_width); | 98 | double getMarginLength(gchar const * const key,Inkscape::Util::Unit const * const margin_units,Inkscape::Util::Unit const * const return_units,double const width,double const height,bool const use_width); |
3531 | 98 | friend class SPDocument; | 99 | friend class SPDocument; |
3532 | 99 | }; | 100 | }; |
3533 | 100 | 101 | ||
3534 | 101 | 102 | ||
3535 | === modified file 'src/sp-text.cpp' | |||
3536 | --- src/sp-text.cpp 2013-08-04 14:27:59 +0000 | |||
3537 | +++ src/sp-text.cpp 2013-08-06 18:46:25 +0000 | |||
3538 | @@ -43,7 +43,6 @@ | |||
3539 | 43 | #include "sp-namedview.h" | 43 | #include "sp-namedview.h" |
3540 | 44 | #include "style.h" | 44 | #include "style.h" |
3541 | 45 | #include "inkscape.h" | 45 | #include "inkscape.h" |
3542 | 46 | #include "sp-metrics.h" | ||
3543 | 47 | #include "xml/quote.h" | 46 | #include "xml/quote.h" |
3544 | 48 | #include "xml/repr.h" | 47 | #include "xml/repr.h" |
3545 | 49 | #include "mod360.h" | 48 | #include "mod360.h" |
3546 | @@ -56,7 +55,6 @@ | |||
3547 | 56 | #include "sp-tspan.h" | 55 | #include "sp-tspan.h" |
3548 | 57 | 56 | ||
3549 | 58 | #include "text-editing.h" | 57 | #include "text-editing.h" |
3550 | 59 | #include "unit-constants.h" | ||
3551 | 60 | 58 | ||
3552 | 61 | /*##################################################### | 59 | /*##################################################### |
3553 | 62 | # SPTEXT | 60 | # SPTEXT |
3554 | @@ -392,7 +390,8 @@ | |||
3555 | 392 | n = g_strdup(_("<no name found>")); | 390 | n = g_strdup(_("<no name found>")); |
3556 | 393 | } | 391 | } |
3557 | 394 | 392 | ||
3559 | 395 | GString *xs = SP_PX_TO_METRIC_STRING(style->font_size.computed, sp_desktop_namedview(SP_ACTIVE_DESKTOP)->getDefaultMetric()); | 393 | Inkscape::Util::Quantity q = Inkscape::Util::Quantity(style->font_size.computed, "px"); |
3560 | 394 | GString *xs = g_string_new(q.string(*sp_desktop_namedview(SP_ACTIVE_DESKTOP)->doc_units).c_str()); | ||
3561 | 396 | 395 | ||
3562 | 397 | char const *trunc = ""; | 396 | char const *trunc = ""; |
3563 | 398 | Inkscape::Text::Layout const *layout = te_get_layout((SPItem *) item); | 397 | Inkscape::Text::Layout const *layout = te_get_layout((SPItem *) item); |
3564 | 399 | 398 | ||
3565 | === modified file 'src/spiral-context.cpp' | |||
3566 | --- src/spiral-context.cpp 2013-04-28 22:48:03 +0000 | |||
3567 | +++ src/spiral-context.cpp 2013-08-06 18:46:25 +0000 | |||
3568 | @@ -34,7 +34,6 @@ | |||
3569 | 34 | #include "message-context.h" | 34 | #include "message-context.h" |
3570 | 35 | #include "pixmaps/cursor-spiral.xpm" | 35 | #include "pixmaps/cursor-spiral.xpm" |
3571 | 36 | #include "spiral-context.h" | 36 | #include "spiral-context.h" |
3572 | 37 | #include "sp-metrics.h" | ||
3573 | 38 | #include <glibmm/i18n.h> | 37 | #include <glibmm/i18n.h> |
3574 | 39 | #include "xml/repr.h" | 38 | #include "xml/repr.h" |
3575 | 40 | #include "xml/node-event-vector.h" | 39 | #include "xml/node-event-vector.h" |
3576 | @@ -437,7 +436,8 @@ | |||
3577 | 437 | /*t0*/ sc->t0); | 436 | /*t0*/ sc->t0); |
3578 | 438 | 437 | ||
3579 | 439 | /* status text */ | 438 | /* status text */ |
3581 | 440 | GString *rads = SP_PX_TO_METRIC_STRING(rad, desktop->namedview->getDefaultMetric()); | 439 | Inkscape::Util::Quantity q = Inkscape::Util::Quantity(rad, "px"); |
3582 | 440 | GString *rads = g_string_new(q.string(*desktop->namedview->doc_units).c_str()); | ||
3583 | 441 | sc->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, | 441 | sc->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, |
3584 | 442 | _("<b>Spiral</b>: radius %s, angle %5g°; with <b>Ctrl</b> to snap angle"), | 442 | _("<b>Spiral</b>: radius %s, angle %5g°; with <b>Ctrl</b> to snap angle"), |
3585 | 443 | rads->str, sp_round((arg + 2.0*M_PI*spiral->revo)*180/M_PI, 0.0001)); | 443 | rads->str, sp_round((arg + 2.0*M_PI*spiral->revo)*180/M_PI, 0.0001)); |
3586 | 444 | 444 | ||
3587 | === modified file 'src/star-context.cpp' | |||
3588 | --- src/star-context.cpp 2013-04-28 22:48:03 +0000 | |||
3589 | +++ src/star-context.cpp 2013-08-06 18:46:25 +0000 | |||
3590 | @@ -36,7 +36,6 @@ | |||
3591 | 36 | #include "desktop-style.h" | 36 | #include "desktop-style.h" |
3592 | 37 | #include "message-context.h" | 37 | #include "message-context.h" |
3593 | 38 | #include "pixmaps/cursor-star.xpm" | 38 | #include "pixmaps/cursor-star.xpm" |
3594 | 39 | #include "sp-metrics.h" | ||
3595 | 40 | #include <glibmm/i18n.h> | 39 | #include <glibmm/i18n.h> |
3596 | 41 | #include "preferences.h" | 40 | #include "preferences.h" |
3597 | 42 | #include "xml/repr.h" | 41 | #include "xml/repr.h" |
3598 | @@ -450,7 +449,8 @@ | |||
3599 | 450 | arg1, arg1 + M_PI / sides, sc->isflatsided, sc->rounded, sc->randomized); | 449 | arg1, arg1 + M_PI / sides, sc->isflatsided, sc->rounded, sc->randomized); |
3600 | 451 | 450 | ||
3601 | 452 | /* status text */ | 451 | /* status text */ |
3603 | 453 | GString *rads = SP_PX_TO_METRIC_STRING(r1, desktop->namedview->getDefaultMetric()); | 452 | Inkscape::Util::Quantity q = Inkscape::Util::Quantity(r1, "px"); |
3604 | 453 | GString *rads = g_string_new(q.string(*desktop->namedview->doc_units).c_str()); | ||
3605 | 454 | sc->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, | 454 | sc->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, |
3606 | 455 | ( sc->isflatsided? | 455 | ( sc->isflatsided? |
3607 | 456 | _("<b>Polygon</b>: radius %s, angle %5g°; with <b>Ctrl</b> to snap angle") | 456 | _("<b>Polygon</b>: radius %s, angle %5g°; with <b>Ctrl</b> to snap angle") |
3608 | 457 | 457 | ||
3609 | === modified file 'src/style.cpp' | |||
3610 | --- src/style.cpp 2013-08-06 17:29:13 +0000 | |||
3611 | +++ src/style.cpp 2013-08-06 18:46:25 +0000 | |||
3612 | @@ -45,7 +45,7 @@ | |||
3613 | 45 | #include "svg/css-ostringstream.h" | 45 | #include "svg/css-ostringstream.h" |
3614 | 46 | #include "xml/repr.h" | 46 | #include "xml/repr.h" |
3615 | 47 | #include "xml/simple-document.h" | 47 | #include "xml/simple-document.h" |
3617 | 48 | #include "unit-constants.h" | 48 | #include "util/units.h" |
3618 | 49 | #include "macros.h" | 49 | #include "macros.h" |
3619 | 50 | #include "preferences.h" | 50 | #include "preferences.h" |
3620 | 51 | 51 | ||
3621 | @@ -2483,11 +2483,11 @@ | |||
3622 | 2483 | 2483 | ||
3623 | 2484 | case SP_CSS_UNIT_NONE: unit_size = size; break; | 2484 | case SP_CSS_UNIT_NONE: unit_size = size; break; |
3624 | 2485 | case SP_CSS_UNIT_PX: unit_size = size; break; | 2485 | case SP_CSS_UNIT_PX: unit_size = size; break; |
3630 | 2486 | case SP_CSS_UNIT_PT: unit_size = size * PT_PER_PX; break; | 2486 | case SP_CSS_UNIT_PT: unit_size = size * Inkscape::Util::Quantity::convert(1, "px", "pt"); break; |
3631 | 2487 | case SP_CSS_UNIT_PC: unit_size = size * (PT_PER_PX / PT_PER_PC); break; | 2487 | case SP_CSS_UNIT_PC: unit_size = size * (Inkscape::Util::Quantity::convert(1, "px", "pt") / Inkscape::Util::Quantity::convert(1, "pc", "pt")); break; |
3632 | 2488 | case SP_CSS_UNIT_MM: unit_size = size * MM_PER_PX; break; | 2488 | case SP_CSS_UNIT_MM: unit_size = size * Inkscape::Util::Quantity::convert(1, "px", "mm"); break; |
3633 | 2489 | case SP_CSS_UNIT_CM: unit_size = size * CM_PER_PX; break; | 2489 | case SP_CSS_UNIT_CM: unit_size = size * Inkscape::Util::Quantity::convert(1, "px", "cm"); break; |
3634 | 2490 | case SP_CSS_UNIT_IN: unit_size = size * IN_PER_PX; break; | 2490 | case SP_CSS_UNIT_IN: unit_size = size * Inkscape::Util::Quantity::convert(1, "px", "in"); break; |
3635 | 2491 | case SP_CSS_UNIT_EM: unit_size = size / SP_CSS_FONT_SIZE_DEFAULT; break; | 2491 | case SP_CSS_UNIT_EM: unit_size = size / SP_CSS_FONT_SIZE_DEFAULT; break; |
3636 | 2492 | case SP_CSS_UNIT_EX: unit_size = size * 2.0 / SP_CSS_FONT_SIZE_DEFAULT ; break; | 2492 | case SP_CSS_UNIT_EX: unit_size = size * 2.0 / SP_CSS_FONT_SIZE_DEFAULT ; break; |
3637 | 2493 | case SP_CSS_UNIT_PERCENT: unit_size = size * 100.0 / SP_CSS_FONT_SIZE_DEFAULT; break; | 2493 | case SP_CSS_UNIT_PERCENT: unit_size = size * 100.0 / SP_CSS_FONT_SIZE_DEFAULT; break; |
3638 | @@ -3472,19 +3472,19 @@ | |||
3639 | 3472 | } else if (!strcmp(e, "pt")) { | 3472 | } else if (!strcmp(e, "pt")) { |
3640 | 3473 | /* Userspace / DEVICESCALE */ | 3473 | /* Userspace / DEVICESCALE */ |
3641 | 3474 | val->unit = SP_CSS_UNIT_PT; | 3474 | val->unit = SP_CSS_UNIT_PT; |
3643 | 3475 | val->computed = value * PX_PER_PT; | 3475 | val->computed = value * Inkscape::Util::Quantity::convert(1, "pt", "px"); |
3644 | 3476 | } else if (!strcmp(e, "pc")) { | 3476 | } else if (!strcmp(e, "pc")) { |
3645 | 3477 | val->unit = SP_CSS_UNIT_PC; | 3477 | val->unit = SP_CSS_UNIT_PC; |
3647 | 3478 | val->computed = value * PX_PER_PC; | 3478 | val->computed = value * Inkscape::Util::Quantity::convert(1, "pc", "px"); |
3648 | 3479 | } else if (!strcmp(e, "mm")) { | 3479 | } else if (!strcmp(e, "mm")) { |
3649 | 3480 | val->unit = SP_CSS_UNIT_MM; | 3480 | val->unit = SP_CSS_UNIT_MM; |
3651 | 3481 | val->computed = value * PX_PER_MM; | 3481 | val->computed = value * Inkscape::Util::Quantity::convert(1, "mm", "px"); |
3652 | 3482 | } else if (!strcmp(e, "cm")) { | 3482 | } else if (!strcmp(e, "cm")) { |
3653 | 3483 | val->unit = SP_CSS_UNIT_CM; | 3483 | val->unit = SP_CSS_UNIT_CM; |
3655 | 3484 | val->computed = value * PX_PER_CM; | 3484 | val->computed = value * Inkscape::Util::Quantity::convert(1, "cm", "px"); |
3656 | 3485 | } else if (!strcmp(e, "in")) { | 3485 | } else if (!strcmp(e, "in")) { |
3657 | 3486 | val->unit = SP_CSS_UNIT_IN; | 3486 | val->unit = SP_CSS_UNIT_IN; |
3659 | 3487 | val->computed = value * PX_PER_IN; | 3487 | val->computed = value * Inkscape::Util::Quantity::convert(1, "in", "px"); |
3660 | 3488 | } else if (!strcmp(e, "em")) { | 3488 | } else if (!strcmp(e, "em")) { |
3661 | 3489 | /* EM square */ | 3489 | /* EM square */ |
3662 | 3490 | val->unit = SP_CSS_UNIT_EM; | 3490 | val->unit = SP_CSS_UNIT_EM; |
3663 | @@ -4043,23 +4043,23 @@ | |||
3664 | 4043 | return g_strlcpy(p, os.str().c_str(), len); | 4043 | return g_strlcpy(p, os.str().c_str(), len); |
3665 | 4044 | break; | 4044 | break; |
3666 | 4045 | case SP_CSS_UNIT_PT: | 4045 | case SP_CSS_UNIT_PT: |
3668 | 4046 | os << key << ":" << val->computed * PT_PER_PX << "pt;"; | 4046 | os << key << ":" << val->computed * Inkscape::Util::Quantity::convert(1, "px", "pt") << "pt;"; |
3669 | 4047 | return g_strlcpy(p, os.str().c_str(), len); | 4047 | return g_strlcpy(p, os.str().c_str(), len); |
3670 | 4048 | break; | 4048 | break; |
3671 | 4049 | case SP_CSS_UNIT_PC: | 4049 | case SP_CSS_UNIT_PC: |
3673 | 4050 | os << key << ":" << val->computed * PT_PER_PX / 12.0 << "pc;"; | 4050 | os << key << ":" << val->computed * Inkscape::Util::Quantity::convert(1, "px", "pt") / 12.0 << "pc;"; |
3674 | 4051 | return g_strlcpy(p, os.str().c_str(), len); | 4051 | return g_strlcpy(p, os.str().c_str(), len); |
3675 | 4052 | break; | 4052 | break; |
3676 | 4053 | case SP_CSS_UNIT_MM: | 4053 | case SP_CSS_UNIT_MM: |
3678 | 4054 | os << key << ":" << val->computed * MM_PER_PX << "mm;"; | 4054 | os << key << ":" << val->computed * Inkscape::Util::Quantity::convert(1, "px", "mm") << "mm;"; |
3679 | 4055 | return g_strlcpy(p, os.str().c_str(), len); | 4055 | return g_strlcpy(p, os.str().c_str(), len); |
3680 | 4056 | break; | 4056 | break; |
3681 | 4057 | case SP_CSS_UNIT_CM: | 4057 | case SP_CSS_UNIT_CM: |
3683 | 4058 | os << key << ":" << val->computed * CM_PER_PX << "cm;"; | 4058 | os << key << ":" << val->computed * Inkscape::Util::Quantity::convert(1, "px", "cm") << "cm;"; |
3684 | 4059 | return g_strlcpy(p, os.str().c_str(), len); | 4059 | return g_strlcpy(p, os.str().c_str(), len); |
3685 | 4060 | break; | 4060 | break; |
3686 | 4061 | case SP_CSS_UNIT_IN: | 4061 | case SP_CSS_UNIT_IN: |
3688 | 4062 | os << key << ":" << val->computed * IN_PER_PX << "in;"; | 4062 | os << key << ":" << val->computed * Inkscape::Util::Quantity::convert(1, "px", "in") << "in;"; |
3689 | 4063 | return g_strlcpy(p, os.str().c_str(), len); | 4063 | return g_strlcpy(p, os.str().c_str(), len); |
3690 | 4064 | break; | 4064 | break; |
3691 | 4065 | case SP_CSS_UNIT_EM: | 4065 | case SP_CSS_UNIT_EM: |
3692 | 4066 | 4066 | ||
3693 | === modified file 'src/svg/svg-length.cpp' | |||
3694 | --- src/svg/svg-length.cpp 2011-12-08 11:53:54 +0000 | |||
3695 | +++ src/svg/svg-length.cpp 2013-08-06 18:46:25 +0000 | |||
3696 | @@ -23,7 +23,7 @@ | |||
3697 | 23 | 23 | ||
3698 | 24 | #include "svg.h" | 24 | #include "svg.h" |
3699 | 25 | #include "stringstream.h" | 25 | #include "stringstream.h" |
3701 | 26 | #include "../unit-constants.h" | 26 | #include "util/units.h" |
3702 | 27 | 27 | ||
3703 | 28 | 28 | ||
3704 | 29 | static unsigned sp_svg_length_read_lff(gchar const *str, SVGLength::Unit *unit, float *val, float *computed, char **next); | 29 | static unsigned sp_svg_length_read_lff(gchar const *str, SVGLength::Unit *unit, float *val, float *computed, char **next); |
3705 | @@ -330,6 +330,8 @@ | |||
3706 | 330 | *next = (char *) e + 1; | 330 | *next = (char *) e + 1; |
3707 | 331 | } | 331 | } |
3708 | 332 | return 1; | 332 | return 1; |
3709 | 333 | } else if (g_ascii_isspace(e[0])) { | ||
3710 | 334 | return 0; // spaces are not allowed | ||
3711 | 333 | } else { | 335 | } else { |
3712 | 334 | /* Unitless */ | 336 | /* Unitless */ |
3713 | 335 | if (unit) { | 337 | if (unit) { |
3714 | @@ -365,7 +367,7 @@ | |||
3715 | 365 | *unit = SVGLength::PT; | 367 | *unit = SVGLength::PT; |
3716 | 366 | } | 368 | } |
3717 | 367 | if (computed) { | 369 | if (computed) { |
3719 | 368 | *computed = v * PX_PER_PT; | 370 | *computed = v * Inkscape::Util::Quantity::convert(1, "pt", "px"); |
3720 | 369 | } | 371 | } |
3721 | 370 | break; | 372 | break; |
3722 | 371 | case UVAL('p','c'): | 373 | case UVAL('p','c'): |
3723 | @@ -373,7 +375,7 @@ | |||
3724 | 373 | *unit = SVGLength::PC; | 375 | *unit = SVGLength::PC; |
3725 | 374 | } | 376 | } |
3726 | 375 | if (computed) { | 377 | if (computed) { |
3728 | 376 | *computed = v * PX_PER_PC; | 378 | *computed = v * Inkscape::Util::Quantity::convert(1, "pc", "px"); |
3729 | 377 | } | 379 | } |
3730 | 378 | break; | 380 | break; |
3731 | 379 | case UVAL('m','m'): | 381 | case UVAL('m','m'): |
3732 | @@ -381,7 +383,7 @@ | |||
3733 | 381 | *unit = SVGLength::MM; | 383 | *unit = SVGLength::MM; |
3734 | 382 | } | 384 | } |
3735 | 383 | if (computed) { | 385 | if (computed) { |
3737 | 384 | *computed = v * PX_PER_MM; | 386 | *computed = v * Inkscape::Util::Quantity::convert(1, "mm", "px"); |
3738 | 385 | } | 387 | } |
3739 | 386 | break; | 388 | break; |
3740 | 387 | case UVAL('c','m'): | 389 | case UVAL('c','m'): |
3741 | @@ -389,7 +391,7 @@ | |||
3742 | 389 | *unit = SVGLength::CM; | 391 | *unit = SVGLength::CM; |
3743 | 390 | } | 392 | } |
3744 | 391 | if (computed) { | 393 | if (computed) { |
3746 | 392 | *computed = v * PX_PER_CM; | 394 | *computed = v * Inkscape::Util::Quantity::convert(1, "cm", "px"); |
3747 | 393 | } | 395 | } |
3748 | 394 | break; | 396 | break; |
3749 | 395 | case UVAL('i','n'): | 397 | case UVAL('i','n'): |
3750 | @@ -397,7 +399,7 @@ | |||
3751 | 397 | *unit = SVGLength::INCH; | 399 | *unit = SVGLength::INCH; |
3752 | 398 | } | 400 | } |
3753 | 399 | if (computed) { | 401 | if (computed) { |
3755 | 400 | *computed = v * PX_PER_IN; | 402 | *computed = v * Inkscape::Util::Quantity::convert(1, "in", "px"); |
3756 | 401 | } | 403 | } |
3757 | 402 | break; | 404 | break; |
3758 | 403 | case UVAL('f','t'): | 405 | case UVAL('f','t'): |
3759 | @@ -405,7 +407,7 @@ | |||
3760 | 405 | *unit = SVGLength::FOOT; | 407 | *unit = SVGLength::FOOT; |
3761 | 406 | } | 408 | } |
3762 | 407 | if (computed) { | 409 | if (computed) { |
3764 | 408 | *computed = v * PX_PER_FT; | 410 | *computed = v * Inkscape::Util::Quantity::convert(1, "ft", "px"); |
3765 | 409 | } | 411 | } |
3766 | 410 | break; | 412 | break; |
3767 | 411 | case UVAL('e','m'): | 413 | case UVAL('e','m'): |
3768 | 412 | 414 | ||
3769 | === modified file 'src/text-context.cpp' | |||
3770 | --- src/text-context.cpp 2013-05-12 10:22:42 +0000 | |||
3771 | +++ src/text-context.cpp 2013-08-06 18:46:25 +0000 | |||
3772 | @@ -42,7 +42,6 @@ | |||
3773 | 42 | #include "selection.h" | 42 | #include "selection.h" |
3774 | 43 | #include "shape-editor.h" | 43 | #include "shape-editor.h" |
3775 | 44 | #include "sp-flowtext.h" | 44 | #include "sp-flowtext.h" |
3776 | 45 | #include "sp-metrics.h" | ||
3777 | 46 | #include "sp-namedview.h" | 45 | #include "sp-namedview.h" |
3778 | 47 | #include "sp-text.h" | 46 | #include "sp-text.h" |
3779 | 48 | #include "style.h" | 47 | #include "style.h" |
3780 | @@ -640,8 +639,10 @@ | |||
3781 | 640 | gobble_motion_events(GDK_BUTTON1_MASK); | 639 | gobble_motion_events(GDK_BUTTON1_MASK); |
3782 | 641 | 640 | ||
3783 | 642 | // status text | 641 | // status text |
3786 | 643 | GString *xs = SP_PX_TO_METRIC_STRING(fabs((p - tc->p0)[Geom::X]), desktop->namedview->getDefaultMetric()); | 642 | Inkscape::Util::Quantity x_q = Inkscape::Util::Quantity(fabs((p - tc->p0)[Geom::X]), "px"); |
3787 | 644 | GString *ys = SP_PX_TO_METRIC_STRING(fabs((p - tc->p0)[Geom::Y]), desktop->namedview->getDefaultMetric()); | 643 | Inkscape::Util::Quantity y_q = Inkscape::Util::Quantity(fabs((p - tc->p0)[Geom::Y]), "px"); |
3788 | 644 | GString *xs = g_string_new(x_q.string(*desktop->namedview->doc_units).c_str()); | ||
3789 | 645 | GString *ys = g_string_new(y_q.string(*desktop->namedview->doc_units).c_str()); | ||
3790 | 645 | event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("<b>Flowed text frame</b>: %s × %s"), xs->str, ys->str); | 646 | event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("<b>Flowed text frame</b>: %s × %s"), xs->str, ys->str); |
3791 | 646 | g_string_free(xs, FALSE); | 647 | g_string_free(xs, FALSE); |
3792 | 647 | g_string_free(ys, FALSE); | 648 | g_string_free(ys, FALSE); |
3793 | 648 | 649 | ||
3794 | === modified file 'src/text-editing.cpp' | |||
3795 | --- src/text-editing.cpp 2013-03-16 19:42:47 +0000 | |||
3796 | +++ src/text-editing.cpp 2013-08-06 18:46:25 +0000 | |||
3797 | @@ -24,7 +24,7 @@ | |||
3798 | 24 | #include "inkscape.h" | 24 | #include "inkscape.h" |
3799 | 25 | #include "message-stack.h" | 25 | #include "message-stack.h" |
3800 | 26 | #include "style.h" | 26 | #include "style.h" |
3802 | 27 | #include "unit-constants.h" | 27 | #include "util/units.h" |
3803 | 28 | 28 | ||
3804 | 29 | #include "document.h" | 29 | #include "document.h" |
3805 | 30 | #include "xml/repr.h" | 30 | #include "xml/repr.h" |
3806 | @@ -1278,23 +1278,23 @@ | |||
3807 | 1278 | style->line_height.value = style->line_height.computed; | 1278 | style->line_height.value = style->line_height.computed; |
3808 | 1279 | break; | 1279 | break; |
3809 | 1280 | case SP_CSS_UNIT_PT: | 1280 | case SP_CSS_UNIT_PT: |
3811 | 1281 | style->line_height.computed += zby * PT_PER_PX; | 1281 | style->line_height.computed += zby * Inkscape::Util::Quantity::convert(1, "px", "pt"); |
3812 | 1282 | style->line_height.value = style->line_height.computed; | 1282 | style->line_height.value = style->line_height.computed; |
3813 | 1283 | break; | 1283 | break; |
3814 | 1284 | case SP_CSS_UNIT_PC: | 1284 | case SP_CSS_UNIT_PC: |
3816 | 1285 | style->line_height.computed += zby * (PT_PER_PX / 12); | 1285 | style->line_height.computed += zby * (Inkscape::Util::Quantity::convert(1, "px", "pt") / 12); |
3817 | 1286 | style->line_height.value = style->line_height.computed; | 1286 | style->line_height.value = style->line_height.computed; |
3818 | 1287 | break; | 1287 | break; |
3819 | 1288 | case SP_CSS_UNIT_MM: | 1288 | case SP_CSS_UNIT_MM: |
3821 | 1289 | style->line_height.computed += zby * MM_PER_PX; | 1289 | style->line_height.computed += zby * Inkscape::Util::Quantity::convert(1, "px", "mm"); |
3822 | 1290 | style->line_height.value = style->line_height.computed; | 1290 | style->line_height.value = style->line_height.computed; |
3823 | 1291 | break; | 1291 | break; |
3824 | 1292 | case SP_CSS_UNIT_CM: | 1292 | case SP_CSS_UNIT_CM: |
3826 | 1293 | style->line_height.computed += zby * CM_PER_PX; | 1293 | style->line_height.computed += zby * Inkscape::Util::Quantity::convert(1, "px", "cm"); |
3827 | 1294 | style->line_height.value = style->line_height.computed; | 1294 | style->line_height.value = style->line_height.computed; |
3828 | 1295 | break; | 1295 | break; |
3829 | 1296 | case SP_CSS_UNIT_IN: | 1296 | case SP_CSS_UNIT_IN: |
3831 | 1297 | style->line_height.computed += zby * IN_PER_PX; | 1297 | style->line_height.computed += zby * Inkscape::Util::Quantity::convert(1, "px", "in"); |
3832 | 1298 | style->line_height.value = style->line_height.computed; | 1298 | style->line_height.value = style->line_height.computed; |
3833 | 1299 | break; | 1299 | break; |
3834 | 1300 | } | 1300 | } |
3835 | 1301 | 1301 | ||
3836 | === modified file 'src/ui/CMakeLists.txt' | |||
3837 | --- src/ui/CMakeLists.txt 2013-07-23 10:54:01 +0000 | |||
3838 | +++ src/ui/CMakeLists.txt 2013-08-06 18:46:25 +0000 | |||
3839 | @@ -112,6 +112,7 @@ | |||
3840 | 112 | widget/text.cpp | 112 | widget/text.cpp |
3841 | 113 | widget/tolerance-slider.cpp | 113 | widget/tolerance-slider.cpp |
3842 | 114 | widget/unit-menu.cpp | 114 | widget/unit-menu.cpp |
3843 | 115 | widget/unit-tracker.cpp | ||
3844 | 115 | 116 | ||
3845 | 116 | view/view.cpp | 117 | view/view.cpp |
3846 | 117 | view/view-widget.cpp | 118 | view/view-widget.cpp |
3847 | @@ -240,6 +241,7 @@ | |||
3848 | 240 | widget/text.h | 241 | widget/text.h |
3849 | 241 | widget/tolerance-slider.h | 242 | widget/tolerance-slider.h |
3850 | 242 | widget/unit-menu.h | 243 | widget/unit-menu.h |
3851 | 244 | widget/unit-tracker.h | ||
3852 | 243 | 245 | ||
3853 | 244 | view/edit-widget-interface.h | 246 | view/edit-widget-interface.h |
3854 | 245 | view/view-widget.h | 247 | view/view-widget.h |
3855 | 246 | 248 | ||
3856 | === modified file 'src/ui/clipboard.cpp' | |||
3857 | --- src/ui/clipboard.cpp 2013-04-21 00:16:01 +0000 | |||
3858 | +++ src/ui/clipboard.cpp 2013-08-06 18:46:25 +0000 | |||
3859 | @@ -79,7 +79,7 @@ | |||
3860 | 79 | #include "text-editing.h" | 79 | #include "text-editing.h" |
3861 | 80 | #include "tools-switch.h" | 80 | #include "tools-switch.h" |
3862 | 81 | #include "path-chemistry.h" | 81 | #include "path-chemistry.h" |
3864 | 82 | #include "unit-constants.h" | 82 | #include "util/units.h" |
3865 | 83 | #include "helper/png-write.h" | 83 | #include "helper/png-write.h" |
3866 | 84 | #include "svg/svg-color.h" | 84 | #include "svg/svg-color.h" |
3867 | 85 | #include "sp-namedview.h" | 85 | #include "sp-namedview.h" |
3868 | @@ -1078,14 +1078,14 @@ | |||
3869 | 1078 | try { | 1078 | try { |
3870 | 1079 | if (out == outlist.end() && target == "image/png") | 1079 | if (out == outlist.end() && target == "image/png") |
3871 | 1080 | { | 1080 | { |
3873 | 1081 | gdouble dpi = PX_PER_IN; | 1081 | gdouble dpi = Inkscape::Util::Quantity::convert(1, "in", "px"); |
3874 | 1082 | guint32 bgcolor = 0x00000000; | 1082 | guint32 bgcolor = 0x00000000; |
3875 | 1083 | 1083 | ||
3876 | 1084 | Geom::Point origin (_clipboardSPDoc->getRoot()->x.computed, _clipboardSPDoc->getRoot()->y.computed); | 1084 | Geom::Point origin (_clipboardSPDoc->getRoot()->x.computed, _clipboardSPDoc->getRoot()->y.computed); |
3877 | 1085 | Geom::Rect area = Geom::Rect(origin, origin + _clipboardSPDoc->getDimensions()); | 1085 | Geom::Rect area = Geom::Rect(origin, origin + _clipboardSPDoc->getDimensions()); |
3878 | 1086 | 1086 | ||
3881 | 1087 | unsigned long int width = (unsigned long int) (area.width() * dpi / PX_PER_IN + 0.5); | 1087 | unsigned long int width = (unsigned long int) (area.width() * dpi / Inkscape::Util::Quantity::convert(1, "in", "px") + 0.5); |
3882 | 1088 | unsigned long int height = (unsigned long int) (area.height() * dpi / PX_PER_IN + 0.5); | 1088 | unsigned long int height = (unsigned long int) (area.height() * dpi / Inkscape::Util::Quantity::convert(1, "in", "px") + 0.5); |
3883 | 1089 | 1089 | ||
3884 | 1090 | // read from namedview | 1090 | // read from namedview |
3885 | 1091 | Inkscape::XML::Node *nv = sp_repr_lookup_name (_clipboardSPDoc->rroot, "sodipodi:namedview"); | 1091 | Inkscape::XML::Node *nv = sp_repr_lookup_name (_clipboardSPDoc->rroot, "sodipodi:namedview"); |
3886 | 1092 | 1092 | ||
3887 | === modified file 'src/ui/dialog/clonetiler.cpp' | |||
3888 | --- src/ui/dialog/clonetiler.cpp 2013-03-29 11:00:19 +0000 | |||
3889 | +++ src/ui/dialog/clonetiler.cpp 2013-08-06 18:46:25 +0000 | |||
3890 | @@ -34,8 +34,8 @@ | |||
3891 | 34 | #include "document.h" | 34 | #include "document.h" |
3892 | 35 | #include "document-undo.h" | 35 | #include "document-undo.h" |
3893 | 36 | #include "filter-chemistry.h" | 36 | #include "filter-chemistry.h" |
3896 | 37 | #include "helper/unit-menu.h" | 37 | #include "ui/widget/unit-menu.h" |
3897 | 38 | #include "helper/units.h" | 38 | #include "util/units.h" |
3898 | 39 | #include "helper/window.h" | 39 | #include "helper/window.h" |
3899 | 40 | #include "inkscape.h" | 40 | #include "inkscape.h" |
3900 | 41 | #include "interface.h" | 41 | #include "interface.h" |
3901 | @@ -58,6 +58,7 @@ | |||
3902 | 58 | #include "sp-root.h" | 58 | #include "sp-root.h" |
3903 | 59 | 59 | ||
3904 | 60 | using Inkscape::DocumentUndo; | 60 | using Inkscape::DocumentUndo; |
3905 | 61 | using Inkscape::Util::unit_table; | ||
3906 | 61 | 62 | ||
3907 | 62 | namespace Inkscape { | 63 | namespace Inkscape { |
3908 | 63 | namespace UI { | 64 | namespace UI { |
3909 | @@ -1092,35 +1093,36 @@ | |||
3910 | 1092 | g_object_set_data (G_OBJECT(dlg), "widthheight", (gpointer) hb); | 1093 | g_object_set_data (G_OBJECT(dlg), "widthheight", (gpointer) hb); |
3911 | 1093 | 1094 | ||
3912 | 1094 | // unitmenu | 1095 | // unitmenu |
3915 | 1095 | GtkWidget *u = sp_unit_selector_new (SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE); | 1096 | unit_menu = new Inkscape::UI::Widget::UnitMenu(); |
3916 | 1096 | sp_unit_selector_set_unit (SP_UNIT_SELECTOR(u), sp_desktop_namedview(SP_ACTIVE_DESKTOP)->doc_units); | 1097 | unit_menu->setUnitType(Inkscape::Util::UNIT_TYPE_LINEAR); |
3917 | 1098 | unit_menu->setUnit(sp_desktop_namedview(SP_ACTIVE_DESKTOP)->doc_units->abbr); | ||
3918 | 1099 | unitChangedConn = unit_menu->signal_changed().connect(sigc::mem_fun(*this, &CloneTiler::clonetiler_unit_changed)); | ||
3919 | 1097 | 1100 | ||
3920 | 1098 | { | 1101 | { |
3921 | 1099 | // Width spinbutton | 1102 | // Width spinbutton |
3922 | 1100 | #if WITH_GTKMM_3_0 | 1103 | #if WITH_GTKMM_3_0 |
3924 | 1101 | Glib::RefPtr<Gtk::Adjustment> a = Gtk::Adjustment::create(0.0, -1e6, 1e6, 1.0, 10.0, 0); | 1104 | fill_width = Gtk::Adjustment::create(0.0, -1e6, 1e6, 1.0, 10.0, 0); |
3925 | 1102 | #else | 1105 | #else |
3927 | 1103 | Gtk::Adjustment *a = new Gtk::Adjustment (0.0, -1e6, 1e6, 1.0, 10.0, 0); | 1106 | fill_width = new Gtk::Adjustment (0.0, -1e6, 1e6, 1.0, 10.0, 0); |
3928 | 1104 | #endif | 1107 | #endif |
3929 | 1105 | sp_unit_selector_add_adjustment (SP_UNIT_SELECTOR (u), GTK_ADJUSTMENT (a->gobj())); | ||
3930 | 1106 | 1108 | ||
3931 | 1107 | double value = prefs->getDouble(prefs_path + "fillwidth", 50.0); | 1109 | double value = prefs->getDouble(prefs_path + "fillwidth", 50.0); |
3935 | 1108 | SPUnit const &unit = *sp_unit_selector_get_unit(SP_UNIT_SELECTOR(u)); | 1110 | Inkscape::Util::Unit const unit = unit_menu->getUnit(); |
3936 | 1109 | gdouble const units = sp_pixels_get_units (value, unit); | 1111 | gdouble const units = Inkscape::Util::Quantity::convert(value, "px", unit); |
3937 | 1110 | a->set_value (units); | 1112 | fill_width->set_value (units); |
3938 | 1111 | 1113 | ||
3939 | 1112 | #if WITH_GTKMM_3_0 | 1114 | #if WITH_GTKMM_3_0 |
3941 | 1113 | Inkscape::UI::Widget::SpinButton *e = new Inkscape::UI::Widget::SpinButton(a, 1.0, 2); | 1115 | Inkscape::UI::Widget::SpinButton *e = new Inkscape::UI::Widget::SpinButton(fill_width, 1.0, 2); |
3942 | 1114 | #else | 1116 | #else |
3944 | 1115 | Inkscape::UI::Widget::SpinButton *e = new Inkscape::UI::Widget::SpinButton (*a, 1.0, 2); | 1117 | Inkscape::UI::Widget::SpinButton *e = new Inkscape::UI::Widget::SpinButton (*fill_width, 1.0, 2); |
3945 | 1116 | #endif | 1118 | #endif |
3946 | 1117 | e->set_tooltip_text (_("Width of the rectangle to be filled")); | 1119 | e->set_tooltip_text (_("Width of the rectangle to be filled")); |
3947 | 1118 | e->set_width_chars (7); | 1120 | e->set_width_chars (7); |
3948 | 1119 | e->set_digits (4); | 1121 | e->set_digits (4); |
3949 | 1120 | gtk_box_pack_start (GTK_BOX (hb), GTK_WIDGET(e->gobj()), TRUE, TRUE, 0); | 1122 | gtk_box_pack_start (GTK_BOX (hb), GTK_WIDGET(e->gobj()), TRUE, TRUE, 0); |
3950 | 1121 | // TODO: C++ification | 1123 | // TODO: C++ification |
3953 | 1122 | g_signal_connect(G_OBJECT(a->gobj()), "value_changed", | 1124 | g_signal_connect(G_OBJECT(fill_width->gobj()), "value_changed", |
3954 | 1123 | G_CALLBACK(clonetiler_fill_width_changed), u); | 1125 | G_CALLBACK(clonetiler_fill_width_changed), unit_menu); |
3955 | 1124 | } | 1126 | } |
3956 | 1125 | { | 1127 | { |
3957 | 1126 | GtkWidget *l = gtk_label_new (""); | 1128 | GtkWidget *l = gtk_label_new (""); |
3958 | @@ -1132,32 +1134,31 @@ | |||
3959 | 1132 | { | 1134 | { |
3960 | 1133 | // Height spinbutton | 1135 | // Height spinbutton |
3961 | 1134 | #if WITH_GTKMM_3_0 | 1136 | #if WITH_GTKMM_3_0 |
3963 | 1135 | Glib::RefPtr<Gtk::Adjustment> a = Gtk::Adjustment::create(0.0, -1e6, 1e6, 1.0, 10.0, 0); | 1137 | fill_height = Gtk::Adjustment::create(0.0, -1e6, 1e6, 1.0, 10.0, 0); |
3964 | 1136 | #else | 1138 | #else |
3966 | 1137 | Gtk::Adjustment *a = new Gtk::Adjustment (0.0, -1e6, 1e6, 1.0, 10.0, 0); | 1139 | fill_height = new Gtk::Adjustment (0.0, -1e6, 1e6, 1.0, 10.0, 0); |
3967 | 1138 | #endif | 1140 | #endif |
3968 | 1139 | sp_unit_selector_add_adjustment (SP_UNIT_SELECTOR (u), GTK_ADJUSTMENT (a->gobj())); | ||
3969 | 1140 | 1141 | ||
3970 | 1141 | double value = prefs->getDouble(prefs_path + "fillheight", 50.0); | 1142 | double value = prefs->getDouble(prefs_path + "fillheight", 50.0); |
3974 | 1142 | SPUnit const &unit = *sp_unit_selector_get_unit(SP_UNIT_SELECTOR(u)); | 1143 | Inkscape::Util::Unit const unit = unit_menu->getUnit(); |
3975 | 1143 | gdouble const units = sp_pixels_get_units (value, unit); | 1144 | gdouble const units = Inkscape::Util::Quantity::convert(value, "px", unit); |
3976 | 1144 | a->set_value (units); | 1145 | fill_height->set_value (units); |
3977 | 1145 | 1146 | ||
3978 | 1146 | #if WITH_GTKMM_3_0 | 1147 | #if WITH_GTKMM_3_0 |
3980 | 1147 | Inkscape::UI::Widget::SpinButton *e = new Inkscape::UI::Widget::SpinButton(a, 1.0, 2); | 1148 | Inkscape::UI::Widget::SpinButton *e = new Inkscape::UI::Widget::SpinButton(fill_height, 1.0, 2); |
3981 | 1148 | #else | 1149 | #else |
3983 | 1149 | Inkscape::UI::Widget::SpinButton *e = new Inkscape::UI::Widget::SpinButton (*a, 1.0, 2); | 1150 | Inkscape::UI::Widget::SpinButton *e = new Inkscape::UI::Widget::SpinButton (*fill_height, 1.0, 2); |
3984 | 1150 | #endif | 1151 | #endif |
3985 | 1151 | e->set_tooltip_text (_("Height of the rectangle to be filled")); | 1152 | e->set_tooltip_text (_("Height of the rectangle to be filled")); |
3986 | 1152 | e->set_width_chars (7); | 1153 | e->set_width_chars (7); |
3987 | 1153 | e->set_digits (4); | 1154 | e->set_digits (4); |
3988 | 1154 | gtk_box_pack_start (GTK_BOX (hb), GTK_WIDGET(e->gobj()), TRUE, TRUE, 0); | 1155 | gtk_box_pack_start (GTK_BOX (hb), GTK_WIDGET(e->gobj()), TRUE, TRUE, 0); |
3989 | 1155 | // TODO: C++ification | 1156 | // TODO: C++ification |
3992 | 1156 | g_signal_connect(G_OBJECT(a->gobj()), "value_changed", | 1157 | g_signal_connect(G_OBJECT(fill_height->gobj()), "value_changed", |
3993 | 1157 | G_CALLBACK(clonetiler_fill_height_changed), u); | 1158 | G_CALLBACK(clonetiler_fill_height_changed), unit_menu); |
3994 | 1158 | } | 1159 | } |
3995 | 1159 | 1160 | ||
3997 | 1160 | gtk_box_pack_start (GTK_BOX (hb), u, TRUE, TRUE, 0); | 1161 | gtk_box_pack_start (GTK_BOX (hb), (GtkWidget*) unit_menu->gobj(), TRUE, TRUE, 0); |
3998 | 1161 | clonetiler_table_attach (table, hb, 0.0, 2, 2); | 1162 | clonetiler_table_attach (table, hb, 0.0, 2, 2); |
3999 | 1162 | 1163 | ||
4000 | 1163 | } | 1164 | } |
4001 | @@ -2944,26 +2945,39 @@ | |||
4002 | 2944 | 2945 | ||
4003 | 2945 | 2946 | ||
4004 | 2946 | 2947 | ||
4006 | 2947 | void CloneTiler::clonetiler_fill_width_changed(GtkAdjustment *adj, GtkWidget *u) | 2948 | void CloneTiler::clonetiler_fill_width_changed(GtkAdjustment *adj, Inkscape::UI::Widget::UnitMenu *u) |
4007 | 2948 | { | 2949 | { |
4008 | 2949 | gdouble const raw_dist = gtk_adjustment_get_value (adj); | 2950 | gdouble const raw_dist = gtk_adjustment_get_value (adj); |
4011 | 2950 | SPUnit const &unit = *sp_unit_selector_get_unit(SP_UNIT_SELECTOR(u)); | 2951 | Inkscape::Util::Unit const unit = u->getUnit(); |
4012 | 2951 | gdouble const pixels = sp_units_get_pixels (raw_dist, unit); | 2952 | gdouble const pixels = Inkscape::Util::Quantity::convert(raw_dist, unit, "px"); |
4013 | 2952 | 2953 | ||
4014 | 2953 | Inkscape::Preferences *prefs = Inkscape::Preferences::get(); | 2954 | Inkscape::Preferences *prefs = Inkscape::Preferences::get(); |
4015 | 2954 | prefs->setDouble(prefs_path + "fillwidth", pixels); | 2955 | prefs->setDouble(prefs_path + "fillwidth", pixels); |
4016 | 2955 | } | 2956 | } |
4017 | 2956 | 2957 | ||
4019 | 2957 | void CloneTiler::clonetiler_fill_height_changed(GtkAdjustment *adj, GtkWidget *u) | 2958 | void CloneTiler::clonetiler_fill_height_changed(GtkAdjustment *adj, Inkscape::UI::Widget::UnitMenu *u) |
4020 | 2958 | { | 2959 | { |
4021 | 2959 | gdouble const raw_dist = gtk_adjustment_get_value (adj); | 2960 | gdouble const raw_dist = gtk_adjustment_get_value (adj); |
4024 | 2960 | SPUnit const &unit = *sp_unit_selector_get_unit(SP_UNIT_SELECTOR(u)); | 2961 | Inkscape::Util::Unit const unit = u->getUnit(); |
4025 | 2961 | gdouble const pixels = sp_units_get_pixels (raw_dist, unit); | 2962 | gdouble const pixels = Inkscape::Util::Quantity::convert(raw_dist, unit, "px"); |
4026 | 2962 | 2963 | ||
4027 | 2963 | Inkscape::Preferences *prefs = Inkscape::Preferences::get(); | 2964 | Inkscape::Preferences *prefs = Inkscape::Preferences::get(); |
4028 | 2964 | prefs->setDouble(prefs_path + "fillheight", pixels); | 2965 | prefs->setDouble(prefs_path + "fillheight", pixels); |
4029 | 2965 | } | 2966 | } |
4030 | 2966 | 2967 | ||
4031 | 2968 | void CloneTiler::clonetiler_unit_changed() | ||
4032 | 2969 | { | ||
4033 | 2970 | Inkscape::Preferences *prefs = Inkscape::Preferences::get(); | ||
4034 | 2971 | gdouble width_pixels = prefs->getDouble(prefs_path + "fillwidth"); | ||
4035 | 2972 | gdouble height_pixels = prefs->getDouble(prefs_path + "fillheight"); | ||
4036 | 2973 | |||
4037 | 2974 | Inkscape::Util::Unit unit = unit_menu->getUnit(); | ||
4038 | 2975 | |||
4039 | 2976 | gdouble width_value = Inkscape::Util::Quantity::convert(width_pixels, "px", unit); | ||
4040 | 2977 | gdouble height_value = Inkscape::Util::Quantity::convert(height_pixels, "px", unit); | ||
4041 | 2978 | gtk_adjustment_set_value(fill_width->gobj(), width_value); | ||
4042 | 2979 | gtk_adjustment_set_value(fill_height->gobj(), height_value); | ||
4043 | 2980 | } | ||
4044 | 2967 | 2981 | ||
4045 | 2968 | void CloneTiler::clonetiler_do_pick_toggled(GtkToggleButton *tb, GtkWidget *dlg) | 2982 | void CloneTiler::clonetiler_do_pick_toggled(GtkToggleButton *tb, GtkWidget *dlg) |
4046 | 2969 | { | 2983 | { |
4047 | @@ -2977,7 +2991,6 @@ | |||
4048 | 2977 | } | 2991 | } |
4049 | 2978 | } | 2992 | } |
4050 | 2979 | 2993 | ||
4051 | 2980 | |||
4052 | 2981 | } | 2994 | } |
4053 | 2982 | } | 2995 | } |
4054 | 2983 | } | 2996 | } |
4055 | 2984 | 2997 | ||
4056 | === modified file 'src/ui/dialog/clonetiler.h' | |||
4057 | --- src/ui/dialog/clonetiler.h 2013-03-29 11:00:19 +0000 | |||
4058 | +++ src/ui/dialog/clonetiler.h 2013-08-06 18:46:25 +0000 | |||
4059 | @@ -19,6 +19,11 @@ | |||
4060 | 19 | 19 | ||
4061 | 20 | namespace Inkscape { | 20 | namespace Inkscape { |
4062 | 21 | namespace UI { | 21 | namespace UI { |
4063 | 22 | |||
4064 | 23 | namespace Widget { | ||
4065 | 24 | class UnitMenu; | ||
4066 | 25 | } | ||
4067 | 26 | |||
4068 | 22 | namespace Dialog { | 27 | namespace Dialog { |
4069 | 23 | 28 | ||
4070 | 24 | class CloneTiler : public Widget::Panel { | 29 | class CloneTiler : public Widget::Panel { |
4071 | @@ -45,8 +50,9 @@ | |||
4072 | 45 | static void clonetiler_do_pick_toggled(GtkToggleButton *tb, GtkWidget *dlg); | 50 | static void clonetiler_do_pick_toggled(GtkToggleButton *tb, GtkWidget *dlg); |
4073 | 46 | static void clonetiler_pick_to(GtkToggleButton *tb, gpointer data); | 51 | static void clonetiler_pick_to(GtkToggleButton *tb, gpointer data); |
4074 | 47 | static void clonetiler_xy_changed(GtkAdjustment *adj, gpointer data); | 52 | static void clonetiler_xy_changed(GtkAdjustment *adj, gpointer data); |
4077 | 48 | static void clonetiler_fill_width_changed(GtkAdjustment *adj, GtkWidget *u); | 53 | static void clonetiler_fill_width_changed(GtkAdjustment *adj, Inkscape::UI::Widget::UnitMenu *u); |
4078 | 49 | static void clonetiler_fill_height_changed(GtkAdjustment *adj, GtkWidget *u); | 54 | static void clonetiler_fill_height_changed(GtkAdjustment *adj, Inkscape::UI::Widget::UnitMenu *u); |
4079 | 55 | void clonetiler_unit_changed(); | ||
4080 | 50 | static void clonetiler_switch_to_create(GtkToggleButton */*tb*/, GtkWidget *dlg); | 56 | static void clonetiler_switch_to_create(GtkToggleButton */*tb*/, GtkWidget *dlg); |
4081 | 51 | static void clonetiler_switch_to_fill(GtkToggleButton */*tb*/, GtkWidget *dlg); | 57 | static void clonetiler_switch_to_fill(GtkToggleButton */*tb*/, GtkWidget *dlg); |
4082 | 52 | static void clonetiler_keep_bbox_toggled(GtkToggleButton *tb, gpointer /*data*/); | 58 | static void clonetiler_keep_bbox_toggled(GtkToggleButton *tb, gpointer /*data*/); |
4083 | @@ -112,12 +118,22 @@ | |||
4084 | 112 | DesktopTracker deskTrack; | 118 | DesktopTracker deskTrack; |
4085 | 113 | Inkscape::UI::Widget::ColorPicker *color_picker; | 119 | Inkscape::UI::Widget::ColorPicker *color_picker; |
4086 | 114 | GtkSizeGroup* table_row_labels; | 120 | GtkSizeGroup* table_row_labels; |
4087 | 121 | Inkscape::UI::Widget::UnitMenu *unit_menu; | ||
4088 | 122 | |||
4089 | 123 | #if WITH_GTKMM_3_0 | ||
4090 | 124 | Glib::RefPtr<Gtk::Adjustment> fill_width; | ||
4091 | 125 | Glib::RefPtr<Gtk::Adjustment> fill_height; | ||
4092 | 126 | #else | ||
4093 | 127 | Gtk::Adjustment *fill_width; | ||
4094 | 128 | Gtk::Adjustment *fill_height; | ||
4095 | 129 | #endif | ||
4096 | 115 | 130 | ||
4097 | 116 | sigc::connection desktopChangeConn; | 131 | sigc::connection desktopChangeConn; |
4098 | 117 | sigc::connection selectChangedConn; | 132 | sigc::connection selectChangedConn; |
4099 | 118 | sigc::connection subselChangedConn; | 133 | sigc::connection subselChangedConn; |
4100 | 119 | sigc::connection selectModifiedConn; | 134 | sigc::connection selectModifiedConn; |
4101 | 120 | sigc::connection color_changed_connection; | 135 | sigc::connection color_changed_connection; |
4102 | 136 | sigc::connection unitChangedConn; | ||
4103 | 121 | 137 | ||
4104 | 122 | /** | 138 | /** |
4105 | 123 | * Can be invoked for setting the desktop. Currently not used. | 139 | * Can be invoked for setting the desktop. Currently not used. |
4106 | 124 | 140 | ||
4107 | === modified file 'src/ui/dialog/document-properties.cpp' | |||
4108 | --- src/ui/dialog/document-properties.cpp 2013-03-16 19:42:47 +0000 | |||
4109 | +++ src/ui/dialog/document-properties.cpp 2013-08-06 18:46:25 +0000 | |||
4110 | @@ -28,7 +28,6 @@ | |||
4111 | 28 | #include "document.h" | 28 | #include "document.h" |
4112 | 29 | #include "desktop-handles.h" | 29 | #include "desktop-handles.h" |
4113 | 30 | #include "desktop.h" | 30 | #include "desktop.h" |
4114 | 31 | #include "helper/units.h" | ||
4115 | 32 | #include "inkscape.h" | 31 | #include "inkscape.h" |
4116 | 33 | #include "io/sys.h" | 32 | #include "io/sys.h" |
4117 | 34 | #include "preferences.h" | 33 | #include "preferences.h" |
4118 | @@ -1432,7 +1431,7 @@ | |||
4119 | 1432 | _rcb_shad.setActive (nv->showpageshadow); | 1431 | _rcb_shad.setActive (nv->showpageshadow); |
4120 | 1433 | 1432 | ||
4121 | 1434 | if (nv->doc_units) | 1433 | if (nv->doc_units) |
4123 | 1435 | _rum_deflt.setUnit (nv->doc_units); | 1434 | _rum_deflt.setUnit (nv->doc_units->abbr); |
4124 | 1436 | 1435 | ||
4125 | 1437 | double const doc_w_px = sp_desktop_document(dt)->getWidth(); | 1436 | double const doc_w_px = sp_desktop_document(dt)->getWidth(); |
4126 | 1438 | double const doc_h_px = sp_desktop_document(dt)->getHeight(); | 1437 | double const doc_h_px = sp_desktop_document(dt)->getHeight(); |
4127 | 1439 | 1438 | ||
4128 | === modified file 'src/ui/dialog/export.cpp' | |||
4129 | --- src/ui/dialog/export.cpp 2013-06-06 13:44:11 +0000 | |||
4130 | +++ src/ui/dialog/export.cpp 2013-08-06 18:46:25 +0000 | |||
4131 | @@ -48,9 +48,8 @@ | |||
4132 | 48 | #include <glibmm/i18n.h> | 48 | #include <glibmm/i18n.h> |
4133 | 49 | #include <glibmm/miscutils.h> | 49 | #include <glibmm/miscutils.h> |
4134 | 50 | 50 | ||
4138 | 51 | #include "helper/unit-menu.h" | 51 | #include "ui/widget/unit-menu.h" |
4139 | 52 | #include "helper/units.h" | 52 | #include "util/units.h" |
4137 | 53 | #include "unit-constants.h" | ||
4140 | 54 | #include "helper/window.h" | 53 | #include "helper/window.h" |
4141 | 55 | #include "inkscape-private.h" | 54 | #include "inkscape-private.h" |
4142 | 56 | #include "document.h" | 55 | #include "document.h" |
4143 | @@ -98,7 +97,7 @@ | |||
4144 | 98 | 97 | ||
4145 | 99 | #define SP_EXPORT_MIN_SIZE 1.0 | 98 | #define SP_EXPORT_MIN_SIZE 1.0 |
4146 | 100 | 99 | ||
4148 | 101 | #define DPI_BASE PX_PER_IN | 100 | #define DPI_BASE Inkscape::Util::Quantity::convert(1, "in", "px") |
4149 | 102 | 101 | ||
4150 | 103 | #define EXPORT_COORD_PRECISION 3 | 102 | #define EXPORT_COORD_PRECISION 3 |
4151 | 104 | 103 | ||
4152 | @@ -108,6 +107,8 @@ | |||
4153 | 108 | #include "verbs.h" | 107 | #include "verbs.h" |
4154 | 109 | #include "export.h" | 108 | #include "export.h" |
4155 | 110 | 109 | ||
4156 | 110 | using Inkscape::Util::unit_table; | ||
4157 | 111 | |||
4158 | 111 | namespace { | 112 | namespace { |
4159 | 112 | 113 | ||
4160 | 113 | class MessageCleaner | 114 | class MessageCleaner |
4161 | @@ -198,10 +199,13 @@ | |||
4162 | 198 | /* Units box */ | 199 | /* Units box */ |
4163 | 199 | /* gets added to the vbox later, but the unit selector is needed | 200 | /* gets added to the vbox later, but the unit selector is needed |
4164 | 200 | earlier than that */ | 201 | earlier than that */ |
4166 | 201 | unit_selector = Glib::wrap(sp_unit_selector_new (SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE)); | 202 | unit_selector = new Inkscape::UI::Widget::UnitMenu(); |
4167 | 203 | unit_selector->setUnitType(Inkscape::Util::UNIT_TYPE_LINEAR); | ||
4168 | 204 | unitChangedConn = unit_selector->signal_changed().connect(sigc::mem_fun(*this, &Export::onUnitChanged)); | ||
4169 | 205 | |||
4170 | 202 | SPDesktop *desktop = SP_ACTIVE_DESKTOP; | 206 | SPDesktop *desktop = SP_ACTIVE_DESKTOP; |
4171 | 203 | if (desktop) | 207 | if (desktop) |
4173 | 204 | sp_unit_selector_set_unit (SP_UNIT_SELECTOR(unit_selector->gobj()), sp_desktop_namedview(desktop)->doc_units); | 208 | unit_selector->setUnit(sp_desktop_namedview(desktop)->doc_units->abbr); |
4174 | 205 | unitbox.pack_end(*unit_selector, false, false, 0); | 209 | unitbox.pack_end(*unit_selector, false, false, 0); |
4175 | 206 | unitbox.pack_end(units_label, false, false, 3); | 210 | unitbox.pack_end(units_label, false, false, 3); |
4176 | 207 | 211 | ||
4177 | @@ -226,28 +230,28 @@ | |||
4178 | 226 | t->set_col_spacings (4); | 230 | t->set_col_spacings (4); |
4179 | 227 | #endif | 231 | #endif |
4180 | 228 | 232 | ||
4182 | 229 | x0_adj = createSpinbutton ( "x0", 0.0, -1000000.0, 1000000.0, 0.1, 1.0, unit_selector->gobj(), | 233 | x0_adj = createSpinbutton ( "x0", 0.0, -1000000.0, 1000000.0, 0.1, 1.0, ((Gtk::Widget*) unit_selector)->gobj(), |
4183 | 230 | t, 0, 0, _("_x0:"), "", EXPORT_COORD_PRECISION, 1, | 234 | t, 0, 0, _("_x0:"), "", EXPORT_COORD_PRECISION, 1, |
4184 | 231 | &Export::onAreaX0Change); | 235 | &Export::onAreaX0Change); |
4185 | 232 | 236 | ||
4187 | 233 | x1_adj = createSpinbutton ( "x1", 0.0, -1000000.0, 1000000.0, 0.1, 1.0, unit_selector->gobj(), | 237 | x1_adj = createSpinbutton ( "x1", 0.0, -1000000.0, 1000000.0, 0.1, 1.0, ((Gtk::Widget*) unit_selector)->gobj(), |
4188 | 234 | t, 0, 1, _("x_1:"), "", EXPORT_COORD_PRECISION, 1, | 238 | t, 0, 1, _("x_1:"), "", EXPORT_COORD_PRECISION, 1, |
4189 | 235 | &Export::onAreaX1Change); | 239 | &Export::onAreaX1Change); |
4190 | 236 | 240 | ||
4191 | 237 | width_adj = createSpinbutton ( "width", 0.0, 0.0, PNG_UINT_31_MAX, 0.1, 1.0, | 241 | width_adj = createSpinbutton ( "width", 0.0, 0.0, PNG_UINT_31_MAX, 0.1, 1.0, |
4193 | 238 | unit_selector->gobj(), t, 0, 2, _("Wid_th:"), "", EXPORT_COORD_PRECISION, 1, | 242 | ((Gtk::Widget*) unit_selector)->gobj(), t, 0, 2, _("Wid_th:"), "", EXPORT_COORD_PRECISION, 1, |
4194 | 239 | &Export::onAreaWidthChange); | 243 | &Export::onAreaWidthChange); |
4195 | 240 | 244 | ||
4197 | 241 | y0_adj = createSpinbutton ( "y0", 0.0, -1000000.0, 1000000.0, 0.1, 1.0, unit_selector->gobj(), | 245 | y0_adj = createSpinbutton ( "y0", 0.0, -1000000.0, 1000000.0, 0.1, 1.0, ((Gtk::Widget*) unit_selector)->gobj(), |
4198 | 242 | t, 2, 0, _("_y0:"), "", EXPORT_COORD_PRECISION, 1, | 246 | t, 2, 0, _("_y0:"), "", EXPORT_COORD_PRECISION, 1, |
4199 | 243 | &Export::onAreaY0Change); | 247 | &Export::onAreaY0Change); |
4200 | 244 | 248 | ||
4202 | 245 | y1_adj = createSpinbutton ( "y1", 0.0, -1000000.0, 1000000.0, 0.1, 1.0, unit_selector->gobj(), | 249 | y1_adj = createSpinbutton ( "y1", 0.0, -1000000.0, 1000000.0, 0.1, 1.0, ((Gtk::Widget*) unit_selector)->gobj(), |
4203 | 246 | t, 2, 1, _("y_1:"), "", EXPORT_COORD_PRECISION, 1, | 250 | t, 2, 1, _("y_1:"), "", EXPORT_COORD_PRECISION, 1, |
4204 | 247 | &Export::onAreaY1Change); | 251 | &Export::onAreaY1Change); |
4205 | 248 | 252 | ||
4206 | 249 | height_adj = createSpinbutton ( "height", 0.0, 0.0, PNG_UINT_31_MAX, 0.1, 1.0, | 253 | height_adj = createSpinbutton ( "height", 0.0, 0.0, PNG_UINT_31_MAX, 0.1, 1.0, |
4208 | 250 | unit_selector->gobj(), t, 2, 2, _("Hei_ght:"), "", EXPORT_COORD_PRECISION, 1, | 254 | ((Gtk::Widget*) unit_selector)->gobj(), t, 2, 2, _("Hei_ght:"), "", EXPORT_COORD_PRECISION, 1, |
4209 | 251 | &Export::onAreaHeightChange); | 255 | &Export::onAreaHeightChange); |
4210 | 252 | 256 | ||
4211 | 253 | area_box.pack_start(togglebox, false, false, 3); | 257 | area_box.pack_start(togglebox, false, false, 3); |
4212 | @@ -496,9 +500,6 @@ | |||
4213 | 496 | #else | 500 | #else |
4214 | 497 | Gtk::Adjustment *adj = new Gtk::Adjustment ( val, min, max, step, page, 0 ); | 501 | Gtk::Adjustment *adj = new Gtk::Adjustment ( val, min, max, step, page, 0 ); |
4215 | 498 | #endif | 502 | #endif |
4216 | 499 | if (us) { | ||
4217 | 500 | sp_unit_selector_add_adjustment ( SP_UNIT_SELECTOR (us), GTK_ADJUSTMENT (adj->gobj()) ); | ||
4218 | 501 | } | ||
4219 | 502 | 503 | ||
4220 | 503 | int pos = 0; | 504 | int pos = 0; |
4221 | 504 | Gtk::Label *l = NULL; | 505 | Gtk::Label *l = NULL; |
4222 | @@ -979,6 +980,12 @@ | |||
4223 | 979 | return path; | 980 | return path; |
4224 | 980 | } | 981 | } |
4225 | 981 | 982 | ||
4226 | 983 | // Called when unit is changed | ||
4227 | 984 | void Export::onUnitChanged() | ||
4228 | 985 | { | ||
4229 | 986 | onAreaToggled(); | ||
4230 | 987 | } | ||
4231 | 988 | |||
4232 | 982 | void Export::onHideExceptSelected () | 989 | void Export::onHideExceptSelected () |
4233 | 983 | { | 990 | { |
4234 | 984 | prefs->setBool("/dialogs/export/hideexceptselected/value", hide_export.get_active()); | 991 | prefs->setBool("/dialogs/export/hideexceptselected/value", hide_export.get_active()); |
4235 | @@ -1042,8 +1049,8 @@ | |||
4236 | 1042 | 1049 | ||
4237 | 1043 | Geom::OptRect area = item->desktopVisualBounds(); | 1050 | Geom::OptRect area = item->desktopVisualBounds(); |
4238 | 1044 | if (area) { | 1051 | if (area) { |
4241 | 1045 | gint width = (gint) (area->width() * dpi / PX_PER_IN + 0.5); | 1052 | gint width = (gint) (area->width() * dpi / DPI_BASE + 0.5); |
4242 | 1046 | gint height = (gint) (area->height() * dpi / PX_PER_IN + 0.5); | 1053 | gint height = (gint) (area->height() * dpi / DPI_BASE + 0.5); |
4243 | 1047 | 1054 | ||
4244 | 1048 | if (width > 1 && height > 1) { | 1055 | if (width > 1 && height > 1) { |
4245 | 1049 | // Do export | 1056 | // Do export |
4246 | @@ -1507,10 +1514,6 @@ | |||
4247 | 1507 | return; | 1514 | return; |
4248 | 1508 | } | 1515 | } |
4249 | 1509 | 1516 | ||
4250 | 1510 | if (sp_unit_selector_update_test(SP_UNIT_SELECTOR(unit_selector->gobj()))) { | ||
4251 | 1511 | return; | ||
4252 | 1512 | } | ||
4253 | 1513 | |||
4254 | 1514 | update = true; | 1517 | update = true; |
4255 | 1515 | 1518 | ||
4256 | 1516 | x0 = getValuePx(x0_adj); | 1519 | x0 = getValuePx(x0_adj); |
4257 | @@ -1554,10 +1557,6 @@ | |||
4258 | 1554 | return; | 1557 | return; |
4259 | 1555 | } | 1558 | } |
4260 | 1556 | 1559 | ||
4261 | 1557 | if (sp_unit_selector_update_test (SP_UNIT_SELECTOR(unit_selector->gobj()))) { | ||
4262 | 1558 | return; | ||
4263 | 1559 | } | ||
4264 | 1560 | |||
4265 | 1561 | update = true; | 1560 | update = true; |
4266 | 1562 | 1561 | ||
4267 | 1563 | y0 = getValuePx(y0_adj); | 1562 | y0 = getValuePx(y0_adj); |
4268 | @@ -1597,10 +1596,6 @@ | |||
4269 | 1597 | return; | 1596 | return; |
4270 | 1598 | } | 1597 | } |
4271 | 1599 | 1598 | ||
4272 | 1600 | if (sp_unit_selector_update_test(reinterpret_cast<SPUnitSelector *>(unit_selector->gobj()))) { | ||
4273 | 1601 | return; | ||
4274 | 1602 | } | ||
4275 | 1603 | |||
4276 | 1604 | update = true; | 1599 | update = true; |
4277 | 1605 | 1600 | ||
4278 | 1606 | float x0 = getValuePx(x0_adj); | 1601 | float x0 = getValuePx(x0_adj); |
4279 | @@ -1630,10 +1625,6 @@ | |||
4280 | 1630 | return; | 1625 | return; |
4281 | 1631 | } | 1626 | } |
4282 | 1632 | 1627 | ||
4283 | 1633 | if (sp_unit_selector_update_test(reinterpret_cast<SPUnitSelector *>(unit_selector->gobj()))) { | ||
4284 | 1634 | return; | ||
4285 | 1635 | } | ||
4286 | 1636 | |||
4287 | 1637 | update = true; | 1628 | update = true; |
4288 | 1638 | 1629 | ||
4289 | 1639 | float y0 = getValuePx(y0_adj); | 1630 | float y0 = getValuePx(y0_adj); |
4290 | @@ -1709,10 +1700,6 @@ | |||
4291 | 1709 | return; | 1700 | return; |
4292 | 1710 | } | 1701 | } |
4293 | 1711 | 1702 | ||
4294 | 1712 | if (sp_unit_selector_update_test(SP_UNIT_SELECTOR(unit_selector->gobj()))) { | ||
4295 | 1713 | return; | ||
4296 | 1714 | } | ||
4297 | 1715 | |||
4298 | 1716 | update = true; | 1703 | update = true; |
4299 | 1717 | 1704 | ||
4300 | 1718 | x0 = getValuePx(x0_adj); | 1705 | x0 = getValuePx(x0_adj); |
4301 | @@ -1743,10 +1730,6 @@ | |||
4302 | 1743 | return; | 1730 | return; |
4303 | 1744 | } | 1731 | } |
4304 | 1745 | 1732 | ||
4305 | 1746 | if (sp_unit_selector_update_test(SP_UNIT_SELECTOR(unit_selector->gobj()))) { | ||
4306 | 1747 | return; | ||
4307 | 1748 | } | ||
4308 | 1749 | |||
4309 | 1750 | update = true; | 1733 | update = true; |
4310 | 1751 | 1734 | ||
4311 | 1752 | y0 = getValuePx(y0_adj); | 1735 | y0 = getValuePx(y0_adj); |
4312 | @@ -1803,10 +1786,6 @@ | |||
4313 | 1803 | return; | 1786 | return; |
4314 | 1804 | } | 1787 | } |
4315 | 1805 | 1788 | ||
4316 | 1806 | if (sp_unit_selector_update_test(SP_UNIT_SELECTOR(unit_selector->gobj()))) { | ||
4317 | 1807 | return; | ||
4318 | 1808 | } | ||
4319 | 1809 | |||
4320 | 1810 | update = true; | 1789 | update = true; |
4321 | 1811 | 1790 | ||
4322 | 1812 | x0 = getValuePx(x0_adj); | 1791 | x0 = getValuePx(x0_adj); |
4323 | @@ -1905,9 +1884,9 @@ | |||
4324 | 1905 | void Export::setValuePx( Gtk::Adjustment *adj, double val) | 1884 | void Export::setValuePx( Gtk::Adjustment *adj, double val) |
4325 | 1906 | #endif | 1885 | #endif |
4326 | 1907 | { | 1886 | { |
4328 | 1908 | const SPUnit *unit = sp_unit_selector_get_unit(SP_UNIT_SELECTOR(unit_selector->gobj()) ); | 1887 | const Unit unit = unit_selector->getUnit(); |
4329 | 1909 | 1888 | ||
4331 | 1910 | setValue(adj, sp_pixels_get_units (val, *unit)); | 1889 | setValue(adj, Inkscape::Util::Quantity::convert(val, "px", unit)); |
4332 | 1911 | 1890 | ||
4333 | 1912 | return; | 1891 | return; |
4334 | 1913 | } | 1892 | } |
4335 | @@ -1955,9 +1934,9 @@ | |||
4336 | 1955 | #endif | 1934 | #endif |
4337 | 1956 | { | 1935 | { |
4338 | 1957 | float value = getValue( adj); | 1936 | float value = getValue( adj); |
4340 | 1958 | const SPUnit *unit = sp_unit_selector_get_unit(SP_UNIT_SELECTOR(unit_selector->gobj())); | 1937 | const Unit unit = unit_selector->getUnit(); |
4341 | 1959 | 1938 | ||
4343 | 1960 | return sp_units_get_pixels (value, *unit); | 1939 | return Inkscape::Util::Quantity::convert(value, unit, "px"); |
4344 | 1961 | } // end of sp_export_value_get_px() | 1940 | } // end of sp_export_value_get_px() |
4345 | 1962 | 1941 | ||
4346 | 1963 | /** | 1942 | /** |
4347 | 1964 | 1943 | ||
4348 | === modified file 'src/ui/dialog/export.h' | |||
4349 | --- src/ui/dialog/export.h 2013-03-16 12:20:26 +0000 | |||
4350 | +++ src/ui/dialog/export.h 2013-08-06 18:46:25 +0000 | |||
4351 | @@ -172,6 +172,11 @@ | |||
4352 | 172 | #endif | 172 | #endif |
4353 | 173 | 173 | ||
4354 | 174 | /** | 174 | /** |
4355 | 175 | * Unit changed callback | ||
4356 | 176 | */ | ||
4357 | 177 | void onUnitChanged(); | ||
4358 | 178 | |||
4359 | 179 | /** | ||
4360 | 175 | * Hide except selected callback | 180 | * Hide except selected callback |
4361 | 176 | */ | 181 | */ |
4362 | 177 | void onHideExceptSelected (); | 182 | void onHideExceptSelected (); |
4363 | @@ -330,7 +335,7 @@ | |||
4364 | 330 | 335 | ||
4365 | 331 | /* Unit selector widgets */ | 336 | /* Unit selector widgets */ |
4366 | 332 | Gtk::HBox unitbox; | 337 | Gtk::HBox unitbox; |
4368 | 333 | Gtk::Widget* unit_selector; | 338 | Inkscape::UI::Widget::UnitMenu *unit_selector; |
4369 | 334 | Gtk::Label units_label; | 339 | Gtk::Label units_label; |
4370 | 335 | 340 | ||
4371 | 336 | /* Filename widgets */ | 341 | /* Filename widgets */ |
4372 | @@ -365,6 +370,7 @@ | |||
4373 | 365 | sigc::connection selectChangedConn; | 370 | sigc::connection selectChangedConn; |
4374 | 366 | sigc::connection subselChangedConn; | 371 | sigc::connection subselChangedConn; |
4375 | 367 | sigc::connection selectModifiedConn; | 372 | sigc::connection selectModifiedConn; |
4376 | 373 | sigc::connection unitChangedConn; | ||
4377 | 368 | 374 | ||
4378 | 369 | }; | 375 | }; |
4379 | 370 | 376 | ||
4380 | 371 | 377 | ||
4381 | === modified file 'src/ui/dialog/guides.cpp' | |||
4382 | --- src/ui/dialog/guides.cpp 2013-03-09 17:43:14 +0000 | |||
4383 | +++ src/ui/dialog/guides.cpp 2013-08-06 18:46:25 +0000 | |||
4384 | @@ -230,7 +230,7 @@ | |||
4385 | 230 | _unit_menu.setUnitType(UNIT_TYPE_LINEAR); | 230 | _unit_menu.setUnitType(UNIT_TYPE_LINEAR); |
4386 | 231 | _unit_menu.setUnit("px"); | 231 | _unit_menu.setUnit("px"); |
4387 | 232 | if (_desktop->namedview->doc_units) { | 232 | if (_desktop->namedview->doc_units) { |
4389 | 233 | _unit_menu.setUnit( sp_unit_get_abbreviation(_desktop->namedview->doc_units) ); | 233 | _unit_menu.setUnit( _desktop->namedview->doc_units->abbr ); |
4390 | 234 | } | 234 | } |
4391 | 235 | _spin_angle.setUnit(_angle_unit_status); | 235 | _spin_angle.setUnit(_angle_unit_status); |
4392 | 236 | 236 | ||
4393 | 237 | 237 | ||
4394 | === modified file 'src/ui/dialog/inkscape-preferences.cpp' | |||
4395 | --- src/ui/dialog/inkscape-preferences.cpp 2013-05-13 06:27:27 +0000 | |||
4396 | +++ src/ui/dialog/inkscape-preferences.cpp 2013-08-06 18:46:25 +0000 | |||
4397 | @@ -28,7 +28,7 @@ | |||
4398 | 28 | #include "preferences.h" | 28 | #include "preferences.h" |
4399 | 29 | #include "verbs.h" | 29 | #include "verbs.h" |
4400 | 30 | #include "selcue.h" | 30 | #include "selcue.h" |
4402 | 31 | #include "unit-constants.h" | 31 | #include "util/units.h" |
4403 | 32 | #include <iostream> | 32 | #include <iostream> |
4404 | 33 | #include "enums.h" | 33 | #include "enums.h" |
4405 | 34 | #include "desktop-handles.h" | 34 | #include "desktop-handles.h" |
4406 | @@ -1428,10 +1428,10 @@ | |||
4407 | 1428 | _("Automatically reload linked images when file is changed on disk")); | 1428 | _("Automatically reload linked images when file is changed on disk")); |
4408 | 1429 | _misc_bitmap_editor.init("/options/bitmapeditor/value", true); | 1429 | _misc_bitmap_editor.init("/options/bitmapeditor/value", true); |
4409 | 1430 | _page_bitmaps.add_line( false, _("_Bitmap editor:"), _misc_bitmap_editor, "", "", true); | 1430 | _page_bitmaps.add_line( false, _("_Bitmap editor:"), _misc_bitmap_editor, "", "", true); |
4411 | 1431 | _importexport_export_res.init("/dialogs/export/defaultxdpi/value", 0.0, 6000.0, 1.0, 1.0, PX_PER_IN, true, false); | 1431 | _importexport_export_res.init("/dialogs/export/defaultxdpi/value", 0.0, 6000.0, 1.0, 1.0, Inkscape::Util::Quantity::convert(1, "in", "px"), true, false); |
4412 | 1432 | _page_bitmaps.add_line( false, _("Default export _resolution:"), _importexport_export_res, _("dpi"), | 1432 | _page_bitmaps.add_line( false, _("Default export _resolution:"), _importexport_export_res, _("dpi"), |
4413 | 1433 | _("Default bitmap resolution (in dots per inch) in the Export dialog"), false); | 1433 | _("Default bitmap resolution (in dots per inch) in the Export dialog"), false); |
4415 | 1434 | _bitmap_copy_res.init("/options/createbitmap/resolution", 1.0, 6000.0, 1.0, 1.0, PX_PER_IN, true, false); | 1434 | _bitmap_copy_res.init("/options/createbitmap/resolution", 1.0, 6000.0, 1.0, 1.0, Inkscape::Util::Quantity::convert(1, "in", "px"), true, false); |
4416 | 1435 | _page_bitmaps.add_line( false, _("Resolution for Create Bitmap _Copy:"), _bitmap_copy_res, _("dpi"), | 1435 | _page_bitmaps.add_line( false, _("Resolution for Create Bitmap _Copy:"), _bitmap_copy_res, _("dpi"), |
4417 | 1436 | _("Resolution used by the Create Bitmap Copy command"), false); | 1436 | _("Resolution used by the Create Bitmap Copy command"), false); |
4418 | 1437 | { | 1437 | { |
4419 | @@ -1443,7 +1443,7 @@ | |||
4420 | 1443 | _bitmap_import_quality.init("/dialogs/import/quality", 1, 100, 1, 1, 100, true, false); | 1443 | _bitmap_import_quality.init("/dialogs/import/quality", 1, 100, 1, 1, 100, true, false); |
4421 | 1444 | _page_bitmaps.add_line( false, _("Bitmap import quality:"), _bitmap_import_quality, "%", "Bitmap import quality (jpeg only). 100 is best quality", false); | 1444 | _page_bitmaps.add_line( false, _("Bitmap import quality:"), _bitmap_import_quality, "%", "Bitmap import quality (jpeg only). 100 is best quality", false); |
4422 | 1445 | } | 1445 | } |
4424 | 1446 | _importexport_import_res.init("/dialogs/import/defaultxdpi/value", 0.0, 6000.0, 1.0, 1.0, PX_PER_IN, true, false); | 1446 | _importexport_import_res.init("/dialogs/import/defaultxdpi/value", 0.0, 6000.0, 1.0, 1.0, Inkscape::Util::Quantity::convert(1, "in", "px"), true, false); |
4425 | 1447 | _page_bitmaps.add_line( false, _("Default _import resolution:"), _importexport_import_res, _("dpi"), | 1447 | _page_bitmaps.add_line( false, _("Default _import resolution:"), _importexport_import_res, _("dpi"), |
4426 | 1448 | _("Default bitmap resolution (in dots per inch) for bitmap import"), false); | 1448 | _("Default bitmap resolution (in dots per inch) for bitmap import"), false); |
4427 | 1449 | _importexport_import_res_override.init(_("Override file resolution"), "/dialogs/import/forcexdpi", false); | 1449 | _importexport_import_res_override.init(_("Override file resolution"), "/dialogs/import/forcexdpi", false); |
4428 | 1450 | 1450 | ||
4429 | === modified file 'src/ui/dialog/print.cpp' | |||
4430 | --- src/ui/dialog/print.cpp 2012-10-28 14:10:22 +0000 | |||
4431 | +++ src/ui/dialog/print.cpp 2013-08-06 18:46:25 +0000 | |||
4432 | @@ -26,7 +26,7 @@ | |||
4433 | 26 | #include "ui/widget/rendering-options.h" | 26 | #include "ui/widget/rendering-options.h" |
4434 | 27 | #include "document.h" | 27 | #include "document.h" |
4435 | 28 | 28 | ||
4437 | 29 | #include "unit-constants.h" | 29 | #include "util/units.h" |
4438 | 30 | #include "helper/png-write.h" | 30 | #include "helper/png-write.h" |
4439 | 31 | #include "svg/svg-color.h" | 31 | #include "svg/svg-color.h" |
4440 | 32 | #include "io/sys.h" | 32 | #include "io/sys.h" |
4441 | @@ -72,8 +72,8 @@ | |||
4442 | 72 | 72 | ||
4443 | 73 | sp_export_png_file(junk->_doc, tmp_png.c_str(), 0.0, 0.0, | 73 | sp_export_png_file(junk->_doc, tmp_png.c_str(), 0.0, 0.0, |
4444 | 74 | width, height, | 74 | width, height, |
4447 | 75 | (unsigned long)(width * dpi / PX_PER_IN), | 75 | (unsigned long)(width * dpi / Inkscape::Util::Quantity::convert(1, "in", "px")), |
4448 | 76 | (unsigned long)(height * dpi / PX_PER_IN), | 76 | (unsigned long)(height * dpi / Inkscape::Util::Quantity::convert(1, "in", "px")), |
4449 | 77 | dpi, dpi, bgcolor, NULL, NULL, true, NULL); | 77 | dpi, dpi, bgcolor, NULL, NULL, true, NULL); |
4450 | 78 | 78 | ||
4451 | 79 | // This doesn't seem to work: | 79 | // This doesn't seem to work: |
4452 | @@ -90,7 +90,7 @@ | |||
4453 | 90 | cairo_t *cr = gtk_print_context_get_cairo_context (context); | 90 | cairo_t *cr = gtk_print_context_get_cairo_context (context); |
4454 | 91 | cairo_matrix_t m; | 91 | cairo_matrix_t m; |
4455 | 92 | cairo_get_matrix(cr, &m); | 92 | cairo_get_matrix(cr, &m); |
4457 | 93 | cairo_scale(cr, PT_PER_IN / dpi, PT_PER_IN / dpi); | 93 | cairo_scale(cr, Inkscape::Util::Quantity::convert(1, "in", "pt") / dpi, Inkscape::Util::Quantity::convert(1, "in", "pt") / dpi); |
4458 | 94 | // FIXME: why is the origin offset?? | 94 | // FIXME: why is the origin offset?? |
4459 | 95 | cairo_set_source_surface(cr, png->cobj(), -16.0, -16.0); | 95 | cairo_set_source_surface(cr, png->cobj(), -16.0, -16.0); |
4460 | 96 | cairo_paint(cr); | 96 | cairo_paint(cr); |
4461 | @@ -195,8 +195,8 @@ | |||
4462 | 195 | // set up paper size to match the document size | 195 | // set up paper size to match the document size |
4463 | 196 | gtk_print_operation_set_unit (_printop, GTK_UNIT_POINTS); | 196 | gtk_print_operation_set_unit (_printop, GTK_UNIT_POINTS); |
4464 | 197 | GtkPageSetup *page_setup = gtk_page_setup_new(); | 197 | GtkPageSetup *page_setup = gtk_page_setup_new(); |
4467 | 198 | gdouble doc_width = _doc->getWidth() * PT_PER_PX; | 198 | gdouble doc_width = _doc->getWidth() * Inkscape::Util::Quantity::convert(1, "px", "pt"); |
4468 | 199 | gdouble doc_height = _doc->getHeight() * PT_PER_PX; | 199 | gdouble doc_height = _doc->getHeight() * Inkscape::Util::Quantity::convert(1, "px", "pt"); |
4469 | 200 | GtkPaperSize *paper_size; | 200 | GtkPaperSize *paper_size; |
4470 | 201 | if (doc_width > doc_height) { | 201 | if (doc_width > doc_height) { |
4471 | 202 | gtk_page_setup_set_orientation (page_setup, GTK_PAGE_ORIENTATION_LANDSCAPE); | 202 | gtk_page_setup_set_orientation (page_setup, GTK_PAGE_ORIENTATION_LANDSCAPE); |
4472 | 203 | 203 | ||
4473 | === modified file 'src/ui/dialog/text-edit.cpp' | |||
4474 | --- src/ui/dialog/text-edit.cpp 2013-04-28 18:38:55 +0000 | |||
4475 | +++ src/ui/dialog/text-edit.cpp 2013-08-06 18:46:25 +0000 | |||
4476 | @@ -58,7 +58,7 @@ | |||
4477 | 58 | #include "widgets/font-selector.h" | 58 | #include "widgets/font-selector.h" |
4478 | 59 | #include <glibmm/i18n.h> | 59 | #include <glibmm/i18n.h> |
4479 | 60 | #include <glibmm/markup.h> | 60 | #include <glibmm/markup.h> |
4481 | 61 | #include "unit-constants.h" | 61 | #include "util/units.h" |
4482 | 62 | #include "sp-textpath.h" | 62 | #include "sp-textpath.h" |
4483 | 63 | 63 | ||
4484 | 64 | namespace Inkscape { | 64 | namespace Inkscape { |
4485 | @@ -401,7 +401,7 @@ | |||
4486 | 401 | 401 | ||
4487 | 402 | Inkscape::Preferences *prefs = Inkscape::Preferences::get(); | 402 | Inkscape::Preferences *prefs = Inkscape::Preferences::get(); |
4488 | 403 | int unit = prefs->getInt("/options/font/unitType", SP_CSS_UNIT_PT); | 403 | int unit = prefs->getInt("/options/font/unitType", SP_CSS_UNIT_PT); |
4490 | 404 | double pt_size = sp_style_css_size_units_to_px(sp_font_selector_get_size(fsel), unit) * PT_PER_PX; | 404 | double pt_size = sp_style_css_size_units_to_px(sp_font_selector_get_size(fsel), unit) * Inkscape::Util::Quantity::convert(1, "px", "pt"); |
4491 | 405 | 405 | ||
4492 | 406 | // Pango font size is in 1024ths of a point | 406 | // Pango font size is in 1024ths of a point |
4493 | 407 | // C++11: Glib::ustring size = std::to_string( pt_size * PANGO_SCALE ); | 407 | // C++11: Glib::ustring size = std::to_string( pt_size * PANGO_SCALE ); |
4494 | 408 | 408 | ||
4495 | === modified file 'src/ui/tool/node.cpp' | |||
4496 | --- src/ui/tool/node.cpp 2012-10-13 21:38:45 +0000 | |||
4497 | +++ src/ui/tool/node.cpp 2013-08-06 18:46:25 +0000 | |||
4498 | @@ -22,7 +22,6 @@ | |||
4499 | 22 | #include "preferences.h" | 22 | #include "preferences.h" |
4500 | 23 | #include "snap.h" | 23 | #include "snap.h" |
4501 | 24 | #include "snap-preferences.h" | 24 | #include "snap-preferences.h" |
4502 | 25 | #include "sp-metrics.h" | ||
4503 | 26 | #include "sp-namedview.h" | 25 | #include "sp-namedview.h" |
4504 | 27 | #include "ui/control-manager.h" | 26 | #include "ui/control-manager.h" |
4505 | 28 | #include "ui/tool/control-point-selection.h" | 27 | #include "ui/tool/control-point-selection.h" |
4506 | @@ -490,9 +489,13 @@ | |||
4507 | 490 | double angle = Geom::angle_between(Geom::Point(-1,0), position() - _parent->position()); | 489 | double angle = Geom::angle_between(Geom::Point(-1,0), position() - _parent->position()); |
4508 | 491 | angle += M_PI; // angle is (-M_PI...M_PI] - offset by +pi and scale to 0...360 | 490 | angle += M_PI; // angle is (-M_PI...M_PI] - offset by +pi and scale to 0...360 |
4509 | 492 | angle *= 360.0 / (2 * M_PI); | 491 | angle *= 360.0 / (2 * M_PI); |
4513 | 493 | GString *x = SP_PX_TO_METRIC_STRING(dist[Geom::X], _desktop->namedview->getDefaultMetric()); | 492 | |
4514 | 494 | GString *y = SP_PX_TO_METRIC_STRING(dist[Geom::Y], _desktop->namedview->getDefaultMetric()); | 493 | Inkscape::Util::Quantity x_q = Inkscape::Util::Quantity(dist[Geom::X], "px"); |
4515 | 495 | GString *len = SP_PX_TO_METRIC_STRING(length(), _desktop->namedview->getDefaultMetric()); | 494 | Inkscape::Util::Quantity y_q = Inkscape::Util::Quantity(dist[Geom::Y], "px"); |
4516 | 495 | Inkscape::Util::Quantity len_q = Inkscape::Util::Quantity(length(), "px"); | ||
4517 | 496 | GString *x = g_string_new(x_q.string(*_desktop->namedview->doc_units).c_str()); | ||
4518 | 497 | GString *y = g_string_new(y_q.string(*_desktop->namedview->doc_units).c_str()); | ||
4519 | 498 | GString *len = g_string_new(len_q.string(*_desktop->namedview->doc_units).c_str()); | ||
4520 | 496 | Glib::ustring ret = format_tip(C_("Path handle tip", | 499 | Glib::ustring ret = format_tip(C_("Path handle tip", |
4521 | 497 | "Move handle by %s, %s; angle %.2f°, length %s"), x->str, y->str, angle, len->str); | 500 | "Move handle by %s, %s; angle %.2f°, length %s"), x->str, y->str, angle, len->str); |
4522 | 498 | g_string_free(x, TRUE); | 501 | g_string_free(x, TRUE); |
4523 | @@ -1294,8 +1297,11 @@ | |||
4524 | 1294 | Glib::ustring Node::_getDragTip(GdkEventMotion */*event*/) const | 1297 | Glib::ustring Node::_getDragTip(GdkEventMotion */*event*/) const |
4525 | 1295 | { | 1298 | { |
4526 | 1296 | Geom::Point dist = position() - _last_drag_origin(); | 1299 | Geom::Point dist = position() - _last_drag_origin(); |
4529 | 1297 | GString *x = SP_PX_TO_METRIC_STRING(dist[Geom::X], _desktop->namedview->getDefaultMetric()); | 1300 | |
4530 | 1298 | GString *y = SP_PX_TO_METRIC_STRING(dist[Geom::Y], _desktop->namedview->getDefaultMetric()); | 1301 | Inkscape::Util::Quantity x_q = Inkscape::Util::Quantity(dist[Geom::X], "px"); |
4531 | 1302 | Inkscape::Util::Quantity y_q = Inkscape::Util::Quantity(dist[Geom::Y], "px"); | ||
4532 | 1303 | GString *x = g_string_new(x_q.string(*_desktop->namedview->doc_units).c_str()); | ||
4533 | 1304 | GString *y = g_string_new(y_q.string(*_desktop->namedview->doc_units).c_str()); | ||
4534 | 1299 | Glib::ustring ret = format_tip(C_("Path node tip", "Move node by %s, %s"), | 1305 | Glib::ustring ret = format_tip(C_("Path node tip", "Move node by %s, %s"), |
4535 | 1300 | x->str, y->str); | 1306 | x->str, y->str); |
4536 | 1301 | g_string_free(x, TRUE); | 1307 | g_string_free(x, TRUE); |
4537 | 1302 | 1308 | ||
4538 | === modified file 'src/ui/widget/Makefile_insert' | |||
4539 | --- src/ui/widget/Makefile_insert 2013-01-08 12:06:44 +0000 | |||
4540 | +++ src/ui/widget/Makefile_insert 2013-08-06 18:46:25 +0000 | |||
4541 | @@ -79,5 +79,7 @@ | |||
4542 | 79 | ui/widget/tolerance-slider.cpp \ | 79 | ui/widget/tolerance-slider.cpp \ |
4543 | 80 | ui/widget/tolerance-slider.h \ | 80 | ui/widget/tolerance-slider.h \ |
4544 | 81 | ui/widget/unit-menu.cpp \ | 81 | ui/widget/unit-menu.cpp \ |
4546 | 82 | ui/widget/unit-menu.h | 82 | ui/widget/unit-menu.h \ |
4547 | 83 | ui/widget/unit-tracker.h \ | ||
4548 | 84 | ui/widget/unit-tracker.cpp | ||
4549 | 83 | 85 | ||
4550 | 84 | 86 | ||
4551 | === modified file 'src/ui/widget/page-sizer.cpp' | |||
4552 | --- src/ui/widget/page-sizer.cpp 2013-07-01 20:04:32 +0000 | |||
4553 | +++ src/ui/widget/page-sizer.cpp 2013-08-06 18:46:25 +0000 | |||
4554 | @@ -37,7 +37,7 @@ | |||
4555 | 37 | #include "desktop.h" | 37 | #include "desktop.h" |
4556 | 38 | #include "helper/action.h" | 38 | #include "helper/action.h" |
4557 | 39 | #include "helper/action-context.h" | 39 | #include "helper/action-context.h" |
4559 | 40 | #include "helper/units.h" | 40 | #include "util/units.h" |
4560 | 41 | #include "inkscape.h" | 41 | #include "inkscape.h" |
4561 | 42 | #include "sp-namedview.h" | 42 | #include "sp-namedview.h" |
4562 | 43 | #include "sp-root.h" | 43 | #include "sp-root.h" |
4563 | @@ -48,6 +48,7 @@ | |||
4564 | 48 | #include "xml/repr.h" | 48 | #include "xml/repr.h" |
4565 | 49 | 49 | ||
4566 | 50 | using std::pair; | 50 | using std::pair; |
4567 | 51 | using Inkscape::Util::unit_table; | ||
4568 | 51 | 52 | ||
4569 | 52 | namespace Inkscape { | 53 | namespace Inkscape { |
4570 | 53 | namespace UI { | 54 | namespace UI { |
4571 | @@ -96,7 +97,7 @@ | |||
4572 | 96 | char const * const name; //name | 97 | char const * const name; //name |
4573 | 97 | double const smaller; //lesser dimension | 98 | double const smaller; //lesser dimension |
4574 | 98 | double const larger; //greater dimension | 99 | double const larger; //greater dimension |
4576 | 99 | SPUnitId const unit; //units | 100 | Glib::ustring const unit; //units |
4577 | 100 | }; | 101 | }; |
4578 | 101 | 102 | ||
4579 | 102 | // list of page formats that should be in landscape automatically | 103 | // list of page formats that should be in landscape automatically |
4580 | @@ -114,31 +115,31 @@ | |||
4581 | 114 | } | 115 | } |
4582 | 115 | 116 | ||
4583 | 116 | static PaperSizeRec const inkscape_papers[] = { | 117 | static PaperSizeRec const inkscape_papers[] = { |
4609 | 117 | { "A4", 210, 297, SP_UNIT_MM }, | 118 | { "A4", 210, 297, "mm" }, |
4610 | 118 | { "US Letter", 8.5, 11, SP_UNIT_IN }, | 119 | { "US Letter", 8.5, 11, "in" }, |
4611 | 119 | { "US Legal", 8.5, 14, SP_UNIT_IN }, | 120 | { "US Legal", 8.5, 14, "in" }, |
4612 | 120 | { "US Executive", 7.25, 10.5, SP_UNIT_IN }, | 121 | { "US Executive", 7.25, 10.5, "in" }, |
4613 | 121 | { "A0", 841, 1189, SP_UNIT_MM }, | 122 | { "A0", 841, 1189, "mm" }, |
4614 | 122 | { "A1", 594, 841, SP_UNIT_MM }, | 123 | { "A1", 594, 841, "mm" }, |
4615 | 123 | { "A2", 420, 594, SP_UNIT_MM }, | 124 | { "A2", 420, 594, "mm" }, |
4616 | 124 | { "A3", 297, 420, SP_UNIT_MM }, | 125 | { "A3", 297, 420, "mm" }, |
4617 | 125 | { "A5", 148, 210, SP_UNIT_MM }, | 126 | { "A5", 148, 210, "mm" }, |
4618 | 126 | { "A6", 105, 148, SP_UNIT_MM }, | 127 | { "A6", 105, 148, "mm" }, |
4619 | 127 | { "A7", 74, 105, SP_UNIT_MM }, | 128 | { "A7", 74, 105, "mm" }, |
4620 | 128 | { "A8", 52, 74, SP_UNIT_MM }, | 129 | { "A8", 52, 74, "mm" }, |
4621 | 129 | { "A9", 37, 52, SP_UNIT_MM }, | 130 | { "A9", 37, 52, "mm" }, |
4622 | 130 | { "A10", 26, 37, SP_UNIT_MM }, | 131 | { "A10", 26, 37, "mm" }, |
4623 | 131 | { "B0", 1000, 1414, SP_UNIT_MM }, | 132 | { "B0", 1000, 1414, "mm" }, |
4624 | 132 | { "B1", 707, 1000, SP_UNIT_MM }, | 133 | { "B1", 707, 1000, "mm" }, |
4625 | 133 | { "B2", 500, 707, SP_UNIT_MM }, | 134 | { "B2", 500, 707, "mm" }, |
4626 | 134 | { "B3", 353, 500, SP_UNIT_MM }, | 135 | { "B3", 353, 500, "mm" }, |
4627 | 135 | { "B4", 250, 353, SP_UNIT_MM }, | 136 | { "B4", 250, 353, "mm" }, |
4628 | 136 | { "B5", 176, 250, SP_UNIT_MM }, | 137 | { "B5", 176, 250, "mm" }, |
4629 | 137 | { "B6", 125, 176, SP_UNIT_MM }, | 138 | { "B6", 125, 176, "mm" }, |
4630 | 138 | { "B7", 88, 125, SP_UNIT_MM }, | 139 | { "B7", 88, 125, "mm" }, |
4631 | 139 | { "B8", 62, 88, SP_UNIT_MM }, | 140 | { "B8", 62, 88, "mm" }, |
4632 | 140 | { "B9", 44, 62, SP_UNIT_MM }, | 141 | { "B9", 44, 62, "mm" }, |
4633 | 141 | { "B10", 31, 44, SP_UNIT_MM }, | 142 | { "B10", 31, 44, "mm" }, |
4634 | 142 | 143 | ||
4635 | 143 | 144 | ||
4636 | 144 | 145 | ||
4637 | @@ -150,63 +151,63 @@ | |||
4638 | 150 | don't know what D and E series are used for. | 151 | don't know what D and E series are used for. |
4639 | 151 | */ | 152 | */ |
4640 | 152 | 153 | ||
4663 | 153 | { "C0", 917, 1297, SP_UNIT_MM }, | 154 | { "C0", 917, 1297, "mm" }, |
4664 | 154 | { "C1", 648, 917, SP_UNIT_MM }, | 155 | { "C1", 648, 917, "mm" }, |
4665 | 155 | { "C2", 458, 648, SP_UNIT_MM }, | 156 | { "C2", 458, 648, "mm" }, |
4666 | 156 | { "C3", 324, 458, SP_UNIT_MM }, | 157 | { "C3", 324, 458, "mm" }, |
4667 | 157 | { "C4", 229, 324, SP_UNIT_MM }, | 158 | { "C4", 229, 324, "mm" }, |
4668 | 158 | { "C5", 162, 229, SP_UNIT_MM }, | 159 | { "C5", 162, 229, "mm" }, |
4669 | 159 | { "C6", 114, 162, SP_UNIT_MM }, | 160 | { "C6", 114, 162, "mm" }, |
4670 | 160 | { "C7", 81, 114, SP_UNIT_MM }, | 161 | { "C7", 81, 114, "mm" }, |
4671 | 161 | { "C8", 57, 81, SP_UNIT_MM }, | 162 | { "C8", 57, 81, "mm" }, |
4672 | 162 | { "C9", 40, 57, SP_UNIT_MM }, | 163 | { "C9", 40, 57, "mm" }, |
4673 | 163 | { "C10", 28, 40, SP_UNIT_MM }, | 164 | { "C10", 28, 40, "mm" }, |
4674 | 164 | { "D1", 545, 771, SP_UNIT_MM }, | 165 | { "D1", 545, 771, "mm" }, |
4675 | 165 | { "D2", 385, 545, SP_UNIT_MM }, | 166 | { "D2", 385, 545, "mm" }, |
4676 | 166 | { "D3", 272, 385, SP_UNIT_MM }, | 167 | { "D3", 272, 385, "mm" }, |
4677 | 167 | { "D4", 192, 272, SP_UNIT_MM }, | 168 | { "D4", 192, 272, "mm" }, |
4678 | 168 | { "D5", 136, 192, SP_UNIT_MM }, | 169 | { "D5", 136, 192, "mm" }, |
4679 | 169 | { "D6", 96, 136, SP_UNIT_MM }, | 170 | { "D6", 96, 136, "mm" }, |
4680 | 170 | { "D7", 68, 96, SP_UNIT_MM }, | 171 | { "D7", 68, 96, "mm" }, |
4681 | 171 | { "E3", 400, 560, SP_UNIT_MM }, | 172 | { "E3", 400, 560, "mm" }, |
4682 | 172 | { "E4", 280, 400, SP_UNIT_MM }, | 173 | { "E4", 280, 400, "mm" }, |
4683 | 173 | { "E5", 200, 280, SP_UNIT_MM }, | 174 | { "E5", 200, 280, "mm" }, |
4684 | 174 | { "E6", 140, 200, SP_UNIT_MM }, | 175 | { "E6", 140, 200, "mm" }, |
4685 | 175 | //#endif | 176 | //#endif |
4686 | 176 | 177 | ||
4687 | 177 | 178 | ||
4688 | 178 | 179 | ||
4691 | 179 | { "CSE", 462, 649, SP_UNIT_PT }, | 180 | { "CSE", 462, 649, "pt" }, |
4692 | 180 | { "US #10 Envelope", 4.125, 9.5, SP_UNIT_IN }, | 181 | { "US #10 Envelope", 4.125, 9.5, "in" }, |
4693 | 181 | /* See http://www.hbp.com/content/PCR_envelopes.cfm for a much larger list of US envelope | 182 | /* See http://www.hbp.com/content/PCR_envelopes.cfm for a much larger list of US envelope |
4694 | 182 | sizes. */ | 183 | sizes. */ |
4697 | 183 | { "DL Envelope", 110, 220, SP_UNIT_MM }, | 184 | { "DL Envelope", 110, 220, "mm" }, |
4698 | 184 | { "Ledger/Tabloid", 11, 17, SP_UNIT_IN }, | 185 | { "Ledger/Tabloid", 11, 17, "in" }, |
4699 | 185 | /* Note that `Folio' (used in QPrinter/KPrinter) is deliberately absent from this list, as it | 186 | /* Note that `Folio' (used in QPrinter/KPrinter) is deliberately absent from this list, as it |
4700 | 186 | means different sizes to different people: different people may expect the width to be | 187 | means different sizes to different people: different people may expect the width to be |
4701 | 187 | either 8, 8.25 or 8.5 inches, and the height to be either 13 or 13.5 inches, even | 188 | either 8, 8.25 or 8.5 inches, and the height to be either 13 or 13.5 inches, even |
4702 | 188 | restricting our interpretation to foolscap folio. If you wish to introduce a folio-like | 189 | restricting our interpretation to foolscap folio. If you wish to introduce a folio-like |
4703 | 189 | page size to the list, then please consider using a name more specific than just `Folio' or | 190 | page size to the list, then please consider using a name more specific than just `Folio' or |
4704 | 190 | `Foolscap Folio'. */ | 191 | `Foolscap Folio'. */ |
4709 | 191 | { "Banner 468x60", 60, 468, SP_UNIT_PX }, | 192 | { "Banner 468x60", 60, 468, "px" }, |
4710 | 192 | { "Icon 16x16", 16, 16, SP_UNIT_PX }, | 193 | { "Icon 16x16", 16, 16, "px" }, |
4711 | 193 | { "Icon 32x32", 32, 32, SP_UNIT_PX }, | 194 | { "Icon 32x32", 32, 32, "px" }, |
4712 | 194 | { "Icon 48x48", 48, 48, SP_UNIT_PX }, | 195 | { "Icon 48x48", 48, 48, "px" }, |
4713 | 195 | /* business cards */ | 196 | /* business cards */ |
4718 | 196 | { "Business Card (ISO 7810)", 53.98, 85.60, SP_UNIT_MM }, | 197 | { "Business Card (ISO 7810)", 53.98, 85.60, "mm" }, |
4719 | 197 | { "Business Card (US)", 2, 3.5, SP_UNIT_IN }, | 198 | { "Business Card (US)", 2, 3.5, "in" }, |
4720 | 198 | { "Business Card (Europe)", 55, 85, SP_UNIT_MM }, | 199 | { "Business Card (Europe)", 55, 85, "mm" }, |
4721 | 199 | { "Business Card (Aus/NZ)", 55, 90, SP_UNIT_MM }, | 200 | { "Business Card (Aus/NZ)", 55, 90, "mm" }, |
4722 | 200 | 201 | ||
4723 | 201 | // Start Arch Series List | 202 | // Start Arch Series List |
4724 | 202 | 203 | ||
4725 | 203 | 204 | ||
4732 | 204 | { "Arch A", 9, 12, SP_UNIT_IN }, // 229 x 305 mm | 205 | { "Arch A", 9, 12, "in" }, // 229 x 305 mm |
4733 | 205 | { "Arch B", 12, 18, SP_UNIT_IN }, // 305 x 457 mm | 206 | { "Arch B", 12, 18, "in" }, // 305 x 457 mm |
4734 | 206 | { "Arch C", 18, 24, SP_UNIT_IN }, // 457 x 610 mm | 207 | { "Arch C", 18, 24, "in" }, // 457 x 610 mm |
4735 | 207 | { "Arch D", 24, 36, SP_UNIT_IN }, // 610 x 914 mm | 208 | { "Arch D", 24, 36, "in" }, // 610 x 914 mm |
4736 | 208 | { "Arch E", 36, 48, SP_UNIT_IN }, // 914 x 1219 mm | 209 | { "Arch E", 36, 48, "in" }, // 914 x 1219 mm |
4737 | 209 | { "Arch E1", 30, 42, SP_UNIT_IN }, // 762 x 1067 mm | 210 | { "Arch E1", 30, 42, "in" }, // 762 x 1067 mm |
4738 | 210 | 211 | ||
4739 | 211 | /* | 212 | /* |
4740 | 212 | * The above list of Arch sizes were taken from the following site: | 213 | * The above list of Arch sizes were taken from the following site: |
4741 | @@ -217,7 +218,7 @@ | |||
4742 | 217 | * September 2009 - DAK | 218 | * September 2009 - DAK |
4743 | 218 | */ | 219 | */ |
4744 | 219 | 220 | ||
4746 | 220 | { NULL, 0, 0, SP_UNIT_PX }, | 221 | { NULL, 0, 0, "px" }, |
4747 | 221 | }; | 222 | }; |
4748 | 222 | 223 | ||
4749 | 223 | 224 | ||
4750 | @@ -226,10 +227,6 @@ | |||
4751 | 226 | //# P A G E S I Z E R | 227 | //# P A G E S I Z E R |
4752 | 227 | //######################################################################## | 228 | //######################################################################## |
4753 | 228 | 229 | ||
4754 | 229 | //The default unit for this widget and its calculations | ||
4755 | 230 | static const SPUnit _px_unit = sp_unit_get_by_id (SP_UNIT_PX); | ||
4756 | 231 | |||
4757 | 232 | |||
4758 | 233 | /** | 230 | /** |
4759 | 234 | * Constructor | 231 | * Constructor |
4760 | 235 | */ | 232 | */ |
4761 | @@ -280,13 +277,8 @@ | |||
4762 | 280 | char formatBuf[80]; | 277 | char formatBuf[80]; |
4763 | 281 | snprintf(formatBuf, 79, "%0.1f x %0.1f", p->smaller, p->larger); | 278 | snprintf(formatBuf, 79, "%0.1f x %0.1f", p->smaller, p->larger); |
4764 | 282 | Glib::ustring desc = formatBuf; | 279 | Glib::ustring desc = formatBuf; |
4772 | 283 | if (p->unit == SP_UNIT_IN) | 280 | desc.append(" " + p->unit); |
4773 | 284 | desc.append(" in"); | 281 | PaperSize paper(name, p->smaller, p->larger, unit_table.getUnit(p->unit)); |
4767 | 285 | else if (p->unit == SP_UNIT_MM) | ||
4768 | 286 | desc.append(" mm"); | ||
4769 | 287 | else if (p->unit == SP_UNIT_PX) | ||
4770 | 288 | desc.append(" px"); | ||
4771 | 289 | PaperSize paper(name, p->smaller, p->larger, p->unit); | ||
4774 | 290 | _paperSizeTable[name] = paper; | 282 | _paperSizeTable[name] = paper; |
4775 | 291 | Gtk::TreeModel::Row row = *(_paperSizeListStore->append()); | 283 | Gtk::TreeModel::Row row = *(_paperSizeListStore->append()); |
4776 | 292 | row[_paperSizeListColumns.nameColumn] = name; | 284 | row[_paperSizeListColumns.nameColumn] = name; |
4777 | @@ -320,9 +312,9 @@ | |||
4778 | 320 | SPNamedView *nv = sp_desktop_namedview(dt); | 312 | SPNamedView *nv = sp_desktop_namedview(dt); |
4779 | 321 | _wr.setUpdating (true); | 313 | _wr.setUpdating (true); |
4780 | 322 | if (nv->units) { | 314 | if (nv->units) { |
4782 | 323 | _dimensionUnits.setUnit(nv->units); | 315 | _dimensionUnits.setUnit(nv->units->abbr); |
4783 | 324 | } else if (nv->doc_units) { | 316 | } else if (nv->doc_units) { |
4785 | 325 | _dimensionUnits.setUnit(nv->doc_units); | 317 | _dimensionUnits.setUnit(nv->doc_units->abbr); |
4786 | 326 | } | 318 | } |
4787 | 327 | _wr.setUpdating (false); | 319 | _wr.setUpdating (false); |
4788 | 328 | 320 | ||
4789 | @@ -484,8 +476,8 @@ | |||
4790 | 484 | if (SP_ACTIVE_DESKTOP && !_widgetRegistry->isUpdating()) { | 476 | if (SP_ACTIVE_DESKTOP && !_widgetRegistry->isUpdating()) { |
4791 | 485 | SPDocument *doc = sp_desktop_document(SP_ACTIVE_DESKTOP); | 477 | SPDocument *doc = sp_desktop_document(SP_ACTIVE_DESKTOP); |
4792 | 486 | double const old_height = doc->getHeight(); | 478 | double const old_height = doc->getHeight(); |
4795 | 487 | doc->setWidth (w, &_px_unit); | 479 | doc->setWidth (Inkscape::Util::Quantity(w, "px")); |
4796 | 488 | doc->setHeight (h, &_px_unit); | 480 | doc->setHeight (Inkscape::Util::Quantity(h, "px")); |
4797 | 489 | // The origin for the user is in the lower left corner; this point should remain stationary when | 481 | // The origin for the user is in the lower left corner; this point should remain stationary when |
4798 | 490 | // changing the page size. The SVG's origin however is in the upper left corner, so we must compensate for this | 482 | // changing the page size. The SVG's origin however is in the upper left corner, so we must compensate for this |
4799 | 491 | Geom::Translate const vert_offset(Geom::Point(0, (old_height - h))); | 483 | Geom::Translate const vert_offset(Geom::Point(0, (old_height - h))); |
4800 | @@ -569,9 +561,9 @@ | |||
4801 | 569 | for (iter = _paperSizeTable.begin() ; | 561 | for (iter = _paperSizeTable.begin() ; |
4802 | 570 | iter != _paperSizeTable.end() ; ++iter) { | 562 | iter != _paperSizeTable.end() ; ++iter) { |
4803 | 571 | PaperSize paper = iter->second; | 563 | PaperSize paper = iter->second; |
4807 | 572 | SPUnit const &i_unit = sp_unit_get_by_id(paper.unit); | 564 | Inkscape::Util::Unit const &i_unit = paper.unit; |
4808 | 573 | double smallX = sp_units_get_pixels(paper.smaller, i_unit); | 565 | double smallX = Inkscape::Util::Quantity::convert(paper.smaller, i_unit, "px"); |
4809 | 574 | double largeX = sp_units_get_pixels(paper.larger, i_unit); | 566 | double largeX = Inkscape::Util::Quantity::convert(paper.larger, i_unit, "px"); |
4810 | 575 | 567 | ||
4811 | 576 | g_return_val_if_fail(smallX <= largeX, _paperSizeListStore->children().end()); | 568 | g_return_val_if_fail(smallX <= largeX, _paperSizeListStore->children().end()); |
4812 | 577 | 569 | ||
4813 | @@ -662,9 +654,8 @@ | |||
4814 | 662 | _landscape = _landscapeButton.get_active(); | 654 | _landscape = _landscapeButton.get_active(); |
4815 | 663 | } | 655 | } |
4816 | 664 | 656 | ||
4820 | 665 | SPUnit const &src_unit = sp_unit_get_by_id (paper.unit); | 657 | w = Inkscape::Util::Quantity::convert(w, paper.unit, "px"); |
4821 | 666 | sp_convert_distance (&w, &src_unit, &_px_unit); | 658 | h = Inkscape::Util::Quantity::convert(h, paper.unit, "px"); |
4819 | 667 | sp_convert_distance (&h, &src_unit, &_px_unit); | ||
4822 | 668 | 659 | ||
4823 | 669 | if (_landscape) | 660 | if (_landscape) |
4824 | 670 | setDim (h, w, false); | 661 | setDim (h, w, false); |
4825 | 671 | 662 | ||
4826 | === modified file 'src/ui/widget/page-sizer.h' | |||
4827 | --- src/ui/widget/page-sizer.h 2012-12-16 11:57:38 +0000 | |||
4828 | +++ src/ui/widget/page-sizer.h 2013-08-06 18:46:25 +0000 | |||
4829 | @@ -18,7 +18,7 @@ | |||
4830 | 18 | #include "ui/widget/registered-widget.h" | 18 | #include "ui/widget/registered-widget.h" |
4831 | 19 | #include <sigc++/sigc++.h> | 19 | #include <sigc++/sigc++.h> |
4832 | 20 | 20 | ||
4834 | 21 | #include "helper/units.h" | 21 | #include "util/units.h" |
4835 | 22 | 22 | ||
4836 | 23 | #include <gtkmm/alignment.h> | 23 | #include <gtkmm/alignment.h> |
4837 | 24 | #include <gtkmm/expander.h> | 24 | #include <gtkmm/expander.h> |
4838 | @@ -64,7 +64,7 @@ | |||
4839 | 64 | PaperSize(const Glib::ustring &nameArg, | 64 | PaperSize(const Glib::ustring &nameArg, |
4840 | 65 | double smallerArg, | 65 | double smallerArg, |
4841 | 66 | double largerArg, | 66 | double largerArg, |
4843 | 67 | SPUnitId unitArg) | 67 | Inkscape::Util::Unit unitArg) |
4844 | 68 | { | 68 | { |
4845 | 69 | name = nameArg; | 69 | name = nameArg; |
4846 | 70 | smaller = smallerArg; | 70 | smaller = smallerArg; |
4847 | @@ -108,7 +108,7 @@ | |||
4848 | 108 | /** | 108 | /** |
4849 | 109 | * The units (px, pt, mm, etc) of this specification | 109 | * The units (px, pt, mm, etc) of this specification |
4850 | 110 | */ | 110 | */ |
4852 | 111 | SPUnitId unit; | 111 | Inkscape::Util::Unit unit; |
4853 | 112 | 112 | ||
4854 | 113 | private: | 113 | private: |
4855 | 114 | 114 | ||
4856 | @@ -117,7 +117,7 @@ | |||
4857 | 117 | name = ""; | 117 | name = ""; |
4858 | 118 | smaller = 0.0; | 118 | smaller = 0.0; |
4859 | 119 | larger = 0.0; | 119 | larger = 0.0; |
4861 | 120 | unit = SP_UNIT_PX; | 120 | unit = unit_table.getUnit("px"); |
4862 | 121 | } | 121 | } |
4863 | 122 | 122 | ||
4864 | 123 | void assign(const PaperSize &other) | 123 | void assign(const PaperSize &other) |
4865 | 124 | 124 | ||
4866 | === modified file 'src/ui/widget/registered-widget.cpp' | |||
4867 | --- src/ui/widget/registered-widget.cpp 2012-04-28 15:49:30 +0000 | |||
4868 | +++ src/ui/widget/registered-widget.cpp 2013-08-06 18:46:25 +0000 | |||
4869 | @@ -27,7 +27,6 @@ | |||
4870 | 27 | #include "ui/widget/random.h" | 27 | #include "ui/widget/random.h" |
4871 | 28 | #include "widgets/spinbutton-events.h" | 28 | #include "widgets/spinbutton-events.h" |
4872 | 29 | 29 | ||
4873 | 30 | #include "helper/units.h" | ||
4874 | 31 | #include "xml/repr.h" | 30 | #include "xml/repr.h" |
4875 | 32 | #include "svg/svg-color.h" | 31 | #include "svg/svg-color.h" |
4876 | 33 | #include "svg/stringstream.h" | 32 | #include "svg/stringstream.h" |
4877 | @@ -118,9 +117,9 @@ | |||
4878 | 118 | } | 117 | } |
4879 | 119 | 118 | ||
4880 | 120 | void | 119 | void |
4882 | 121 | RegisteredUnitMenu::setUnit (const SPUnit* unit) | 120 | RegisteredUnitMenu::setUnit (Glib::ustring unit) |
4883 | 122 | { | 121 | { |
4885 | 123 | getUnitMenu()->setUnit (sp_unit_get_abbreviation (unit)); | 122 | getUnitMenu()->setUnit(unit); |
4886 | 124 | } | 123 | } |
4887 | 125 | 124 | ||
4888 | 126 | void | 125 | void |
4889 | 127 | 126 | ||
4890 | === modified file 'src/ui/widget/registered-widget.h' | |||
4891 | --- src/ui/widget/registered-widget.h 2013-08-03 20:45:01 +0000 | |||
4892 | +++ src/ui/widget/registered-widget.h 2013-08-06 18:46:25 +0000 | |||
4893 | @@ -32,7 +32,6 @@ | |||
4894 | 32 | 32 | ||
4895 | 33 | #include <gtkmm/checkbutton.h> | 33 | #include <gtkmm/checkbutton.h> |
4896 | 34 | 34 | ||
4897 | 35 | struct SPUnit; | ||
4898 | 36 | class SPDocument; | 35 | class SPDocument; |
4899 | 37 | 36 | ||
4900 | 38 | namespace Gtk { | 37 | namespace Gtk { |
4901 | @@ -167,7 +166,7 @@ | |||
4902 | 167 | Inkscape::XML::Node* repr_in = NULL, | 166 | Inkscape::XML::Node* repr_in = NULL, |
4903 | 168 | SPDocument *doc_in = NULL ); | 167 | SPDocument *doc_in = NULL ); |
4904 | 169 | 168 | ||
4906 | 170 | void setUnit (const SPUnit*); | 169 | void setUnit (const Glib::ustring); |
4907 | 171 | Unit getUnit() const { return static_cast<UnitMenu*>(_widget)->getUnit(); }; | 170 | Unit getUnit() const { return static_cast<UnitMenu*>(_widget)->getUnit(); }; |
4908 | 172 | UnitMenu* getUnitMenu() const { return static_cast<UnitMenu*>(_widget); }; | 171 | UnitMenu* getUnitMenu() const { return static_cast<UnitMenu*>(_widget); }; |
4909 | 173 | sigc::connection _changed_connection; | 172 | sigc::connection _changed_connection; |
4910 | 174 | 173 | ||
4911 | === modified file 'src/ui/widget/rendering-options.cpp' | |||
4912 | --- src/ui/widget/rendering-options.cpp 2013-03-25 17:42:31 +0000 | |||
4913 | +++ src/ui/widget/rendering-options.cpp 2013-08-06 18:46:25 +0000 | |||
4914 | @@ -13,7 +13,7 @@ | |||
4915 | 13 | #endif | 13 | #endif |
4916 | 14 | 14 | ||
4917 | 15 | #include "rendering-options.h" | 15 | #include "rendering-options.h" |
4919 | 16 | #include "unit-constants.h" | 16 | #include "util/units.h" |
4920 | 17 | #include <glibmm/i18n.h> | 17 | #include <glibmm/i18n.h> |
4921 | 18 | 18 | ||
4922 | 19 | namespace Inkscape { | 19 | namespace Inkscape { |
4923 | @@ -59,8 +59,8 @@ | |||
4924 | 59 | _radio_bitmap.signal_toggled().connect(sigc::mem_fun(*this, &RenderingOptions::_toggled)); | 59 | _radio_bitmap.signal_toggled().connect(sigc::mem_fun(*this, &RenderingOptions::_toggled)); |
4925 | 60 | 60 | ||
4926 | 61 | // configure default DPI | 61 | // configure default DPI |
4929 | 62 | _dpi.setRange(PT_PER_IN,2400.0); | 62 | _dpi.setRange(Inkscape::Util::Quantity::convert(1, "in", "pt"),2400.0); |
4930 | 63 | _dpi.setValue(PT_PER_IN); | 63 | _dpi.setValue(Inkscape::Util::Quantity::convert(1, "in", "pt")); |
4931 | 64 | _dpi.setIncrements(1.0,10.0); | 64 | _dpi.setIncrements(1.0,10.0); |
4932 | 65 | _dpi.setDigits(0); | 65 | _dpi.setDigits(0); |
4933 | 66 | _dpi.update(); | 66 | _dpi.update(); |
4934 | 67 | 67 | ||
4935 | === modified file 'src/ui/widget/scalar-unit.cpp' | |||
4936 | --- src/ui/widget/scalar-unit.cpp 2011-10-27 04:55:51 +0000 | |||
4937 | +++ src/ui/widget/scalar-unit.cpp 2013-08-06 18:46:25 +0000 | |||
4938 | @@ -16,6 +16,8 @@ | |||
4939 | 16 | #include "scalar-unit.h" | 16 | #include "scalar-unit.h" |
4940 | 17 | #include "spinbutton.h" | 17 | #include "spinbutton.h" |
4941 | 18 | 18 | ||
4942 | 19 | using Inkscape::Util::unit_table; | ||
4943 | 20 | |||
4944 | 19 | namespace Inkscape { | 21 | namespace Inkscape { |
4945 | 20 | namespace UI { | 22 | namespace UI { |
4946 | 21 | namespace Widget { | 23 | namespace Widget { |
4947 | @@ -226,9 +228,8 @@ | |||
4948 | 226 | Glib::ustring abbr = _unit_menu->getUnitAbbr(); | 228 | Glib::ustring abbr = _unit_menu->getUnitAbbr(); |
4949 | 227 | _suffix->set_label(abbr); | 229 | _suffix->set_label(abbr); |
4950 | 228 | 230 | ||
4954 | 229 | Inkscape::Util::UnitTable &table = _unit_menu->getUnitTable(); | 231 | Inkscape::Util::Unit new_unit = (unit_table.getUnit(abbr)); |
4955 | 230 | Inkscape::Util::Unit new_unit = (table.getUnit(abbr)); | 232 | Inkscape::Util::Unit old_unit = (unit_table.getUnit(lastUnits)); |
4953 | 231 | Inkscape::Util::Unit old_unit = (table.getUnit(lastUnits)); | ||
4956 | 232 | 233 | ||
4957 | 233 | double convertedVal = 0; | 234 | double convertedVal = 0; |
4958 | 234 | if (old_unit.type == UNIT_TYPE_DIMENSIONLESS && new_unit.type == UNIT_TYPE_LINEAR) { | 235 | if (old_unit.type == UNIT_TYPE_DIMENSIONLESS && new_unit.type == UNIT_TYPE_LINEAR) { |
4959 | 235 | 236 | ||
4960 | === modified file 'src/ui/widget/selected-style.cpp' | |||
4961 | --- src/ui/widget/selected-style.cpp 2013-03-09 13:24:32 +0000 | |||
4962 | +++ src/ui/widget/selected-style.cpp 2013-08-06 18:46:25 +0000 | |||
4963 | @@ -50,6 +50,9 @@ | |||
4964 | 50 | #include "pixmaps/cursor-adj-a.xpm" | 50 | #include "pixmaps/cursor-adj-a.xpm" |
4965 | 51 | #include "sp-cursor.h" | 51 | #include "sp-cursor.h" |
4966 | 52 | #include "gradient-chemistry.h" | 52 | #include "gradient-chemistry.h" |
4967 | 53 | #include "util/units.h" | ||
4968 | 54 | |||
4969 | 55 | using Inkscape::Util::unit_table; | ||
4970 | 53 | 56 | ||
4971 | 54 | static gdouble const _sw_presets[] = { 32 , 16 , 10 , 8 , 6 , 4 , 3 , 2 , 1.5 , 1 , 0.75 , 0.5 , 0.25 , 0.1 }; | 57 | static gdouble const _sw_presets[] = { 32 , 16 , 10 , 8 , 6 , 4 , 3 , 2 , 1.5 , 1 , 0.75 , 0.5 , 0.25 , 0.1 }; |
4972 | 55 | static gchar const *const _sw_presets_str[] = {"32", "16", "10", "8", "6", "4", "3", "2", "1.5", "1", "0.75", "0.5", "0.25", "0.1"}; | 58 | static gchar const *const _sw_presets_str[] = {"32", "16", "10", "8", "6", "4", "3", "2", "1.5", "1", "0.75", "0.5", "0.25", "0.1"}; |
4973 | @@ -306,15 +309,17 @@ | |||
4974 | 306 | { | 309 | { |
4975 | 307 | int row = 0; | 310 | int row = 0; |
4976 | 308 | 311 | ||
4980 | 309 | // List of units should match with Fill/Stroke dialog stroke style width list | 312 | Inkscape::Util::UnitTable::UnitMap m = unit_table.units(Inkscape::Util::UNIT_TYPE_LINEAR); |
4981 | 310 | for (GSList *l = sp_unit_get_list(SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE); l != NULL; l = l->next) { | 313 | Inkscape::Util::UnitTable::UnitMap::iterator iter = m.begin(); |
4982 | 311 | SPUnit const *u = static_cast<SPUnit*>(l->data); | 314 | while(iter != m.end()) { |
4983 | 312 | Gtk::RadioMenuItem *mi = Gtk::manage(new Gtk::RadioMenuItem(_sw_group)); | 315 | Gtk::RadioMenuItem *mi = Gtk::manage(new Gtk::RadioMenuItem(_sw_group)); |
4985 | 313 | mi->add(*(new Gtk::Label(u->abbr, 0.0, 0.5))); | 316 | mi->add(*(new Gtk::Label((*iter).first, 0.0, 0.5))); |
4986 | 314 | _unit_mis = g_slist_append(_unit_mis, mi); | 317 | _unit_mis = g_slist_append(_unit_mis, mi); |
4988 | 315 | mi->signal_activate().connect(sigc::bind<SPUnitId>(sigc::mem_fun(*this, &SelectedStyle::on_popup_units), u->unit_id)); | 318 | Inkscape::Util::Unit const *u = new Inkscape::Util::Unit(unit_table.getUnit(iter->first)); |
4989 | 319 | mi->signal_activate().connect(sigc::bind<Inkscape::Util::Unit>(sigc::mem_fun(*this, &SelectedStyle::on_popup_units), *u)); | ||
4990 | 316 | _popup_sw.attach(*mi, 0,1, row, row+1); | 320 | _popup_sw.attach(*mi, 0,1, row, row+1); |
4991 | 317 | row++; | 321 | row++; |
4992 | 322 | ++iter; | ||
4993 | 318 | } | 323 | } |
4994 | 319 | 324 | ||
4995 | 320 | _popup_sw.attach(*(new Gtk::SeparatorMenuItem()), 0,1, row, row+1); | 325 | _popup_sw.attach(*(new Gtk::SeparatorMenuItem()), 0,1, row, row+1); |
4996 | @@ -476,13 +481,13 @@ | |||
4997 | 476 | this ) | 481 | this ) |
4998 | 477 | )); | 482 | )); |
4999 | 478 | 483 | ||
5000 | 479 | _sw_unit = const_cast<SPUnit*>(sp_desktop_namedview(desktop)->doc_units); |
The diff has been truncated for viewing.
Hi Matthew - the merge of this branch has introduced a couple of regressions in trunk (3 reported so far):
- Bug #1215104: Inkscape crashes when exporting PNG if default unit is different than "px" /bugs.launchpad .net/inkscape/ +bug/1215104> /bugs.launchpad .net/inkscape/ +bug/1215575> /bugs.launchpad .net/inkscape/ +bug/1216306>
<https:/
- Bug #1215575: Manual text kerning not working since r12471
<https:/
- Bug #1216306: Grid parameters not working with comma as decimal separator
<https:/
I just tested your current branch for phase two (<lp:~matthewpetroff/inkscape/gsoc-2013-unit-improvement> r12484), and - since all of them are still reproducible - wanted to make you aware of these issues.