Merge lp:~inkscape.dev/inkscape/roughen into lp:~inkscape.dev/inkscape/trunk
- roughen
- Merge into trunk
Status: | Merged |
---|---|
Merge reported by: | su_v |
Merged at revision: | not available |
Proposed branch: | lp:~inkscape.dev/inkscape/roughen |
Merge into: | lp:~inkscape.dev/inkscape/trunk |
Diff against target: |
827 lines (+666/-1) 13 files modified
po/POTFILES.skip (+1/-0) src/live_effects/CMakeLists.txt (+4/-0) src/live_effects/Makefile_insert (+2/-0) src/live_effects/effect-enum.h (+1/-0) src/live_effects/effect.cpp (+15/-1) src/live_effects/lpe-roughen.cpp (+349/-0) src/live_effects/lpe-roughen.h (+63/-0) src/live_effects/parameter/Makefile_insert (+2/-0) src/live_effects/parameter/togglebutton.cpp (+92/-0) src/live_effects/parameter/togglebutton.h (+56/-0) src/ui/tools/node-tool.h (+3/-0) src/ui/widget/registered-widget.cpp (+53/-0) src/ui/widget/registered-widget.h (+25/-0) |
To merge this branch: | bzr merge lp:~inkscape.dev/inkscape/roughen |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Inkscape Developers | Pending | ||
Review via email: mp+217357@code.launchpad.net |
Commit message
Description of the change
Add a new LPE that mix this extensions: "add nodes" + "Jitter nodes"
An aidea by Josh Andler.
- 13308. By Jabiertxof <email address hidden>
-
fix a bug in closed paths
- 13309. By Jabiertxof <email address hidden>
-
fix a bug in closed paths
- 13310. By Jabiertxof <email address hidden>
-
improving closed paths
- 13311. By Jabiertxof <email address hidden>
-
improving closed paths
- 13312. By Jabiertxof <email address hidden>
-
improving closed paths
- 13313. By Jabiertxof <email address hidden>
-
Now the shift X&Y values accept only positive values and the random result are divided by 2 and randomly *-1
- 13314. By Jabiertxof <email address hidden>
-
Removed the division by 2 in the random Shift values, think is more clear,now sifth X sice from pont
- 13315. By Jabiertxof <email address hidden>
-
Removed the division by 2 in the random Shift values, now shift X&Y size to ponts
- 13316. By Jabiertxof <email address hidden>
-
update to trunk
- 13317. By Jabiertxof <email address hidden>
-
Fixed unit problem in subdivide by max lenght
- 13318. By Jabiertxof <email address hidden>
-
Now handles no subdivision - number of segments = 1
- 13319. By Jabiertxof <email address hidden>
-
2 attempt: Now handles no subdivision - number of segments = 1
- 13320. By Jabiertxof <email address hidden>
-
fixing closing straight lines whith no subdivision
- 13321. By Jabiertxof <email address hidden>
-
Clang Format code
- 13322. By Jabiertxof <email address hidden>
-
update to trunk
- 13323. By Jabiertxof <email address hidden>
-
update to trunk
- 13324. By Jabiertxof <email address hidden>
-
update to trunk
- 13325. By Jabiertxof <email address hidden>
-
update to trunk
- 13326. By Jabiertxof <email address hidden>
-
update to trunk
- 13327. By Jabiertxof <email address hidden>
-
Fix a bug pointed by LiamW
- 13328. By Jabiertxof <email address hidden>
-
Fix code and add crack parameters
- 13329. By Jabiertxof <email address hidden>
-
update to trunk
- 13330. By Jabiertxof <email address hidden>
-
Reorder widgets
- 13331. By Jabiertxof <email address hidden>
-
fix bug compiling
- 13332. By Jabiertxof <email address hidden>
-
fix bug compiling pointed by su_v
- 13333. By Jabiertxof <email address hidden>
-
Fix a bug in crack percent
- 13334. By Jabiertxof <email address hidden>
-
Fix a/nother bug in crack percent
- 13335. By Jabiertxof <email address hidden>
-
Code cleanup and fixed percent craked value
- 13336. By Jabiertxof <email address hidden>
-
Fix crack percent calculation
- 13337. By Jabiertxof <email address hidden>
-
Fix crack percent calculation II
- 13338. By Jabiertxof <email address hidden>
-
Fix crack percent calculation III
- 13339. By Jabiertxof <email address hidden>
-
Fixed crack percent calculation
- 13340. By Jabiertxof <email address hidden>
-
removed craked work, waiting to KK work on boolean operations, also some code formating
- 13341. By Jabiertxof <email address hidden>
-
update to trunk
su_v (suv-lp) wrote : | # |
Preview Diff
1 | === modified file 'po/POTFILES.skip' | |||
2 | --- po/POTFILES.skip 2010-01-14 08:13:09 +0000 | |||
3 | +++ po/POTFILES.skip 2014-09-15 15:24:25 +0000 | |||
4 | @@ -25,6 +25,7 @@ | |||
5 | 25 | src/live_effects/lpe-tangent_to_curve.cpp | 25 | src/live_effects/lpe-tangent_to_curve.cpp |
6 | 26 | src/live_effects/lpe-test-doEffect-stack.cpp | 26 | src/live_effects/lpe-test-doEffect-stack.cpp |
7 | 27 | src/live_effects/lpe-text_label.cpp | 27 | src/live_effects/lpe-text_label.cpp |
8 | 28 | src/live_effects/lpe-simplify.cpp | ||
9 | 28 | src/lpe-tool-context.cpp | 29 | src/lpe-tool-context.cpp |
10 | 29 | src/ui/dialog/session-player.cpp | 30 | src/ui/dialog/session-player.cpp |
11 | 30 | src/ui/dialog/whiteboard-connect.cpp | 31 | src/ui/dialog/whiteboard-connect.cpp |
12 | 31 | 32 | ||
13 | === modified file 'src/live_effects/CMakeLists.txt' | |||
14 | --- src/live_effects/CMakeLists.txt 2012-03-23 21:02:03 +0000 | |||
15 | +++ src/live_effects/CMakeLists.txt 2014-09-15 15:24:25 +0000 | |||
16 | @@ -32,6 +32,7 @@ | |||
17 | 32 | # lpe-skeleton.cpp | 32 | # lpe-skeleton.cpp |
18 | 33 | lpe-sketch.cpp | 33 | lpe-sketch.cpp |
19 | 34 | lpe-spiro.cpp | 34 | lpe-spiro.cpp |
20 | 35 | lpe-roughen.cpp | ||
21 | 35 | lpe-tangent_to_curve.cpp | 36 | lpe-tangent_to_curve.cpp |
22 | 36 | lpe-test-doEffect-stack.cpp | 37 | lpe-test-doEffect-stack.cpp |
23 | 37 | lpe-text_label.cpp | 38 | lpe-text_label.cpp |
24 | @@ -52,6 +53,7 @@ | |||
25 | 52 | parameter/powerstrokepointarray.cpp | 53 | parameter/powerstrokepointarray.cpp |
26 | 53 | parameter/random.cpp | 54 | parameter/random.cpp |
27 | 54 | parameter/text.cpp | 55 | parameter/text.cpp |
28 | 56 | parameter/togglebutton.cpp | ||
29 | 55 | parameter/unit.cpp | 57 | parameter/unit.cpp |
30 | 56 | parameter/vector.cpp | 58 | parameter/vector.cpp |
31 | 57 | 59 | ||
32 | @@ -92,6 +94,7 @@ | |||
33 | 92 | lpe-skeleton.h | 94 | lpe-skeleton.h |
34 | 93 | lpe-sketch.h | 95 | lpe-sketch.h |
35 | 94 | lpe-spiro.h | 96 | lpe-spiro.h |
36 | 97 | lpe-roughen.h | ||
37 | 95 | lpe-tangent_to_curve.h | 98 | lpe-tangent_to_curve.h |
38 | 96 | lpe-test-doEffect-stack.h | 99 | lpe-test-doEffect-stack.h |
39 | 97 | lpe-text_label.h | 100 | lpe-text_label.h |
40 | @@ -113,6 +116,7 @@ | |||
41 | 113 | parameter/powerstrokepointarray.h | 116 | parameter/powerstrokepointarray.h |
42 | 114 | parameter/random.h | 117 | parameter/random.h |
43 | 115 | parameter/text.h | 118 | parameter/text.h |
44 | 119 | parameter/togglebutton.h | ||
45 | 116 | parameter/unit.h | 120 | parameter/unit.h |
46 | 117 | parameter/vector.h | 121 | parameter/vector.h |
47 | 118 | 122 | ||
48 | 119 | 123 | ||
49 | === modified file 'src/live_effects/Makefile_insert' | |||
50 | --- src/live_effects/Makefile_insert 2012-03-23 21:02:03 +0000 | |||
51 | +++ src/live_effects/Makefile_insert 2014-09-15 15:24:25 +0000 | |||
52 | @@ -40,6 +40,8 @@ | |||
53 | 40 | live_effects/lpe-test-doEffect-stack.h \ | 40 | live_effects/lpe-test-doEffect-stack.h \ |
54 | 41 | live_effects/lpe-lattice.cpp \ | 41 | live_effects/lpe-lattice.cpp \ |
55 | 42 | live_effects/lpe-lattice.h \ | 42 | live_effects/lpe-lattice.h \ |
56 | 43 | live_effects/lpe-roughen.cpp \ | ||
57 | 44 | live_effects/lpe-roughen.h \ | ||
58 | 43 | live_effects/lpe-envelope.cpp \ | 45 | live_effects/lpe-envelope.cpp \ |
59 | 44 | live_effects/lpe-envelope.h \ | 46 | live_effects/lpe-envelope.h \ |
60 | 45 | live_effects/lpe-spiro.cpp \ | 47 | live_effects/lpe-spiro.cpp \ |
61 | 46 | 48 | ||
62 | === modified file 'src/live_effects/effect-enum.h' | |||
63 | --- src/live_effects/effect-enum.h 2012-01-12 21:06:16 +0000 | |||
64 | +++ src/live_effects/effect-enum.h 2014-09-15 15:24:25 +0000 | |||
65 | @@ -28,6 +28,7 @@ | |||
66 | 28 | PERSPECTIVE_PATH, | 28 | PERSPECTIVE_PATH, |
67 | 29 | SPIRO, | 29 | SPIRO, |
68 | 30 | LATTICE, | 30 | LATTICE, |
69 | 31 | ROUGHEN, | ||
70 | 31 | ENVELOPE, | 32 | ENVELOPE, |
71 | 32 | CONSTRUCT_GRID, | 33 | CONSTRUCT_GRID, |
72 | 33 | PERP_BISECTOR, | 34 | PERP_BISECTOR, |
73 | 34 | 35 | ||
74 | === modified file 'src/live_effects/effect.cpp' | |||
75 | --- src/live_effects/effect.cpp 2014-05-05 08:40:12 +0000 | |||
76 | +++ src/live_effects/effect.cpp 2014-09-15 15:24:25 +0000 | |||
77 | @@ -25,6 +25,7 @@ | |||
78 | 25 | #include "live_effects/lpe-perspective_path.h" | 25 | #include "live_effects/lpe-perspective_path.h" |
79 | 26 | #include "live_effects/lpe-spiro.h" | 26 | #include "live_effects/lpe-spiro.h" |
80 | 27 | #include "live_effects/lpe-lattice.h" | 27 | #include "live_effects/lpe-lattice.h" |
81 | 28 | #include "live_effects/lpe-roughen.h" | ||
82 | 28 | #include "live_effects/lpe-envelope.h" | 29 | #include "live_effects/lpe-envelope.h" |
83 | 29 | #include "live_effects/lpe-constructgrid.h" | 30 | #include "live_effects/lpe-constructgrid.h" |
84 | 30 | #include "live_effects/lpe-perp_bisector.h" | 31 | #include "live_effects/lpe-perp_bisector.h" |
85 | @@ -120,6 +121,7 @@ | |||
86 | 120 | /* 0.49 */ | 121 | /* 0.49 */ |
87 | 121 | {POWERSTROKE, N_("Power stroke"), "powerstroke"}, | 122 | {POWERSTROKE, N_("Power stroke"), "powerstroke"}, |
88 | 122 | {CLONE_ORIGINAL, N_("Clone original path"), "clone_original"}, | 123 | {CLONE_ORIGINAL, N_("Clone original path"), "clone_original"}, |
89 | 124 | {ROUGHEN, N_("Roughen"), "roughen"}, | ||
90 | 123 | }; | 125 | }; |
91 | 124 | const Util::EnumDataConverter<EffectType> LPETypeConverter(LPETypeData, sizeof(LPETypeData)/sizeof(*LPETypeData)); | 126 | const Util::EnumDataConverter<EffectType> LPETypeConverter(LPETypeData, sizeof(LPETypeData)/sizeof(*LPETypeData)); |
92 | 125 | 127 | ||
93 | @@ -243,6 +245,9 @@ | |||
94 | 243 | case CLONE_ORIGINAL: | 245 | case CLONE_ORIGINAL: |
95 | 244 | neweffect = static_cast<Effect*> ( new LPECloneOriginal(lpeobj) ); | 246 | neweffect = static_cast<Effect*> ( new LPECloneOriginal(lpeobj) ); |
96 | 245 | break; | 247 | break; |
97 | 248 | case ROUGHEN: | ||
98 | 249 | neweffect = static_cast<Effect*> ( new LPERoughen(lpeobj) ); | ||
99 | 250 | break; | ||
100 | 246 | default: | 251 | default: |
101 | 247 | g_warning("LivePathEffect::Effect::New called with invalid patheffect type (%d)", lpenr); | 252 | g_warning("LivePathEffect::Effect::New called with invalid patheffect type (%d)", lpenr); |
102 | 248 | neweffect = NULL; | 253 | neweffect = NULL; |
103 | @@ -496,7 +501,16 @@ | |||
104 | 496 | 501 | ||
105 | 497 | if (!SP_IS_SHAPE(lpeitem)) { | 502 | if (!SP_IS_SHAPE(lpeitem)) { |
106 | 498 | // g_print ("How to handle helperpaths for non-shapes?\n"); // non-shapes are for example SPGroups. | 503 | // g_print ("How to handle helperpaths for non-shapes?\n"); // non-shapes are for example SPGroups. |
108 | 499 | return hp_vec; | 504 | // return hp_vec; |
109 | 505 | } | ||
110 | 506 | |||
111 | 507 | |||
112 | 508 | // TODO: we can probably optimize this by using a lot more references | ||
113 | 509 | // rather than copying PathVectors all over the place | ||
114 | 510 | if (SP_IS_SHAPE(lpeitem) && show_orig_path) { | ||
115 | 511 | // add original path to helperpaths | ||
116 | 512 | SPCurve* curve = SP_SHAPE(lpeitem)->getCurve (); | ||
117 | 513 | hp_vec.push_back(curve->get_pathvector()); | ||
118 | 500 | } | 514 | } |
119 | 501 | 515 | ||
120 | 502 | // add indicators provided by the effect itself | 516 | // add indicators provided by the effect itself |
121 | 503 | 517 | ||
122 | === added file 'src/live_effects/lpe-roughen.cpp' | |||
123 | --- src/live_effects/lpe-roughen.cpp 1970-01-01 00:00:00 +0000 | |||
124 | +++ src/live_effects/lpe-roughen.cpp 2014-09-15 15:24:25 +0000 | |||
125 | @@ -0,0 +1,349 @@ | |||
126 | 1 | /** | ||
127 | 2 | * @file | ||
128 | 3 | * Roughen LPE implementation. Creates roughen paths. | ||
129 | 4 | */ | ||
130 | 5 | /* Authors: | ||
131 | 6 | * Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | ||
132 | 7 | * | ||
133 | 8 | * Thanks to all people involved specialy to Josh Andler for the idea and to the | ||
134 | 9 | * original extensions authors. | ||
135 | 10 | * | ||
136 | 11 | * Copyright (C) 2014 Authors | ||
137 | 12 | * | ||
138 | 13 | * Released under GNU GPL, read the file 'COPYING' for more information | ||
139 | 14 | */ | ||
140 | 15 | |||
141 | 16 | #include <gtkmm.h> | ||
142 | 17 | |||
143 | 18 | #include "live_effects/lpe-roughen.h" | ||
144 | 19 | #include "display/curve.h" | ||
145 | 20 | #include "live_effects/parameter/parameter.h" | ||
146 | 21 | #include "helper/geom.h" | ||
147 | 22 | #include <glibmm/i18n.h> | ||
148 | 23 | #include <cmath> | ||
149 | 24 | |||
150 | 25 | namespace Inkscape { | ||
151 | 26 | namespace LivePathEffect { | ||
152 | 27 | |||
153 | 28 | static const Util::EnumData<DivisionMethod> DivisionMethodData[DM_END] = { | ||
154 | 29 | { DM_SEGMENTS, N_("By number of segments"), "segments" }, | ||
155 | 30 | { DM_SIZE, N_("By max. segment size"), "size" } | ||
156 | 31 | }; | ||
157 | 32 | static const Util::EnumDataConverter<DivisionMethod> | ||
158 | 33 | DMConverter(DivisionMethodData, DM_END); | ||
159 | 34 | |||
160 | 35 | LPERoughen::LPERoughen(LivePathEffectObject *lpeobject) | ||
161 | 36 | : Effect(lpeobject), | ||
162 | 37 | // initialise your parameters here: | ||
163 | 38 | unit(_("Unit"), _("Unit"), "unit", &wr, this), | ||
164 | 39 | method(_("Method"), _("Division method"), "method", DMConverter, &wr, | ||
165 | 40 | this, DM_SEGMENTS), | ||
166 | 41 | maxSegmentSize(_("Max. segment size"), _("Max. segment size"), | ||
167 | 42 | "maxSegmentSize", &wr, this, 10.), | ||
168 | 43 | segments(_("Number of segments"), _("Number of segments"), "segments", | ||
169 | 44 | &wr, this, 2), | ||
170 | 45 | displaceX(_("Max. displacement in X"), _("Max. displacement in X"), | ||
171 | 46 | "displaceX", &wr, this, 10.), | ||
172 | 47 | displaceY(_("Max. displacement in Y"), _("Max. displacement in Y"), | ||
173 | 48 | "displaceY", &wr, this, 10.), | ||
174 | 49 | shiftNodes(_("Shift nodes"), _("Shift nodes"), "shiftNodes", &wr, this, | ||
175 | 50 | true), | ||
176 | 51 | shiftNodeHandles(_("Shift node handles"), _("Shift node handles"), | ||
177 | 52 | "shiftNodeHandles", &wr, this, true) | ||
178 | 53 | { | ||
179 | 54 | registerParameter(&unit); | ||
180 | 55 | registerParameter(&method); | ||
181 | 56 | registerParameter(&maxSegmentSize); | ||
182 | 57 | registerParameter(&segments); | ||
183 | 58 | registerParameter(&displaceX); | ||
184 | 59 | registerParameter(&displaceY); | ||
185 | 60 | registerParameter(&shiftNodes); | ||
186 | 61 | registerParameter(&shiftNodeHandles); | ||
187 | 62 | displaceX.param_set_range(0., Geom::infinity()); | ||
188 | 63 | displaceY.param_set_range(0., Geom::infinity()); | ||
189 | 64 | maxSegmentSize.param_set_range(0., Geom::infinity()); | ||
190 | 65 | maxSegmentSize.param_set_increments(1, 1); | ||
191 | 66 | maxSegmentSize.param_set_digits(1); | ||
192 | 67 | segments.param_set_range(1, Geom::infinity()); | ||
193 | 68 | segments.param_set_increments(1, 1); | ||
194 | 69 | segments.param_set_digits(0); | ||
195 | 70 | } | ||
196 | 71 | |||
197 | 72 | LPERoughen::~LPERoughen() {} | ||
198 | 73 | |||
199 | 74 | void LPERoughen::doBeforeEffect(SPLPEItem const */*lpeitem*/) | ||
200 | 75 | { | ||
201 | 76 | displaceX.resetRandomizer(); | ||
202 | 77 | displaceY.resetRandomizer(); | ||
203 | 78 | srand(1); | ||
204 | 79 | } | ||
205 | 80 | |||
206 | 81 | Gtk::Widget *LPERoughen::newWidget() | ||
207 | 82 | { | ||
208 | 83 | Gtk::VBox *vbox = Gtk::manage(new Gtk::VBox(Effect::newWidget())); | ||
209 | 84 | vbox->set_border_width(5); | ||
210 | 85 | vbox->set_homogeneous(false); | ||
211 | 86 | vbox->set_spacing(2); | ||
212 | 87 | std::vector<Parameter *>::iterator it = param_vector.begin(); | ||
213 | 88 | while (it != param_vector.end()) { | ||
214 | 89 | if ((*it)->widget_is_visible) { | ||
215 | 90 | Parameter *param = *it; | ||
216 | 91 | Gtk::Widget *widg = dynamic_cast<Gtk::Widget *>(param->param_newWidget()); | ||
217 | 92 | if (param->param_key == "unit") { | ||
218 | 93 | Gtk::Label *unitLabel = Gtk::manage(new Gtk::Label( | ||
219 | 94 | Glib::ustring(_("<b>Roughen unit</b>")), Gtk::ALIGN_START)); | ||
220 | 95 | unitLabel->set_use_markup(true); | ||
221 | 96 | vbox->pack_start(*unitLabel, false, false, 2); | ||
222 | 97 | vbox->pack_start(*Gtk::manage(new Gtk::HSeparator()), | ||
223 | 98 | Gtk::PACK_EXPAND_WIDGET); | ||
224 | 99 | } | ||
225 | 100 | if (param->param_key == "method") { | ||
226 | 101 | Gtk::Label *methodLabel = Gtk::manage(new Gtk::Label( | ||
227 | 102 | Glib::ustring(_("<b>Add nodes</b> Subdivide each segment")), | ||
228 | 103 | Gtk::ALIGN_START)); | ||
229 | 104 | methodLabel->set_use_markup(true); | ||
230 | 105 | vbox->pack_start(*methodLabel, false, false, 2); | ||
231 | 106 | vbox->pack_start(*Gtk::manage(new Gtk::HSeparator()), | ||
232 | 107 | Gtk::PACK_EXPAND_WIDGET); | ||
233 | 108 | } | ||
234 | 109 | if (param->param_key == "displaceX") { | ||
235 | 110 | Gtk::Label *displaceXLabel = Gtk::manage(new Gtk::Label( | ||
236 | 111 | Glib::ustring(_("<b>Jitter nodes</b> Move nodes/handles")), | ||
237 | 112 | Gtk::ALIGN_START)); | ||
238 | 113 | displaceXLabel->set_use_markup(true); | ||
239 | 114 | vbox->pack_start(*displaceXLabel, false, false, 2); | ||
240 | 115 | vbox->pack_start(*Gtk::manage(new Gtk::HSeparator()), | ||
241 | 116 | Gtk::PACK_EXPAND_WIDGET); | ||
242 | 117 | } | ||
243 | 118 | Glib::ustring *tip = param->param_getTooltip(); | ||
244 | 119 | if (widg) { | ||
245 | 120 | vbox->pack_start(*widg, true, true, 2); | ||
246 | 121 | if (tip) { | ||
247 | 122 | widg->set_tooltip_text(*tip); | ||
248 | 123 | } else { | ||
249 | 124 | widg->set_tooltip_text(""); | ||
250 | 125 | widg->set_has_tooltip(false); | ||
251 | 126 | } | ||
252 | 127 | } | ||
253 | 128 | } | ||
254 | 129 | |||
255 | 130 | ++it; | ||
256 | 131 | } | ||
257 | 132 | return dynamic_cast<Gtk::Widget *>(vbox); | ||
258 | 133 | } | ||
259 | 134 | |||
260 | 135 | double LPERoughen::sign(double randNumber) | ||
261 | 136 | { | ||
262 | 137 | if (rand() % 100 < 49) { | ||
263 | 138 | randNumber *= -1.; | ||
264 | 139 | } | ||
265 | 140 | return randNumber; | ||
266 | 141 | } | ||
267 | 142 | |||
268 | 143 | //to use when bolean operations work done | ||
269 | 144 | /* | ||
270 | 145 | std::vector<Geom::Path> LPERoughen::getCrackCircles(SPCurve *curve){ | ||
271 | 146 | std::vector<Geom::Path> crackCircles; | ||
272 | 147 | gint seg = curve->get_segment_count()-1; | ||
273 | 148 | Piecewise<D2<SBasis> > pwd2 = paths_to_pw(curve); | ||
274 | 149 | for(type_t i = 0; i < nCracks; ++i){ | ||
275 | 150 | Geom::Circle(pwd2.pointAt((rand() % (seg * 100.))/100.),crackRadius).getPath(crackCircles); | ||
276 | 151 | } | ||
277 | 152 | return crackCircles; | ||
278 | 153 | } | ||
279 | 154 | */ | ||
280 | 155 | |||
281 | 156 | Geom::Point LPERoughen::randomize() | ||
282 | 157 | { | ||
283 | 158 | double displaceXParsed = Inkscape::Util::Quantity::convert( | ||
284 | 159 | displaceX, unit.get_abbreviation(), "px"); | ||
285 | 160 | double displaceYParsed = Inkscape::Util::Quantity::convert( | ||
286 | 161 | displaceY, unit.get_abbreviation(), "px"); | ||
287 | 162 | |||
288 | 163 | Geom::Point output = Geom::Point(sign(displaceXParsed), sign(displaceYParsed)); | ||
289 | 164 | return output; | ||
290 | 165 | } | ||
291 | 166 | |||
292 | 167 | void LPERoughen::doEffect(SPCurve *curve) | ||
293 | 168 | { | ||
294 | 169 | Geom::PathVector const original_pathv = | ||
295 | 170 | pathv_to_linear_and_cubic_beziers(curve->get_pathvector()); | ||
296 | 171 | curve->reset(); | ||
297 | 172 | for (Geom::PathVector::const_iterator path_it = original_pathv.begin(); | ||
298 | 173 | path_it != original_pathv.end(); ++path_it) { | ||
299 | 174 | if (path_it->empty()) | ||
300 | 175 | continue; | ||
301 | 176 | |||
302 | 177 | Geom::Path::const_iterator curve_it1 = path_it->begin(); | ||
303 | 178 | Geom::Path::const_iterator curve_it2 = ++(path_it->begin()); | ||
304 | 179 | Geom::Path::const_iterator curve_endit = path_it->end_default(); | ||
305 | 180 | SPCurve *nCurve = new SPCurve(); | ||
306 | 181 | if (path_it->closed()) { | ||
307 | 182 | const Geom::Curve &closingline = | ||
308 | 183 | path_it->back_closed(); | ||
309 | 184 | if (are_near(closingline.initialPoint(), closingline.finalPoint())) { | ||
310 | 185 | curve_endit = path_it->end_open(); | ||
311 | 186 | } | ||
312 | 187 | } | ||
313 | 188 | Geom::Point initialMove(0, 0); | ||
314 | 189 | if (shiftNodes) { | ||
315 | 190 | initialMove = randomize(); | ||
316 | 191 | } | ||
317 | 192 | Geom::Point initialPoint = curve_it1->initialPoint() + initialMove; | ||
318 | 193 | nCurve->moveto(initialPoint); | ||
319 | 194 | Geom::Point A0(0, 0); | ||
320 | 195 | Geom::Point A1(0, 0); | ||
321 | 196 | Geom::Point A2(0, 0); | ||
322 | 197 | Geom::Point A3(0, 0); | ||
323 | 198 | while (curve_it1 != curve_endit) { | ||
324 | 199 | Geom::CubicBezier const *cubic = NULL; | ||
325 | 200 | A0 = curve_it1->initialPoint(); | ||
326 | 201 | A1 = curve_it1->initialPoint(); | ||
327 | 202 | A2 = curve_it1->finalPoint(); | ||
328 | 203 | A3 = curve_it1->finalPoint(); | ||
329 | 204 | cubic = dynamic_cast<Geom::CubicBezier const *>(&*curve_it1); | ||
330 | 205 | if (cubic) { | ||
331 | 206 | A1 = (*cubic)[1]; | ||
332 | 207 | if (shiftNodes) { | ||
333 | 208 | A1 = (*cubic)[1] + initialMove; | ||
334 | 209 | } | ||
335 | 210 | A2 = (*cubic)[2]; | ||
336 | 211 | nCurve->curveto(A1, A2, A3); | ||
337 | 212 | } else { | ||
338 | 213 | nCurve->lineto(A3); | ||
339 | 214 | } | ||
340 | 215 | double length = Inkscape::Util::Quantity::convert( | ||
341 | 216 | curve_it1->length(0.001), "px", unit.get_abbreviation()); | ||
342 | 217 | std::size_t splits = 0; | ||
343 | 218 | if (method == DM_SEGMENTS) { | ||
344 | 219 | splits = segments; | ||
345 | 220 | } else { | ||
346 | 221 | splits = ceil(length / maxSegmentSize); | ||
347 | 222 | } | ||
348 | 223 | for (unsigned int t = splits; t >= 1; t--) { | ||
349 | 224 | if (t == 1 && splits != 1) { | ||
350 | 225 | continue; | ||
351 | 226 | } | ||
352 | 227 | const SPCurve *tmp; | ||
353 | 228 | if (splits == 1) { | ||
354 | 229 | tmp = jitter(nCurve->last_segment()); | ||
355 | 230 | } else { | ||
356 | 231 | tmp = addNodesAndJitter(nCurve->last_segment(), 1. / t); | ||
357 | 232 | } | ||
358 | 233 | if (nCurve->get_segment_count() > 1) { | ||
359 | 234 | nCurve->backspace(); | ||
360 | 235 | nCurve->append_continuous(tmp, 0.001); | ||
361 | 236 | } else { | ||
362 | 237 | nCurve = tmp->copy(); | ||
363 | 238 | } | ||
364 | 239 | delete tmp; | ||
365 | 240 | } | ||
366 | 241 | ++curve_it1; | ||
367 | 242 | if(curve_it2 != curve_endit) { | ||
368 | 243 | ++curve_it2; | ||
369 | 244 | } | ||
370 | 245 | } | ||
371 | 246 | if (path_it->closed()) { | ||
372 | 247 | nCurve->closepath_current(); | ||
373 | 248 | } | ||
374 | 249 | curve->append(nCurve, false); | ||
375 | 250 | nCurve->reset(); | ||
376 | 251 | delete nCurve; | ||
377 | 252 | } | ||
378 | 253 | } | ||
379 | 254 | |||
380 | 255 | SPCurve *LPERoughen::addNodesAndJitter(const Geom::Curve *A, double t) | ||
381 | 256 | { | ||
382 | 257 | SPCurve *out = new SPCurve(); | ||
383 | 258 | Geom::CubicBezier const *cubic = dynamic_cast<Geom::CubicBezier const *>(&*A); | ||
384 | 259 | Geom::Point A1(0, 0); | ||
385 | 260 | Geom::Point A2(0, 0); | ||
386 | 261 | Geom::Point A3(0, 0); | ||
387 | 262 | Geom::Point B1(0, 0); | ||
388 | 263 | Geom::Point B2(0, 0); | ||
389 | 264 | Geom::Point B3(0, 0); | ||
390 | 265 | if (shiftNodes) { | ||
391 | 266 | A3 = randomize(); | ||
392 | 267 | B3 = randomize(); | ||
393 | 268 | } | ||
394 | 269 | if (shiftNodeHandles) { | ||
395 | 270 | A1 = randomize(); | ||
396 | 271 | A2 = randomize(); | ||
397 | 272 | B1 = randomize(); | ||
398 | 273 | B2 = randomize(); | ||
399 | 274 | } else { | ||
400 | 275 | A2 = A3; | ||
401 | 276 | B1 = A3; | ||
402 | 277 | B2 = B3; | ||
403 | 278 | } | ||
404 | 279 | if (cubic) { | ||
405 | 280 | std::pair<Geom::CubicBezier, Geom::CubicBezier> div = cubic->subdivide(t); | ||
406 | 281 | std::vector<Geom::Point> seg1 = div.first.points(), | ||
407 | 282 | seg2 = div.second.points(); | ||
408 | 283 | out->moveto(seg1[0]); | ||
409 | 284 | out->curveto(seg1[1] + A1, seg1[2] + A2, seg1[3] + A3); | ||
410 | 285 | out->curveto(seg2[1] + B1, seg2[2], seg2[3]); | ||
411 | 286 | } else if (shiftNodeHandles) { | ||
412 | 287 | out->moveto(A->initialPoint()); | ||
413 | 288 | out->curveto(A->pointAt(t / 3) + A1, A->pointAt((t / 3) * 2) + A2, | ||
414 | 289 | A->pointAt(t) + A3); | ||
415 | 290 | out->curveto(A->pointAt(t + (t / 3)) + B1, A->pointAt(t + ((t / 3) * 2)), | ||
416 | 291 | A->finalPoint()); | ||
417 | 292 | } else { | ||
418 | 293 | out->moveto(A->initialPoint()); | ||
419 | 294 | out->lineto(A->pointAt(t) + A3); | ||
420 | 295 | out->lineto(A->finalPoint()); | ||
421 | 296 | } | ||
422 | 297 | return out; | ||
423 | 298 | } | ||
424 | 299 | |||
425 | 300 | SPCurve *LPERoughen::jitter(const Geom::Curve *A) | ||
426 | 301 | { | ||
427 | 302 | SPCurve *out = new SPCurve(); | ||
428 | 303 | Geom::CubicBezier const *cubic = dynamic_cast<Geom::CubicBezier const *>(&*A); | ||
429 | 304 | Geom::Point A1(0, 0); | ||
430 | 305 | Geom::Point A2(0, 0); | ||
431 | 306 | Geom::Point A3(0, 0); | ||
432 | 307 | if (shiftNodes) { | ||
433 | 308 | A3 = randomize(); | ||
434 | 309 | } | ||
435 | 310 | if (shiftNodeHandles) { | ||
436 | 311 | A1 = randomize(); | ||
437 | 312 | A2 = randomize(); | ||
438 | 313 | } else { | ||
439 | 314 | A2 = A3; | ||
440 | 315 | } | ||
441 | 316 | if (cubic) { | ||
442 | 317 | out->moveto((*cubic)[0]); | ||
443 | 318 | out->curveto((*cubic)[1] + A1, (*cubic)[2] + A2, (*cubic)[3] + A3); | ||
444 | 319 | } else if (shiftNodeHandles) { | ||
445 | 320 | out->moveto(A->initialPoint()); | ||
446 | 321 | out->curveto(A->pointAt(0.3333) + A1, A->pointAt(0.6666) + A2, | ||
447 | 322 | A->finalPoint() + A3); | ||
448 | 323 | } else { | ||
449 | 324 | out->moveto(A->initialPoint()); | ||
450 | 325 | out->lineto(A->finalPoint() + A3); | ||
451 | 326 | } | ||
452 | 327 | return out; | ||
453 | 328 | } | ||
454 | 329 | |||
455 | 330 | Geom::Point LPERoughen::tpoint(Geom::Point A, Geom::Point B, double t) | ||
456 | 331 | { | ||
457 | 332 | using Geom::X; | ||
458 | 333 | using Geom::Y; | ||
459 | 334 | return Geom::Point(A[X] + t * (B[X] - A[X]), A[Y] + t * (B[Y] - A[Y])); | ||
460 | 335 | } | ||
461 | 336 | |||
462 | 337 | }; //namespace LivePathEffect | ||
463 | 338 | }; /* namespace Inkscape */ | ||
464 | 339 | |||
465 | 340 | /* | ||
466 | 341 | Local Variables: | ||
467 | 342 | mode:c++ | ||
468 | 343 | c-file-style:"stroustrup" | ||
469 | 344 | c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) | ||
470 | 345 | indent-tabs-mode:nil | ||
471 | 346 | fill-column:99 | ||
472 | 347 | End: | ||
473 | 348 | */ | ||
474 | 349 | // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : | ||
475 | 0 | 350 | ||
476 | === added file 'src/live_effects/lpe-roughen.h' | |||
477 | --- src/live_effects/lpe-roughen.h 1970-01-01 00:00:00 +0000 | |||
478 | +++ src/live_effects/lpe-roughen.h 2014-09-15 15:24:25 +0000 | |||
479 | @@ -0,0 +1,63 @@ | |||
480 | 1 | /** @file | ||
481 | 2 | * @brief Roughen LPE effect, see lpe-roughen.cpp. | ||
482 | 3 | */ | ||
483 | 4 | /* Authors: | ||
484 | 5 | * Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | ||
485 | 6 | * | ||
486 | 7 | * Copyright (C) 2014 Authors | ||
487 | 8 | * | ||
488 | 9 | * Released under GNU GPL, read the file 'COPYING' for more information | ||
489 | 10 | */ | ||
490 | 11 | |||
491 | 12 | #ifndef INKSCAPE_LPE_ROUGHEN_H | ||
492 | 13 | #define INKSCAPE_LPE_ROUGHEN_H | ||
493 | 14 | |||
494 | 15 | #include "live_effects/parameter/enum.h" | ||
495 | 16 | #include "live_effects/effect.h" | ||
496 | 17 | #include "live_effects/parameter/parameter.h" | ||
497 | 18 | #include "live_effects/parameter/path.h" | ||
498 | 19 | #include "live_effects/parameter/bool.h" | ||
499 | 20 | #include "live_effects/parameter/unit.h" | ||
500 | 21 | #include "live_effects/parameter/random.h" | ||
501 | 22 | |||
502 | 23 | namespace Inkscape { | ||
503 | 24 | namespace LivePathEffect { | ||
504 | 25 | |||
505 | 26 | enum DivisionMethod { | ||
506 | 27 | DM_SEGMENTS, | ||
507 | 28 | DM_SIZE, | ||
508 | 29 | DM_END | ||
509 | 30 | }; | ||
510 | 31 | |||
511 | 32 | class LPERoughen : public Effect { | ||
512 | 33 | |||
513 | 34 | public: | ||
514 | 35 | LPERoughen(LivePathEffectObject *lpeobject); | ||
515 | 36 | virtual ~LPERoughen(); | ||
516 | 37 | |||
517 | 38 | virtual void doEffect(SPCurve *curve); | ||
518 | 39 | virtual double sign(double randNumber); | ||
519 | 40 | virtual Geom::Point randomize(); | ||
520 | 41 | virtual void doBeforeEffect(SPLPEItem const */*lpeitem*/); | ||
521 | 42 | virtual SPCurve *addNodesAndJitter(const Geom::Curve *A, double t); | ||
522 | 43 | virtual SPCurve *jitter(const Geom::Curve *A); | ||
523 | 44 | virtual Geom::Point tpoint(Geom::Point A, Geom::Point B, double t = 0.5); | ||
524 | 45 | virtual Gtk::Widget *newWidget(); | ||
525 | 46 | |||
526 | 47 | private: | ||
527 | 48 | UnitParam unit; | ||
528 | 49 | EnumParam<DivisionMethod> method; | ||
529 | 50 | ScalarParam maxSegmentSize; | ||
530 | 51 | ScalarParam segments; | ||
531 | 52 | RandomParam displaceX; | ||
532 | 53 | RandomParam displaceY; | ||
533 | 54 | BoolParam shiftNodes; | ||
534 | 55 | BoolParam shiftNodeHandles; | ||
535 | 56 | LPERoughen(const LPERoughen &); | ||
536 | 57 | LPERoughen &operator=(const LPERoughen &); | ||
537 | 58 | |||
538 | 59 | }; | ||
539 | 60 | |||
540 | 61 | }; //namespace LivePathEffect | ||
541 | 62 | }; //namespace Inkscape | ||
542 | 63 | #endif | ||
543 | 0 | 64 | ||
544 | === modified file 'src/live_effects/parameter/Makefile_insert' | |||
545 | --- src/live_effects/parameter/Makefile_insert 2012-01-12 21:06:16 +0000 | |||
546 | +++ src/live_effects/parameter/Makefile_insert 2014-09-15 15:24:25 +0000 | |||
547 | @@ -22,6 +22,8 @@ | |||
548 | 22 | live_effects/parameter/powerstrokepointarray.h \ | 22 | live_effects/parameter/powerstrokepointarray.h \ |
549 | 23 | live_effects/parameter/text.cpp \ | 23 | live_effects/parameter/text.cpp \ |
550 | 24 | live_effects/parameter/text.h \ | 24 | live_effects/parameter/text.h \ |
551 | 25 | live_effects/parameter/togglebutton.cpp \ | ||
552 | 26 | live_effects/parameter/togglebutton.h \ | ||
553 | 25 | live_effects/parameter/unit.cpp \ | 27 | live_effects/parameter/unit.cpp \ |
554 | 26 | live_effects/parameter/unit.h \ | 28 | live_effects/parameter/unit.h \ |
555 | 27 | live_effects/parameter/vector.cpp \ | 29 | live_effects/parameter/vector.cpp \ |
556 | 28 | 30 | ||
557 | === added file 'src/live_effects/parameter/togglebutton.cpp' | |||
558 | --- src/live_effects/parameter/togglebutton.cpp 1970-01-01 00:00:00 +0000 | |||
559 | +++ src/live_effects/parameter/togglebutton.cpp 2014-09-15 15:24:25 +0000 | |||
560 | @@ -0,0 +1,92 @@ | |||
561 | 1 | /* | ||
562 | 2 | * Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl> | ||
563 | 3 | * Copyright (C) Jabiertxo Arraiza Cenoz 2014 <j.b.c.engelen@utwente.nl> | ||
564 | 4 | * | ||
565 | 5 | * Released under GNU GPL, read the file 'COPYING' for more information | ||
566 | 6 | */ | ||
567 | 7 | |||
568 | 8 | #include "ui/widget/registered-widget.h" | ||
569 | 9 | #include "live_effects/parameter/togglebutton.h" | ||
570 | 10 | #include "live_effects/effect.h" | ||
571 | 11 | #include "svg/svg.h" | ||
572 | 12 | #include "svg/stringstream.h" | ||
573 | 13 | #include "widgets/icon.h" | ||
574 | 14 | #include "inkscape.h" | ||
575 | 15 | #include "verbs.h" | ||
576 | 16 | #include "helper-fns.h" | ||
577 | 17 | #include <glibmm/i18n.h> | ||
578 | 18 | |||
579 | 19 | namespace Inkscape { | ||
580 | 20 | |||
581 | 21 | namespace LivePathEffect { | ||
582 | 22 | |||
583 | 23 | ToggleButtonParam::ToggleButtonParam( const Glib::ustring& label, const Glib::ustring& tip, | ||
584 | 24 | const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr, | ||
585 | 25 | Effect* effect, bool default_value ) | ||
586 | 26 | : Parameter(label, tip, key, wr, effect), value(default_value), defvalue(default_value) | ||
587 | 27 | { | ||
588 | 28 | } | ||
589 | 29 | |||
590 | 30 | ToggleButtonParam::~ToggleButtonParam() | ||
591 | 31 | { | ||
592 | 32 | } | ||
593 | 33 | |||
594 | 34 | void | ||
595 | 35 | ToggleButtonParam::param_set_default() | ||
596 | 36 | { | ||
597 | 37 | param_setValue(defvalue); | ||
598 | 38 | } | ||
599 | 39 | |||
600 | 40 | bool | ||
601 | 41 | ToggleButtonParam::param_readSVGValue(const gchar * strvalue) | ||
602 | 42 | { | ||
603 | 43 | param_setValue(helperfns_read_bool(strvalue, defvalue)); | ||
604 | 44 | return true; // not correct: if value is unacceptable, should return false! | ||
605 | 45 | } | ||
606 | 46 | |||
607 | 47 | gchar * | ||
608 | 48 | ToggleButtonParam::param_getSVGValue() const | ||
609 | 49 | { | ||
610 | 50 | gchar * str = g_strdup(value ? "true" : "false"); | ||
611 | 51 | return str; | ||
612 | 52 | } | ||
613 | 53 | |||
614 | 54 | Gtk::Widget * | ||
615 | 55 | ToggleButtonParam::param_newWidget() | ||
616 | 56 | { | ||
617 | 57 | Inkscape::UI::Widget::RegisteredToggleButton * checkwdg = Gtk::manage( | ||
618 | 58 | new Inkscape::UI::Widget::RegisteredToggleButton( param_label, | ||
619 | 59 | param_tooltip, | ||
620 | 60 | param_key, | ||
621 | 61 | *param_wr, | ||
622 | 62 | false, | ||
623 | 63 | param_effect->getRepr(), | ||
624 | 64 | param_effect->getSPDoc()) ); | ||
625 | 65 | |||
626 | 66 | checkwdg->setActive(value); | ||
627 | 67 | checkwdg->setProgrammatically = false; | ||
628 | 68 | checkwdg->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change togglebutton parameter")); | ||
629 | 69 | |||
630 | 70 | return dynamic_cast<Gtk::Widget *> (checkwdg); | ||
631 | 71 | } | ||
632 | 72 | |||
633 | 73 | void | ||
634 | 74 | ToggleButtonParam::param_setValue(bool newvalue) | ||
635 | 75 | { | ||
636 | 76 | value = newvalue; | ||
637 | 77 | } | ||
638 | 78 | |||
639 | 79 | } /* namespace LivePathEffect */ | ||
640 | 80 | |||
641 | 81 | } /* namespace Inkscape */ | ||
642 | 82 | |||
643 | 83 | /* | ||
644 | 84 | Local Variables: | ||
645 | 85 | mode:c++ | ||
646 | 86 | c-file-style:"stroustrup" | ||
647 | 87 | c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) | ||
648 | 88 | indent-tabs-mode:nil | ||
649 | 89 | fill-column:99 | ||
650 | 90 | End: | ||
651 | 91 | */ | ||
652 | 92 | // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 : | ||
653 | 0 | 93 | ||
654 | === added file 'src/live_effects/parameter/togglebutton.h' | |||
655 | --- src/live_effects/parameter/togglebutton.h 1970-01-01 00:00:00 +0000 | |||
656 | +++ src/live_effects/parameter/togglebutton.h 2014-09-15 15:24:25 +0000 | |||
657 | @@ -0,0 +1,56 @@ | |||
658 | 1 | #ifndef INKSCAPE_LIVEPATHEFFECT_PARAMETER_TOGGLEBUTTON_H | ||
659 | 2 | #define INKSCAPE_LIVEPATHEFFECT_PARAMETER_TOGGLEBUTTON_H | ||
660 | 3 | |||
661 | 4 | /* | ||
662 | 5 | * Inkscape::LivePathEffectParameters | ||
663 | 6 | * | ||
664 | 7 | * Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl> | ||
665 | 8 | * | ||
666 | 9 | * Released under GNU GPL, read the file 'COPYING' for more information | ||
667 | 10 | */ | ||
668 | 11 | |||
669 | 12 | #include <glib.h> | ||
670 | 13 | |||
671 | 14 | #include "live_effects/parameter/parameter.h" | ||
672 | 15 | |||
673 | 16 | namespace Inkscape { | ||
674 | 17 | |||
675 | 18 | namespace LivePathEffect { | ||
676 | 19 | |||
677 | 20 | |||
678 | 21 | class ToggleButtonParam : public Parameter { | ||
679 | 22 | public: | ||
680 | 23 | ToggleButtonParam( const Glib::ustring& label, | ||
681 | 24 | const Glib::ustring& tip, | ||
682 | 25 | const Glib::ustring& key, | ||
683 | 26 | Inkscape::UI::Widget::Registry* wr, | ||
684 | 27 | Effect* effect, | ||
685 | 28 | bool default_value = false); | ||
686 | 29 | virtual ~ToggleButtonParam(); | ||
687 | 30 | |||
688 | 31 | virtual Gtk::Widget * param_newWidget(); | ||
689 | 32 | |||
690 | 33 | virtual bool param_readSVGValue(const gchar * strvalue); | ||
691 | 34 | virtual gchar * param_getSVGValue() const; | ||
692 | 35 | |||
693 | 36 | void param_setValue(bool newvalue); | ||
694 | 37 | virtual void param_set_default(); | ||
695 | 38 | |||
696 | 39 | bool get_value() const { return value; }; | ||
697 | 40 | |||
698 | 41 | inline operator bool() const { return value; }; | ||
699 | 42 | |||
700 | 43 | private: | ||
701 | 44 | ToggleButtonParam(const ToggleButtonParam&); | ||
702 | 45 | ToggleButtonParam& operator=(const ToggleButtonParam&); | ||
703 | 46 | |||
704 | 47 | bool value; | ||
705 | 48 | bool defvalue; | ||
706 | 49 | }; | ||
707 | 50 | |||
708 | 51 | |||
709 | 52 | } //namespace LivePathEffect | ||
710 | 53 | |||
711 | 54 | } //namespace Inkscape | ||
712 | 55 | |||
713 | 56 | #endif | ||
714 | 0 | 57 | ||
715 | === modified file 'src/ui/tools/node-tool.h' | |||
716 | --- src/ui/tools/node-tool.h 2014-08-01 14:28:31 +0000 | |||
717 | +++ src/ui/tools/node-tool.h 2014-09-15 15:24:25 +0000 | |||
718 | @@ -15,6 +15,9 @@ | |||
719 | 15 | #include <glib.h> | 15 | #include <glib.h> |
720 | 16 | #include "ui/tools/tool-base.h" | 16 | #include "ui/tools/tool-base.h" |
721 | 17 | 17 | ||
722 | 18 | // we need it to call it from Live Effect | ||
723 | 19 | #include "selection.h" | ||
724 | 20 | |||
725 | 18 | namespace Inkscape { | 21 | namespace Inkscape { |
726 | 19 | namespace Display { | 22 | namespace Display { |
727 | 20 | class TemporaryItem; | 23 | class TemporaryItem; |
728 | 21 | 24 | ||
729 | === modified file 'src/ui/widget/registered-widget.cpp' | |||
730 | --- src/ui/widget/registered-widget.cpp 2014-03-30 21:43:02 +0000 | |||
731 | +++ src/ui/widget/registered-widget.cpp 2014-09-15 15:24:25 +0000 | |||
732 | @@ -99,6 +99,59 @@ | |||
733 | 99 | _wr->setUpdating (false); | 99 | _wr->setUpdating (false); |
734 | 100 | } | 100 | } |
735 | 101 | 101 | ||
736 | 102 | /*######################################### | ||
737 | 103 | * Registered TOGGLEBUTTON | ||
738 | 104 | */ | ||
739 | 105 | |||
740 | 106 | RegisteredToggleButton::~RegisteredToggleButton() | ||
741 | 107 | { | ||
742 | 108 | _toggled_connection.disconnect(); | ||
743 | 109 | } | ||
744 | 110 | |||
745 | 111 | RegisteredToggleButton::RegisteredToggleButton (const Glib::ustring& label, const Glib::ustring& tip, const Glib::ustring& key, Registry& wr, bool right, Inkscape::XML::Node* repr_in, SPDocument *doc_in, char const *active_str, char const *inactive_str) | ||
746 | 112 | : RegisteredWidget<Gtk::ToggleButton>(label) | ||
747 | 113 | , _active_str(active_str) | ||
748 | 114 | , _inactive_str(inactive_str) | ||
749 | 115 | { | ||
750 | 116 | init_parent(key, wr, repr_in, doc_in); | ||
751 | 117 | setProgrammatically = false; | ||
752 | 118 | set_tooltip_text (tip); | ||
753 | 119 | set_alignment (right? 1.0 : 0.0, 0.5); | ||
754 | 120 | _toggled_connection = signal_toggled().connect (sigc::mem_fun (*this, &RegisteredToggleButton::on_toggled)); | ||
755 | 121 | } | ||
756 | 122 | |||
757 | 123 | void | ||
758 | 124 | RegisteredToggleButton::setActive (bool b) | ||
759 | 125 | { | ||
760 | 126 | setProgrammatically = true; | ||
761 | 127 | set_active (b); | ||
762 | 128 | //The slave button is greyed out if the master button is untoggled | ||
763 | 129 | for (std::list<Gtk::Widget*>::const_iterator i = _slavewidgets.begin(); i != _slavewidgets.end(); ++i) { | ||
764 | 130 | (*i)->set_sensitive(b); | ||
765 | 131 | } | ||
766 | 132 | setProgrammatically = false; | ||
767 | 133 | } | ||
768 | 134 | |||
769 | 135 | void | ||
770 | 136 | RegisteredToggleButton::on_toggled() | ||
771 | 137 | { | ||
772 | 138 | if (setProgrammatically) { | ||
773 | 139 | setProgrammatically = false; | ||
774 | 140 | return; | ||
775 | 141 | } | ||
776 | 142 | |||
777 | 143 | if (_wr->isUpdating()) | ||
778 | 144 | return; | ||
779 | 145 | _wr->setUpdating (true); | ||
780 | 146 | |||
781 | 147 | write_to_xml(get_active() ? _active_str : _inactive_str); | ||
782 | 148 | //The slave button is greyed out if the master button is untoggled | ||
783 | 149 | for (std::list<Gtk::Widget*>::const_iterator i = _slavewidgets.begin(); i != _slavewidgets.end(); ++i) { | ||
784 | 150 | (*i)->set_sensitive(get_active()); | ||
785 | 151 | } | ||
786 | 152 | |||
787 | 153 | _wr->setUpdating (false); | ||
788 | 154 | } | ||
789 | 102 | 155 | ||
790 | 103 | /*######################################### | 156 | /*######################################### |
791 | 104 | * Registered UNITMENU | 157 | * Registered UNITMENU |
792 | 105 | 158 | ||
793 | === modified file 'src/ui/widget/registered-widget.h' | |||
794 | --- src/ui/widget/registered-widget.h 2014-03-27 01:33:44 +0000 | |||
795 | +++ src/ui/widget/registered-widget.h 2014-09-15 15:24:25 +0000 | |||
796 | @@ -163,6 +163,31 @@ | |||
797 | 163 | void on_toggled(); | 163 | void on_toggled(); |
798 | 164 | }; | 164 | }; |
799 | 165 | 165 | ||
800 | 166 | class RegisteredToggleButton : public RegisteredWidget<Gtk::ToggleButton> { | ||
801 | 167 | public: | ||
802 | 168 | virtual ~RegisteredToggleButton(); | ||
803 | 169 | RegisteredToggleButton (const Glib::ustring& label, const Glib::ustring& tip, const Glib::ustring& key, Registry& wr, bool right=true, Inkscape::XML::Node* repr_in=NULL, SPDocument *doc_in=NULL, char const *active_str = "true", char const *inactive_str = "false"); | ||
804 | 170 | |||
805 | 171 | void setActive (bool); | ||
806 | 172 | |||
807 | 173 | std::list<Gtk::Widget*> _slavewidgets; | ||
808 | 174 | |||
809 | 175 | // a slave button is only sensitive when the master button is active | ||
810 | 176 | // i.e. a slave button is greyed-out when the master button is not checked | ||
811 | 177 | |||
812 | 178 | void setSlaveWidgets(std::list<Gtk::Widget*> btns) { | ||
813 | 179 | _slavewidgets = btns; | ||
814 | 180 | } | ||
815 | 181 | |||
816 | 182 | bool setProgrammatically; // true if the value was set by setActive, not changed by the user; | ||
817 | 183 | // if a callback checks it, it must reset it back to false | ||
818 | 184 | |||
819 | 185 | protected: | ||
820 | 186 | char const *_active_str, *_inactive_str; | ||
821 | 187 | sigc::connection _toggled_connection; | ||
822 | 188 | void on_toggled(); | ||
823 | 189 | }; | ||
824 | 190 | |||
825 | 166 | class RegisteredUnitMenu : public RegisteredWidget<Labelled> { | 191 | class RegisteredUnitMenu : public RegisteredWidget<Labelled> { |
826 | 167 | public: | 192 | public: |
827 | 168 | ~RegisteredUnitMenu(); | 193 | ~RegisteredUnitMenu(); |
roughen was added to experimental in r13447 bazaar. launchpad. net/~inkscape. dev/inkscape/ experimental/ revision/ 13447
http://
experimental was merged into trunk in r13641 bazaar. launchpad. net/~inkscape. dev/inkscape/ trunk/revision/ 13641
http://
Changing status to 'Merged'.