summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--share/extensions/docinfo.inx21
-rw-r--r--share/extensions/dpi90to96.inx23
-rw-r--r--share/extensions/dpi96to90.inx23
-rw-r--r--share/extensions/dpiswitcher.py219
-rw-r--r--src/display/curve.cpp14
-rw-r--r--src/display/curve.h1
-rw-r--r--src/file.cpp72
-rw-r--r--src/live_effects/lpe-measure-line.cpp160
-rw-r--r--src/live_effects/lpe-measure-line.h9
-rw-r--r--src/live_effects/lpe-path_length.cpp10
-rw-r--r--src/live_effects/lpe-path_length.h2
-rw-r--r--src/live_effects/parameter/parameter.h2
-rw-r--r--src/live_effects/parameter/text.cpp5
-rw-r--r--src/sp-lpe-item.cpp16
-rw-r--r--src/sp-mesh-array.cpp5
-rw-r--r--src/sp-path.cpp62
-rw-r--r--src/ui/tool/path-manipulator.cpp10
17 files changed, 492 insertions, 162 deletions
diff --git a/share/extensions/docinfo.inx b/share/extensions/docinfo.inx
new file mode 100644
index 000000000..c3d76a960
--- /dev/null
+++ b/share/extensions/docinfo.inx
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
+ <_name>DOC Info</_name>
+ <id>org.inkscape.docinfo</id>
+ <dependency type="executable" location="extensions">dpiswitcher.py</dependency>
+ <dependency type="executable" location="extensions">inkex.py</dependency>
+ <param name="action" type="notebook" gui-hidden="true">
+ <page name="page_info" _gui-text="Show page info">
+ <_param name="d" type="description">Choose this tab if you would like to see page info previously to apply DPI Switcher.</_param>
+ </page>
+ </param>
+ <effect needs-live-preview="false">
+ <object-type>all</object-type>
+ <effects-menu>
+ <submenu _name="Document"/>
+ </effects-menu>
+ </effect>
+ <script>
+ <command reldir="extensions" interpreter="python">dpiswitcher.py</command>
+ </script>
+</inkscape-extension>
diff --git a/share/extensions/dpi90to96.inx b/share/extensions/dpi90to96.inx
new file mode 100644
index 000000000..e7ad4a895
--- /dev/null
+++ b/share/extensions/dpi90to96.inx
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
+ <_name>DPI 90 to 96</_name>
+ <id>org.inkscape.dpi90to96</id>
+ <dependency type="executable" location="extensions">dpiswitcher.py</dependency>
+ <dependency type="executable" location="extensions">inkex.py</dependency>
+ <param name="action" type="notebook" gui-hidden="true">
+ <page name="dpi_swicher" >
+ <param name="switcher" type="enum" gui-hidden="true">
+ <item value="0">DPI Switch from 90 to 96</item>
+ </param>
+ </page>
+ </param>
+ <effect needs-live-preview="false">
+ <object-type>all</object-type>
+ <effects-menu>
+ <submenu _name="Document"/>
+ </effects-menu>
+ </effect>
+ <script>
+ <command reldir="extensions" interpreter="python">dpiswitcher.py</command>
+ </script>
+</inkscape-extension>
diff --git a/share/extensions/dpi96to90.inx b/share/extensions/dpi96to90.inx
new file mode 100644
index 000000000..11d1cb40b
--- /dev/null
+++ b/share/extensions/dpi96to90.inx
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
+ <_name>DPI 96 to 90</_name>
+ <id>org.inkscape.dpi96to90</id>
+ <dependency type="executable" location="extensions">dpiswitcher.py</dependency>
+ <dependency type="executable" location="extensions">inkex.py</dependency>
+ <param name="action" type="notebook" gui-hidden="true">
+ <page name="dpi_swicher" >
+ <param name="switcher" type="enum" gui-hidden="true">
+ <item value="1">DPI Switch from 96 to 90</item>
+ </param>
+ </page>
+ </param>
+ <effect needs-live-preview="false">
+ <object-type>all</object-type>
+ <effects-menu>
+ <submenu _name="Document"/>
+ </effects-menu>
+ </effect>
+ <script>
+ <command reldir="extensions" interpreter="python">dpiswitcher.py</command>
+ </script>
+</inkscape-extension>
diff --git a/share/extensions/dpiswitcher.py b/share/extensions/dpiswitcher.py
new file mode 100644
index 000000000..e7adbc0cf
--- /dev/null
+++ b/share/extensions/dpiswitcher.py
@@ -0,0 +1,219 @@
+#!/usr/bin/env python
+'''
+This extension scale or reduce a document to fit diferent SVG DPI -90/96-
+
+Copyright (C) 2012 Jabiertxo Arraiza, jabier.arraiza@marker.es
+
+Version 0.5 - DPI Switcher
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+'''
+
+import inkex, sys, re, string
+from lxml import etree
+
+class DPISwitcher(inkex.Effect):
+
+ def __init__(self):
+ inkex.Effect.__init__(self)
+ self.OptionParser.add_option("--switcher", action="store",
+ type="string", dest="switcher", default="0",
+ help="Select the DPI switch you want")
+ self.OptionParser.add_option("--action", action="store",
+ type="string", dest="action",
+ default=None, help="")
+ self.factor_a = 90.0/96.0
+ self.factor_b = 96.0/90.0
+ self.units = "px"
+ self.unitExponent = 1.0
+
+ def scaleRoot(self, svg):
+ widthNumber = re.sub("[a-zA-Z]", "", svg.get('width'))
+ heightNumber = re.sub("[a-zA-Z]", "", svg.get('height'))
+ widthDoc = str(float(widthNumber) * self.factor_a * self.unitExponent)
+ heightDoc = str(float(heightNumber) * self.factor_a * self.unitExponent)
+ if svg.get('viewBox'):
+ widthNumber = svg.get('viewBox').split(" ")[2]
+ heightNumber = svg.get('viewBox').split(" ")[3]
+ if svg.get('height'):
+ svg.set('height', heightDoc)
+ if svg.get('width'):
+ svg.set('width', widthDoc)
+ if svg.get('viewBox'):
+ svg.set('viewBox',"0 0 " + str(float(widthNumber) * self.factor_a) + " " + str(float(heightNumber) * self.factor_a))
+ if self.options.switcher == "1":
+ self.scaleGuides(svg)
+ self.scaleGrid(svg)
+ for element in svg:
+ box3DSide = element.get(inkex.addNS('box3dsidetype', 'inkscape'))
+ if box3DSide:
+ continue
+ uri, tag = element.tag.split("}")
+ width_scale = self.factor_a
+ height_scale = self.factor_a
+ if tag == "rect" or tag == "image" or tag == "path" or tag == "circle" or tag == "ellipse" or tag == "text":
+ if element.get('width') is not None and \
+ (re.sub("[0-9]*\.?[0-9]", "", element.get('width')) == "%" or \
+ re.sub("[0-9]*\.?[0-9]", "", element.get('width')) == "px"):
+ width_scale = 1.0;
+ if element.get('height') is not None and \
+ (re.sub("[0-9]*\.?[0-9]", "", element.get('height')) == "%" or \
+ re.sub("[0-9]*\.?[0-9]", "", element.get('height')) == "px"):
+ height_scale = 1.0;
+ if element.get('x') is not None and \
+ re.sub("[0-9]*\.?[0-9]", "", element.get('x')) == "%":
+ xpos = str(float(element.get('x').replace('%','')) * self.factor_b) + '%'
+ element.set('x', xpos)
+ if element.get('y') is not None and \
+ re.sub("[0-9]*\.?[0-9]", "", element.get('y')) == "%":
+ ypos = str(float(element.get('y').replace('%','')) * self.factor_b) + '%'
+ element.set('y', ypos)
+ if element.get('transform'):
+ if "matrix" in str(element.get('transform')) and width_scale != 1.0:
+ result = re.sub(r".*?matrix( \(|\()(.*?)\)", self.matrixElement, str(element.get('transform')))
+ element.set('transform', result)
+ if "scale" in str(element.get('transform')) and width_scale != 1.0:
+ result = re.sub(r".*?scale( \(|\()(.*?)\)", self.scaleElement, str(element.get('transform')))
+ element.set('transform', result)
+ if "translate" in str(element.get('transform')) and width_scale != 1.0:
+ result = re.sub(r".*?translate( \(|\()(.*?)\)", self.translateElement, str(element.get('transform')))
+ element.set('transform', result)
+ if "skew" in str(element.get('transform')) and width_scale != 1.0:
+ result = re.sub(r".*?skew( \(|\()(.*?)\)", self.skewElement, str(element.get('transform')))
+ element.set('transform', result)
+ if "scale" not in str(element.get('transform')) and "matrix" not in str(element.get('transform')):
+ element.set('transform', str(element.get('transform')) + "scale(" + str( width_scale) + ", " + str(height_scale) + ")")
+ else:
+ element.set('transform', "scale(" + str(width_scale) + ", " + str(height_scale) + ")")
+
+ #a dictionary of unit to user unit conversion factors
+ __uuconv = {'in':96.0, 'pt':1.33333333333, 'px':1.0, 'mm':3.77952755913, 'cm':37.7952755913,
+ 'm':3779.52755913, 'km':3779527.55913, 'pc':16.0, 'yd':3456.0 , 'ft':1152.0}
+
+ __uuconvLegazy = {'in':90.0, 'pt':1.25, 'px':1, 'mm':3.5433070866, 'cm':35.433070866, 'm':3543.3070866,
+ 'km':3543307.0866, 'pc':15.0, 'yd':3240 , 'ft':1080}
+
+ def scaleElement(self, m):
+ scaleVal = m.group(2).replace(" ","")
+ total = scaleVal.count(',')
+ if total == 1:
+ scaleVal = scaleVal.split(",")
+ return "matrix(" + str(float(scaleVal[0]) * self.factor_a) + ",0,0," + str(float(scaleVal[1]) * self.factor_a) + ",0,0)"
+ else:
+ return "matrix(" + str(float(scaleVal) * self.factor_a) + ",0,0," + str(float(scaleVal) * self.factor_a) + ",0,0)"
+
+
+ def translateElement(self, m):
+ translateVal = m.group(2).replace(" ","")
+ total = translateVal.count(',')
+ if total == 1:
+ translateVal = translateVal.split(",")
+ return "matrix(" + str(self.factor_a) + ",0,0," + str(self.factor_a) + "," + str(float(translateVal[0]) * self.factor_a) + "," + str(float(translateVal[1]) * self.factor_a) + ")"
+ else:
+ return "matrix(" + str(self.factor_a) + ",0,0," + str(self.factor_a) + "," + str(float(translateVal) * self.factor_a) + "," + str(float(translateVal) * self.factor_a) + ")"
+
+ def skewElement(self, m):
+ skeweVal = m.group(2).replace(" ","")
+ total = skewVal.count(',')
+ if total == 1:
+ skeweVal = skewVal.split(",")
+ return "skew(" + str(float(skewVal[0]) * self.factor_a) + "," + str(float(skewVal[1]) * self.factor_a) + ") matrix(" + str(self.factor_a) + ",0,0," + str(self.factor_a) + ",0,0)"
+ else:
+ return "skew(" + str(float(skewVal) * self.factor_a) + ") matrix(" + str(self.factor_a) + ",0,0," + str(self.factor_a) + ",0,0)"
+
+ def matrixElement(self, m):
+ matrixVal = m.group(2).replace(" ","")
+ total = matrixVal.count(',')
+ matrixVal = matrixVal.split(",")
+ if total == 5:
+ return "matrix(" + str(float(matrixVal[0]) * self.factor_a) + "," + matrixVal[1] + "," + matrixVal[2] + "," + str(float(matrixVal[3]) * self.factor_a) + "," + str(float(matrixVal[4]) * self.factor_a) + "," + str(float(matrixVal[5]) * self.factor_a) + ")"
+
+ def scaleGuides(self, svg):
+ xpathStr = '//sodipodi:guide'
+ guides = svg.xpath(xpathStr, namespaces=inkex.NSS)
+ for guide in guides:
+ point = string.split(guide.get("position"), ",")
+ guide.set("position", str(float(point[0].strip()) * self.factor_a ) + "," + str(float(point[1].strip()) * self.factor_a ))
+
+ def scaleGrid(self, svg):
+ xpathStr = '//inkscape:grid'
+ grids = svg.xpath(xpathStr, namespaces=inkex.NSS)
+ for grid in grids:
+ grid.set("units", "px")
+ if grid.get("spacingx"):
+ spacingx = str(float(re.sub("[a-zA-Z]", "", grid.get("spacingx"))) * self.factor_a) + "px"
+ grid.set("spacingx", str(spacingx))
+ if grid.get("spacingy"):
+ spacingy = str(float(re.sub("[a-zA-Z]", "", grid.get("spacingy"))) * self.factor_a) + "px"
+ grid.set("spacingy", str(spacingy))
+ if grid.get("originx"):
+ originx = str(float(re.sub("[a-zA-Z]", "", grid.get("originx"))) * self.factor_a) + "px"
+ grid.set("originx", str(originx))
+ if grid.get("originy"):
+ originy = str(float(re.sub("[a-zA-Z]", "", grid.get("originy"))) * self.factor_a) + "px"
+ grid.set("originy", str(originy))
+
+ def effect(self):
+ action = self.options.action.strip("\"") # TODO Is this a bug? (Extra " characters)
+ saveout = sys.stdout
+ sys.stdout = sys.stderr
+ svg = self.document.getroot()
+ if action == "page_info":
+ print ":::SVG document related info:::"
+ print "version: " + str(svg.get(inkex.addNS('version',u'inkscape')))
+ width = svg.get('width')
+ if width:
+ print "width: " + width
+ height = svg.get('height')
+ if height:
+ print "height: " + height
+ viewBox = svg.get('viewBox')
+ if viewBox:
+ print "viewBox: " + viewBox
+ namedview = svg.find(inkex.addNS('namedview', 'sodipodi'))
+ docunits= namedview.get(inkex.addNS('document-units', 'inkscape'))
+ if docunits:
+ print "document-units: " + docunits
+ units = namedview.get('units')
+ if units:
+ print "units: " + units
+ xpathStr = '//sodipodi:guide'
+ guides = svg.xpath(xpathStr, namespaces=inkex.NSS)
+ xpathStr = '//inkscape:grid'
+ if guides:
+ numberGuides = len(guides)
+ print "Document has " + str(numberGuides) + " guides"
+ grids = svg.xpath(xpathStr, namespaces=inkex.NSS)
+ i = 1
+ for grid in grids:
+ print "Grid number " + str(i) + ": Units: " + grid.get("units")
+ i = i+1
+ else:
+ if self.options.switcher == "0":
+ self.factor_a = 96.0/90.0
+ self.factor_b = 90.0/96.0
+ namedview = svg.find(inkex.addNS('namedview', 'sodipodi'))
+ namedview.set(inkex.addNS('document-units', 'inkscape'), "px")
+ self.units = re.sub("[0-9]*\.?[0-9]", "", svg.get('width'))
+ if self.units and self.units <> "px" and self.units <> "" and self.units <> "%":
+ if self.options.switcher == "0":
+ self.unitExponent = 1.0/(self.factor_a/self.__uuconv[self.units])
+ else:
+ self.unitExponent = 1.0/(self.factor_a/self.__uuconvLegazy[self.units])
+ self.scaleRoot(svg);
+ sys.stdout = saveout
+
+effect = DPISwitcher()
+effect.affect()
diff --git a/src/display/curve.cpp b/src/display/curve.cpp
index 1998e9bec..6e662b17b 100644
--- a/src/display/curve.cpp
+++ b/src/display/curve.cpp
@@ -335,6 +335,20 @@ SPCurve::is_closed() const
}
/**
+ * True if both curves are equal
+ */
+bool
+SPCurve::is_equal(SPCurve * other) const
+{
+ if(other == NULL) {
+ return false;
+ } else if(_pathv == other->get_pathvector()){
+ return true;
+ }
+ return false;
+}
+
+/**
* Return last pathsegment (possibly the closing path segment) of the last path in PathVector or NULL.
* If the last path is empty (contains only a moveto), the function returns NULL
*/
diff --git a/src/display/curve.h b/src/display/curve.h
index 72e6df95c..8375e1105 100644
--- a/src/display/curve.h
+++ b/src/display/curve.h
@@ -45,6 +45,7 @@ public:
bool is_empty() const;
bool is_unset() const;
bool is_closed() const;
+ bool is_equal(SPCurve * other) const;
Geom::Curve const * last_segment() const;
Geom::Path const * last_path() const;
Geom::Curve const * first_segment() const;
diff --git a/src/file.cpp b/src/file.cpp
index ee66cc162..38c07311d 100644
--- a/src/file.cpp
+++ b/src/file.cpp
@@ -34,6 +34,7 @@
#include "ui/dialog/ocaldialogs.h"
#include "desktop.h"
+#include "extension/effect.h"
#include "document-private.h"
#include "document-undo.h"
#include "ui/tools/tool-base.h"
@@ -312,14 +313,13 @@ bool sp_file_open(const Glib::ustring &uri,
// std::cout << " SVG file from old Inkscape version detected: "
// << sp_version_to_string(root->version.inkscape) << std::endl;
-
-
static const double ratio = 90.0/96.0;
bool need_fix_viewbox = false;
bool need_fix_units = false;
bool need_fix_guides = false;
bool need_fix_grid_mm = false;
+ bool is_extension = false;
// Check if potentially need viewbox or unit fix
switch (root->width.unit) {
@@ -358,20 +358,18 @@ bool sp_file_open(const Glib::ustring &uri,
if (!root->viewBox_set && need_fix_viewbox) {
std::string msg = _(
- "Old Inkscape files used 1in == 90px. CSS requires 1in == 96px.\n"
+ "Old Inkscape files use 1in == 90px. CSS requires 1in == 96px.\n"
"Drawing elements may be too small. This can be corrected by\n"
- "setting the SVG 'viewBox' to compensate." );
- // "either setting the SVG 'viewBox' to compensate or by scaling\n"
- // "all the elements in the drawing."
+ "either setting the SVG 'viewBox' to compensate or by scaling\n"
+ "all the elements in the drawing.");
Gtk::Dialog scaleDialog( _("Old Inkscape file detected (90 DPI)"), false);
Gtk::Label info;
info.set_markup(msg.c_str());
info.show();
scaleDialog.get_content_area()->pack_start(info, false, false, 20);
scaleDialog.add_button("Set 'viewBox'", 1);
- // scaleDialog.add_button("Scale elements", 2);
+ scaleDialog.add_button("Scale elements", 2);
scaleDialog.add_button("Ignore", 3);
-
gint response = scaleDialog.run();
if (response == 1) {
doc->setViewBox(Geom::Rect::from_xywh(
@@ -379,27 +377,42 @@ bool sp_file_open(const Glib::ustring &uri,
doc->getWidth().value("px") * ratio,
doc->getHeight().value("px") * ratio));
} else if (response == 2 ) {
- // Insert DPISwitcher code
+ std::list<Inkscape::Extension::Effect *> effects;
+ Inkscape::Extension::db.get_effect_list(effects);
+ std::list<Inkscape::Extension::Effect *>::iterator it = effects.begin();
+ bool did = false;
+ while (it != effects.end()) {
+ if (strcmp((*it)->get_id(), "org.inkscape.dpi90to96") == 0) {
+ Inkscape::UI::View::View *view = desktop;
+ (*it)->effect(view);
+ did = true;
+ break;
+ }
+ ++it;
+ }
+ if (!did) {
+ std::cerr << "sp_file_open: Failed to find dpi90to96 extension." << std::endl;
+ }
+ is_extension = true;
}
need_fix_guides = true; // Always fix guides
}
if (need_fix_units) {
std::string msg = (
- "Old Inkscape files used 1in == 90px. CSS requires 1in == 96px.\n"
+ "Old Inkscape files use 1in == 90px. CSS requires 1in == 96px.\n"
"Drawings meant to match a physical size (e.g. Letter or A4)\n"
- "will be too small. Scaling the drawing can correct for this.\n" );
- // "Internal scaling can be handled either by setting the SVG 'viewBox'\n"
- // "attribute to compensate or by scaling all objects in the drawing."
+ "will be too small. Scaling the drawing can correct for this.\n"
+ "Internal scaling can be handled either by setting the SVG 'viewBox'\n"
+ "attribute to compensate or by scaling all objects in the drawing.");
Gtk::Dialog scaleDialog( _("Old Inkscape file detected (90 DPI)"), false);
Gtk::Label info;
info.set_markup(msg.c_str());
info.show();
scaleDialog.get_content_area()->pack_start(info, false, false, 20);
- scaleDialog.add_button("Scale drawing", 1);
- // scaleDialog.add_button("Set 'viewBox'", 1);
- // scaleDialog.add_button("Scale elements", 2);
- scaleDialog.add_button("Ignore", 3);
+ scaleDialog.add_button("Set 'viewBox'", 1);
+ scaleDialog.add_button("Scale elements", 2);
+ scaleDialog.add_button("Ignore", 3);
gint response = scaleDialog.run();
if (response == 1) {
@@ -418,7 +431,24 @@ bool sp_file_open(const Glib::ustring &uri,
need_fix_guides = true; // Only fix guides if drawing scaled
} else if (response == 2) {
- // Insert DPISwitcher code
+ std::list<Inkscape::Extension::Effect *> effects;
+ Inkscape::Extension::db.get_effect_list(effects);
+ std::list<Inkscape::Extension::Effect *>::iterator it = effects.begin();
+ bool did = false;
+ while (it != effects.end()){
+ if (strcmp((*it)->get_id(), "org.inkscape.dpi90to96") == 0) {
+ Inkscape::UI::View::View *view = desktop;
+ (*it)->effect(view);
+ did = true;
+ break;
+ }
+ ++it;
+ }
+ if (!did) {
+ std::cerr << "sp_file_open: Failed to find dpi90to96 extension." << std::endl;
+ }
+ need_fix_guides = true; // Only fix guides if drawing scaled
+ is_extension = true;
} else {
// Ignore
need_fix_grid_mm = true;
@@ -467,7 +497,11 @@ bool sp_file_open(const Glib::ustring &uri,
// HACK: Scaling the document does not seem to cause
// grids defined in document units to be updated.
// This forces an update.
- xy->Scale( Geom::Scale(1,1) );
+ if(is_extension){
+ xy->Scale( Geom::Scale(ratio,ratio).inverse() );
+ } else {
+ xy->Scale( Geom::Scale(1,1) );
+ }
}
}
}
diff --git a/src/live_effects/lpe-measure-line.cpp b/src/live_effects/lpe-measure-line.cpp
index ef270d849..a1de035fb 100644
--- a/src/live_effects/lpe-measure-line.cpp
+++ b/src/live_effects/lpe-measure-line.cpp
@@ -47,9 +47,6 @@ static const Util::EnumData<OrientationMethod> OrientationMethodData[] = {
};
static const Util::EnumDataConverter<OrientationMethod> OMConverter(OrientationMethodData, OM_END);
-std::vector<Glib::ustring> ml_elements;
-SPObject * container;
-
LPEMeasureLine::LPEMeasureLine(LivePathEffectObject *lpeobject) :
Effect(lpeobject),
unit(_("Unit*"), _("Unit"), "unit", &wr, this, "px"),
@@ -63,7 +60,7 @@ LPEMeasureLine::LPEMeasureLine(LivePathEffectObject *lpeobject) :
helpline_distance(_("Helpline distance*"), _("Helpline distance"), "helpline_distance", &wr, this, 0.0),
helpline_overlap(_("Helpline overlap*"), _("Helpline overlap"), "helpline_overlap", &wr, this, 2.0),
scale(_("Scale*"), _("Scaling factor"), "scale", &wr, this, 1.0),
- format(_("Format*"), _("Format the number ex:{measure} {unit}, return to save"), "format", &wr, this,"measure unit"),
+ format(_("Format*"), _("Format the number ex:{measure} {unit}, return to save"), "format", &wr, this,"{measure}{unit}"),
arrows_outside(_("Arrows outside"), _("Arrows outside"), "arrows_outside", &wr, this, false),
flip_side(_("Flip side*"), _("Flip side"), "flip_side", &wr, this, false),
scale_sensitive(_("Scale sensitive*"), _("Costrained scale sensitive to transformed containers"), "scale_sensitive", &wr, this, true),
@@ -161,6 +158,8 @@ LPEMeasureLine::LPEMeasureLine(LivePathEffectObject *lpeobject) :
helpline_overlap.param_set_range(-999999.0, 999999.0);
helpline_overlap.param_set_increments(1, 1);
helpline_overlap.param_set_digits(2);
+ start_stored = Geom::Point(0,0);
+ end_stored = Geom::Point(0,0);
}
LPEMeasureLine::~LPEMeasureLine() {}
@@ -172,19 +171,19 @@ void swap(Geom::Point &A, Geom::Point &B){
}
void
-LPEMeasureLine::createArrowMarker(Glib::ustring mode)
+LPEMeasureLine::createArrowMarker(const char * mode)
{
if (SPDesktop *desktop = SP_ACTIVE_DESKTOP) {
Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc();
- Inkscape::URI SVGElem_uri(((Glib::ustring)"#" + mode).c_str());
+ Inkscape::URI SVGElem_uri(Glib::ustring("#").append(mode).c_str());
Inkscape::URIReference* SVGElemRef = new Inkscape::URIReference(desktop->doc());
SVGElemRef->attach(SVGElem_uri);
SPObject *elemref = NULL;
Inkscape::XML::Node *arrow = NULL;
if (!(elemref = SVGElemRef->getObject())) {
arrow = xml_doc->createElement("svg:marker");
- arrow->setAttribute("id", mode.c_str());
- arrow->setAttribute("inkscape:stockid", mode.c_str());
+ arrow->setAttribute("id", mode);
+ arrow->setAttribute("inkscape:stockid", mode);
arrow->setAttribute("orient", "auto");
arrow->setAttribute("refX", "0.0");
arrow->setAttribute("refY", "0.0");
@@ -192,20 +191,20 @@ LPEMeasureLine::createArrowMarker(Glib::ustring mode)
arrow->setAttribute("sodipodi:insensitive", "true");
/* Create <path> */
Inkscape::XML::Node *arrow_path = xml_doc->createElement("svg:path");
- if (mode == (Glib::ustring)"ArrowDIN-start") {
+ if (std::strcmp(mode, "ArrowDIN-start") == 0) {
arrow_path->setAttribute("d", "M -8,0 8,-2.11 8,2.11 z");
- } else if (mode == (Glib::ustring)"ArrowDIN-end") {
+ } else if (std::strcmp(mode, "ArrowDIN-end") == 0) {
arrow_path->setAttribute("d", "M 8,0 -8,2.11 -8,-2.11 z");
- } else if (mode == (Glib::ustring)"ArrowDINout-start") {
+ } else if (std::strcmp(mode, "ArrowDINout-start") == 0) {
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");
} else {
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");
}
- arrow_path->setAttribute("id", (mode + (Glib::ustring)"_path").c_str());
+ arrow_path->setAttribute("id", Glib::ustring(mode).append("_path").c_str());
SPCSSAttr *css = sp_repr_css_attr_new();
sp_repr_css_set_property (css, "fill","#000000");
- sp_repr_css_set_property (css, "stroke","none" );
+ sp_repr_css_set_property (css, "stroke","none");
sp_repr_css_attr_add_from_string(css, arrows_format.param_getSVGValue());
Glib::ustring css_str;
sp_repr_css_write_string(css,css_str);
@@ -223,7 +222,7 @@ LPEMeasureLine::createArrowMarker(Glib::ustring mode)
if (arrow_data) {
SPCSSAttr *css = sp_repr_css_attr_new();
sp_repr_css_set_property (css, "fill","#000000");
- sp_repr_css_set_property (css, "stroke","none" );
+ sp_repr_css_set_property (css, "stroke","none");
arrow_data->setAttribute("transform", NULL);
sp_repr_css_attr_add_from_string(css, arrows_format.param_getSVGValue());
Glib::ustring css_str;
@@ -232,7 +231,7 @@ LPEMeasureLine::createArrowMarker(Glib::ustring mode)
}
}
}
- ml_elements.push_back(mode);
+ elements.push_back(mode);
}
}
@@ -256,8 +255,8 @@ LPEMeasureLine::createTextLabel(Geom::Point pos, double length, Geom::Coord angl
} else {
doc_scale = 1.0;
}
- Glib::ustring id = (Glib::ustring)"text-on-" + (Glib::ustring)this->getRepr()->attribute("id");
- Inkscape::URI SVGElem_uri(((Glib::ustring)"#" + id).c_str());
+ const char * id = g_strdup(Glib::ustring("text-on-").append(this->getRepr()->attribute("id")).c_str());
+ Inkscape::URI SVGElem_uri(Glib::ustring("#").append(id).c_str());
Inkscape::URIReference* SVGElemRef = new Inkscape::URIReference(desktop->doc());
SVGElemRef->attach(SVGElem_uri);
SPObject *elemref = NULL;
@@ -279,7 +278,7 @@ LPEMeasureLine::createTextLabel(Geom::Point pos, double length, Geom::Coord angl
}
rtext = xml_doc->createElement("svg:text");
rtext->setAttribute("xml:space", "preserve");
- rtext->setAttribute("id", ( (Glib::ustring)"text-on-" + (Glib::ustring)this->getRepr()->attribute("id")).c_str());
+ rtext->setAttribute("id", id);
rtext->setAttribute("sodipodi:insensitive", "true");
pos = pos - Point::polar(angle, text_right_left);
sp_repr_set_svg_double(rtext, "x", pos[Geom::X]);
@@ -287,7 +286,7 @@ LPEMeasureLine::createTextLabel(Geom::Point pos, double length, Geom::Coord angl
rtspan = xml_doc->createElement("svg:tspan");
rtspan->setAttribute("sodipodi:role", "line");
}
- gchar * transform;
+ const char * transform;
Geom::Affine affine = Geom::Affine(Geom::Translate(pos).inverse());
angle = std::fmod(angle, 2*M_PI);
if (angle < 0) angle += 2*M_PI;
@@ -306,7 +305,7 @@ LPEMeasureLine::createTextLabel(Geom::Point pos, double length, Geom::Coord angl
SPCSSAttr *css = sp_repr_css_attr_new();
sp_repr_css_attr_add_from_string(css, anotation_format.param_getSVGValue());
Inkscape::FontLister *fontlister = Inkscape::FontLister::get_instance();
- fontlister->fill_css( css, (Glib::ustring)fontbutton.param_getSVGValue() );
+ fontlister->fill_css(css, Glib::ustring(fontbutton.param_getSVGValue()));
std::stringstream font_size;
font_size.imbue(std::locale::classic());
font_size << fontsize << "pt";
@@ -344,11 +343,11 @@ LPEMeasureLine::createTextLabel(Geom::Point pos, double length, Geom::Coord angl
}
length_str << std::fixed << length;
Glib::ustring label_value = Glib::ustring(format.param_getSVGValue());
- size_t s = label_value.find((Glib::ustring)"{measure}",0);
+ size_t s = label_value.find(Glib::ustring("{measure}"),0);
if(s < label_value.length()) {
label_value.replace(s,s+9,length_str.str());
}
- s = label_value.find((Glib::ustring)"{unit}",0);
+ s = label_value.find(Glib::ustring("{unit}"),0);
if(s < label_value.length()) {
label_value.replace(s,s+6,unit.get_abbreviation());
}
@@ -365,18 +364,18 @@ LPEMeasureLine::createTextLabel(Geom::Point pos, double length, Geom::Coord angl
rstring->setContent(label_value.c_str());
}
if (!elemref) {
- elemref = container->appendChildRepr(rtext);
+ elemref = sp_lpe_item->parent->appendChildRepr(rtext);
Inkscape::GC::release(rtext);
- } else if (elemref->parent != container) {
+ } else if (elemref->parent != sp_lpe_item->parent) {
Inkscape::XML::Node *old_repr = elemref->getRepr();
Inkscape::XML::Node *copy = old_repr->duplicate(xml_doc);
- SPObject * elemref_copy = container->appendChildRepr(copy);
+ SPObject * elemref_copy = sp_lpe_item->parent->appendChildRepr(copy);
Inkscape::GC::release(copy);
elemref->deleteObject();
- copy->setAttribute("id", id.c_str());
+ copy->setAttribute("id", id);
elemref = elemref_copy;
}
- ml_elements.push_back(id);
+ elements.push_back(id);
Geom::OptRect bounds = SP_ITEM(elemref)->bounds(SPItem::GEOMETRIC_BBOX);
if (bounds) {
anotation_width = bounds->width() * 1.4;
@@ -385,11 +384,11 @@ LPEMeasureLine::createTextLabel(Geom::Point pos, double length, Geom::Coord angl
}
void
-LPEMeasureLine::createLine(Geom::Point start,Geom::Point end, Glib::ustring id, bool main, bool overflow, bool remove, bool arrows)
+LPEMeasureLine::createLine(Geom::Point start,Geom::Point end, const char * id, bool main, bool overflow, bool remove, bool arrows)
{
if (SPDesktop *desktop = SP_ACTIVE_DESKTOP) {
Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc();
- Inkscape::URI SVGElem_uri(((Glib::ustring)"#" + id).c_str());
+ Inkscape::URI SVGElem_uri(Glib::ustring("#").append(id).c_str());
Inkscape::URIReference* SVGElemRef = new Inkscape::URIReference(desktop->doc());
SVGElemRef->attach(SVGElem_uri);
SPObject *elemref = NULL;
@@ -427,7 +426,6 @@ LPEMeasureLine::createLine(Geom::Point start,Geom::Point end, Glib::ustring id,
line_path.appendNew<Geom::LineSegment>(end);
line_pathv.push_back(line_path);
}
-
if (elemref = SVGElemRef->getObject()) {
if (remove) {
elemref->deleteObject();
@@ -435,7 +433,7 @@ LPEMeasureLine::createLine(Geom::Point start,Geom::Point end, Glib::ustring id,
}
line = elemref->getRepr();
- gchar * line_str = sp_svg_write_path( line_pathv );
+ const char * line_str = sp_svg_write_path( line_pathv );
line->setAttribute("d" , line_str);
line->setAttribute("transform", NULL);
} else {
@@ -443,22 +441,22 @@ LPEMeasureLine::createLine(Geom::Point start,Geom::Point end, Glib::ustring id,
return;
}
line = xml_doc->createElement("svg:path");
- line->setAttribute("id", id.c_str());
- gchar * line_str = sp_svg_write_path( line_pathv );
+ line->setAttribute("id", id);
+ const char * line_str = sp_svg_write_path( line_pathv );
line->setAttribute("d" , line_str);
}
line->setAttribute("sodipodi:insensitive", "true");
line_pathv.clear();
- Glib::ustring style = (Glib::ustring)"stroke:#000000;fill:none;";
+ Glib::ustring style = Glib::ustring("stroke:#000000;fill:none;");
if (overflow && !arrows) {
line->setAttribute("inkscape:label", "downline");
} else if (main) {
line->setAttribute("inkscape:label", "dinline");
if (arrows_outside) {
- style = style + (Glib::ustring)"marker-start:url(#ArrowDINout-start);marker-end:url(#ArrowDINout-end);";
+ style = style + Glib::ustring("marker-start:url(#ArrowDINout-start);marker-end:url(#ArrowDINout-end);");
} else {
- style = style + (Glib::ustring)"marker-start:url(#ArrowDIN-start);marker-end:url(#ArrowDIN-end);";
+ style = style + Glib::ustring("marker-start:url(#ArrowDIN-start);marker-end:url(#ArrowDIN-end);");
}
} else {
line->setAttribute("inkscape:label", "dinhelpline");
@@ -468,11 +466,11 @@ LPEMeasureLine::createLine(Geom::Point start,Geom::Point end, Glib::ustring id,
if (line_group_05) {
double stroke_width = Inkscape::Util::Quantity::convert(0.25 / doc_scale, "mm", display_unit.c_str());
stroke_w << stroke_width;
- style = style + (Glib::ustring)"stroke-width:" + (Glib::ustring)stroke_w.str();
+ style = style + Glib::ustring("stroke-width:" + stroke_w.str());
} else {
double stroke_width = Inkscape::Util::Quantity::convert(0.35 / doc_scale, "mm", display_unit.c_str());
stroke_w << stroke_width;
- style = style + (Glib::ustring)"stroke-width:" + (Glib::ustring)stroke_w.str();
+ style = style + Glib::ustring("stroke-width:" + stroke_w.str());
}
SPCSSAttr *css = sp_repr_css_attr_new();
sp_repr_css_attr_add_from_string(css, style.c_str());
@@ -485,17 +483,17 @@ LPEMeasureLine::createLine(Geom::Point start,Geom::Point end, Glib::ustring id,
sp_repr_css_write_string(css,css_str);
line->setAttribute("style", css_str.c_str());
if (!elemref) {
- elemref = container->appendChildRepr(line);
+ elemref = sp_lpe_item->parent->appendChildRepr(line);
Inkscape::GC::release(line);
- } else if (elemref->parent != container) {
+ } else if (elemref->parent != sp_lpe_item->parent) {
Inkscape::XML::Node *old_repr = elemref->getRepr();
Inkscape::XML::Node *copy = old_repr->duplicate(xml_doc);
- SPObject * elemref_copy = container->appendChildRepr(copy);
+ SPObject * elemref_copy = sp_lpe_item->parent->appendChildRepr(copy);
Inkscape::GC::release(copy);
elemref->deleteObject();
- copy->setAttribute("id", id.c_str());
+ copy->setAttribute("id", id);
}
- ml_elements.push_back(id);
+ elements.push_back(id);
}
}
@@ -513,7 +511,7 @@ void
LPEMeasureLine::doBeforeEffect (SPLPEItem const* lpeitem)
{
SPLPEItem * splpeitem = const_cast<SPLPEItem *>(lpeitem);
- container = dynamic_cast<SPObject *>(splpeitem->parent);
+ sp_lpe_item->parent = dynamic_cast<SPObject *>(splpeitem->parent);
SPDocument * doc = SP_ACTIVE_DOCUMENT;
Inkscape::XML::Node *root = splpeitem->document->getReprRoot();
Inkscape::XML::Node *root_origin = doc->getReprRoot();
@@ -527,26 +525,29 @@ LPEMeasureLine::doBeforeEffect (SPLPEItem const* lpeitem)
Geom::Affine writed_transform = Geom::identity();
sp_svg_transform_read(splpeitem->getAttribute("transform"), &writed_transform );
pathvector *= writed_transform;
- if (arrows_outside) {
- createArrowMarker((Glib::ustring)"ArrowDINout-start");
- createArrowMarker((Glib::ustring)"ArrowDINout-end");
- } else {
- createArrowMarker((Glib::ustring)"ArrowDIN-start");
- createArrowMarker((Glib::ustring)"ArrowDIN-end");
- }
if (SPDesktop *desktop = SP_ACTIVE_DESKTOP) {
- if (((Glib::ustring)format.param_getSVGValue()).empty()) {
- format.param_setValue((Glib::ustring)"{measure}{unit}");
+ if ((Glib::ustring(format.param_getSVGValue()).empty())) {
+ format.param_setValue(Glib::ustring("{measure}{unit}"));
this->upd_params = true;
}
size_t ncurves = pathvector.curveCount();
- curve_linked.param_set_range(0, ncurves);
+ if (ncurves != (size_t)curve_linked.param_get_max()) {
+ curve_linked.param_set_range(0, ncurves);
+ }
Geom::Point start = pathvector.initialPoint();
Geom::Point end = pathvector.finalPoint();
if (curve_linked) { //!0
start = pathvector.pointAt(curve_linked -1);
end = pathvector.pointAt(curve_linked);
}
+ if (Geom::are_near(start, start_stored, 0.01) &&
+ Geom::are_near(end, end_stored, 0.01) &&
+ sp_lpe_item->getCurrentLPE() != this){
+ return;
+ }
+ elements.clear();
+ start_stored = start;
+ end_stored = end;
Geom::Point hstart = start;
Geom::Point hend = end;
bool remove = false;
@@ -591,8 +592,15 @@ LPEMeasureLine::doBeforeEffect (SPLPEItem const* lpeitem)
angle = std::fmod(angle + rad_from_deg(180), 2*M_PI);
if (angle < 0) angle += 2*M_PI;
}
+ if (arrows_outside) {
+ createArrowMarker("ArrowDINout-start");
+ createArrowMarker("ArrowDINout-end");
+ } else {
+ createArrowMarker("ArrowDIN-start");
+ createArrowMarker("ArrowDIN-end");
+ }
//We get the font size to offset the text to the middle
- Pango::FontDescription fontdesc((Glib::ustring)fontbutton.param_getSVGValue());
+ Pango::FontDescription fontdesc(Glib::ustring(fontbutton.param_getSVGValue()));
fontsize = fontdesc.get_size()/(double)Pango::SCALE;
fontsize *= desktop->doc()->getRoot()->c2p.inverse().expansionX();
Geom::Coord angle_cross = std::fmod(angle + rad_from_deg(90), 2*M_PI);
@@ -614,6 +622,7 @@ LPEMeasureLine::doBeforeEffect (SPLPEItem const* lpeitem)
createTextLabel(pos, length, angle, remove, true);
}
bool overflow = false;
+ const char * downline = g_strdup(Glib::ustring("downline-").append(this->getRepr()->attribute("id")).c_str());
if ((anotation_width/2) + std::abs(text_right_left) > Geom::distance(start,end)/2.0) {
Geom::Point sstart = end - Point::polar(angle_cross, position);
Geom::Point send = end - Point::polar(angle_cross, position);
@@ -636,10 +645,10 @@ LPEMeasureLine::doBeforeEffect (SPLPEItem const* lpeitem)
}
}
overflow = true;
- createLine(sstart, prog_end, (Glib::ustring)"downline-" + (Glib::ustring)this->getRepr()->attribute("id"), true, overflow, false, false);
+ createLine(sstart, prog_end, downline, true, overflow, false, false);
} else {
//erase it
- createLine(Geom::Point(),Geom::Point(), (Glib::ustring)"downline-" + (Glib::ustring)this->getRepr()->attribute("id"), true, overflow, true, false);
+ createLine(Geom::Point(),Geom::Point(), downline, true, overflow, true, false);
}
//LINE
arrow_gap = 8 * Inkscape::Util::Quantity::convert(0.35 / doc_scale, "mm", display_unit.c_str());
@@ -658,17 +667,15 @@ LPEMeasureLine::doBeforeEffect (SPLPEItem const* lpeitem)
arrow_gap *= -1;
}
hstart = hstart - Point::polar(angle_cross, position);
- Glib::ustring id = (Glib::ustring)"infoline-on-start-" + (Glib::ustring)this->getRepr()->attribute("id");
- createLine(start, hstart, id, false, false, remove);
+ createLine(start, hstart, g_strdup(Glib::ustring("infoline-on-start-").append(this->getRepr()->attribute("id")).c_str()), false, false, remove);
hend = hend - Point::polar(angle_cross, position);
- id = (Glib::ustring)"infoline-on-end-" + (Glib::ustring)this->getRepr()->attribute("id");
- createLine(end, hend, id, false, false, remove);
+ createLine(end, hend, g_strdup(Glib::ustring("infoline-on-end-").append(this->getRepr()->attribute("id")).c_str()), false, false, remove);
if (!arrows_outside) {
hstart = hstart + Point::polar(angle, arrow_gap);
hend = hend - Point::polar(angle, arrow_gap );
}
- id = (Glib::ustring)"infoline-" + (Glib::ustring)this->getRepr()->attribute("id");
- createLine(hstart, hend, id, true, overflow, remove, true);
+ createLine(hstart, hend, g_strdup(Glib::ustring("infoline-").append(this->getRepr()->attribute("id")).c_str()), true, overflow, remove, true);
+
}
}
}
@@ -685,7 +692,7 @@ LPEMeasureLine::doOnRemove (SPLPEItem const* /*lpeitem*/)
{
if (!erase_extra_objects) {
processObjects(LPE_TO_OBJECTS);
- ml_elements.clear();
+ elements.clear();
return;
}
processObjects(LPE_ERASE);
@@ -696,10 +703,11 @@ LPEMeasureLine::processObjects(LpeAction lpe_action)
{
if (SPDesktop *desktop = SP_ACTIVE_DESKTOP) {
- for (std::vector<Glib::ustring>::iterator el_it = ml_elements.begin();
- el_it != ml_elements.end();++el_it) {
- Glib::ustring id = *el_it;
- Inkscape::URI SVGElem_uri(((Glib::ustring)"#" + id).c_str());
+ for (std::vector<const char *>::const_iterator el_it = elements.begin();
+ el_it != elements.end();++el_it) {
+ const char * id = (const char *)(*el_it);
+ std::cout << id << "asdfffgasdfasdsdgf\n";
+ Inkscape::URI SVGElem_uri(Glib::ustring("#").append(id).c_str());
Inkscape::URIReference* SVGElemRef = new Inkscape::URIReference(desktop->doc());
SVGElemRef->attach(SVGElem_uri);
SPObject *elemref = NULL;
@@ -722,7 +730,7 @@ LPEMeasureLine::processObjects(LpeAction lpe_action)
}
}
if (lpe_action == LPE_ERASE) {
- ml_elements.clear();
+ elements.clear();
}
}
}
@@ -800,19 +808,19 @@ void
LPEMeasureLine::saveDefault()
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- prefs->setString("/live_effects/measure-line/fontbutton", (Glib::ustring)fontbutton.param_getSVGValue());
+ prefs->setString("/live_effects/measure-line/fontbutton", Glib::ustring(fontbutton.param_getSVGValue()));
prefs->setDouble("/live_effects/measure-line/scale", scale);
prefs->setInt("/live_effects/measure-line/precision", precision);
prefs->setDouble("/live_effects/measure-line/position", position);
prefs->setDouble("/live_effects/measure-line/text_top_bottom", text_top_bottom);
prefs->setDouble("/live_effects/measure-line/helpline_distance", helpline_distance);
prefs->setDouble("/live_effects/measure-line/helpline_overlap", helpline_overlap);
- prefs->setString("/live_effects/measure-line/unit", (Glib::ustring)unit.get_abbreviation());
- prefs->setString("/live_effects/measure-line/format", (Glib::ustring)format.param_getSVGValue());
- prefs->setString("/live_effects/measure-line/dimline_format", (Glib::ustring)dimline_format.param_getSVGValue());
- prefs->setString("/live_effects/measure-line/helperlines_format", (Glib::ustring)helperlines_format.param_getSVGValue());
- prefs->setString("/live_effects/measure-line/anotation_format", (Glib::ustring)anotation_format.param_getSVGValue());
- prefs->setString("/live_effects/measure-line/arrows_format", (Glib::ustring)arrows_format.param_getSVGValue());
+ prefs->setString("/live_effects/measure-line/unit", Glib::ustring(unit.get_abbreviation()));
+ prefs->setString("/live_effects/measure-line/format", Glib::ustring(format.param_getSVGValue()));
+ prefs->setString("/live_effects/measure-line/dimline_format", Glib::ustring(dimline_format.param_getSVGValue()));
+ prefs->setString("/live_effects/measure-line/helperlines_format", Glib::ustring(helperlines_format.param_getSVGValue()));
+ prefs->setString("/live_effects/measure-line/anotation_format", Glib::ustring(anotation_format.param_getSVGValue()));
+ prefs->setString("/live_effects/measure-line/arrows_format", Glib::ustring(arrows_format.param_getSVGValue()));
prefs->setBool("/live_effects/measure-line/flip_side", flip_side);
prefs->setBool("/live_effects/measure-line/scale_sensitive", scale_sensitive);
prefs->setBool("/live_effects/measure-line/local_locale", local_locale);
diff --git a/src/live_effects/lpe-measure-line.h b/src/live_effects/lpe-measure-line.h
index d668fbd30..d680282a5 100644
--- a/src/live_effects/lpe-measure-line.h
+++ b/src/live_effects/lpe-measure-line.h
@@ -39,13 +39,14 @@ public:
virtual void doBeforeEffect (SPLPEItem const* lpeitem);
virtual void doOnApply(SPLPEItem const* lpeitem);
virtual void doOnRemove (SPLPEItem const* /*lpeitem*/);
+ virtual void doEffect (SPCurve * curve){}; //stop the chain
virtual void doOnVisibilityToggled(SPLPEItem const* /*lpeitem*/);
virtual Geom::PathVector doEffect_path(Geom::PathVector const &path_in);
void processObjects(LpeAction lpe_action);
- void createLine(Geom::Point start,Geom::Point end,Glib::ustring id, bool main, bool overflow, bool remove, bool arrows = false);
+ void createLine(Geom::Point start,Geom::Point end, const char * id, bool main, bool overflow, bool remove, bool arrows = false);
void createTextLabel(Geom::Point pos, double length, Geom::Coord angle, bool remove, bool valid);
void onExpanderChanged();
- void createArrowMarker(Glib::ustring mode);
+ void createArrowMarker(const char * mode);
void saveDefault();
virtual Gtk::Widget *newWidget();
private:
@@ -79,7 +80,9 @@ private:
double fontsize;
double anotation_width;
double arrow_gap;
-
+ Geom::Point start_stored;
+ Geom::Point end_stored;
+ std::vector<const char *> elements;
/* Geom::Affine affine_over;*/
LPEMeasureLine(const LPEMeasureLine &);
LPEMeasureLine &operator=(const LPEMeasureLine &);
diff --git a/src/live_effects/lpe-path_length.cpp b/src/live_effects/lpe-path_length.cpp
index 8fbf9d420..6ec1e0ede 100644
--- a/src/live_effects/lpe-path_length.cpp
+++ b/src/live_effects/lpe-path_length.cpp
@@ -37,12 +37,6 @@ LPEPathLength::~LPEPathLength()
}
-void
-LPEPathLength::hideCanvasText() {
- // this is only used in sp-lpe-item.cpp to hide the canvas text when the effect is invisible
- info_text.param_setValue("");
-}
-
Geom::Piecewise<Geom::D2<Geom::SBasis> >
LPEPathLength::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in)
{
@@ -69,7 +63,9 @@ LPEPathLength::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & p
//g_print ("Area is zero\n");
}
//g_print ("Area: %f\n", area);
-
+ if (!this->isVisible()) {
+ info_text.param_setValue("");
+ }
return pwd2_in;
}
diff --git a/src/live_effects/lpe-path_length.h b/src/live_effects/lpe-path_length.h
index e108e770a..14d093c09 100644
--- a/src/live_effects/lpe-path_length.h
+++ b/src/live_effects/lpe-path_length.h
@@ -29,8 +29,6 @@ public:
virtual Geom::Piecewise<Geom::D2<Geom::SBasis> > doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in);
- void hideCanvasText();
-
private:
LPEPathLength(const LPEPathLength&);
LPEPathLength& operator=(const LPEPathLength&);
diff --git a/src/live_effects/parameter/parameter.h b/src/live_effects/parameter/parameter.h
index 3658bded8..5dbcb7868 100644
--- a/src/live_effects/parameter/parameter.h
+++ b/src/live_effects/parameter/parameter.h
@@ -118,6 +118,8 @@ public:
void param_set_digits(unsigned digits);
void param_set_increments(double step, double page);
void addSlider(bool add_slider_widget) { add_slider = add_slider_widget; };
+ double param_get_max() { return max; };
+ double param_get_min() { return min; };
void param_overwrite_widget(bool overwrite_widget);
virtual Gtk::Widget * param_newWidget();
diff --git a/src/live_effects/parameter/text.cpp b/src/live_effects/parameter/text.cpp
index 0650b7e66..8cab68ad0 100644
--- a/src/live_effects/parameter/text.cpp
+++ b/src/live_effects/parameter/text.cpp
@@ -110,7 +110,10 @@ TextParam::param_readSVGValue(const gchar * strvalue)
gchar *
TextParam::param_getSVGValue() const
{
- return g_strdup(value.c_str());
+ Inkscape::SVGOStringStream os;
+ os << value;
+ gchar * str = g_strdup(os.str().c_str());
+ return str;
}
Gtk::Widget *
diff --git a/src/sp-lpe-item.cpp b/src/sp-lpe-item.cpp
index ae29137e6..872a88289 100644
--- a/src/sp-lpe-item.cpp
+++ b/src/sp-lpe-item.cpp
@@ -289,22 +289,6 @@ sp_lpe_item_update_patheffect (SPLPEItem *lpeitem, bool wholetree, bool write)
if (!lpeitem->pathEffectsEnabled())
return;
- // TODO: hack! this will be removed when path length measuring is reimplemented in a better way
- PathEffectList lpelist = lpeitem->getEffectList();
- std::list<Inkscape::LivePathEffect::LPEObjectReference *>::iterator i;
- for (i = lpelist.begin(); i != lpelist.end(); ++i) {
- if ((*i)->lpeobject) {
- Inkscape::LivePathEffect::Effect *lpe = (*i)->lpeobject->get_lpe();
- if (dynamic_cast<Inkscape::LivePathEffect::LPEPathLength *>(lpe)) {
- if (!lpe->isVisible()) {
- // we manually disable text for LPEPathLength
- // use static_cast, because we already checked for the right type above
- static_cast<Inkscape::LivePathEffect::LPEPathLength *>(lpe)->hideCanvasText();
- }
- }
- }
- }
-
SPLPEItem *top = NULL;
if (wholetree) {
diff --git a/src/sp-mesh-array.cpp b/src/sp-mesh-array.cpp
index e4877d5c9..f2604976e 100644
--- a/src/sp-mesh-array.cpp
+++ b/src/sp-mesh-array.cpp
@@ -1478,11 +1478,8 @@ void SPMeshNodeArray::clear() {
delete nodes[i][j];
}
}
- for( guint i = 0; i < nodes.size(); ++i ) {
- nodes[i].clear();
- }
- nodes.clear();
}
+ nodes.clear();
};
diff --git a/src/sp-path.cpp b/src/sp-path.cpp
index a7119dd31..b593b7937 100644
--- a/src/sp-path.cpp
+++ b/src/sp-path.cpp
@@ -187,35 +187,35 @@ void SPPath::release() {
void SPPath::set(unsigned int key, const gchar* value) {
switch (key) {
case SP_ATTR_INKSCAPE_ORIGINAL_D:
- if (value) {
- Geom::PathVector pv = sp_svg_read_pathv(value);
- SPCurve *curve = new SPCurve(pv);
-
- if (curve) {
- this->set_original_curve(curve, TRUE, true);
- curve->unref();
- }
- } else {
- this->set_original_curve(NULL, TRUE, true);
- }
-
- this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
+ if (value) {
+ Geom::PathVector pv = sp_svg_read_pathv(value);
+ SPCurve *curve = new SPCurve(pv);
+
+ if (curve) {
+ this->set_original_curve(curve, TRUE, true);
+ curve->unref();
+ }
+ } else {
+ this->set_original_curve(NULL, TRUE, true);
+ }
+
+ this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
break;
case SP_ATTR_D:
- if (value) {
- Geom::PathVector pv = sp_svg_read_pathv(value);
- SPCurve *curve = new SPCurve(pv);
-
- if (curve) {
- this->setCurve(curve, TRUE);
- curve->unref();
- }
- } else {
- this->setCurve(NULL, TRUE);
- }
-
- this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
+ if (value) {
+ Geom::PathVector pv = sp_svg_read_pathv(value);
+ SPCurve *curve = new SPCurve(pv);
+
+ if (curve) {
+ this->setCurve(curve, TRUE);
+ curve->unref();
+ }
+ } else {
+ this->setCurve(NULL, TRUE);
+ }
+
+ this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
break;
case SP_PROP_MARKER:
@@ -276,13 +276,13 @@ g_message("sp_path_write writes 'd' attribute");
}
void SPPath::update(SPCtx *ctx, guint flags) {
- if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) {
- flags &= ~SP_OBJECT_USER_MODIFIED_FLAG_B; // since we change the description, it's not a "just translation" anymore
- }
+ if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) {
+ flags &= ~SP_OBJECT_USER_MODIFIED_FLAG_B; // since we change the description, it's not a "just translation" anymore
+ }
- SPShape::update(ctx, flags);
+ SPShape::update(ctx, flags);
- this->connEndPair.update();
+ this->connEndPair.update();
}
Geom::Affine SPPath::set_transform(Geom::Affine const &transform) {
diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp
index f316bea38..75b507a57 100644
--- a/src/ui/tool/path-manipulator.cpp
+++ b/src/ui/tool/path-manipulator.cpp
@@ -1493,10 +1493,14 @@ void PathManipulator::_setGeometry()
} else {
if (empty()) return;
//XML Tree being used here directly while it shouldn't be.
- if (_path->getRepr()->attribute("inkscape:original-d"))
- _path->set_original_curve(_spcurve, false, false);
- else
+ if (SPCurve * original = _path->get_original_curve()){
+ if(!_spcurve->is_equal(original)) {
+ _path->set_original_curve(_spcurve, false, false);
+ delete original;
+ }
+ } else if(!_spcurve->is_equal(_path->get_curve())) {
_path->setCurve(_spcurve, false);
+ }
}
}