From 97bd182d6a2113eab1dd5faf51402ebd5382791c Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sun, 8 May 2016 22:57:37 +0200 Subject: First attempt to make fixed tweenk review (bzr r13645.1.128) --- src/live_effects/parameter/satellitesarray.cpp | 527 +++++++++++++++++++++++++ 1 file changed, 527 insertions(+) create mode 100644 src/live_effects/parameter/satellitesarray.cpp (limited to 'src/live_effects/parameter/satellitesarray.cpp') diff --git a/src/live_effects/parameter/satellitesarray.cpp b/src/live_effects/parameter/satellitesarray.cpp new file mode 100644 index 000000000..9274a4aff --- /dev/null +++ b/src/live_effects/parameter/satellitesarray.cpp @@ -0,0 +1,527 @@ +/* + * Author(s): + * Jabiertxo Arraiza Cenoz + * + * 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 +#include +// TODO due to internal breakage in glibmm headers, +// this has to be included last. +#include + +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) + : ArrayArrayParam >(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; + _effectType = FILLET_CHAMFER; + _last_pointwise = NULL; +} + +void SatellitesArrayParam::set_oncanvas_looks(SPKnotShapeType shape, + SPKnotModeType mode, + guint32 color) +{ + _knot_shape = shape; + _knot_mode = mode; + _knot_color = color; +} + +void SatellitesArrayParam::setPointwise(Pointwise *pointwise) +{ + _last_pointwise = pointwise; + param_set_and_write_new_value(_last_pointwise->getSatellites()); +} + +void SatellitesArrayParam::setUseDistance(bool use_knot_distance) +{ + _use_distance = use_knot_distance; +} + +void SatellitesArrayParam::setEffectType(EffectType et) +{ + _effectType = et; +} + +void SatellitesArrayParam::setHelperSize(int hs) +{ + _helper_size = hs; + updateCanvasIndicators(); +} + +void SatellitesArrayParam::updateCanvasIndicators(bool mirror) +{ + if (!_last_pointwise) { + return; + } + Geom::PathVector pathv = _last_pointwise->getPV(); + if (mirror == true) { + _hp.clear(); + } + for (size_t i = 0; i < _vector.size(); ++i) { + for (size_t j = 0; j < _vector[i].size(); ++j) { + if (!_vector[i][j].active || _vector[i][j].hidden) { + continue; + } + if ((!_vector[i][j].has_mirror && mirror == true) || _vector[i][j].amount == 0) { + continue; + } + double pos = 0; + if (pathv.size() <= i || pathv[i].size() <= j) { + break; + } + Geom::Curve *curve_in = pathv[i][j].duplicate(); + bool overflow = false; + double size_out = _vector[i][j].arcDistance(*curve_in); + double lenght_out = curve_in->length(); + double lenght_in = 0; + + boost::optional curve_prev_index = boost::none; + if(j == 0 && pathv[i].closed()){ + curve_prev_index = pathv[pathv[i].size() - 1]; + } else if(!pathv[i].closed() || j != 0) { + curve_prev_index = j - 1; + } + if (curve_prev_index) { + lenght_in = pathv.curveAt(*curve_prev_index).length(); + } + if (mirror == true) { + if (curve_prev_index) { + curve_in = const_cast(&pathv.curveAt(*curve_prev_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 == true) { + 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 == true) { + 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 (mirror == true) { + updateCanvasIndicators(false); + } +} +void SatellitesArrayParam::updateCanvasIndicators() +{ + updateCanvasIndicators(true); +} + +void SatellitesArrayParam::addCanvasIndicators( + SPLPEItem const */*lpeitem*/, std::vector &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, + SPDesktop *desktop, + SPItem *item, bool mirror) +{ + for (size_t i = 0; i < _vector.size(); ++i) { + for (size_t j = 0; j < _vector[i].size(); ++j) { + size_t iPlus = j; + if (mirror == true) { + iPlus = j + _vector[i].size(); + } + if (!_vector[i][j].active) { + continue; + } + if (!_vector[i][j].has_mirror && mirror == true) { + continue; + } + using namespace Geom; + SatelliteType type = _vector[i][j].satellite_type; + //IF is for filletChamfer effect... + if (_effectType == FILLET_CHAMFER) { + const gchar *tip; + if (type == CHAMFER) { + tip = _("Chamfer: Ctrl+Click toggle type, " + "Shift+Click open dialog, " + "Ctrl+Alt+Click reset"); + } else if (type == INVERSE_CHAMFER) { + tip = _("Inverse Chamfer: Ctrl+Click toggle type, " + "Shift+Click open dialog, " + "Ctrl+Alt+Click reset"); + } else if (type == INVERSE_FILLET) { + tip = _("Inverse Fillet: Ctrl+Click toggle type, " + "Shift+Click open dialog, " + "Ctrl+Alt+Click reset"); + } else { + tip = _("Fillet: Ctrl+Click toggle type, " + "Shift+Click open dialog, " + "Ctrl+Alt+Click reset"); + } + FilletChamferKnotHolderEntity *e = + new FilletChamferKnotHolderEntity(this, i, iPlus); + e->create(desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, _(tip), + _knot_shape, _knot_mode, _knot_color); + knotholder->add(e); + } + } + } + if (mirror == true) { + addKnotHolderEntities(knotholder, desktop, item, false); + } +} + +void SatellitesArrayParam::addKnotHolderEntities(KnotHolder *knotholder, + SPDesktop *desktop, + SPItem *item) +{ + knoth = knotholder; + addKnotHolderEntities(knotholder, desktop, item, true); +} + +FilletChamferKnotHolderEntity::FilletChamferKnotHolderEntity( + SatellitesArrayParam *p, size_t index, size_t subindex) + : _pparam(p), _index(index), _subindex(subindex) {} + +void FilletChamferKnotHolderEntity::knot_set(Geom::Point const &p, + Geom::Point const &/*origin*/, + guint state) +{ + Geom::Point s = snap_knot_position(p, state); + size_t subindex = _subindex; + if (_subindex >= _pparam->_vector[_index].size()) { + subindex = _subindex - _pparam->_vector[_index].size(); + } + if (!valid_index(subindex)) { + return; + } + + if (!_pparam->_last_pointwise) { + return; + } + + Satellite satellite = _pparam->_vector[_index].at(subindex); + if (!satellite.active || satellite.hidden) { + return; + } + Pointwise *pointwise = _pparam->_last_pointwise; + Geom::PathVector pathv = pparam->_last_pointwise->getPV(); + if (_subindex >= _pparam->_vector[_index].size() ) { + boost::optional curve_prev_index = boost::none; + if(_subindex == 0 && pathv[_index].closed()){ + curve_prev_index = pathv[pathv[_index].size() - 1]; + } else if(!pathv[_index].closed() || _subindex != 0) { + curve_prev_index = _subindex - 1; + } + if (curve_prev_index) { + Geom::Curve const &curve_in = pathv[_index][*curve_prev_index]; + double mirror_time = Geom::nearest_time(s, curve_in); + double time_start = 0; + Satellites sats = pointwise->getSatellites(); + time_start = sats[_index][*curve_prev_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[_index][); + } + satellite.amount = amount; + } + } else { + satellite.setPosition(s, pathv[_index]); + } + _pparam->_vector[_index][_subindex] = satellite; + SPLPEItem *splpeitem = dynamic_cast(item); + if (splpeitem) { + sp_lpe_item_update_patheffect(splpeitem, false, false); + } +} + +Geom::Point FilletChamferKnotHolderEntity::knot_get() const +{ + Geom::Point tmp_point; + size_t subindex = _subindex; + if (_subindex >= _pparam->_vector[_index].size()) { + subindex = _subindex - _pparam->_vector[_index].size(); + } + if (!valid_index(_subindex)) { + return Geom::Point(Geom::infinity(), Geom::infinity()); + } + Satellite satellite = _pparam->_vector[_index][_subindex]; + if (!_pparam->_last_pointwise) { + return Geom::Point(Geom::infinity(), Geom::infinity()); + } + if (!satellite.active || satellite.hidden) { + return Geom::Point(Geom::infinity(), Geom::infinity()); + } + Pointwise *pointwise = _pparam->_last_pointwise; + Geom::PathVector pathv = pparam->_last_pointwise->getPV(); + if (pathv[_index].size() <= subindex) { + return Geom::Point(Geom::infinity(), Geom::infinity()); + } + this->knot->show(); + if (_subindex >= _pparam->_vector[index].size()) { + tmp_point = satellite.getPosition(pathv[_index][_subindex]); + boost::optional curve_prev_index = boost::none; + if(_subindex == 0 && pathv[_index].closed()){ + curve_prev_index = pathv[pathv[_index].size() - 1]; + } else if(!pathv[_index].closed() || _subindex != 0) { + curve_prev_index = _subindex - 1; + } + if (curve_prev_index) { + Geom::Curve const &curve_in = pathv[_index][*curve_prev_index]; + double s = satellite.arcDistance(pathv[_index][_subindex]); + double t = satellite.time(s, true, curve_in); + if (t > 1) { + t = 1; + } + if (t < 0) { + t = 0; + } + double time_start = 0; + time_start = pointwise->getSatellites()[_index][*curve_prev_index].time(curve_in); + if (time_start > t) { + t = time_start; + } + tmp_point = (curve_in).pointAt(t); + } + } else { + tmp_point = satellite.getPosition(pathv[_index][_subindex]); + } + Geom::Point const canvas_point = tmp_point; + return canvas_point; +} + +void FilletChamferKnotHolderEntity::knot_click(guint state) +{ + if (!_pparam->_last_pointwise) { + return; + } + + size_t subindex = _subindex; + if (_subindex >= _pparam->_vector[_index].size()) { + subindex = _subindex - _pparam->_vector[_index].size(); + } + if (state & GDK_CONTROL_MASK) { + if (state & GDK_MOD1_MASK) { + _pparam->_vector[_index][_subindex].amount = 0.0; + _pparam->param_set_and_write_new_value(_pparam->_vector); + sp_lpe_item_update_patheffect(SP_LPE_ITEM(item), false, false); + } else { + using namespace Geom; + SatelliteType type = _pparam->_vector[_index][_subindex].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[_index][subindex].satellite_type = 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 == CHAMFER) { + tip = _("Chamfer: Ctrl+Click toggle type, " + "Shift+Click open dialog, " + "Ctrl+Alt+Click reset"); + } else if (type == INVERSE_CHAMFER) { + tip = _("Inverse Chamfer: Ctrl+Click toggle type, " + "Shift+Click open dialog, " + "Ctrl+Alt+Click reset"); + } else if (type == INVERSE_FILLET) { + tip = _("Inverse Fillet: Ctrl+Click toggle type, " + "Shift+Click open dialog, " + "Ctrl+Alt+Click reset"); + } else { + tip = _("Fillet: Ctrl+Click toggle type, " + "Shift+Click open dialog, " + "Ctrl+Alt+Click reset"); + } + this->knot->tip = g_strdup(tip); + this->knot->show(); + } + } else if (state & GDK_SHIFT_MASK) { + Geom::PathVector pathv = pparam->_last_pointwise->getPV(); + double amount = _pparam->_vector[_index][_subindex].amount; + boost::optional curve_prev_index = boost::none; + if(_subindex == 0 && pathv[_index].closed()){ + curve_prev_index = pathv[pathv[_index].size() - 1]; + } else if(!pathv[_index].closed() || _subindex != 0) { + curve_prev_index = _subindex - 1; + } + if (!_pparam->_use_distance && !_pparam->_vector[_index][subindex].is_time) { + if (curve_prev_index) { + amount = _pparam->_vector[_index][subindex].lenToRad(amount, pathv[_index][*curve_prev_index], pathv[_index][subindex], _pparam->_vector[_index][*curve_prev_index]); + } else { + amount = 0.0; + } + } + bool aprox = false; + Geom::D2 d2_out = _pparam->_last_pointwise->getPwd2()[_index][subindex]; + if (curve_prev_index) { + Geom::D2 d2_in = + _pparam->_last_pointwise->getPwd2()[_index][*curve_prev_index]; + 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[_index][subindex]); + + } +} + +void FilletChamferKnotHolderEntity::knot_set_offset(Satellite satellite) +{ + if (!_pparam->_last_pointwise) { + return; + } + size_t subindex = _subindex; + if (_subindex >= _pparam->_vector[_index].size()) { + subindex = _subindex - _pparam->_vector[_index].size(); + } + double amount = satellite.amount; + double max_amount = amount; + if (!_pparam->_use_distance && !satellite.is_time) { + Geom::Piecewise > pwd2 = _pparam->_last_pointwise->getPwd2(); + Geom::PathVector pathv = path_from_piecewise(Geom::remove_short_cuts(pwd2,0.01),0.01); + Geom::Path sat_path = pathv.pathAt(index); + boost::optional curve_prev_index = boost::none; + if(_subindex == 0 && pathv[_index].closed()){ + curve_prev_index = pathv[pathv[_index].size() - 1]; + } else if(!pathv[_index].closed() || _subindex != 0) { + curve_prev_index = _subindex - 1; + } + if (curve_prev_index) { + amount = _pparam->_vector[_index][subindex].radToLen(amount, pathv[_index][*prev], pathv[_index][subindex]); + } else { + amount = 0.0; + } + if (max_amount > 0 && amount == 0) { + amount = _pparam->_vector[_index][subindex].amount; + } + } + satellite.amount = amount; + _pparam->_vector[_index][subindex] = satellite; + this->parent_holder->knot_ungrabbed_handler(this->knot, 0); + _pparam->param_set_and_write_new_value(_pparam->_vector); + SPLPEItem *splpeitem = dynamic_cast(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 : -- cgit v1.2.3 From 07717a370b8efe6ddbb0c69d115bb063a2e7686a Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Tue, 10 May 2016 23:16:49 +0200 Subject: Working with path updates (bzr r13645.1.130) --- src/live_effects/parameter/satellitesarray.cpp | 310 +++++++++++++------------ 1 file changed, 156 insertions(+), 154 deletions(-) (limited to 'src/live_effects/parameter/satellitesarray.cpp') diff --git a/src/live_effects/parameter/satellitesarray.cpp b/src/live_effects/parameter/satellitesarray.cpp index 9274a4aff..9f14a1d5b 100644 --- a/src/live_effects/parameter/satellitesarray.cpp +++ b/src/live_effects/parameter/satellitesarray.cpp @@ -26,7 +26,7 @@ SatellitesArrayParam::SatellitesArrayParam(const Glib::ustring &label, const Glib::ustring &key, Inkscape::UI::Widget::Registry *wr, Effect *effect) - : ArrayArrayParam >(label, tip, key, wr, effect, 0), knoth(NULL) + : ArrayParam >(label, tip, key, wr, effect, 0), knoth(NULL) { _knot_shape = SP_KNOT_SHAPE_DIAMOND; _knot_mode = SP_KNOT_MODE_XOR; @@ -77,104 +77,106 @@ void SatellitesArrayParam::updateCanvasIndicators(bool mirror) if (mirror == true) { _hp.clear(); } - for (size_t i = 0; i < _vector.size(); ++i) { - for (size_t j = 0; j < _vector[i].size(); ++j) { - if (!_vector[i][j].active || _vector[i][j].hidden) { - continue; - } - if ((!_vector[i][j].has_mirror && mirror == true) || _vector[i][j].amount == 0) { - continue; - } - double pos = 0; - if (pathv.size() <= i || pathv[i].size() <= j) { - break; - } - Geom::Curve *curve_in = pathv[i][j].duplicate(); - bool overflow = false; - double size_out = _vector[i][j].arcDistance(*curve_in); - double lenght_out = curve_in->length(); - double lenght_in = 0; - - boost::optional curve_prev_index = boost::none; - if(j == 0 && pathv[i].closed()){ - curve_prev_index = pathv[pathv[i].size() - 1]; - } else if(!pathv[i].closed() || j != 0) { - curve_prev_index = j - 1; - } - if (curve_prev_index) { - lenght_in = pathv.curveAt(*curve_prev_index).length(); - } - if (mirror == true) { + 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) { + continue; + } + if ((!_vector[i][j].has_mirror && mirror == true) || _vector[i][j].amount == 0) { + continue; + } + double pos = 0; + if (pathv[i].size() == j) { //ignore last satellite in open paths with fillet chamfer effect + continue; + } + Geom::Curve *curve_in = pathv[i][j].duplicate(); + bool overflow = false; + double size_out = _vector[i][j].arcDistance(*curve_in); + double lenght_out = curve_in->length(); + double lenght_in = 0; + + boost::optional curve_prev_index = boost::none; + if(j == 0 && pathv[i].closed()){ + curve_prev_index = pathv[i].size() - 1; + } else if(!pathv[i].closed() || j != 0) { + curve_prev_index = j - 1; + } if (curve_prev_index) { - curve_in = const_cast(&pathv.curveAt(*curve_prev_index)); - pos = _vector[i][j].time(size_out, true, *curve_in); - if (lenght_out < size_out) { + lenght_in = pathv.curveAt(*curve_prev_index).length(); + } + if (mirror) { + if (curve_prev_index) { + curve_in = const_cast(&pathv.curveAt(*curve_prev_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; } } - } else { - pos = _vector[i][j].time(*curve_in); - if (lenght_in < size_out) { - overflow = true; + if (pos <= 0 || pos >= 1) { + continue; } - } - 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 == true) { - 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]); + 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 { - 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 == true) { - aff *= Geom::Rotate(ray_1.angle() - Geom::rad_from_deg(90)); + 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 { - aff *= Geom::Rotate(ray_1.angle() - Geom::rad_from_deg(270)); + 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]); } - aff *= Geom::Translate(curve_in->pointAt(pos)); - pathv *= aff; - _hp.push_back(pathv[0]); } } } } - if (mirror == true) { + if (mirror) { updateCanvasIndicators(false); } } @@ -198,8 +200,7 @@ void SatellitesArrayParam::param_transform_multiply(Geom::Affine const &postmul, 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); + _vector[i][j].amount = _vector[i][j].amount * ((postmul.expansionX() + postmul.expansionY()) / 2); } } } @@ -208,24 +209,22 @@ void SatellitesArrayParam::param_transform_multiply(Geom::Affine const &postmul, } void SatellitesArrayParam::addKnotHolderEntities(KnotHolder *knotholder, - SPDesktop *desktop, - SPItem *item, bool mirror) + SPDesktop *desktop, + SPItem *item, bool mirror) { for (size_t i = 0; i < _vector.size(); ++i) { for (size_t j = 0; j < _vector[i].size(); ++j) { - size_t iPlus = j; - if (mirror == true) { - iPlus = j + _vector[i].size(); - } - if (!_vector[i][j].active) { + if (!_vector[i][j].has_mirror && mirror) { continue; } - if (!_vector[i][j].has_mirror && mirror == true) { - continue; + SatelliteType type = _vector[i][j].satellite_type; + size_t index = i; + size_t subindex = j; + if (mirror) { + subindex = subindex + _vector[i].size(); } using namespace Geom; - SatelliteType type = _vector[i][j].satellite_type; - //IF is for filletChamfer effect... + //If is for filletChamfer effect... if (_effectType == FILLET_CHAMFER) { const gchar *tip; if (type == CHAMFER) { @@ -245,15 +244,13 @@ void SatellitesArrayParam::addKnotHolderEntities(KnotHolder *knotholder, "Shift+Click open dialog, " "Ctrl+Alt+Click reset"); } - FilletChamferKnotHolderEntity *e = - new FilletChamferKnotHolderEntity(this, i, iPlus); - e->create(desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, _(tip), - _knot_shape, _knot_mode, _knot_color); + FilletChamferKnotHolderEntity *e = new FilletChamferKnotHolderEntity(this, index, subindex); + e->create(desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, _(tip),_knot_shape, _knot_mode, _knot_color); knotholder->add(e); } } } - if (mirror == true) { + if (mirror) { addKnotHolderEntities(knotholder, desktop, item, false); } } @@ -279,7 +276,7 @@ void FilletChamferKnotHolderEntity::knot_set(Geom::Point const &p, if (_subindex >= _pparam->_vector[_index].size()) { subindex = _subindex - _pparam->_vector[_index].size(); } - if (!valid_index(subindex)) { + if (!valid_index(_index)) { return; } @@ -287,39 +284,39 @@ void FilletChamferKnotHolderEntity::knot_set(Geom::Point const &p, return; } - Satellite satellite = _pparam->_vector[_index].at(subindex); - if (!satellite.active || satellite.hidden) { + Satellite satellite = _pparam->_vector[_index][subindex]; + if (satellite.hidden) { return; } Pointwise *pointwise = _pparam->_last_pointwise; - Geom::PathVector pathv = pparam->_last_pointwise->getPV(); - if (_subindex >= _pparam->_vector[_index].size() ) { + Geom::PathVector pathv = pointwise->getPV(); + if (subindex != _subindex) { boost::optional curve_prev_index = boost::none; - if(_subindex == 0 && pathv[_index].closed()){ - curve_prev_index = pathv[pathv[_index].size() - 1]; - } else if(!pathv[_index].closed() || _subindex != 0) { - curve_prev_index = _subindex - 1; + if(subindex == 0 && pathv[_index].closed()){ + curve_prev_index = pathv[_index].size() - 1; + } else if(!pathv[_index].closed() || subindex != 0) { + curve_prev_index = subindex - 1; } if (curve_prev_index) { Geom::Curve const &curve_in = pathv[_index][*curve_prev_index]; double mirror_time = Geom::nearest_time(s, curve_in); double time_start = 0; - Satellites sats = pointwise->getSatellites(); - time_start = sats[_index][*curve_prev_index].time(curve_in); + Satellites satellites = pointwise->getSatellites(); + time_start = satellites[_index][*curve_prev_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[_index][); + amount = timeAtArcLength(amount, pathv[_index][subindex]); } satellite.amount = amount; } } else { - satellite.setPosition(s, pathv[_index]); + satellite.setPosition(s, pathv[_index][subindex]); } - _pparam->_vector[_index][_subindex] = satellite; + _pparam->_vector[_index][subindex] = satellite; SPLPEItem *splpeitem = dynamic_cast(item); if (splpeitem) { sp_lpe_item_update_patheffect(splpeitem, false, false); @@ -333,33 +330,41 @@ Geom::Point FilletChamferKnotHolderEntity::knot_get() const if (_subindex >= _pparam->_vector[_index].size()) { subindex = _subindex - _pparam->_vector[_index].size(); } - if (!valid_index(_subindex)) { + if (!valid_index(_index)) { return Geom::Point(Geom::infinity(), Geom::infinity()); } - Satellite satellite = _pparam->_vector[_index][_subindex]; - if (!_pparam->_last_pointwise) { + Satellite satellite = _pparam->_vector[_index][subindex]; + Pointwise *pointwise = _pparam->_last_pointwise; + if (!pointwise) { return Geom::Point(Geom::infinity(), Geom::infinity()); } - if (!satellite.active || satellite.hidden) { + Geom::PathVector pathv = pointwise->getPV(); + if (pathv[_index].size() <= subindex){ //We know this path is open and is last satellite. Hide it + _pparam->_vector[_index][subindex].hidden = true; return Geom::Point(Geom::infinity(), Geom::infinity()); } - Pointwise *pointwise = _pparam->_last_pointwise; - Geom::PathVector pathv = pparam->_last_pointwise->getPV(); - if (pathv[_index].size() <= subindex) { + if (!pathv[_index].closed() && subindex == 0){ //Path is open hide first satellite + _pparam->_vector[_index][subindex].hidden = true; + return Geom::Point(Geom::infinity(), Geom::infinity()); + } + if (satellite.hidden) { + return Geom::Point(Geom::infinity(), Geom::infinity()); + } + if (subindex != _subindex && !_pparam->_vector[_index][subindex].has_mirror) { return Geom::Point(Geom::infinity(), Geom::infinity()); } this->knot->show(); - if (_subindex >= _pparam->_vector[index].size()) { - tmp_point = satellite.getPosition(pathv[_index][_subindex]); + if (subindex != _subindex) { + tmp_point = satellite.getPosition(pathv[_index][subindex]); boost::optional curve_prev_index = boost::none; - if(_subindex == 0 && pathv[_index].closed()){ - curve_prev_index = pathv[pathv[_index].size() - 1]; - } else if(!pathv[_index].closed() || _subindex != 0) { - curve_prev_index = _subindex - 1; + if(subindex == 0 && pathv[_index].closed()){ + curve_prev_index = pathv[_index].size() - 1; + } else if(!pathv[_index].closed() || subindex != 0) { + curve_prev_index = subindex - 1; } if (curve_prev_index) { Geom::Curve const &curve_in = pathv[_index][*curve_prev_index]; - double s = satellite.arcDistance(pathv[_index][_subindex]); + double s = satellite.arcDistance(pathv[_index][subindex]); double t = satellite.time(s, true, curve_in); if (t > 1) { t = 1; @@ -375,7 +380,7 @@ Geom::Point FilletChamferKnotHolderEntity::knot_get() const tmp_point = (curve_in).pointAt(t); } } else { - tmp_point = satellite.getPosition(pathv[_index][_subindex]); + tmp_point = satellite.getPosition(pathv[_index][subindex]); } Geom::Point const canvas_point = tmp_point; return canvas_point; @@ -386,19 +391,18 @@ void FilletChamferKnotHolderEntity::knot_click(guint state) if (!_pparam->_last_pointwise) { return; } - size_t subindex = _subindex; if (_subindex >= _pparam->_vector[_index].size()) { subindex = _subindex - _pparam->_vector[_index].size(); } if (state & GDK_CONTROL_MASK) { if (state & GDK_MOD1_MASK) { - _pparam->_vector[_index][_subindex].amount = 0.0; + _pparam->_vector[_index][subindex].amount = 0.0; _pparam->param_set_and_write_new_value(_pparam->_vector); sp_lpe_item_update_patheffect(SP_LPE_ITEM(item), false, false); } else { using namespace Geom; - SatelliteType type = _pparam->_vector[_index][_subindex].satellite_type; + SatelliteType type = _pparam->_vector[_index][subindex].satellite_type; switch (type) { case FILLET: type = INVERSE_FILLET; @@ -438,13 +442,13 @@ void FilletChamferKnotHolderEntity::knot_click(guint state) this->knot->show(); } } else if (state & GDK_SHIFT_MASK) { - Geom::PathVector pathv = pparam->_last_pointwise->getPV(); - double amount = _pparam->_vector[_index][_subindex].amount; + Geom::PathVector pathv = _pparam->_last_pointwise->getPV(); + double amount = _pparam->_vector[_index][subindex].amount; boost::optional curve_prev_index = boost::none; - if(_subindex == 0 && pathv[_index].closed()){ - curve_prev_index = pathv[pathv[_index].size() - 1]; - } else if(!pathv[_index].closed() || _subindex != 0) { - curve_prev_index = _subindex - 1; + if(subindex == 0 && pathv[_index].closed()){ + curve_prev_index = pathv[_index].size() - 1; + } else if(!pathv[_index].closed() || subindex != 0) { + curve_prev_index = subindex - 1; } if (!_pparam->_use_distance && !_pparam->_vector[_index][subindex].is_time) { if (curve_prev_index) { @@ -454,10 +458,9 @@ void FilletChamferKnotHolderEntity::knot_click(guint state) } } bool aprox = false; - Geom::D2 d2_out = _pparam->_last_pointwise->getPwd2()[_index][subindex]; + Geom::D2 d2_out = pathv[_index][subindex].toSBasis(); if (curve_prev_index) { - Geom::D2 d2_in = - _pparam->_last_pointwise->getPwd2()[_index][*curve_prev_index]; + Geom::D2 d2_in = pathv[_index][*curve_prev_index].toSBasis(); aprox = ((d2_in)[0].degreesOfFreedom() != 2 || d2_out[0].degreesOfFreedom() != 2) && !_pparam->_use_distance @@ -483,17 +486,16 @@ void FilletChamferKnotHolderEntity::knot_set_offset(Satellite satellite) double amount = satellite.amount; double max_amount = amount; if (!_pparam->_use_distance && !satellite.is_time) { - Geom::Piecewise > pwd2 = _pparam->_last_pointwise->getPwd2(); - Geom::PathVector pathv = path_from_piecewise(Geom::remove_short_cuts(pwd2,0.01),0.01); - Geom::Path sat_path = pathv.pathAt(index); + Pointwise *pointwise = _pparam->_last_pointwise; + Geom::PathVector pathv = pointwise->getPV(); boost::optional curve_prev_index = boost::none; - if(_subindex == 0 && pathv[_index].closed()){ - curve_prev_index = pathv[pathv[_index].size() - 1]; - } else if(!pathv[_index].closed() || _subindex != 0) { - curve_prev_index = _subindex - 1; + if(subindex == 0 && pathv[_index].closed()){ + curve_prev_index = pathv[_index].size() - 1; + } else if(!pathv[_index].closed() || subindex != 0) { + curve_prev_index = subindex - 1; } if (curve_prev_index) { - amount = _pparam->_vector[_index][subindex].radToLen(amount, pathv[_index][*prev], pathv[_index][subindex]); + amount = _pparam->_vector[_index][subindex].radToLen(amount, pathv[_index][*curve_prev_index], pathv[_index][subindex]); } else { amount = 0.0; } -- cgit v1.2.3 From b03cc6d03c9cfa57ebee8c70412e96c5d92f4f83 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Wed, 11 May 2016 22:27:45 +0200 Subject: pre-remove of subpath update satellites (bzr r13645.1.132) --- src/live_effects/parameter/satellitesarray.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/live_effects/parameter/satellitesarray.cpp') diff --git a/src/live_effects/parameter/satellitesarray.cpp b/src/live_effects/parameter/satellitesarray.cpp index 9f14a1d5b..8e6ba0b41 100644 --- a/src/live_effects/parameter/satellitesarray.cpp +++ b/src/live_effects/parameter/satellitesarray.cpp @@ -339,6 +339,7 @@ Geom::Point FilletChamferKnotHolderEntity::knot_get() const return Geom::Point(Geom::infinity(), Geom::infinity()); } Geom::PathVector pathv = pointwise->getPV(); + if (pathv[_index].size() <= subindex){ //We know this path is open and is last satellite. Hide it _pparam->_vector[_index][subindex].hidden = true; return Geom::Point(Geom::infinity(), Geom::infinity()); -- cgit v1.2.3 From 4c145e43f8ab8d8040fb2fa42309f7bd400f6349 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sat, 14 May 2016 23:52:45 +0200 Subject: Fixing pointwise (bzr r13645.1.135) --- src/live_effects/parameter/satellitesarray.cpp | 231 ++++++++++++------------- 1 file changed, 107 insertions(+), 124 deletions(-) (limited to 'src/live_effects/parameter/satellitesarray.cpp') diff --git a/src/live_effects/parameter/satellitesarray.cpp b/src/live_effects/parameter/satellitesarray.cpp index 8e6ba0b41..be4eb6732 100644 --- a/src/live_effects/parameter/satellitesarray.cpp +++ b/src/live_effects/parameter/satellitesarray.cpp @@ -12,7 +12,6 @@ #include "live_effects/effect.h" #include "sp-lpe-item.h" #include -#include // TODO due to internal breakage in glibmm headers, // this has to be included last. #include @@ -34,7 +33,6 @@ SatellitesArrayParam::SatellitesArrayParam(const Glib::ustring &label, _helper_size = 0; _use_distance = false; _effectType = FILLET_CHAMFER; - _last_pointwise = NULL; } void SatellitesArrayParam::set_oncanvas_looks(SPKnotShapeType shape, @@ -46,10 +44,10 @@ void SatellitesArrayParam::set_oncanvas_looks(SPKnotShapeType shape, _knot_color = color; } -void SatellitesArrayParam::setPointwise(Pointwise *pointwise) +void SatellitesArrayParam::setPointwise(Pointwise pointwise) { _last_pointwise = pointwise; - param_set_and_write_new_value(_last_pointwise->getSatellites()); + param_set_and_write_new_value(_last_pointwise.getSatellites()); } void SatellitesArrayParam::setUseDistance(bool use_knot_distance) @@ -67,51 +65,51 @@ void SatellitesArrayParam::setHelperSize(int hs) _helper_size = hs; updateCanvasIndicators(); } - +bool SatellitesArrayParam::validData() +{ + return _last_pointwise.getPathVector().nodes().size() == _last_pointwise.getTotalSatellites(); +} void SatellitesArrayParam::updateCanvasIndicators(bool mirror) { - if (!_last_pointwise) { + if (!validData()) { + return; + } + if(!_hp.empty()) { + _hp.clear(); + } + Geom::PathVector pathv = _last_pointwise.getPathVector(); + if (pathv.empty()) { return; } - Geom::PathVector pathv = _last_pointwise->getPV(); 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) { - continue; - } - if ((!_vector[i][j].has_mirror && mirror == true) || _vector[i][j].amount == 0) { - continue; - } - double pos = 0; - if (pathv[i].size() == j) { //ignore last satellite in open paths with fillet chamfer effect + 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(); - double lenght_in = 0; - - boost::optional curve_prev_index = boost::none; + size_t previous_index = j - 1; //Always are previous index because we skip first satellite on open paths if(j == 0 && pathv[i].closed()){ - curve_prev_index = pathv[i].size() - 1; - } else if(!pathv[i].closed() || j != 0) { - curve_prev_index = j - 1; - } - if (curve_prev_index) { - lenght_in = pathv.curveAt(*curve_prev_index).length(); + previous_index = pathv[i].size() - 1; } + double lenght_in = pathv.curveAt(previous_index).length(); if (mirror) { - if (curve_prev_index) { - curve_in = const_cast(&pathv.curveAt(*curve_prev_index)); - pos = _vector[i][j].time(size_out, true, *curve_in); - if (lenght_out < size_out) { - overflow = true; - } + curve_in = const_cast(&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); @@ -191,8 +189,7 @@ void SatellitesArrayParam::addCanvasIndicators( hp_vec.push_back(_hp); } -void SatellitesArrayParam::param_transform_multiply(Geom::Affine const &postmul, - bool /*set*/) +void SatellitesArrayParam::param_transform_multiply(Geom::Affine const &postmul, bool /*set*/) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -212,6 +209,10 @@ void SatellitesArrayParam::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item, bool mirror) { + if (!validData()) { + return; + } + Geom::PathVector pathv = _last_pointwise.getPathVector(); 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) { @@ -226,6 +227,9 @@ void SatellitesArrayParam::addKnotHolderEntities(KnotHolder *knotholder, using namespace Geom; //If is for filletChamfer effect... if (_effectType == FILLET_CHAMFER) { + if(!pathv[i].closed() && (j == 0 || j == _vector[i].size() -1)) { + continue; + } const gchar *tip; if (type == CHAMFER) { tip = _("Chamfer: Ctrl+Click toggle type, " @@ -271,48 +275,41 @@ void FilletChamferKnotHolderEntity::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state) { + if (! _pparam->validData() || !valid_index(_index)) { + return; + } Geom::Point s = snap_knot_position(p, state); size_t subindex = _subindex; if (_subindex >= _pparam->_vector[_index].size()) { subindex = _subindex - _pparam->_vector[_index].size(); } - if (!valid_index(_index)) { - return; - } - - if (!_pparam->_last_pointwise) { - return; - } - Satellite satellite = _pparam->_vector[_index][subindex]; - if (satellite.hidden) { + Geom::PathVector pathv = _pparam->_last_pointwise.getPathVector(); + if (satellite.hidden || + !pathv[_index].closed() && subindex == 0 ||//ignore first satellites on open paths + pathv[_index].size() == subindex) //ignore last satellite in open paths with fillet chamfer effect + { return; } - Pointwise *pointwise = _pparam->_last_pointwise; - Geom::PathVector pathv = pointwise->getPV(); if (subindex != _subindex) { - boost::optional curve_prev_index = boost::none; + size_t previous_index = subindex - 1; if(subindex == 0 && pathv[_index].closed()){ - curve_prev_index = pathv[_index].size() - 1; - } else if(!pathv[_index].closed() || subindex != 0) { - curve_prev_index = subindex - 1; + previous_index = pathv[_index].size() - 1; } - if (curve_prev_index) { - Geom::Curve const &curve_in = pathv[_index][*curve_prev_index]; - double mirror_time = Geom::nearest_time(s, curve_in); - double time_start = 0; - Satellites satellites = pointwise->getSatellites(); - time_start = satellites[_index][*curve_prev_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[_index][subindex]); - } - satellite.amount = amount; + Geom::Curve const &curve_in = pathv[_index][previous_index]; + double mirror_time = Geom::nearest_time(s, curve_in); + double time_start = 0; + Satellites satellites = _pparam->_last_pointwise.getSatellites(); + time_start = satellites[_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[_index][subindex]); + } + satellite.amount = amount; } else { satellite.setPosition(s, pathv[_index][subindex]); } @@ -325,61 +322,45 @@ void FilletChamferKnotHolderEntity::knot_set(Geom::Point const &p, Geom::Point FilletChamferKnotHolderEntity::knot_get() const { + if (! _pparam->validData() || !valid_index(_index)) { + return Geom::Point(Geom::infinity(), Geom::infinity()); + } Geom::Point tmp_point; size_t subindex = _subindex; if (_subindex >= _pparam->_vector[_index].size()) { subindex = _subindex - _pparam->_vector[_index].size(); } - if (!valid_index(_index)) { - return Geom::Point(Geom::infinity(), Geom::infinity()); - } Satellite satellite = _pparam->_vector[_index][subindex]; - Pointwise *pointwise = _pparam->_last_pointwise; - if (!pointwise) { - return Geom::Point(Geom::infinity(), Geom::infinity()); - } - Geom::PathVector pathv = pointwise->getPV(); - - if (pathv[_index].size() <= subindex){ //We know this path is open and is last satellite. Hide it + Geom::PathVector pathv = _pparam->_last_pointwise.getPathVector(); + if (satellite.hidden || + !pathv[_index].closed() && subindex == 0 ||//ignore first satellites on open paths + pathv[_index].size() == subindex) //ignore last satellite in open paths with fillet chamfer effect + { _pparam->_vector[_index][subindex].hidden = true; return Geom::Point(Geom::infinity(), Geom::infinity()); } - if (!pathv[_index].closed() && subindex == 0){ //Path is open hide first satellite - _pparam->_vector[_index][subindex].hidden = true; - return Geom::Point(Geom::infinity(), Geom::infinity()); - } - if (satellite.hidden) { - return Geom::Point(Geom::infinity(), Geom::infinity()); - } - if (subindex != _subindex && !_pparam->_vector[_index][subindex].has_mirror) { - return Geom::Point(Geom::infinity(), Geom::infinity()); - } this->knot->show(); if (subindex != _subindex) { tmp_point = satellite.getPosition(pathv[_index][subindex]); - boost::optional curve_prev_index = boost::none; + size_t previous_index = subindex - 1; if(subindex == 0 && pathv[_index].closed()){ - curve_prev_index = pathv[_index].size() - 1; - } else if(!pathv[_index].closed() || subindex != 0) { - curve_prev_index = subindex - 1; + previous_index = pathv[_index].size() - 1; } - if (curve_prev_index) { - Geom::Curve const &curve_in = pathv[_index][*curve_prev_index]; - double s = satellite.arcDistance(pathv[_index][subindex]); - double t = satellite.time(s, true, curve_in); - if (t > 1) { - t = 1; - } - if (t < 0) { - t = 0; - } - double time_start = 0; - time_start = pointwise->getSatellites()[_index][*curve_prev_index].time(curve_in); - if (time_start > t) { - t = time_start; - } - tmp_point = (curve_in).pointAt(t); + Geom::Curve const &curve_in = pathv[_index][previous_index]; + double s = satellite.arcDistance(pathv[_index][subindex]); + 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_pointwise.getSatellites()[_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[_index][subindex]); } @@ -389,13 +370,19 @@ Geom::Point FilletChamferKnotHolderEntity::knot_get() const void FilletChamferKnotHolderEntity::knot_click(guint state) { - if (!_pparam->_last_pointwise) { + if (! _pparam->validData() || !valid_index(_index)) { return; } size_t subindex = _subindex; if (_subindex >= _pparam->_vector[_index].size()) { subindex = _subindex - _pparam->_vector[_index].size(); } + Geom::PathVector pathv = _pparam->_last_pointwise.getPathVector(); + if (!pathv[_index].closed() && subindex == 0 ||//ignore first satellites on open paths + pathv[_index].size() == subindex) //ignore last satellite in open paths with fillet chamfer effect + { + return; + } if (state & GDK_CONTROL_MASK) { if (state & GDK_MOD1_MASK) { _pparam->_vector[_index][subindex].amount = 0.0; @@ -443,25 +430,22 @@ void FilletChamferKnotHolderEntity::knot_click(guint state) this->knot->show(); } } else if (state & GDK_SHIFT_MASK) { - Geom::PathVector pathv = _pparam->_last_pointwise->getPV(); double amount = _pparam->_vector[_index][subindex].amount; - boost::optional curve_prev_index = boost::none; + size_t previous_index = subindex - 1; if(subindex == 0 && pathv[_index].closed()){ - curve_prev_index = pathv[_index].size() - 1; - } else if(!pathv[_index].closed() || subindex != 0) { - curve_prev_index = subindex - 1; + previous_index = pathv[_index].size() - 1; } if (!_pparam->_use_distance && !_pparam->_vector[_index][subindex].is_time) { - if (curve_prev_index) { - amount = _pparam->_vector[_index][subindex].lenToRad(amount, pathv[_index][*curve_prev_index], pathv[_index][subindex], _pparam->_vector[_index][*curve_prev_index]); + if (previous_index) { + amount = _pparam->_vector[_index][subindex].lenToRad(amount, pathv[_index][previous_index], pathv[_index][subindex], _pparam->_vector[_index][previous_index]); } else { amount = 0.0; } } bool aprox = false; Geom::D2 d2_out = pathv[_index][subindex].toSBasis(); - if (curve_prev_index) { - Geom::D2 d2_in = pathv[_index][*curve_prev_index].toSBasis(); + if (previous_index) { + Geom::D2 d2_in = pathv[_index][previous_index].toSBasis(); aprox = ((d2_in)[0].degreesOfFreedom() != 2 || d2_out[0].degreesOfFreedom() != 2) && !_pparam->_use_distance @@ -477,29 +461,28 @@ void FilletChamferKnotHolderEntity::knot_click(guint state) void FilletChamferKnotHolderEntity::knot_set_offset(Satellite satellite) { - if (!_pparam->_last_pointwise) { + if (! _pparam->validData() || !valid_index(_index)) { return; } size_t subindex = _subindex; if (_subindex >= _pparam->_vector[_index].size()) { subindex = _subindex - _pparam->_vector[_index].size(); } + Geom::PathVector pathv = _pparam->_last_pointwise.getPathVector(); + if (satellite.hidden || + !pathv[_index].closed() && subindex == 0 ||//ignore first satellites on open paths + pathv[_index].size() == subindex) //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) { - Pointwise *pointwise = _pparam->_last_pointwise; - Geom::PathVector pathv = pointwise->getPV(); - boost::optional curve_prev_index = boost::none; + size_t previous_index = subindex - 1; if(subindex == 0 && pathv[_index].closed()){ - curve_prev_index = pathv[_index].size() - 1; - } else if(!pathv[_index].closed() || subindex != 0) { - curve_prev_index = subindex - 1; - } - if (curve_prev_index) { - amount = _pparam->_vector[_index][subindex].radToLen(amount, pathv[_index][*curve_prev_index], pathv[_index][subindex]); - } else { - amount = 0.0; + previous_index = pathv[_index].size() - 1; } + amount = _pparam->_vector[_index][subindex].radToLen(amount, pathv[_index][previous_index], pathv[_index][subindex]); if (max_amount > 0 && amount == 0) { amount = _pparam->_vector[_index][subindex].amount; } -- cgit v1.2.3 From 159439c26042b7c69aa9c33ce9484e4dfd00372a Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sun, 15 May 2016 11:48:51 +0200 Subject: Fixing pointwise (bzr r13645.1.137) --- src/live_effects/parameter/satellitesarray.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/live_effects/parameter/satellitesarray.cpp') diff --git a/src/live_effects/parameter/satellitesarray.cpp b/src/live_effects/parameter/satellitesarray.cpp index be4eb6732..14660acc4 100644 --- a/src/live_effects/parameter/satellitesarray.cpp +++ b/src/live_effects/parameter/satellitesarray.cpp @@ -48,6 +48,7 @@ void SatellitesArrayParam::setPointwise(Pointwise pointwise) { _last_pointwise = pointwise; param_set_and_write_new_value(_last_pointwise.getSatellites()); + } void SatellitesArrayParam::setUseDistance(bool use_knot_distance) @@ -60,6 +61,11 @@ void SatellitesArrayParam::setEffectType(EffectType et) _effectType = et; } +void SatellitesArrayParam::setPathUpdate(bool path_update) +{ + _path_update = path_update; +} + void SatellitesArrayParam::setHelperSize(int hs) { _helper_size = hs; @@ -67,6 +73,7 @@ void SatellitesArrayParam::setHelperSize(int hs) } bool SatellitesArrayParam::validData() { + if (_path_update) { return false;} return _last_pointwise.getPathVector().nodes().size() == _last_pointwise.getTotalSatellites(); } void SatellitesArrayParam::updateCanvasIndicators(bool mirror) @@ -323,6 +330,7 @@ void FilletChamferKnotHolderEntity::knot_set(Geom::Point const &p, Geom::Point FilletChamferKnotHolderEntity::knot_get() const { if (! _pparam->validData() || !valid_index(_index)) { + this->knot->hide(); return Geom::Point(Geom::infinity(), Geom::infinity()); } Geom::Point tmp_point; @@ -336,10 +344,12 @@ Geom::Point FilletChamferKnotHolderEntity::knot_get() const !pathv[_index].closed() && subindex == 0 ||//ignore first satellites on open paths pathv[_index].size() == subindex) //ignore last satellite in open paths with fillet chamfer effect { + this->knot->hide(); _pparam->_vector[_index][subindex].hidden = true; return Geom::Point(Geom::infinity(), Geom::infinity()); } this->knot->show(); + std::cout << subindex << pathv[_index].size() << "----" << _pparam->_vector[_index].size() << "fgdgsdgsdgsdsdsgd\n"; if (subindex != _subindex) { tmp_point = satellite.getPosition(pathv[_index][subindex]); size_t previous_index = subindex - 1; -- cgit v1.2.3 From 8d35486a82d04a28dc9f297147ad4666b34cde4a Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Thu, 26 May 2016 19:37:15 +0200 Subject: Fixing pointwise (bzr r13645.1.143) --- src/live_effects/parameter/satellitesarray.cpp | 56 +++++++++++++------------- 1 file changed, 29 insertions(+), 27 deletions(-) (limited to 'src/live_effects/parameter/satellitesarray.cpp') diff --git a/src/live_effects/parameter/satellitesarray.cpp b/src/live_effects/parameter/satellitesarray.cpp index 14660acc4..78f1a945f 100644 --- a/src/live_effects/parameter/satellitesarray.cpp +++ b/src/live_effects/parameter/satellitesarray.cpp @@ -61,26 +61,25 @@ void SatellitesArrayParam::setEffectType(EffectType et) _effectType = et; } -void SatellitesArrayParam::setPathUpdate(bool path_update) -{ - _path_update = path_update; -} - void SatellitesArrayParam::setHelperSize(int hs) { _helper_size = hs; updateCanvasIndicators(); } -bool SatellitesArrayParam::validData() +bool SatellitesArrayParam::validData(size_t index,size_t subindex) { - if (_path_update) { return false;} - return _last_pointwise.getPathVector().nodes().size() == _last_pointwise.getTotalSatellites(); + if(!_last_pointwise.getPathVector().size() > index){ + return false; + } + if(!_last_pointwise.getPathVector()[index].size_closed() > subindex){ + return false; + } + return true; //_last_pointwise.getPathVector().nodes().size() == _last_pointwise.getTotalSatellites(); } + void SatellitesArrayParam::updateCanvasIndicators(bool mirror) { - if (!validData()) { - return; - } + if(!_hp.empty()) { _hp.clear(); } @@ -94,6 +93,9 @@ void SatellitesArrayParam::updateCanvasIndicators(bool mirror) if (_effectType == FILLET_CHAMFER) { for (size_t i = 0; i < _vector.size(); ++i) { for (size_t j = 0; j < _vector[i].size(); ++j) { + if (!validData(i, j)) { + return; + } 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 @@ -216,12 +218,12 @@ void SatellitesArrayParam::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item, bool mirror) { - if (!validData()) { - return; - } Geom::PathVector pathv = _last_pointwise.getPathVector(); for (size_t i = 0; i < _vector.size(); ++i) { for (size_t j = 0; j < _vector[i].size(); ++j) { + if (!validData(i, j)) { + return; + } if (!_vector[i][j].has_mirror && mirror) { continue; } @@ -282,14 +284,14 @@ void FilletChamferKnotHolderEntity::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state) { - if (! _pparam->validData() || !valid_index(_index)) { - return; - } Geom::Point s = snap_knot_position(p, state); size_t subindex = _subindex; if (_subindex >= _pparam->_vector[_index].size()) { subindex = _subindex - _pparam->_vector[_index].size(); } + if (!_pparam->validData(_index, subindex)) { + return; + } Satellite satellite = _pparam->_vector[_index][subindex]; Geom::PathVector pathv = _pparam->_last_pointwise.getPathVector(); if (satellite.hidden || @@ -329,15 +331,15 @@ void FilletChamferKnotHolderEntity::knot_set(Geom::Point const &p, Geom::Point FilletChamferKnotHolderEntity::knot_get() const { - if (! _pparam->validData() || !valid_index(_index)) { - this->knot->hide(); - return Geom::Point(Geom::infinity(), Geom::infinity()); - } Geom::Point tmp_point; size_t subindex = _subindex; if (_subindex >= _pparam->_vector[_index].size()) { subindex = _subindex - _pparam->_vector[_index].size(); } + if (!_pparam->validData(_index, subindex)) { + this->knot->hide(); + return Geom::Point(Geom::infinity(), Geom::infinity()); + } Satellite satellite = _pparam->_vector[_index][subindex]; Geom::PathVector pathv = _pparam->_last_pointwise.getPathVector(); if (satellite.hidden || @@ -380,13 +382,13 @@ Geom::Point FilletChamferKnotHolderEntity::knot_get() const void FilletChamferKnotHolderEntity::knot_click(guint state) { - if (! _pparam->validData() || !valid_index(_index)) { - return; - } size_t subindex = _subindex; if (_subindex >= _pparam->_vector[_index].size()) { subindex = _subindex - _pparam->_vector[_index].size(); } + if (!_pparam->validData(_index, subindex)) { + return; + } Geom::PathVector pathv = _pparam->_last_pointwise.getPathVector(); if (!pathv[_index].closed() && subindex == 0 ||//ignore first satellites on open paths pathv[_index].size() == subindex) //ignore last satellite in open paths with fillet chamfer effect @@ -471,13 +473,13 @@ void FilletChamferKnotHolderEntity::knot_click(guint state) void FilletChamferKnotHolderEntity::knot_set_offset(Satellite satellite) { - if (! _pparam->validData() || !valid_index(_index)) { - return; - } size_t subindex = _subindex; if (_subindex >= _pparam->_vector[_index].size()) { subindex = _subindex - _pparam->_vector[_index].size(); } + if (!_pparam->validData(_index, subindex)) { + return; + } Geom::PathVector pathv = _pparam->_last_pointwise.getPathVector(); if (satellite.hidden || !pathv[_index].closed() && subindex == 0 ||//ignore first satellites on open paths -- cgit v1.2.3 From 634be67d2fa8aa07d25d96e10a3ad24fdfdcc80e Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Thu, 26 May 2016 20:44:19 +0200 Subject: Rename branch (bzr r13645.1.145) --- src/live_effects/parameter/satellitesarray.cpp | 28 +++++++++++++------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'src/live_effects/parameter/satellitesarray.cpp') diff --git a/src/live_effects/parameter/satellitesarray.cpp b/src/live_effects/parameter/satellitesarray.cpp index 78f1a945f..45a6282e0 100644 --- a/src/live_effects/parameter/satellitesarray.cpp +++ b/src/live_effects/parameter/satellitesarray.cpp @@ -44,10 +44,10 @@ void SatellitesArrayParam::set_oncanvas_looks(SPKnotShapeType shape, _knot_color = color; } -void SatellitesArrayParam::setPointwise(Pointwise pointwise) +void SatellitesArrayParam::setPathVectorSatellites(PathVectorSatellites pathVectorSatellites) { - _last_pointwise = pointwise; - param_set_and_write_new_value(_last_pointwise.getSatellites()); + _last_pathVectorSatellites = pathVectorSatellites; + param_set_and_write_new_value(_last_pathVectorSatellites.getSatellites()); } @@ -68,13 +68,13 @@ void SatellitesArrayParam::setHelperSize(int hs) } bool SatellitesArrayParam::validData(size_t index,size_t subindex) { - if(!_last_pointwise.getPathVector().size() > index){ + if(!_last_pathVectorSatellites.getPathVector().size() > index){ return false; } - if(!_last_pointwise.getPathVector()[index].size_closed() > subindex){ + if(!_last_pathVectorSatellites.getPathVector()[index].size_closed() > subindex){ return false; } - return true; //_last_pointwise.getPathVector().nodes().size() == _last_pointwise.getTotalSatellites(); + return true; //_last_pathVectorSatellites.getPathVector().nodes().size() == _last_pathVectorSatellites.getTotalSatellites(); } void SatellitesArrayParam::updateCanvasIndicators(bool mirror) @@ -83,7 +83,7 @@ void SatellitesArrayParam::updateCanvasIndicators(bool mirror) if(!_hp.empty()) { _hp.clear(); } - Geom::PathVector pathv = _last_pointwise.getPathVector(); + Geom::PathVector pathv = _last_pathVectorSatellites.getPathVector(); if (pathv.empty()) { return; } @@ -218,7 +218,7 @@ void SatellitesArrayParam::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item, bool mirror) { - Geom::PathVector pathv = _last_pointwise.getPathVector(); + Geom::PathVector pathv = _last_pathVectorSatellites.getPathVector(); for (size_t i = 0; i < _vector.size(); ++i) { for (size_t j = 0; j < _vector[i].size(); ++j) { if (!validData(i, j)) { @@ -293,7 +293,7 @@ void FilletChamferKnotHolderEntity::knot_set(Geom::Point const &p, return; } Satellite satellite = _pparam->_vector[_index][subindex]; - Geom::PathVector pathv = _pparam->_last_pointwise.getPathVector(); + Geom::PathVector pathv = _pparam->_last_pathVectorSatellites.getPathVector(); if (satellite.hidden || !pathv[_index].closed() && subindex == 0 ||//ignore first satellites on open paths pathv[_index].size() == subindex) //ignore last satellite in open paths with fillet chamfer effect @@ -308,7 +308,7 @@ void FilletChamferKnotHolderEntity::knot_set(Geom::Point const &p, Geom::Curve const &curve_in = pathv[_index][previous_index]; double mirror_time = Geom::nearest_time(s, curve_in); double time_start = 0; - Satellites satellites = _pparam->_last_pointwise.getSatellites(); + Satellites satellites = _pparam->_last_pathVectorSatellites.getSatellites(); time_start = satellites[_index][previous_index].time(curve_in); if (time_start > mirror_time) { mirror_time = time_start; @@ -341,7 +341,7 @@ Geom::Point FilletChamferKnotHolderEntity::knot_get() const return Geom::Point(Geom::infinity(), Geom::infinity()); } Satellite satellite = _pparam->_vector[_index][subindex]; - Geom::PathVector pathv = _pparam->_last_pointwise.getPathVector(); + Geom::PathVector pathv = _pparam->_last_pathVectorSatellites.getPathVector(); if (satellite.hidden || !pathv[_index].closed() && subindex == 0 ||//ignore first satellites on open paths pathv[_index].size() == subindex) //ignore last satellite in open paths with fillet chamfer effect @@ -368,7 +368,7 @@ Geom::Point FilletChamferKnotHolderEntity::knot_get() const t = 0; } double time_start = 0; - time_start = _pparam->_last_pointwise.getSatellites()[_index][previous_index].time(curve_in); + time_start = _pparam->_last_pathVectorSatellites.getSatellites()[_index][previous_index].time(curve_in); if (time_start > t) { t = time_start; } @@ -389,7 +389,7 @@ void FilletChamferKnotHolderEntity::knot_click(guint state) if (!_pparam->validData(_index, subindex)) { return; } - Geom::PathVector pathv = _pparam->_last_pointwise.getPathVector(); + Geom::PathVector pathv = _pparam->_last_pathVectorSatellites.getPathVector(); if (!pathv[_index].closed() && subindex == 0 ||//ignore first satellites on open paths pathv[_index].size() == subindex) //ignore last satellite in open paths with fillet chamfer effect { @@ -480,7 +480,7 @@ void FilletChamferKnotHolderEntity::knot_set_offset(Satellite satellite) if (!_pparam->validData(_index, subindex)) { return; } - Geom::PathVector pathv = _pparam->_last_pointwise.getPathVector(); + Geom::PathVector pathv = _pparam->_last_pathVectorSatellites.getPathVector(); if (satellite.hidden || !pathv[_index].closed() && subindex == 0 ||//ignore first satellites on open paths pathv[_index].size() == subindex) //ignore last satellite in open paths with fillet chamfer effect -- cgit v1.2.3 From 5ad260d5810f6f8bb2cdea7186d0766091ad9b54 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sat, 11 Jun 2016 17:32:56 +0200 Subject: Fixing satellites bug on erase (bzr r13645.1.146) --- src/live_effects/parameter/satellitesarray.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'src/live_effects/parameter/satellitesarray.cpp') diff --git a/src/live_effects/parameter/satellitesarray.cpp b/src/live_effects/parameter/satellitesarray.cpp index 45a6282e0..cb7d0df8f 100644 --- a/src/live_effects/parameter/satellitesarray.cpp +++ b/src/live_effects/parameter/satellitesarray.cpp @@ -44,11 +44,16 @@ void SatellitesArrayParam::set_oncanvas_looks(SPKnotShapeType shape, _knot_color = color; } -void SatellitesArrayParam::setPathVectorSatellites(PathVectorSatellites pathVectorSatellites) +void SatellitesArrayParam::setPathVectorSatellites(PathVectorSatellites pathVectorSatellites, bool refresh_knots) { + if (refresh_knots) { + clearKnotHolder(knoth); + } _last_pathVectorSatellites = pathVectorSatellites; param_set_and_write_new_value(_last_pathVectorSatellites.getSatellites()); - + if (refresh_knots) { + addKnotHolderEntities(knoth, SP_ACTIVE_DESKTOP, knoth.getItem()); + } } void SatellitesArrayParam::setUseDistance(bool use_knot_distance) @@ -214,6 +219,16 @@ void SatellitesArrayParam::param_transform_multiply(Geom::Affine const &postmul, } } +void SatellitesArrayParam::clearKnotHolder(KnotHolder *knotholder) +{ + for (std::list::iterator i = knotholder.entity.begin(); i != knotholder.entity.end(); ++i) + { + delete (*i); + (*i) = NULL; + } + entity.clear(); // is this necessary? +} + void SatellitesArrayParam::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item, bool mirror) -- cgit v1.2.3 From d84bbca17771ed1a2f680328adf14b30a4c66b77 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sun, 12 Jun 2016 01:05:25 +0200 Subject: Fix the bug deleting satellites (bzr r13645.1.148) --- src/live_effects/parameter/satellitesarray.cpp | 248 +++++++++++++------------ 1 file changed, 128 insertions(+), 120 deletions(-) (limited to 'src/live_effects/parameter/satellitesarray.cpp') diff --git a/src/live_effects/parameter/satellitesarray.cpp b/src/live_effects/parameter/satellitesarray.cpp index cb7d0df8f..e61aaf38d 100644 --- a/src/live_effects/parameter/satellitesarray.cpp +++ b/src/live_effects/parameter/satellitesarray.cpp @@ -11,6 +11,7 @@ #include "live_effects/parameter/satellitesarray.h" #include "live_effects/effect.h" #include "sp-lpe-item.h" +#include "inkscape.h" #include // TODO due to internal breakage in glibmm headers, // this has to be included last. @@ -33,6 +34,7 @@ SatellitesArrayParam::SatellitesArrayParam(const Glib::ustring &label, _helper_size = 0; _use_distance = false; _effectType = FILLET_CHAMFER; + _last_pathvector_satellites = NULL; } void SatellitesArrayParam::set_oncanvas_looks(SPKnotShapeType shape, @@ -44,16 +46,10 @@ void SatellitesArrayParam::set_oncanvas_looks(SPKnotShapeType shape, _knot_color = color; } -void SatellitesArrayParam::setPathVectorSatellites(PathVectorSatellites pathVectorSatellites, bool refresh_knots) +void SatellitesArrayParam::setPathVectorSatellites(PathVectorSatellites *pathVectorSatellites) { - if (refresh_knots) { - clearKnotHolder(knoth); - } - _last_pathVectorSatellites = pathVectorSatellites; - param_set_and_write_new_value(_last_pathVectorSatellites.getSatellites()); - if (refresh_knots) { - addKnotHolderEntities(knoth, SP_ACTIVE_DESKTOP, knoth.getItem()); - } + _last_pathvector_satellites = pathVectorSatellites; + param_set_and_write_new_value(_last_pathvector_satellites->getSatellites()); } void SatellitesArrayParam::setUseDistance(bool use_knot_distance) @@ -71,24 +67,18 @@ void SatellitesArrayParam::setHelperSize(int hs) _helper_size = hs; updateCanvasIndicators(); } -bool SatellitesArrayParam::validData(size_t index,size_t subindex) -{ - if(!_last_pathVectorSatellites.getPathVector().size() > index){ - return false; - } - if(!_last_pathVectorSatellites.getPathVector()[index].size_closed() > subindex){ - return false; - } - return true; //_last_pathVectorSatellites.getPathVector().nodes().size() == _last_pathVectorSatellites.getTotalSatellites(); -} void SatellitesArrayParam::updateCanvasIndicators(bool mirror) { + if (!_last_pathvector_satellites) { + return; + } + if(!_hp.empty()) { _hp.clear(); } - Geom::PathVector pathv = _last_pathVectorSatellites.getPathVector(); + Geom::PathVector pathv = _last_pathvector_satellites->getPathVector(); if (pathv.empty()) { return; } @@ -98,9 +88,6 @@ void SatellitesArrayParam::updateCanvasIndicators(bool mirror) if (_effectType == FILLET_CHAMFER) { for (size_t i = 0; i < _vector.size(); ++i) { for (size_t j = 0; j < _vector[i].size(); ++j) { - if (!validData(i, j)) { - return; - } 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 @@ -219,41 +206,28 @@ void SatellitesArrayParam::param_transform_multiply(Geom::Affine const &postmul, } } -void SatellitesArrayParam::clearKnotHolder(KnotHolder *knotholder) -{ - for (std::list::iterator i = knotholder.entity.begin(); i != knotholder.entity.end(); ++i) - { - delete (*i); - (*i) = NULL; - } - entity.clear(); // is this necessary? -} - void SatellitesArrayParam::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, - SPItem *item, bool mirror) + SPItem *item, + bool mirror) { - Geom::PathVector pathv = _last_pathVectorSatellites.getPathVector(); + 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 (!validData(i, j)) { - return; - } if (!_vector[i][j].has_mirror && mirror) { continue; } SatelliteType type = _vector[i][j].satellite_type; - size_t index = i; - size_t subindex = j; - if (mirror) { - subindex = subindex + _vector[i].size(); + if (mirror && i == 0 && j == 0) { + index = index + _last_pathvector_satellites->getTotalSatellites(); } using namespace Geom; //If is for filletChamfer effect... if (_effectType == FILLET_CHAMFER) { - if(!pathv[i].closed() && (j == 0 || j == _vector[i].size() -1)) { - continue; - } +// if(!pathv[i].closed() && (j == 0 || j == _vector[i].size() -1)) { +// continue; +// } const gchar *tip; if (type == CHAMFER) { tip = _("Chamfer: Ctrl+Click toggle type, " @@ -272,10 +246,11 @@ void SatellitesArrayParam::addKnotHolderEntities(KnotHolder *knotholder, "Shift+Click open dialog, " "Ctrl+Alt+Click reset"); } - FilletChamferKnotHolderEntity *e = new FilletChamferKnotHolderEntity(this, index, subindex); + FilletChamferKnotHolderEntity *e = new FilletChamferKnotHolderEntity(this, index); e->create(desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, _(tip),_knot_shape, _knot_mode, _knot_color); knotholder->add(e); } + index++; } } if (mirror) { @@ -292,52 +267,62 @@ void SatellitesArrayParam::addKnotHolderEntities(KnotHolder *knotholder, } FilletChamferKnotHolderEntity::FilletChamferKnotHolderEntity( - SatellitesArrayParam *p, size_t index, size_t subindex) - : _pparam(p), _index(index), _subindex(subindex) {} + SatellitesArrayParam *p, size_t index) + : _pparam(p), _index(index) {} void FilletChamferKnotHolderEntity::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state) { - Geom::Point s = snap_knot_position(p, state); - size_t subindex = _subindex; - if (_subindex >= _pparam->_vector[_index].size()) { - subindex = _subindex - _pparam->_vector[_index].size(); + 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; } - if (!_pparam->validData(_index, subindex)) { + std::pair 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[_index][subindex]; - Geom::PathVector pathv = _pparam->_last_pathVectorSatellites.getPathVector(); + Satellite satellite = _pparam->_vector[path_index][curve_index]; + Geom::PathVector pathv = _pparam->_last_pathvector_satellites->getPathVector(); if (satellite.hidden || - !pathv[_index].closed() && subindex == 0 ||//ignore first satellites on open paths - pathv[_index].size() == subindex) //ignore last satellite in open paths with fillet chamfer effect + !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 (subindex != _subindex) { - size_t previous_index = subindex - 1; - if(subindex == 0 && pathv[_index].closed()){ - previous_index = pathv[_index].size() - 1; + if (is_mirror) { + size_t previous_index = curve_index - 1; + if(curve_index == 0 && pathv[path_index].closed()){ + previous_index = pathv[path_index].size() - 1; } - Geom::Curve const &curve_in = pathv[_index][previous_index]; + Geom::Curve const &curve_in = pathv[path_index][previous_index]; double mirror_time = Geom::nearest_time(s, curve_in); double time_start = 0; - Satellites satellites = _pparam->_last_pathVectorSatellites.getSatellites(); - time_start = satellites[_index][previous_index].time(curve_in); + 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[_index][subindex]); + amount = timeAtArcLength(amount, pathv[path_index][curve_index]); } satellite.amount = amount; } else { - satellite.setPosition(s, pathv[_index][subindex]); + satellite.setPosition(s, pathv[path_index][curve_index]); } - _pparam->_vector[_index][subindex] = satellite; + _pparam->_vector[path_index][curve_index] = satellite; SPLPEItem *splpeitem = dynamic_cast(item); if (splpeitem) { sp_lpe_item_update_patheffect(splpeitem, false, false); @@ -346,35 +331,40 @@ void FilletChamferKnotHolderEntity::knot_set(Geom::Point const &p, Geom::Point FilletChamferKnotHolderEntity::knot_get() const { + if (!_pparam->_last_pathvector_satellites) { + return Geom::Point(Geom::infinity(), Geom::infinity()); + } Geom::Point tmp_point; - size_t subindex = _subindex; - if (_subindex >= _pparam->_vector[_index].size()) { - subindex = _subindex - _pparam->_vector[_index].size(); + 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; } - if (!_pparam->validData(_index, subindex)) { - this->knot->hide(); + std::pair 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[_index][subindex]; - Geom::PathVector pathv = _pparam->_last_pathVectorSatellites.getPathVector(); + Satellite satellite = _pparam->_vector[path_index][curve_index]; + Geom::PathVector pathv = _pparam->_last_pathvector_satellites->getPathVector(); if (satellite.hidden || - !pathv[_index].closed() && subindex == 0 ||//ignore first satellites on open paths - pathv[_index].size() == subindex) //ignore last satellite in open paths with fillet chamfer effect + !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 { - this->knot->hide(); - _pparam->_vector[_index][subindex].hidden = true; return Geom::Point(Geom::infinity(), Geom::infinity()); } this->knot->show(); - std::cout << subindex << pathv[_index].size() << "----" << _pparam->_vector[_index].size() << "fgdgsdgsdgsdsdsgd\n"; - if (subindex != _subindex) { - tmp_point = satellite.getPosition(pathv[_index][subindex]); - size_t previous_index = subindex - 1; - if(subindex == 0 && pathv[_index].closed()){ - previous_index = pathv[_index].size() - 1; + if (is_mirror) { + tmp_point = satellite.getPosition(pathv[path_index][curve_index]); + size_t previous_index = curve_index - 1; + if(curve_index == 0 && pathv[path_index].closed()){ + previous_index = pathv[path_index].size() - 1; } - Geom::Curve const &curve_in = pathv[_index][previous_index]; - double s = satellite.arcDistance(pathv[_index][subindex]); + 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; @@ -383,13 +373,13 @@ Geom::Point FilletChamferKnotHolderEntity::knot_get() const t = 0; } double time_start = 0; - time_start = _pparam->_last_pathVectorSatellites.getSatellites()[_index][previous_index].time(curve_in); + 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[_index][subindex]); + tmp_point = satellite.getPosition(pathv[path_index][curve_index]); } Geom::Point const canvas_point = tmp_point; return canvas_point; @@ -397,27 +387,36 @@ Geom::Point FilletChamferKnotHolderEntity::knot_get() const void FilletChamferKnotHolderEntity::knot_click(guint state) { - size_t subindex = _subindex; - if (_subindex >= _pparam->_vector[_index].size()) { - subindex = _subindex - _pparam->_vector[_index].size(); + if (!_pparam->_last_pathvector_satellites) { + return; } - if (!_pparam->validData(_index, subindex)) { + 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 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_pathVectorSatellites.getPathVector(); - if (!pathv[_index].closed() && subindex == 0 ||//ignore first satellites on open paths - pathv[_index].size() == subindex) //ignore last satellite in open paths with fillet chamfer effect + 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[_index][subindex].amount = 0.0; + _pparam->_vector[path_index][curve_index].amount = 0.0; _pparam->param_set_and_write_new_value(_pparam->_vector); sp_lpe_item_update_patheffect(SP_LPE_ITEM(item), false, false); } else { using namespace Geom; - SatelliteType type = _pparam->_vector[_index][subindex].satellite_type; + SatelliteType type = _pparam->_vector[path_index][curve_index].satellite_type; switch (type) { case FILLET: type = INVERSE_FILLET; @@ -432,7 +431,7 @@ void FilletChamferKnotHolderEntity::knot_click(guint state) type = FILLET; break; } - _pparam->_vector[_index][subindex].satellite_type = type; + _pparam->_vector[path_index][curve_index].satellite_type = type; _pparam->param_set_and_write_new_value(_pparam->_vector); sp_lpe_item_update_patheffect(SP_LPE_ITEM(item), false, false); const gchar *tip; @@ -457,22 +456,22 @@ void FilletChamferKnotHolderEntity::knot_click(guint state) this->knot->show(); } } else if (state & GDK_SHIFT_MASK) { - double amount = _pparam->_vector[_index][subindex].amount; - size_t previous_index = subindex - 1; - if(subindex == 0 && pathv[_index].closed()){ - previous_index = pathv[_index].size() - 1; + double amount = _pparam->_vector[path_index][curve_index].amount; + size_t previous_index = curve_index - 1; + if(curve_index == 0 && pathv[path_index].closed()){ + previous_index = pathv[path_index].size() - 1; } - if (!_pparam->_use_distance && !_pparam->_vector[_index][subindex].is_time) { + if (!_pparam->_use_distance && !_pparam->_vector[path_index][curve_index].is_time) { if (previous_index) { - amount = _pparam->_vector[_index][subindex].lenToRad(amount, pathv[_index][previous_index], pathv[_index][subindex], _pparam->_vector[_index][previous_index]); + 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]); } else { amount = 0.0; } } bool aprox = false; - Geom::D2 d2_out = pathv[_index][subindex].toSBasis(); + Geom::D2 d2_out = pathv[path_index][curve_index].toSBasis(); if (previous_index) { - Geom::D2 d2_in = pathv[_index][previous_index].toSBasis(); + Geom::D2 d2_in = pathv[path_index][previous_index].toSBasis(); aprox = ((d2_in)[0].degreesOfFreedom() != 2 || d2_out[0].degreesOfFreedom() != 2) && !_pparam->_use_distance @@ -481,41 +480,50 @@ void FilletChamferKnotHolderEntity::knot_click(guint state) } Inkscape::UI::Dialogs::FilletChamferPropertiesDialog::showDialog( this->desktop, amount, this, _pparam->_use_distance, - aprox, _pparam->_vector[_index][subindex]); + aprox, _pparam->_vector[path_index][curve_index]); } } void FilletChamferKnotHolderEntity::knot_set_offset(Satellite satellite) { - size_t subindex = _subindex; - if (_subindex >= _pparam->_vector[_index].size()) { - subindex = _subindex - _pparam->_vector[_index].size(); + 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; } - if (!_pparam->validData(_index, subindex)) { + std::pair 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_pathVectorSatellites.getPathVector(); + Geom::PathVector pathv = _pparam->_last_pathvector_satellites->getPathVector(); if (satellite.hidden || - !pathv[_index].closed() && subindex == 0 ||//ignore first satellites on open paths - pathv[_index].size() == subindex) //ignore last satellite in open paths with fillet chamfer effect + !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) { - size_t previous_index = subindex - 1; - if(subindex == 0 && pathv[_index].closed()){ - previous_index = pathv[_index].size() - 1; + size_t previous_index = curve_index - 1; + if(curve_index == 0 && pathv[path_index].closed()){ + previous_index = pathv[path_index].size() - 1; } - amount = _pparam->_vector[_index][subindex].radToLen(amount, pathv[_index][previous_index], pathv[_index][subindex]); + 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[_index][subindex].amount; + amount = _pparam->_vector[path_index][curve_index].amount; } } satellite.amount = amount; - _pparam->_vector[_index][subindex] = satellite; + _pparam->_vector[path_index][curve_index] = satellite; this->parent_holder->knot_ungrabbed_handler(this->knot, 0); _pparam->param_set_and_write_new_value(_pparam->_vector); SPLPEItem *splpeitem = dynamic_cast(item); -- cgit v1.2.3 From 7e1183de6ed51ff730915fe936e2bb607dd72f33 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sun, 12 Jun 2016 16:33:27 +0200 Subject: Fix bug consecutive nodes at same position (bzr r13645.1.152) --- src/live_effects/parameter/satellitesarray.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/live_effects/parameter/satellitesarray.cpp') diff --git a/src/live_effects/parameter/satellitesarray.cpp b/src/live_effects/parameter/satellitesarray.cpp index e61aaf38d..db7cf80c0 100644 --- a/src/live_effects/parameter/satellitesarray.cpp +++ b/src/live_effects/parameter/satellitesarray.cpp @@ -33,6 +33,7 @@ SatellitesArrayParam::SatellitesArrayParam(const Glib::ustring &label, _knot_color = 0xAAFF8800; _helper_size = 0; _use_distance = false; + _global_knot_hide = false; _effectType = FILLET_CHAMFER; _last_pathvector_satellites = NULL; } @@ -57,6 +58,10 @@ void SatellitesArrayParam::setUseDistance(bool use_knot_distance) _use_distance = use_knot_distance; } +void SatellitesArrayParam::setGlobalKnotHide(bool global_knot_hide) +{ + _global_knot_hide = global_knot_hide; +} void SatellitesArrayParam::setEffectType(EffectType et) { _effectType = et; @@ -331,7 +336,7 @@ void FilletChamferKnotHolderEntity::knot_set(Geom::Point const &p, Geom::Point FilletChamferKnotHolderEntity::knot_get() const { - if (!_pparam->_last_pathvector_satellites) { + if (!_pparam->_last_pathvector_satellites || _pparam->_global_knot_hide) { return Geom::Point(Geom::infinity(), Geom::infinity()); } Geom::Point tmp_point; -- cgit v1.2.3 From e40990e3b9c391cdded31f28bb8f8d448fd1d361 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sun, 12 Jun 2016 17:27:07 +0200 Subject: Handle both directions on knot reposition (bzr r13645.1.154) --- src/live_effects/parameter/satellitesarray.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'src/live_effects/parameter/satellitesarray.cpp') diff --git a/src/live_effects/parameter/satellitesarray.cpp b/src/live_effects/parameter/satellitesarray.cpp index db7cf80c0..18e1bd4de 100644 --- a/src/live_effects/parameter/satellitesarray.cpp +++ b/src/live_effects/parameter/satellitesarray.cpp @@ -305,13 +305,18 @@ void FilletChamferKnotHolderEntity::knot_set(Geom::Point const &p, { return; } - if (is_mirror) { - size_t previous_index = curve_index - 1; - if(curve_index == 0 && pathv[path_index].closed()){ - previous_index = pathv[path_index].size() - 1; - } - Geom::Curve const &curve_in = pathv[path_index][previous_index]; - double mirror_time = Geom::nearest_time(s, curve_in); + size_t previous_index = curve_index - 1; + if(curve_index == 0 && pathv[path_index].closed()){ + previous_index = pathv[path_index].size() - 1; + } + 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 (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); -- cgit v1.2.3 From 73f078b27b669c941651ecf14a3119ae491ccabf Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 13 Jun 2016 00:58:55 +0200 Subject: Fix 90% of tweenk review (bzr r13645.1.155) --- src/live_effects/parameter/satellitesarray.cpp | 51 +++++++++++++++++--------- 1 file changed, 34 insertions(+), 17 deletions(-) (limited to 'src/live_effects/parameter/satellitesarray.cpp') diff --git a/src/live_effects/parameter/satellitesarray.cpp b/src/live_effects/parameter/satellitesarray.cpp index 18e1bd4de..2f5cea7b5 100644 --- a/src/live_effects/parameter/satellitesarray.cpp +++ b/src/live_effects/parameter/satellitesarray.cpp @@ -26,7 +26,7 @@ SatellitesArrayParam::SatellitesArrayParam(const Glib::ustring &label, const Glib::ustring &key, Inkscape::UI::Widget::Registry *wr, Effect *effect) - : ArrayParam >(label, tip, key, wr, effect, 0), knoth(NULL) + : ArrayParam >(label, tip, key, wr, effect, 0), _knoth(NULL) { _knot_shape = SP_KNOT_SHAPE_DIAMOND; _knot_mode = SP_KNOT_MODE_XOR; @@ -180,6 +180,9 @@ void SatellitesArrayParam::updateCanvasIndicators(bool mirror) } } } + if(!_knot_reset_helper.empty()){ + _hp.insert(_hp.end(), _knot_reset_helper.begin(), _knot_reset_helper.end() ); + } if (mirror) { updateCanvasIndicators(false); } @@ -230,24 +233,21 @@ void SatellitesArrayParam::addKnotHolderEntities(KnotHolder *knotholder, using namespace Geom; //If is for filletChamfer effect... if (_effectType == FILLET_CHAMFER) { -// if(!pathv[i].closed() && (j == 0 || j == _vector[i].size() -1)) { -// continue; -// } const gchar *tip; if (type == CHAMFER) { - tip = _("Chamfer: Ctrl+Click toggle type, " + tip = _("Chamfer: Ctrl+Click toggles type, " "Shift+Click open dialog, " "Ctrl+Alt+Click reset"); } else if (type == INVERSE_CHAMFER) { - tip = _("Inverse Chamfer: Ctrl+Click toggle type, " + tip = _("Inverse Chamfer: Ctrl+Click toggles type, " "Shift+Click open dialog, " "Ctrl+Alt+Click reset"); } else if (type == INVERSE_FILLET) { - tip = _("Inverse Fillet: Ctrl+Click toggle type, " + tip = _("Inverse Fillet: Ctrl+Click toggles type, " "Shift+Click open dialog, " "Ctrl+Alt+Click reset"); } else { - tip = _("Fillet: Ctrl+Click toggle type, " + tip = _("Fillet: Ctrl+Click toggles type, " "Shift+Click open dialog, " "Ctrl+Alt+Click reset"); } @@ -267,7 +267,7 @@ void SatellitesArrayParam::addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item) { - knoth = knotholder; + _knoth = knotholder; addKnotHolderEntities(knotholder, desktop, item, true); } @@ -316,6 +316,14 @@ void FilletChamferKnotHolderEntity::knot_set(Geom::Point const &p, 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); + //this avoid toggle when fillet are near node +// if (is_mirror && Geom::are_near(mirror, pathv[path_index][curve_index].initialPoint())) { +// distance_mirror = 0.0; +// distance_normal = 1.0; +// } else if (!is_mirror && Geom::are_near(normal, pathv[path_index][curve_index].initialPoint())){ +// distance_mirror = 1.0; +// distance_normal = 0.0; +// } if (distance_mirror <= distance_normal) { double time_start = 0; Satellites satellites = _pparam->_last_pathvector_satellites->getSatellites(); @@ -332,6 +340,15 @@ void FilletChamferKnotHolderEntity::knot_set(Geom::Point const &p, } 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(Geom::Point(normal)); + } _pparam->_vector[path_index][curve_index] = satellite; SPLPEItem *splpeitem = dynamic_cast(item); if (splpeitem) { @@ -446,21 +463,21 @@ void FilletChamferKnotHolderEntity::knot_click(guint state) sp_lpe_item_update_patheffect(SP_LPE_ITEM(item), false, false); const gchar *tip; if (type == CHAMFER) { - tip = _("Chamfer: Ctrl+Click toggle type, " + tip = _("Chamfer: Ctrl+Click toggles type, " "Shift+Click open dialog, " - "Ctrl+Alt+Click reset"); + "Ctrl+Alt+Click resets"); } else if (type == INVERSE_CHAMFER) { - tip = _("Inverse Chamfer: Ctrl+Click toggle type, " + tip = _("Inverse Chamfer: Ctrl+Click toggles type, " "Shift+Click open dialog, " - "Ctrl+Alt+Click reset"); + "Ctrl+Alt+Click resets"); } else if (type == INVERSE_FILLET) { - tip = _("Inverse Fillet: Ctrl+Click toggle type, " + tip = _("Inverse Fillet: Ctrl+Click toggles type, " "Shift+Click open dialog, " - "Ctrl+Alt+Click reset"); + "Ctrl+Alt+Click resets"); } else { - tip = _("Fillet: Ctrl+Click toggle type, " + tip = _("Fillet: Ctrl+Click toggles type, " "Shift+Click open dialog, " - "Ctrl+Alt+Click reset"); + "Ctrl+Alt+Click resets"); } this->knot->tip = g_strdup(tip); this->knot->show(); -- cgit v1.2.3 From 2c544b51a588c8874b5b5f9a5e1e33d591972b15 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Tue, 14 Jun 2016 23:44:32 +0200 Subject: Add snap to origin in double direction knots (bzr r13645.1.157) --- src/live_effects/parameter/satellitesarray.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/live_effects/parameter/satellitesarray.cpp') diff --git a/src/live_effects/parameter/satellitesarray.cpp b/src/live_effects/parameter/satellitesarray.cpp index 2f5cea7b5..c0141ddfa 100644 --- a/src/live_effects/parameter/satellitesarray.cpp +++ b/src/live_effects/parameter/satellitesarray.cpp @@ -34,6 +34,7 @@ SatellitesArrayParam::SatellitesArrayParam(const Glib::ustring &label, _helper_size = 0; _use_distance = false; _global_knot_hide = false; + _current_zoom = 0; _effectType = FILLET_CHAMFER; _last_pathvector_satellites = NULL; } @@ -58,6 +59,11 @@ 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; @@ -316,15 +322,9 @@ void FilletChamferKnotHolderEntity::knot_set(Geom::Point const &p, 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); - //this avoid toggle when fillet are near node -// if (is_mirror && Geom::are_near(mirror, pathv[path_index][curve_index].initialPoint())) { -// distance_mirror = 0.0; -// distance_normal = 1.0; -// } else if (!is_mirror && Geom::are_near(normal, pathv[path_index][curve_index].initialPoint())){ -// distance_mirror = 1.0; -// distance_normal = 0.0; -// } - if (distance_mirror <= distance_normal) { + 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); @@ -347,7 +347,7 @@ void FilletChamferKnotHolderEntity::knot_set(Geom::Point const &p, "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(Geom::Point(normal)); + _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; SPLPEItem *splpeitem = dynamic_cast(item); -- cgit v1.2.3 From c5f642fbd66ccb150d361d2861d0b1baa744dcba Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sat, 18 Jun 2016 15:07:51 +0200 Subject: Pre fixing selected points (bzr r13645.1.161) --- src/live_effects/parameter/satellitesarray.cpp | 45 +++++++++++++++----------- 1 file changed, 27 insertions(+), 18 deletions(-) (limited to 'src/live_effects/parameter/satellitesarray.cpp') diff --git a/src/live_effects/parameter/satellitesarray.cpp b/src/live_effects/parameter/satellitesarray.cpp index c0141ddfa..71c69c6c5 100644 --- a/src/live_effects/parameter/satellitesarray.cpp +++ b/src/live_effects/parameter/satellitesarray.cpp @@ -112,10 +112,13 @@ void SatellitesArrayParam::updateCanvasIndicators(bool mirror) bool overflow = false; double size_out = _vector[i][j].arcDistance(*curve_in); double lenght_out = curve_in->length(); - size_t previous_index = j - 1; //Always are previous index because we skip first satellite on open paths + 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(&pathv.curveAt(previous_index)); @@ -311,10 +314,13 @@ void FilletChamferKnotHolderEntity::knot_set(Geom::Point const &p, { return; } - size_t previous_index = curve_index - 1; + 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); @@ -386,10 +392,13 @@ Geom::Point FilletChamferKnotHolderEntity::knot_get() const this->knot->show(); if (is_mirror) { tmp_point = satellite.getPosition(pathv[path_index][curve_index]); - size_t previous_index = curve_index - 1; + 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); @@ -484,27 +493,24 @@ void FilletChamferKnotHolderEntity::knot_click(guint state) } } else if (state & GDK_SHIFT_MASK) { double amount = _pparam->_vector[path_index][curve_index].amount; - size_t previous_index = curve_index - 1; + 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) { - if (previous_index) { - 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]); - } else { - amount = 0.0; - } + 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 d2_out = pathv[path_index][curve_index].toSBasis(); - if (previous_index) { - Geom::D2 d2_in = pathv[path_index][previous_index].toSBasis(); - aprox = ((d2_in)[0].degreesOfFreedom() != 2 || - d2_out[0].degreesOfFreedom() != 2) && - !_pparam->_use_distance - ? true - : false; - } + Geom::D2 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]); @@ -540,10 +546,13 @@ void FilletChamferKnotHolderEntity::knot_set_offset(Satellite satellite) double amount = satellite.amount; double max_amount = amount; if (!_pparam->_use_distance && !satellite.is_time) { - size_t previous_index = curve_index - 1; + 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; -- cgit v1.2.3 From 38a1a4d45114a681408e763c3afec79f0bc21940 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sat, 18 Jun 2016 18:53:51 +0200 Subject: fixing bug moving nodes (bzr r13645.1.162) --- src/live_effects/parameter/satellitesarray.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'src/live_effects/parameter/satellitesarray.cpp') diff --git a/src/live_effects/parameter/satellitesarray.cpp b/src/live_effects/parameter/satellitesarray.cpp index 71c69c6c5..8c86f64ca 100644 --- a/src/live_effects/parameter/satellitesarray.cpp +++ b/src/live_effects/parameter/satellitesarray.cpp @@ -356,10 +356,7 @@ void FilletChamferKnotHolderEntity::knot_set(Geom::Point const &p, _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; - SPLPEItem *splpeitem = dynamic_cast(item); - if (splpeitem) { - sp_lpe_item_update_patheffect(splpeitem, false, false); - } + sp_lpe_item_update_patheffect(SP_LPE_ITEM(item), false, false); } Geom::Point FilletChamferKnotHolderEntity::knot_get() const @@ -391,7 +388,6 @@ Geom::Point FilletChamferKnotHolderEntity::knot_get() const } this->knot->show(); if (is_mirror) { - tmp_point = satellite.getPosition(pathv[path_index][curve_index]); gint previous_index = curve_index - 1; if(curve_index == 0 && pathv[path_index].closed()){ previous_index = pathv[path_index].size() - 1; @@ -418,6 +414,7 @@ Geom::Point FilletChamferKnotHolderEntity::knot_get() const tmp_point = satellite.getPosition(pathv[path_index][curve_index]); } Geom::Point const canvas_point = tmp_point; + _pparam->updateCanvasIndicators(); return canvas_point; } -- cgit v1.2.3 From 6820ee49d69cd419c5e8d3c9de74b0552758c842 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sun, 19 Jun 2016 00:58:42 +0200 Subject: Fixes when moves a path (bzr r13645.1.163) --- src/live_effects/parameter/satellitesarray.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/live_effects/parameter/satellitesarray.cpp') diff --git a/src/live_effects/parameter/satellitesarray.cpp b/src/live_effects/parameter/satellitesarray.cpp index 8c86f64ca..d4182d459 100644 --- a/src/live_effects/parameter/satellitesarray.cpp +++ b/src/live_effects/parameter/satellitesarray.cpp @@ -81,7 +81,6 @@ void SatellitesArrayParam::setHelperSize(int hs) void SatellitesArrayParam::updateCanvasIndicators(bool mirror) { - if (!_last_pathvector_satellites) { return; } -- cgit v1.2.3 From 417ba16c9f42a5476045ca4f1825fff2fed518ba Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sun, 19 Jun 2016 03:30:10 +0200 Subject: Organize doeffect function (bzr r13645.1.164) --- src/live_effects/parameter/satellitesarray.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src/live_effects/parameter/satellitesarray.cpp') diff --git a/src/live_effects/parameter/satellitesarray.cpp b/src/live_effects/parameter/satellitesarray.cpp index d4182d459..4705fd821 100644 --- a/src/live_effects/parameter/satellitesarray.cpp +++ b/src/live_effects/parameter/satellitesarray.cpp @@ -85,7 +85,7 @@ void SatellitesArrayParam::updateCanvasIndicators(bool mirror) return; } - if(!_hp.empty()) { + if (!_hp.empty()) { _hp.clear(); } Geom::PathVector pathv = _last_pathvector_satellites->getPathVector(); @@ -112,10 +112,10 @@ void SatellitesArrayParam::updateCanvasIndicators(bool mirror) 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()){ + if (j == 0 && pathv[i].closed()) { previous_index = pathv[i].size() - 1; } - if( previous_index < 0 ) { + if ( previous_index < 0 ) { return; } double lenght_in = pathv.curveAt(previous_index).length(); @@ -188,7 +188,7 @@ void SatellitesArrayParam::updateCanvasIndicators(bool mirror) } } } - if(!_knot_reset_helper.empty()){ + if (!_knot_reset_helper.empty()) { _hp.insert(_hp.end(), _knot_reset_helper.begin(), _knot_reset_helper.end() ); } if (mirror) { @@ -314,10 +314,10 @@ void FilletChamferKnotHolderEntity::knot_set(Geom::Point const &p, return; } gint previous_index = curve_index - 1; - if(curve_index == 0 && pathv[path_index].closed()){ + if (curve_index == 0 && pathv[path_index].closed()) { previous_index = pathv[path_index].size() - 1; } - if( previous_index < 0 ) { + if ( previous_index < 0 ) { return; } Geom::Curve const &curve_in = pathv[path_index][previous_index]; @@ -346,7 +346,7 @@ void FilletChamferKnotHolderEntity::knot_set(Geom::Point const &p, satellite.setPosition(s, pathv[path_index][curve_index]); } _pparam->_knot_reset_helper.clear(); - if (satellite.amount == 0){ + 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 " @@ -388,10 +388,10 @@ Geom::Point FilletChamferKnotHolderEntity::knot_get() const this->knot->show(); if (is_mirror) { gint previous_index = curve_index - 1; - if(curve_index == 0 && pathv[path_index].closed()){ + if (curve_index == 0 && pathv[path_index].closed()) { previous_index = pathv[path_index].size() - 1; } - if( previous_index < 0 ) { + if ( previous_index < 0 ) { return Geom::Point(Geom::infinity(), Geom::infinity()); } Geom::Curve const &curve_in = pathv[path_index][previous_index]; @@ -490,10 +490,10 @@ void FilletChamferKnotHolderEntity::knot_click(guint state) } 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()){ + if (curve_index == 0 && pathv[path_index].closed()) { previous_index = pathv[path_index].size() - 1; } - if( previous_index < 0 ) { + if ( previous_index < 0 ) { return; } if (!_pparam->_use_distance && !_pparam->_vector[path_index][curve_index].is_time) { @@ -543,10 +543,10 @@ void FilletChamferKnotHolderEntity::knot_set_offset(Satellite satellite) 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()){ + if (curve_index == 0 && pathv[path_index].closed()) { previous_index = pathv[path_index].size() - 1; } - if( previous_index < 0 ) { + if ( previous_index < 0 ) { return; } amount = _pparam->_vector[path_index][curve_index].radToLen(amount, pathv[path_index][previous_index], pathv[path_index][curve_index]); -- cgit v1.2.3 From d431044fc72f9b668dcfa5771f361f4d6088bdd7 Mon Sep 17 00:00:00 2001 From: Jabiertxof Date: Sun, 22 Jan 2017 18:53:31 +0100 Subject: Update to new code in trunk (bzr r13645.1.166) --- src/live_effects/parameter/satellitesarray.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src/live_effects/parameter/satellitesarray.cpp') diff --git a/src/live_effects/parameter/satellitesarray.cpp b/src/live_effects/parameter/satellitesarray.cpp index 4705fd821..7efe5dd98 100644 --- a/src/live_effects/parameter/satellitesarray.cpp +++ b/src/live_effects/parameter/satellitesarray.cpp @@ -223,7 +223,6 @@ void SatellitesArrayParam::param_transform_multiply(Geom::Affine const &postmul, } void SatellitesArrayParam::addKnotHolderEntities(KnotHolder *knotholder, - SPDesktop *desktop, SPItem *item, bool mirror) { @@ -260,23 +259,22 @@ void SatellitesArrayParam::addKnotHolderEntities(KnotHolder *knotholder, "Ctrl+Alt+Click reset"); } FilletChamferKnotHolderEntity *e = new FilletChamferKnotHolderEntity(this, index); - e->create(desktop, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, _(tip),_knot_shape, _knot_mode, _knot_color); + e->create(NULL, item, knotholder, Inkscape::CTRL_TYPE_UNKNOWN, _(tip),_knot_shape, _knot_mode, _knot_color); knotholder->add(e); } index++; } } if (mirror) { - addKnotHolderEntities(knotholder, desktop, item, false); + addKnotHolderEntities(knotholder, item, false); } } void SatellitesArrayParam::addKnotHolderEntities(KnotHolder *knotholder, - SPDesktop *desktop, SPItem *item) { _knoth = knotholder; - addKnotHolderEntities(knotholder, desktop, item, true); + addKnotHolderEntities(knotholder, item, true); } FilletChamferKnotHolderEntity::FilletChamferKnotHolderEntity( -- cgit v1.2.3 From 98c50c48230463cb059434ad781ccef2ce998cb7 Mon Sep 17 00:00:00 2001 From: Jabiertxof Date: Thu, 16 Mar 2017 20:58:19 +0100 Subject: Remove some warnings (bzr r13645.1.171) --- src/live_effects/parameter/satellitesarray.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/live_effects/parameter/satellitesarray.cpp') diff --git a/src/live_effects/parameter/satellitesarray.cpp b/src/live_effects/parameter/satellitesarray.cpp index 7efe5dd98..8cf517852 100644 --- a/src/live_effects/parameter/satellitesarray.cpp +++ b/src/live_effects/parameter/satellitesarray.cpp @@ -102,7 +102,7 @@ void SatellitesArrayParam::updateCanvasIndicators(bool mirror) (!_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 + (!pathv[i].closed() && j == 0)) //ignore first satellites on open paths { continue; } @@ -306,7 +306,7 @@ void FilletChamferKnotHolderEntity::knot_set(Geom::Point const &p, 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].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; -- cgit v1.2.3 From 5997087db8a3bc2ec3b3bb0623f3f66cb81a4521 Mon Sep 17 00:00:00 2001 From: Jabiertxof Date: Thu, 16 Mar 2017 21:03:59 +0100 Subject: Remove some warnings (bzr r13645.1.172) --- src/live_effects/parameter/satellitesarray.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/live_effects/parameter/satellitesarray.cpp') diff --git a/src/live_effects/parameter/satellitesarray.cpp b/src/live_effects/parameter/satellitesarray.cpp index 8cf517852..c7bc7f026 100644 --- a/src/live_effects/parameter/satellitesarray.cpp +++ b/src/live_effects/parameter/satellitesarray.cpp @@ -378,7 +378,7 @@ Geom::Point FilletChamferKnotHolderEntity::knot_get() const 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].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()); @@ -434,7 +434,7 @@ void FilletChamferKnotHolderEntity::knot_click(guint state) return; } Geom::PathVector pathv = _pparam->_last_pathvector_satellites->getPathVector(); - if (!pathv[path_index].closed() && curve_index == 0 ||//ignore first satellites on open paths + 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; @@ -532,7 +532,7 @@ void FilletChamferKnotHolderEntity::knot_set_offset(Satellite satellite) } 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].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; -- cgit v1.2.3 From 5004996c798cdbad5ff7abbaf2e7272411631cee Mon Sep 17 00:00:00 2001 From: Jabiertxof Date: Sat, 6 May 2017 19:45:16 +0200 Subject: Pre merge fixing (bzr r13645.1.177) --- src/live_effects/parameter/satellitesarray.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/live_effects/parameter/satellitesarray.cpp') diff --git a/src/live_effects/parameter/satellitesarray.cpp b/src/live_effects/parameter/satellitesarray.cpp index c7bc7f026..7626317a1 100644 --- a/src/live_effects/parameter/satellitesarray.cpp +++ b/src/live_effects/parameter/satellitesarray.cpp @@ -39,6 +39,7 @@ SatellitesArrayParam::SatellitesArrayParam(const Glib::ustring &label, _last_pathvector_satellites = NULL; } + void SatellitesArrayParam::set_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, guint32 color) @@ -48,10 +49,14 @@ void SatellitesArrayParam::set_oncanvas_looks(SPKnotShapeType shape, _knot_color = color; } -void SatellitesArrayParam::setPathVectorSatellites(PathVectorSatellites *pathVectorSatellites) +void SatellitesArrayParam::setPathVectorSatellites(PathVectorSatellites *pathVectorSatellites, bool write) { _last_pathvector_satellites = pathVectorSatellites; - param_set_and_write_new_value(_last_pathvector_satellites->getSatellites()); + 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) @@ -226,6 +231,9 @@ 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) { @@ -442,7 +450,6 @@ void FilletChamferKnotHolderEntity::knot_click(guint state) if (state & GDK_CONTROL_MASK) { if (state & GDK_MOD1_MASK) { _pparam->_vector[path_index][curve_index].amount = 0.0; - _pparam->param_set_and_write_new_value(_pparam->_vector); sp_lpe_item_update_patheffect(SP_LPE_ITEM(item), false, false); } else { using namespace Geom; @@ -462,7 +469,6 @@ void FilletChamferKnotHolderEntity::knot_click(guint state) break; } _pparam->_vector[path_index][curve_index].satellite_type = 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 == CHAMFER) { @@ -555,7 +561,6 @@ void FilletChamferKnotHolderEntity::knot_set_offset(Satellite satellite) satellite.amount = amount; _pparam->_vector[path_index][curve_index] = satellite; this->parent_holder->knot_ungrabbed_handler(this->knot, 0); - _pparam->param_set_and_write_new_value(_pparam->_vector); SPLPEItem *splpeitem = dynamic_cast(item); if (splpeitem) { sp_lpe_item_update_patheffect(splpeitem, false, false); -- cgit v1.2.3 From d77efb0c2c4b6925e87055f2921d35677d1625d5 Mon Sep 17 00:00:00 2001 From: Jabiertxof Date: Sat, 27 May 2017 14:00:01 +0200 Subject: More fixes to LPE (bzr r15705) --- src/live_effects/parameter/satellitesarray.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/live_effects/parameter/satellitesarray.cpp') diff --git a/src/live_effects/parameter/satellitesarray.cpp b/src/live_effects/parameter/satellitesarray.cpp index 7626317a1..ce4da243e 100644 --- a/src/live_effects/parameter/satellitesarray.cpp +++ b/src/live_effects/parameter/satellitesarray.cpp @@ -37,6 +37,7 @@ SatellitesArrayParam::SatellitesArrayParam(const Glib::ustring &label, _current_zoom = 0; _effectType = FILLET_CHAMFER; _last_pathvector_satellites = NULL; + param_widget_is_visible(false); } -- cgit v1.2.3