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