summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2015-09-01 17:13:06 +0000
committerJabiertxof <jtx@jtx.marker.es>2015-09-01 17:13:06 +0000
commit6f342e449becb621a2f93f492b38791ec5aba35d (patch)
tree131870f18f5a3853b98c9742e0e165b110978289 /src
parentastyle code (diff)
parentextensions. dxf_outlines. add support for line, circle, ellipse. (Bug 1489320... (diff)
downloadinkscape-6f342e449becb621a2f93f492b38791ec5aba35d.tar.gz
inkscape-6f342e449becb621a2f93f492b38791ec5aba35d.zip
update to trunk
(bzr r13645.1.117)
Diffstat (limited to 'src')
-rw-r--r--src/desktop.cpp2
-rw-r--r--src/document.cpp77
-rw-r--r--src/extension/internal/metafile-print.cpp4
-rw-r--r--src/extension/internal/pdfinput/svg-builder.cpp1
-rw-r--r--src/io/streamtest.cpp1
-rw-r--r--src/libuemf/uemf.c6
-rw-r--r--src/live_effects/lpe-bspline.cpp44
-rw-r--r--src/live_effects/lpe-bspline.h3
-rw-r--r--src/live_effects/lpe-powerstroke.cpp7
-rw-r--r--src/live_effects/lpe-transform_2pts.cpp116
-rw-r--r--src/live_effects/lpe-transform_2pts.h11
-rw-r--r--src/live_effects/parameter/togglebutton.cpp4
-rw-r--r--src/ui/dialog/grid-arrange-tab.cpp12
-rw-r--r--src/ui/tool/node.cpp2
-rw-r--r--src/ui/tool/path-manipulator.cpp2
-rw-r--r--src/ui/widget/color-entry.h2
16 files changed, 208 insertions, 86 deletions
diff --git a/src/desktop.cpp b/src/desktop.cpp
index 02df50c6b..7b20bcb9f 100644
--- a/src/desktop.cpp
+++ b/src/desktop.cpp
@@ -1876,6 +1876,8 @@ SPDesktop::show_dialogs()
mapVerbPreference.insert(std::make_pair ("ObjectProperties", "/dialogs/object") );
mapVerbPreference.insert(std::make_pair ("SpellCheck", "/dialogs/spellcheck") );
mapVerbPreference.insert(std::make_pair ("Symbols", "/dialogs/symbols") );
+ mapVerbPreference.insert(std::make_pair ("ObjectsPanel", "/dialogs/objects") );
+ mapVerbPreference.insert(std::make_pair ("TagsPanel", "/dialogs/tags") );
for (std::map<Glib::ustring, Glib::ustring>::const_iterator iter = mapVerbPreference.begin(); iter != mapVerbPreference.end(); ++iter) {
Glib::ustring pref = iter->second;
diff --git a/src/document.cpp b/src/document.cpp
index 2ea969910..d6a2e1b98 100644
--- a/src/document.cpp
+++ b/src/document.cpp
@@ -1335,20 +1335,11 @@ SPItem *SPDocument::getItemFromListAtPointBottom(unsigned int dkey, SPGroup *gro
}
/**
-Returns the topmost (in z-order) item from the descendants of group (recursively) which
-is at the point p, or NULL if none. Honors into_groups on whether to recurse into
-non-layer groups or not. Honors take_insensitive on whether to return insensitive
-items. If upto != NULL, then if item upto is encountered (at any level), stops searching
-upwards in z-order and returns what it has found so far (i.e. the found item is
-guaranteed to be lower than upto).
- */
-static SPItem *find_item_at_point(unsigned int dkey, SPGroup *group, Geom::Point const &p, gboolean into_groups, bool take_insensitive = false, SPItem *upto = NULL)
+Turn the SVG DOM into a flat list of nodes that can be searched from top-down.
+The list can be persisted, which improves "find at multiple points" speed.
+*/
+static void build_flat_item_list(std::deque<SPItem*> *nodes, unsigned int dkey, SPGroup *group, gboolean into_groups, bool take_insensitive = false, SPItem *upto = NULL)
{
- SPItem *seen = NULL;
- SPItem *newseen = NULL;
- Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- gdouble delta = prefs->getDouble("/options/cursortolerance/value", 1.0);
-
for ( SPObject *o = group->firstChild() ; o ; o = o->getNext() ) {
if (!SP_IS_ITEM(o)) {
continue;
@@ -1359,27 +1350,43 @@ static SPItem *find_item_at_point(unsigned int dkey, SPGroup *group, Geom::Point
}
if (SP_IS_GROUP(o) && (SP_GROUP(o)->effectiveLayerMode(dkey) == SPGroup::LAYER || into_groups)) {
- // if nothing found yet, recurse into the group
- newseen = find_item_at_point(dkey, SP_GROUP(o), p, into_groups, take_insensitive, upto);
- if (newseen) {
- seen = newseen;
- newseen = NULL;
- }
-
- if (item_is_in_group(upto, SP_GROUP(o))) {
- break;
- }
+ build_flat_item_list(nodes, dkey, SP_GROUP(o), into_groups, take_insensitive, upto);
} else {
SPItem *child = SP_ITEM(o);
- Inkscape::DrawingItem *arenaitem = child->get_arenaitem(dkey);
- // seen remembers the last (topmost) of items pickable at this point
- if (arenaitem && arenaitem->pick(p, delta, 1) != NULL
- && (take_insensitive || child->isVisibleAndUnlocked(dkey))) {
- seen = child;
+ if (take_insensitive || child->isVisibleAndUnlocked(dkey)) {
+ nodes->push_front(child);
}
}
}
+}
+
+/**
+Returns the topmost (in z-order) item from the descendants of group (recursively) which
+is at the point p, or NULL if none. Honors into_groups on whether to recurse into
+non-layer groups or not. Honors take_insensitive on whether to return insensitive
+items. If upto != NULL, then if item upto is encountered (at any level), stops searching
+upwards in z-order and returns what it has found so far (i.e. the found item is
+guaranteed to be lower than upto). Requires a list of nodes built by
+build_flat_item_list.
+ */
+static SPItem *find_item_at_point(std::deque<SPItem*> *nodes, unsigned int dkey, Geom::Point const &p)
+{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ gdouble delta = prefs->getDouble("/options/cursortolerance/value", 1.0);
+
+ SPItem *seen = NULL;
+ SPItem *child;
+ for (unsigned long i = 0; i < nodes->size(); ++i) {
+ child = nodes->at(i);
+ Inkscape::DrawingItem *arenaitem = child->get_arenaitem(dkey);
+
+ if (arenaitem && arenaitem->pick(p, delta, 1) != NULL) {
+ seen = child;
+ break;
+ }
+ }
+
return seen;
}
@@ -1454,9 +1461,12 @@ std::vector<SPItem*> SPDocument::getItemsAtPoints(unsigned const key, std::vecto
gdouble saved_delta = prefs->getDouble("/options/cursortolerance/value", 1.0);
prefs->setDouble("/options/cursortolerance/value", 0.25);
+ // Cache a flattened SVG DOM to speed up selection.
+ std::deque<SPItem*> nodes;
+ build_flat_item_list(&nodes, key, SP_GROUP(this->root), true, false, NULL);
+
for(int i = points.size()-1;i>=0; i--) {
- SPItem *item = getItemAtPoint(key, points[i],
- false, NULL);
+ SPItem *item = find_item_at_point(&nodes, key, points[i]);
if (item && items.end()==find(items.begin(),items.end(), item))
items.push_back(item);
}
@@ -1472,7 +1482,11 @@ SPItem *SPDocument::getItemAtPoint( unsigned const key, Geom::Point const &p,
{
g_return_val_if_fail(this->priv != NULL, NULL);
- return find_item_at_point(key, SP_GROUP(this->root), p, into_groups, false, upto);
+ // Build a flattened SVG DOM for find_item_at_point.
+ std::deque<SPItem*> nodes;
+ build_flat_item_list(&nodes, key, SP_GROUP(this->root), into_groups, false, upto);
+
+ return find_item_at_point(&nodes, key, p);
}
SPItem *SPDocument::getGroupAtPoint(unsigned int key, Geom::Point const &p) const
@@ -1482,7 +1496,6 @@ SPItem *SPDocument::getGroupAtPoint(unsigned int key, Geom::Point const &p) cons
return find_group_at_point(key, SP_GROUP(this->root), p);
}
-
// Resource management
bool SPDocument::addResource(gchar const *key, SPObject *object)
diff --git a/src/extension/internal/metafile-print.cpp b/src/extension/internal/metafile-print.cpp
index 2fb36be85..47ba5971c 100644
--- a/src/extension/internal/metafile-print.cpp
+++ b/src/extension/internal/metafile-print.cpp
@@ -285,8 +285,8 @@ void PrintMetafile::brush_classify(SPObject *parent, int depth, Inkscape::Pixbuf
return;
}
char temp[32]; // large enough
- temp[31] = '\0';
- strncpy(temp, pat_i->getAttribute("id"), 31); // Some names may be longer than [EW]MFhatch#_######
+ strncpy(temp, pat_i->getAttribute("id"), sizeof(temp)-1); // Some names may be longer than [EW]MFhatch#_######
+ temp[sizeof(temp)-1] = '\0';
hatch_classify(temp, hatchType, hatchColor, bkColor);
if (*hatchType != -1) {
return;
diff --git a/src/extension/internal/pdfinput/svg-builder.cpp b/src/extension/internal/pdfinput/svg-builder.cpp
index 58e2030d9..a448be639 100644
--- a/src/extension/internal/pdfinput/svg-builder.cpp
+++ b/src/extension/internal/pdfinput/svg-builder.cpp
@@ -498,6 +498,7 @@ void SvgBuilder::addShadedFill(GfxShading *shading, double *matrix, GfxPath *pat
// Obtain clipping path's id from the URL
gchar clip_path_id[32];
strncpy(clip_path_id, clip_path_url + 5, strlen(clip_path_url) - 6);
+ clip_path_id[sizeof (clip_path_id) - 1] = '\0';
SPObject *clip_obj = _doc->getObjectById(clip_path_id);
if (clip_obj) {
clip_obj->deleteObject();
diff --git a/src/io/streamtest.cpp b/src/io/streamtest.cpp
index 2030e6a85..ec59ac4a6 100644
--- a/src/io/streamtest.cpp
+++ b/src/io/streamtest.cpp
@@ -202,6 +202,7 @@ void path_init(char *path, char *name)
exit(1);
}
strncpy(ptr+1,name,strlen(name)+1);
+ path[PATH_MAX-1] = '\0';
printf("'%s'\n",path);
}
diff --git a/src/libuemf/uemf.c b/src/libuemf/uemf.c
index 3180c757c..afa116e75 100644
--- a/src/libuemf/uemf.c
+++ b/src/libuemf/uemf.c
@@ -1858,8 +1858,8 @@ U_LOGCOLORSPACEA logcolorspacea_set(
lcsa.lcsIntent = lcsIntent;
lcsa.lcsEndpoints = lcsEndpoints;
lcsa.lcsGammaRGB = lcsGammaRGB;
- memset(lcsa.lcsFilename,0,U_MAX_PATH); // zero out the Filename field
strncpy(lcsa.lcsFilename,lcsFilename,U_MAX_PATH);
+ lcsa.lcsFilename[U_MAX_PATH-1] = '\0';
return(lcsa);
}
@@ -1889,6 +1889,7 @@ U_LOGCOLORSPACEW logcolorspacew_set(
lcsa.lcsEndpoints = lcsEndpoints;
lcsa.lcsGammaRGB = lcsGammaRGB;
wchar16strncpypad(lcsa.lcsFilename,lcsFilename,U_MAX_PATH);
+ lcsa.lcsFilename[U_MAX_PATH-1] = '\0';
return(lcsa);
}
@@ -1983,6 +1984,7 @@ U_LOGFONT logfont_set(
lf.lfQuality = lfQuality;
lf.lfPitchAndFamily = lfPitchAndFamily;
wchar16strncpypad(lf.lfFaceName, lfFaceName, U_LF_FACESIZE); // pad this one as the intial structure was not set to zero
+ lf.lfFaceName[U_LF_FACESIZE-1] = '\0';
return(lf);
}
@@ -2006,7 +2008,9 @@ U_LOGFONT_PANOSE logfont_panose_set(
U_LOGFONT_PANOSE lfp;
memset(&lfp,0,sizeof(U_LOGFONT_PANOSE)); // all fields zero unless needed. Many should be ignored or must be 0.
wchar16strncpy(lfp.elfFullName, elfFullName, U_LF_FULLFACESIZE);
+ lfp.elfFullName[U_LF_FULLFACESIZE-1] = '\0';
wchar16strncpy(lfp.elfStyle, elfStyle, U_LF_FACESIZE);
+ lfp.elfStyle[U_LF_FACESIZE-1] = '\0';
lfp.elfLogFont = elfLogFont;
lfp.elfStyleSize = elfStyleSize;
lfp.elfPanose = elfPanose;
diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp
index 0cae1dcb6..08ef7ca1b 100644
--- a/src/live_effects/lpe-bspline.cpp
+++ b/src/live_effects/lpe-bspline.cpp
@@ -18,8 +18,8 @@ namespace LivePathEffect {
const double HANDLE_CUBIC_GAP = 0.001;
const double NO_POWER = 0.0;
-const double DEFAULT_START_POWER = 0.3334;
-const double DEFAULT_END_POWER = 0.6667;
+const double DEFAULT_START_POWER = 0.333334;
+const double DEFAULT_END_POWER = 0.666667;
Geom::PathVector hp;
void sp_bspline_drawHandle(Geom::Point p, double helper_size);
@@ -27,17 +27,19 @@ LPEBSpline::LPEBSpline(LivePathEffectObject *lpeobject)
: Effect(lpeobject),
steps(_("Steps with CTRL:"), _("Change number of steps with CTRL pressed"), "steps", &wr, this, 2),
helper_size(_("Helper size:"), _("Helper size"), "helper_size", &wr, this, 0),
- ignore_cusp(_("Ignore cusp nodes"), _("Change ignoring cusp nodes"), "ignore_cusp", &wr, this, true),
+ apply_cusp(_("Apply on cusp nodes"), _("Apply on cusp nodes"), "apply_cusp", &wr, this, true),
+ apply_non_cusp(_("Apply on non cusp nodes"), _("Apply on non cusp nodes"), "apply_non_cusp", &wr, this, true),
only_selected(_("Change only selected nodes"), _("Change only selected nodes"), "only_selected", &wr, this, false),
- weight(_("Change weight:"), _("Change weight of the effect"), "weight", &wr, this, DEFAULT_START_POWER)
+ weight(_("Change weight %:"), _("Change weight percent of the effect"), "weight", &wr, this, DEFAULT_START_POWER * 100)
{
registerParameter(&weight);
registerParameter(&steps);
registerParameter(&helper_size);
- registerParameter(&ignore_cusp);
+ registerParameter(&apply_cusp);
+ registerParameter(&apply_non_cusp);
registerParameter(&only_selected);
- weight.param_set_range(NO_POWER, 1);
+ weight.param_set_range(NO_POWER, 100.0);
weight.param_set_increments(0.1, 0.1);
weight.param_set_digits(4);
@@ -111,15 +113,10 @@ Gtk::Widget *LPEBSpline::newWidget()
Gtk::HBox * hbox_weight_steps = dynamic_cast<Gtk::HBox *>(widg);
std::vector< Gtk::Widget* > childList = hbox_weight_steps->get_children();
Gtk::Entry* entry_widget = dynamic_cast<Gtk::Entry *>(childList[1]);
- entry_widget->set_width_chars(6);
+ entry_widget->set_width_chars(9);
}
}
- if (param->param_key == "only_selected") {
- Gtk::CheckButton *widg_registered =
- Gtk::manage(dynamic_cast<Gtk::CheckButton *>(widg));
- widg = dynamic_cast<Gtk::Widget *>(widg_registered);
- }
- if (param->param_key == "ignore_cusp") {
+ if (param->param_key == "only_selected" || param->param_key == "apply_cusp" || param->param_key == "apply_non_cusp") {
Gtk::CheckButton *widg_registered =
Gtk::manage(dynamic_cast<Gtk::CheckButton *>(widg));
widg = dynamic_cast<Gtk::Widget *>(widg_registered);
@@ -161,7 +158,7 @@ void LPEBSpline::changeWeight(double weight_ammount)
SPPath *path = dynamic_cast<SPPath *>(sp_lpe_item);
if(path) {
SPCurve *curve = path->get_curve_for_edit();
- doBSplineFromWidget(curve, weight_ammount);
+ doBSplineFromWidget(curve, weight_ammount/100.0);
gchar *str = sp_svg_write_path(curve->get_pathvector());
path->getRepr()->setAttribute("inkscape:original-d", str);
}
@@ -366,7 +363,10 @@ void LPEBSpline::doBSplineFromWidget(SPCurve *curve, double weight_ammount)
point_at3 = in->first_segment()->finalPoint();
sbasis_in = in->first_segment()->toSBasis();
if (cubic) {
- if (!ignore_cusp || !Geom::are_near((*cubic)[1], point_at0)) {
+ if ((apply_cusp && apply_non_cusp) ||
+ (apply_cusp && Geom::are_near((*cubic)[1], point_at0)) ||
+ (apply_non_cusp && !Geom::are_near((*cubic)[1], point_at0)))
+ {
if (isNodePointSelected(point_at0) || !only_selected) {
point_at1 = sbasis_in.valueAt(weight_ammount);
if (weight_ammount != NO_POWER) {
@@ -377,9 +377,12 @@ void LPEBSpline::doBSplineFromWidget(SPCurve *curve, double weight_ammount)
point_at1 = (*cubic)[1];
}
} else {
- point_at1 = in->first_segment()->initialPoint();
+ point_at1 = (*cubic)[1];
}
- if (!ignore_cusp || !Geom::are_near((*cubic)[2], point_at3)) {
+ if ((apply_cusp && apply_non_cusp) ||
+ (apply_cusp && Geom::are_near((*cubic)[2], point_at3)) ||
+ (apply_non_cusp && !Geom::are_near((*cubic)[2], point_at3)))
+ {
if (isNodePointSelected(point_at3) || !only_selected) {
point_at2 = sbasis_in.valueAt(1 - weight_ammount);
if (weight_ammount != NO_POWER) {
@@ -390,10 +393,13 @@ void LPEBSpline::doBSplineFromWidget(SPCurve *curve, double weight_ammount)
point_at2 = (*cubic)[2];
}
} else {
- point_at2 = in->first_segment()->finalPoint();
+ point_at2 = (*cubic)[2];
}
} else {
- if (!ignore_cusp && weight_ammount != NO_POWER) {
+ if ((apply_cusp && apply_non_cusp) ||
+ (apply_cusp && weight_ammount == NO_POWER) ||
+ (apply_non_cusp && weight_ammount != NO_POWER))
+ {
if (isNodePointSelected(point_at0) || !only_selected) {
point_at1 = sbasis_in.valueAt(weight_ammount);
point_at1 =
diff --git a/src/live_effects/lpe-bspline.h b/src/live_effects/lpe-bspline.h
index 033e85cf0..b9cd336a9 100644
--- a/src/live_effects/lpe-bspline.h
+++ b/src/live_effects/lpe-bspline.h
@@ -38,7 +38,8 @@ public:
private:
ScalarParam helper_size;
- BoolParam ignore_cusp;
+ BoolParam apply_cusp;
+ BoolParam apply_non_cusp;
BoolParam only_selected;
ScalarParam weight;
diff --git a/src/live_effects/lpe-powerstroke.cpp b/src/live_effects/lpe-powerstroke.cpp
index f90d67d4e..03102a84a 100644
--- a/src/live_effects/lpe-powerstroke.cpp
+++ b/src/live_effects/lpe-powerstroke.cpp
@@ -102,12 +102,15 @@ static Circle touching_circle( D2<SBasis> const &curve, double t, double tol=0.0
{
//Piecewise<SBasis> k = curvature(curve, tol);
D2<SBasis> dM=derivative(curve);
- if ( are_near(L2sq(dM(t)),0.) ) {
+ if ( are_near(L2sq(dM(t)),0.) && (dM[0].size() > 1) && (dM[1].size() > 1) ) {
dM=derivative(dM);
}
- if ( are_near(L2sq(dM(t)),0.) ) { // try second time
+ if ( are_near(L2sq(dM(t)),0.) && (dM[0].size() > 1) && (dM[1].size() > 1) ) { // try second time
dM=derivative(dM);
}
+ if ( are_near(L2sq(dM(t)),0.) && (dM[0].size() > 1) && (dM[1].size() > 1) ) { // admit defeat
+ return Geom::Circle(Geom::Point(0., 0.), 0.);
+ }
Piecewise<D2<SBasis> > unitv = unitVector(dM,tol);
Piecewise<SBasis> dMlength = dot(Piecewise<D2<SBasis> >(dM),unitv);
Piecewise<SBasis> k = cross(derivative(unitv),unitv);
diff --git a/src/live_effects/lpe-transform_2pts.cpp b/src/live_effects/lpe-transform_2pts.cpp
index b70b68968..79ffd74de 100644
--- a/src/live_effects/lpe-transform_2pts.cpp
+++ b/src/live_effects/lpe-transform_2pts.cpp
@@ -18,6 +18,7 @@
#include <2geom/pathvector.h>
#include "sp-path.h"
#include "ui/icon-names.h"
+#include "svg/svg.h"
#include <glibmm/i18n.h>
@@ -26,25 +27,39 @@ namespace LivePathEffect {
LPETransform2Pts::LPETransform2Pts(LivePathEffectObject *lpeobject) :
Effect(lpeobject),
+ elastic(_("Elastic"), _("Elastic transform mode"), "elastic", &wr, this, false,"", INKSCAPE_ICON("on"), INKSCAPE_ICON("off")),
from_original_width(_("From original width"), _("From original width"), "from_original_width", &wr, this, false,"", INKSCAPE_ICON("on"), INKSCAPE_ICON("off")),
+ lock_lenght(_("Lock lenght"), _("Lock lenght to current distance"), "lock_lenght", &wr, this, false,"", INKSCAPE_ICON("on"), INKSCAPE_ICON("off")),
+ lock_angle(_("Lock angle"), _("Lock angle"), "lock_angle", &wr, this, false,"", INKSCAPE_ICON("on"), INKSCAPE_ICON("off")),
start(_("Start"), _("Start point"), "start", &wr, this, "Start point"),
end(_("End"), _("End point"), "end", &wr, this, "End point"),
first_knot(_("First Knot"), _("First Knot"), "first_knot", &wr, this, 1),
last_knot(_("Last Knot"), _("Last Knot"), "last_knot", &wr, this, 1),
+ helper_size(_("Helper size:"), _("Rotation helper size"), "helper_size", &wr, this, 3),
from_original_width_toggler(false),
point_a(Geom::Point()),
point_b(Geom::Point()),
pathvector(),
- append_path(false)
+ append_path(false),
+ previous_angle(Geom::deg_to_rad(0)),
+ previous_start(Geom::Point()),
+ previous_lenght(-1)
{
registerParameter(&start);
registerParameter(&end);
registerParameter(&first_knot);
registerParameter(&last_knot);
+ registerParameter(&helper_size);
+ registerParameter(&elastic);
registerParameter(&from_original_width);
+ registerParameter(&lock_lenght);
+ registerParameter(&lock_angle);
first_knot.param_make_integer(true);
last_knot.param_make_integer(true);
+ helper_size.param_set_range(0, 999);
+ helper_size.param_set_increments(1, 1);
+ helper_size.param_set_digits(0);
}
LPETransform2Pts::~LPETransform2Pts()
@@ -67,12 +82,16 @@ LPETransform2Pts::doOnApply(SPLPEItem const* lpeitem)
if(!pathvector.empty()) {
point_a = pathvector.initialPoint();
point_b = pathvector.finalPoint();
- if(are_near(point_a,point_b)){
+ if(are_near(point_a,point_b)) {
point_b = pathvector.back().finalCurve().initialPoint();
}
size_t nnodes = nodeCount(pathvector);
last_knot.param_set_value(nnodes);
}
+
+ previous_lenght = Geom::distance(point_a,point_b);
+ Geom::Ray transformed(point_a,point_b);
+ previous_angle = transformed.angle();
start.param_update_default(point_a);
start.param_set_default();
end.param_update_default(point_b);
@@ -101,7 +120,6 @@ LPETransform2Pts::doBeforeEffect (SPLPEItem const* lpeitem)
point_a = pointAtNodeIndex(pathvector,(size_t)first_knot-1);
point_b = pointAtNodeIndex(pathvector,(size_t)last_knot-1);
size_t nnodes = nodeCount(pathvector);
- std::cout << nnodes << "nnodes\n";
first_knot.param_set_range(1, last_knot-1);
last_knot.param_set_range(first_knot+1, nnodes);
from_original_width.param_setValue(false);
@@ -113,6 +131,24 @@ LPETransform2Pts::doBeforeEffect (SPLPEItem const* lpeitem)
from_original_width.param_setValue(true);
append_path = false;
}
+ if(lock_lenght && !lock_angle && previous_lenght != -1) {
+ Geom::Ray transformed((Geom::Point)start,(Geom::Point)end);
+ if(previous_start == start || previous_angle == Geom::deg_to_rad(0)) {
+ previous_angle = transformed.angle();
+ }
+ } else if(lock_angle && !lock_lenght && previous_angle != Geom::deg_to_rad(0)) {
+ if(previous_start == start){
+ previous_lenght = Geom::distance((Geom::Point)start, (Geom::Point)end);
+ }
+ }
+ if(lock_lenght || lock_angle ) {
+ Geom::Point end_point = Geom::Point::polar(previous_angle, previous_lenght) + (Geom::Point)start;
+ end.param_setValue(end_point);
+ }
+ Geom::Ray transformed((Geom::Point)start,(Geom::Point)end);
+ previous_angle = transformed.angle();
+ previous_lenght = Geom::distance((Geom::Point)start, (Geom::Point)end);
+ previous_start = start;
splpeitem->apply_to_clippath(splpeitem);
splpeitem->apply_to_mask(splpeitem);
}
@@ -125,7 +161,10 @@ LPETransform2Pts::updateIndex()
if (sp_path) {
pathvector = sp_path->get_original_curve()->get_pathvector();
}
- if(!pathvector.empty() && !from_original_width) {
+ if(pathvector.empty()) {
+ return;
+ }
+ if(!from_original_width) {
point_a = pointAtNodeIndex(pathvector,(size_t)first_knot-1);
point_b = pointAtNodeIndex(pathvector,(size_t)last_knot-1);
start.param_update_default(point_a);
@@ -155,7 +194,7 @@ LPETransform2Pts::pointAtNodeIndex(Geom::PathVector pathvector, size_t index) co
size_t n = 0;
for (Geom::PathVector::iterator pv_it = pathvector.begin(); pv_it != pathvector.end(); ++pv_it) {
for (Geom::Path::iterator curve_it = pv_it->begin(); curve_it != pv_it->end_closed(); ++curve_it) {
- if(index == n){
+ if(index == n) {
return curve_it->initialPoint();
}
n++;
@@ -170,7 +209,7 @@ LPETransform2Pts::pathAtNodeIndex(Geom::PathVector pathvector, size_t index) con
size_t n = 0;
for (Geom::PathVector::iterator pv_it = pathvector.begin(); pv_it != pathvector.end(); ++pv_it) {
for (Geom::Path::iterator curve_it = pv_it->begin(); curve_it != pv_it->end_closed(); ++curve_it) {
- if(index == n){
+ if(index == n) {
return *pv_it;
}
n++;
@@ -197,6 +236,9 @@ LPETransform2Pts::reset()
first_knot.param_set_value(1);
last_knot.param_set_value(2);
}
+ Geom::Ray transformed(point_a, point_b);
+ previous_angle = transformed.angle();
+ previous_lenght = Geom::distance(point_a, point_b);
start.param_update_default(point_a);
end.param_update_default(point_b);
start.param_set_default();
@@ -214,7 +256,9 @@ Gtk::Widget *LPETransform2Pts::newWidget()
vbox->set_spacing(6);
std::vector<Parameter *>::iterator it = param_vector.begin();
- Gtk::HBox * button = Gtk::manage(new Gtk::HBox(true,0));
+ Gtk::HBox * button1 = Gtk::manage(new Gtk::HBox(true,0));
+ Gtk::HBox * button2 = Gtk::manage(new Gtk::HBox(true,0));
+ Gtk::HBox * button3 = Gtk::manage(new Gtk::HBox(true,0));
while (it != param_vector.end()) {
if ((*it)->widget_is_visible) {
Parameter *param = *it;
@@ -237,10 +281,21 @@ Gtk::Widget *LPETransform2Pts::newWidget()
widg->set_has_tooltip(false);
}
}
- } else if (param->param_key == "from_original_width") {
+ } else if (param->param_key == "from_original_width" || param->param_key == "elastic") {
+ Glib::ustring * tip = param->param_getTooltip();
+ if (widg) {
+ button1->pack_start(*widg, true, true, 2);
+ if (tip) {
+ widg->set_tooltip_text(*tip);
+ } else {
+ widg->set_tooltip_text("");
+ widg->set_has_tooltip(false);
+ }
+ }
+ } else if (param->param_key == "lock_angle" || param->param_key == "lock_lenght") {
Glib::ustring * tip = param->param_getTooltip();
if (widg) {
- button->pack_start(*widg, true, true, 2);
+ button2->pack_start(*widg, true, true, 2);
if (tip) {
widg->set_tooltip_text(*tip);
} else {
@@ -263,8 +318,10 @@ Gtk::Widget *LPETransform2Pts::newWidget()
}
Gtk::Button *reset = Gtk::manage(new Gtk::Button(Glib::ustring(_("Reset"))));
reset->signal_clicked().connect(sigc::mem_fun(*this, &LPETransform2Pts::reset));
- button->pack_start(*reset, true, true, 2);
- vbox->pack_start(*button, true, true, 2);
+ button3->pack_start(*reset, true, true, 2);
+ vbox->pack_start(*button1, true, true, 2);
+ vbox->pack_start(*button2, true, true, 2);
+ vbox->pack_start(*button3, true, true, 2);
return dynamic_cast<Gtk::Widget *>(vbox);
}
@@ -280,10 +337,23 @@ LPETransform2Pts::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const
helper.start(point_a);
helper.appendNew<Geom::LineSegment>(point_b);
Geom::Affine m;
- m *= Geom::Scale(sca);
- m *= Geom::Rotate(rot);
- helper *= m;
- m *= Geom::Translate((Geom::Point)start - helper.initialPoint());
+ if(elastic) {
+ Geom::Angle original_angle = original.angle();
+ m *= Geom::Rotate(-original_angle);
+ if(sca > 1){
+ m *= Geom::Scale(sca, 1.0);
+ } else {
+ m *= Geom::Scale(sca, 1.0-((1.0-sca)/2.0));
+ }
+ m *= Geom::Rotate(transformed.angle());
+ helper *= m;
+ m *= Geom::Translate((Geom::Point)start - helper.initialPoint());
+ } else {
+ m *= Geom::Scale(sca);
+ m *= Geom::Rotate(rot);
+ helper *= m;
+ m *= Geom::Translate((Geom::Point)start - helper.initialPoint());
+ }
output.concat(pwd2_in * m);
return output;
@@ -299,6 +369,22 @@ LPETransform2Pts::addCanvasIndicators(SPLPEItem const */*lpeitem*/, std::vector<
hp.appendNew<Geom::LineSegment>((Geom::Point)end);
Geom::PathVector pathv;
pathv.push_back(hp);
+ double r = helper_size*.1;
+ if(lock_lenght || lock_angle ) {
+ 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";
+ PathVector pathv_move = sp_svg_read_pathv(svgd);
+ pathv_move *= Affine(r,0,0,r,0,0) * Translate(Geom::Point(start));
+ hp_vec.push_back(pathv_move);
+ }
+ if(!lock_angle && lock_lenght) {
+ char const * svgd;
+ svgd = "m 7.07,7.07 c -3.9,3.91 -10.24,3.91 -14.14,0 -3.91,-3.9 -3.91,-10.24 0,-14.14 3.9,-3.91 10.24,-3.91 14.14,0 l -2.83,-4.24 -0.7,2.12";
+ PathVector pathv_turn = sp_svg_read_pathv(svgd);
+ pathv_turn *= Geom::Rotate(previous_angle);
+ pathv_turn *= Affine(r,0,0,r,0,0) * Translate(Geom::Point(end));
+ hp_vec.push_back(pathv_turn);
+ }
hp_vec.push_back(pathv);
}
diff --git a/src/live_effects/lpe-transform_2pts.h b/src/live_effects/lpe-transform_2pts.h
index 855780a7a..947243c82 100644
--- a/src/live_effects/lpe-transform_2pts.h
+++ b/src/live_effects/lpe-transform_2pts.h
@@ -38,9 +38,9 @@ public:
void updateIndex();
size_t nodeCount(Geom::PathVector pathvector) const;
-
+
Geom::Point pointAtNodeIndex(Geom::PathVector pathvector, size_t index) const;
-
+
Geom::Path pathAtNodeIndex(Geom::PathVector pathvector, size_t index) const;
void reset();
@@ -49,16 +49,23 @@ protected:
virtual void addCanvasIndicators(SPLPEItem const *lpeitem, std::vector<Geom::PathVector> &hp_vec);
private:
+ ToggleButtonParam elastic;
ToggleButtonParam from_original_width;
+ ToggleButtonParam lock_lenght;
+ ToggleButtonParam lock_angle;
PointParam start;
PointParam end;
ScalarParam first_knot;
ScalarParam last_knot;
+ ScalarParam helper_size;
bool from_original_width_toggler;
Geom::Point point_a;
Geom::Point point_b;
Geom::PathVector pathvector;
bool append_path;
+ Geom::Angle previous_angle;
+ Geom::Point previous_start;
+ double previous_lenght;
LPETransform2Pts(const LPETransform2Pts&);
LPETransform2Pts& operator=(const LPETransform2Pts&);
};
diff --git a/src/live_effects/parameter/togglebutton.cpp b/src/live_effects/parameter/togglebutton.cpp
index c5da8b858..47a8b5615 100644
--- a/src/live_effects/parameter/togglebutton.cpp
+++ b/src/live_effects/parameter/togglebutton.cpp
@@ -119,6 +119,10 @@ ToggleButtonParam::param_newWidget()
void
ToggleButtonParam::refresh_button()
{
+ if (!_toggled_connection.connected()) {
+ return;
+ }
+
if(!checkwdg){
return;
}
diff --git a/src/ui/dialog/grid-arrange-tab.cpp b/src/ui/dialog/grid-arrange-tab.cpp
index ccd23a572..086cbe45f 100644
--- a/src/ui/dialog/grid-arrange-tab.cpp
+++ b/src/ui/dialog/grid-arrange-tab.cpp
@@ -75,16 +75,10 @@ static bool sp_compare_x_position(SPItem *first, SPItem *second)
a_in_b_vert = false;
}
- if (!a_in_b_vert) {
- return true;
- }
- if (a_in_b_vert && a->min()[X] > b->min()[X]) {
- return false;
+ if (!a_in_b_vert) { // a and b are not in the same row
+ return (a->min()[Y] < b->min()[Y]);
}
- if (a_in_b_vert && a->min()[X] < b->min()[X]) {
- return true;
- }
- return false;
+ return (a->min()[X] < b->min()[X]);
}
/*
diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp
index 55d801c46..06e49dc7f 100644
--- a/src/ui/tool/node.cpp
+++ b/src/ui/tool/node.cpp
@@ -61,7 +61,7 @@ namespace Inkscape {
namespace UI {
const double NO_POWER = 0.0;
-const double DEFAULT_START_POWER = 0.3334;
+const double DEFAULT_START_POWER = 0.333334;
ControlPoint::ColorSet Node::node_colors = {
{0xbfbfbf00, 0x000000ff}, // normal fill, stroke
diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp
index 982002159..284932bb8 100644
--- a/src/ui/tool/path-manipulator.cpp
+++ b/src/ui/tool/path-manipulator.cpp
@@ -58,7 +58,7 @@ enum PathChange {
} // anonymous namespace
const double HANDLE_CUBIC_GAP = 0.001;
const double NO_POWER = 0.0;
-const double DEFAULT_START_POWER = 0.3334;
+const double DEFAULT_START_POWER = 0.333334;
/**
diff --git a/src/ui/widget/color-entry.h b/src/ui/widget/color-entry.h
index edabe1980..08537f26d 100644
--- a/src/ui/widget/color-entry.h
+++ b/src/ui/widget/color-entry.h
@@ -9,7 +9,7 @@
*/
#ifndef SEEN_COLOR_ENTRY_H
-#define SEEN_COLOR_ENTRY_H_
+#define SEEN_COLOR_ENTRY_H
#include <gtkmm/entry.h>
#include "ui/selected-color.h"