summaryrefslogtreecommitdiffstats
path: root/src/live_effects/parameter
diff options
context:
space:
mode:
authorMichael Soegtrop <MSoegtrop@yahoo.de>2017-06-05 13:01:17 +0000
committerMichael Soegtrop <MSoegtrop@yahoo.de>2017-06-05 13:01:17 +0000
commite7248b2fa042f42a5c4dd14cd86ab6a5b4524059 (patch)
tree9097520c54e355ded9bd0b4d6618af4e8dacdd91 /src/live_effects/parameter
parentupdated to latest trunk (diff)
parent[Bug #1695016] Xaml export misses some radialGradients. (diff)
downloadinkscape-e7248b2fa042f42a5c4dd14cd86ab6a5b4524059.tar.gz
inkscape-e7248b2fa042f42a5c4dd14cd86ab6a5b4524059.zip
updated to latest trunk
(bzr r14876.2.4)
Diffstat (limited to 'src/live_effects/parameter')
-rw-r--r--src/live_effects/parameter/Makefile_insert36
-rw-r--r--src/live_effects/parameter/array.cpp44
-rw-r--r--src/live_effects/parameter/array.h41
-rw-r--r--src/live_effects/parameter/bool.cpp22
-rw-r--r--src/live_effects/parameter/bool.h8
-rw-r--r--src/live_effects/parameter/enum.h21
-rw-r--r--src/live_effects/parameter/filletchamferpointarray.cpp877
-rw-r--r--src/live_effects/parameter/filletchamferpointarray.h123
-rw-r--r--src/live_effects/parameter/fontbutton.cpp97
-rw-r--r--src/live_effects/parameter/fontbutton.h61
-rw-r--r--src/live_effects/parameter/hidden.cpp90
-rw-r--r--src/live_effects/parameter/hidden.h69
-rw-r--r--src/live_effects/parameter/item-reference.cpp44
-rw-r--r--src/live_effects/parameter/item-reference.h56
-rw-r--r--src/live_effects/parameter/item.cpp253
-rw-r--r--src/live_effects/parameter/item.h80
-rw-r--r--src/live_effects/parameter/originalitem.cpp129
-rw-r--r--src/live_effects/parameter/originalitem.h49
-rw-r--r--src/live_effects/parameter/originalpath.cpp4
-rw-r--r--src/live_effects/parameter/originalpatharray.cpp4
-rw-r--r--src/live_effects/parameter/originalpatharray.h3
-rw-r--r--src/live_effects/parameter/parameter.cpp43
-rw-r--r--src/live_effects/parameter/parameter.h22
-rw-r--r--src/live_effects/parameter/path.cpp128
-rw-r--r--src/live_effects/parameter/path.h7
-rw-r--r--src/live_effects/parameter/point.cpp45
-rw-r--r--src/live_effects/parameter/point.h9
-rw-r--r--src/live_effects/parameter/powerstrokepointarray.cpp4
-rw-r--r--src/live_effects/parameter/powerstrokepointarray.h4
-rw-r--r--src/live_effects/parameter/random.cpp15
-rw-r--r--src/live_effects/parameter/random.h4
-rw-r--r--src/live_effects/parameter/satellitesarray.cpp584
-rw-r--r--src/live_effects/parameter/satellitesarray.h114
-rw-r--r--src/live_effects/parameter/text.cpp61
-rw-r--r--src/live_effects/parameter/text.h8
-rw-r--r--src/live_effects/parameter/togglebutton.cpp96
-rw-r--r--src/live_effects/parameter/togglebutton.h10
-rw-r--r--src/live_effects/parameter/transformedpoint.cpp19
-rw-r--r--src/live_effects/parameter/transformedpoint.h4
-rw-r--r--src/live_effects/parameter/unit.cpp7
-rw-r--r--src/live_effects/parameter/unit.h4
-rw-r--r--src/live_effects/parameter/vector.cpp28
-rw-r--r--src/live_effects/parameter/vector.h5
43 files changed, 2096 insertions, 1236 deletions
diff --git a/src/live_effects/parameter/Makefile_insert b/src/live_effects/parameter/Makefile_insert
deleted file mode 100644
index bd1c5b600..000000000
--- a/src/live_effects/parameter/Makefile_insert
+++ /dev/null
@@ -1,36 +0,0 @@
-## Makefile.am fragment sourced by src/Makefile.am.
-
-ink_common_sources += \
- live_effects/parameter/parameter.cpp \
- live_effects/parameter/parameter.h \
- live_effects/parameter/array.cpp \
- live_effects/parameter/array.h \
- live_effects/parameter/bool.cpp \
- live_effects/parameter/bool.h \
- live_effects/parameter/random.cpp \
- live_effects/parameter/random.h \
- live_effects/parameter/point.cpp \
- live_effects/parameter/point.h \
- live_effects/parameter/enum.h \
- live_effects/parameter/path-reference.cpp \
- live_effects/parameter/path-reference.h \
- live_effects/parameter/path.cpp \
- live_effects/parameter/path.h \
- live_effects/parameter/originalpath.cpp \
- live_effects/parameter/originalpath.h \
- live_effects/parameter/originalpatharray.cpp \
- live_effects/parameter/originalpatharray.h \
- live_effects/parameter/powerstrokepointarray.cpp \
- live_effects/parameter/powerstrokepointarray.h \
- live_effects/parameter/filletchamferpointarray.cpp \
- live_effects/parameter/filletchamferpointarray.h \
- live_effects/parameter/text.cpp \
- live_effects/parameter/text.h \
- live_effects/parameter/transformedpoint.cpp \
- live_effects/parameter/transformedpoint.h \
- live_effects/parameter/togglebutton.cpp \
- live_effects/parameter/togglebutton.h \
- live_effects/parameter/unit.cpp \
- live_effects/parameter/unit.h \
- live_effects/parameter/vector.cpp \
- live_effects/parameter/vector.h
diff --git a/src/live_effects/parameter/array.cpp b/src/live_effects/parameter/array.cpp
index 1b8f742da..7470f54cd 100644
--- a/src/live_effects/parameter/array.cpp
+++ b/src/live_effects/parameter/array.cpp
@@ -5,10 +5,7 @@
*/
#include "live_effects/parameter/array.h"
-
-#include "svg/svg.h"
-#include "svg/stringstream.h"
-
+#include "helper-fns.h"
#include <2geom/coord.h>
#include <2geom/point.h>
@@ -49,6 +46,45 @@ ArrayParam<Geom::Point>::readsvg(const gchar * str)
return Geom::Point(Geom::infinity(),Geom::infinity());
}
+
+template <>
+std::vector<Satellite>
+ArrayParam<std::vector<Satellite > >::readsvg(const gchar * str)
+{
+ std::vector<Satellite> subpath_satellites;
+ if (!str) {
+ return subpath_satellites;
+ }
+ gchar ** strarray = g_strsplit(str, "@", 0);
+ gchar ** iter = strarray;
+ while (*iter != NULL) {
+ gchar ** strsubarray = g_strsplit(*iter, ",", 8);
+ if (*strsubarray[7]) {//steps always > 0
+ Satellite *satellite = new Satellite();
+ satellite->setSatelliteType(g_strstrip(strsubarray[0]));
+ satellite->is_time = strncmp(strsubarray[1],"1",1) == 0;
+ satellite->selected = strncmp(strsubarray[2],"1",1) == 0;
+ satellite->has_mirror = strncmp(strsubarray[3],"1",1) == 0;
+ satellite->hidden = strncmp(strsubarray[4],"1",1) == 0;
+ double amount,angle;
+ float stepsTmp;
+ sp_svg_number_read_d(strsubarray[5], &amount);
+ sp_svg_number_read_d(strsubarray[6], &angle);
+ sp_svg_number_read_f(g_strstrip(strsubarray[7]), &stepsTmp);
+ unsigned int steps = (unsigned int)stepsTmp;
+ satellite->amount = amount;
+ satellite->angle = angle;
+ satellite->steps = steps;
+ subpath_satellites.push_back(*satellite);
+ }
+ g_strfreev (strsubarray);
+ iter++;
+ }
+ g_strfreev (strarray);
+ return subpath_satellites;
+}
+
+
} /* namespace LivePathEffect */
} /* namespace Inkscape */
diff --git a/src/live_effects/parameter/array.h b/src/live_effects/parameter/array.h
index a600f0257..e65d3b55c 100644
--- a/src/live_effects/parameter/array.h
+++ b/src/live_effects/parameter/array.h
@@ -15,6 +15,7 @@
#include "live_effects/parameter/parameter.h"
+#include "helper/geom-satellite.h"
#include "svg/svg.h"
#include "svg/stringstream.h"
@@ -59,7 +60,7 @@ public:
g_strfreev (strarray);
return true;
}
-
+ virtual void param_update_default(const gchar * default_value){};
virtual gchar * param_getSVGValue() const {
Inkscape::SVGOStringStream os;
writesvg(os, _vector);
@@ -93,7 +94,43 @@ protected:
// separate items with pipe symbol
str << " | ";
}
- str << vector[i];
+ writesvgData(str,vector[i]);
+ }
+ }
+
+ void writesvgData(SVGOStringStream &str, float const &vector_data) const {
+ str << vector_data;
+ }
+
+ void writesvgData(SVGOStringStream &str, double const &vector_data) const {
+ str << vector_data;
+ }
+
+ void writesvgData(SVGOStringStream &str, Geom::Point const &vector_data) const {
+ str << vector_data;
+ }
+
+ void writesvgData(SVGOStringStream &str, std::vector<Satellite> const &vector_data) const {
+ for (size_t i = 0; i < vector_data.size(); ++i) {
+ if (i != 0) {
+ // separate items with @ symbol ¿Any other?
+ str << " @ ";
+ }
+ str << vector_data[i].getSatelliteTypeGchar();
+ str << ",";
+ str << vector_data[i].is_time;
+ str << ",";
+ str << vector_data[i].selected;
+ str << ",";
+ str << vector_data[i].has_mirror;
+ str << ",";
+ str << vector_data[i].hidden;
+ str << ",";
+ str << vector_data[i].amount;
+ str << ",";
+ str << vector_data[i].angle;
+ str << ",";
+ str << static_cast<int>(vector_data[i].steps);
}
}
diff --git a/src/live_effects/parameter/bool.cpp b/src/live_effects/parameter/bool.cpp
index 9ecadbdeb..954947cf4 100644
--- a/src/live_effects/parameter/bool.cpp
+++ b/src/live_effects/parameter/bool.cpp
@@ -21,8 +21,8 @@ namespace LivePathEffect {
BoolParam::BoolParam( const Glib::ustring& label, const Glib::ustring& tip,
const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr,
- Effect* effect, bool default_value , bool no_widget)
- : Parameter(label, tip, key, wr, effect), value(default_value), defvalue(default_value), hide_widget(no_widget)
+ Effect* effect, bool default_value)
+ : Parameter(label, tip, key, wr, effect), value(default_value), defvalue(default_value)
{
}
@@ -36,6 +36,18 @@ BoolParam::param_set_default()
param_setValue(defvalue);
}
+void
+BoolParam::param_update_default(bool const default_value)
+{
+ defvalue = default_value;
+}
+
+void
+BoolParam::param_update_default(const gchar * default_value)
+{
+ param_update_default(helperfns_read_bool(default_value, defvalue));
+}
+
bool
BoolParam::param_readSVGValue(const gchar * strvalue)
{
@@ -53,7 +65,7 @@ BoolParam::param_getSVGValue() const
Gtk::Widget *
BoolParam::param_newWidget()
{
- if(!hide_widget){
+ if(widget_is_visible){
Inkscape::UI::Widget::RegisteredCheckButton * checkwdg = Gtk::manage(
new Inkscape::UI::Widget::RegisteredCheckButton( param_label,
param_tooltip,
@@ -66,7 +78,6 @@ BoolParam::param_newWidget()
checkwdg->setActive(value);
checkwdg->setProgrammatically = false;
checkwdg->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change bool parameter"));
-
return dynamic_cast<Gtk::Widget *> (checkwdg);
} else {
return NULL;
@@ -76,6 +87,9 @@ BoolParam::param_newWidget()
void
BoolParam::param_setValue(bool newvalue)
{
+ if (value != newvalue) {
+ param_effect->upd_params = true;
+ }
value = newvalue;
}
diff --git a/src/live_effects/parameter/bool.h b/src/live_effects/parameter/bool.h
index 403dd0b87..417752050 100644
--- a/src/live_effects/parameter/bool.h
+++ b/src/live_effects/parameter/bool.h
@@ -25,8 +25,7 @@ public:
const Glib::ustring& key,
Inkscape::UI::Widget::Registry* wr,
Effect* effect,
- bool default_value = false,
- bool no_widget = false);
+ bool default_value = false);
virtual ~BoolParam();
virtual Gtk::Widget * param_newWidget();
@@ -36,9 +35,9 @@ public:
void param_setValue(bool newvalue);
virtual void param_set_default();
-
+ void param_update_default(bool const default_value);
+ virtual void param_update_default(const gchar * default_value);
bool get_value() const { return value; };
-
inline operator bool() const { return value; };
private:
@@ -47,7 +46,6 @@ private:
bool value;
bool defvalue;
- bool hide_widget;
};
diff --git a/src/live_effects/parameter/enum.h b/src/live_effects/parameter/enum.h
index 2340663c3..78fa87a4f 100644
--- a/src/live_effects/parameter/enum.h
+++ b/src/live_effects/parameter/enum.h
@@ -27,12 +27,14 @@ public:
const Util::EnumDataConverter<E>& c,
Inkscape::UI::Widget::Registry* wr,
Effect* effect,
- E default_value)
+ E default_value,
+ bool sort = true)
: Parameter(label, tip, key, wr, effect)
{
enumdataconv = &c;
defvalue = default_value;
value = defvalue;
+ sorted = sort;
};
virtual ~EnumParam() { };
@@ -40,12 +42,11 @@ public:
virtual Gtk::Widget * param_newWidget() {
Inkscape::UI::Widget::RegisteredEnum<E> *regenum = Gtk::manage (
new Inkscape::UI::Widget::RegisteredEnum<E>( param_label, param_tooltip,
- param_key, *enumdataconv, *param_wr, param_effect->getRepr(), param_effect->getSPDoc() ) );
+ param_key, *enumdataconv, *param_wr, param_effect->getRepr(), param_effect->getSPDoc(), sorted ) );
regenum->set_active_by_id(value);
regenum->combobox()->setProgrammatically = false;
regenum->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change enumeration parameter"));
-
return dynamic_cast<Gtk::Widget *> (regenum);
};
@@ -75,8 +76,19 @@ public:
void param_set_default() {
param_set_value(defvalue);
}
-
+
+ void param_update_default(E default_value) {
+ defvalue = default_value;
+ }
+
+ virtual void param_update_default(const gchar * default_value) {
+ param_update_default(enumdataconv->get_id_from_key(Glib::ustring(default_value)));
+ }
+
void param_set_value(E val) {
+ if (value != val) {
+ param_effect->upd_params = true;
+ }
value = val;
}
@@ -86,6 +98,7 @@ private:
E value;
E defvalue;
+ bool sorted;
const Util::EnumDataConverter<E> * enumdataconv;
};
diff --git a/src/live_effects/parameter/filletchamferpointarray.cpp b/src/live_effects/parameter/filletchamferpointarray.cpp
deleted file mode 100644
index b321a5831..000000000
--- a/src/live_effects/parameter/filletchamferpointarray.cpp
+++ /dev/null
@@ -1,877 +0,0 @@
-/*
- * Copyright (C) Jabiertxo Arraiza Cenoz <jabier.arraiza@marker.es>
- * Special thanks to Johan Engelen for the base of the effect -powerstroke-
- * Also to ScislaC for point me to the idea
- * Also su_v for his construvtive feedback and time
- * and finaly to Liam P. White for his big help on coding, that save me a lot of
- * hours
- * Released under GNU GPL, read the file 'COPYING' for more information
- */
-
-#include <2geom/piecewise.h>
-#include <2geom/sbasis-to-bezier.h>
-#include <2geom/sbasis-geometric.h>
-#include <2geom/line.h>
-#include <2geom/path-intersection.h>
-
-#include "ui/dialog/lpe-fillet-chamfer-properties.h"
-#include "live_effects/parameter/filletchamferpointarray.h"
-#include "live_effects/effect.h"
-#include "svg/svg.h"
-#include "svg/stringstream.h"
-#include "knotholder.h"
-#include "sp-lpe-item.h"
-#include "selection.h"
-
-// needed for on-canvas editting:
-#include "desktop.h"
-#include "live_effects/lpeobject.h"
-#include "helper/geom-nodetype.h"
-#include "helper/geom-curves.h"
-#include "ui/tools/node-tool.h"
-
-// TODO due to internal breakage in glibmm headers,
-// this has to be included last.
-#include <glibmm/i18n.h>
-
-
-using namespace Geom;
-
-namespace Inkscape {
-
-namespace LivePathEffect {
-
-FilletChamferPointArrayParam::FilletChamferPointArrayParam(
- const Glib::ustring &label, const Glib::ustring &tip,
- const Glib::ustring &key, Inkscape::UI::Widget::Registry *wr,
- Effect *effect)
- : ArrayParam<Point>(label, tip, key, wr, effect, 0)
-{
- knot_shape = SP_KNOT_SHAPE_DIAMOND;
- knot_mode = SP_KNOT_MODE_XOR;
- knot_color = 0x00ff0000;
-}
-
-FilletChamferPointArrayParam::~FilletChamferPointArrayParam() {}
-
-Gtk::Widget *FilletChamferPointArrayParam::param_newWidget()
-{
- return NULL;
- /*
- Inkscape::UI::Widget::RegisteredTransformedPoint * pointwdg =
- Gtk::manage(
- new Inkscape::UI::Widget::RegisteredTransformedPoint(
- param_label,
- param_tooltip,
- param_key,
- *param_wr,
- param_effect->getRepr(),
- param_effect->getSPDoc()
- ) );
- // TODO: fix to get correct desktop (don't use SP_ACTIVE_DESKTOP)
- SPDesktop *desktop = SP_ACTIVE_DESKTOP;
- Affine transf = desktop->doc2dt();
- pointwdg->setTransform(transf);
- pointwdg->setValue( *this );
- pointwdg->clearProgrammatically();
- pointwdg->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT,
- _("Change point parameter"));
-
- Gtk::HBox * hbox = Gtk::manage( new Gtk::HBox() );
- static_cast<Gtk::HBox*>(hbox)->pack_start(*pointwdg, true, true);
- static_cast<Gtk::HBox*>(hbox)->show_all_children();
-
- return dynamic_cast<Gtk::Widget *> (hbox);
- */
-}
-
-void
-FilletChamferPointArrayParam::param_transform_multiply(Affine const &postmul,
- bool /*set*/)
-{
- Inkscape::Preferences *prefs = Inkscape::Preferences::get();
-
- if (prefs->getBool("/options/transform/rectcorners", true) &&
- _vector[1][X] <= 0) {
- std::vector<Geom::Point> result;
- for (std::vector<Point>::const_iterator point_it = _vector.begin();
- point_it != _vector.end(); ++point_it) {
- Coord A =
- (*point_it)[X] * ((postmul.expansionX() + postmul.expansionY()) / 2);
- result.push_back(Point(A, (*point_it)[Y]));
- }
- param_set_and_write_new_value(result);
- }
-
- // param_set_and_write_new_value( (*this) * postmul );
-}
-
-/** call this method to recalculate the controlpoints such that they stay at the
- * same location relative to the new path. Useful after adding/deleting nodes to
- * the path.*/
-void FilletChamferPointArrayParam::recalculate_controlpoints_for_new_pwd2(
- Piecewise<D2<SBasis> > const &pwd2_in)
-{
- if (!last_pwd2.empty()) {
- PathVector const pathv =
- path_from_piecewise(remove_short_cuts(pwd2_in, 0.1), 0.001);
- PathVector last_pathv =
- path_from_piecewise(remove_short_cuts(last_pwd2, 0.1), 0.001);
- std::vector<Point> result;
- unsigned long counter = 0;
- unsigned long counterPaths = 0;
- unsigned long counterCurves = 0;
- long offset = 0;
- long offsetPaths = 0;
- Geom::NodeType nodetype;
- for (PathVector::const_iterator path_it = pathv.begin();
- path_it != pathv.end(); ++path_it) {
- if (path_it->empty()) {
- counterPaths++;
- counter++;
- continue;
- }
- Geom::Path::const_iterator curve_it1 = path_it->begin();
- Geom::Path::const_iterator curve_it2 = ++(path_it->begin());
- Geom::Path::const_iterator curve_endit = path_it->end_default();
- if (path_it->closed() && path_it->back_closed().isDegenerate()) {
- const Curve &closingline = path_it->back_closed();
- if (are_near(closingline.initialPoint(), closingline.finalPoint())) {
- curve_endit = path_it->end_open();
- }
- }
- counterCurves = 0;
- while (curve_it1 != curve_endit) {
- //if start a path get node type
- if (counterCurves == 0) {
- if (path_it->closed()) {
- if (path_it->back_closed().isDegenerate()) {
- nodetype = get_nodetype(path_it->back_open(), *curve_it1);
- } else {
- nodetype = get_nodetype(path_it->back_closed(), *curve_it1);
- }
- } else {
- nodetype = NODE_NONE;
- }
- } else {
- //check node type also whith straight lines because get_nodetype
- //return non cusp node in a node inserted inside a straight line
- //todo: if the path remove some nodes whith the result of a straight
- //line but with handles, the node inserted into dont fire the knot
- // because is not handle as cusp node by get_nodetype function
- bool next_is_line = is_straight_curve(*curve_it1);
- bool this_is_line = is_straight_curve((*path_it)[counterCurves - 1]);
- nodetype = get_nodetype((*path_it)[counterCurves - 1], *curve_it1);
- if (this_is_line || next_is_line) {
- nodetype = NODE_CUSP;
- }
- }
- if (last_pathv.size() > pathv.size() ||
- (last_pathv.size() > counterPaths &&
- last_pathv[counterPaths].size() > counter - offset &&
- !are_near(curve_it1->initialPoint(),
- last_pathv[counterPaths][counter - offset].initialPoint(),
- 0.1))) {
- if ( curve_it2 == curve_endit) {
- if (last_pathv[counterPaths].size() != pathv[counterPaths].size()) {
- offset = (last_pathv[counterPaths].size() - pathv[counterPaths].size()) * -1;
- } else {
- offset = 0;
- }
- offsetPaths += offset;
- offset = offsetPaths;
- } else if (counterCurves == 0 && last_pathv.size() <= pathv.size() &&
- counter - offset <= last_pathv[counterPaths].size() &&
- are_near(curve_it1->initialPoint(),
- last_pathv[counterPaths].finalPoint(), 0.1) &&
- !last_pathv[counterPaths].closed()) {
- long e = counter - offset + 1;
- std::vector<Point> tmp = _vector;
- for (unsigned long i =
- last_pathv[counterPaths].size() + counter - offset;
- i > counterCurves - offset + 1; i--) {
-
- if (tmp[i - 1][X] > 0) {
- double fractpart, intpart;
- fractpart = modf(tmp[i - 1][X], &intpart);
- _vector[e] = Point(e + fractpart, tmp[i - 1][Y]);
- } else {
- _vector[e] = Point(tmp[i - 1][X], tmp[i - 1][Y]);
- }
- e++;
- }
- //delete temp vector
- std::vector<Point>().swap(tmp);
- if (last_pathv.size() > counterPaths) {
- last_pathv[counterPaths] = last_pathv[counterPaths].reversed();
- }
- } else {
- if (last_pathv.size() > counterPaths) {
- if (last_pathv[counterPaths].size() <
- pathv[counterPaths].size()) {
- offset++;
- } else if (last_pathv[counterPaths].size() >
- pathv[counterPaths].size()) {
- offset--;
- continue;
- }
- } else {
- offset++;
- }
- }
- double xPos = 0;
- if (_vector[1][X] > 0) {
- xPos = nearest_time(curve_it1->initialPoint(), pwd2_in);
- }
- if (nodetype == NODE_CUSP) {
- result.push_back(Point(xPos, 1));
- } else {
- result.push_back(Point(xPos, 0));
- }
- } else {
- double xPos = _vector[counter - offset][X];
- if (_vector.size() <= (unsigned)(counter - offset)) {
- if (_vector[1][X] > 0) {
- xPos = nearest_time(curve_it1->initialPoint(), pwd2_in);
- } else {
- xPos = 0;
- }
- }
- if (nodetype == NODE_CUSP) {
- double vectorY = _vector[counter - offset][Y];
- if (_vector.size() <= (unsigned)(counter - offset) || vectorY == 0) {
- vectorY = 1;
- }
- result.push_back(Point(xPos, vectorY));
- } else {
- if (_vector[1][X] < 0) {
- xPos = 0;
- }
- result.push_back(Point(floor(xPos), 0));
- }
- }
- ++curve_it1;
- if (curve_it2 != curve_endit) {
- ++curve_it2;
- }
- counter++;
- counterCurves++;
- }
- counterPaths++;
- }
- _vector = result;
- write_to_SVG();
- }
-}
-
-void FilletChamferPointArrayParam::recalculate_knots(
- Piecewise<D2<SBasis> > const &pwd2_in)
-{
- bool change = false;
- if(_vector.size() == 0){
- return;
- }
- PathVector pathv = path_from_piecewise(pwd2_in, 0.001);
- if (!pathv.empty()) {
- std::vector<Point> result;
- int counter = 0;
- int counterCurves = 0;
- Geom::NodeType nodetype;
- for (PathVector::const_iterator path_it = pathv.begin();
- path_it != pathv.end(); ++path_it) {
- if (path_it->empty()) {
- counter++;
- continue;
- }
- Geom::Path::const_iterator curve_it1 = path_it->begin();
- Geom::Path::const_iterator curve_it2 = ++(path_it->begin());
- Geom::Path::const_iterator curve_endit = path_it->end_default();
- if (path_it->closed() && path_it->back_closed().isDegenerate()) {
- const Curve &closingline = path_it->back_closed();
- if (are_near(closingline.initialPoint(), closingline.finalPoint())) {
- curve_endit = path_it->end_open();
- }
- }
- counterCurves = 0;
- while (curve_it1 != curve_endit) {
- //if start a path get node type
- if (counterCurves == 0) {
- if (path_it->closed()) {
- if (path_it->back_closed().isDegenerate()) {
- nodetype = get_nodetype(path_it->back_open(), *curve_it1);
- } else {
- nodetype = get_nodetype(path_it->back_closed(), *curve_it1);
- }
- } else {
- nodetype = NODE_NONE;
- }
- } else {
- bool next_is_line = is_straight_curve(*curve_it1);
- bool this_is_line = is_straight_curve((*path_it)[counterCurves - 1]);
- nodetype = get_nodetype((*path_it)[counterCurves - 1], *curve_it1);
- if (this_is_line || next_is_line) {
- nodetype = NODE_CUSP;
- }
- }
- if (nodetype == NODE_CUSP) {
- double vectorY = _vector[counter][Y];
- if (vectorY == 0) {
- vectorY = 1;
- change = true;
- }
- result.push_back(Point(_vector[counter][X], vectorY));
- } else {
- double xPos = floor(_vector[counter][X]);
- if (_vector[1][X] < 0) {
- xPos = 0;
- }
- double vectorY = _vector[counter][Y];
- if (vectorY != 0) {
- change = true;
- }
- result.push_back(Point(xPos, 0));
- }
- ++curve_it1;
- counter++;
- if (curve_it2 != curve_endit) {
- ++curve_it2;
- }
- counterCurves++;
- }
- }
- if (change) {
- _vector = result;
- write_to_SVG();
- }
- }
-}
-
-void FilletChamferPointArrayParam::set_pwd2(
- Piecewise<D2<SBasis> > const &pwd2_in,
- Piecewise<D2<SBasis> > const &pwd2_normal_in)
-{
- last_pwd2 = pwd2_in;
- last_pwd2_normal = pwd2_normal_in;
-}
-
-void FilletChamferPointArrayParam::set_helper_size(int hs)
-{
- helper_size = hs;
-}
-
-void FilletChamferPointArrayParam::set_chamfer_steps(int value_chamfer_steps)
-{
- chamfer_steps = value_chamfer_steps;
-}
-
-void FilletChamferPointArrayParam::set_use_distance(bool use_knot_distance )
-{
- use_distance = use_knot_distance;
-}
-
-void FilletChamferPointArrayParam::updateCanvasIndicators()
-{
- std::vector<Point> ts = data();
- hp.clear();
- unsigned int i = 0;
- for (std::vector<Point>::const_iterator point_it = ts.begin();
- point_it != ts.end(); ++point_it) {
- double Xvalue = to_time(i, (*point_it)[X]) -i;
- if (Xvalue == 0) {
- i++;
- continue;
- }
- Geom::Point ptA = last_pwd2[i].valueAt(Xvalue);
- Geom::Point derivA = unit_vector(derivative(last_pwd2[i]).valueAt(Xvalue));
- Geom::Rotate rot(Geom::Rotate::from_degrees(-90));
- derivA = derivA * rot;
- Geom::Point C = ptA - derivA * helper_size;
- Geom::Point D = ptA + derivA * helper_size;
- Geom::Ray ray1(C, D);
- char const * svgd = "M 1,0.25 0.5,0 1,-0.25 M 1,0.5 0,0 1,-0.5";
- Geom::PathVector pathv = sp_svg_read_pathv(svgd);
- Geom::Affine aff = Geom::Affine();
- aff *= Geom::Scale(helper_size);
- aff *= Geom::Rotate(ray1.angle() - rad_from_deg(270));
- aff *= Geom::Translate(last_pwd2[i].valueAt(Xvalue));
- pathv *= aff;
- hp.push_back(pathv[0]);
- hp.push_back(pathv[1]);
- i++;
- }
-}
-
-void FilletChamferPointArrayParam::addCanvasIndicators(
- SPLPEItem const */*lpeitem*/, std::vector<Geom::PathVector> &hp_vec)
-{
- hp_vec.push_back(hp);
-}
-
-double FilletChamferPointArrayParam::rad_to_len(int index, double rad)
-{
- double len = 0;
- Geom::PathVector subpaths = path_from_piecewise(last_pwd2, 0.1);
- std::pair<std::size_t, std::size_t> positions = get_positions(index, subpaths);
- D2<SBasis> A = last_pwd2[last_index(index, subpaths)];
- if(positions.second != 0){
- A = last_pwd2[index-1];
- }else{
- if(!subpaths[positions.first].closed()){
- return len;
- }
- }
- D2<SBasis> B = last_pwd2[index];
- Piecewise<D2<SBasis> > offset_curve0 = Piecewise<D2<SBasis> >(A)+rot90(unitVector(derivative(A)))*(rad);
- Piecewise<D2<SBasis> > offset_curve1 = Piecewise<D2<SBasis> >(B)+rot90(unitVector(derivative(B)))*(rad);
- Geom::Path p0 = path_from_piecewise(offset_curve0, 0.1)[0];
- Geom::Path p1 = path_from_piecewise(offset_curve1, 0.1)[0];
- Geom::Crossings cs = Geom::crossings(p0, p1);
- if(cs.size() > 0){
- Point cp =p0(cs[0].ta);
- double p0pt = nearest_time(cp, B);
- len = time_to_len(index,p0pt);
- } else {
- if(rad < 0){
- len = rad_to_len(index, rad * -1);
- }
- }
- return len;
-}
-
-double FilletChamferPointArrayParam::len_to_rad(int index, double len)
-{
- double rad = 0;
- double tmp_len = _vector[index][X];
- _vector[index] = Geom::Point(len,_vector[index][Y]);
- Geom::PathVector subpaths = path_from_piecewise(last_pwd2, 0.1);
- std::pair<std::size_t, std::size_t> positions = get_positions(index, subpaths);
- Piecewise<D2<SBasis> > u;
- u.push_cut(0);
- u.push(last_pwd2[last_index(index, subpaths)], 1);
- Geom::Curve * A = path_from_piecewise(u, 0.1)[0][0].duplicate();
- Geom::Curve * B = subpaths[positions.first][positions.second].duplicate();
- std::vector<double> times;
- if(positions.second != 0){
- A = subpaths[positions.first][positions.second-1].duplicate();
- times = get_times(index-1, subpaths, false);
- }else{
- if(!subpaths[positions.first].closed()){
- return rad;
- }
- times = get_times(last_index(index, subpaths), subpaths, true);
- }
- _vector[index] = Geom::Point(tmp_len,_vector[index][Y]);
- Geom::Point startArcPoint = A->toSBasis().valueAt(times[1]);
- Geom::Point endArcPoint = B->toSBasis().valueAt(times[2]);
- Curve *knotCurve1 = A->portion(times[0], times[1]);
- Curve *knotCurve2 = B->portion(times[2], 1);
- Geom::CubicBezier const *cubic1 = dynamic_cast<Geom::CubicBezier const *>(knotCurve1);
- Ray ray1(startArcPoint, A->finalPoint());
- if (cubic1) {
- ray1.setPoints((*cubic1)[2], startArcPoint);
- }
- Geom::CubicBezier const *cubic2 = dynamic_cast<Geom::CubicBezier const *>(knotCurve2);
- Ray ray2(B->initialPoint(), endArcPoint);
- if (cubic2) {
- ray2.setPoints(endArcPoint, (*cubic2)[1]);
- }
- bool ccwToggle = cross(A->finalPoint() - startArcPoint, endArcPoint - startArcPoint) > 0;
- double distanceArc = Geom::distance(startArcPoint,middle_point(startArcPoint,endArcPoint));
- double angleBetween = angle_between(ray1, ray2, ccwToggle);
- rad = distanceArc/sin(angleBetween/2.0);
- return rad * -1;
-}
-
-std::vector<double> FilletChamferPointArrayParam::get_times(int index, Geom::PathVector subpaths, bool last)
-{
- const double tolerance = 0.001;
- const double gapHelper = 0.00001;
- std::pair<std::size_t, std::size_t> positions = get_positions(index, subpaths);
- Curve *curve_it1;
- curve_it1 = subpaths[positions.first][positions.second].duplicate();
- Coord it1_length = (*curve_it1).length(tolerance);
- double time_it1, time_it2, time_it1_B, intpart;
- if (static_cast<int>(_vector.size()) <= index){
- std::vector<double> out;
- out.push_back(0);
- out.push_back(1);
- out.push_back(0);
- return out;
- }
- time_it1 = modf(to_time(index, _vector[index][X]), &intpart);
- if (_vector[index][Y] == 0) {
- time_it1 = 0;
- }
- double resultLenght = 0;
- if (subpaths[positions.first].closed() && last) {
- time_it2 = modf(to_time(index - positions.second , _vector[index - positions.second ][X]), &intpart);
- resultLenght = it1_length + to_len(index - positions.second, _vector[index - positions.second ][X]);
- } else if (!subpaths[positions.first].closed() && last){
- time_it2 = 0;
- resultLenght = 0;
- } else {
- time_it2 = modf(to_time(index + 1, _vector[index + 1][X]), &intpart);
- resultLenght = it1_length + to_len( index + 1, _vector[index + 1][X]);
- }
- if (resultLenght > 0 && time_it2 != 0) {
- time_it1_B = modf(to_time(index, -resultLenght), &intpart);
- } else {
- if (time_it2 == 0) {
- time_it1_B = 1;
- } else {
- time_it1_B = gapHelper;
- }
- }
-
- if ((subpaths[positions.first].closed() && last && _vector[index - positions.second][Y] == 0) || (subpaths[positions.first].size() > positions.second + 1 && _vector[index + 1][Y] == 0)) {
- time_it1_B = 1;
- time_it2 = 0;
- }
- if (time_it1_B < time_it1) {
- time_it1_B = time_it1 + gapHelper;
- }
- std::vector<double> out;
- out.push_back(time_it1);
- out.push_back(time_it1_B);
- out.push_back(time_it2);
- return out;
-}
-
-std::pair<std::size_t, std::size_t> FilletChamferPointArrayParam::get_positions(int index, Geom::PathVector subpaths)
-{
- int counter = -1;
- std::size_t first = 0;
- std::size_t second = 0;
- for (PathVector::const_iterator path_it = subpaths.begin(); path_it != subpaths.end(); ++path_it) {
- if (path_it->empty())
- continue;
- Geom::Path::const_iterator curve_it1 = path_it->begin();
- Geom::Path::const_iterator curve_endit = path_it->end_default();
- if (path_it->closed()) {
- const Geom::Curve &closingline = path_it->back_closed();
- // the closing line segment is always of type
- // Geom::LineSegment.
- if (are_near(closingline.initialPoint(), closingline.finalPoint())) {
- // closingline.isDegenerate() did not work, because it only checks for
- // *exact* zero length, which goes wrong for relative coordinates and
- // rounding errors...
- // the closing line segment has zero-length. So stop before that one!
- curve_endit = path_it->end_open();
- }
- }
- first++;
- second = 0;
- while (curve_it1 != curve_endit) {
- counter++;
- second++;
- if(counter == index){
- break;
- }
- ++curve_it1;
- }
- if(counter == index){
- break;
- }
- }
- first--;
- second--;
- std::pair<std::size_t, std::size_t> out(first, second);
- return out;
-}
-
-int FilletChamferPointArrayParam::last_index(int index, Geom::PathVector subpaths)
-{
- int counter = -1;
- bool inSubpath = false;
- for (PathVector::const_iterator path_it = subpaths.begin(); path_it != subpaths.end(); ++path_it) {
- if (path_it->empty())
- continue;
- Geom::Path::const_iterator curve_it1 = path_it->begin();
- Geom::Path::const_iterator curve_endit = path_it->end_default();
- if (path_it->closed()) {
- const Geom::Curve &closingline = path_it->back_closed();
- if (are_near(closingline.initialPoint(), closingline.finalPoint())) {
- curve_endit = path_it->end_open();
- }
- }
- while (curve_it1 != curve_endit) {
- counter++;
- if(counter == index){
- inSubpath = true;
- }
- ++curve_it1;
- }
- if(inSubpath){
- break;
- }
- }
- if(!inSubpath){
- counter = -1;
- }
- return counter;
-}
-
-
-double FilletChamferPointArrayParam::len_to_time(int index, double len)
-{
- double t = 0;
- if (last_pwd2.size() > (unsigned) index) {
- if (len != 0) {
- if (last_pwd2[index][0].degreesOfFreedom() != 2) {
- Piecewise<D2<SBasis> > u;
- u.push_cut(0);
- u.push(last_pwd2[index], 1);
- std::vector<double> t_roots = roots(arcLengthSb(u) - std::abs(len));
- if (t_roots.size() > 0) {
- t = t_roots[0];
- }
- } else {
- double lenghtPart = 0;
- if (last_pwd2.size() > (unsigned) index) {
- lenghtPart = length(last_pwd2[index], EPSILON);
- }
- if (std::abs(len) < lenghtPart && lenghtPart != 0) {
- t = std::abs(len) / lenghtPart;
- }
- }
- }
- t = double(index) + t;
- } else {
- t = double(last_pwd2.size() - 1);
- }
-
- return t;
-}
-
-double FilletChamferPointArrayParam::time_to_len(int index, double time)
-{
- double intpart;
- double len = 0;
- time = modf(time, &intpart);
- double lenghtPart = 0;
- if (last_pwd2.size() <= (unsigned) index || time == 0) {
- return len;
- }
- if (last_pwd2[index][0].degreesOfFreedom() != 2) {
- Piecewise<D2<SBasis> > u;
- u.push_cut(0);
- u.push(last_pwd2[index], 1);
- u = portion(u, 0, time);
- return length(u, 0.001) * -1;
- }
- lenghtPart = length(last_pwd2[index], EPSILON);
- return (time * lenghtPart) * -1;
-}
-
-double FilletChamferPointArrayParam::to_time(int index, double A)
-{
- if (A > 0) {
- return A;
- } else {
- return len_to_time(index, A);
- }
-}
-
-double FilletChamferPointArrayParam::to_len(int index, double A)
-{
- if (A > 0) {
- return time_to_len(index, A);
- } else {
- return A;
- }
-}
-
-void FilletChamferPointArrayParam::set_oncanvas_looks(SPKnotShapeType shape,
- SPKnotModeType mode,
- guint32 color)
-{
- knot_shape = shape;
- knot_mode = mode;
- knot_color = color;
-}
-
-FilletChamferPointArrayParamKnotHolderEntity::
-FilletChamferPointArrayParamKnotHolderEntity(
- FilletChamferPointArrayParam *p, unsigned int index)
- : _pparam(p), _index(index) {}
-
-void FilletChamferPointArrayParamKnotHolderEntity::knot_set(Point const &p,
- Point const &/*origin*/,
- guint state)
-{
- using namespace Geom;
-
- if (!valid_index(_index)) {
- return;
- }
- Piecewise<D2<SBasis> > const &pwd2 = _pparam->get_pwd2();
- double t = nearest_time(p, pwd2[_index]);
- Geom::Point const s = snap_knot_position(pwd2[_index].valueAt(t), state);
- t = nearest_time(s, pwd2[_index]);
- if (t == 1) {
- t = 0.9999;
- }
- t += _index;
-
- if (_pparam->_vector.at(_index)[X] <= 0) {
- _pparam->_vector.at(_index) =
- Point(_pparam->time_to_len(_index, t), _pparam->_vector.at(_index)[Y]);
- } else {
- _pparam->_vector.at(_index) = Point(t, _pparam->_vector.at(_index)[Y]);
- }
- sp_lpe_item_update_patheffect(SP_LPE_ITEM(item), false, false);
-}
-
-Point FilletChamferPointArrayParamKnotHolderEntity::knot_get() const
-{
- using namespace Geom;
-
- if (!valid_index(_index)) {
- return Point(infinity(), infinity());
- }
-
- Piecewise<D2<SBasis> > const &pwd2 = _pparam->get_pwd2();
-
- double time_it = _pparam->to_time(_index, _pparam->_vector.at(_index)[X]);
- Point canvas_point = pwd2.valueAt(time_it);
-
- _pparam->updateCanvasIndicators();
- return canvas_point;
-
-}
-
-void FilletChamferPointArrayParamKnotHolderEntity::knot_click(guint state)
-{
- if (state & GDK_CONTROL_MASK) {
- if (state & GDK_MOD1_MASK) {
- _pparam->_vector.at(_index) = Point(_index, _pparam->_vector.at(_index)[Y]);
- _pparam->param_set_and_write_new_value(_pparam->_vector);
- sp_lpe_item_update_patheffect(SP_LPE_ITEM(item), false, false);
- }else{
- using namespace Geom;
- int type = (int)_pparam->_vector.at(_index)[Y];
- if (type >=3000 && type < 4000){
- type = 3;
- }
- if (type >=4000 && type < 5000){
- type = 4;
- }
- switch(type){
- case 1:
- type = 2;
- break;
- case 2:
- type = _pparam->chamfer_steps + 3000;
- break;
- case 3:
- type = _pparam->chamfer_steps + 4000;
- break;
- default:
- type = 1;
- break;
- }
- _pparam->_vector.at(_index) = Point(_pparam->_vector.at(_index)[X], (double)type);
- _pparam->param_set_and_write_new_value(_pparam->_vector);
- sp_lpe_item_update_patheffect(SP_LPE_ITEM(item), false, false);
- const gchar *tip;
- if (type >=3000 && type < 4000){
- tip = _("<b>Chamfer</b>: <b>Ctrl+Click</b> toggle type, "
- "<b>Shift+Click</b> open dialog, "
- "<b>Ctrl+Alt+Click</b> reset");
- } else if (type >=4000 && type < 5000) {
- tip = _("<b>Inverse Chamfer</b>: <b>Ctrl+Click</b> toggle type, "
- "<b>Shift+Click</b> open dialog, "
- "<b>Ctrl+Alt+Click</b> reset");
- } else if (type == 2) {
- tip = _("<b>Inverse Fillet</b>: <b>Ctrl+Click</b> toggle type, "
- "<b>Shift+Click</b> open dialog, "
- "<b>Ctrl+Alt+Click</b> reset");
- } else {
- tip = _("<b>Fillet</b>: <b>Ctrl+Click</b> toggle type, "
- "<b>Shift+Click</b> open dialog, "
- "<b>Ctrl+Alt+Click</b> reset");
- }
- this->knot->tip = g_strdup(tip);
- this->knot->show();
- }
- } else if (state & GDK_SHIFT_MASK) {
- double xModified = _pparam->_vector.at(_index).x();
- if(xModified < 0 && !_pparam->use_distance){
- xModified = _pparam->len_to_rad(_index, _pparam->_vector.at(_index).x());
- }
- Geom::PathVector subpaths = path_from_piecewise(_pparam->last_pwd2, 0.1);
- std::pair<std::size_t, std::size_t> positions = _pparam->get_positions(_index, subpaths);
- D2<SBasis> A = _pparam->last_pwd2[_pparam->last_index(_index, subpaths)];
- if(positions.second != 0){
- A = _pparam->last_pwd2[_index-1];
- }
- D2<SBasis> B = _pparam->last_pwd2[_index];
- bool aprox = (A[0].degreesOfFreedom() != 2 || B[0].degreesOfFreedom() != 2) && !_pparam->use_distance?true:false;
- Geom::Point offset = Geom::Point(xModified, _pparam->_vector.at(_index).y());
- Inkscape::UI::Dialogs::FilletChamferPropertiesDialog::showDialog(
- this->desktop, offset, this, _pparam->use_distance, aprox);
- }
-
-}
-
-void FilletChamferPointArrayParamKnotHolderEntity::knot_set_offset(
- Geom::Point offset)
-{
- double xModified = offset.x();
- if(xModified < 0 && !_pparam->use_distance){
- xModified = _pparam->rad_to_len(_index, offset.x());
- }
- _pparam->_vector.at(_index) = Geom::Point(xModified, offset.y());
- this->parent_holder->knot_ungrabbed_handler(this->knot, 0);
-}
-
-void FilletChamferPointArrayParam::addKnotHolderEntities(KnotHolder *knotholder,
- SPDesktop *desktop,
- SPItem *item)
-{
- recalculate_knots(get_pwd2());
- for (unsigned int i = 0; i < _vector.size(); ++i) {
- if (_vector[i][Y] <= 0) {
- continue;
- }
- const gchar *tip;
- if (_vector[i][Y] >=3000 && _vector[i][Y] < 4000){
- tip = _("<b>Chamfer</b>: <b>Ctrl+Click</b> toggle type, "
- "<b>Shift+Click</b> open dialog, "
- "<b>Ctrl+Alt+Click</b> reset");
- } else if (_vector[i][Y] >=4000 && _vector[i][Y] < 5000) {
- tip = _("<b>Inverse Chamfer</b>: <b>Ctrl+Click</b> toggle type, "
- "<b>Shift+Click</b> open dialog, "
- "<b>Ctrl+Alt+Click</b> reset");
- } else if (_vector[i][Y] == 2) {
- tip = _("<b>Inverse Fillet</b>: <b>Ctrl+Click</b> toggle type, "
- "<b>Shift+Click</b> open dialog, "
- "<b>Ctrl+Alt+Click</b> reset");
- } else {
- tip = _("<b>Fillet</b>: <b>Ctrl+Click</b> toggle type, "
- "<b>Shift+Click</b> open dialog, "
- "<b>Ctrl+Alt+Click</b> reset");
- }
- FilletChamferPointArrayParamKnotHolderEntity *e =
- new FilletChamferPointArrayParamKnotHolderEntity(this, i);
- e->create(desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, _(tip),
- knot_shape, knot_mode, knot_color);
- knotholder->add(e);
- }
- updateCanvasIndicators();
-}
-
-} /* namespace LivePathEffect */
-
-} /* namespace Inkscape */
-
-/*
- Local Variables:
- mode:c++
- c-file-style:"stroustrup"
- c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
- indent-tabs-mode:nil
- fill-column:99
- End:
-*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
diff --git a/src/live_effects/parameter/filletchamferpointarray.h b/src/live_effects/parameter/filletchamferpointarray.h
deleted file mode 100644
index 48cd26d2d..000000000
--- a/src/live_effects/parameter/filletchamferpointarray.h
+++ /dev/null
@@ -1,123 +0,0 @@
-#ifndef INKSCAPE_LIVEPATHEFFECT_FILLET_CHAMFER_POINT_ARRAY_H
-#define INKSCAPE_LIVEPATHEFFECT_FILLET_CHAMFER_POINT_ARRAY_H
-
-/*
- * Inkscape::LivePathEffectParameters
- * Copyright (C) Jabiertxo Arraiza Cenoz <jabier.arraiza@marker.es>
- * Special thanks to Johan Engelen for the base of the effect -powerstroke-
- * Also to ScislaC for point me to the idea
- * Also su_v for his construvtive feedback and time
- * and finaly to Liam P. White for his big help on coding, that save me a lot of
- * hours
- * Released under GNU GPL, read the file 'COPYING' for more information
- */
-
-#include <glib.h>
-#include <2geom/point.h>
-
-#include "live_effects/parameter/array.h"
-
-#include "knot-holder-entity.h"
-
-namespace Inkscape {
-
-namespace LivePathEffect {
-
-class FilletChamferPointArrayParamKnotHolderEntity;
-
-class FilletChamferPointArrayParam : public ArrayParam<Geom::Point> {
-public:
- FilletChamferPointArrayParam(const Glib::ustring &label,
- const Glib::ustring &tip,
- const Glib::ustring &key,
- Inkscape::UI::Widget::Registry *wr,
- Effect *effect);
- virtual ~FilletChamferPointArrayParam();
-
- virtual Gtk::Widget *param_newWidget();
-
- virtual void param_transform_multiply(Geom::Affine const &postmul,
- bool /*set*/);
-
- void set_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode,
- guint32 color);
- virtual double to_time(int index, double A);
- virtual double to_len(int index, double A);
- virtual double rad_to_len(int index, double rad);
- virtual double len_to_rad(int index, double len);
- virtual double len_to_time(int index, double len);
- virtual double time_to_len(int index, double time);
- virtual std::pair<std::size_t, std::size_t> get_positions(int index, Geom::PathVector subpaths);
- virtual int last_index(int index, Geom::PathVector subpaths);
- std::vector<double> get_times(int index, Geom::PathVector subpaths, bool last);
- virtual void set_helper_size(int hs);
- virtual void set_use_distance(bool use_knot_distance);
- virtual void set_chamfer_steps(int value_chamfer_steps);
- virtual void addCanvasIndicators(SPLPEItem const *lpeitem,
- std::vector<Geom::PathVector> &hp_vec);
- virtual bool providesKnotHolderEntities() const {
- return true;
- }
- virtual void updateCanvasIndicators();
- virtual void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop,
- SPItem *item);
-
- void set_pwd2(Geom::Piecewise<Geom::D2<Geom::SBasis> > const &pwd2_in,
- Geom::Piecewise<Geom::D2<Geom::SBasis> > const &pwd2_normal_in);
- Geom::Piecewise<Geom::D2<Geom::SBasis> > const &get_pwd2() const {
- return last_pwd2;
- }
- Geom::Piecewise<Geom::D2<Geom::SBasis> > const &get_pwd2_normal() const {
- return last_pwd2_normal;
- }
-
- void recalculate_controlpoints_for_new_pwd2(
- Geom::Piecewise<Geom::D2<Geom::SBasis> > const &pwd2_in);
- void recalculate_knots(
- Geom::Piecewise<Geom::D2<Geom::SBasis> > const &pwd2_in);
- friend class FilletChamferPointArrayParamKnotHolderEntity;
-
-private:
- FilletChamferPointArrayParam(const FilletChamferPointArrayParam &);
- FilletChamferPointArrayParam &operator=(const FilletChamferPointArrayParam &);
-
- SPKnotShapeType knot_shape;
- SPKnotModeType knot_mode;
- guint32 knot_color;
- int helper_size;
- int chamfer_steps;
- bool use_distance;
- Geom::PathVector hp;
-
- Geom::Piecewise<Geom::D2<Geom::SBasis> > last_pwd2;
- Geom::Piecewise<Geom::D2<Geom::SBasis> > last_pwd2_normal;
-};
-
-class FilletChamferPointArrayParamKnotHolderEntity : public KnotHolderEntity {
-public:
- FilletChamferPointArrayParamKnotHolderEntity(FilletChamferPointArrayParam *p,
- unsigned int index);
- virtual ~FilletChamferPointArrayParamKnotHolderEntity() {}
-
- virtual void knot_set(Geom::Point const &p, Geom::Point const &origin,
- guint state);
- virtual Geom::Point knot_get() const;
- virtual void knot_click(guint state);
- virtual void knot_set_offset(Geom::Point offset);
-
- /*Checks whether the index falls within the size of the parameter's vector*/
- bool valid_index(unsigned int index) const {
- return (_pparam->_vector.size() > index);
- }
- ;
-
-private:
- FilletChamferPointArrayParam *_pparam;
- unsigned int _index;
-};
-
-} //namespace LivePathEffect
-
-} //namespace Inkscape
-
-#endif
diff --git a/src/live_effects/parameter/fontbutton.cpp b/src/live_effects/parameter/fontbutton.cpp
new file mode 100644
index 000000000..ca8908f0e
--- /dev/null
+++ b/src/live_effects/parameter/fontbutton.cpp
@@ -0,0 +1,97 @@
+/*
+ * Authors:
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include <gtkmm.h>
+#include "ui/widget/registered-widget.h"
+#include "live_effects/parameter/fontbutton.h"
+#include "live_effects/effect.h"
+#include "ui/widget/font-button.h"
+#include "svg/svg.h"
+#include "svg/stringstream.h"
+#include "verbs.h"
+
+#include <glibmm/i18n.h>
+
+namespace Inkscape {
+
+namespace LivePathEffect {
+
+FontButtonParam::FontButtonParam( const Glib::ustring& label, const Glib::ustring& tip,
+ const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr,
+ Effect* effect, const Glib::ustring default_value )
+ : Parameter(label, tip, key, wr, effect),
+ value(default_value),
+ defvalue(default_value)
+{
+}
+
+void
+FontButtonParam::param_set_default()
+{
+ param_setValue(defvalue);
+}
+
+void
+FontButtonParam::param_update_default(const gchar * default_value)
+{
+ defvalue = (Glib::ustring)strdup(default_value);
+}
+
+bool
+FontButtonParam::param_readSVGValue(const gchar * strvalue)
+{
+ Inkscape::SVGOStringStream os;
+ os << strvalue;
+ param_setValue((Glib::ustring)os.str());
+ return true;
+}
+
+gchar *
+FontButtonParam::param_getSVGValue() const
+{
+ return g_strdup(value.c_str());
+}
+
+Gtk::Widget *
+FontButtonParam::param_newWidget()
+{
+ Inkscape::UI::Widget::RegisteredFontButton * fontbuttonwdg = Gtk::manage(
+ new Inkscape::UI::Widget::RegisteredFontButton( param_label,
+ param_tooltip,
+ param_key,
+ *param_wr,
+ param_effect->getRepr(),
+ param_effect->getSPDoc() ) );
+ Glib::ustring fontspec = param_getSVGValue();
+ fontbuttonwdg->setValue( fontspec);
+ fontbuttonwdg->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change font button parameter"));
+ return dynamic_cast<Gtk::Widget *> (fontbuttonwdg);
+}
+
+void
+FontButtonParam::param_setValue(const Glib::ustring newvalue)
+{
+ if (value != newvalue) {
+ param_effect->upd_params = true;
+ }
+ value = newvalue;
+}
+
+
+} /* namespace LivePathEffect */
+
+} /* namespace Inkscape */
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
diff --git a/src/live_effects/parameter/fontbutton.h b/src/live_effects/parameter/fontbutton.h
new file mode 100644
index 000000000..60e1aa46e
--- /dev/null
+++ b/src/live_effects/parameter/fontbutton.h
@@ -0,0 +1,61 @@
+#ifndef INKSCAPE_LIVEPATHEFFECT_PARAMETER_FONT_H
+#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_FONT_H
+
+/*
+ * Inkscape::LivePathEffectParameters
+ *
+ * Authors:
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+#include <glib.h>
+#include "live_effects/parameter/parameter.h"
+
+namespace Inkscape {
+
+namespace LivePathEffect {
+
+class FontButtonParam : public Parameter {
+public:
+ FontButtonParam( const Glib::ustring& label,
+ const Glib::ustring& tip,
+ const Glib::ustring& key,
+ Inkscape::UI::Widget::Registry* wr,
+ Effect* effect,
+ const Glib::ustring default_value = "Sans 10");
+ virtual ~FontButtonParam() {}
+
+ virtual Gtk::Widget * param_newWidget();
+ virtual bool param_readSVGValue(const gchar * strvalue);
+ void param_update_default(const gchar * default_value);
+ virtual gchar * param_getSVGValue() const;
+
+ void param_setValue(Glib::ustring newvalue);
+
+ virtual void param_set_default();
+
+ const Glib::ustring get_value() const { return defvalue; };
+
+private:
+ FontButtonParam(const FontButtonParam&);
+ FontButtonParam& operator=(const FontButtonParam&);
+ Glib::ustring value;
+ Glib::ustring defvalue;
+
+};
+
+} //namespace LivePathEffect
+
+} //namespace Inkscape
+
+#endif
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
diff --git a/src/live_effects/parameter/hidden.cpp b/src/live_effects/parameter/hidden.cpp
new file mode 100644
index 000000000..e8c55ebd3
--- /dev/null
+++ b/src/live_effects/parameter/hidden.cpp
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) jabiertxof 2017 <jabier.arraiza@marker.es>
+ * Copyright (C) Maximilian Albert 2008 <maximilian.albert@gmail.com>
+ *
+ * Authors:
+ * Jabiertxof
+ * Maximilian Albert
+ * Johan Engelen
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+
+#include "live_effects/parameter/hidden.h"
+#include "live_effects/effect.h"
+#include "svg/svg.h"
+#include "svg/stringstream.h"
+
+namespace Inkscape {
+
+namespace LivePathEffect {
+
+HiddenParam::HiddenParam( const Glib::ustring& label, const Glib::ustring& tip,
+ const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr,
+ Effect* effect, const Glib::ustring default_value, bool is_visible)
+ : Parameter(label, tip, key, wr, effect),
+ value(default_value),
+ defvalue(default_value)
+{
+ param_widget_is_visible(is_visible);
+}
+
+void
+HiddenParam::param_set_default()
+{
+ param_setValue(defvalue);
+}
+
+void
+HiddenParam::param_update_default(const gchar * default_value)
+{
+ defvalue = (Glib::ustring)default_value;
+}
+
+
+bool
+HiddenParam::param_readSVGValue(const gchar * strvalue)
+{
+ param_setValue(strvalue);
+ return true;
+}
+
+gchar *
+HiddenParam::param_getSVGValue() const
+{
+ Inkscape::SVGOStringStream os;
+ os << value;
+ gchar * str = g_strdup(os.str().c_str());
+ return str;
+}
+
+Gtk::Widget *
+HiddenParam::param_newWidget()
+{
+ return NULL;
+}
+
+void
+HiddenParam::param_setValue(const Glib::ustring newvalue, bool write)
+{
+ value = newvalue;
+ if (write) {
+ param_write_to_repr(value.c_str());
+ }
+}
+
+} /* namespace LivePathEffect */
+
+} /* namespace Inkscape */
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
diff --git a/src/live_effects/parameter/hidden.h b/src/live_effects/parameter/hidden.h
new file mode 100644
index 000000000..c3fba5575
--- /dev/null
+++ b/src/live_effects/parameter/hidden.h
@@ -0,0 +1,69 @@
+#ifndef INKSCAPE_LIVEPATHEFFECT_HIDDEN_H
+#define INKSCAPE_LIVEPATHEFFECT_HIDDEN_H
+
+/*
+ * Inkscape::LivePathEffectParameters
+ *
+ * Authors:
+ * Jabiertxof
+ * Maximilian Albert
+ * Johan Engelen
+ *
+ * Copyright (C) jabiertxof 2017 <jabier.arraiza@marker.es>
+ * Copyright (C) Maximilian Albert 2008 <maximilian.albert@gmail.com>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "live_effects/parameter/parameter.h"
+
+
+namespace Inkscape {
+
+namespace LivePathEffect {
+
+class HiddenParam : public Parameter {
+public:
+ HiddenParam( const Glib::ustring& label,
+ const Glib::ustring& tip,
+ const Glib::ustring& key,
+ Inkscape::UI::Widget::Registry* wr,
+ Effect* effect,
+ const Glib::ustring default_value = "",
+ bool widget_is_visible = false);
+ virtual ~HiddenParam() {}
+
+ virtual Gtk::Widget * param_newWidget();
+
+ virtual bool param_readSVGValue(const gchar * strvalue);
+ virtual gchar * param_getSVGValue() const;
+
+ void param_setValue(Glib::ustring newvalue, bool write = false);
+ virtual void param_set_default();
+ virtual void param_update_default(const gchar * default_value);
+
+ const Glib::ustring get_value() const { return value; };
+
+private:
+ HiddenParam(const HiddenParam&);
+ HiddenParam& operator=(const HiddenParam&);
+ Glib::ustring value;
+ Glib::ustring defvalue;
+};
+
+} //namespace LivePathEffect
+
+} //namespace Inkscape
+
+#endif
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
diff --git a/src/live_effects/parameter/item-reference.cpp b/src/live_effects/parameter/item-reference.cpp
new file mode 100644
index 000000000..a775d93b7
--- /dev/null
+++ b/src/live_effects/parameter/item-reference.cpp
@@ -0,0 +1,44 @@
+/*
+ * The reference corresponding to href of LPE Item parameter.
+ *
+ * Copyright (C) 2008 Johan Engelen
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information.
+ */
+
+#include "live_effects/parameter/item-reference.h"
+
+#include "sp-shape.h"
+#include "sp-text.h"
+#include "sp-item-group.h"
+
+namespace Inkscape {
+namespace LivePathEffect {
+
+bool ItemReference::_acceptObject(SPObject * const obj) const
+{
+ if (SP_IS_SHAPE(obj) || SP_IS_TEXT(obj) || SP_IS_GROUP(obj)) {
+ /* Refuse references to lpeobject */
+ if (obj == getOwner()) {
+ return false;
+ }
+ // TODO: check whether the referred item has this LPE applied, if so: deny deny deny!
+ return URIReference::_acceptObject(obj);
+ } else {
+ return false;
+ }
+}
+
+} // namespace LivePathEffect
+} // namespace Inkscape
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
diff --git a/src/live_effects/parameter/item-reference.h b/src/live_effects/parameter/item-reference.h
new file mode 100644
index 000000000..91231455a
--- /dev/null
+++ b/src/live_effects/parameter/item-reference.h
@@ -0,0 +1,56 @@
+#ifndef SEEN_LPE_ITEM_REFERENCE_H
+#define SEEN_LPE_ITEM_REFERENCE_H
+
+/*
+ * Copyright (C) 2008-2012 Authors
+ * Authors: Johan Engelen
+ * Abhishek Sharma
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information.
+ */
+
+#include <uri-references.h>
+
+class SPItem;
+namespace Inkscape {
+namespace XML { class Node; }
+
+namespace LivePathEffect {
+
+/**
+ * The reference corresponding to href of LPE ItemParam.
+ */
+class ItemReference : public Inkscape::URIReference {
+public:
+ ItemReference(SPObject *owner) : URIReference(owner) {}
+
+ SPItem *getObject() const {
+ return (SPItem *)URIReference::getObject();
+ }
+
+protected:
+ virtual bool _acceptObject(SPObject * const obj) const;
+
+private:
+ ItemReference(const ItemReference&);
+ ItemReference& operator=(const ItemReference&);
+};
+
+} // namespace LivePathEffect
+
+} // namespace Inkscape
+
+
+
+#endif /* !SEEN_LPE_PATH_REFERENCE_H */
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
diff --git a/src/live_effects/parameter/item.cpp b/src/live_effects/parameter/item.cpp
new file mode 100644
index 000000000..7b40f4540
--- /dev/null
+++ b/src/live_effects/parameter/item.cpp
@@ -0,0 +1,253 @@
+/*
+ * Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
+ * Abhishek Sharma
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "live_effects/parameter/item.h"
+
+#include <glibmm/i18n.h>
+
+#include <gtkmm/button.h>
+#include <gtkmm/label.h>
+
+#include "bad-uri-exception.h"
+#include "ui/widget/point.h"
+
+#include "live_effects/effect.h"
+#include "svg/svg.h"
+
+#include "widgets/icon.h"
+#include "selection-chemistry.h"
+#include "xml/repr.h"
+#include "desktop.h"
+#include "inkscape.h"
+#include "message-stack.h"
+
+// clipboard support
+#include "ui/clipboard.h"
+// required for linking to other paths
+#include "uri.h"
+
+#include "ui/icon-names.h"
+
+namespace Inkscape {
+
+namespace LivePathEffect {
+
+ItemParam::ItemParam( const Glib::ustring& label, const Glib::ustring& tip,
+ const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr,
+ Effect* effect, const gchar * default_value)
+ : Parameter(label, tip, key, wr, effect),
+ changed(true),
+ href(NULL),
+ ref( (SPObject*)effect->getLPEObj() )
+{
+ defvalue = g_strdup(default_value);
+ ref_changed_connection = ref.changedSignal().connect(sigc::mem_fun(*this, &ItemParam::ref_changed));
+}
+
+ItemParam::~ItemParam()
+{
+ remove_link();
+ g_free(defvalue);
+}
+
+void
+ItemParam::param_set_default()
+{
+ param_readSVGValue(defvalue);
+}
+
+void
+ItemParam::param_update_default(const gchar * default_value){
+ defvalue = strdup(default_value);
+}
+
+void
+ItemParam::param_set_and_write_default()
+{
+ param_write_to_repr(defvalue);
+}
+
+bool
+ItemParam::param_readSVGValue(const gchar * strvalue)
+{
+ if (strvalue) {
+ remove_link();
+ if (strvalue[0] == '#') {
+ if (href)
+ g_free(href);
+ href = g_strdup(strvalue);
+ try {
+ ref.attach(Inkscape::URI(href));
+ //lp:1299948
+ SPItem* i = ref.getObject();
+ if (i) {
+ linked_modified_callback(i, SP_OBJECT_MODIFIED_FLAG);
+ } // else: document still processing new events. Repr of the linked object not created yet.
+ } catch (Inkscape::BadURIException &e) {
+ g_warning("%s", e.what());
+ ref.detach();
+ }
+ }
+ emit_changed();
+ return true;
+ }
+
+ return false;
+}
+
+gchar *
+ItemParam::param_getSVGValue() const
+{
+ return g_strdup(href);
+}
+
+Gtk::Widget *
+ItemParam::param_newWidget()
+{
+ Gtk::HBox * _widget = Gtk::manage(new Gtk::HBox());
+ Gtk::Widget* pIcon = Gtk::manage( sp_icon_get_icon( INKSCAPE_ICON("edit-clone"), Inkscape::ICON_SIZE_BUTTON) );
+ Gtk::Button * pButton = Gtk::manage(new Gtk::Button());
+ Gtk::Label* pLabel = Gtk::manage(new Gtk::Label(param_label));
+ static_cast<Gtk::HBox*>(_widget)->pack_start(*pLabel, true, true);
+ pLabel->set_tooltip_text(param_tooltip);
+ pButton->set_relief(Gtk::RELIEF_NONE);
+ pIcon->show();
+ pButton->add(*pIcon);
+ pButton->show();
+ pButton->signal_clicked().connect(sigc::mem_fun(*this, &ItemParam::on_link_button_click));
+ static_cast<Gtk::HBox*>(_widget)->pack_start(*pButton, true, true);
+ pButton->set_tooltip_text(_("Link to item on clipboard"));
+
+ static_cast<Gtk::HBox*>(_widget)->show_all_children();
+
+ return dynamic_cast<Gtk::Widget *> (_widget);
+}
+
+void
+ItemParam::emit_changed()
+{
+ changed = true;
+ signal_item_changed.emit();
+}
+
+
+void
+ItemParam::addCanvasIndicators(SPLPEItem const*/*lpeitem*/, std::vector<Geom::PathVector> &hp_vec)
+{
+}
+
+
+void
+ItemParam::start_listening(SPObject * to)
+{
+ if ( to == NULL ) {
+ return;
+ }
+ linked_delete_connection = to->connectDelete(sigc::mem_fun(*this, &ItemParam::linked_delete));
+ linked_modified_connection = to->connectModified(sigc::mem_fun(*this, &ItemParam::linked_modified));
+ if (SP_IS_ITEM(to)) {
+ linked_transformed_connection = SP_ITEM(to)->connectTransformed(sigc::mem_fun(*this, &ItemParam::linked_transformed));
+ }
+ linked_modified(to, SP_OBJECT_MODIFIED_FLAG); // simulate linked_modified signal, so that path data is updated
+}
+
+void
+ItemParam::quit_listening(void)
+{
+ linked_modified_connection.disconnect();
+ linked_delete_connection.disconnect();
+ linked_transformed_connection.disconnect();
+}
+
+void
+ItemParam::ref_changed(SPObject */*old_ref*/, SPObject *new_ref)
+{
+ quit_listening();
+ if ( new_ref ) {
+ start_listening(new_ref);
+ }
+}
+
+void
+ItemParam::remove_link()
+{
+ if (href) {
+ ref.detach();
+ g_free(href);
+ href = NULL;
+ }
+}
+
+void
+ItemParam::linked_delete(SPObject */*deleted*/)
+{
+ quit_listening();
+ remove_link();
+}
+
+void ItemParam::linked_modified(SPObject *linked_obj, guint flags)
+{
+ linked_modified_callback(linked_obj, flags);
+}
+
+void ItemParam::linked_transformed(Geom::Affine const *rel_transf, SPItem *moved_item)
+{
+ linked_transformed_callback(rel_transf, moved_item);
+}
+
+void
+ItemParam::linked_modified_callback(SPObject *linked_obj, guint /*flags*/)
+{
+ emit_changed();
+ SP_OBJECT(param_effect->getLPEObj())->requestModified(SP_OBJECT_MODIFIED_FLAG);
+}
+
+void
+ItemParam::on_link_button_click()
+{
+ Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get();
+ const gchar * iid = cm->getFirstObjectID();
+ if (!iid) {
+ return;
+ }
+
+ Glib::ustring itemid(iid);
+
+ if (itemid.empty()) {
+ return;
+ }
+
+ // add '#' at start to make it an uri.
+ itemid.insert(itemid.begin(), '#');
+ if ( href && strcmp(itemid.c_str(), href) == 0 ) {
+ // no change, do nothing
+ return;
+ } else {
+ // TODO:
+ // check if id really exists in document, or only in clipboard document: if only in clipboard then invalid
+ // check if linking to object to which LPE is applied (maybe delegated to PathReference
+
+ param_write_to_repr(itemid.c_str());
+ DocumentUndo::done(param_effect->getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT,
+ _("Link item parameter to path"));
+ }
+}
+
+} /* namespace LivePathEffect */
+
+} /* namespace Inkscape */
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
diff --git a/src/live_effects/parameter/item.h b/src/live_effects/parameter/item.h
new file mode 100644
index 000000000..89c32f9bd
--- /dev/null
+++ b/src/live_effects/parameter/item.h
@@ -0,0 +1,80 @@
+#ifndef INKSCAPE_LIVEPATHEFFECT_PARAMETER_ITEM_H
+#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_ITEM_H
+
+/*
+ * Inkscape::LivePathEffectParameters
+ *
+* Copyright (C) Johan Engelen 2007 <j.b.c.engelen@utwente.nl>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include <glib.h>
+
+
+#include "live_effects/parameter/parameter.h"
+#include "live_effects/parameter/item-reference.h"
+#include <stddef.h>
+#include <sigc++/sigc++.h>
+
+namespace Inkscape {
+
+namespace LivePathEffect {
+
+class ItemParam : public Parameter {
+public:
+ ItemParam ( const Glib::ustring& label,
+ const Glib::ustring& tip,
+ const Glib::ustring& key,
+ Inkscape::UI::Widget::Registry* wr,
+ Effect* effect,
+ const gchar * default_value = "");
+ virtual ~ItemParam();
+ virtual Gtk::Widget * param_newWidget();
+
+ virtual bool param_readSVGValue(const gchar * strvalue);
+ virtual gchar * param_getSVGValue() const;
+
+ virtual void param_set_default();
+ virtual void param_update_default(const gchar * default_value);
+ void param_set_and_write_default();
+ virtual void addCanvasIndicators(SPLPEItem const* lpeitem, std::vector<Geom::PathVector> &hp_vec);
+
+ sigc::signal <void> signal_item_pasted;
+ sigc::signal <void> signal_item_changed;
+ bool changed; /* this gets set whenever the path is changed (this is set to true, and then the signal_item_changed signal is emitted).
+ * the user must set it back to false if she wants to use it sensibly */
+protected:
+
+ gchar * href; // contains link to other object, e.g. "#path2428", NULL if ItemParam contains pathdata itself
+ ItemReference ref;
+ sigc::connection ref_changed_connection;
+ sigc::connection linked_delete_connection;
+ sigc::connection linked_modified_connection;
+ sigc::connection linked_transformed_connection;
+ void ref_changed(SPObject *old_ref, SPObject *new_ref);
+ void remove_link();
+ void start_listening(SPObject * to);
+ void quit_listening(void);
+ void linked_delete(SPObject *deleted);
+ void linked_modified(SPObject *linked_obj, guint flags);
+ void linked_transformed(Geom::Affine const *rel_transf, SPItem *moved_item);
+ virtual void linked_modified_callback(SPObject *linked_obj, guint flags);
+ virtual void linked_transformed_callback(Geom::Affine const * /*rel_transf*/, SPItem * /*moved_item*/) {};
+ void on_link_button_click();
+
+ void emit_changed();
+
+ gchar * defvalue;
+
+private:
+ ItemParam(const ItemParam&);
+ ItemParam& operator=(const ItemParam&);
+};
+
+
+} //namespace LivePathEffect
+
+} //namespace Inkscape
+
+#endif
diff --git a/src/live_effects/parameter/originalitem.cpp b/src/live_effects/parameter/originalitem.cpp
new file mode 100644
index 000000000..053062128
--- /dev/null
+++ b/src/live_effects/parameter/originalitem.cpp
@@ -0,0 +1,129 @@
+/*
+ * Copyright (C) Johan Engelen 2012 <j.b.c.engelen@alumnus.utwente.nl>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <gtkmm/box.h>
+#include "live_effects/parameter/originalitem.h"
+
+#include "widgets/icon.h"
+#include <glibmm/i18n.h>
+#include <gtkmm/button.h>
+#include <gtkmm/label.h>
+
+#include "uri.h"
+#include "sp-shape.h"
+#include "sp-text.h"
+#include "display/curve.h"
+#include "live_effects/effect.h"
+
+#include "inkscape.h"
+#include "desktop.h"
+#include "selection.h"
+#include "ui/icon-names.h"
+
+namespace Inkscape {
+
+namespace LivePathEffect {
+
+OriginalItemParam::OriginalItemParam( const Glib::ustring& label, const Glib::ustring& tip,
+ const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr,
+ Effect* effect)
+ : ItemParam(label, tip, key, wr, effect, "")
+{
+}
+
+OriginalItemParam::~OriginalItemParam()
+{
+
+}
+
+Gtk::Widget *
+OriginalItemParam::param_newWidget()
+{
+ Gtk::HBox *_widget = Gtk::manage(new Gtk::HBox());
+
+ { // Label
+ Gtk::Label *pLabel = Gtk::manage(new Gtk::Label(param_label));
+ static_cast<Gtk::HBox*>(_widget)->pack_start(*pLabel, true, true);
+ pLabel->set_tooltip_text(param_tooltip);
+ }
+
+ { // Paste item to link button
+ Gtk::Widget *pIcon = Gtk::manage( sp_icon_get_icon( INKSCAPE_ICON("edit-paste"), Inkscape::ICON_SIZE_BUTTON) );
+ Gtk::Button *pButton = Gtk::manage(new Gtk::Button());
+ pButton->set_relief(Gtk::RELIEF_NONE);
+ pIcon->show();
+ pButton->add(*pIcon);
+ pButton->show();
+ pButton->signal_clicked().connect(sigc::mem_fun(*this, &OriginalItemParam::on_link_button_click));
+ static_cast<Gtk::HBox*>(_widget)->pack_start(*pButton, true, true);
+ pButton->set_tooltip_text(_("Link to item"));
+ }
+
+ { // Select original button
+ Gtk::Widget *pIcon = Gtk::manage( sp_icon_get_icon("edit-select-original", Inkscape::ICON_SIZE_BUTTON) );
+ Gtk::Button *pButton = Gtk::manage(new Gtk::Button());
+ pButton->set_relief(Gtk::RELIEF_NONE);
+ pIcon->show();
+ pButton->add(*pIcon);
+ pButton->show();
+ pButton->signal_clicked().connect(sigc::mem_fun(*this, &OriginalItemParam::on_select_original_button_click));
+ static_cast<Gtk::HBox*>(_widget)->pack_start(*pButton, true, true);
+ pButton->set_tooltip_text(_("Select original"));
+ }
+
+ static_cast<Gtk::HBox*>(_widget)->show_all_children();
+
+ return dynamic_cast<Gtk::Widget *> (_widget);
+}
+
+void
+OriginalItemParam::linked_modified_callback(SPObject *linked_obj, guint /*flags*/)
+{
+ if (!inverse) {
+ emit_changed();
+ SP_OBJECT(param_effect->getLPEObj())->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ }
+}
+
+void
+OriginalItemParam::linked_transformed_callback(Geom::Affine const * /*rel_transf*/, SPItem * /*moved_item*/)
+{
+/** \todo find good way to compensate for referenced item transform, like done for normal clones.
+ * See sp-use.cpp: sp_use_move_compensate */
+}
+
+
+void
+OriginalItemParam::on_select_original_button_click()
+{
+ SPDesktop *desktop = SP_ACTIVE_DESKTOP;
+ SPItem *original = ref.getObject();
+ if (desktop == NULL || original == NULL) {
+ return;
+ }
+ Inkscape::Selection *selection = desktop->getSelection();
+ selection->clear();
+ selection->set(original);
+}
+
+} /* namespace LivePathEffect */
+
+} /* namespace Inkscape */
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
diff --git a/src/live_effects/parameter/originalitem.h b/src/live_effects/parameter/originalitem.h
new file mode 100644
index 000000000..58d04e05a
--- /dev/null
+++ b/src/live_effects/parameter/originalitem.h
@@ -0,0 +1,49 @@
+#ifndef INKSCAPE_LIVEPATHEFFECT_PARAMETER_ORIGINAL_ITEM_H
+#define INKSCAPE_LIVEPATHEFFECT_PARAMETER_ORIGINAL_ITEM_H
+
+/*
+ * Inkscape::LiveItemEffectParameters
+ *
+* Copyright (C) Johan Engelen 2012 <j.b.c.engelen@alumnus.utwente.nl>
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "live_effects/parameter/item.h"
+
+namespace Inkscape {
+
+namespace LivePathEffect {
+
+class OriginalItemParam: public ItemParam {
+public:
+ OriginalItemParam ( const Glib::ustring& label,
+ const Glib::ustring& tip,
+ const Glib::ustring& key,
+ Inkscape::UI::Widget::Registry* wr,
+ Effect* effect);
+ virtual ~OriginalItemParam();
+ void setInverse(bool inversed) { inverse = inversed; }
+ bool linksToItem() const { return (href != NULL); }
+ SPItem * getObject() const { return ref.getObject(); }
+
+ virtual Gtk::Widget * param_newWidget();
+
+protected:
+ virtual void linked_modified_callback(SPObject *linked_obj, guint flags);
+ virtual void linked_transformed_callback(Geom::Affine const *rel_transf, SPItem *moved_item);
+
+ void on_select_original_button_click();
+
+private:
+ bool inverse;
+ OriginalItemParam(const OriginalItemParam&);
+ OriginalItemParam& operator=(const OriginalItemParam&);
+};
+
+
+} //namespace LivePathEffect
+
+} //namespace Inkscape
+
+#endif
diff --git a/src/live_effects/parameter/originalpath.cpp b/src/live_effects/parameter/originalpath.cpp
index 2741461be..1e78f7fe1 100644
--- a/src/live_effects/parameter/originalpath.cpp
+++ b/src/live_effects/parameter/originalpath.cpp
@@ -56,7 +56,7 @@ OriginalPathParam::param_newWidget()
}
{ // Paste path to link button
- Gtk::Widget *pIcon = Gtk::manage( sp_icon_get_icon( INKSCAPE_ICON("edit-paste"), Inkscape::ICON_SIZE_BUTTON) );
+ Gtk::Widget *pIcon = Gtk::manage( sp_icon_get_icon( INKSCAPE_ICON("edit-clone"), Inkscape::ICON_SIZE_BUTTON) );
Gtk::Button *pButton = Gtk::manage(new Gtk::Button());
pButton->set_relief(Gtk::RELIEF_NONE);
pIcon->show();
@@ -89,7 +89,7 @@ OriginalPathParam::linked_modified_callback(SPObject *linked_obj, guint /*flags*
{
SPCurve *curve = NULL;
if (SP_IS_SHAPE(linked_obj)) {
- curve = SP_SHAPE(linked_obj)->getCurveBeforeLPE();
+ curve = SP_SHAPE(linked_obj)->getCurve();
}
if (SP_IS_TEXT(linked_obj)) {
curve = SP_TEXT(linked_obj)->getNormalizedBpath();
diff --git a/src/live_effects/parameter/originalpatharray.cpp b/src/live_effects/parameter/originalpatharray.cpp
index 4ee068ebf..693821ed2 100644
--- a/src/live_effects/parameter/originalpatharray.cpp
+++ b/src/live_effects/parameter/originalpatharray.cpp
@@ -144,7 +144,7 @@ Gtk::Widget* OriginalPathArrayParam::param_newWidget()
{ // Paste path to link button
- Gtk::Widget *pIcon = Gtk::manage( sp_icon_get_icon("gtk-stock", Inkscape::ICON_SIZE_BUTTON) );
+ Gtk::Widget *pIcon = Gtk::manage( sp_icon_get_icon("edit-clone", Inkscape::ICON_SIZE_BUTTON) );
Gtk::Button *pButton = Gtk::manage(new Gtk::Button());
pButton->set_relief(Gtk::RELIEF_NONE);
pIcon->show();
@@ -386,7 +386,7 @@ void OriginalPathArrayParam::setPathVector(SPObject *linked_obj, guint /*flags*/
}
SPCurve *curve = NULL;
if (SP_IS_SHAPE(linked_obj)) {
- curve = SP_SHAPE(linked_obj)->getCurveBeforeLPE();
+ curve = SP_SHAPE(linked_obj)->getCurve();
}
if (SP_IS_TEXT(linked_obj)) {
curve = SP_TEXT(linked_obj)->getNormalizedBpath();
diff --git a/src/live_effects/parameter/originalpatharray.h b/src/live_effects/parameter/originalpatharray.h
index 296c0f7f7..fe9371644 100644
--- a/src/live_effects/parameter/originalpatharray.h
+++ b/src/live_effects/parameter/originalpatharray.h
@@ -65,12 +65,11 @@ public:
virtual bool param_readSVGValue(const gchar * strvalue);
virtual gchar * param_getSVGValue() const;
virtual void param_set_default();
-
+ virtual void param_update_default(const gchar * default_value){};
/** Disable the canvas indicators of parent class by overriding this method */
virtual void param_editOncanvas(SPItem * /*item*/, SPDesktop * /*dt*/) {};
/** Disable the canvas indicators of parent class by overriding this method */
virtual void addCanvasIndicators(SPLPEItem const* /*lpeitem*/, std::vector<Geom::PathVector> & /*hp_vec*/) {};
-
std::vector<PathAndDirection*> _vector;
protected:
diff --git a/src/live_effects/parameter/parameter.cpp b/src/live_effects/parameter/parameter.cpp
index d4e213948..2f73488aa 100644
--- a/src/live_effects/parameter/parameter.cpp
+++ b/src/live_effects/parameter/parameter.cpp
@@ -4,11 +4,9 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
-#include "ui/widget/registered-widget.h"
-#include <glibmm/i18n.h>
-#include "live_effects/parameter/parameter.h"
#include "live_effects/effect.h"
+#include "live_effects/parameter/parameter.h"
#include "svg/svg.h"
#include "xml/repr.h"
@@ -16,6 +14,8 @@
#include "verbs.h"
+#include <glibmm/i18n.h>
+
#define noLPEREALPARAM_DEBUG
namespace Inkscape {
@@ -39,6 +39,7 @@ Parameter::Parameter( const Glib::ustring& label, const Glib::ustring& tip,
void
Parameter::param_write_to_repr(const char * svgd)
{
+ param_effect->upd_params = true;
param_effect->getRepr()->setAttribute(param_key.c_str(), svgd);
}
@@ -54,7 +55,7 @@ void Parameter::write_to_SVG(void)
*/
ScalarParam::ScalarParam( const Glib::ustring& label, const Glib::ustring& tip,
const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr,
- Effect* effect, gdouble default_value, bool no_widget)
+ Effect* effect, gdouble default_value)
: Parameter(label, tip, key, wr, effect),
value(default_value),
min(-SCALARPARAM_G_MAXDOUBLE),
@@ -65,8 +66,7 @@ ScalarParam::ScalarParam( const Glib::ustring& label, const Glib::ustring& tip,
inc_step(0.1),
inc_page(1),
add_slider(false),
- overwrite_widget(false),
- hide_widget(no_widget)
+ _set_undo(true)
{
}
@@ -101,9 +101,28 @@ ScalarParam::param_set_default()
param_set_value(defvalue);
}
+void
+ScalarParam::param_update_default(gdouble default_value)
+{
+ defvalue = default_value;
+}
+
+void
+ScalarParam::param_update_default(const gchar * default_value)
+{
+ double newval;
+ unsigned int success = sp_svg_number_read_d(default_value, &newval);
+ if (success == 1) {
+ param_update_default(newval);
+ }
+}
+
void
ScalarParam::param_set_value(gdouble val)
{
+ if (value != val) {
+ param_effect->upd_params = true;
+ }
value = val;
if (integer)
value = round(value);
@@ -121,7 +140,6 @@ ScalarParam::param_set_range(gdouble min, gdouble max)
// Once again, in gtk2, this is not a problem. But in gtk3,
// widgets get allocated the amount of size they ask for,
// leading to excessively long widgets.
-
if (min >= -SCALARPARAM_G_MAXDOUBLE) {
this->min = min;
} else {
@@ -130,9 +148,8 @@ ScalarParam::param_set_range(gdouble min, gdouble max)
if (max <= SCALARPARAM_G_MAXDOUBLE) {
this->max = max;
} else {
- this->max = SCALARPARAM_G_MAXDOUBLE;
+ this->max = SCALARPARAM_G_MAXDOUBLE;
}
-
param_set_value(value); // reset value to see whether it is in ranges
}
@@ -146,15 +163,15 @@ ScalarParam::param_make_integer(bool yes)
}
void
-ScalarParam::param_overwrite_widget(bool overwrite_widget)
+ScalarParam::param_set_undo(bool set_undo)
{
- this->overwrite_widget = overwrite_widget;
+ _set_undo = set_undo;
}
Gtk::Widget *
ScalarParam::param_newWidget()
{
- if(!hide_widget){
+ if(widget_is_visible){
Inkscape::UI::Widget::RegisteredScalar *rsu = Gtk::manage( new Inkscape::UI::Widget::RegisteredScalar(
param_label, param_tooltip, param_key, *param_wr, param_effect->getRepr(), param_effect->getSPDoc() ) );
@@ -166,7 +183,7 @@ ScalarParam::param_newWidget()
if (add_slider) {
rsu->addSlider();
}
- if(!overwrite_widget){
+ if(_set_undo){
rsu->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change scalar parameter"));
}
return dynamic_cast<Gtk::Widget *> (rsu);
diff --git a/src/live_effects/parameter/parameter.h b/src/live_effects/parameter/parameter.h
index 0ef28650a..7ab7e30dd 100644
--- a/src/live_effects/parameter/parameter.h
+++ b/src/live_effects/parameter/parameter.h
@@ -12,6 +12,7 @@
#include <glibmm/ustring.h>
#include <2geom/forward.h>
#include <2geom/pathvector.h>
+#include "ui/widget/registered-widget.h"
// In gtk2, this wasn't an issue; we could toss around
// G_MAXDOUBLE and not worry about size allocations. But
@@ -56,10 +57,11 @@ public:
virtual bool param_readSVGValue(const gchar * strvalue) = 0; // returns true if new value is valid / accepted.
virtual gchar * param_getSVGValue() const = 0;
+ virtual void param_widget_is_visible(bool is_visible) {widget_is_visible = is_visible;}
void write_to_SVG();
virtual void param_set_default() = 0;
-
+ virtual void param_update_default(const gchar * default_value) = 0;
// This creates a new widget (newed with Gtk::manage(new ...);)
virtual Gtk::Widget * param_newWidget() = 0;
@@ -67,7 +69,7 @@ public:
// overload these for your particular parameter to make it provide knotholder handles or canvas helperpaths
virtual bool providesKnotHolderEntities() const { return false; }
- virtual void addKnotHolderEntities(KnotHolder */*knotholder*/, SPDesktop */*desktop*/, SPItem */*item*/) {};
+ virtual void addKnotHolderEntities(KnotHolder */*knotholder*/, SPItem */*item*/) {};
virtual void addCanvasIndicators(SPLPEItem const*/*lpeitem*/, std::vector<Geom::PathVector> &/*hp_vec*/) {};
virtual void param_editOncanvas(SPItem * /*item*/, SPDesktop * /*dt*/) {};
@@ -76,6 +78,7 @@ public:
virtual void param_transform_multiply(Geom::Affine const& /*postmul*/, bool /*set*/) {};
Glib::ustring param_key;
+ Glib::ustring param_tooltip;
Inkscape::UI::Widget::Registry * param_wr;
Glib::ustring param_label;
@@ -83,7 +86,6 @@ public:
bool widget_is_visible;
protected:
- Glib::ustring param_tooltip;
Effect* param_effect;
@@ -102,23 +104,24 @@ public:
const Glib::ustring& key,
Inkscape::UI::Widget::Registry* wr,
Effect* effect,
- gdouble default_value = 1.0,
- bool no_widget = false);
+ gdouble default_value = 1.0);
virtual ~ScalarParam();
virtual bool param_readSVGValue(const gchar * strvalue);
virtual gchar * param_getSVGValue() const;
virtual void param_set_default();
+ void param_update_default(gdouble default_value);
+ virtual void param_update_default(const gchar * default_value);
void param_set_value(gdouble val);
void param_make_integer(bool yes = true);
void param_set_range(gdouble min, gdouble max);
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; };
-
- void param_overwrite_widget(bool overwrite_widget);
+ double param_get_max() { return max; };
+ double param_get_min() { return min; };
+ void param_set_undo(bool set_undo);
virtual Gtk::Widget * param_newWidget();
inline operator gdouble() const { return value; };
@@ -133,8 +136,7 @@ protected:
double inc_step;
double inc_page;
bool add_slider;
- bool overwrite_widget;
- bool hide_widget;
+ bool _set_undo;
private:
ScalarParam(const ScalarParam&);
diff --git a/src/live_effects/parameter/path.cpp b/src/live_effects/parameter/path.cpp
index bed191e83..54f5d93e8 100644
--- a/src/live_effects/parameter/path.cpp
+++ b/src/live_effects/parameter/path.cpp
@@ -5,10 +5,16 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
-#include "ui/widget/point.h"
+#include "live_effects/parameter/path.h"
+
#include <glibmm/i18n.h>
-#include "live_effects/parameter/path.h"
+#include <gtkmm/button.h>
+#include <gtkmm/label.h>
+
+#include "bad-uri-exception.h"
+#include "ui/widget/point.h"
+
#include "live_effects/effect.h"
#include "svg/svg.h"
#include <2geom/svg-path-parser.h>
@@ -17,7 +23,6 @@
#include <2geom/d2.h>
#include "widgets/icon.h"
-#include <gtk/gtk.h>
#include "selection-chemistry.h"
#include "xml/repr.h"
#include "desktop.h"
@@ -44,8 +49,6 @@
#include "ui/tool/multi-path-manipulator.h"
#include "ui/tool/shape-record.h"
-#include <gtkmm/button.h>
-#include <gtkmm/label.h>
#include "ui/icon-names.h"
namespace Inkscape {
@@ -66,7 +69,10 @@ PathParam::PathParam( const Glib::ustring& label, const Glib::ustring& tip,
defvalue = g_strdup(default_value);
param_readSVGValue(defvalue);
oncanvas_editable = true;
-
+ _edit_button = true;
+ _copy_button = true;
+ _paste_button = true;
+ _link_button = true;
ref_changed_connection = ref.changedSignal().connect(sigc::mem_fun(*this, &PathParam::ref_changed));
}
@@ -164,6 +170,15 @@ PathParam::param_getSVGValue() const
}
}
+void
+PathParam::set_buttons(bool edit_button, bool copy_button, bool paste_button, bool link_button)
+{
+ _edit_button = edit_button;
+ _copy_button = copy_button;
+ _paste_button = paste_button;
+ _link_button = link_button;
+}
+
Gtk::Widget *
PathParam::param_newWidget()
{
@@ -172,47 +187,55 @@ PathParam::param_newWidget()
Gtk::Label* pLabel = Gtk::manage(new Gtk::Label(param_label));
static_cast<Gtk::HBox*>(_widget)->pack_start(*pLabel, true, true);
pLabel->set_tooltip_text(param_tooltip);
-
- Gtk::Widget* pIcon = Gtk::manage( sp_icon_get_icon( INKSCAPE_ICON("tool-node-editor"), Inkscape::ICON_SIZE_BUTTON) );
- Gtk::Button * pButton = Gtk::manage(new Gtk::Button());
- pButton->set_relief(Gtk::RELIEF_NONE);
- pIcon->show();
- pButton->add(*pIcon);
- pButton->show();
- pButton->signal_clicked().connect(sigc::mem_fun(*this, &PathParam::on_edit_button_click));
- static_cast<Gtk::HBox*>(_widget)->pack_start(*pButton, true, true);
- pButton->set_tooltip_text(_("Edit on-canvas"));
-
- pIcon = Gtk::manage( sp_icon_get_icon( INKSCAPE_ICON("edit-copy"), Inkscape::ICON_SIZE_BUTTON) );
- pButton = Gtk::manage(new Gtk::Button());
- pButton->set_relief(Gtk::RELIEF_NONE);
- pIcon->show();
- pButton->add(*pIcon);
- pButton->show();
- pButton->signal_clicked().connect(sigc::mem_fun(*this, &PathParam::on_copy_button_click));
- static_cast<Gtk::HBox*>(_widget)->pack_start(*pButton, true, true);
- pButton->set_tooltip_text(_("Copy path"));
-
- pIcon = Gtk::manage( sp_icon_get_icon( INKSCAPE_ICON("edit-paste"), Inkscape::ICON_SIZE_BUTTON) );
- pButton = Gtk::manage(new Gtk::Button());
- pButton->set_relief(Gtk::RELIEF_NONE);
- pIcon->show();
- pButton->add(*pIcon);
- pButton->show();
- pButton->signal_clicked().connect(sigc::mem_fun(*this, &PathParam::on_paste_button_click));
- static_cast<Gtk::HBox*>(_widget)->pack_start(*pButton, true, true);
- pButton->set_tooltip_text(_("Paste path"));
-
- pIcon = Gtk::manage( sp_icon_get_icon( INKSCAPE_ICON("edit-clone"), Inkscape::ICON_SIZE_BUTTON) );
- pButton = Gtk::manage(new Gtk::Button());
- pButton->set_relief(Gtk::RELIEF_NONE);
- pIcon->show();
- pButton->add(*pIcon);
- pButton->show();
- pButton->signal_clicked().connect(sigc::mem_fun(*this, &PathParam::on_link_button_click));
- static_cast<Gtk::HBox*>(_widget)->pack_start(*pButton, true, true);
- pButton->set_tooltip_text(_("Link to path on clipboard"));
-
+ Gtk::Widget * pIcon = NULL;
+ Gtk::Button * pButton = NULL;
+ if (_edit_button) {
+ pIcon = Gtk::manage( sp_icon_get_icon( INKSCAPE_ICON("tool-node-editor"), Inkscape::ICON_SIZE_BUTTON) );
+ pButton = Gtk::manage(new Gtk::Button());
+ pButton->set_relief(Gtk::RELIEF_NONE);
+ pIcon->show();
+ pButton->add(*pIcon);
+ pButton->show();
+ pButton->signal_clicked().connect(sigc::mem_fun(*this, &PathParam::on_edit_button_click));
+ static_cast<Gtk::HBox*>(_widget)->pack_start(*pButton, true, true);
+ pButton->set_tooltip_text(_("Edit on-canvas"));
+ }
+
+ if (_copy_button) {
+ pIcon = Gtk::manage( sp_icon_get_icon( INKSCAPE_ICON("edit-copy"), Inkscape::ICON_SIZE_BUTTON) );
+ pButton = Gtk::manage(new Gtk::Button());
+ pButton->set_relief(Gtk::RELIEF_NONE);
+ pIcon->show();
+ pButton->add(*pIcon);
+ pButton->show();
+ pButton->signal_clicked().connect(sigc::mem_fun(*this, &PathParam::on_copy_button_click));
+ static_cast<Gtk::HBox*>(_widget)->pack_start(*pButton, true, true);
+ pButton->set_tooltip_text(_("Copy path"));
+ }
+
+ if (_paste_button) {
+ pIcon = Gtk::manage( sp_icon_get_icon( INKSCAPE_ICON("edit-paste"), Inkscape::ICON_SIZE_BUTTON) );
+ pButton = Gtk::manage(new Gtk::Button());
+ pButton->set_relief(Gtk::RELIEF_NONE);
+ pIcon->show();
+ pButton->add(*pIcon);
+ pButton->show();
+ pButton->signal_clicked().connect(sigc::mem_fun(*this, &PathParam::on_paste_button_click));
+ static_cast<Gtk::HBox*>(_widget)->pack_start(*pButton, true, true);
+ pButton->set_tooltip_text(_("Paste path"));
+ }
+ if (_link_button) {
+ pIcon = Gtk::manage( sp_icon_get_icon( INKSCAPE_ICON("edit-clone"), Inkscape::ICON_SIZE_BUTTON) );
+ pButton = Gtk::manage(new Gtk::Button());
+ pButton->set_relief(Gtk::RELIEF_NONE);
+ pIcon->show();
+ pButton->add(*pIcon);
+ pButton->show();
+ pButton->signal_clicked().connect(sigc::mem_fun(*this, &PathParam::on_link_button_click));
+ static_cast<Gtk::HBox*>(_widget)->pack_start(*pButton, true, true);
+ pButton->set_tooltip_text(_("Link to path on clipboard"));
+ }
+
static_cast<Gtk::HBox*>(_widget)->show_all_children();
return dynamic_cast<Gtk::Widget *> (_widget);
@@ -237,14 +260,14 @@ PathParam::param_editOncanvas(SPItem *item, SPDesktop * dt)
r.role = SHAPE_ROLE_LPE_PARAM;
r.edit_transform = item->i2dt_affine(); // TODO is it right?
- r.edit_transform *= item->transform.inverse();
if (!href) {
r.item = reinterpret_cast<SPItem*>(param_effect->getLPEObj());
r.lpe_key = param_key;
Geom::PathVector stored_pv = _pathvector;
param_write_to_repr("M0,0 L1,0");
- const char *svgd = sp_svg_write_path(stored_pv);
+ gchar *svgd = sp_svg_write_path(stored_pv);
param_write_to_repr(svgd);
+ g_free(svgd);
} else {
r.item = ref.getObject();
}
@@ -437,6 +460,10 @@ PathParam::linked_modified_callback(SPObject *linked_obj, guint /*flags*/)
SP_OBJECT(param_effect->getLPEObj())->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
+void
+PathParam::param_update_default(const gchar * default_value){
+ defvalue = strdup(default_value);
+}
/* CALLBACK FUNCTIONS FOR THE BUTTONS */
void
@@ -458,8 +485,7 @@ PathParam::paste_param_path(const char *svgd)
SPItem * item = SP_ACTIVE_DESKTOP->getSelection()->singleItem();
if (item != NULL) {
Geom::PathVector path_clipboard = sp_svg_read_pathv(svgd);
- path_clipboard *= item->i2doc_affine().inverse() * item->transform;
- path_clipboard *= Geom::Translate(path_clipboard.initialPoint() - _pathvector.initialPoint()).inverse();
+ path_clipboard *= item->i2doc_affine().inverse();
svgd = sp_svg_write_path( path_clipboard );
}
diff --git a/src/live_effects/parameter/path.h b/src/live_effects/parameter/path.h
index d2dddbe97..ff5e4f1b8 100644
--- a/src/live_effects/parameter/path.h
+++ b/src/live_effects/parameter/path.h
@@ -40,10 +40,11 @@ public:
virtual gchar * param_getSVGValue() const;
virtual void param_set_default();
+ virtual void param_update_default(const gchar * default_value);
void param_set_and_write_default();
void set_new_value (Geom::PathVector const &newpath, bool write_to_svg);
void set_new_value (Geom::Piecewise<Geom::D2<Geom::SBasis> > const &newpath, bool write_to_svg);
-
+ void set_buttons(bool edit_button, bool copy_button, bool paste_button, bool link_button);
virtual void param_editOncanvas(SPItem * item, SPDesktop * dt);
virtual void param_setup_nodepath(Inkscape::NodePath::Path *np);
virtual void addCanvasIndicators(SPLPEItem const* lpeitem, std::vector<Geom::PathVector> &hp_vec);
@@ -90,6 +91,10 @@ protected:
gchar * defvalue;
private:
+ bool _edit_button;
+ bool _copy_button;
+ bool _paste_button;
+ bool _link_button;
PathParam(const PathParam&);
PathParam& operator=(const PathParam&);
};
diff --git a/src/live_effects/parameter/point.cpp b/src/live_effects/parameter/point.cpp
index ca3471b29..4ca88a6b8 100644
--- a/src/live_effects/parameter/point.cpp
+++ b/src/live_effects/parameter/point.cpp
@@ -4,7 +4,6 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
-#include "ui/widget/registered-widget.h"
#include "live_effects/parameter/point.h"
#include "live_effects/effect.h"
#include "svg/svg.h"
@@ -16,9 +15,6 @@
#include "knotholder.h"
#include <glibmm/i18n.h>
-// needed for on-canvas editting:
-#include "desktop.h"
-
namespace Inkscape {
namespace LivePathEffect {
@@ -62,9 +58,22 @@ PointParam::param_get_default() const{
}
void
-PointParam::param_update_default(Geom::Point newpoint)
+PointParam::param_update_default(Geom::Point default_point)
{
- defvalue = newpoint;
+ defvalue = default_point;
+}
+
+void
+PointParam::param_update_default(const gchar * default_point)
+{
+ gchar ** strarray = g_strsplit(default_point, ",", 2);
+ double newx, newy;
+ unsigned int success = sp_svg_number_read_d(strarray[0], &newx);
+ success += sp_svg_number_read_d(strarray[1], &newy);
+ g_strfreev (strarray);
+ if (success == 2) {
+ param_update_default( Geom::Point(newx, newy) );
+ }
}
void
@@ -123,9 +132,8 @@ PointParam::param_newWidget()
*param_wr,
param_effect->getRepr(),
param_effect->getSPDoc() ) );
- // TODO: fix to get correct desktop (don't use SP_ACTIVE_DESKTOP)
- SPDesktop *desktop = SP_ACTIVE_DESKTOP;
- Geom::Affine transf = desktop->doc2dt();
+ Geom::Affine transf = Geom::Scale(1, -1);
+ transf[5] = SP_ACTIVE_DOCUMENT->getHeight().value("px");
pointwdg->setTransform(transf);
pointwdg->setValue( *this );
pointwdg->clearProgrammatically();
@@ -134,7 +142,6 @@ PointParam::param_newWidget()
Gtk::HBox * hbox = Gtk::manage( new Gtk::HBox() );
static_cast<Gtk::HBox*>(hbox)->pack_start(*pointwdg, true, true);
static_cast<Gtk::HBox*>(hbox)->show_all_children();
-
return dynamic_cast<Gtk::Widget *> (hbox);
}
@@ -174,7 +181,7 @@ PointParamKnotHolderEntity::knot_set(Geom::Point const &p, Geom::Point const &or
s = A;
}
}
- pparam->param_setValue(s, this->pparam->liveupdate);
+ pparam->param_setValue(s);
SPLPEItem * splpeitem = dynamic_cast<SPLPEItem *>(item);
if(splpeitem && this->pparam->liveupdate){
sp_lpe_item_update_patheffect(splpeitem, false, false);
@@ -191,23 +198,23 @@ void
PointParamKnotHolderEntity::knot_click(guint state)
{
if (state & GDK_CONTROL_MASK) {
- if (state & GDK_MOD1_MASK) {
- this->pparam->param_set_default();
- SPLPEItem * splpeitem = dynamic_cast<SPLPEItem *>(item);
- if(splpeitem){
- sp_lpe_item_update_patheffect(splpeitem, false, false);
- }
+ if (state & GDK_MOD1_MASK) {
+ this->pparam->param_set_default();
+ SPLPEItem * splpeitem = dynamic_cast<SPLPEItem *>(item);
+ if(splpeitem){
+ sp_lpe_item_update_patheffect(splpeitem, false, false);
}
+ }
}
}
void
-PointParam::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item)
+PointParam::addKnotHolderEntities(KnotHolder *knotholder, SPItem *item)
{
knoth = knotholder;
PointParamKnotHolderEntity *e = new PointParamKnotHolderEntity(this);
// TODO: can we ditch handleTip() etc. because we have access to handle_tip etc. itself???
- e->create(desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, handleTip(), knot_shape, knot_mode, knot_color);
+ e->create(NULL, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, handleTip(), knot_shape, knot_mode, knot_color);
knotholder->add(e);
}
diff --git a/src/live_effects/parameter/point.h b/src/live_effects/parameter/point.h
index 4329e0bcd..a5153ad80 100644
--- a/src/live_effects/parameter/point.h
+++ b/src/live_effects/parameter/point.h
@@ -11,7 +11,7 @@
#include <glib.h>
#include <2geom/point.h>
-
+#include "ui/widget/registered-widget.h"
#include "live_effects/parameter/parameter.h"
#include "knot-holder-entity.h"
@@ -43,14 +43,15 @@ public:
void param_set_default();
Geom::Point param_get_default() const;
void param_set_liveupdate(bool live_update);
- void param_update_default(Geom::Point newpoint);
+ void param_update_default(Geom::Point default_point);
+
+ virtual void param_update_default(const gchar * default_point);
virtual void param_transform_multiply(Geom::Affine const& /*postmul*/, bool /*set*/);
void set_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, guint32 color);
virtual bool providesKnotHolderEntities() const { return true; }
- virtual void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item);
-
+ virtual void addKnotHolderEntities(KnotHolder *knotholder, SPItem *item);
friend class PointParamKnotHolderEntity;
private:
PointParam(const PointParam&);
diff --git a/src/live_effects/parameter/powerstrokepointarray.cpp b/src/live_effects/parameter/powerstrokepointarray.cpp
index c61e8f9cb..7753d819d 100644
--- a/src/live_effects/parameter/powerstrokepointarray.cpp
+++ b/src/live_effects/parameter/powerstrokepointarray.cpp
@@ -248,11 +248,11 @@ PowerStrokePointArrayParamKnotHolderEntity::knot_click(guint state)
}
}
-void PowerStrokePointArrayParam::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item)
+void PowerStrokePointArrayParam::addKnotHolderEntities(KnotHolder *knotholder, SPItem *item)
{
for (unsigned int i = 0; i < _vector.size(); ++i) {
PowerStrokePointArrayParamKnotHolderEntity *e = new PowerStrokePointArrayParamKnotHolderEntity(this, i);
- e->create( desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN,
+ e->create(NULL, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN,
_("<b>Stroke width control point</b>: drag to alter the stroke width. <b>Ctrl+click</b> adds a control point, <b>Ctrl+Alt+click</b> deletes it, <b>Shift+click</b> launches width dialog."),
knot_shape, knot_mode, knot_color);
knotholder->add(e);
diff --git a/src/live_effects/parameter/powerstrokepointarray.h b/src/live_effects/parameter/powerstrokepointarray.h
index 70b22e27e..a34163ca1 100644
--- a/src/live_effects/parameter/powerstrokepointarray.h
+++ b/src/live_effects/parameter/powerstrokepointarray.h
@@ -38,14 +38,14 @@ public:
float median_width();
virtual bool providesKnotHolderEntities() const { return true; }
- virtual void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item);
+ virtual void addKnotHolderEntities(KnotHolder *knotholder, SPItem *item);
+ virtual void param_update_default(const gchar * default_value){};
void set_pwd2(Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in, Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_normal_in);
Geom::Piecewise<Geom::D2<Geom::SBasis> > const & get_pwd2() const { return last_pwd2; }
Geom::Piecewise<Geom::D2<Geom::SBasis> > const & get_pwd2_normal() const { return last_pwd2_normal; }
void recalculate_controlpoints_for_new_pwd2(Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in);
-
friend class PowerStrokePointArrayParamKnotHolderEntity;
private:
diff --git a/src/live_effects/parameter/random.cpp b/src/live_effects/parameter/random.cpp
index 075e85ee1..b1375adda 100644
--- a/src/live_effects/parameter/random.cpp
+++ b/src/live_effects/parameter/random.cpp
@@ -78,8 +78,23 @@ RandomParam::param_set_default()
}
void
+RandomParam::param_update_default(gdouble default_value){
+ defvalue = default_value;
+}
+
+void
+RandomParam::param_update_default(const gchar * default_value){
+ double newval;
+ unsigned int success = sp_svg_number_read_d(default_value, &newval);
+ if (success == 1) {
+ param_update_default(newval);
+ }
+}
+
+void
RandomParam::param_set_value(gdouble val, long newseed)
{
+ param_effect->upd_params = true;
value = val;
if (integer)
value = round(value);
diff --git a/src/live_effects/parameter/random.h b/src/live_effects/parameter/random.h
index ca4440336..5fb6027ac 100644
--- a/src/live_effects/parameter/random.h
+++ b/src/live_effects/parameter/random.h
@@ -38,9 +38,9 @@ public:
void param_set_value(gdouble val, long newseed);
void param_make_integer(bool yes = true);
void param_set_range(gdouble min, gdouble max);
-
+ void param_update_default(gdouble default_value);
+ virtual void param_update_default(const gchar * default_value);
void resetRandomizer();
-
operator gdouble();
inline gdouble get_value() { return value; } ;
diff --git a/src/live_effects/parameter/satellitesarray.cpp b/src/live_effects/parameter/satellitesarray.cpp
new file mode 100644
index 000000000..ce4da243e
--- /dev/null
+++ b/src/live_effects/parameter/satellitesarray.cpp
@@ -0,0 +1,584 @@
+/*
+ * Author(s):
+ * Jabiertxo Arraiza Cenoz <jabier.arraiza@marker.es>
+ *
+ * Copyright (C) 2014 Author(s)
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "knotholder.h"
+#include "ui/dialog/lpe-fillet-chamfer-properties.h"
+#include "live_effects/parameter/satellitesarray.h"
+#include "live_effects/effect.h"
+#include "sp-lpe-item.h"
+#include "inkscape.h"
+#include <preferences.h>
+// TODO due to internal breakage in glibmm headers,
+// this has to be included last.
+#include <glibmm/i18n.h>
+
+namespace Inkscape {
+
+namespace LivePathEffect {
+
+SatellitesArrayParam::SatellitesArrayParam(const Glib::ustring &label,
+ const Glib::ustring &tip,
+ const Glib::ustring &key,
+ Inkscape::UI::Widget::Registry *wr,
+ Effect *effect)
+ : ArrayParam<std::vector<Satellite> >(label, tip, key, wr, effect, 0), _knoth(NULL)
+{
+ _knot_shape = SP_KNOT_SHAPE_DIAMOND;
+ _knot_mode = SP_KNOT_MODE_XOR;
+ _knot_color = 0xAAFF8800;
+ _helper_size = 0;
+ _use_distance = false;
+ _global_knot_hide = false;
+ _current_zoom = 0;
+ _effectType = FILLET_CHAMFER;
+ _last_pathvector_satellites = NULL;
+ param_widget_is_visible(false);
+}
+
+
+void SatellitesArrayParam::set_oncanvas_looks(SPKnotShapeType shape,
+ SPKnotModeType mode,
+ guint32 color)
+{
+ _knot_shape = shape;
+ _knot_mode = mode;
+ _knot_color = color;
+}
+
+void SatellitesArrayParam::setPathVectorSatellites(PathVectorSatellites *pathVectorSatellites, bool write)
+{
+ _last_pathvector_satellites = pathVectorSatellites;
+ if (write) {
+ param_set_and_write_new_value(_last_pathvector_satellites->getSatellites());
+ } else {
+ param_setValue(_last_pathvector_satellites->getSatellites());
+ }
+}
+
+void SatellitesArrayParam::setUseDistance(bool use_knot_distance)
+{
+ _use_distance = use_knot_distance;
+}
+
+void SatellitesArrayParam::setCurrentZoom(double current_zoom)
+{
+ _current_zoom = current_zoom;
+}
+
+void SatellitesArrayParam::setGlobalKnotHide(bool global_knot_hide)
+{
+ _global_knot_hide = global_knot_hide;
+}
+void SatellitesArrayParam::setEffectType(EffectType et)
+{
+ _effectType = et;
+}
+
+void SatellitesArrayParam::setHelperSize(int hs)
+{
+ _helper_size = hs;
+ updateCanvasIndicators();
+}
+
+void SatellitesArrayParam::updateCanvasIndicators(bool mirror)
+{
+ if (!_last_pathvector_satellites) {
+ return;
+ }
+
+ if (!_hp.empty()) {
+ _hp.clear();
+ }
+ Geom::PathVector pathv = _last_pathvector_satellites->getPathVector();
+ if (pathv.empty()) {
+ return;
+ }
+ if (mirror == true) {
+ _hp.clear();
+ }
+ if (_effectType == FILLET_CHAMFER) {
+ for (size_t i = 0; i < _vector.size(); ++i) {
+ for (size_t j = 0; j < _vector[i].size(); ++j) {
+ if (_vector[i][j].hidden || //Ignore if hidden
+ (!_vector[i][j].has_mirror && mirror == true) || //Ignore if not have mirror and we are in mirror loop
+ _vector[i][j].amount == 0 || //no helper in 0 value
+ pathv[i].size() == j || //ignore last satellite in open paths with fillet chamfer effect
+ (!pathv[i].closed() && j == 0)) //ignore first satellites on open paths
+ {
+ continue;
+ }
+ Geom::Curve *curve_in = pathv[i][j].duplicate();
+ double pos = 0;
+ bool overflow = false;
+ double size_out = _vector[i][j].arcDistance(*curve_in);
+ double lenght_out = curve_in->length();
+ gint previous_index = j - 1; //Always are previous index because we skip first satellite on open paths
+ if (j == 0 && pathv[i].closed()) {
+ previous_index = pathv[i].size() - 1;
+ }
+ if ( previous_index < 0 ) {
+ return;
+ }
+ double lenght_in = pathv.curveAt(previous_index).length();
+ if (mirror) {
+ curve_in = const_cast<Geom::Curve *>(&pathv.curveAt(previous_index));
+ pos = _vector[i][j].time(size_out, true, *curve_in);
+ if (lenght_out < size_out) {
+ overflow = true;
+ }
+ } else {
+ pos = _vector[i][j].time(*curve_in);
+ if (lenght_in < size_out) {
+ overflow = true;
+ }
+ }
+ if (pos <= 0 || pos >= 1) {
+ continue;
+ }
+ Geom::Point point_a = curve_in->pointAt(pos);
+ Geom::Point deriv_a = unit_vector(derivative(curve_in->toSBasis()).pointAt(pos));
+ Geom::Rotate rot(Geom::Rotate::from_degrees(-90));
+ deriv_a = deriv_a * rot;
+ Geom::Point point_c = point_a - deriv_a * _helper_size;
+ Geom::Point point_d = point_a + deriv_a * _helper_size;
+ Geom::Ray ray_1(point_c, point_d);
+ char const *svgd = "M 1,0.25 0.5,0 1,-0.25 M 1,0.5 0,0 1,-0.5";
+ Geom::PathVector pathv = sp_svg_read_pathv(svgd);
+ Geom::Affine aff = Geom::Affine();
+ aff *= Geom::Scale(_helper_size);
+ if (mirror) {
+ aff *= Geom::Rotate(ray_1.angle() - Geom::rad_from_deg(90));
+ } else {
+ aff *= Geom::Rotate(ray_1.angle() - Geom::rad_from_deg(270));
+ }
+ aff *= Geom::Translate(curve_in->pointAt(pos));
+ pathv *= aff;
+ _hp.push_back(pathv[0]);
+ _hp.push_back(pathv[1]);
+ if (overflow) {
+ double diameter = _helper_size;
+ if (_helper_size == 0) {
+ diameter = 15;
+ char const *svgd;
+ svgd = "M 0.7,0.35 A 0.35,0.35 0 0 1 0.35,0.7 0.35,0.35 0 0 1 0,0.35 "
+ "0.35,0.35 0 0 1 0.35,0 0.35,0.35 0 0 1 0.7,0.35 Z";
+ Geom::PathVector pathv = sp_svg_read_pathv(svgd);
+ aff = Geom::Affine();
+ aff *= Geom::Scale(diameter);
+ aff *= Geom::Translate(point_a - Geom::Point(diameter * 0.35, diameter * 0.35));
+ pathv *= aff;
+ _hp.push_back(pathv[0]);
+ } else {
+ char const *svgd;
+ svgd = "M 0 -1.32 A 1.32 1.32 0 0 0 -1.32 0 A 1.32 1.32 0 0 0 0 1.32 A "
+ "1.32 1.32 0 0 0 1.18 0.59 L 0 0 L 1.18 -0.59 A 1.32 1.32 0 0 0 "
+ "0 -1.32 z";
+ Geom::PathVector pathv = sp_svg_read_pathv(svgd);
+ aff = Geom::Affine();
+ aff *= Geom::Scale(_helper_size / 2.0);
+ if (mirror) {
+ aff *= Geom::Rotate(ray_1.angle() - Geom::rad_from_deg(90));
+ } else {
+ aff *= Geom::Rotate(ray_1.angle() - Geom::rad_from_deg(270));
+ }
+ aff *= Geom::Translate(curve_in->pointAt(pos));
+ pathv *= aff;
+ _hp.push_back(pathv[0]);
+ }
+ }
+ }
+ }
+ }
+ if (!_knot_reset_helper.empty()) {
+ _hp.insert(_hp.end(), _knot_reset_helper.begin(), _knot_reset_helper.end() );
+ }
+ if (mirror) {
+ updateCanvasIndicators(false);
+ }
+}
+void SatellitesArrayParam::updateCanvasIndicators()
+{
+ updateCanvasIndicators(true);
+}
+
+void SatellitesArrayParam::addCanvasIndicators(
+ SPLPEItem const */*lpeitem*/, std::vector<Geom::PathVector> &hp_vec)
+{
+ hp_vec.push_back(_hp);
+}
+
+void SatellitesArrayParam::param_transform_multiply(Geom::Affine const &postmul, bool /*set*/)
+{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+
+ if (prefs->getBool("/options/transform/rectcorners", true)) {
+ for (size_t i = 0; i < _vector.size(); ++i) {
+ for (size_t j = 0; j < _vector[i].size(); ++j) {
+ if (!_vector[i][j].is_time && _vector[i][j].amount > 0) {
+ _vector[i][j].amount = _vector[i][j].amount * ((postmul.expansionX() + postmul.expansionY()) / 2);
+ }
+ }
+ }
+ param_set_and_write_new_value(_vector);
+ }
+}
+
+void SatellitesArrayParam::addKnotHolderEntities(KnotHolder *knotholder,
+ SPItem *item,
+ bool mirror)
+{
+ if (!_last_pathvector_satellites) {
+ return;
+ }
+ Geom::PathVector pathv = _last_pathvector_satellites->getPathVector();
+ size_t index = 0;
+ for (size_t i = 0; i < _vector.size(); ++i) {
+ for (size_t j = 0; j < _vector[i].size(); ++j) {
+ if (!_vector[i][j].has_mirror && mirror) {
+ continue;
+ }
+ SatelliteType type = _vector[i][j].satellite_type;
+ if (mirror && i == 0 && j == 0) {
+ index = index + _last_pathvector_satellites->getTotalSatellites();
+ }
+ using namespace Geom;
+ //If is for filletChamfer effect...
+ if (_effectType == FILLET_CHAMFER) {
+ const gchar *tip;
+ if (type == CHAMFER) {
+ tip = _("<b>Chamfer</b>: <b>Ctrl+Click</b> toggles type, "
+ "<b>Shift+Click</b> open dialog, "
+ "<b>Ctrl+Alt+Click</b> reset");
+ } else if (type == INVERSE_CHAMFER) {
+ tip = _("<b>Inverse Chamfer</b>: <b>Ctrl+Click</b> toggles type, "
+ "<b>Shift+Click</b> open dialog, "
+ "<b>Ctrl+Alt+Click</b> reset");
+ } else if (type == INVERSE_FILLET) {
+ tip = _("<b>Inverse Fillet</b>: <b>Ctrl+Click</b> toggles type, "
+ "<b>Shift+Click</b> open dialog, "
+ "<b>Ctrl+Alt+Click</b> reset");
+ } else {
+ tip = _("<b>Fillet</b>: <b>Ctrl+Click</b> toggles type, "
+ "<b>Shift+Click</b> open dialog, "
+ "<b>Ctrl+Alt+Click</b> reset");
+ }
+ FilletChamferKnotHolderEntity *e = new FilletChamferKnotHolderEntity(this, index);
+ e->create(NULL, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, _(tip),_knot_shape, _knot_mode, _knot_color);
+ knotholder->add(e);
+ }
+ index++;
+ }
+ }
+ if (mirror) {
+ addKnotHolderEntities(knotholder, item, false);
+ }
+}
+
+void SatellitesArrayParam::addKnotHolderEntities(KnotHolder *knotholder,
+ SPItem *item)
+{
+ _knoth = knotholder;
+ addKnotHolderEntities(knotholder, item, true);
+}
+
+FilletChamferKnotHolderEntity::FilletChamferKnotHolderEntity(
+ SatellitesArrayParam *p, size_t index)
+ : _pparam(p), _index(index) {}
+
+void FilletChamferKnotHolderEntity::knot_set(Geom::Point const &p,
+ Geom::Point const &/*origin*/,
+ guint state)
+{
+ if (!_pparam->_last_pathvector_satellites) {
+ return;
+ }
+ size_t total_satellites = _pparam->_last_pathvector_satellites->getTotalSatellites();
+ bool is_mirror = false;
+ size_t index = _index;
+ if (_index >= total_satellites) {
+ index = _index - total_satellites;
+ is_mirror = true;
+ }
+ std::pair<size_t, size_t> index_data = _pparam->_last_pathvector_satellites->getIndexData(index);
+ size_t path_index = index_data.first;
+ size_t curve_index = index_data.second;
+
+ Geom::Point s = snap_knot_position(p, state);
+ if (!valid_index(path_index, curve_index)) {
+ return;
+ }
+ Satellite satellite = _pparam->_vector[path_index][curve_index];
+ Geom::PathVector pathv = _pparam->_last_pathvector_satellites->getPathVector();
+ if (satellite.hidden ||
+ (!pathv[path_index].closed() && curve_index == 0) ||//ignore first satellites on open paths
+ pathv[path_index].size() == curve_index) //ignore last satellite in open paths with fillet chamfer effect
+ {
+ return;
+ }
+ gint previous_index = curve_index - 1;
+ if (curve_index == 0 && pathv[path_index].closed()) {
+ previous_index = pathv[path_index].size() - 1;
+ }
+ if ( previous_index < 0 ) {
+ return;
+ }
+ Geom::Curve const &curve_in = pathv[path_index][previous_index];
+ double mirror_time = Geom::nearest_time(s, curve_in);
+ Geom::Point mirror = curve_in.pointAt(mirror_time);
+ double normal_time = Geom::nearest_time(s, pathv[path_index][curve_index]);
+ Geom::Point normal = pathv[path_index][curve_index].pointAt(normal_time);
+ double distance_mirror = Geom::distance(mirror,s);
+ double distance_normal = Geom::distance(normal,s);
+ if (Geom::are_near(s, pathv[path_index][curve_index].initialPoint(), 1.5 / _pparam->_current_zoom)) {
+ satellite.amount = 0;
+ } else if (distance_mirror < distance_normal) {
+ double time_start = 0;
+ Satellites satellites = _pparam->_last_pathvector_satellites->getSatellites();
+ time_start = satellites[path_index][previous_index].time(curve_in);
+ if (time_start > mirror_time) {
+ mirror_time = time_start;
+ }
+ double size = arcLengthAt(mirror_time, curve_in);
+ double amount = curve_in.length() - size;
+ if (satellite.is_time) {
+ amount = timeAtArcLength(amount, pathv[path_index][curve_index]);
+ }
+ satellite.amount = amount;
+ } else {
+ satellite.setPosition(s, pathv[path_index][curve_index]);
+ }
+ _pparam->_knot_reset_helper.clear();
+ if (satellite.amount == 0) {
+ char const *svgd;
+ svgd = "M -5.39,8.78 -9.13,5.29 -10.38,10.28 Z M -7.22,7.07 -3.43,3.37 m -1.95,-12.16 -3.74,3.5 -1.26,-5 z "
+ "m -1.83,1.71 3.78,3.7 M 5.24,8.78 8.98,5.29 10.24,10.28 Z "
+ "M 7.07,7.07 3.29,3.37 M 5.24,-8.78 l 3.74,3.5 1.26,-5 z M 7.07,-7.07 3.29,-3.37";
+ _pparam->_knot_reset_helper = sp_svg_read_pathv(svgd);
+ _pparam->_knot_reset_helper *= Geom::Affine(_pparam->_helper_size * 0.1,0,0,_pparam->_helper_size * 0.1,0,0) * Geom::Translate(pathv[path_index][curve_index].initialPoint());
+ }
+ _pparam->_vector[path_index][curve_index] = satellite;
+ sp_lpe_item_update_patheffect(SP_LPE_ITEM(item), false, false);
+}
+
+Geom::Point FilletChamferKnotHolderEntity::knot_get() const
+{
+ if (!_pparam->_last_pathvector_satellites || _pparam->_global_knot_hide) {
+ return Geom::Point(Geom::infinity(), Geom::infinity());
+ }
+ Geom::Point tmp_point;
+ size_t total_satellites = _pparam->_last_pathvector_satellites->getTotalSatellites();
+ bool is_mirror = false;
+ size_t index = _index;
+ if (_index >= total_satellites) {
+ index = _index - total_satellites;
+ is_mirror = true;
+ }
+ std::pair<size_t, size_t> index_data = _pparam->_last_pathvector_satellites->getIndexData(index);
+ size_t path_index = index_data.first;
+ size_t curve_index = index_data.second;
+ if (!valid_index(path_index, curve_index)) {
+ return Geom::Point(Geom::infinity(), Geom::infinity());
+ }
+ Satellite satellite = _pparam->_vector[path_index][curve_index];
+ Geom::PathVector pathv = _pparam->_last_pathvector_satellites->getPathVector();
+ if (satellite.hidden ||
+ (!pathv[path_index].closed() && curve_index == 0) ||//ignore first satellites on open paths
+ pathv[path_index].size() == curve_index) //ignore last satellite in open paths with fillet chamfer effect
+ {
+ return Geom::Point(Geom::infinity(), Geom::infinity());
+ }
+ this->knot->show();
+ if (is_mirror) {
+ gint previous_index = curve_index - 1;
+ if (curve_index == 0 && pathv[path_index].closed()) {
+ previous_index = pathv[path_index].size() - 1;
+ }
+ if ( previous_index < 0 ) {
+ return Geom::Point(Geom::infinity(), Geom::infinity());
+ }
+ Geom::Curve const &curve_in = pathv[path_index][previous_index];
+ double s = satellite.arcDistance(pathv[path_index][curve_index]);
+ double t = satellite.time(s, true, curve_in);
+ if (t > 1) {
+ t = 1;
+ }
+ if (t < 0) {
+ t = 0;
+ }
+ double time_start = 0;
+ time_start = _pparam->_last_pathvector_satellites->getSatellites()[path_index][previous_index].time(curve_in);
+ if (time_start > t) {
+ t = time_start;
+ }
+ tmp_point = (curve_in).pointAt(t);
+ } else {
+ tmp_point = satellite.getPosition(pathv[path_index][curve_index]);
+ }
+ Geom::Point const canvas_point = tmp_point;
+ _pparam->updateCanvasIndicators();
+ return canvas_point;
+}
+
+void FilletChamferKnotHolderEntity::knot_click(guint state)
+{
+ if (!_pparam->_last_pathvector_satellites) {
+ return;
+ }
+ size_t total_satellites = _pparam->_last_pathvector_satellites->getTotalSatellites();
+ bool is_mirror = false;
+ size_t index = _index;
+ if (_index >= total_satellites) {
+ index = _index - total_satellites;
+ is_mirror = true;
+ }
+ std::pair<size_t, size_t> index_data = _pparam->_last_pathvector_satellites->getIndexData(index);
+ size_t path_index = index_data.first;
+ size_t curve_index = index_data.second;
+ if (!valid_index(path_index, curve_index)) {
+ return;
+ }
+ Geom::PathVector pathv = _pparam->_last_pathvector_satellites->getPathVector();
+ if ((!pathv[path_index].closed() && curve_index == 0) ||//ignore first satellites on open paths
+ pathv[path_index].size() == curve_index) //ignore last satellite in open paths with fillet chamfer effect
+ {
+ return;
+ }
+ if (state & GDK_CONTROL_MASK) {
+ if (state & GDK_MOD1_MASK) {
+ _pparam->_vector[path_index][curve_index].amount = 0.0;
+ sp_lpe_item_update_patheffect(SP_LPE_ITEM(item), false, false);
+ } else {
+ using namespace Geom;
+ SatelliteType type = _pparam->_vector[path_index][curve_index].satellite_type;
+ switch (type) {
+ case FILLET:
+ type = INVERSE_FILLET;
+ break;
+ case INVERSE_FILLET:
+ type = CHAMFER;
+ break;
+ case CHAMFER:
+ type = INVERSE_CHAMFER;
+ break;
+ default:
+ type = FILLET;
+ break;
+ }
+ _pparam->_vector[path_index][curve_index].satellite_type = type;
+ sp_lpe_item_update_patheffect(SP_LPE_ITEM(item), false, false);
+ const gchar *tip;
+ if (type == CHAMFER) {
+ tip = _("<b>Chamfer</b>: <b>Ctrl+Click</b> toggles type, "
+ "<b>Shift+Click</b> open dialog, "
+ "<b>Ctrl+Alt+Click</b> resets");
+ } else if (type == INVERSE_CHAMFER) {
+ tip = _("<b>Inverse Chamfer</b>: <b>Ctrl+Click</b> toggles type, "
+ "<b>Shift+Click</b> open dialog, "
+ "<b>Ctrl+Alt+Click</b> resets");
+ } else if (type == INVERSE_FILLET) {
+ tip = _("<b>Inverse Fillet</b>: <b>Ctrl+Click</b> toggles type, "
+ "<b>Shift+Click</b> open dialog, "
+ "<b>Ctrl+Alt+Click</b> resets");
+ } else {
+ tip = _("<b>Fillet</b>: <b>Ctrl+Click</b> toggles type, "
+ "<b>Shift+Click</b> open dialog, "
+ "<b>Ctrl+Alt+Click</b> resets");
+ }
+ this->knot->tip = g_strdup(tip);
+ this->knot->show();
+ }
+ } else if (state & GDK_SHIFT_MASK) {
+ double amount = _pparam->_vector[path_index][curve_index].amount;
+ gint previous_index = curve_index - 1;
+ if (curve_index == 0 && pathv[path_index].closed()) {
+ previous_index = pathv[path_index].size() - 1;
+ }
+ if ( previous_index < 0 ) {
+ return;
+ }
+ if (!_pparam->_use_distance && !_pparam->_vector[path_index][curve_index].is_time) {
+ amount = _pparam->_vector[path_index][curve_index].lenToRad(amount, pathv[path_index][previous_index], pathv[path_index][curve_index], _pparam->_vector[path_index][previous_index]);
+ }
+ bool aprox = false;
+ Geom::D2<Geom::SBasis> d2_out = pathv[path_index][curve_index].toSBasis();
+ Geom::D2<Geom::SBasis> d2_in = pathv[path_index][previous_index].toSBasis();
+ aprox = ((d2_in)[0].degreesOfFreedom() != 2 ||
+ d2_out[0].degreesOfFreedom() != 2) &&
+ !_pparam->_use_distance
+ ? true
+ : false;
+ Inkscape::UI::Dialogs::FilletChamferPropertiesDialog::showDialog(
+ this->desktop, amount, this, _pparam->_use_distance,
+ aprox, _pparam->_vector[path_index][curve_index]);
+
+ }
+}
+
+void FilletChamferKnotHolderEntity::knot_set_offset(Satellite satellite)
+{
+ if (!_pparam->_last_pathvector_satellites) {
+ return;
+ }
+ size_t total_satellites = _pparam->_last_pathvector_satellites->getTotalSatellites();
+ bool is_mirror = false;
+ size_t index = _index;
+ if (_index >= total_satellites) {
+ index = _index - total_satellites;
+ is_mirror = true;
+ }
+ std::pair<size_t, size_t> index_data = _pparam->_last_pathvector_satellites->getIndexData(index);
+ size_t path_index = index_data.first;
+ size_t curve_index = index_data.second;
+ if (!valid_index(path_index, curve_index)) {
+ return;
+ }
+ Geom::PathVector pathv = _pparam->_last_pathvector_satellites->getPathVector();
+ if (satellite.hidden ||
+ (!pathv[path_index].closed() && curve_index == 0) ||//ignore first satellites on open paths
+ pathv[path_index].size() == curve_index) //ignore last satellite in open paths with fillet chamfer effect
+ {
+ return;
+ }
+ double amount = satellite.amount;
+ double max_amount = amount;
+ if (!_pparam->_use_distance && !satellite.is_time) {
+ gint previous_index = curve_index - 1;
+ if (curve_index == 0 && pathv[path_index].closed()) {
+ previous_index = pathv[path_index].size() - 1;
+ }
+ if ( previous_index < 0 ) {
+ return;
+ }
+ amount = _pparam->_vector[path_index][curve_index].radToLen(amount, pathv[path_index][previous_index], pathv[path_index][curve_index]);
+ if (max_amount > 0 && amount == 0) {
+ amount = _pparam->_vector[path_index][curve_index].amount;
+ }
+ }
+ satellite.amount = amount;
+ _pparam->_vector[path_index][curve_index] = satellite;
+ this->parent_holder->knot_ungrabbed_handler(this->knot, 0);
+ SPLPEItem *splpeitem = dynamic_cast<SPLPEItem *>(item);
+ if (splpeitem) {
+ sp_lpe_item_update_patheffect(splpeitem, false, false);
+ }
+}
+
+} /* namespace LivePathEffect */
+
+} /* namespace Inkscape */
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
diff --git a/src/live_effects/parameter/satellitesarray.h b/src/live_effects/parameter/satellitesarray.h
new file mode 100644
index 000000000..5ae372ac2
--- /dev/null
+++ b/src/live_effects/parameter/satellitesarray.h
@@ -0,0 +1,114 @@
+#ifndef INKSCAPE_LIVEPATHEFFECT_SATELLITES_ARRAY_H
+#define INKSCAPE_LIVEPATHEFFECT_SATELLITES_ARRAY_H
+
+/*
+ * Inkscape::LivePathEffectParameters
+ * Copyright (C) Jabiertxo Arraiza Cenoz <jabier.arraiza@marker.es>
+ * Special thanks to Johan Engelen for the base of the effect -powerstroke-
+ * Also to ScislaC for point me to the idea
+ * Also su_v for his construvtive feedback and time
+ * To Nathan Hurst for his review and help on refactor
+ * and finaly to Liam P. White for his big help on coding, that save me a lot of
+ * hours
+ *
+ *
+ * This parameter act as bridge from pathVectorSatellites class to serialize it as a LPE
+ * parameter
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include "live_effects/parameter/array.h"
+#include "live_effects/effect-enum.h"
+#include "helper/geom-pathvectorsatellites.h"
+#include "knot-holder-entity.h"
+#include <glib.h>
+
+namespace Inkscape {
+
+namespace LivePathEffect {
+
+class FilletChamferKnotHolderEntity;
+
+class SatellitesArrayParam : public ArrayParam<std::vector<Satellite> > {
+public:
+ SatellitesArrayParam(const Glib::ustring &label, const Glib::ustring &tip,
+ const Glib::ustring &key,
+ Inkscape::UI::Widget::Registry *wr, Effect *effect);
+
+ virtual Gtk::Widget *param_newWidget()
+ {
+ return NULL;
+ }
+ virtual void setHelperSize(int hs);
+ virtual void addKnotHolderEntities(KnotHolder *knotholder, SPItem *item);
+ virtual void addKnotHolderEntities(KnotHolder *knotholder, SPItem *item, bool mirror);
+ virtual void addCanvasIndicators(SPLPEItem const *lpeitem, std::vector<Geom::PathVector> &hp_vec);
+ virtual void updateCanvasIndicators();
+ virtual void updateCanvasIndicators(bool mirror);
+ virtual bool providesKnotHolderEntities() const
+ {
+ return true;
+ }
+ void param_transform_multiply(Geom::Affine const &postmul, bool /*set*/);
+ void setUseDistance(bool use_knot_distance);
+ void setCurrentZoom(double current_zoom);
+ void setGlobalKnotHide(bool global_knot_hide);
+ void setEffectType(EffectType et);
+ void setPathVectorSatellites(PathVectorSatellites *pathVectorSatellites, bool write = true);
+ void set_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, guint32 color);
+
+ friend class FilletChamferKnotHolderEntity;
+ friend class LPEFilletChamfer;
+
+protected:
+ KnotHolder *_knoth;
+
+private:
+ SatellitesArrayParam(const SatellitesArrayParam &);
+ SatellitesArrayParam &operator=(const SatellitesArrayParam &);
+
+ SPKnotShapeType _knot_shape;
+ SPKnotModeType _knot_mode;
+ guint32 _knot_color;
+ Geom::PathVector _hp;
+ Geom::PathVector _knot_reset_helper;
+ int _helper_size;
+ bool _use_distance;
+ bool _global_knot_hide;
+ double _current_zoom;
+ EffectType _effectType;
+ PathVectorSatellites *_last_pathvector_satellites;
+
+};
+
+class FilletChamferKnotHolderEntity : public KnotHolderEntity {
+public:
+ FilletChamferKnotHolderEntity(SatellitesArrayParam *p, size_t index);
+ virtual ~FilletChamferKnotHolderEntity()
+ {
+ _pparam->_knoth = NULL;
+ }
+
+ virtual void knot_set(Geom::Point const &p, Geom::Point const &origin,
+ guint state);
+ virtual Geom::Point knot_get() const;
+ virtual void knot_click(guint state);
+ void knot_set_offset(Satellite);
+ /** Checks whether the index falls within the size of the parameter's vector
+ */
+ bool valid_index(size_t index,size_t subindex) const
+ {
+ return (_pparam->_vector.size() > index && _pparam->_vector[index].size() > subindex);
+ };
+
+private:
+ SatellitesArrayParam *_pparam;
+ size_t _index;
+};
+
+} //namespace LivePathEffect
+
+} //namespace Inkscape
+
+#endif
diff --git a/src/live_effects/parameter/text.cpp b/src/live_effects/parameter/text.cpp
index 234a6174d..d633666aa 100644
--- a/src/live_effects/parameter/text.cpp
+++ b/src/live_effects/parameter/text.cpp
@@ -31,12 +31,16 @@ TextParam::TextParam( const Glib::ustring& label, const Glib::ustring& tip,
Effect* effect, const Glib::ustring default_value )
: Parameter(label, tip, key, wr, effect),
value(default_value),
- defvalue(default_value)
+ defvalue(default_value),
+ _hide_canvas_text(false)
{
- SPDesktop *desktop = SP_ACTIVE_DESKTOP; // FIXME: we shouldn't use this!
- canvas_text = (SPCanvasText *) sp_canvastext_new(desktop->getTempGroup(), desktop, Geom::Point(0,0), "");
- sp_canvastext_set_text (canvas_text, default_value.c_str());
- sp_canvastext_set_coords (canvas_text, 0, 0);
+ if (SPDesktop *desktop = SP_ACTIVE_DESKTOP) { // FIXME: we shouldn't use this!
+ canvas_text = (SPCanvasText *) sp_canvastext_new(desktop->getTempGroup(), desktop, Geom::Point(0,0), "");
+ sp_canvastext_set_text (canvas_text, default_value.c_str());
+ sp_canvastext_set_coords (canvas_text, 0, 0);
+ } else {
+ _hide_canvas_text = true;
+ }
}
void
@@ -46,9 +50,26 @@ TextParam::param_set_default()
}
void
+TextParam::param_update_default(const gchar * default_value)
+{
+ defvalue = (Glib::ustring)default_value;
+}
+
+void
+TextParam::param_hide_canvas_text()
+{
+ if (!_hide_canvas_text) {
+ sp_canvastext_set_text(canvas_text, " ");
+ _hide_canvas_text = true;
+ }
+}
+
+void
TextParam::setPos(Geom::Point pos)
{
- sp_canvastext_set_coords (canvas_text, pos);
+ if (!_hide_canvas_text) {
+ sp_canvastext_set_coords (canvas_text, pos);
+ }
}
void
@@ -63,9 +84,10 @@ TextParam::setPosAndAnchor(const Geom::Piecewise<Geom::D2<Geom::SBasis> > &pwd2,
Point dir = unit_vector(derivative(pwd2_reparam).valueAt(t_reparam));
Point n = -rot90(dir);
double angle = Geom::angle_between(dir, Point(1,0));
-
- sp_canvastext_set_coords(canvas_text, pos + n * length);
- sp_canvastext_set_anchor_manually(canvas_text, std::sin(angle), -std::cos(angle));
+ if (!_hide_canvas_text) {
+ sp_canvastext_set_coords(canvas_text, pos + n * length);
+ sp_canvastext_set_anchor_manually(canvas_text, std::sin(angle), -std::cos(angle));
+ }
}
void
@@ -73,7 +95,9 @@ TextParam::setAnchor(double x_value, double y_value)
{
anchor_x = x_value;
anchor_y = y_value;
- sp_canvastext_set_anchor_manually (canvas_text, anchor_x, anchor_y);
+ if (!_hide_canvas_text) {
+ sp_canvastext_set_anchor_manually (canvas_text, anchor_x, anchor_y);
+ }
}
bool
@@ -86,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 *
@@ -94,21 +121,23 @@ TextParam::param_newWidget()
{
Inkscape::UI::Widget::RegisteredText *rsu = Gtk::manage(new Inkscape::UI::Widget::RegisteredText(
param_label, param_tooltip, param_key, *param_wr, param_effect->getRepr(), param_effect->getSPDoc()));
-
- rsu->setText(value.c_str());
+ rsu->setText(value);
rsu->setProgrammatically = false;
rsu->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change text parameter"));
-
return dynamic_cast<Gtk::Widget *> (rsu);
}
void
TextParam::param_setValue(const Glib::ustring newvalue)
{
+ if (value != newvalue) {
+ param_effect->upd_params = true;
+ }
value = newvalue;
-
- sp_canvastext_set_text (canvas_text, newvalue.c_str());
+ if (!_hide_canvas_text) {
+ sp_canvastext_set_text (canvas_text, newvalue.c_str());
+ }
}
} /* namespace LivePathEffect */
diff --git a/src/live_effects/parameter/text.h b/src/live_effects/parameter/text.h
index 62de70eec..137f3ee02 100644
--- a/src/live_effects/parameter/text.h
+++ b/src/live_effects/parameter/text.h
@@ -39,21 +39,23 @@ public:
virtual bool param_readSVGValue(const gchar * strvalue);
virtual gchar * param_getSVGValue() const;
- void param_setValue(const Glib::ustring newvalue);
+ void param_setValue(Glib::ustring newvalue);
+ void param_hide_canvas_text();
virtual void param_set_default();
+ virtual void param_update_default(const gchar * default_value);
void setPos(Geom::Point pos);
void setPosAndAnchor(const Geom::Piecewise<Geom::D2<Geom::SBasis> > &pwd2,
const double t, const double length, bool use_curvature = false);
void setAnchor(double x_value, double y_value);
- const Glib::ustring get_value() const { return defvalue; };
+ const Glib::ustring get_value() const { return value; };
private:
TextParam(const TextParam&);
TextParam& operator=(const TextParam&);
double anchor_x;
double anchor_y;
-
+ bool _hide_canvas_text;
Glib::ustring value;
Glib::ustring defvalue;
diff --git a/src/live_effects/parameter/togglebutton.cpp b/src/live_effects/parameter/togglebutton.cpp
index 47a8b5615..eb40a7e41 100644
--- a/src/live_effects/parameter/togglebutton.cpp
+++ b/src/live_effects/parameter/togglebutton.cpp
@@ -12,6 +12,7 @@
#include "live_effects/effect.h"
#include "svg/svg.h"
#include "svg/stringstream.h"
+#include "selection.h"
#include "widgets/icon.h"
#include "inkscape.h"
#include "verbs.h"
@@ -24,10 +25,10 @@ namespace LivePathEffect {
ToggleButtonParam::ToggleButtonParam( const Glib::ustring& label, const Glib::ustring& tip,
const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr,
Effect* effect, bool default_value, const Glib::ustring& inactive_label,
- char const * icon_active, char const * icon_inactive,
- Inkscape::IconSize icon_size)
+ char const * _icon_active, char const * _icon_inactive,
+ Inkscape::IconSize _icon_size)
: Parameter(label, tip, key, wr, effect), value(default_value), defvalue(default_value),
- inactiveLabel(inactive_label), iconActive(icon_active), iconInactive(icon_inactive), iconSize(icon_size)
+ inactive_label(inactive_label), _icon_active(_icon_active), _icon_inactive(_icon_inactive), _icon_size(_icon_size)
{
checkwdg = NULL;
}
@@ -59,6 +60,18 @@ ToggleButtonParam::param_getSVGValue() const
return str;
}
+void
+ToggleButtonParam::param_update_default(bool default_value)
+{
+ defvalue = default_value;
+}
+
+void
+ToggleButtonParam::param_update_default(const gchar * default_value)
+{
+ param_update_default(helperfns_read_bool(default_value, defvalue));
+}
+
Gtk::Widget *
ToggleButtonParam::param_newWidget()
{
@@ -67,52 +80,50 @@ ToggleButtonParam::param_newWidget()
}
checkwdg = Gtk::manage(
- new Inkscape::UI::Widget::RegisteredToggleButton( param_label,
+ new Inkscape::UI::Widget::RegisteredToggleButton(param_label,
param_tooltip,
param_key,
*param_wr,
false,
param_effect->getRepr(),
param_effect->getSPDoc()) );
-#if GTK_CHECK_VERSION(3,0,0)
- GtkWidget * boxButton = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
- gtk_box_set_homogeneous(GTK_BOX(boxButton), false);
-#else
- GtkWidget * boxButton = gtk_hbox_new (false, 0);
-#endif
- GtkWidget * labelButton = gtk_label_new ("");
+ auto box_button = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
+ gtk_box_set_homogeneous(GTK_BOX(box_button), false);
+ GtkWidget * label_button = gtk_label_new ("");
if (!param_label.empty()) {
- if(value || inactiveLabel.empty()){
- gtk_label_set_text(GTK_LABEL(labelButton), param_label.c_str());
+ if(value || inactive_label.empty()){
+ gtk_label_set_text(GTK_LABEL(label_button), param_label.c_str());
}else{
- gtk_label_set_text(GTK_LABEL(labelButton), inactiveLabel.c_str());
+ gtk_label_set_text(GTK_LABEL(label_button), inactive_label.c_str());
}
}
- gtk_widget_show(labelButton);
- if ( iconActive ) {
- if(!iconInactive){
- iconInactive = iconActive;
+ gtk_widget_show(label_button);
+ if ( _icon_active ) {
+ if(!_icon_inactive){
+ _icon_inactive = _icon_active;
}
- gtk_widget_show(boxButton);
- GtkWidget *iconButton = sp_icon_new(iconSize, iconActive);
+ gtk_widget_show(box_button);
+ GtkWidget *icon_button = NULL;
if(!value){
- iconButton = sp_icon_new(iconSize, iconInactive);
+ icon_button = sp_icon_new(_icon_size, _icon_inactive);
+ } else {
+ icon_button = sp_icon_new(_icon_size, _icon_active);
}
- gtk_widget_show(iconButton);
- gtk_box_pack_start (GTK_BOX(boxButton), iconButton, false, false, 1);
+ gtk_widget_show(icon_button);
+ gtk_box_pack_start (GTK_BOX(box_button), icon_button, false, false, 1);
if (!param_label.empty()) {
- gtk_box_pack_start (GTK_BOX(boxButton), labelButton, false, false, 1);
+ gtk_box_pack_start (GTK_BOX(box_button), label_button, false, false, 1);
}
}else{
- gtk_box_pack_start (GTK_BOX(boxButton), labelButton, false, false, 1);
+ gtk_box_pack_start (GTK_BOX(box_button), label_button, false, false, 1);
}
- checkwdg->add(*Gtk::manage(Glib::wrap(boxButton)));
+
+ checkwdg->add(*Gtk::manage(Glib::wrap(box_button)));
checkwdg->setActive(value);
checkwdg->setProgrammatically = false;
checkwdg->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change togglebutton parameter"));
_toggled_connection = checkwdg->signal_toggled().connect(sigc::mem_fun(*this, &ToggleButtonParam::toggled));
-
return checkwdg;
}
@@ -126,37 +137,46 @@ ToggleButtonParam::refresh_button()
if(!checkwdg){
return;
}
- Gtk::Widget * boxButton = checkwdg->get_child();
- if(!boxButton){
+ Gtk::Widget * box_button = checkwdg->get_child();
+ if(!box_button){
return;
}
- GList * childs = gtk_container_get_children(GTK_CONTAINER(boxButton->gobj()));
- guint totalWidgets = g_list_length (childs);
+ GList * childs = gtk_container_get_children(GTK_CONTAINER(box_button->gobj()));
+ guint total_widgets = g_list_length (childs);
if (!param_label.empty()) {
- if(value || inactiveLabel.empty()){
- gtk_label_set_text(GTK_LABEL(g_list_nth_data(childs, totalWidgets-1)), param_label.c_str());
+ if(value || inactive_label.empty()){
+ gtk_label_set_text(GTK_LABEL(g_list_nth_data(childs, total_widgets-1)), param_label.c_str());
}else{
- gtk_label_set_text(GTK_LABEL(g_list_nth_data(childs, totalWidgets-1)), inactiveLabel.c_str());
+ gtk_label_set_text(GTK_LABEL(g_list_nth_data(childs, total_widgets-1)), inactive_label.c_str());
}
}
- if ( iconActive ) {
- GdkPixbuf * iconPixbuf = sp_pixbuf_new( iconSize, iconActive );
+ if ( _icon_active ) {
+ GdkPixbuf * icon_pixbuf = NULL;
if(!value){
- iconPixbuf = sp_pixbuf_new( iconSize, iconInactive);
+ icon_pixbuf = sp_pixbuf_new( _icon_size, _icon_inactive );
+ } else {
+ icon_pixbuf = sp_pixbuf_new( _icon_size, _icon_active );
}
- gtk_image_set_from_pixbuf (GTK_IMAGE(g_list_nth_data(childs, 0)), iconPixbuf);
+ gtk_image_set_from_pixbuf (GTK_IMAGE(g_list_nth_data(childs, 0)), icon_pixbuf);
}
}
void
ToggleButtonParam::param_setValue(bool newvalue)
{
+ if (value != newvalue) {
+ param_effect->upd_params = true;
+ }
value = newvalue;
refresh_button();
}
void
ToggleButtonParam::toggled() {
+ if (SP_ACTIVE_DESKTOP) {
+ Inkscape::Selection *selection = SP_ACTIVE_DESKTOP->getSelection();
+ selection->emitModified();
+ }
_signal_toggled.emit();
}
diff --git a/src/live_effects/parameter/togglebutton.h b/src/live_effects/parameter/togglebutton.h
index 4e545bcfd..d6ca15e75 100644
--- a/src/live_effects/parameter/togglebutton.h
+++ b/src/live_effects/parameter/togglebutton.h
@@ -51,6 +51,8 @@ public:
sigc::signal<void>& signal_toggled() { return _signal_toggled; }
virtual void toggled();
+ void param_update_default(bool default_value);
+ virtual void param_update_default(const gchar * default_value);
private:
ToggleButtonParam(const ToggleButtonParam&);
@@ -59,10 +61,10 @@ private:
void refresh_button();
bool value;
bool defvalue;
- const Glib::ustring inactiveLabel;
- const char * iconActive;
- const char * iconInactive;
- Inkscape::IconSize iconSize;
+ const Glib::ustring inactive_label;
+ const char * _icon_active;
+ const char * _icon_inactive;
+ Inkscape::IconSize _icon_size;
Inkscape::UI::Widget::RegisteredToggleButton * checkwdg;
sigc::signal<void> _signal_toggled;
diff --git a/src/live_effects/parameter/transformedpoint.cpp b/src/live_effects/parameter/transformedpoint.cpp
index 0d03432c3..22d5ba3a4 100644
--- a/src/live_effects/parameter/transformedpoint.cpp
+++ b/src/live_effects/parameter/transformedpoint.cpp
@@ -82,6 +82,25 @@ TransformedPointParam::param_getSVGValue() const
return str;
}
+void
+TransformedPointParam::param_update_default(Geom::Point default_point)
+{
+ defvalue = default_point;
+}
+
+void
+TransformedPointParam::param_update_default(const gchar * default_point)
+{
+ gchar ** strarray = g_strsplit(default_point, ",", 2);
+ double newx, newy;
+ unsigned int success = sp_svg_number_read_d(strarray[0], &newx);
+ success += sp_svg_number_read_d(strarray[1], &newy);
+ g_strfreev (strarray);
+ if (success == 2) {
+ param_update_default( Geom::Point(newx, newy) );
+ }
+}
+
Gtk::Widget *
TransformedPointParam::param_newWidget()
{
diff --git a/src/live_effects/parameter/transformedpoint.h b/src/live_effects/parameter/transformedpoint.h
index c96bedb53..269cc508e 100644
--- a/src/live_effects/parameter/transformedpoint.h
+++ b/src/live_effects/parameter/transformedpoint.h
@@ -51,7 +51,9 @@ public:
void set_vector_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, guint32 color);
void set_oncanvas_color(guint32 color);
-
+ Geom::Point param_get_default() { return defvalue; }
+ void param_update_default(Geom::Point default_point);
+ virtual void param_update_default(const gchar * default_point);
virtual bool providesKnotHolderEntities() const { return true; }
virtual void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item);
diff --git a/src/live_effects/parameter/unit.cpp b/src/live_effects/parameter/unit.cpp
index 0ee553e2c..b9b91c1e6 100644
--- a/src/live_effects/parameter/unit.cpp
+++ b/src/live_effects/parameter/unit.cpp
@@ -54,9 +54,16 @@ UnitParam::param_set_default()
param_set_value(*defunit);
}
+void
+UnitParam::param_update_default(const gchar * default_unit)
+{
+ defunit = unit_table.getUnit((Glib::ustring)default_unit);
+}
+
void
UnitParam::param_set_value(Inkscape::Util::Unit const &val)
{
+ param_effect->upd_params = true;
unit = new Inkscape::Util::Unit(val);
}
diff --git a/src/live_effects/parameter/unit.h b/src/live_effects/parameter/unit.h
index 59a483018..c662b6edc 100644
--- a/src/live_effects/parameter/unit.h
+++ b/src/live_effects/parameter/unit.h
@@ -33,10 +33,10 @@ public:
virtual gchar * param_getSVGValue() const;
virtual void param_set_default();
void param_set_value(Inkscape::Util::Unit const &val);
+ virtual void param_update_default(const gchar * default_unit);
const gchar *get_abbreviation() const;
-
virtual Gtk::Widget * param_newWidget();
-
+
operator Inkscape::Util::Unit const *() const { return unit; }
private:
diff --git a/src/live_effects/parameter/vector.cpp b/src/live_effects/parameter/vector.cpp
index cfaa9e7e7..470fa9c2d 100644
--- a/src/live_effects/parameter/vector.cpp
+++ b/src/live_effects/parameter/vector.cpp
@@ -14,7 +14,6 @@
#include "svg/stringstream.h"
#include "live_effects/effect.h"
-#include "desktop.h"
#include "verbs.h"
namespace Inkscape {
@@ -49,6 +48,25 @@ VectorParam::param_set_default()
setVector(defvalue);
}
+void
+VectorParam::param_update_default(Geom::Point default_point)
+{
+ defvalue = default_point;
+}
+
+void
+VectorParam::param_update_default(const gchar * default_point)
+{
+ gchar ** strarray = g_strsplit(default_point, ",", 2);
+ double newx, newy;
+ unsigned int success = sp_svg_number_read_d(strarray[0], &newx);
+ success += sp_svg_number_read_d(strarray[1], &newy);
+ g_strfreev (strarray);
+ if (success == 2) {
+ param_update_default( Geom::Point(newx, newy) );
+ }
+}
+
bool
VectorParam::param_readSVGValue(const gchar * strvalue)
{
@@ -117,7 +135,7 @@ VectorParam::set_and_write_new_values(Geom::Point const &new_origin, Geom::Point
void
VectorParam::param_transform_multiply(Geom::Affine const& postmul, bool /*set*/)
{
- set_and_write_new_values( origin * postmul, vector * postmul.withoutTranslation() );
+ set_and_write_new_values( origin * postmul, vector * postmul.withoutTranslation() );
}
@@ -188,14 +206,14 @@ private:
};
void
-VectorParam::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item)
+VectorParam::addKnotHolderEntities(KnotHolder *knotholder, SPItem *item)
{
VectorParamKnotHolderEntity_Origin *origin_e = new VectorParamKnotHolderEntity_Origin(this);
- origin_e->create(desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, handleTip(), ori_knot_shape, ori_knot_mode, ori_knot_color);
+ origin_e->create(NULL, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, handleTip(), ori_knot_shape, ori_knot_mode, ori_knot_color);
knotholder->add(origin_e);
VectorParamKnotHolderEntity_Vector *vector_e = new VectorParamKnotHolderEntity_Vector(this);
- vector_e->create(desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, handleTip(), vec_knot_shape, vec_knot_mode, vec_knot_color);
+ vector_e->create(NULL, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, handleTip(), vec_knot_shape, vec_knot_mode, vec_knot_color);
knotholder->add(vector_e);
}
diff --git a/src/live_effects/parameter/vector.h b/src/live_effects/parameter/vector.h
index 35ca04437..d270e9f43 100644
--- a/src/live_effects/parameter/vector.h
+++ b/src/live_effects/parameter/vector.h
@@ -51,9 +51,10 @@ public:
void set_vector_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, guint32 color);
void set_origin_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, guint32 color);
void set_oncanvas_color(guint32 color);
-
+ void param_update_default(Geom::Point default_point);
+ virtual void param_update_default(const gchar * default_point);
virtual bool providesKnotHolderEntities() const { return true; }
- virtual void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item);
+ virtual void addKnotHolderEntities(KnotHolder *knotholder, SPItem *item);
private:
VectorParam(const VectorParam&);