Merge lp:~inkscape.dev/inkscape/roughen into lp:~inkscape.dev/inkscape/trunk

Proposed by Jabiertxof
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
Reviewer Review Type Date Requested Status
Inkscape Developers Pending
Review via email: mp+217357@code.launchpad.net

Description of the change

Add a new LPE that mix this extensions: "add nodes" + "Jitter nodes"

An aidea by Josh Andler.

To post a comment you must log in.
lp:~inkscape.dev/inkscape/roughen updated
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

Revision history for this message
su_v (suv-lp) wrote :

roughen was added to experimental in r13447
http://bazaar.launchpad.net/~inkscape.dev/inkscape/experimental/revision/13447

experimental was merged into trunk in r13641
http://bazaar.launchpad.net/~inkscape.dev/inkscape/trunk/revision/13641

Changing status to 'Merged'.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'po/POTFILES.skip'
--- po/POTFILES.skip 2010-01-14 08:13:09 +0000
+++ po/POTFILES.skip 2014-09-15 15:24:25 +0000
@@ -25,6 +25,7 @@
25src/live_effects/lpe-tangent_to_curve.cpp25src/live_effects/lpe-tangent_to_curve.cpp
26src/live_effects/lpe-test-doEffect-stack.cpp26src/live_effects/lpe-test-doEffect-stack.cpp
27src/live_effects/lpe-text_label.cpp27src/live_effects/lpe-text_label.cpp
28src/live_effects/lpe-simplify.cpp
28src/lpe-tool-context.cpp29src/lpe-tool-context.cpp
29src/ui/dialog/session-player.cpp30src/ui/dialog/session-player.cpp
30src/ui/dialog/whiteboard-connect.cpp31src/ui/dialog/whiteboard-connect.cpp
3132
=== modified file 'src/live_effects/CMakeLists.txt'
--- src/live_effects/CMakeLists.txt 2012-03-23 21:02:03 +0000
+++ src/live_effects/CMakeLists.txt 2014-09-15 15:24:25 +0000
@@ -32,6 +32,7 @@
32 # lpe-skeleton.cpp32 # lpe-skeleton.cpp
33 lpe-sketch.cpp33 lpe-sketch.cpp
34 lpe-spiro.cpp34 lpe-spiro.cpp
35 lpe-roughen.cpp
35 lpe-tangent_to_curve.cpp36 lpe-tangent_to_curve.cpp
36 lpe-test-doEffect-stack.cpp37 lpe-test-doEffect-stack.cpp
37 lpe-text_label.cpp38 lpe-text_label.cpp
@@ -52,6 +53,7 @@
52 parameter/powerstrokepointarray.cpp53 parameter/powerstrokepointarray.cpp
53 parameter/random.cpp54 parameter/random.cpp
54 parameter/text.cpp55 parameter/text.cpp
56 parameter/togglebutton.cpp
55 parameter/unit.cpp57 parameter/unit.cpp
56 parameter/vector.cpp58 parameter/vector.cpp
5759
@@ -92,6 +94,7 @@
92 lpe-skeleton.h94 lpe-skeleton.h
93 lpe-sketch.h95 lpe-sketch.h
94 lpe-spiro.h96 lpe-spiro.h
97 lpe-roughen.h
95 lpe-tangent_to_curve.h98 lpe-tangent_to_curve.h
96 lpe-test-doEffect-stack.h99 lpe-test-doEffect-stack.h
97 lpe-text_label.h100 lpe-text_label.h
@@ -113,6 +116,7 @@
113 parameter/powerstrokepointarray.h116 parameter/powerstrokepointarray.h
114 parameter/random.h117 parameter/random.h
115 parameter/text.h118 parameter/text.h
119 parameter/togglebutton.h
116 parameter/unit.h120 parameter/unit.h
117 parameter/vector.h121 parameter/vector.h
118122
119123
=== modified file 'src/live_effects/Makefile_insert'
--- src/live_effects/Makefile_insert 2012-03-23 21:02:03 +0000
+++ src/live_effects/Makefile_insert 2014-09-15 15:24:25 +0000
@@ -40,6 +40,8 @@
40 live_effects/lpe-test-doEffect-stack.h \40 live_effects/lpe-test-doEffect-stack.h \
41 live_effects/lpe-lattice.cpp \41 live_effects/lpe-lattice.cpp \
42 live_effects/lpe-lattice.h \42 live_effects/lpe-lattice.h \
43 live_effects/lpe-roughen.cpp \
44 live_effects/lpe-roughen.h \
43 live_effects/lpe-envelope.cpp \45 live_effects/lpe-envelope.cpp \
44 live_effects/lpe-envelope.h \46 live_effects/lpe-envelope.h \
45 live_effects/lpe-spiro.cpp \47 live_effects/lpe-spiro.cpp \
4648
=== modified file 'src/live_effects/effect-enum.h'
--- src/live_effects/effect-enum.h 2012-01-12 21:06:16 +0000
+++ src/live_effects/effect-enum.h 2014-09-15 15:24:25 +0000
@@ -28,6 +28,7 @@
28 PERSPECTIVE_PATH,28 PERSPECTIVE_PATH,
29 SPIRO,29 SPIRO,
30 LATTICE,30 LATTICE,
31 ROUGHEN,
31 ENVELOPE,32 ENVELOPE,
32 CONSTRUCT_GRID,33 CONSTRUCT_GRID,
33 PERP_BISECTOR,34 PERP_BISECTOR,
3435
=== modified file 'src/live_effects/effect.cpp'
--- src/live_effects/effect.cpp 2014-05-05 08:40:12 +0000
+++ src/live_effects/effect.cpp 2014-09-15 15:24:25 +0000
@@ -25,6 +25,7 @@
25#include "live_effects/lpe-perspective_path.h"25#include "live_effects/lpe-perspective_path.h"
26#include "live_effects/lpe-spiro.h"26#include "live_effects/lpe-spiro.h"
27#include "live_effects/lpe-lattice.h"27#include "live_effects/lpe-lattice.h"
28#include "live_effects/lpe-roughen.h"
28#include "live_effects/lpe-envelope.h"29#include "live_effects/lpe-envelope.h"
29#include "live_effects/lpe-constructgrid.h"30#include "live_effects/lpe-constructgrid.h"
30#include "live_effects/lpe-perp_bisector.h"31#include "live_effects/lpe-perp_bisector.h"
@@ -120,6 +121,7 @@
120/* 0.49 */121/* 0.49 */
121 {POWERSTROKE, N_("Power stroke"), "powerstroke"},122 {POWERSTROKE, N_("Power stroke"), "powerstroke"},
122 {CLONE_ORIGINAL, N_("Clone original path"), "clone_original"},123 {CLONE_ORIGINAL, N_("Clone original path"), "clone_original"},
124 {ROUGHEN, N_("Roughen"), "roughen"},
123};125};
124const Util::EnumDataConverter<EffectType> LPETypeConverter(LPETypeData, sizeof(LPETypeData)/sizeof(*LPETypeData));126const Util::EnumDataConverter<EffectType> LPETypeConverter(LPETypeData, sizeof(LPETypeData)/sizeof(*LPETypeData));
125127
@@ -243,6 +245,9 @@
243 case CLONE_ORIGINAL:245 case CLONE_ORIGINAL:
244 neweffect = static_cast<Effect*> ( new LPECloneOriginal(lpeobj) );246 neweffect = static_cast<Effect*> ( new LPECloneOriginal(lpeobj) );
245 break;247 break;
248 case ROUGHEN:
249 neweffect = static_cast<Effect*> ( new LPERoughen(lpeobj) );
250 break;
246 default:251 default:
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);
248 neweffect = NULL;253 neweffect = NULL;
@@ -496,7 +501,16 @@
496501
497 if (!SP_IS_SHAPE(lpeitem)) {502 if (!SP_IS_SHAPE(lpeitem)) {
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.
499 return hp_vec;504// return hp_vec;
505 }
506
507
508 // TODO: we can probably optimize this by using a lot more references
509 // rather than copying PathVectors all over the place
510 if (SP_IS_SHAPE(lpeitem) && show_orig_path) {
511 // add original path to helperpaths
512 SPCurve* curve = SP_SHAPE(lpeitem)->getCurve ();
513 hp_vec.push_back(curve->get_pathvector());
500 }514 }
501515
502 // add indicators provided by the effect itself516 // add indicators provided by the effect itself
503517
=== added file 'src/live_effects/lpe-roughen.cpp'
--- src/live_effects/lpe-roughen.cpp 1970-01-01 00:00:00 +0000
+++ src/live_effects/lpe-roughen.cpp 2014-09-15 15:24:25 +0000
@@ -0,0 +1,349 @@
1/**
2 * @file
3 * Roughen LPE implementation. Creates roughen paths.
4 */
5/* Authors:
6 * Jabier Arraiza Cenoz <jabier.arraiza@marker.es>
7 *
8 * Thanks to all people involved specialy to Josh Andler for the idea and to the
9 * original extensions authors.
10 *
11 * Copyright (C) 2014 Authors
12 *
13 * Released under GNU GPL, read the file 'COPYING' for more information
14 */
15
16#include <gtkmm.h>
17
18#include "live_effects/lpe-roughen.h"
19#include "display/curve.h"
20#include "live_effects/parameter/parameter.h"
21#include "helper/geom.h"
22#include <glibmm/i18n.h>
23#include <cmath>
24
25namespace Inkscape {
26namespace LivePathEffect {
27
28static const Util::EnumData<DivisionMethod> DivisionMethodData[DM_END] = {
29 { DM_SEGMENTS, N_("By number of segments"), "segments" },
30 { DM_SIZE, N_("By max. segment size"), "size" }
31};
32static const Util::EnumDataConverter<DivisionMethod>
33DMConverter(DivisionMethodData, DM_END);
34
35LPERoughen::LPERoughen(LivePathEffectObject *lpeobject)
36 : Effect(lpeobject),
37 // initialise your parameters here:
38 unit(_("Unit"), _("Unit"), "unit", &wr, this),
39 method(_("Method"), _("Division method"), "method", DMConverter, &wr,
40 this, DM_SEGMENTS),
41 maxSegmentSize(_("Max. segment size"), _("Max. segment size"),
42 "maxSegmentSize", &wr, this, 10.),
43 segments(_("Number of segments"), _("Number of segments"), "segments",
44 &wr, this, 2),
45 displaceX(_("Max. displacement in X"), _("Max. displacement in X"),
46 "displaceX", &wr, this, 10.),
47 displaceY(_("Max. displacement in Y"), _("Max. displacement in Y"),
48 "displaceY", &wr, this, 10.),
49 shiftNodes(_("Shift nodes"), _("Shift nodes"), "shiftNodes", &wr, this,
50 true),
51 shiftNodeHandles(_("Shift node handles"), _("Shift node handles"),
52 "shiftNodeHandles", &wr, this, true)
53{
54 registerParameter(&unit);
55 registerParameter(&method);
56 registerParameter(&maxSegmentSize);
57 registerParameter(&segments);
58 registerParameter(&displaceX);
59 registerParameter(&displaceY);
60 registerParameter(&shiftNodes);
61 registerParameter(&shiftNodeHandles);
62 displaceX.param_set_range(0., Geom::infinity());
63 displaceY.param_set_range(0., Geom::infinity());
64 maxSegmentSize.param_set_range(0., Geom::infinity());
65 maxSegmentSize.param_set_increments(1, 1);
66 maxSegmentSize.param_set_digits(1);
67 segments.param_set_range(1, Geom::infinity());
68 segments.param_set_increments(1, 1);
69 segments.param_set_digits(0);
70}
71
72LPERoughen::~LPERoughen() {}
73
74void LPERoughen::doBeforeEffect(SPLPEItem const */*lpeitem*/)
75{
76 displaceX.resetRandomizer();
77 displaceY.resetRandomizer();
78 srand(1);
79}
80
81Gtk::Widget *LPERoughen::newWidget()
82{
83 Gtk::VBox *vbox = Gtk::manage(new Gtk::VBox(Effect::newWidget()));
84 vbox->set_border_width(5);
85 vbox->set_homogeneous(false);
86 vbox->set_spacing(2);
87 std::vector<Parameter *>::iterator it = param_vector.begin();
88 while (it != param_vector.end()) {
89 if ((*it)->widget_is_visible) {
90 Parameter *param = *it;
91 Gtk::Widget *widg = dynamic_cast<Gtk::Widget *>(param->param_newWidget());
92 if (param->param_key == "unit") {
93 Gtk::Label *unitLabel = Gtk::manage(new Gtk::Label(
94 Glib::ustring(_("<b>Roughen unit</b>")), Gtk::ALIGN_START));
95 unitLabel->set_use_markup(true);
96 vbox->pack_start(*unitLabel, false, false, 2);
97 vbox->pack_start(*Gtk::manage(new Gtk::HSeparator()),
98 Gtk::PACK_EXPAND_WIDGET);
99 }
100 if (param->param_key == "method") {
101 Gtk::Label *methodLabel = Gtk::manage(new Gtk::Label(
102 Glib::ustring(_("<b>Add nodes</b> Subdivide each segment")),
103 Gtk::ALIGN_START));
104 methodLabel->set_use_markup(true);
105 vbox->pack_start(*methodLabel, false, false, 2);
106 vbox->pack_start(*Gtk::manage(new Gtk::HSeparator()),
107 Gtk::PACK_EXPAND_WIDGET);
108 }
109 if (param->param_key == "displaceX") {
110 Gtk::Label *displaceXLabel = Gtk::manage(new Gtk::Label(
111 Glib::ustring(_("<b>Jitter nodes</b> Move nodes/handles")),
112 Gtk::ALIGN_START));
113 displaceXLabel->set_use_markup(true);
114 vbox->pack_start(*displaceXLabel, false, false, 2);
115 vbox->pack_start(*Gtk::manage(new Gtk::HSeparator()),
116 Gtk::PACK_EXPAND_WIDGET);
117 }
118 Glib::ustring *tip = param->param_getTooltip();
119 if (widg) {
120 vbox->pack_start(*widg, true, true, 2);
121 if (tip) {
122 widg->set_tooltip_text(*tip);
123 } else {
124 widg->set_tooltip_text("");
125 widg->set_has_tooltip(false);
126 }
127 }
128 }
129
130 ++it;
131 }
132 return dynamic_cast<Gtk::Widget *>(vbox);
133}
134
135double LPERoughen::sign(double randNumber)
136{
137 if (rand() % 100 < 49) {
138 randNumber *= -1.;
139 }
140 return randNumber;
141}
142
143//to use when bolean operations work done
144/*
145std::vector<Geom::Path> LPERoughen::getCrackCircles(SPCurve *curve){
146 std::vector<Geom::Path> crackCircles;
147 gint seg = curve->get_segment_count()-1;
148 Piecewise<D2<SBasis> > pwd2 = paths_to_pw(curve);
149 for(type_t i = 0; i < nCracks; ++i){
150 Geom::Circle(pwd2.pointAt((rand() % (seg * 100.))/100.),crackRadius).getPath(crackCircles);
151 }
152 return crackCircles;
153}
154*/
155
156Geom::Point LPERoughen::randomize()
157{
158 double displaceXParsed = Inkscape::Util::Quantity::convert(
159 displaceX, unit.get_abbreviation(), "px");
160 double displaceYParsed = Inkscape::Util::Quantity::convert(
161 displaceY, unit.get_abbreviation(), "px");
162
163 Geom::Point output = Geom::Point(sign(displaceXParsed), sign(displaceYParsed));
164 return output;
165}
166
167void LPERoughen::doEffect(SPCurve *curve)
168{
169 Geom::PathVector const original_pathv =
170 pathv_to_linear_and_cubic_beziers(curve->get_pathvector());
171 curve->reset();
172 for (Geom::PathVector::const_iterator path_it = original_pathv.begin();
173 path_it != original_pathv.end(); ++path_it) {
174 if (path_it->empty())
175 continue;
176
177 Geom::Path::const_iterator curve_it1 = path_it->begin();
178 Geom::Path::const_iterator curve_it2 = ++(path_it->begin());
179 Geom::Path::const_iterator curve_endit = path_it->end_default();
180 SPCurve *nCurve = new SPCurve();
181 if (path_it->closed()) {
182 const Geom::Curve &closingline =
183 path_it->back_closed();
184 if (are_near(closingline.initialPoint(), closingline.finalPoint())) {
185 curve_endit = path_it->end_open();
186 }
187 }
188 Geom::Point initialMove(0, 0);
189 if (shiftNodes) {
190 initialMove = randomize();
191 }
192 Geom::Point initialPoint = curve_it1->initialPoint() + initialMove;
193 nCurve->moveto(initialPoint);
194 Geom::Point A0(0, 0);
195 Geom::Point A1(0, 0);
196 Geom::Point A2(0, 0);
197 Geom::Point A3(0, 0);
198 while (curve_it1 != curve_endit) {
199 Geom::CubicBezier const *cubic = NULL;
200 A0 = curve_it1->initialPoint();
201 A1 = curve_it1->initialPoint();
202 A2 = curve_it1->finalPoint();
203 A3 = curve_it1->finalPoint();
204 cubic = dynamic_cast<Geom::CubicBezier const *>(&*curve_it1);
205 if (cubic) {
206 A1 = (*cubic)[1];
207 if (shiftNodes) {
208 A1 = (*cubic)[1] + initialMove;
209 }
210 A2 = (*cubic)[2];
211 nCurve->curveto(A1, A2, A3);
212 } else {
213 nCurve->lineto(A3);
214 }
215 double length = Inkscape::Util::Quantity::convert(
216 curve_it1->length(0.001), "px", unit.get_abbreviation());
217 std::size_t splits = 0;
218 if (method == DM_SEGMENTS) {
219 splits = segments;
220 } else {
221 splits = ceil(length / maxSegmentSize);
222 }
223 for (unsigned int t = splits; t >= 1; t--) {
224 if (t == 1 && splits != 1) {
225 continue;
226 }
227 const SPCurve *tmp;
228 if (splits == 1) {
229 tmp = jitter(nCurve->last_segment());
230 } else {
231 tmp = addNodesAndJitter(nCurve->last_segment(), 1. / t);
232 }
233 if (nCurve->get_segment_count() > 1) {
234 nCurve->backspace();
235 nCurve->append_continuous(tmp, 0.001);
236 } else {
237 nCurve = tmp->copy();
238 }
239 delete tmp;
240 }
241 ++curve_it1;
242 if(curve_it2 != curve_endit) {
243 ++curve_it2;
244 }
245 }
246 if (path_it->closed()) {
247 nCurve->closepath_current();
248 }
249 curve->append(nCurve, false);
250 nCurve->reset();
251 delete nCurve;
252 }
253}
254
255SPCurve *LPERoughen::addNodesAndJitter(const Geom::Curve *A, double t)
256{
257 SPCurve *out = new SPCurve();
258 Geom::CubicBezier const *cubic = dynamic_cast<Geom::CubicBezier const *>(&*A);
259 Geom::Point A1(0, 0);
260 Geom::Point A2(0, 0);
261 Geom::Point A3(0, 0);
262 Geom::Point B1(0, 0);
263 Geom::Point B2(0, 0);
264 Geom::Point B3(0, 0);
265 if (shiftNodes) {
266 A3 = randomize();
267 B3 = randomize();
268 }
269 if (shiftNodeHandles) {
270 A1 = randomize();
271 A2 = randomize();
272 B1 = randomize();
273 B2 = randomize();
274 } else {
275 A2 = A3;
276 B1 = A3;
277 B2 = B3;
278 }
279 if (cubic) {
280 std::pair<Geom::CubicBezier, Geom::CubicBezier> div = cubic->subdivide(t);
281 std::vector<Geom::Point> seg1 = div.first.points(),
282 seg2 = div.second.points();
283 out->moveto(seg1[0]);
284 out->curveto(seg1[1] + A1, seg1[2] + A2, seg1[3] + A3);
285 out->curveto(seg2[1] + B1, seg2[2], seg2[3]);
286 } else if (shiftNodeHandles) {
287 out->moveto(A->initialPoint());
288 out->curveto(A->pointAt(t / 3) + A1, A->pointAt((t / 3) * 2) + A2,
289 A->pointAt(t) + A3);
290 out->curveto(A->pointAt(t + (t / 3)) + B1, A->pointAt(t + ((t / 3) * 2)),
291 A->finalPoint());
292 } else {
293 out->moveto(A->initialPoint());
294 out->lineto(A->pointAt(t) + A3);
295 out->lineto(A->finalPoint());
296 }
297 return out;
298}
299
300SPCurve *LPERoughen::jitter(const Geom::Curve *A)
301{
302 SPCurve *out = new SPCurve();
303 Geom::CubicBezier const *cubic = dynamic_cast<Geom::CubicBezier const *>(&*A);
304 Geom::Point A1(0, 0);
305 Geom::Point A2(0, 0);
306 Geom::Point A3(0, 0);
307 if (shiftNodes) {
308 A3 = randomize();
309 }
310 if (shiftNodeHandles) {
311 A1 = randomize();
312 A2 = randomize();
313 } else {
314 A2 = A3;
315 }
316 if (cubic) {
317 out->moveto((*cubic)[0]);
318 out->curveto((*cubic)[1] + A1, (*cubic)[2] + A2, (*cubic)[3] + A3);
319 } else if (shiftNodeHandles) {
320 out->moveto(A->initialPoint());
321 out->curveto(A->pointAt(0.3333) + A1, A->pointAt(0.6666) + A2,
322 A->finalPoint() + A3);
323 } else {
324 out->moveto(A->initialPoint());
325 out->lineto(A->finalPoint() + A3);
326 }
327 return out;
328}
329
330Geom::Point LPERoughen::tpoint(Geom::Point A, Geom::Point B, double t)
331{
332 using Geom::X;
333 using Geom::Y;
334 return Geom::Point(A[X] + t * (B[X] - A[X]), A[Y] + t * (B[Y] - A[Y]));
335}
336
337}; //namespace LivePathEffect
338}; /* namespace Inkscape */
339
340/*
341 Local Variables:
342 mode:c++
343 c-file-style:"stroustrup"
344 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
345 indent-tabs-mode:nil
346 fill-column:99
347 End:
348*/
349// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
0350
=== added file 'src/live_effects/lpe-roughen.h'
--- src/live_effects/lpe-roughen.h 1970-01-01 00:00:00 +0000
+++ src/live_effects/lpe-roughen.h 2014-09-15 15:24:25 +0000
@@ -0,0 +1,63 @@
1/** @file
2 * @brief Roughen LPE effect, see lpe-roughen.cpp.
3 */
4/* Authors:
5 * Jabier Arraiza Cenoz <jabier.arraiza@marker.es>
6 *
7 * Copyright (C) 2014 Authors
8 *
9 * Released under GNU GPL, read the file 'COPYING' for more information
10 */
11
12#ifndef INKSCAPE_LPE_ROUGHEN_H
13#define INKSCAPE_LPE_ROUGHEN_H
14
15#include "live_effects/parameter/enum.h"
16#include "live_effects/effect.h"
17#include "live_effects/parameter/parameter.h"
18#include "live_effects/parameter/path.h"
19#include "live_effects/parameter/bool.h"
20#include "live_effects/parameter/unit.h"
21#include "live_effects/parameter/random.h"
22
23namespace Inkscape {
24namespace LivePathEffect {
25
26enum DivisionMethod {
27 DM_SEGMENTS,
28 DM_SIZE,
29 DM_END
30};
31
32class LPERoughen : public Effect {
33
34public:
35 LPERoughen(LivePathEffectObject *lpeobject);
36 virtual ~LPERoughen();
37
38 virtual void doEffect(SPCurve *curve);
39 virtual double sign(double randNumber);
40 virtual Geom::Point randomize();
41 virtual void doBeforeEffect(SPLPEItem const */*lpeitem*/);
42 virtual SPCurve *addNodesAndJitter(const Geom::Curve *A, double t);
43 virtual SPCurve *jitter(const Geom::Curve *A);
44 virtual Geom::Point tpoint(Geom::Point A, Geom::Point B, double t = 0.5);
45 virtual Gtk::Widget *newWidget();
46
47private:
48 UnitParam unit;
49 EnumParam<DivisionMethod> method;
50 ScalarParam maxSegmentSize;
51 ScalarParam segments;
52 RandomParam displaceX;
53 RandomParam displaceY;
54 BoolParam shiftNodes;
55 BoolParam shiftNodeHandles;
56 LPERoughen(const LPERoughen &);
57 LPERoughen &operator=(const LPERoughen &);
58
59};
60
61}; //namespace LivePathEffect
62}; //namespace Inkscape
63#endif
064
=== modified file 'src/live_effects/parameter/Makefile_insert'
--- src/live_effects/parameter/Makefile_insert 2012-01-12 21:06:16 +0000
+++ src/live_effects/parameter/Makefile_insert 2014-09-15 15:24:25 +0000
@@ -22,6 +22,8 @@
22 live_effects/parameter/powerstrokepointarray.h \22 live_effects/parameter/powerstrokepointarray.h \
23 live_effects/parameter/text.cpp \23 live_effects/parameter/text.cpp \
24 live_effects/parameter/text.h \24 live_effects/parameter/text.h \
25 live_effects/parameter/togglebutton.cpp \
26 live_effects/parameter/togglebutton.h \
25 live_effects/parameter/unit.cpp \27 live_effects/parameter/unit.cpp \
26 live_effects/parameter/unit.h \28 live_effects/parameter/unit.h \
27 live_effects/parameter/vector.cpp \29 live_effects/parameter/vector.cpp \
2830
=== added file 'src/live_effects/parameter/togglebutton.cpp'
--- src/live_effects/parameter/togglebutton.cpp 1970-01-01 00:00:00 +0000
+++ src/live_effects/parameter/togglebutton.cpp 2014-09-15 15:24:25 +0000
@@ -0,0 +1,92 @@
1/*
2 * Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
3 * Copyright (C) Jabiertxo Arraiza Cenoz 2014 <j.b.c.engelen@utwente.nl>
4 *
5 * Released under GNU GPL, read the file 'COPYING' for more information
6 */
7
8#include "ui/widget/registered-widget.h"
9#include "live_effects/parameter/togglebutton.h"
10#include "live_effects/effect.h"
11#include "svg/svg.h"
12#include "svg/stringstream.h"
13#include "widgets/icon.h"
14#include "inkscape.h"
15#include "verbs.h"
16#include "helper-fns.h"
17#include <glibmm/i18n.h>
18
19namespace Inkscape {
20
21namespace LivePathEffect {
22
23ToggleButtonParam::ToggleButtonParam( const Glib::ustring& label, const Glib::ustring& tip,
24 const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr,
25 Effect* effect, bool default_value )
26 : Parameter(label, tip, key, wr, effect), value(default_value), defvalue(default_value)
27{
28}
29
30ToggleButtonParam::~ToggleButtonParam()
31{
32}
33
34void
35ToggleButtonParam::param_set_default()
36{
37 param_setValue(defvalue);
38}
39
40bool
41ToggleButtonParam::param_readSVGValue(const gchar * strvalue)
42{
43 param_setValue(helperfns_read_bool(strvalue, defvalue));
44 return true; // not correct: if value is unacceptable, should return false!
45}
46
47gchar *
48ToggleButtonParam::param_getSVGValue() const
49{
50 gchar * str = g_strdup(value ? "true" : "false");
51 return str;
52}
53
54Gtk::Widget *
55ToggleButtonParam::param_newWidget()
56{
57 Inkscape::UI::Widget::RegisteredToggleButton * checkwdg = Gtk::manage(
58 new Inkscape::UI::Widget::RegisteredToggleButton( param_label,
59 param_tooltip,
60 param_key,
61 *param_wr,
62 false,
63 param_effect->getRepr(),
64 param_effect->getSPDoc()) );
65
66 checkwdg->setActive(value);
67 checkwdg->setProgrammatically = false;
68 checkwdg->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change togglebutton parameter"));
69
70 return dynamic_cast<Gtk::Widget *> (checkwdg);
71}
72
73void
74ToggleButtonParam::param_setValue(bool newvalue)
75{
76 value = newvalue;
77}
78
79} /* namespace LivePathEffect */
80
81} /* namespace Inkscape */
82
83/*
84 Local Variables:
85 mode:c++
86 c-file-style:"stroustrup"
87 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
88 indent-tabs-mode:nil
89 fill-column:99
90 End:
91*/
92// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
093
=== added file 'src/live_effects/parameter/togglebutton.h'
--- src/live_effects/parameter/togglebutton.h 1970-01-01 00:00:00 +0000
+++ src/live_effects/parameter/togglebutton.h 2014-09-15 15:24:25 +0000
@@ -0,0 +1,56 @@
1#ifndef INKSCAPE_LIVEPATHEFFECT_PARAMETER_TOGGLEBUTTON_H
2#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_TOGGLEBUTTON_H
3
4/*
5 * Inkscape::LivePathEffectParameters
6 *
7* Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
8 *
9 * Released under GNU GPL, read the file 'COPYING' for more information
10 */
11
12#include <glib.h>
13
14#include "live_effects/parameter/parameter.h"
15
16namespace Inkscape {
17
18namespace LivePathEffect {
19
20
21class ToggleButtonParam : public Parameter {
22public:
23 ToggleButtonParam( const Glib::ustring& label,
24 const Glib::ustring& tip,
25 const Glib::ustring& key,
26 Inkscape::UI::Widget::Registry* wr,
27 Effect* effect,
28 bool default_value = false);
29 virtual ~ToggleButtonParam();
30
31 virtual Gtk::Widget * param_newWidget();
32
33 virtual bool param_readSVGValue(const gchar * strvalue);
34 virtual gchar * param_getSVGValue() const;
35
36 void param_setValue(bool newvalue);
37 virtual void param_set_default();
38
39 bool get_value() const { return value; };
40
41 inline operator bool() const { return value; };
42
43private:
44 ToggleButtonParam(const ToggleButtonParam&);
45 ToggleButtonParam& operator=(const ToggleButtonParam&);
46
47 bool value;
48 bool defvalue;
49};
50
51
52} //namespace LivePathEffect
53
54} //namespace Inkscape
55
56#endif
057
=== modified file 'src/ui/tools/node-tool.h'
--- src/ui/tools/node-tool.h 2014-08-01 14:28:31 +0000
+++ src/ui/tools/node-tool.h 2014-09-15 15:24:25 +0000
@@ -15,6 +15,9 @@
15#include <glib.h>15#include <glib.h>
16#include "ui/tools/tool-base.h"16#include "ui/tools/tool-base.h"
1717
18// we need it to call it from Live Effect
19#include "selection.h"
20
18namespace Inkscape {21namespace Inkscape {
19 namespace Display {22 namespace Display {
20 class TemporaryItem;23 class TemporaryItem;
2124
=== modified file 'src/ui/widget/registered-widget.cpp'
--- src/ui/widget/registered-widget.cpp 2014-03-30 21:43:02 +0000
+++ src/ui/widget/registered-widget.cpp 2014-09-15 15:24:25 +0000
@@ -99,6 +99,59 @@
99 _wr->setUpdating (false);99 _wr->setUpdating (false);
100}100}
101101
102/*#########################################
103 * Registered TOGGLEBUTTON
104 */
105
106RegisteredToggleButton::~RegisteredToggleButton()
107{
108 _toggled_connection.disconnect();
109}
110
111RegisteredToggleButton::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)
112 : RegisteredWidget<Gtk::ToggleButton>(label)
113 , _active_str(active_str)
114 , _inactive_str(inactive_str)
115{
116 init_parent(key, wr, repr_in, doc_in);
117 setProgrammatically = false;
118 set_tooltip_text (tip);
119 set_alignment (right? 1.0 : 0.0, 0.5);
120 _toggled_connection = signal_toggled().connect (sigc::mem_fun (*this, &RegisteredToggleButton::on_toggled));
121}
122
123void
124RegisteredToggleButton::setActive (bool b)
125{
126 setProgrammatically = true;
127 set_active (b);
128 //The slave button is greyed out if the master button is untoggled
129 for (std::list<Gtk::Widget*>::const_iterator i = _slavewidgets.begin(); i != _slavewidgets.end(); ++i) {
130 (*i)->set_sensitive(b);
131 }
132 setProgrammatically = false;
133}
134
135void
136RegisteredToggleButton::on_toggled()
137{
138 if (setProgrammatically) {
139 setProgrammatically = false;
140 return;
141 }
142
143 if (_wr->isUpdating())
144 return;
145 _wr->setUpdating (true);
146
147 write_to_xml(get_active() ? _active_str : _inactive_str);
148 //The slave button is greyed out if the master button is untoggled
149 for (std::list<Gtk::Widget*>::const_iterator i = _slavewidgets.begin(); i != _slavewidgets.end(); ++i) {
150 (*i)->set_sensitive(get_active());
151 }
152
153 _wr->setUpdating (false);
154}
102155
103/*#########################################156/*#########################################
104 * Registered UNITMENU157 * Registered UNITMENU
105158
=== modified file 'src/ui/widget/registered-widget.h'
--- src/ui/widget/registered-widget.h 2014-03-27 01:33:44 +0000
+++ src/ui/widget/registered-widget.h 2014-09-15 15:24:25 +0000
@@ -163,6 +163,31 @@
163 void on_toggled();163 void on_toggled();
164};164};
165165
166class RegisteredToggleButton : public RegisteredWidget<Gtk::ToggleButton> {
167public:
168 virtual ~RegisteredToggleButton();
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");
170
171 void setActive (bool);
172
173 std::list<Gtk::Widget*> _slavewidgets;
174
175 // a slave button is only sensitive when the master button is active
176 // i.e. a slave button is greyed-out when the master button is not checked
177
178 void setSlaveWidgets(std::list<Gtk::Widget*> btns) {
179 _slavewidgets = btns;
180 }
181
182 bool setProgrammatically; // true if the value was set by setActive, not changed by the user;
183 // if a callback checks it, it must reset it back to false
184
185protected:
186 char const *_active_str, *_inactive_str;
187 sigc::connection _toggled_connection;
188 void on_toggled();
189};
190
166class RegisteredUnitMenu : public RegisteredWidget<Labelled> {191class RegisteredUnitMenu : public RegisteredWidget<Labelled> {
167public:192public:
168 ~RegisteredUnitMenu();193 ~RegisteredUnitMenu();