1. === modified file 'po/POTFILES.in'
  2. --- po/POTFILES.in 2016-05-30 12:34:46 +0000
  3. +++ po/POTFILES.in 2016-07-30 14:50:37 +0000
  4. @@ -154,6 +154,7 @@
  5. src/live_effects/lpe-rough-hatches.cpp
  6. src/live_effects/lpe-roughen.cpp
  7. src/live_effects/lpe-ruler.cpp
  8. +src/live_effects/lpe-measure-line.cpp
  9. src/live_effects/lpe-show_handles.cpp
  10. src/live_effects/lpe-simplify.cpp
  11. src/live_effects/lpe-sketch.cpp
  12. @@ -171,6 +172,7 @@
  13. src/live_effects/parameter/powerstrokepointarray.cpp
  14. src/live_effects/parameter/random.cpp
  15. src/live_effects/parameter/text.cpp
  16. +src/live_effects/parameter/fontbutton.cpp
  17. src/live_effects/parameter/togglebutton.cpp
  18. src/live_effects/parameter/transformedpoint.cpp
  19. src/live_effects/parameter/unit.cpp
  20. === modified file 'src/live_effects/CMakeLists.txt'
  21. --- src/live_effects/CMakeLists.txt 2015-07-24 19:53:33 +0000
  22. +++ src/live_effects/CMakeLists.txt 2016-07-29 21:22:57 +0000
  23. @@ -27,6 +27,7 @@
  24. lpe-lattice.cpp
  25. lpe-lattice2.cpp
  26. lpe-line_segment.cpp
  27. + lpe-measure-line.cpp
  28. lpe-mirror_symmetry.cpp
  29. lpe-offset.cpp
  30. lpe-parallel.cpp
  31. @@ -68,6 +69,7 @@
  32. parameter/powerstrokepointarray.cpp
  33. parameter/random.cpp
  34. parameter/text.cpp
  35. + parameter/fontbutton.cpp
  36. parameter/togglebutton.cpp
  37. parameter/transformedpoint.cpp
  38. parameter/unit.cpp
  39. @@ -105,6 +107,7 @@
  40. lpe-lattice.h
  41. lpe-lattice2.h
  42. lpe-line_segment.h
  43. + lpe-measure-line.h
  44. lpe-mirror_symmetry.h
  45. lpe-offset.h
  46. lpe-parallel.h
  47. @@ -148,6 +151,7 @@
  48. parameter/powerstrokepointarray.h
  49. parameter/random.h
  50. parameter/text.h
  51. + parameter/fontbutton.h
  52. parameter/togglebutton.h
  53. parameter/transformedpoint.h
  54. parameter/unit.h
  55. === modified file 'src/live_effects/Makefile_insert'
  56. --- src/live_effects/Makefile_insert 2015-07-24 19:53:33 +0000
  57. +++ src/live_effects/Makefile_insert 2016-07-21 18:04:54 +0000
  58. @@ -70,6 +70,8 @@
  59. live_effects/lpe-perspective_path.h \
  60. live_effects/lpe-perspective-envelope.cpp \
  61. live_effects/lpe-perspective-envelope.h \
  62. + live_effects/lpe-measure-line.cpp \
  63. + live_effects/lpe-measure-line.h \
  64. live_effects/lpe-mirror_symmetry.cpp \
  65. live_effects/lpe-mirror_symmetry.h \
  66. live_effects/lpe-circle_3pts.cpp \
  67. === modified file 'src/live_effects/effect-enum.h'
  68. --- src/live_effects/effect-enum.h 2015-01-27 22:09:47 +0000
  69. +++ src/live_effects/effect-enum.h 2016-07-21 18:55:39 +0000
  70. @@ -36,6 +36,7 @@
  71. CONSTRUCT_GRID,
  72. PERP_BISECTOR,
  73. TANGENT_TO_CURVE,
  74. + MEASURE_LINE,
  75. MIRROR_SYMMETRY,
  76. CIRCLE_3PTS,
  77. TRANSFORM_2PTS,
  78. === modified file 'src/live_effects/effect.cpp'
  79. --- src/live_effects/effect.cpp 2016-07-28 11:26:17 +0000
  80. +++ src/live_effects/effect.cpp 2016-07-30 16:41:13 +0000
  81. @@ -40,6 +40,7 @@
  82. #include "live_effects/lpe-lattice2.h"
  83. #include "live_effects/lpe-lattice.h"
  84. #include "live_effects/lpe-line_segment.h"
  85. +#include "live_effects/lpe-measure-line.h"
  86. #include "live_effects/lpe-mirror_symmetry.h"
  87. #include "live_effects/lpe-offset.h"
  88. #include "live_effects/lpe-parallel.h"
  89. @@ -151,6 +152,8 @@
  90. {FILL_BETWEEN_MANY, N_("Fill between many"), "fill_between_many"},
  91. {ELLIPSE_5PTS, N_("Ellipse by 5 points"), "ellipse_5pts"},
  92. {BOUNDING_BOX, N_("Bounding Box"), "bounding_box"},
  93. +/* 9.93 */
  94. + {MEASURE_LINE, N_("Measure Line"), "measure-line"},
  95. };
  96. const Util::EnumDataConverter<EffectType> LPETypeConverter(LPETypeData, sizeof(LPETypeData)/sizeof(*LPETypeData));
  97. @@ -319,6 +322,9 @@
  98. case TRANSFORM_2PTS:
  99. neweffect = static_cast<Effect*> ( new LPETransform2Pts(lpeobj) );
  100. break;
  101. + case MEASURE_LINE:
  102. + neweffect = static_cast<Effect*> ( new LPEMeasureLine(lpeobj) );
  103. + break;
  104. default:
  105. g_warning("LivePathEffect::Effect::New called with invalid patheffect type (%d)", lpenr);
  106. neweffect = NULL;
  107. @@ -364,6 +370,7 @@
  108. concatenate_before_pwd2(false),
  109. sp_lpe_item(NULL),
  110. current_zoom(1),
  111. + upd_params(true),
  112. sp_curve(NULL),
  113. provides_own_flash_paths(true), // is automatically set to false if providesOwnFlashPaths() is not overridden
  114. is_ready(false) // is automatically set to false if providesOwnFlashPaths() is not overridden
  115. @@ -447,7 +454,9 @@
  116. void Effect::doOnRemove (SPLPEItem const* /*lpeitem*/)
  117. {
  118. }
  119. -
  120. +void Effect::doOnVisibilityToggled(SPLPEItem const* /*lpeitem*/)
  121. +{
  122. +}
  123. //secret impl methods (shhhh!)
  124. void Effect::doOnApply_impl(SPLPEItem const* lpeitem)
  125. {
  126. @@ -691,7 +700,7 @@
  127. ++it;
  128. }
  129. -
  130. + upd_params = false;
  131. return dynamic_cast<Gtk::Widget *>(vbox);
  132. }
  133. === modified file 'src/live_effects/effect.h'
  134. --- src/live_effects/effect.h 2016-03-14 16:47:47 +0000
  135. +++ src/live_effects/effect.h 2016-07-30 16:40:47 +0000
  136. @@ -66,7 +66,7 @@
  137. virtual void doAfterEffect (SPLPEItem const* lpeitem);
  138. virtual void doOnRemove (SPLPEItem const* lpeitem);
  139. -
  140. + virtual void doOnVisibilityToggled(SPLPEItem const* lpeitem);
  141. void writeParamsToSVG();
  142. virtual void acceptParamPath (SPPath const* param_path);
  143. @@ -122,6 +122,7 @@
  144. void editNextParamOncanvas(SPItem * item, SPDesktop * desktop);
  145. bool apply_to_clippath_and_mask;
  146. + bool upd_params;
  147. protected:
  148. Effect(LivePathEffectObject *lpeobject);
  149. === modified file 'src/live_effects/lpe-ellipse_5pts.cpp'
  150. --- src/live_effects/lpe-ellipse_5pts.cpp 2016-07-28 11:26:17 +0000
  151. +++ src/live_effects/lpe-ellipse_5pts.cpp 2016-07-29 09:29:42 +0000
  152. @@ -171,7 +171,7 @@
  153. // figure out if we have a slice, guarding against rounding errors
  154. - Path p(Geom::Point(cos(0), sin(0)));
  155. + Geom::Path p(Geom::Point(cos(0), sin(0)));
  156. double end = 2 * M_PI;
  157. for (s = 0; s < end; s += M_PI_2) {
  158. === modified file 'src/live_effects/lpe-extrude.cpp'
  159. --- src/live_effects/lpe-extrude.cpp 2016-07-28 11:26:17 +0000
  160. +++ src/live_effects/lpe-extrude.cpp 2016-07-29 09:50:56 +0000
  161. @@ -66,7 +66,7 @@
  162. using namespace Geom;
  163. // generate connecting lines (the 'sides' of the extrusion)
  164. - Path path(Point(0.,0.));
  165. + Geom::Path path(Point(0.,0.));
  166. path.appendNew<Geom::LineSegment>( extrude_vector.getVector() );
  167. Piecewise<D2<SBasis> > connector = path.toPwSb();
  168. === modified file 'src/live_effects/lpe-knot.cpp'
  169. --- src/live_effects/lpe-knot.cpp 2016-07-28 11:26:17 +0000
  170. +++ src/live_effects/lpe-knot.cpp 2016-07-29 09:52:43 +0000
  171. @@ -101,7 +101,7 @@
  172. Affine mat = from_basis( T, N, pt_and_dir[0] );
  173. mat = mat.inverse();
  174. - Path p = patha * mat;
  175. + Geom::Path p = patha * mat;
  176. std::vector<double> times;
  177. @@ -484,7 +484,7 @@
  178. // std::cout<<"fusing first and last component\n";
  179. ++beg_comp;
  180. --end_comp;
  181. - Path first = gpaths[i0].portion(dom.back());
  182. + Geom::Path first = gpaths[i0].portion(dom.back());
  183. //FIXME: stitching should not be necessary (?!?)
  184. first.setStitching(true);
  185. first.append(gpaths[i0].portion(dom.front()));
  186. === added file 'src/live_effects/lpe-measure-line.cpp'
  187. --- src/live_effects/lpe-measure-line.cpp 1970-01-01 00:00:00 +0000
  188. +++ src/live_effects/lpe-measure-line.cpp 2016-08-02 11:27:01 +0000
  189. @@ -0,0 +1,821 @@
  190. +/*
  191. + * Author(s):
  192. + * Jabiertxo Arraiza Cenoz <jabier.arraiza@marker.es>
  193. + * Some code and ideas migrated from dimensioning.py by
  194. + * Johannes B. Rutzmoser, johannes.rutzmoser (at) googlemail (dot) com
  195. + * https://github.com/Rutzmoser/inkscape_dimensioning
  196. + * Copyright (C) 2014 Author(s)
  197. +
  198. + * Released under GNU GPL, read the file 'COPYING' for more information
  199. + */
  200. +#include "live_effects/lpe-measure-line.h"
  201. +#include <pangomm/fontdescription.h>
  202. +#include <libnrtype/font-lister.h>
  203. +#include "inkscape.h"
  204. +#include "xml/node.h"
  205. +#include "uri.h"
  206. +#include "uri-references.h"
  207. +#include "preferences.h"
  208. +#include "util/units.h"
  209. +#include "svg/svg-length.h"
  210. +#include "svg/svg-color.h"
  211. +#include "svg/svg.h"
  212. +#include "display/curve.h"
  213. +#include <2geom/affine.h>
  214. +#include "style.h"
  215. +#include "sp-root.h"
  216. +#include "sp-defs.h"
  217. +#include "sp-item.h"
  218. +#include "sp-shape.h"
  219. +#include "sp-path.h"
  220. +#include "desktop.h"
  221. +#include "document.h"
  222. +#include <iomanip>
  223. +
  224. +// TODO due to internal breakage in glibmm headers, this must be last:
  225. +#include <glibmm/i18n.h>
  226. +
  227. +using namespace Geom;
  228. +namespace Inkscape {
  229. +namespace LivePathEffect {
  230. +
  231. +static const Util::EnumData<OrientationMethod> OrientationMethodData[] = {
  232. + { OM_HORIZONTAL, N_("Horizontal"), "horizontal" },
  233. + { OM_VERTICAL, N_("Vertical"), "vertical" },
  234. + { OM_PARALLEL, N_("Parallel"), "parallel" }
  235. +};
  236. +static const Util::EnumDataConverter<OrientationMethod> OMConverter(OrientationMethodData, OM_END);
  237. +
  238. +LPEMeasureLine::LPEMeasureLine(LivePathEffectObject *lpeobject) :
  239. + Effect(lpeobject),
  240. + unit(_("Unit*"), _("Unit"), "unit", &wr, this, "px"),
  241. + fontbutton(_("Font*"), _("Font Selector"), "fontbutton", &wr, this),
  242. + orientation(_("Orientation"), _("Orientation method"), "orientation", OMConverter, &wr, this, OM_PARALLEL, false),
  243. + curve_linked(_("Curve on origin"), _("Curve on origin, set 0 to start/end"), "curve_linked", &wr, this, 1),
  244. + precision(_("Precision*"), _("Precision"), "precision", &wr, this, 2),
  245. + position(_("Positon*"), _("Positon"), "position", &wr, this, 5),
  246. + text_top_bottom(_("Text top/bottom*"), _("Text top/bottom"), "text_top_bottom", &wr, this, 0),
  247. + text_right_left(_("Text right/left*"), _("Text right/left"), "text_right_left", &wr, this, 0),
  248. + helpline_distance(_("Helpline distance*"), _("Helpline distance"), "helpline_distance", &wr, this, 0.0),
  249. + helpline_overlap(_("Helpline overlap*"), _("Helpline overlap"), "helpline_overlap", &wr, this, 2.0),
  250. + scale(_("Scale*"), _("Scaling factor"), "scale", &wr, this, 1.0),
  251. + format(_("Format*"), _("Format the number ex:{measure} {unit}, return to save"), "format", &wr, this,"measure unit"),
  252. + arrows_outside(_("Arrows outside"), _("Arrows outside"), "arrows_outside", &wr, this, false),
  253. + flip_side(_("Flip side*"), _("Flip side"), "flip_side", &wr, this, false),
  254. + scale_insensitive(_("Scale insensitive*"), _("Scale insensitive to transforms in element, parents..."), "scale_insensitive", &wr, this, true),
  255. + local_locale(_("Local Number Format*"), _("Local number format"), "local_locale", &wr, this, true),
  256. + line_group_05(_("Line Group 0.5*"), _("Line Group 0.5, from 0.7"), "line_group_05", &wr, this, true),
  257. + rotate_anotation(_("Rotate Anotation*"), _("Rotate Anotation"), "rotate_anotation", &wr, this, true),
  258. + hide_back(_("Hide if label over*"), _("Hide DIN line if label over"), "hide_back", &wr, this, true),
  259. + dimline_format(_("CSS DIN line*"), _("Override CSS to DIN line, return to save, empty to reset to DIM"), "dimline_format", &wr, this,""),
  260. + helperlines_format(_("CSS helpers*"), _("Override CSS to helper lines, return to save, empty to reset to DIM"), "helperlines_format", &wr, this,""),
  261. + anotation_format(_("CSS anotation*"), _("Override CSS to anotation text, return to save, empty to reset to DIM"), "anotation_format", &wr, this,""),
  262. + arrows_format(_("CSS arrows*"), _("Override CSS to arrows, return to save, empty to reset DIM"), "arrows_format", &wr, this,""),
  263. + expanded(false)
  264. +{
  265. + registerParameter(&unit);
  266. + registerParameter(&fontbutton);
  267. + registerParameter(&orientation);
  268. + registerParameter(&curve_linked);
  269. + registerParameter(&precision);
  270. + registerParameter(&position);
  271. + registerParameter(&text_top_bottom);
  272. + registerParameter(&text_right_left);
  273. + registerParameter(&helpline_distance);
  274. + registerParameter(&helpline_overlap);
  275. + registerParameter(&scale);
  276. + registerParameter(&format);
  277. + registerParameter(&arrows_outside);
  278. + registerParameter(&flip_side);
  279. + registerParameter(&scale_insensitive);
  280. + registerParameter(&local_locale);
  281. + registerParameter(&line_group_05);
  282. + registerParameter(&rotate_anotation);
  283. + registerParameter(&hide_back);
  284. + registerParameter(&dimline_format);
  285. + registerParameter(&helperlines_format);
  286. + registerParameter(&anotation_format);
  287. + registerParameter(&arrows_format);
  288. + Inkscape::Preferences *prefs = Inkscape::Preferences::get();
  289. + Glib::ustring fontbutton_value = prefs->getString("/live_effects/measure-line/fontbutton");
  290. + if(fontbutton_value.empty()){
  291. + fontbutton_value = "Sans 10";
  292. + }
  293. + fontbutton.param_update_default(fontbutton_value);
  294. + scale.param_update_default(prefs->getDouble("/live_effects/measure-line/scale", 1.0));
  295. + precision.param_update_default(prefs->getInt("/live_effects/measure-line/precision", 2));
  296. + position.param_update_default(prefs->getDouble("/live_effects/measure-line/position", 10.0));
  297. + text_top_bottom.param_update_default(prefs->getDouble("/live_effects/measure-line/text_top_bottom", 5.0));
  298. + helpline_distance.param_update_default(prefs->getDouble("/live_effects/measure-line/helpline_distance", 0.0));
  299. + helpline_overlap.param_update_default(prefs->getDouble("/live_effects/measure-line/helpline_overlap", 0.0));
  300. + Glib::ustring unit_value = prefs->getString("/live_effects/measure-line/unit");
  301. + if(unit_value.empty()){
  302. + unit_value = "px";
  303. + }
  304. + unit.param_update_default(unit_value);
  305. + Glib::ustring format_value = prefs->getString("/live_effects/measure-line/format");
  306. + if(format_value.empty()){
  307. + format_value = "{measure}{unit}";
  308. + }
  309. + format.param_update_default(format_value);
  310. + dimline_format.param_update_default(prefs->getString("/live_effects/measure-line/dimline_format"));
  311. + helperlines_format.param_update_default(prefs->getString("/live_effects/measure-line/helperlines_format"));
  312. + anotation_format.param_update_default(prefs->getString("/live_effects/measure-line/anotation_format"));
  313. + arrows_format.param_update_default(prefs->getString("/live_effects/measure-line/arrows_format"));
  314. + flip_side.param_update_default(prefs->getBool("/live_effects/measure-line/flip_side"));
  315. + scale_insensitive.param_update_default(prefs->getBool("/live_effects/measure-line/scale_insensitive"));
  316. + local_locale.param_update_default(prefs->getBool("/live_effects/measure-line/local_locale"));
  317. + line_group_05.param_update_default(prefs->getBool("/live_effects/measure-line/line_group_05"));
  318. + rotate_anotation.param_update_default(prefs->getBool("/live_effects/measure-line/rotate_anotation"));
  319. + hide_back.param_update_default(prefs->getBool("/live_effects/measure-line/hide_back"));
  320. + format.param_hide_canvas_text();
  321. + dimline_format.param_hide_canvas_text();
  322. + helperlines_format.param_hide_canvas_text();
  323. + anotation_format.param_hide_canvas_text();
  324. + arrows_format.param_hide_canvas_text();
  325. + precision.param_set_range(0, 100);
  326. + precision.param_set_increments(1, 1);
  327. + precision.param_set_digits(0);
  328. + precision.param_make_integer(true);
  329. + curve_linked.param_set_range(0, 999);
  330. + curve_linked.param_set_increments(1, 1);
  331. + curve_linked.param_set_digits(0);
  332. + curve_linked.param_make_integer(true);
  333. + precision.param_make_integer(true);
  334. + position.param_set_range(-999999.0, 999999.0);
  335. + position.param_set_increments(1, 1);
  336. + position.param_set_digits(2);
  337. + text_top_bottom.param_set_range(-999999.0, 999999.0);
  338. + text_top_bottom.param_set_increments(1, 1);
  339. + text_top_bottom.param_set_digits(2);
  340. + text_right_left.param_set_range(-999999.0, 999999.0);
  341. + text_right_left.param_set_increments(1, 1);
  342. + text_right_left.param_set_digits(2);
  343. + helpline_distance.param_set_range(-999999.0, 999999.0);
  344. + helpline_distance.param_set_increments(1, 1);
  345. + helpline_distance.param_set_digits(2);
  346. + helpline_overlap.param_set_range(-999999.0, 999999.0);
  347. + helpline_overlap.param_set_increments(1, 1);
  348. + helpline_overlap.param_set_digits(2);
  349. +}
  350. +
  351. +LPEMeasureLine::~LPEMeasureLine() {}
  352. +
  353. +void
  354. +LPEMeasureLine::doOnApply(SPLPEItem const* lpeitem)
  355. +{
  356. + if (!SP_IS_SHAPE(lpeitem)) {
  357. + g_warning("LPE measure line can only be applied to shapes (not groups).");
  358. + SPLPEItem * item = const_cast<SPLPEItem*>(lpeitem);
  359. + item->removeCurrentPathEffect(false);
  360. + }
  361. +}
  362. +
  363. +void
  364. +LPEMeasureLine::doOnVisibilityToggled(SPLPEItem const* /*lpeitem*/)
  365. +{
  366. + if (SPDesktop *desktop = SP_ACTIVE_DESKTOP) {
  367. + Inkscape::URI SVGElem_uri(((Glib::ustring)"#" + (Glib::ustring)"text-on-" + (Glib::ustring)this->getRepr()->attribute("id")).c_str());
  368. + Inkscape::URIReference* SVGElemRef = new Inkscape::URIReference(desktop->doc());
  369. + SVGElemRef->attach(SVGElem_uri);
  370. + SPObject *elemref = NULL;
  371. + Inkscape::XML::Node *node = NULL;
  372. + if (elemref = SVGElemRef->getObject()) {
  373. + node = elemref->getRepr();
  374. + if (!this->isVisible()) {
  375. + node->setAttribute("style", "display:none");
  376. + } else {
  377. + node->setAttribute("style", NULL);
  378. + }
  379. + }
  380. + Inkscape::URI SVGElem_uri2(((Glib::ustring)"#" + (Glib::ustring)"infoline-on-start-" + (Glib::ustring)this->getRepr()->attribute("id")).c_str());
  381. + SVGElemRef->attach(SVGElem_uri2);
  382. + if (elemref = SVGElemRef->getObject()) {
  383. + node = elemref->getRepr();
  384. + if (!this->isVisible()) {
  385. + node->setAttribute("style", "display:none");
  386. + } else {
  387. + node->setAttribute("style", NULL);
  388. + }
  389. + }
  390. + Inkscape::URI SVGElem_uri3(((Glib::ustring)"#" + (Glib::ustring)"infoline-on-end-" + (Glib::ustring)this->getRepr()->attribute("id")).c_str());
  391. + SVGElemRef->attach(SVGElem_uri3);
  392. + if (elemref = SVGElemRef->getObject()) {
  393. + node = elemref->getRepr();
  394. + if (!this->isVisible()) {
  395. + node->setAttribute("style", "display:none");
  396. + } else {
  397. + node->setAttribute("style", NULL);
  398. + }
  399. + }
  400. + Inkscape::URI SVGElem_uri4(((Glib::ustring)"#" + (Glib::ustring)"infoline-" + (Glib::ustring)this->getRepr()->attribute("id")).c_str());
  401. + SVGElemRef->attach(SVGElem_uri4);
  402. + if (elemref = SVGElemRef->getObject()) {
  403. + node = elemref->getRepr();
  404. + if (!this->isVisible()) {
  405. + node->setAttribute("style", "display:none");
  406. + } else {
  407. + node->setAttribute("style", NULL);
  408. + }
  409. + }
  410. + Inkscape::URI SVGElem_uri5(((Glib::ustring)"#" + (Glib::ustring)"downline-" + (Glib::ustring)this->getRepr()->attribute("id")).c_str());
  411. + SVGElemRef->attach(SVGElem_uri5);
  412. + if (elemref = SVGElemRef->getObject()) {
  413. + node = elemref->getRepr();
  414. + if (!this->isVisible()) {
  415. + node->setAttribute("style", "display:none");
  416. + } else {
  417. + node->setAttribute("style", NULL);
  418. + }
  419. + }
  420. + }
  421. +}
  422. +
  423. +void
  424. +LPEMeasureLine::createArrowMarker(Glib::ustring mode)
  425. +{
  426. + if (SPDesktop *desktop = SP_ACTIVE_DESKTOP) {
  427. + Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc();
  428. + Inkscape::URI SVGElem_uri(((Glib::ustring)"#" + mode).c_str());
  429. + Inkscape::URIReference* SVGElemRef = new Inkscape::URIReference(desktop->doc());
  430. + SVGElemRef->attach(SVGElem_uri);
  431. + SPObject *elemref = NULL;
  432. + Inkscape::XML::Node *arrow = NULL;
  433. + if (!(elemref = SVGElemRef->getObject())) {
  434. + arrow = xml_doc->createElement("svg:marker");
  435. + arrow->setAttribute("id", mode.c_str());
  436. + arrow->setAttribute("inkscape:stockid", mode.c_str());
  437. + arrow->setAttribute("orient", "auto");
  438. + arrow->setAttribute("refX", "0.0");
  439. + arrow->setAttribute("refY", "0.0");
  440. + arrow->setAttribute("style", "overflow:visible");
  441. + /* Create <path> */
  442. + Inkscape::XML::Node *arrow_path = xml_doc->createElement("svg:path");
  443. + if (mode == (Glib::ustring)"ArrowDIN-start") {
  444. + arrow_path->setAttribute("d", "M -8,0 8,-2.11 8,2.11 z");
  445. + } else if (mode == (Glib::ustring)"ArrowDIN-end") {
  446. + arrow_path->setAttribute("d", "M 8,0 -8,2.11 -8,-2.11 z");
  447. + } else if (mode == (Glib::ustring)"ArrowDINout-start") {
  448. + arrow_path->setAttribute("d", "M 0,0 -16,2.11 -16,0.5 -26,0.5 -26,-0.5 -16,-0.5 -16,-2.11 z");
  449. + } else {
  450. + arrow_path->setAttribute("d", "M 0,0 16,2.11 16,0.5 26,0.5 26,-0.5 16,-0.5 16,-2.11 z");
  451. + }
  452. + arrow_path->setAttribute("id", (mode + (Glib::ustring)"_path").c_str());
  453. + SPCSSAttr *css = sp_repr_css_attr_new();
  454. + sp_repr_css_set_property (css, "fill","#000000");
  455. + sp_repr_css_set_property (css, "stroke","none" );
  456. + sp_repr_css_attr_add_from_string(css, arrows_format.param_getSVGValue());
  457. + Glib::ustring css_str;
  458. + sp_repr_css_write_string(css,css_str);
  459. + arrow_path->setAttribute("style", css_str.c_str());
  460. + arrow->addChild(arrow_path, NULL);
  461. + Inkscape::GC::release(arrow_path);
  462. + elemref = SP_OBJECT(desktop->getDocument()->getDefs()->appendChildRepr(arrow));
  463. + Inkscape::GC::release(arrow);
  464. + } else {
  465. + Inkscape::XML::Node *arrow= elemref->getRepr();
  466. + if (arrow) {
  467. + Inkscape::XML::Node *arrow_data = arrow->firstChild();
  468. + if (arrow_data) {
  469. + SPCSSAttr *css = sp_repr_css_attr_new();
  470. + sp_repr_css_set_property (css, "fill","#000000");
  471. + sp_repr_css_set_property (css, "stroke","none" );
  472. + sp_repr_css_attr_add_from_string(css, arrows_format.param_getSVGValue());
  473. + Glib::ustring css_str;
  474. + sp_repr_css_write_string(css,css_str);
  475. + arrow_data->setAttribute("style", css_str.c_str());
  476. + }
  477. + }
  478. + }
  479. + }
  480. +}
  481. +
  482. +void
  483. +LPEMeasureLine::createTextLabel(Geom::Point pos, double length, Geom::Coord angle, bool remove)
  484. +{
  485. + if (SPDesktop *desktop = SP_ACTIVE_DESKTOP) {
  486. + Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc();
  487. + Inkscape::XML::Node *rtext = NULL;
  488. + double doc_w = desktop->getDocument()->getRoot()->width.value;
  489. + Geom::Scale scale = desktop->getDocument()->getDocumentScale();
  490. + SPNamedView *nv = desktop->getNamedView();
  491. + Glib::ustring display_unit = nv->display_units->abbr;
  492. + if (display_unit.empty()) {
  493. + display_unit = "px";
  494. + }
  495. + //only check constrain viewbox on X
  496. + doc_scale = Inkscape::Util::Quantity::convert( scale[Geom::X], "px", nv->display_units );
  497. + if( doc_scale > 0 ) {
  498. + doc_scale= 1.0/doc_scale;
  499. + } else {
  500. + doc_scale = 1.0;
  501. + }
  502. + Inkscape::URI SVGElem_uri(((Glib::ustring)"#" + (Glib::ustring)"text-on-" + (Glib::ustring)this->getRepr()->attribute("id")).c_str());
  503. + Inkscape::URIReference* SVGElemRef = new Inkscape::URIReference(desktop->doc());
  504. + SVGElemRef->attach(SVGElem_uri);
  505. + SPObject *elemref = NULL;
  506. + Inkscape::XML::Node *rtspan = NULL;
  507. + pos = pos - Point::polar(angle, text_right_left);
  508. + if (elemref = SVGElemRef->getObject()) {
  509. + if (remove) {
  510. + elemref->deleteObject();
  511. + return;
  512. + }
  513. + rtext = elemref->getRepr();
  514. + sp_repr_set_svg_double(rtext, "x", pos[Geom::X]);
  515. + sp_repr_set_svg_double(rtext, "y", pos[Geom::Y]);
  516. + } else {
  517. + if (remove) {
  518. + return;
  519. + }
  520. + rtext = xml_doc->createElement("svg:text");
  521. + rtext->setAttribute("xml:space", "preserve");
  522. + rtext->setAttribute("id", ( (Glib::ustring)"text-on-" + (Glib::ustring)this->getRepr()->attribute("id")).c_str());
  523. + sp_repr_set_svg_double(rtext, "x", pos[Geom::X]);
  524. + sp_repr_set_svg_double(rtext, "y", pos[Geom::Y]);
  525. + rtspan = xml_doc->createElement("svg:tspan");
  526. + rtspan->setAttribute("sodipodi:role", "line");
  527. + }
  528. + gchar * transform;
  529. + Geom::Affine affine = Geom::Affine(Geom::Translate(pos).inverse());
  530. + angle = std::fmod(angle, 2*M_PI);
  531. + if (angle < 0) angle += 2*M_PI;
  532. + if (angle >= rad_from_deg(90) && angle < rad_from_deg(270)) {
  533. + angle = std::fmod(angle + rad_from_deg(180), 2*M_PI);
  534. + if (angle < 0) angle += 2*M_PI;
  535. + }
  536. + affine *= Geom::Rotate(angle);
  537. + affine *= Geom::Translate(pos);
  538. + if (rotate_anotation) {
  539. + transform = sp_svg_transform_write(affine);
  540. + } else {
  541. + transform = NULL;
  542. + }
  543. + rtext->setAttribute("transform", transform);
  544. + SPCSSAttr *css = sp_repr_css_attr_new();
  545. + sp_repr_css_attr_add_from_string(css, anotation_format.param_getSVGValue());
  546. + Inkscape::FontLister *fontlister = Inkscape::FontLister::get_instance();
  547. + fontlister->fill_css( css, (Glib::ustring)fontbutton.param_getSVGValue() );
  548. + std::stringstream font_size;
  549. + font_size.imbue(std::locale::classic());
  550. + font_size << fontsize << "pt";
  551. +
  552. + sp_repr_css_set_property (css, "font-size",font_size.str().c_str());
  553. + sp_repr_css_set_property (css, "line-height","125%");
  554. + sp_repr_css_set_property (css, "letter-spacing","0");
  555. + sp_repr_css_set_property (css, "word-spacing", "0");
  556. + sp_repr_css_set_property (css, "text-align", "center");
  557. + sp_repr_css_set_property (css, "text-anchor", "middle");
  558. + sp_repr_css_set_property (css, "fill", "#000000");
  559. + sp_repr_css_set_property (css, "fill-opacity", "1");
  560. + sp_repr_css_set_property (css, "stroke", "none");
  561. + sp_repr_css_attr_add_from_string(css, anotation_format.param_getSVGValue());
  562. + Glib::ustring css_str;
  563. + sp_repr_css_write_string(css,css_str);
  564. + if (!rtspan) {
  565. + rtspan = rtext->firstChild();
  566. + }
  567. + rtext->setAttribute("style", css_str.c_str());
  568. + rtspan->setAttribute("style", NULL);
  569. + sp_repr_css_attr_unref (css);
  570. + if (!elemref) {
  571. + rtext->addChild(rtspan, NULL);
  572. + Inkscape::GC::release(rtspan);
  573. + }
  574. + length = Inkscape::Util::Quantity::convert(length / doc_scale, display_unit.c_str(), unit.get_abbreviation());
  575. + std::stringstream length_str;
  576. + length_str.precision(precision);
  577. + length_str.setf(std::ios::fixed, std::ios::floatfield);
  578. + if (local_locale) {
  579. + length_str.imbue(std::locale(""));
  580. + } else {
  581. + length_str.imbue(std::locale::classic());
  582. + }
  583. + length_str << std::fixed << length;
  584. + Glib::ustring label_value = Glib::ustring(format.param_getSVGValue());
  585. + size_t s = label_value.find((Glib::ustring)"{measure}",0);
  586. + if(s < label_value.length()) {
  587. + label_value.replace(s,s+9,length_str.str());
  588. + }
  589. + s = label_value.find((Glib::ustring)"{unit}",0);
  590. + if(s < label_value.length()) {
  591. + label_value.replace(s,s+6,unit.get_abbreviation());
  592. + }
  593. + Inkscape::XML::Node *rstring = NULL;
  594. + if (!elemref) {
  595. + rstring = xml_doc->createTextNode(label_value.c_str());
  596. + rtspan->addChild(rstring, NULL);
  597. + Inkscape::GC::release(rstring);
  598. + } else {
  599. + rstring = rtspan->firstChild();
  600. + rstring->setContent(label_value.c_str());
  601. + }
  602. + if (!elemref) {
  603. + elemref = SP_OBJECT(desktop->currentLayer()->appendChildRepr(rtext));
  604. + Inkscape::GC::release(rtext);
  605. + }
  606. + Inkscape::XML::Node *tmp_node = rtext->duplicate(xml_doc);
  607. + affine = Geom::Affine(Geom::Scale(1.4));
  608. + tmp_node->setAttribute("transform", sp_svg_transform_write(affine));
  609. + SPObject * tmp_obj = SP_OBJECT(desktop->currentLayer()->appendChildRepr(tmp_node));
  610. + Inkscape::GC::release(tmp_node);
  611. + tmp_obj->updateRepr();
  612. + Geom::OptRect bounds = SP_ITEM(tmp_obj)->bounds(SPItem::GEOMETRIC_BBOX);
  613. + if (bounds) {
  614. + anotation_width = bounds->width();
  615. + }
  616. + tmp_obj->deleteObject();
  617. + }
  618. +}
  619. +
  620. +void
  621. +LPEMeasureLine::createLine(Geom::Point start,Geom::Point end, Glib::ustring id, bool main, bool overflow, bool remove, bool arrows)
  622. +{
  623. + if (SPDesktop *desktop = SP_ACTIVE_DESKTOP) {
  624. + Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc();
  625. + Inkscape::URI SVGElem_uri(((Glib::ustring)"#" + id).c_str());
  626. + Inkscape::URIReference* SVGElemRef = new Inkscape::URIReference(desktop->doc());
  627. + SVGElemRef->attach(SVGElem_uri);
  628. + SPObject *elemref = NULL;
  629. + Inkscape::XML::Node *line = NULL;
  630. + if (!main) {
  631. + Geom::Ray ray(start, end);
  632. + Geom::Coord angle = ray.angle();
  633. + start = start + Point::polar(angle, helpline_distance );
  634. + end = end + Point::polar(angle, helpline_overlap );
  635. + }
  636. + Geom::PathVector line_pathv;
  637. + if (main && std::abs(text_top_bottom) < fontsize/1.5 && hide_back && !overflow){
  638. + Geom::Path line_path;
  639. + double k = 0;
  640. + if (flip_side) {
  641. + k = (Geom::distance(start,end)/2.0) + arrow_gap - (anotation_width/2.0);
  642. + } else {
  643. + k = (Geom::distance(start,end)/2.0) - arrow_gap - (anotation_width/2.0);
  644. + }
  645. + if (Geom::distance(start,end) < anotation_width){
  646. + return;
  647. + }
  648. + Geom::Ray ray(end, start);
  649. + Geom::Coord angle = ray.angle();
  650. + line_path.start(start);
  651. + line_path.appendNew<Geom::LineSegment>(start - Point::polar(angle, k));
  652. + line_pathv.push_back(line_path);
  653. + line_path.clear();
  654. + line_path.start(end + Point::polar(angle, k));
  655. + line_path.appendNew<Geom::LineSegment>(end);
  656. + line_pathv.push_back(line_path);
  657. + } else {
  658. + Geom::Path line_path;
  659. + line_path.start(start);
  660. + line_path.appendNew<Geom::LineSegment>(end);
  661. + line_pathv.push_back(line_path);
  662. + }
  663. + gchar * line_str = sp_svg_write_path( line_pathv );
  664. + line_pathv.clear();
  665. + if (elemref = SVGElemRef->getObject()) {
  666. + if (remove) {
  667. + elemref->deleteObject();
  668. + return;
  669. + }
  670. + line = elemref->getRepr();
  671. + line->setAttribute("d" , line_str);
  672. + } else {
  673. + if (remove) {
  674. + return;
  675. + }
  676. + line = xml_doc->createElement("svg:path");
  677. + line->setAttribute("id", id.c_str());
  678. + line->setAttribute("d" , line_str);
  679. + }
  680. + Glib::ustring style = (Glib::ustring)"stroke:#000000;fill:none;";
  681. + if (overflow && !arrows) {
  682. + line->setAttribute("inkscape:label", "downline");
  683. + } else if (main) {
  684. + line->setAttribute("inkscape:label", "dinline");
  685. + if (arrows_outside) {
  686. + style = style + (Glib::ustring)"marker-start:url(#ArrowDINout-start);marker-end:url(#ArrowDINout-end);";
  687. + } else {
  688. + style = style + (Glib::ustring)"marker-start:url(#ArrowDIN-start);marker-end:url(#ArrowDIN-end);";
  689. + }
  690. + } else {
  691. + line->setAttribute("inkscape:label", "dinhelpline");
  692. + }
  693. + std::stringstream stroke_w;
  694. + stroke_w.imbue(std::locale::classic());
  695. + if (line_group_05) {
  696. + double stroke_width = Inkscape::Util::Quantity::convert(0.25 / doc_scale, "mm", display_unit.c_str());
  697. + stroke_w << stroke_width;
  698. + style = style + (Glib::ustring)"stroke-width:" + (Glib::ustring)stroke_w.str();
  699. + } else {
  700. + double stroke_width = Inkscape::Util::Quantity::convert(0.35 / doc_scale, "mm", display_unit.c_str());
  701. + stroke_w << stroke_width;
  702. + style = style + (Glib::ustring)"stroke-width:" + (Glib::ustring)stroke_w.str();
  703. + }
  704. + SPCSSAttr *css = sp_repr_css_attr_new();
  705. + sp_repr_css_attr_add_from_string(css, style.c_str());
  706. + if (main) {
  707. + sp_repr_css_attr_add_from_string(css, dimline_format.param_getSVGValue());
  708. + } else {
  709. + sp_repr_css_attr_add_from_string(css, helperlines_format.param_getSVGValue());
  710. + }
  711. + Glib::ustring css_str;
  712. + sp_repr_css_write_string(css,css_str);
  713. + line->setAttribute("style", css_str.c_str());
  714. + if (!elemref) {
  715. + elemref = SP_OBJECT(desktop->currentLayer()->appendChildRepr(line));
  716. + Inkscape::GC::release(line);
  717. + }
  718. + }
  719. +}
  720. +
  721. +void
  722. +LPEMeasureLine::doBeforeEffect (SPLPEItem const* lpeitem)
  723. +{
  724. + SPLPEItem * splpeitem = const_cast<SPLPEItem *>(lpeitem);
  725. + SPPath *sp_path = dynamic_cast<SPPath *>(splpeitem);
  726. + if (sp_path) {
  727. + Geom::PathVector pathvector = sp_path->get_original_curve()->get_pathvector();
  728. + if (arrows_outside) {
  729. + createArrowMarker((Glib::ustring)"ArrowDINout-start");
  730. + createArrowMarker((Glib::ustring)"ArrowDINout-end");
  731. + } else {
  732. + createArrowMarker((Glib::ustring)"ArrowDIN-start");
  733. + createArrowMarker((Glib::ustring)"ArrowDIN-end");
  734. + }
  735. + if (SPDesktop *desktop = SP_ACTIVE_DESKTOP) {
  736. + if (((Glib::ustring)format.param_getSVGValue()).empty()) {
  737. + format.param_setValue((Glib::ustring)"{measure}{unit}");
  738. + this->upd_params = true;
  739. + }
  740. + size_t ncurves = pathvector.curveCount();
  741. + curve_linked.param_set_range(0, ncurves);
  742. + Geom::Point start = pathvector.initialPoint();
  743. + Geom::Point end = pathvector.finalPoint();
  744. + if (curve_linked) { //!0
  745. + start = pathvector.pointAt(curve_linked -1);
  746. + end = pathvector.pointAt(curve_linked);
  747. + }
  748. + Geom::Point hstart = start;
  749. + Geom::Point hend = end;
  750. + bool remove = false;
  751. + if (Geom::are_near(hstart, hend)) {
  752. + remove = true;
  753. + }
  754. + if (orientation == OM_VERTICAL) {
  755. + Coord xpos = std::max(hstart[Geom::X],hend[Geom::X]);
  756. + if (flip_side) {
  757. + xpos = std::min(hstart[Geom::X],hend[Geom::X]);
  758. + }
  759. + hstart[Geom::X] = xpos;
  760. + hend[Geom::X] = xpos;
  761. + if (hstart[Geom::Y] > hend[Geom::Y]) {
  762. + swap(hstart,hend);
  763. + swap(start,end);
  764. + }
  765. + if (Geom::are_near(hstart[Geom::Y], hend[Geom::Y])) {
  766. + remove = true;
  767. + }
  768. + }
  769. + if (orientation == OM_HORIZONTAL) {
  770. + Coord ypos = std::max(hstart[Geom::Y],hend[Geom::Y]);
  771. + if (flip_side) {
  772. + ypos = std::min(hstart[Geom::Y],hend[Geom::Y]);
  773. + }
  774. + hstart[Geom::Y] = ypos;
  775. + hend[Geom::Y] = ypos;
  776. + if (hstart[Geom::X] < hend[Geom::X]) {
  777. + swap(hstart,hend);
  778. + swap(start,end);
  779. + }
  780. + if (Geom::are_near(hstart[Geom::X], hend[Geom::X])) {
  781. + remove = true;
  782. + }
  783. + }
  784. + double length = Geom::distance(hstart,hend) * scale;
  785. + Geom::Point pos = Geom::middle_point(hstart,hend);
  786. + Geom::Ray ray(hstart,hend);
  787. + Geom::Coord angle = ray.angle();
  788. + if (flip_side) {
  789. + angle = std::fmod(angle + rad_from_deg(180), 2*M_PI);
  790. + if (angle < 0) angle += 2*M_PI;
  791. + }
  792. + //We get the font size to offset the text to the middle
  793. + Pango::FontDescription fontdesc((Glib::ustring)fontbutton.param_getSVGValue());
  794. + fontsize = fontdesc.get_size()/(double)Pango::SCALE;
  795. + fontsize *= desktop->doc()->getRoot()->c2p.inverse().expansionX();
  796. + Geom::Coord angle_cross = std::fmod(angle + rad_from_deg(90), 2*M_PI);
  797. + if (angle_cross < 0) angle_cross += 2*M_PI;
  798. + angle = std::fmod(angle, 2*M_PI);
  799. + if (angle < 0) angle += 2*M_PI;
  800. + if (angle >= rad_from_deg(90) && angle < rad_from_deg(270)) {
  801. + pos = pos - Point::polar(angle_cross, (position - text_top_bottom) + fontsize/2.5);
  802. + } else {
  803. + pos = pos - Point::polar(angle_cross, (position + text_top_bottom) - fontsize/2.5);
  804. + }
  805. + if (!scale_insensitive) {
  806. + Geom::Affine affinetransform = i2anc_affine(SP_OBJECT(lpeitem), SP_OBJECT(desktop->doc()->getRoot()));
  807. + length *= (affinetransform.expansionX() + affinetransform.expansionY()) / 2.0;
  808. + }
  809. + createTextLabel(pos, length, angle, remove);
  810. + bool overflow = false;
  811. + if ((anotation_width/2) + std::abs(text_right_left) > Geom::distance(start,end)/2.0) {
  812. + Geom::Point sstart = end - Point::polar(angle_cross, position);
  813. + Geom::Point send = end - Point::polar(angle_cross, position);
  814. + if (text_right_left < 0 && flip_side || text_right_left > 0 && !flip_side) {
  815. + sstart = start - Point::polar(angle_cross, position);
  816. + send = start - Point::polar(angle_cross, position);
  817. + }
  818. + Geom::Point prog_end = Geom::Point();
  819. + if (std::abs(text_top_bottom) < fontsize/1.5 && hide_back) {
  820. + if (text_right_left > 0 ) {
  821. + prog_end = sstart - Point::polar(angle, std::abs(text_right_left) - (anotation_width/1.9) - (Geom::distance(start,end)/2.0));
  822. + } else {
  823. + prog_end = sstart + Point::polar(angle, std::abs(text_right_left) - (anotation_width/1.9) - (Geom::distance(start,end)/2.0));
  824. + }
  825. + } else {
  826. + if (text_right_left > 0 ) {
  827. + prog_end = sstart - Point::polar(angle,(anotation_width/2) + std::abs(text_right_left) - (Geom::distance(start,end)/2.0));
  828. + } else {
  829. + prog_end = sstart + Point::polar(angle,(anotation_width/2) + std::abs(text_right_left) - (Geom::distance(start,end)/2.0));
  830. + }
  831. + }
  832. + overflow = true;
  833. + createLine(sstart, prog_end, (Glib::ustring)"downline-" + (Glib::ustring)this->getRepr()->attribute("id"), true, overflow, false, false);
  834. + } else {
  835. + //erase it
  836. + createLine(Geom::Point(),Geom::Point(), (Glib::ustring)"downline-" + (Glib::ustring)this->getRepr()->attribute("id"), true, overflow, true, false);
  837. + }
  838. + //LINE
  839. + arrow_gap = 8 * Inkscape::Util::Quantity::convert(0.35 / doc_scale, "mm", display_unit.c_str());
  840. + if (line_group_05) {
  841. + arrow_gap = 8 * Inkscape::Util::Quantity::convert(0.25 / doc_scale, "mm", display_unit.c_str());
  842. + }
  843. + SPCSSAttr *css = sp_repr_css_attr_new();
  844. + sp_repr_css_attr_add_from_string(css, dimline_format.param_getSVGValue());
  845. + setlocale(LC_NUMERIC, std::locale::classic().name().c_str());
  846. + double width_line = atof(sp_repr_css_property(css,"stroke-width","-1"));
  847. + setlocale(LC_NUMERIC, std::locale("").name().c_str());
  848. + if (width_line > -0.0001) {
  849. + arrow_gap = 8 * Inkscape::Util::Quantity::convert(width_line/ doc_scale, "mm", display_unit.c_str());
  850. + }
  851. + if (flip_side) {
  852. + arrow_gap *= -1;
  853. + }
  854. + hstart = hstart - Point::polar(angle_cross, position);
  855. + Glib::ustring id = (Glib::ustring)"infoline-on-start-" + (Glib::ustring)this->getRepr()->attribute("id");
  856. + createLine(start, hstart, id, false, false, remove);
  857. + hend = hend - Point::polar(angle_cross, position);
  858. + id = (Glib::ustring)"infoline-on-end-" + (Glib::ustring)this->getRepr()->attribute("id");
  859. + createLine(end, hend, id, false, false, remove);
  860. + if (!arrows_outside) {
  861. + hstart = hstart + Point::polar(angle, arrow_gap);
  862. + hend = hend - Point::polar(angle, arrow_gap );
  863. + }
  864. + id = (Glib::ustring)"infoline-" + (Glib::ustring)this->getRepr()->attribute("id");
  865. + createLine(hstart, hend, id, true, overflow, remove, true);
  866. + }
  867. + }
  868. +}
  869. +
  870. +void LPEMeasureLine::doOnRemove (SPLPEItem const* lpeitem)
  871. +{
  872. + if (SPDesktop *desktop = SP_ACTIVE_DESKTOP) {
  873. + SPLPEItem * splpeitem = const_cast<SPLPEItem *>(lpeitem);
  874. + Inkscape::URI SVGElem_uri(((Glib::ustring)"#" + (Glib::ustring)"text-on-" + (Glib::ustring)this->getRepr()->attribute("id")).c_str());
  875. + Inkscape::URIReference* SVGElemRef = new Inkscape::URIReference(desktop->doc());
  876. + SVGElemRef->attach(SVGElem_uri);
  877. + SPObject *elemref = NULL;
  878. + if (elemref = SVGElemRef->getObject()) {
  879. + elemref->deleteObject();
  880. + }
  881. + Inkscape::URI SVGElem_uri2(((Glib::ustring)"#" + (Glib::ustring)"infoline-on-end-" + (Glib::ustring)this->getRepr()->attribute("id")).c_str());
  882. + SVGElemRef->attach(SVGElem_uri2);
  883. + if (elemref = SVGElemRef->getObject()) {
  884. + elemref->deleteObject();
  885. + }
  886. + Inkscape::URI SVGElem_uri3(((Glib::ustring)"#" + (Glib::ustring)"infoline-on-start-" + (Glib::ustring)this->getRepr()->attribute("id")).c_str());
  887. + SVGElemRef->attach(SVGElem_uri3);
  888. + if (elemref = SVGElemRef->getObject()) {
  889. + elemref->deleteObject();
  890. + }
  891. + Inkscape::URI SVGElem_uri4(((Glib::ustring)"#" + (Glib::ustring)"infoline-" + (Glib::ustring)this->getRepr()->attribute("id")).c_str());
  892. + SVGElemRef->attach(SVGElem_uri4);
  893. + if (elemref = SVGElemRef->getObject()) {
  894. + elemref->deleteObject();
  895. + }
  896. + Inkscape::URI SVGElem_uri5(((Glib::ustring)"#" + (Glib::ustring)"downline-" + (Glib::ustring)this->getRepr()->attribute("id")).c_str());
  897. + SVGElemRef->attach(SVGElem_uri5);
  898. + if (elemref = SVGElemRef->getObject()) {
  899. + elemref->deleteObject();
  900. + }
  901. + }
  902. +}
  903. +
  904. +Gtk::Widget *LPEMeasureLine::newWidget()
  905. +{
  906. + // use manage here, because after deletion of Effect object, others might
  907. + // still be pointing to this widget.
  908. + Gtk::VBox *vbox = Gtk::manage(new Gtk::VBox(Effect::newWidget()));
  909. +
  910. + vbox->set_border_width(5);
  911. + vbox->set_homogeneous(false);
  912. + vbox->set_spacing(2);
  913. +
  914. + std::vector<Parameter *>::iterator it = param_vector.begin();
  915. + Gtk::HBox * button1 = Gtk::manage(new Gtk::HBox(true,0));
  916. + Gtk::VBox * vbox_expander = Gtk::manage( new Gtk::VBox(Effect::newWidget()) );
  917. + vbox_expander->set_border_width(0);
  918. + vbox_expander->set_spacing(2);
  919. + while (it != param_vector.end()) {
  920. + if ((*it)->widget_is_visible) {
  921. + Parameter *param = *it;
  922. + Gtk::Widget *widg = dynamic_cast<Gtk::Widget *>(param->param_newWidget());
  923. + Glib::ustring *tip = param->param_getTooltip();
  924. + if (widg) {
  925. + if (param->param_key != "dimline_format" &&
  926. + param->param_key != "helperlines_format" &&
  927. + param->param_key != "arrows_format" &&
  928. + param->param_key != "anotation_format") {
  929. + vbox->pack_start(*widg, true, true, 2);
  930. + } else {
  931. + vbox_expander->pack_start(*widg, true, true, 2);
  932. + }
  933. + if (tip) {
  934. + widg->set_tooltip_text(*tip);
  935. + } else {
  936. + widg->set_tooltip_text("");
  937. + widg->set_has_tooltip(false);
  938. + }
  939. + }
  940. + }
  941. +
  942. + ++it;
  943. + }
  944. + Gtk::Button *save_default = Gtk::manage(new Gtk::Button(Glib::ustring(_("Save '*' as default"))));
  945. + save_default->signal_clicked().connect(sigc::mem_fun(*this, &LPEMeasureLine::saveDefault));
  946. + button1->pack_start(*save_default, true, true, 2);
  947. + expander = Gtk::manage(new Gtk::Expander(Glib::ustring(_("Show DIM CSS style override"))));
  948. + expander->add(*vbox_expander);
  949. + expander->set_expanded(expanded);
  950. + expander->property_expanded().signal_changed().connect(sigc::mem_fun(*this, &LPEMeasureLine::onExpanderChanged) );
  951. + vbox->pack_start(*expander, true, true, 2);
  952. + vbox->pack_start(*button1, true, true, 2);
  953. + return dynamic_cast<Gtk::Widget *>(vbox);
  954. +}
  955. +
  956. +void
  957. +LPEMeasureLine::onExpanderChanged()
  958. +{
  959. + expanded = expander->get_expanded();
  960. + if(expanded) {
  961. + expander->set_label (Glib::ustring(_("Hide DIM CSS style override")));
  962. + } else {
  963. + expander->set_label (Glib::ustring(_("Show DIM CSS style override")));
  964. + }
  965. +}
  966. +
  967. +Geom::PathVector
  968. +LPEMeasureLine::doEffect_path(Geom::PathVector const &path_in)
  969. +{
  970. + return path_in;
  971. +}
  972. +
  973. +void
  974. +LPEMeasureLine::saveDefault()
  975. +{
  976. + Inkscape::Preferences *prefs = Inkscape::Preferences::get();
  977. + prefs->setString("/live_effects/measure-line/fontbutton", (Glib::ustring)fontbutton.param_getSVGValue());
  978. + prefs->setDouble("/live_effects/measure-line/scale", scale);
  979. + prefs->setInt("/live_effects/measure-line/precision", precision);
  980. + prefs->setDouble("/live_effects/measure-line/position", position);
  981. + prefs->setDouble("/live_effects/measure-line/text_top_bottom", text_top_bottom);
  982. + prefs->setDouble("/live_effects/measure-line/helpline_distance", helpline_distance);
  983. + prefs->setDouble("/live_effects/measure-line/helpline_overlap", helpline_overlap);
  984. + prefs->setString("/live_effects/measure-line/unit", (Glib::ustring)unit.get_abbreviation());
  985. + prefs->setString("/live_effects/measure-line/format", (Glib::ustring)format.param_getSVGValue());
  986. + prefs->setString("/live_effects/measure-line/dimline_format", (Glib::ustring)dimline_format.param_getSVGValue());
  987. + prefs->setString("/live_effects/measure-line/helperlines_format", (Glib::ustring)helperlines_format.param_getSVGValue());
  988. + prefs->setString("/live_effects/measure-line/anotation_format", (Glib::ustring)anotation_format.param_getSVGValue());
  989. + prefs->setString("/live_effects/measure-line/arrows_format", (Glib::ustring)arrows_format.param_getSVGValue());
  990. + prefs->setBool("/live_effects/measure-line/flip_side", flip_side);
  991. + prefs->setBool("/live_effects/measure-line/scale_insensitive", scale_insensitive);
  992. + prefs->setBool("/live_effects/measure-line/local_locale", local_locale);
  993. + prefs->setBool("/live_effects/measure-line/line_group_05", line_group_05);
  994. + prefs->setBool("/live_effects/measure-line/rotate_anotation", rotate_anotation);
  995. + prefs->setBool("/live_effects/measure-line/hide_back", hide_back);
  996. +}
  997. +
  998. +}; //namespace LivePathEffect
  999. +}; /* namespace Inkscape */
  1000. +
  1001. +/*
  1002. + Local Variables:
  1003. + mode:c++
  1004. + c-file-style:"stroustrup"
  1005. + c-file-offset:((innamespace . 0)(inline-open . 0)(case-label . +))
  1006. + indent-tabs-mode:nil
  1007. + fill-column:99
  1008. + End:
  1009. +*/
  1010. +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
  1011. === added file 'src/live_effects/lpe-measure-line.h'
  1012. --- src/live_effects/lpe-measure-line.h 1970-01-01 00:00:00 +0000
  1013. +++ src/live_effects/lpe-measure-line.h 2016-08-02 11:00:55 +0000
  1014. @@ -0,0 +1,101 @@
  1015. +#ifndef INKSCAPE_LPE_MEASURE_LINE_H
  1016. +#define INKSCAPE_LPE_MEASURE_LINE_H
  1017. +
  1018. +/*
  1019. + * Author(s):
  1020. + * Jabiertxo Arraiza Cenoz <jabier.arraiza@marker.es>
  1021. + *
  1022. + * Copyright (C) 2014 Author(s)
  1023. + *
  1024. + * Released under GNU GPL, read the file 'COPYING' for more information
  1025. + */
  1026. +
  1027. +#include "live_effects/effect.h"
  1028. +#include "live_effects/parameter/enum.h"
  1029. +#include "live_effects/parameter/fontbutton.h"
  1030. +#include "live_effects/parameter/text.h"
  1031. +#include "live_effects/parameter/unit.h"
  1032. +#include "live_effects/parameter/bool.h"
  1033. +#include "live_effects/parameter/originalpath.h"
  1034. +#include <libnrtype/font-lister.h>
  1035. +#include <2geom/angle.h>
  1036. +#include <2geom/ray.h>
  1037. +#include <2geom/point.h>
  1038. +
  1039. +namespace Inkscape {
  1040. +namespace LivePathEffect {
  1041. +
  1042. +enum OrientationMethod {
  1043. + OM_HORIZONTAL,
  1044. + OM_VERTICAL,
  1045. + OM_PARALLEL,
  1046. + OM_END
  1047. +};
  1048. +
  1049. +class LPEMeasureLine : public Effect {
  1050. +public:
  1051. + LPEMeasureLine(LivePathEffectObject *lpeobject);
  1052. + virtual ~LPEMeasureLine();
  1053. + virtual void doBeforeEffect (SPLPEItem const* lpeitem);
  1054. + virtual void doOnApply(SPLPEItem const* lpeitem);
  1055. + virtual void doOnRemove (SPLPEItem const* lpeitem);
  1056. + virtual void doOnVisibilityToggled(SPLPEItem const* /*lpeitem*/);
  1057. + virtual Geom::PathVector doEffect_path(Geom::PathVector const &path_in);
  1058. + void createLine(Geom::Point start,Geom::Point end,Glib::ustring id, bool main, bool overflow, bool remove, bool arrows = false);
  1059. + void createTextLabel(Geom::Point pos, double length, Geom::Coord angle, bool remove);
  1060. + void onExpanderChanged();
  1061. + void createArrowMarker(Glib::ustring mode);
  1062. + void saveDefault();
  1063. + virtual Gtk::Widget *newWidget();
  1064. +private:
  1065. + UnitParam unit;
  1066. + FontButtonParam fontbutton;
  1067. + EnumParam<OrientationMethod> orientation;
  1068. + ScalarParam curve_linked;
  1069. + ScalarParam precision;
  1070. + ScalarParam position;
  1071. + ScalarParam text_top_bottom;
  1072. + ScalarParam text_right_left;
  1073. + ScalarParam helpline_distance;
  1074. + ScalarParam helpline_overlap;
  1075. + ScalarParam scale;
  1076. + TextParam format;
  1077. + BoolParam arrows_outside;
  1078. + BoolParam flip_side;
  1079. + BoolParam scale_insensitive;
  1080. + BoolParam local_locale;
  1081. + BoolParam line_group_05;
  1082. + BoolParam rotate_anotation;
  1083. + BoolParam hide_back;
  1084. + TextParam dimline_format;
  1085. + TextParam helperlines_format;
  1086. + TextParam anotation_format;
  1087. + TextParam arrows_format;
  1088. + Glib::ustring display_unit;
  1089. + bool expanded;
  1090. + Gtk::Expander * expander;
  1091. + double doc_scale;
  1092. + double fontsize;
  1093. + double anotation_width;
  1094. + double arrow_gap;
  1095. +/* Geom::Affine affine_over;*/
  1096. + LPEMeasureLine(const LPEMeasureLine &);
  1097. + LPEMeasureLine &operator=(const LPEMeasureLine &);
  1098. +
  1099. +};
  1100. +
  1101. +} //namespace LivePathEffect
  1102. +} //namespace Inkscape
  1103. +
  1104. +#endif
  1105. +
  1106. +/*
  1107. + Local Variables:
  1108. + mode:c++
  1109. + c-file-style:"stroustrup"
  1110. + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
  1111. + indent-tabs-mode:nil
  1112. + fill-column:99
  1113. + End:
  1114. +*/
  1115. +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
  1116. === modified file 'src/live_effects/lpe-transform_2pts.cpp'
  1117. --- src/live_effects/lpe-transform_2pts.cpp 2016-07-28 11:26:17 +0000
  1118. +++ src/live_effects/lpe-transform_2pts.cpp 2016-07-24 16:00:12 +0000
  1119. @@ -90,7 +90,6 @@
  1120. {
  1121. using namespace Geom;
  1122. original_bbox(lpeitem);
  1123. -
  1124. point_a = Point(boundingbox_X.min(), boundingbox_Y.middle());
  1125. point_b = Point(boundingbox_X.max(), boundingbox_Y.middle());
  1126. SPLPEItem * splpeitem = const_cast<SPLPEItem *>(lpeitem);
  1127. === modified file 'src/live_effects/parameter/Makefile_insert'
  1128. --- src/live_effects/parameter/Makefile_insert 2015-03-02 01:29:50 +0000
  1129. +++ src/live_effects/parameter/Makefile_insert 2016-07-29 21:24:09 +0000
  1130. @@ -11,6 +11,8 @@
  1131. live_effects/parameter/random.h \
  1132. live_effects/parameter/point.cpp \
  1133. live_effects/parameter/point.h \
  1134. + live_effects/parameter/fontbutton.cpp \
  1135. + live_effects/parameter/fontbutton.h \
  1136. live_effects/parameter/enum.h \
  1137. live_effects/parameter/path-reference.cpp \
  1138. live_effects/parameter/path-reference.h \
  1139. === modified file 'src/live_effects/parameter/bool.cpp'
  1140. --- src/live_effects/parameter/bool.cpp 2015-10-18 19:13:13 +0000
  1141. +++ src/live_effects/parameter/bool.cpp 2016-07-24 23:27:14 +0000
  1142. @@ -36,6 +36,12 @@
  1143. param_setValue(defvalue);
  1144. }
  1145. +void
  1146. +BoolParam::param_update_default(bool const default_value)
  1147. +{
  1148. + defvalue = default_value;
  1149. +}
  1150. +
  1151. bool
  1152. BoolParam::param_readSVGValue(const gchar * strvalue)
  1153. {
  1154. === modified file 'src/live_effects/parameter/bool.h'
  1155. --- src/live_effects/parameter/bool.h 2015-10-18 19:13:13 +0000
  1156. +++ src/live_effects/parameter/bool.h 2016-07-24 23:26:29 +0000
  1157. @@ -36,7 +36,7 @@
  1158. void param_setValue(bool newvalue);
  1159. virtual void param_set_default();
  1160. -
  1161. + void param_update_default(bool const default_value);
  1162. bool get_value() const { return value; };
  1163. inline operator bool() const { return value; };
  1164. === modified file 'src/live_effects/parameter/enum.h'
  1165. --- src/live_effects/parameter/enum.h 2014-03-27 01:33:44 +0000
  1166. +++ src/live_effects/parameter/enum.h 2016-07-29 18:13:50 +0000
  1167. @@ -27,12 +27,14 @@
  1168. const Util::EnumDataConverter<E>& c,
  1169. Inkscape::UI::Widget::Registry* wr,
  1170. Effect* effect,
  1171. - E default_value)
  1172. + E default_value,
  1173. + bool sort = true)
  1174. : Parameter(label, tip, key, wr, effect)
  1175. {
  1176. enumdataconv = &c;
  1177. defvalue = default_value;
  1178. value = defvalue;
  1179. + sorted = sort;
  1180. };
  1181. virtual ~EnumParam() { };
  1182. @@ -40,12 +42,11 @@
  1183. virtual Gtk::Widget * param_newWidget() {
  1184. Inkscape::UI::Widget::RegisteredEnum<E> *regenum = Gtk::manage (
  1185. new Inkscape::UI::Widget::RegisteredEnum<E>( param_label, param_tooltip,
  1186. - param_key, *enumdataconv, *param_wr, param_effect->getRepr(), param_effect->getSPDoc() ) );
  1187. + param_key, *enumdataconv, *param_wr, param_effect->getRepr(), param_effect->getSPDoc(), sorted ) );
  1188. regenum->set_active_by_id(value);
  1189. regenum->combobox()->setProgrammatically = false;
  1190. regenum->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change enumeration parameter"));
  1191. -
  1192. return dynamic_cast<Gtk::Widget *> (regenum);
  1193. };
  1194. @@ -86,6 +87,7 @@
  1195. E value;
  1196. E defvalue;
  1197. + bool sorted;
  1198. const Util::EnumDataConverter<E> * enumdataconv;
  1199. };
  1200. === added file 'src/live_effects/parameter/fontbutton.cpp'
  1201. --- src/live_effects/parameter/fontbutton.cpp 1970-01-01 00:00:00 +0000
  1202. +++ src/live_effects/parameter/fontbutton.cpp 2016-07-29 21:26:48 +0000
  1203. @@ -0,0 +1,92 @@
  1204. +/*
  1205. + * Authors:
  1206. + *
  1207. + * Released under GNU GPL, read the file 'COPYING' for more information
  1208. + */
  1209. +
  1210. +
  1211. +#include "ui/widget/registered-widget.h"
  1212. +#include "live_effects/parameter/fontbutton.h"
  1213. +#include "live_effects/effect.h"
  1214. +#include "ui/widget/font-button.h"
  1215. +#include "svg/svg.h"
  1216. +#include "svg/stringstream.h"
  1217. +#include "verbs.h"
  1218. +
  1219. +#include <glibmm/i18n.h>
  1220. +
  1221. +namespace Inkscape {
  1222. +
  1223. +namespace LivePathEffect {
  1224. +
  1225. +FontButtonParam::FontButtonParam( const Glib::ustring& label, const Glib::ustring& tip,
  1226. + const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr,
  1227. + Effect* effect, const Glib::ustring default_value )
  1228. + : Parameter(label, tip, key, wr, effect),
  1229. + value(default_value),
  1230. + defvalue(default_value)
  1231. +{
  1232. +}
  1233. +
  1234. +void
  1235. +FontButtonParam::param_set_default()
  1236. +{
  1237. + param_setValue(defvalue);
  1238. +}
  1239. +void
  1240. +FontButtonParam::param_update_default(const Glib::ustring default_value){
  1241. + defvalue = default_value;
  1242. +}
  1243. +
  1244. +bool
  1245. +FontButtonParam::param_readSVGValue(const gchar * strvalue)
  1246. +{
  1247. + Inkscape::SVGOStringStream os;
  1248. + os << strvalue;
  1249. + param_setValue((Glib::ustring)os.str());
  1250. + return true;
  1251. +}
  1252. +
  1253. +gchar *
  1254. +FontButtonParam::param_getSVGValue() const
  1255. +{
  1256. + return g_strdup(value.c_str());
  1257. +}
  1258. +
  1259. +Gtk::Widget *
  1260. +FontButtonParam::param_newWidget()
  1261. +{
  1262. + Inkscape::UI::Widget::RegisteredFontButton * fontbuttonwdg = Gtk::manage(
  1263. + new Inkscape::UI::Widget::RegisteredFontButton( param_label,
  1264. + param_tooltip,
  1265. + param_key,
  1266. + *param_wr,
  1267. + param_effect->getRepr(),
  1268. + param_effect->getSPDoc() ) );
  1269. + Glib::ustring fontspec = param_getSVGValue();
  1270. + fontbuttonwdg->setValue( fontspec);
  1271. + fontbuttonwdg->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change font button parameter"));
  1272. + param_effect->upd_params = false;
  1273. + return dynamic_cast<Gtk::Widget *> (fontbuttonwdg);
  1274. +}
  1275. +
  1276. +void
  1277. +FontButtonParam::param_setValue(const Glib::ustring newvalue)
  1278. +{
  1279. + value = newvalue;
  1280. +}
  1281. +
  1282. +} /* namespace LivePathEffect */
  1283. +
  1284. +} /* namespace Inkscape */
  1285. +
  1286. +/*
  1287. + Local Variables:
  1288. + mode:c++
  1289. + c-file-style:"stroustrup"
  1290. + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
  1291. + indent-tabs-mode:nil
  1292. + fill-column:99
  1293. + End:
  1294. +*/
  1295. +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
  1296. === added file 'src/live_effects/parameter/fontbutton.h'
  1297. --- src/live_effects/parameter/fontbutton.h 1970-01-01 00:00:00 +0000
  1298. +++ src/live_effects/parameter/fontbutton.h 2016-07-29 20:44:37 +0000
  1299. @@ -0,0 +1,62 @@
  1300. +#ifndef INKSCAPE_LIVEPATHEFFECT_PARAMETER_FONT_H
  1301. +#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_FONT_H
  1302. +
  1303. +/*
  1304. + * Inkscape::LivePathEffectParameters
  1305. + *
  1306. + * Authors:
  1307. + * Released under GNU GPL, read the file 'COPYING' for more information
  1308. + */
  1309. +#include <glib.h>
  1310. +#include <gtkmm.h>
  1311. +#include "live_effects/parameter/parameter.h"
  1312. +
  1313. +namespace Inkscape {
  1314. +
  1315. +namespace LivePathEffect {
  1316. +
  1317. +class FontButtonParam : public Parameter {
  1318. +public:
  1319. + FontButtonParam( const Glib::ustring& label,
  1320. + const Glib::ustring& tip,
  1321. + const Glib::ustring& key,
  1322. + Inkscape::UI::Widget::Registry* wr,
  1323. + Effect* effect,
  1324. + const Glib::ustring default_value = "");
  1325. + virtual ~FontButtonParam() {}
  1326. +
  1327. + virtual Gtk::Widget * param_newWidget();
  1328. + virtual bool param_readSVGValue(const gchar * strvalue);
  1329. + void param_update_default(const Glib::ustring defvalue);
  1330. + virtual gchar * param_getSVGValue() const;
  1331. +
  1332. + void param_setValue(const Glib::ustring newvalue);
  1333. +
  1334. + virtual void param_set_default();
  1335. +
  1336. + const Glib::ustring get_value() const { return defvalue; };
  1337. +
  1338. +private:
  1339. + FontButtonParam(const FontButtonParam&);
  1340. + FontButtonParam& operator=(const FontButtonParam&);
  1341. + Glib::ustring value;
  1342. + Glib::ustring defvalue;
  1343. +
  1344. +};
  1345. +
  1346. +} //namespace LivePathEffect
  1347. +
  1348. +} //namespace Inkscape
  1349. +
  1350. +#endif
  1351. +
  1352. +/*
  1353. + Local Variables:
  1354. + mode:c++
  1355. + c-file-style:"stroustrup"
  1356. + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
  1357. + indent-tabs-mode:nil
  1358. + fill-column:99
  1359. + End:
  1360. +*/
  1361. +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
  1362. === modified file 'src/live_effects/parameter/parameter.cpp'
  1363. --- src/live_effects/parameter/parameter.cpp 2015-10-18 19:13:13 +0000
  1364. +++ src/live_effects/parameter/parameter.cpp 2016-07-30 16:08:21 +0000
  1365. @@ -4,11 +4,9 @@
  1366. * Released under GNU GPL, read the file 'COPYING' for more information
  1367. */
  1368. -#include "ui/widget/registered-widget.h"
  1369. -#include <glibmm/i18n.h>
  1370. +#include "live_effects/effect.h"
  1371. #include "live_effects/parameter/parameter.h"
  1372. -#include "live_effects/effect.h"
  1373. #include "svg/svg.h"
  1374. #include "xml/repr.h"
  1375. @@ -16,6 +14,8 @@
  1376. #include "verbs.h"
  1377. +#include <glibmm/i18n.h>
  1378. +
  1379. #define noLPEREALPARAM_DEBUG
  1380. namespace Inkscape {
  1381. @@ -101,9 +101,16 @@
  1382. param_set_value(defvalue);
  1383. }
  1384. +void
  1385. +ScalarParam::param_update_default(gdouble default_value)
  1386. +{
  1387. + defvalue = default_value;
  1388. +}
  1389. +
  1390. void
  1391. ScalarParam::param_set_value(gdouble val)
  1392. {
  1393. + param_effect->upd_params = true;
  1394. value = val;
  1395. if (integer)
  1396. value = round(value);
  1397. @@ -121,7 +128,7 @@
  1398. // Once again, in gtk2, this is not a problem. But in gtk3,
  1399. // widgets get allocated the amount of size they ask for,
  1400. // leading to excessively long widgets.
  1401. -
  1402. + param_effect->upd_params = true;
  1403. if (min >= -SCALARPARAM_G_MAXDOUBLE) {
  1404. this->min = min;
  1405. } else {
  1406. @@ -130,15 +137,15 @@
  1407. if (max <= SCALARPARAM_G_MAXDOUBLE) {
  1408. this->max = max;
  1409. } else {
  1410. - this->max = SCALARPARAM_G_MAXDOUBLE;
  1411. + this->max = SCALARPARAM_G_MAXDOUBLE;
  1412. }
  1413. -
  1414. param_set_value(value); // reset value to see whether it is in ranges
  1415. }
  1416. void
  1417. ScalarParam::param_make_integer(bool yes)
  1418. {
  1419. + param_effect->upd_params = true;
  1420. integer = yes;
  1421. digits = 0;
  1422. inc_step = 1;
  1423. @@ -169,6 +176,7 @@
  1424. if(!overwrite_widget){
  1425. rsu->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change scalar parameter"));
  1426. }
  1427. + param_effect->upd_params = false;
  1428. return dynamic_cast<Gtk::Widget *> (rsu);
  1429. } else {
  1430. return NULL;
  1431. @@ -178,12 +186,14 @@
  1432. void
  1433. ScalarParam::param_set_digits(unsigned digits)
  1434. {
  1435. + param_effect->upd_params = true;
  1436. this->digits = digits;
  1437. }
  1438. void
  1439. ScalarParam::param_set_increments(double step, double page)
  1440. {
  1441. + param_effect->upd_params = true;
  1442. inc_step = step;
  1443. inc_page = page;
  1444. }
  1445. === modified file 'src/live_effects/parameter/parameter.h'
  1446. --- src/live_effects/parameter/parameter.h 2015-10-18 19:13:13 +0000
  1447. +++ src/live_effects/parameter/parameter.h 2016-07-30 16:05:28 +0000
  1448. @@ -12,6 +12,7 @@
  1449. #include <glibmm/ustring.h>
  1450. #include <2geom/forward.h>
  1451. #include <2geom/pathvector.h>
  1452. +#include "ui/widget/registered-widget.h"
  1453. // In gtk2, this wasn't an issue; we could toss around
  1454. // G_MAXDOUBLE and not worry about size allocations. But
  1455. @@ -110,12 +111,12 @@
  1456. virtual gchar * param_getSVGValue() const;
  1457. virtual void param_set_default();
  1458. + void param_update_default(gdouble default_value);
  1459. void param_set_value(gdouble val);
  1460. void param_make_integer(bool yes = true);
  1461. void param_set_range(gdouble min, gdouble max);
  1462. void param_set_digits(unsigned digits);
  1463. void param_set_increments(double step, double page);
  1464. -
  1465. void addSlider(bool add_slider_widget) { add_slider = add_slider_widget; };
  1466. void param_overwrite_widget(bool overwrite_widget);
  1467. === modified file 'src/live_effects/parameter/point.cpp'
  1468. --- src/live_effects/parameter/point.cpp 2016-01-17 19:18:53 +0000
  1469. +++ src/live_effects/parameter/point.cpp 2016-07-29 09:36:40 +0000
  1470. @@ -4,7 +4,6 @@
  1471. * Released under GNU GPL, read the file 'COPYING' for more information
  1472. */
  1473. -#include "ui/widget/registered-widget.h"
  1474. #include "live_effects/parameter/point.h"
  1475. #include "live_effects/effect.h"
  1476. #include "svg/svg.h"
  1477. @@ -30,7 +29,8 @@
  1478. : Parameter(label, tip, key, wr, effect),
  1479. defvalue(default_value),
  1480. liveupdate(live_update),
  1481. - knoth(NULL)
  1482. + knoth(NULL),
  1483. + _pointwdg(NULL)
  1484. {
  1485. knot_shape = SP_KNOT_SHAPE_DIAMOND;
  1486. knot_mode = SP_KNOT_MODE_XOR;
  1487. @@ -62,9 +62,9 @@
  1488. }
  1489. void
  1490. -PointParam::param_update_default(Geom::Point newpoint)
  1491. +PointParam::param_update_default(const Geom::Point default_point)
  1492. {
  1493. - defvalue = newpoint;
  1494. + defvalue = default_point;
  1495. }
  1496. void
  1497. @@ -81,6 +81,9 @@
  1498. if(knoth && liveupdate){
  1499. knoth->update_knots();
  1500. }
  1501. + if (_pointwdg) {
  1502. + _pointwdg->setValue( newpoint );
  1503. + }
  1504. }
  1505. bool
  1506. @@ -116,7 +119,7 @@
  1507. Gtk::Widget *
  1508. PointParam::param_newWidget()
  1509. {
  1510. - Inkscape::UI::Widget::RegisteredTransformedPoint * pointwdg = Gtk::manage(
  1511. + _pointwdg = Gtk::manage(
  1512. new Inkscape::UI::Widget::RegisteredTransformedPoint( param_label,
  1513. param_tooltip,
  1514. param_key,
  1515. @@ -126,15 +129,15 @@
  1516. // TODO: fix to get correct desktop (don't use SP_ACTIVE_DESKTOP)
  1517. SPDesktop *desktop = SP_ACTIVE_DESKTOP;
  1518. Geom::Affine transf = desktop->doc2dt();
  1519. - pointwdg->setTransform(transf);
  1520. - pointwdg->setValue( *this );
  1521. - pointwdg->clearProgrammatically();
  1522. - pointwdg->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change point parameter"));
  1523. + _pointwdg->setTransform(transf);
  1524. + _pointwdg->setValue( *this );
  1525. + _pointwdg->clearProgrammatically();
  1526. + _pointwdg->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change point parameter"));
  1527. Gtk::HBox * hbox = Gtk::manage( new Gtk::HBox() );
  1528. - static_cast<Gtk::HBox*>(hbox)->pack_start(*pointwdg, true, true);
  1529. + static_cast<Gtk::HBox*>(hbox)->pack_start(*_pointwdg, true, true);
  1530. static_cast<Gtk::HBox*>(hbox)->show_all_children();
  1531. -
  1532. + param_effect->upd_params = false;
  1533. return dynamic_cast<Gtk::Widget *> (hbox);
  1534. }
  1535. @@ -191,13 +194,13 @@
  1536. PointParamKnotHolderEntity::knot_click(guint state)
  1537. {
  1538. if (state & GDK_CONTROL_MASK) {
  1539. - if (state & GDK_MOD1_MASK) {
  1540. - this->pparam->param_set_default();
  1541. - SPLPEItem * splpeitem = dynamic_cast<SPLPEItem *>(item);
  1542. - if(splpeitem){
  1543. - sp_lpe_item_update_patheffect(splpeitem, false, false);
  1544. - }
  1545. + if (state & GDK_MOD1_MASK) {
  1546. + this->pparam->param_set_default();
  1547. + SPLPEItem * splpeitem = dynamic_cast<SPLPEItem *>(item);
  1548. + if(splpeitem){
  1549. + sp_lpe_item_update_patheffect(splpeitem, false, false);
  1550. }
  1551. + }
  1552. }
  1553. }
  1554. === modified file 'src/live_effects/parameter/point.h'
  1555. --- src/live_effects/parameter/point.h 2016-01-17 19:18:53 +0000
  1556. +++ src/live_effects/parameter/point.h 2016-07-29 09:28:12 +0000
  1557. @@ -11,7 +11,7 @@
  1558. #include <glib.h>
  1559. #include <2geom/point.h>
  1560. -
  1561. +#include "ui/widget/registered-widget.h"
  1562. #include "live_effects/parameter/parameter.h"
  1563. #include "knot-holder-entity.h"
  1564. @@ -43,7 +43,7 @@
  1565. void param_set_default();
  1566. Geom::Point param_get_default() const;
  1567. void param_set_liveupdate(bool live_update);
  1568. - void param_update_default(Geom::Point newpoint);
  1569. + void param_update_default(const Geom::Point default_point);
  1570. virtual void param_transform_multiply(Geom::Affine const& /*postmul*/, bool /*set*/);
  1571. void set_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, guint32 color);
  1572. @@ -62,6 +62,7 @@
  1573. SPKnotModeType knot_mode;
  1574. guint32 knot_color;
  1575. gchar *handle_tip;
  1576. + Inkscape::UI::Widget::RegisteredTransformedPoint * _pointwdg;
  1577. };
  1578. === modified file 'src/live_effects/parameter/text.cpp'
  1579. --- src/live_effects/parameter/text.cpp 2014-12-21 21:58:32 +0000
  1580. +++ src/live_effects/parameter/text.cpp 2016-07-31 22:44:32 +0000
  1581. @@ -31,12 +31,16 @@
  1582. Effect* effect, const Glib::ustring default_value )
  1583. : Parameter(label, tip, key, wr, effect),
  1584. value(default_value),
  1585. - defvalue(default_value)
  1586. + defvalue(default_value),
  1587. + _hide_canvas_text(false)
  1588. {
  1589. - SPDesktop *desktop = SP_ACTIVE_DESKTOP; // FIXME: we shouldn't use this!
  1590. - canvas_text = (SPCanvasText *) sp_canvastext_new(desktop->getTempGroup(), desktop, Geom::Point(0,0), "");
  1591. - sp_canvastext_set_text (canvas_text, default_value.c_str());
  1592. - sp_canvastext_set_coords (canvas_text, 0, 0);
  1593. + if (SPDesktop *desktop = SP_ACTIVE_DESKTOP) { // FIXME: we shouldn't use this!
  1594. + canvas_text = (SPCanvasText *) sp_canvastext_new(desktop->getTempGroup(), desktop, Geom::Point(0,0), "");
  1595. + sp_canvastext_set_text (canvas_text, default_value.c_str());
  1596. + sp_canvastext_set_coords (canvas_text, 0, 0);
  1597. + } else {
  1598. + _hide_canvas_text = true;
  1599. + }
  1600. }
  1601. void
  1602. @@ -46,9 +50,26 @@
  1603. }
  1604. void
  1605. +TextParam::param_update_default(Glib::ustring default_value)
  1606. +{
  1607. + defvalue = default_value;
  1608. +}
  1609. +
  1610. +void
  1611. +TextParam::param_hide_canvas_text()
  1612. +{
  1613. + if (!_hide_canvas_text) {
  1614. + sp_canvastext_set_text(canvas_text, " ");
  1615. + _hide_canvas_text = true;
  1616. + }
  1617. +}
  1618. +
  1619. +void
  1620. TextParam::setPos(Geom::Point pos)
  1621. {
  1622. - sp_canvastext_set_coords (canvas_text, pos);
  1623. + if (!_hide_canvas_text) {
  1624. + sp_canvastext_set_coords (canvas_text, pos);
  1625. + }
  1626. }
  1627. void
  1628. @@ -63,9 +84,10 @@
  1629. Point dir = unit_vector(derivative(pwd2_reparam).valueAt(t_reparam));
  1630. Point n = -rot90(dir);
  1631. double angle = Geom::angle_between(dir, Point(1,0));
  1632. -
  1633. - sp_canvastext_set_coords(canvas_text, pos + n * length);
  1634. - sp_canvastext_set_anchor_manually(canvas_text, std::sin(angle), -std::cos(angle));
  1635. + if (!_hide_canvas_text) {
  1636. + sp_canvastext_set_coords(canvas_text, pos + n * length);
  1637. + sp_canvastext_set_anchor_manually(canvas_text, std::sin(angle), -std::cos(angle));
  1638. + }
  1639. }
  1640. void
  1641. @@ -73,7 +95,9 @@
  1642. {
  1643. anchor_x = x_value;
  1644. anchor_y = y_value;
  1645. - sp_canvastext_set_anchor_manually (canvas_text, anchor_x, anchor_y);
  1646. + if (!_hide_canvas_text) {
  1647. + sp_canvastext_set_anchor_manually (canvas_text, anchor_x, anchor_y);
  1648. + }
  1649. }
  1650. bool
  1651. @@ -94,8 +118,7 @@
  1652. {
  1653. Inkscape::UI::Widget::RegisteredText *rsu = Gtk::manage(new Inkscape::UI::Widget::RegisteredText(
  1654. param_label, param_tooltip, param_key, *param_wr, param_effect->getRepr(), param_effect->getSPDoc()));
  1655. -
  1656. - rsu->setText(value.c_str());
  1657. + rsu->setText(value);
  1658. rsu->setProgrammatically = false;
  1659. rsu->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change text parameter"));
  1660. @@ -107,8 +130,9 @@
  1661. TextParam::param_setValue(const Glib::ustring newvalue)
  1662. {
  1663. value = newvalue;
  1664. -
  1665. - sp_canvastext_set_text (canvas_text, newvalue.c_str());
  1666. + if (!_hide_canvas_text) {
  1667. + sp_canvastext_set_text (canvas_text, newvalue.c_str());
  1668. + }
  1669. }
  1670. } /* namespace LivePathEffect */
  1671. === modified file 'src/live_effects/parameter/text.h'
  1672. --- src/live_effects/parameter/text.h 2014-03-27 01:33:44 +0000
  1673. +++ src/live_effects/parameter/text.h 2016-07-31 02:24:55 +0000
  1674. @@ -40,7 +40,9 @@
  1675. virtual gchar * param_getSVGValue() const;
  1676. void param_setValue(const Glib::ustring newvalue);
  1677. + void param_hide_canvas_text();
  1678. virtual void param_set_default();
  1679. + void param_update_default(Glib::ustring default_value);
  1680. void setPos(Geom::Point pos);
  1681. void setPosAndAnchor(const Geom::Piecewise<Geom::D2<Geom::SBasis> > &pwd2,
  1682. const double t, const double length, bool use_curvature = false);
  1683. @@ -53,7 +55,7 @@
  1684. TextParam& operator=(const TextParam&);
  1685. double anchor_x;
  1686. double anchor_y;
  1687. -
  1688. + bool _hide_canvas_text;
  1689. Glib::ustring value;
  1690. Glib::ustring defvalue;
  1691. === modified file 'src/live_effects/parameter/togglebutton.cpp'
  1692. --- src/live_effects/parameter/togglebutton.cpp 2016-07-24 15:05:29 +0000
  1693. +++ src/live_effects/parameter/togglebutton.cpp 2016-07-24 16:53:55 +0000
  1694. @@ -12,6 +12,7 @@
  1695. #include "live_effects/effect.h"
  1696. #include "svg/svg.h"
  1697. #include "svg/stringstream.h"
  1698. +#include "selection.h"
  1699. #include "widgets/icon.h"
  1700. #include "inkscape.h"
  1701. #include "verbs.h"
  1702. @@ -108,13 +109,14 @@
  1703. }else{
  1704. gtk_box_pack_start (GTK_BOX(box_button), label_button, false, false, 1);
  1705. }
  1706. +
  1707. checkwdg->add(*Gtk::manage(Glib::wrap(box_button)));
  1708. checkwdg->setActive(value);
  1709. checkwdg->setProgrammatically = false;
  1710. checkwdg->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change togglebutton parameter"));
  1711. _toggled_connection = checkwdg->signal_toggled().connect(sigc::mem_fun(*this, &ToggleButtonParam::toggled));
  1712. -
  1713. + param_effect->upd_params = false;
  1714. return checkwdg;
  1715. }
  1716. @@ -161,6 +163,12 @@
  1717. void
  1718. ToggleButtonParam::toggled() {
  1719. + //Force redraw for update widgets
  1720. + param_effect->upd_params = true;
  1721. + if (SP_ACTIVE_DESKTOP) {
  1722. + Inkscape::Selection *selection = SP_ACTIVE_DESKTOP->getSelection();
  1723. + selection ->emitModified();
  1724. + }
  1725. _signal_toggled.emit();
  1726. }
  1727. === modified file 'src/live_effects/parameter/unit.cpp'
  1728. --- src/live_effects/parameter/unit.cpp 2014-03-27 01:33:44 +0000
  1729. +++ src/live_effects/parameter/unit.cpp 2016-07-24 23:34:35 +0000
  1730. @@ -54,6 +54,12 @@
  1731. param_set_value(*defunit);
  1732. }
  1733. +void
  1734. +UnitParam::param_update_default(const Glib::ustring default_unit)
  1735. +{
  1736. + defunit = unit_table.getUnit(default_unit);
  1737. +}
  1738. +
  1739. void
  1740. UnitParam::param_set_value(Inkscape::Util::Unit const &val)
  1741. {
  1742. === modified file 'src/live_effects/parameter/unit.h'
  1743. --- src/live_effects/parameter/unit.h 2014-03-27 01:33:44 +0000
  1744. +++ src/live_effects/parameter/unit.h 2016-07-24 23:34:56 +0000
  1745. @@ -33,6 +33,7 @@
  1746. virtual gchar * param_getSVGValue() const;
  1747. virtual void param_set_default();
  1748. void param_set_value(Inkscape::Util::Unit const &val);
  1749. + void param_update_default(const Glib::ustring default_unit);
  1750. const gchar *get_abbreviation() const;
  1751. virtual Gtk::Widget * param_newWidget();
  1752. === modified file 'src/selection.cpp'
  1753. --- src/selection.cpp 2016-07-28 11:26:17 +0000
  1754. +++ src/selection.cpp 2016-07-24 16:00:12 +0000
  1755. @@ -282,6 +282,11 @@
  1756. _emitChanged();
  1757. }
  1758. +void Selection::emitModified()
  1759. +{
  1760. + _emitChanged();
  1761. +}
  1762. +
  1763. std::vector<SPObject*> const &Selection::list() {
  1764. if(!_objs_vector.empty())
  1765. return _objs_vector;
  1766. === modified file 'src/selection.h'
  1767. --- src/selection.h 2016-07-28 11:26:17 +0000
  1768. +++ src/selection.h 2016-07-24 16:00:12 +0000
  1769. @@ -192,6 +192,11 @@
  1770. void clear();
  1771. /**
  1772. + * Emmit modified signal
  1773. + */
  1774. + void emitModified();
  1775. +
  1776. + /**
  1777. * Returns true if no items are selected.
  1778. */
  1779. bool isEmpty() const { return _objs.empty(); }
  1780. === modified file 'src/ui/CMakeLists.txt'
  1781. --- src/ui/CMakeLists.txt 2016-02-07 15:49:01 +0000
  1782. +++ src/ui/CMakeLists.txt 2016-07-29 21:24:51 +0000
  1783. @@ -128,6 +128,7 @@
  1784. widget/entity-entry.cpp
  1785. widget/entry.cpp
  1786. widget/filter-effect-chooser.cpp
  1787. + widget/font-button.cpp
  1788. widget/font-variants.cpp
  1789. widget/frame.cpp
  1790. widget/gimpcolorwheel.c
  1791. @@ -312,6 +313,7 @@
  1792. widget/entity-entry.h
  1793. widget/entry.h
  1794. widget/filter-effect-chooser.h
  1795. + widget/font-button.h
  1796. widget/font-variants.h
  1797. widget/frame.h
  1798. widget/gimpspinscale.h
  1799. === modified file 'src/ui/dialog/livepatheffect-editor.cpp'
  1800. --- src/ui/dialog/livepatheffect-editor.cpp 2016-07-28 11:26:17 +0000
  1801. +++ src/ui/dialog/livepatheffect-editor.cpp 2016-07-30 17:02:04 +0000
  1802. @@ -61,7 +61,7 @@
  1803. {
  1804. LivePathEffectEditor *lpeeditor = static_cast<LivePathEffectEditor *>(data);
  1805. lpeeditor->lpe_list_locked = false;
  1806. - lpeeditor->onSelectionChanged(selection);
  1807. + lpeeditor->onSelectionChanged(selection, true);
  1808. }
  1809. static void lpeeditor_selection_modified (Inkscape::Selection * selection, guint /*flags*/, gpointer data)
  1810. @@ -98,7 +98,8 @@
  1811. button_up(),
  1812. button_down(),
  1813. current_desktop(NULL),
  1814. - current_lpeitem(NULL)
  1815. + current_lpeitem(NULL),
  1816. + current_lperef(NULL)
  1817. {
  1818. Gtk::Box *contents = _getContents();
  1819. contents->set_spacing(4);
  1820. @@ -206,6 +207,10 @@
  1821. void
  1822. LivePathEffectEditor::showParams(LivePathEffect::Effect& effect)
  1823. {
  1824. + if ( ! effect.upd_params ) {
  1825. + return;
  1826. + }
  1827. +
  1828. if (effectwidget) {
  1829. effectcontrol_vbox.remove(*effectwidget);
  1830. delete effectwidget;
  1831. @@ -265,9 +270,8 @@
  1832. button_down.set_sensitive(sensitive);
  1833. }
  1834. -
  1835. void
  1836. -LivePathEffectEditor::onSelectionChanged(Inkscape::Selection *sel)
  1837. +LivePathEffectEditor::onSelectionChanged(Inkscape::Selection *sel, bool upd_params)
  1838. {
  1839. if (lpe_list_locked) {
  1840. // this was triggered by selecting a row in the list, so skip reloading
  1841. @@ -291,6 +295,9 @@
  1842. if ( lpeitem->hasPathEffect() ) {
  1843. Inkscape::LivePathEffect::Effect *lpe = lpeitem->getCurrentLPE();
  1844. if (lpe) {
  1845. + if (upd_params) {
  1846. + lpe->upd_params = true;
  1847. + }
  1848. showParams(*lpe);
  1849. lpe_list_locked = true;
  1850. selectInList(lpe);
  1851. @@ -494,6 +501,12 @@
  1852. SPItem *item = sel->singleItem();
  1853. SPLPEItem *lpeitem = dynamic_cast<SPLPEItem *>(item);
  1854. if ( lpeitem ) {
  1855. + if (current_lperef && current_lperef->lpeobject) {
  1856. + LivePathEffect::Effect * effect = current_lperef->lpeobject->get_lpe();
  1857. + if (effect) {
  1858. + effect->upd_params = true;
  1859. + }
  1860. + }
  1861. lpeitem->removeCurrentPathEffect(false);
  1862. DocumentUndo::done( current_desktop->getDocument(), SP_VERB_DIALOG_LIVE_PATH_EFFECT,
  1863. @@ -548,11 +561,17 @@
  1864. Gtk::TreeModel::iterator it = sel->get_selected();
  1865. LivePathEffect::LPEObjectReference * lperef = (*it)[columns.lperef];
  1866. - if (lperef && current_lpeitem) {
  1867. + if (lperef && current_lpeitem && current_lperef != lperef) {
  1868. + //The last condition ignore Gtk::TreeModel may occasionally be changed emitted when nothing has happened
  1869. if (lperef->lpeobject->get_lpe()) {
  1870. lpe_list_locked = true; // prevent reload of the list which would lose selection
  1871. current_lpeitem->setCurrentPathEffect(lperef);
  1872. - showParams(*lperef->lpeobject->get_lpe());
  1873. + current_lperef = lperef;
  1874. + LivePathEffect::Effect * effect = lperef->lpeobject->get_lpe();
  1875. + if (effect) {
  1876. + effect->upd_params = true;
  1877. + showParams(*effect);
  1878. + }
  1879. }
  1880. }
  1881. }
  1882. @@ -570,6 +589,14 @@
  1883. /* FIXME: this explicit writing to SVG is wrong. The lpe_item should have a method to disable/enable an effect within its stack.
  1884. * So one can call: lpe_item->setActive(lpeobjref->lpeobject); */
  1885. lpeobjref->lpeobject->get_lpe()->getRepr()->setAttribute("is_visible", newValue ? "true" : "false");
  1886. + Inkscape::Selection *sel = _getSelection();
  1887. + if ( sel && !sel->isEmpty() ) {
  1888. + SPItem *item = sel->singleItem();
  1889. + SPLPEItem *lpeitem = dynamic_cast<SPLPEItem *>(item);
  1890. + if ( lpeitem ) {
  1891. + lpeobjref->lpeobject->get_lpe()->doOnVisibilityToggled(lpeitem);
  1892. + }
  1893. + }
  1894. DocumentUndo::done( current_desktop->getDocument(), SP_VERB_DIALOG_LIVE_PATH_EFFECT,
  1895. newValue ? _("Activate path effect") : _("Deactivate path effect"));
  1896. }
  1897. === modified file 'src/ui/dialog/livepatheffect-editor.h'
  1898. --- src/ui/dialog/livepatheffect-editor.h 2014-03-27 01:33:44 +0000
  1899. +++ src/ui/dialog/livepatheffect-editor.h 2016-07-24 16:00:12 +0000
  1900. @@ -45,7 +45,8 @@
  1901. static LivePathEffectEditor &getInstance() { return *new LivePathEffectEditor(); }
  1902. - void onSelectionChanged(Inkscape::Selection *sel);
  1903. + void onSelectionChanged(Inkscape::Selection *sel, bool upd_params = false);
  1904. + void onSelectionModified(Inkscape::Selection *sel);
  1905. virtual void on_effect_selection_changed();
  1906. void setDesktop(SPDesktop *desktop);
  1907. @@ -126,6 +127,8 @@
  1908. SPLPEItem * current_lpeitem;
  1909. + LivePathEffect::LPEObjectReference * current_lperef;
  1910. +
  1911. friend void lpeeditor_selection_changed (Inkscape::Selection * selection, gpointer data);
  1912. LivePathEffectEditor(LivePathEffectEditor const &d);
  1913. === modified file 'src/ui/widget/Makefile_insert'
  1914. --- src/ui/widget/Makefile_insert 2015-05-17 09:20:36 +0000
  1915. +++ src/ui/widget/Makefile_insert 2016-07-29 21:25:30 +0000
  1916. @@ -33,6 +33,8 @@
  1917. ui/widget/entry.h \
  1918. ui/widget/filter-effect-chooser.h \
  1919. ui/widget/filter-effect-chooser.cpp \
  1920. + ui/widget/font-button.h \
  1921. + ui/widget/font-button.cpp \
  1922. ui/widget/font-variants.h \
  1923. ui/widget/font-variants.cpp \
  1924. ui/widget/gimpspinscale.c \
  1925. === modified file 'src/ui/widget/combo-enums.h'
  1926. --- src/ui/widget/combo-enums.h 2012-02-15 11:19:00 +0000
  1927. +++ src/ui/widget/combo-enums.h 2016-07-29 18:13:37 +0000
  1928. @@ -16,7 +16,6 @@
  1929. #include <gtkmm/liststore.h>
  1930. #include "attr-widget.h"
  1931. #include "util/enums.h"
  1932. -
  1933. #include <glibmm/i18n.h>
  1934. namespace Inkscape {
  1935. @@ -190,9 +189,11 @@
  1936. const Util::EnumDataConverter<E>& c,
  1937. Glib::ustring const &suffix = "",
  1938. Glib::ustring const &icon = "",
  1939. - bool mnemonic = true)
  1940. - : Labelled(label, tooltip, new ComboBoxEnum<E>(c), suffix, icon, mnemonic)
  1941. - { }
  1942. + bool mnemonic = true,
  1943. + bool sorted = true)
  1944. + : Labelled(label, tooltip, new ComboBoxEnum<E>(c, SP_ATTR_INVALID, sorted), suffix, icon, mnemonic)
  1945. + {
  1946. + }
  1947. ComboBoxEnum<E>* getCombobox() {
  1948. return static_cast< ComboBoxEnum<E>* > (_widget);
  1949. === added file 'src/ui/widget/font-button.cpp'
  1950. --- src/ui/widget/font-button.cpp 1970-01-01 00:00:00 +0000
  1951. +++ src/ui/widget/font-button.cpp 2016-07-30 00:01:38 +0000
  1952. @@ -0,0 +1,58 @@
  1953. +/*
  1954. + *
  1955. + * Released under GNU GPL. Read the file 'COPYING' for more information.
  1956. + */
  1957. +
  1958. +#ifdef HAVE_CONFIG_H
  1959. +# include <config.h>
  1960. +#endif
  1961. +
  1962. +#include "font-button.h"
  1963. +#include <glibmm/i18n.h>
  1964. +
  1965. +namespace Inkscape {
  1966. +namespace UI {
  1967. +namespace Widget {
  1968. +
  1969. +FontButton::FontButton(Glib::ustring const &label, Glib::ustring const &tooltip,
  1970. + Glib::ustring const &suffix,
  1971. + Glib::ustring const &icon,
  1972. + bool mnemonic)
  1973. + : Labelled(label, tooltip, new Gtk::FontButton("Sans 10"), suffix, icon, mnemonic)
  1974. +{
  1975. +}
  1976. +
  1977. +Glib::ustring FontButton::getValue() const
  1978. +{
  1979. + g_assert(_widget != NULL);
  1980. + return static_cast<Gtk::FontButton*>(_widget)->get_font_name();
  1981. +}
  1982. +
  1983. +
  1984. +void FontButton::setValue (Glib::ustring fontspec)
  1985. +{
  1986. + g_assert(_widget != NULL);
  1987. + static_cast<Gtk::FontButton*>(_widget)->set_font_name(fontspec);
  1988. +}
  1989. +
  1990. +Glib::SignalProxy0<void> FontButton::signal_font_value_changed()
  1991. +{
  1992. + g_assert(_widget != NULL);
  1993. + return static_cast<Gtk::FontButton*>(_widget)->signal_font_set();
  1994. +}
  1995. +
  1996. +
  1997. +} // namespace Widget
  1998. +} // namespace UI
  1999. +} // namespace Inkscape
  2000. +
  2001. +/*
  2002. + Local Variables:
  2003. + mode:c++
  2004. + c-file-style:"stroustrup"
  2005. + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
  2006. + indent-tabs-mode:nil
  2007. + fill-column:99
  2008. + End:
  2009. +*/
  2010. +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
  2011. === added file 'src/ui/widget/font-button.h'
  2012. --- src/ui/widget/font-button.h 1970-01-01 00:00:00 +0000
  2013. +++ src/ui/widget/font-button.h 2016-07-29 22:58:22 +0000
  2014. @@ -0,0 +1,63 @@
  2015. +/*
  2016. + *
  2017. + * Copyright (C) 2007 Author
  2018. + *
  2019. + * Released under GNU GPL. Read the file 'COPYING' for more information.
  2020. + */
  2021. +
  2022. +#ifndef INKSCAPE_UI_WIDGET_FONT_BUTTON_H
  2023. +#define INKSCAPE_UI_WIDGET_FONT_BUTTON_H
  2024. +
  2025. +#include <gtkmm.h>
  2026. +#include "labelled.h"
  2027. +
  2028. +namespace Inkscape {
  2029. +namespace UI {
  2030. +namespace Widget {
  2031. +
  2032. +/**
  2033. + * A labelled font button for entering font values
  2034. + */
  2035. +class FontButton : public Labelled
  2036. +{
  2037. +public:
  2038. + /**
  2039. + * Construct a FontButton Widget.
  2040. + *
  2041. + * @param label Label.
  2042. + * @param suffix Suffix, placed after the widget (defaults to "").
  2043. + * @param icon Icon filename, placed before the label (defaults to "").
  2044. + * @param mnemonic Mnemonic toggle; if true, an underscore (_) in the label
  2045. + * indicates the next character should be used for the
  2046. + * mnemonic accelerator key (defaults to false).
  2047. + */
  2048. + FontButton( Glib::ustring const &label,
  2049. + Glib::ustring const &tooltip,
  2050. + Glib::ustring const &suffix = "",
  2051. + Glib::ustring const &icon = "",
  2052. + bool mnemonic = true);
  2053. +
  2054. + Glib::ustring getValue() const;
  2055. + void setValue (Glib::ustring fontspec);
  2056. + /**
  2057. + * Signal raised when the font button's value changes.
  2058. + */
  2059. + Glib::SignalProxy0<void> signal_font_value_changed();
  2060. +};
  2061. +
  2062. +} // namespace Widget
  2063. +} // namespace UI
  2064. +} // namespace Inkscape
  2065. +
  2066. +#endif // INKSCAPE_UI_WIDGET_RANDOM_H
  2067. +
  2068. +/*
  2069. + Local Variables:
  2070. + mode:c++
  2071. + c-file-style:"stroustrup"
  2072. + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
  2073. + indent-tabs-mode:nil
  2074. + fill-column:99
  2075. + End:
  2076. +*/
  2077. +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
  2078. === modified file 'src/ui/widget/registered-enums.h'
  2079. --- src/ui/widget/registered-enums.h 2011-10-25 07:45:35 +0000
  2080. +++ src/ui/widget/registered-enums.h 2016-07-29 18:13:43 +0000
  2081. @@ -33,11 +33,11 @@
  2082. const Util::EnumDataConverter<E>& c,
  2083. Registry& wr,
  2084. Inkscape::XML::Node* repr_in = NULL,
  2085. - SPDocument *doc_in = NULL )
  2086. - : RegisteredWidget< LabelledComboBoxEnum<E> >(label, tip, c)
  2087. + SPDocument *doc_in = NULL,
  2088. + bool sorted = true )
  2089. + : RegisteredWidget< LabelledComboBoxEnum<E> >(label, tip, c, (const Glib::ustring &)"", (const Glib::ustring &)"", true, sorted)
  2090. {
  2091. RegisteredWidget< LabelledComboBoxEnum<E> >::init_parent(key, wr, repr_in, doc_in);
  2092. -
  2093. _changed_connection = combobox()->signal_changed().connect (sigc::mem_fun (*this, &RegisteredEnum::on_changed));
  2094. }
  2095. === modified file 'src/ui/widget/registered-widget.cpp'
  2096. --- src/ui/widget/registered-widget.cpp 2016-07-28 11:26:17 +0000
  2097. +++ src/ui/widget/registered-widget.cpp 2016-08-01 15:29:19 +0000
  2098. @@ -25,6 +25,7 @@
  2099. #include "ui/widget/scalar-unit.h"
  2100. #include "ui/widget/point.h"
  2101. #include "ui/widget/random.h"
  2102. +#include "ui/widget/font-button.h"
  2103. #include "widgets/spinbutton-events.h"
  2104. #include "xml/repr.h"
  2105. @@ -297,7 +298,6 @@
  2106. setProgrammatically = false;
  2107. return;
  2108. }
  2109. -
  2110. if (_wr->isUpdating()) {
  2111. return;
  2112. }
  2113. @@ -331,8 +331,6 @@
  2114. init_parent(key, wr, repr_in, doc_in);
  2115. setProgrammatically = false;
  2116. -
  2117. - setText("");
  2118. _activate_connection = signal_activate().connect (sigc::mem_fun (*this, &RegisteredText::on_activate));
  2119. }
  2120. @@ -348,16 +346,12 @@
  2121. return;
  2122. }
  2123. _wr->setUpdating (true);
  2124. -
  2125. + Glib::ustring str(getText());
  2126. + set_sensitive(false);
  2127. Inkscape::SVGOStringStream os;
  2128. - os << getText();
  2129. -
  2130. - set_sensitive(false);
  2131. + os << str;
  2132. write_to_xml(os.str().c_str());
  2133. set_sensitive(true);
  2134. -
  2135. - setText(os.str().c_str());
  2136. -
  2137. _wr->setUpdating (false);
  2138. }
  2139. @@ -803,6 +797,47 @@
  2140. _wr->setUpdating (false);
  2141. }
  2142. +/*#########################################
  2143. + * Registered FONT-BUTTON
  2144. + */
  2145. +
  2146. +RegisteredFontButton::~RegisteredFontButton()
  2147. +{
  2148. + _signal_font_set.disconnect();
  2149. +}
  2150. +
  2151. +RegisteredFontButton::RegisteredFontButton ( const Glib::ustring& label, const Glib::ustring& tip,
  2152. + const Glib::ustring& key, Registry& wr, Inkscape::XML::Node* repr_in,
  2153. + SPDocument* doc_in )
  2154. + : RegisteredWidget<FontButton>(label, tip)
  2155. +{
  2156. + init_parent(key, wr, repr_in, doc_in);
  2157. + _signal_font_set = signal_font_value_changed().connect (sigc::mem_fun (*this, &RegisteredFontButton::on_value_changed));
  2158. +}
  2159. +
  2160. +void
  2161. +RegisteredFontButton::setValue (Glib::ustring fontspec)
  2162. +{
  2163. + FontButton::setValue(fontspec);
  2164. +}
  2165. +
  2166. +void
  2167. +RegisteredFontButton::on_value_changed()
  2168. +{
  2169. +
  2170. + if (_wr->isUpdating())
  2171. + return;
  2172. +
  2173. + _wr->setUpdating (true);
  2174. +
  2175. + Inkscape::SVGOStringStream os;
  2176. + os << getValue();
  2177. +
  2178. + write_to_xml(os.str().c_str());
  2179. +
  2180. + _wr->setUpdating (false);
  2181. +}
  2182. +
  2183. } // namespace Dialog
  2184. } // namespace UI
  2185. } // namespace Inkscape
  2186. === modified file 'src/ui/widget/registered-widget.h'
  2187. --- src/ui/widget/registered-widget.h 2016-07-24 15:05:29 +0000
  2188. +++ src/ui/widget/registered-widget.h 2016-07-29 22:45:14 +0000
  2189. @@ -22,6 +22,7 @@
  2190. #include "ui/widget/text.h"
  2191. #include "ui/widget/random.h"
  2192. #include "ui/widget/unit-menu.h"
  2193. +#include "ui/widget/font-button.h"
  2194. #include "ui/widget/color-picker.h"
  2195. #include "inkscape.h"
  2196. @@ -77,6 +78,8 @@
  2197. RegisteredWidget( A& a, B& b, C c, D d ): W( a, b, c, d ) { construct(); }
  2198. template< typename A, typename B, typename C, typename D, typename E , typename F>
  2199. RegisteredWidget( A& a, B& b, C c, D& d, E& e, F* f): W( a, b, c, d, e, f) { construct(); }
  2200. + template< typename A, typename B, typename C, typename D, typename E , typename F, typename G>
  2201. + RegisteredWidget( A& a, B& b, C& c, D& d, E& e, F f, G& g): W( a, b, c, d, e, f, g) { construct(); }
  2202. virtual ~RegisteredWidget() {};
  2203. @@ -418,6 +421,23 @@
  2204. void on_value_changed();
  2205. };
  2206. +class RegisteredFontButton : public RegisteredWidget<FontButton> {
  2207. +public:
  2208. + virtual ~RegisteredFontButton();
  2209. + RegisteredFontButton ( const Glib::ustring& label,
  2210. + const Glib::ustring& tip,
  2211. + const Glib::ustring& key,
  2212. + Registry& wr,
  2213. + Inkscape::XML::Node* repr_in = NULL,
  2214. + SPDocument *doc_in = NULL);
  2215. +
  2216. + void setValue (Glib::ustring fontspec);
  2217. +
  2218. +protected:
  2219. + sigc::connection _signal_font_set;
  2220. + void on_value_changed();
  2221. +};
  2222. +
  2223. } // namespace Widget
  2224. } // namespace UI
  2225. } // namespace Inkscape
  2226. === modified file 'src/ui/widget/scalar.cpp'
  2227. --- src/ui/widget/scalar.cpp 2014-03-27 01:33:44 +0000
  2228. +++ src/ui/widget/scalar.cpp 2016-07-30 15:23:12 +0000
  2229. @@ -126,10 +126,12 @@
  2230. static_cast<SpinButton*>(_widget)->set_range(min, max);
  2231. }
  2232. -void Scalar::setValue(double value)
  2233. +void Scalar::setValue(double value, bool setProg)
  2234. {
  2235. g_assert(_widget != NULL);
  2236. - setProgrammatically = true; // callback is supposed to reset back, if it cares
  2237. + if (setProg) {
  2238. + setProgrammatically = true; // callback is supposed to reset back, if it cares
  2239. + }
  2240. static_cast<SpinButton*>(_widget)->set_value(value);
  2241. }
  2242. === modified file 'src/ui/widget/scalar.h'
  2243. --- src/ui/widget/scalar.h 2012-04-30 22:04:12 +0000
  2244. +++ src/ui/widget/scalar.h 2016-07-30 15:23:27 +0000
  2245. @@ -139,7 +139,7 @@
  2246. /**
  2247. * Sets the value of the spin button.
  2248. */
  2249. - void setValue(double value);
  2250. + void setValue(double value, bool setProg = true);
  2251. /**
  2252. * Manually forces an update of the spin button.
  2253. === modified file 'src/ui/widget/text.cpp'
  2254. --- src/ui/widget/text.cpp 2012-02-26 16:54:08 +0000
  2255. +++ src/ui/widget/text.cpp 2016-07-31 21:49:31 +0000
  2256. @@ -28,13 +28,13 @@
  2257. {
  2258. }
  2259. -const char *Text::getText() const
  2260. +Glib::ustring const Text::getText() const
  2261. {
  2262. g_assert(_widget != NULL);
  2263. - return static_cast<Gtk::Entry*>(_widget)->get_text().c_str();
  2264. + return static_cast<Gtk::Entry*>(_widget)->get_text();
  2265. }
  2266. -void Text::setText(const char* text)
  2267. +void Text::setText(Glib::ustring const text)
  2268. {
  2269. g_assert(_widget != NULL);
  2270. setProgrammatically = true; // callback is supposed to reset back, if it cares
  2271. === modified file 'src/ui/widget/text.h'
  2272. --- src/ui/widget/text.h 2012-02-26 16:54:08 +0000
  2273. +++ src/ui/widget/text.h 2016-07-31 21:49:59 +0000
  2274. @@ -44,12 +44,12 @@
  2275. /**
  2276. * Get the text in the entry.
  2277. */
  2278. - const char* getText() const;
  2279. + Glib::ustring const getText() const;
  2280. /**
  2281. * Sets the text of the text entry.
  2282. */
  2283. - void setText(const char* text);
  2284. + void setText(Glib::ustring const text);
  2285. void update();
  2286. === modified file 'src/widgets/font-selector.cpp'
  2287. --- src/widgets/font-selector.cpp 2016-07-28 11:26:17 +0000
  2288. +++ src/widgets/font-selector.cpp 2016-07-22 19:59:31 +0000
  2289. @@ -19,9 +19,6 @@
  2290. # include "config.h"
  2291. #endif
  2292. -#include <libnrtype/font-lister.h>
  2293. -#include <libnrtype/font-instance.h>
  2294. -
  2295. #include <2geom/transforms.h>
  2296. #include <gtk/gtk.h>
  2297. @@ -34,29 +31,7 @@
  2298. /* SPFontSelector */
  2299. -struct SPFontSelector
  2300. -{
  2301. -#if GTK_CHECK_VERSION(3,0,0)
  2302. - GtkBox hbox;
  2303. -#else
  2304. - GtkHBox hbox;
  2305. -#endif
  2306. -
  2307. - unsigned int block_emit : 1;
  2308. -
  2309. - GtkWidget *family;
  2310. - GtkWidget *style;
  2311. - GtkWidget *size;
  2312. -
  2313. - GtkWidget *family_treeview;
  2314. - GtkWidget *style_treeview;
  2315. -
  2316. - NRNameList families;
  2317. - NRStyleList styles;
  2318. - gfloat fontsize;
  2319. - bool fontsize_dirty;
  2320. - Glib::ustring *fontspec;
  2321. -};
  2322. +
  2323. struct SPFontSelectorClass
  2324. @@ -274,6 +249,7 @@
  2325. if (fsel->fontspec) {
  2326. delete fsel->fontspec;
  2327. + fsel->fontspec = 0;
  2328. }
  2329. if (fsel->families.length > 0) {
  2330. === modified file 'src/widgets/font-selector.h'
  2331. --- src/widgets/font-selector.h 2014-08-18 20:19:55 +0000
  2332. +++ src/widgets/font-selector.h 2016-07-22 19:59:29 +0000
  2333. @@ -15,10 +15,33 @@
  2334. *
  2335. * Released under GNU GPL, read the file 'COPYING' for more information
  2336. */
  2337. -
  2338. +#include <libnrtype/font-lister.h>
  2339. +#include <libnrtype/font-instance.h>
  2340. #include <glib.h>
  2341. -struct SPFontSelector;
  2342. +struct SPFontSelector
  2343. +{
  2344. +#if GTK_CHECK_VERSION(3,0,0)
  2345. + GtkBox hbox;
  2346. +#else
  2347. + GtkHBox hbox;
  2348. +#endif
  2349. +
  2350. + unsigned int block_emit : 1;
  2351. +
  2352. + GtkWidget *family;
  2353. + GtkWidget *style;
  2354. + GtkWidget *size;
  2355. +
  2356. + GtkWidget *family_treeview;
  2357. + GtkWidget *style_treeview;
  2358. +
  2359. + NRNameList families;
  2360. + NRStyleList styles;
  2361. + gfloat fontsize;
  2362. + bool fontsize_dirty;
  2363. + Glib::ustring *fontspec;
  2364. +};
  2365. #define SP_TYPE_FONT_SELECTOR (sp_font_selector_get_type ())
  2366. #define SP_FONT_SELECTOR(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), SP_TYPE_FONT_SELECTOR, SPFontSelector))
  1. More ...
 
 

17

 

853

Measure Line DIFF r.15051

-

PasteBin

2514
言葉
8262
サイズ
93.3 KB
作成済み
タイプ
text/plain
General Public License v2 (GPLv2)
コメントするにはログインしてください!