diff options
| author | Jabiertxof <jtx@jtx> | 2017-01-22 17:53:31 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx> | 2017-01-22 17:53:31 +0000 |
| commit | d431044fc72f9b668dcfa5771f361f4d6088bdd7 (patch) | |
| tree | 69862e58b8ed2adc86ab9220ed4a28b617a65c65 /src | |
| parent | Update to trunk (diff) | |
| download | inkscape-d431044fc72f9b668dcfa5771f361f4d6088bdd7.tar.gz inkscape-d431044fc72f9b668dcfa5771f361f4d6088bdd7.zip | |
Update to new code in trunk
(bzr r13645.1.166)
Diffstat (limited to 'src')
| -rw-r--r-- | src/helper/geom-pathvectorsatellites.cpp | 23 | ||||
| -rw-r--r-- | src/helper/geom-pathvectorsatellites.h | 1 | ||||
| -rw-r--r-- | src/live_effects/effect.cpp | 94 | ||||
| -rw-r--r-- | src/live_effects/effect.h | 15 | ||||
| -rw-r--r-- | src/live_effects/lpe-fillet-chamfer.cpp | 188 | ||||
| -rw-r--r-- | src/live_effects/lpe-fillet-chamfer.h | 29 | ||||
| -rw-r--r-- | src/live_effects/parameter/satellitesarray.cpp | 8 | ||||
| -rw-r--r-- | src/live_effects/parameter/satellitesarray.h | 9 | ||||
| -rw-r--r-- | src/ui/tools/node-tool.cpp | 4 |
9 files changed, 214 insertions, 157 deletions
diff --git a/src/helper/geom-pathvectorsatellites.cpp b/src/helper/geom-pathvectorsatellites.cpp index eca866978..79055af8d 100644 --- a/src/helper/geom-pathvectorsatellites.cpp +++ b/src/helper/geom-pathvectorsatellites.cpp @@ -15,6 +15,8 @@ */ #include <helper/geom-pathvectorsatellites.h> +#include "util/units.h" + Geom::PathVector PathVectorSatellites::getPathVector() const { return _pathvector; @@ -141,6 +143,27 @@ void PathVectorSatellites::updateAmount(double radius, bool apply_no_radius, boo } } +void PathVectorSatellites::convertUnit(Glib::ustring in, Glib::ustring to, bool apply_no_radius, bool apply_with_radius) +{ + for (size_t i = 0; i < _satellites.size(); ++i) { + for (size_t j = 0; j < _satellites[i].size(); ++j) { + if (!_pathvector[i].closed() && j == 0) { + _satellites[i][j].amount = 0; + continue; + } + if (_pathvector[i].size() == j) { + continue; + } + if ((!apply_no_radius && _satellites[i][j].amount == 0) || + (!apply_with_radius && _satellites[i][j].amount != 0)) + { + continue; + } + _satellites[i][j].amount = Inkscape::Util::Quantity::convert(_satellites[i][j].amount, in.c_str(), to.c_str()); + } + } +} + void PathVectorSatellites::updateSatelliteType(SatelliteType satellitetype, bool apply_no_radius, bool apply_with_radius, bool only_selected) { diff --git a/src/helper/geom-pathvectorsatellites.h b/src/helper/geom-pathvectorsatellites.h index 4a020f553..d86e6cb25 100644 --- a/src/helper/geom-pathvectorsatellites.h +++ b/src/helper/geom-pathvectorsatellites.h @@ -34,6 +34,7 @@ public: void updateSteps(size_t steps, bool apply_no_radius, bool apply_with_radius, bool only_selected); void updateAmount(double radius, bool apply_no_radius, bool apply_with_radius, bool only_selected, bool use_knot_distance, bool flexible); + void convertUnit(Glib::ustring in, Glib::ustring to, bool apply_no_radius, bool apply_with_radius); void updateSatelliteType(SatelliteType satellitetype, bool apply_no_radius, bool apply_with_radius, bool only_selected); std::pair<size_t, size_t> getIndexData(size_t index); void recalculateForNewPathVector(Geom::PathVector const pathv, Satellite const S); diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index 6899a3161..19e80c611 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -119,7 +119,7 @@ const Util::EnumData<EffectType> LPETypeData[] = { /* 0.92 */ {SIMPLIFY, N_("Simplify"), "simplify"}, {LATTICE2, N_("Lattice Deformation 2"), "lattice2"}, - {PERSPECTIVE_ENVELOPE, N_("Perspective/Envelope"), "perspective-envelope"}, + {PERSPECTIVE_ENVELOPE, N_("Perspective/Envelope"), "perspective_envelope"}, {INTERPOLATE_POINTS, N_("Interpolate points"), "interpolate_points"}, {TRANSFORM_2PTS, N_("Transform by 2 points"), "transform_2pts"}, {SHOW_HANDLES, N_("Show handles"), "show_handles"}, @@ -129,7 +129,6 @@ const Util::EnumData<EffectType> LPETypeData[] = { {TAPER_STROKE, N_("Taper stroke"), "taper_stroke"}, {MIRROR_SYMMETRY, N_("Mirror symmetry"), "mirror_symmetry"}, {COPY_ROTATE, N_("Rotate copies"), "copy_rotate"}, - {FILLET_CHAMFER, N_("Fillet/Chamfer"), "fillet-chamfer"}, /* Ponyscape -> Inkscape 0.92*/ {ATTACH_PATH, N_("Attach path"), "attach_path"}, {FILL_BETWEEN_STROKES, N_("Fill between strokes"), "fill_between_strokes"}, @@ -137,7 +136,8 @@ const Util::EnumData<EffectType> LPETypeData[] = { {ELLIPSE_5PTS, N_("Ellipse by 5 points"), "ellipse_5pts"}, {BOUNDING_BOX, N_("Bounding Box"), "bounding_box"}, /* 9.93 */ - {MEASURE_LINE, N_("Measure Line"), "measure-line"}, + {MEASURE_LINE, N_("Measure Line"), "measure_line"}, + {FILLET_CHAMFER, N_("Fillet/Chamfer"), "fillet_chamfer"}, }; const Util::EnumDataConverter<EffectType> LPETypeConverter(LPETypeData, sizeof(LPETypeData)/sizeof(*LPETypeData)); @@ -358,11 +358,11 @@ Effect::Effect(LivePathEffectObject *lpeobject) upd_params(true), sp_curve(NULL), provides_own_flash_paths(true), // is automatically set to false if providesOwnFlashPaths() is not overridden - is_ready(false), // is automatically set to false if providesOwnFlashPaths() is not overridden - _current_zoom(1.0) + is_ready(false) // is automatically set to false if providesOwnFlashPaths() is not overridden { registerParameter( dynamic_cast<Parameter *>(&is_visible) ); is_visible.widget_is_visible = false; + current_zoom = 0.0; } Effect::~Effect() @@ -392,55 +392,67 @@ Effect::doOnApply (SPLPEItem const*/*lpeitem*/) } void -Effect::setCurrentZoom(double zoom) +Effect::setSelectedNodePos(std::vector<Geom::Point> selected_nodes_pos_data) { - _current_zoom = zoom; -} - -double -Effect::getCurrentZoom() -{ - return _current_zoom; + selected_nodes_pos = selected_nodes_pos_data; } void -Effect::setSelectedNodes(std::vector<Geom::Point> selected_nodes_pos) +Effect::setSelectedNodeIndex(Geom::PathVector pv) { - _selected_nodes_pos = selected_nodes_pos; -} + selected_nodes_index.clear(); + for (Geom::PathVector::const_iterator path_it = pv.begin(); + path_it != pv.end(); ++path_it) { -std::vector<size_t> -Effect::getSelectedNodes() -{ - size_t counter = 0; - std::vector<size_t> result; - if (pathvector_before_effect.empty()){ - return result; - } - for (size_t i = 0; i < pathvector_before_effect.size(); i++) { - for (size_t j = 0; j < pathvector_before_effect[i].size_closed(); j++) { - if ((!pathvector_before_effect[i].closed() && - pathvector_before_effect[i].size_closed() == j+1 && - isNodeSelected( pathvector_before_effect[i][j].finalPoint())) || - isNodeSelected( pathvector_before_effect[i][j].initialPoint())) - { - result.push_back(counter); + if (path_it->empty()) { + continue; + } + Geom::Path::const_iterator curve_it1 = path_it->begin(); + Geom::Path::const_iterator curve_endit = path_it->end_default(); + if (path_it->closed()) { + const Geom::Curve &closingline = path_it->back_closed(); + // the closing line segment is always of type + // Geom::LineSegment. + if (are_near(closingline.initialPoint(), closingline.finalPoint())) { + // closingline.isDegenerate() did not work, because it only checks for + // *exact* zero length, which goes wrong for relative coordinates and + // rounding errors... + // the closing line segment has zero-length. So stop before that one! + curve_endit = path_it->end_open(); + } + } + size_t i = 0; + while (curve_it1 != curve_endit) { + if (isNodeSelected(curve_it1->initialPoint())) { + selected_nodes_index.push_back(i); } - counter++; + ++i; + ++curve_it1; + } + if (isNodeSelected(path_it->finalPoint())) { + selected_nodes_index.push_back(i); } } - return result; } +void +Effect::setCurrentZoom(double cZ) +{ + current_zoom = cZ; +} bool -Effect::isNodeSelected(Geom::Point const &node_point) const -{ - if (!_selected_nodes_pos.empty()) { - for (std::vector<Geom::Point>::const_iterator i = _selected_nodes_pos.begin(); - i != _selected_nodes_pos.end(); ++i) { - Geom::Point p = (*i); - Geom::Point p2(node_point[Geom::X],node_point[Geom::Y]); +Effect::isNodeSelected(Geom::Point const &nodePoint) const +{ + if (selected_nodes_pos.size() > 0) { + using Geom::X; + using Geom::Y; + for (std::vector<Geom::Point>::const_iterator i = selected_nodes_pos.begin(); + i != selected_nodes_pos.end(); ++i) { + Geom::Point p = *i; + Geom::Affine transformCoordinate = sp_lpe_item->i2dt_affine(); + Geom::Point p2(nodePoint[X],nodePoint[Y]); + p2 *= transformCoordinate; if (Geom::are_near(p, p2, 0.01)) { return true; } diff --git a/src/live_effects/effect.h b/src/live_effects/effect.h index 61de60db8..0190325c0 100644 --- a/src/live_effects/effect.h +++ b/src/live_effects/effect.h @@ -58,11 +58,10 @@ public: //of indirection is needed. We first call these methods, then the below. void doOnApply_impl(SPLPEItem const* lpeitem); void doBeforeEffect_impl(SPLPEItem const* lpeitem); - void setCurrentZoom(double zoom); - double getCurrentZoom(); - void setSelectedNodes(std::vector<Geom::Point> selected_nodes_pos); - std::vector<size_t> getSelectedNodes(); - bool isNodeSelected(Geom::Point const &node_point) const; + void setCurrentZoom(double cZ); + void setSelectedNodePos(std::vector<Geom::Point> selected_nodes_pos_data); + void setSelectedNodeIndex(Geom::PathVector pv); + bool isNodeSelected(Geom::Point const &nodePoint) const; virtual void doOnApply (SPLPEItem const* lpeitem); virtual void doBeforeEffect (SPLPEItem const* lpeitem); @@ -166,14 +165,16 @@ protected: bool concatenate_before_pwd2; SPLPEItem * sp_lpe_item; // these get stored in doBeforeEffect_impl, and derived classes may do as they please with them. - std::vector<Geom::Point> _selected_nodes_pos; + double current_zoom; + std::vector<Geom::Point> selected_nodes_pos; + std::vector<size_t> selected_nodes_index; SPCurve * sp_curve; Geom::PathVector pathvector_before_effect; private: bool provides_own_flash_paths; // if true, the standard flash path is suppressed bool is_ready; - double _current_zoom; + Effect(const Effect&); Effect& operator=(const Effect&); }; diff --git a/src/live_effects/lpe-fillet-chamfer.cpp b/src/live_effects/lpe-fillet-chamfer.cpp index 2bbd3dbab..410d6f0fc 100644 --- a/src/live_effects/lpe-fillet-chamfer.cpp +++ b/src/live_effects/lpe-fillet-chamfer.cpp @@ -23,65 +23,68 @@ namespace Inkscape { namespace LivePathEffect { -static const Util::EnumData<Fillet_method> Fillet_methodData[] = { +static const Util::EnumData<Filletmethod> FilletmethodData[] = { { FM_AUTO, N_("Auto"), "auto" }, { FM_ARC, N_("Force arc"), "arc" }, { FM_BEZIER, N_("Force bezier"), "bezier" } }; -static const Util::EnumDataConverter<Fillet_method> FMConverter(Fillet_methodData, FM_END); +static const Util::EnumDataConverter<Filletmethod> FMConverter(FilletmethodData, FM_END); LPEFilletChamfer::LPEFilletChamfer(LivePathEffectObject *lpeobject) : Effect(lpeobject), - _satellites_param("satellites_param", "satellites_param", - "_satellites_param", &wr, this), - _method(_("_method:"), _("_methods to calculate the fillet or chamfer"), - "_method", FMConverter, &wr, this, FM_AUTO), - _radius(_("_radius (unit or %):"), _("_radius, in unit or %"), "_radius", &wr, + unit(_("Unit"), _("Unit"), "unit", &wr, this, "px"), + satellites_param("Satellites_param", "Satellites_param", + "satellites_param", &wr, this), + method(_("Method:"), _("Methods to calculate the fillet or chamfer"), + "method", FMConverter, &wr, this, FM_AUTO), + radius(_("Radius (unit or %):"), _("Radius, in unit or %"), "radius", &wr, this, 0.0), - _chamfer_steps(_("Chamfer steps:"), _("Chamfer steps"), "_chamfer_steps", + chamfer_steps(_("Chamfer steps:"), _("Chamfer steps"), "chamfer_steps", &wr, this, 1), - _flexible(_("_flexible _radius size (%)"), _("_flexible _radius size (%)"), - "_flexible", &wr, this, false), - _mirror_knots(_("Mirror Knots"), _("Mirror Knots"), "_mirror_knots", &wr, + flexible(_("Flexible radius size (%)"), _("Flexible radius size (%)"), + "flexible", &wr, this, false), + mirror_knots(_("Mirror Knots"), _("Mirror Knots"), "mirror_knots", &wr, this, true), - _only_selected(_("Change only selected nodes"), - _("Change only selected nodes"), "_only_selected", &wr, this, + only_selected(_("Change only selected nodes"), + _("Change only selected nodes"), "only_selected", &wr, this, false), - _use_knot_distance(_("Use knots distance instead _radius"), - _("Use knots distance instead _radius"), - "_use_knot_distance", &wr, this, false), - _hide_knots(_("Hide knots"), _("Hide knots"), "_hide_knots", &wr, this, + use_knot_distance(_("Use knots distance instead radius"), + _("Use knots distance instead radius"), + "use_knot_distance", &wr, this, false), + hide_knots(_("Hide knots"), _("Hide knots"), "hide_knots", &wr, this, false), - _apply_no_radius(_("Apply changes if _radius = 0"), _("Apply changes if _radius = 0"), "_apply_no_radius", &wr, this, true), - _apply_with_radius(_("Apply changes if _radius > 0"), _("Apply changes if _radius > 0"), "_apply_with_radius", &wr, this, true), - _helper_size(_("Helper path size with direction to node:"), - _("Helper path size with direction to node"), "_helper_size", &wr, this, 0), + apply_no_radius(_("Apply changes if radius = 0"), _("Apply changes if radius = 0"), "apply_no_radius", &wr, this, true), + apply_with_radius(_("Apply changes if radius > 0"), _("Apply changes if radius > 0"), "apply_with_radius", &wr, this, true), + helper_size(_("Helper path size with direction to node:"), + _("Helper path size with direction to node"), "helper_size", &wr, this, 0), _pathvector_satellites(NULL), _degenerate_hide(false) { - registerParameter(&_satellites_param); - registerParameter(&_method); - registerParameter(&_radius); - registerParameter(&_chamfer_steps); - registerParameter(&_helper_size); - registerParameter(&_flexible); - registerParameter(&_use_knot_distance); - registerParameter(&_mirror_knots); - registerParameter(&_apply_no_radius); - registerParameter(&_apply_with_radius); - registerParameter(&_only_selected); - registerParameter(&_hide_knots); + registerParameter(&satellites_param); + registerParameter(&unit); + registerParameter(&method); + registerParameter(&radius); + registerParameter(&chamfer_steps); + registerParameter(&helper_size); + registerParameter(&flexible); + registerParameter(&use_knot_distance); + registerParameter(&mirror_knots); + registerParameter(&apply_no_radius); + registerParameter(&apply_with_radius); + registerParameter(&only_selected); + registerParameter(&hide_knots); - _radius.param_set_range(0.0, Geom::infinity()); - _radius.param_set_increments(1, 1); - _radius.param_set_digits(4); - _radius.param_overwrite_widget(true); - _chamfer_steps.param_set_range(1, 999); - _chamfer_steps.param_set_increments(1, 1); - _chamfer_steps.param_set_digits(0); - _helper_size.param_set_range(0, 999); - _helper_size.param_set_increments(5, 5); - _helper_size.param_set_digits(0); + radius.param_set_range(0.0, Geom::infinity()); + radius.param_set_increments(1, 1); + radius.param_set_digits(4); + radius.param_overwrite_widget(true); + chamfer_steps.param_set_range(1, 999); + chamfer_steps.param_set_increments(1, 1); + chamfer_steps.param_set_digits(0); + helper_size.param_set_range(0, 999); + helper_size.param_set_increments(5, 5); + helper_size.param_set_digits(0); + _provides_knotholder_entities = true; } void LPEFilletChamfer::doOnApply(SPLPEItem const *lpeItem) @@ -102,16 +105,16 @@ void LPEFilletChamfer::doOnApply(SPLPEItem const *lpeItem) // continue //} Satellite satellite(FILLET); - satellite.setSteps(_chamfer_steps); + satellite.setSteps(chamfer_steps); subpath_satellites.push_back(satellite); } //we add the last satellite on open path because _pathvector_satellites is related to nodes, not curves //so maybe in the future we can need this last satellite in other effects - //dont remove for this effect because _pathvector_satellites class has _methods when the path is modiffied - //and we want one _method for all uses + //dont remove for this effect because _pathvector_satellites class has methods when the path is modiffied + //and we want one method for all uses if (!path_it->closed()) { Satellite satellite(FILLET); - satellite.setSteps(_chamfer_steps); + satellite.setSteps(chamfer_steps); subpath_satellites.push_back(satellite); } satellites.push_back(subpath_satellites); @@ -119,7 +122,7 @@ void LPEFilletChamfer::doOnApply(SPLPEItem const *lpeItem) _pathvector_satellites = new PathVectorSatellites(); _pathvector_satellites->setPathVector(pathv); _pathvector_satellites->setSatellites(satellites); - _satellites_param.setPathVectorSatellites(_pathvector_satellites); + satellites_param.setPathVectorSatellites(_pathvector_satellites); } else { g_warning("LPE Fillet/Chamfer can only be applied to shapes (not groups)."); SPLPEItem *item = const_cast<SPLPEItem *>(lpeItem); @@ -141,7 +144,7 @@ Gtk::Widget *LPEFilletChamfer::newWidget() if ((*it)->widget_is_visible) { Parameter *param = *it; Gtk::Widget *widg = param->param_newWidget(); - if (param->param_key == "_radius") { + if (param->param_key == "radius") { Inkscape::UI::Widget::Scalar *widg_registered = Gtk::manage(dynamic_cast<Inkscape::UI::Widget::Scalar *>(widg)); widg_registered->signal_value_changed().connect( @@ -153,7 +156,14 @@ Gtk::Widget *LPEFilletChamfer::newWidget() Gtk::Entry *entry_widget = dynamic_cast<Gtk::Entry *>(childList[1]); entry_widget->set_width_chars(6); } - } else if (param->param_key == "_chamfer_steps") { +// } else if (param->param_key == "unit") { +// Inkscape::UI::Widget::RegisteredUnitMenu* widg_registered = +// Gtk::manage(dynamic_cast< Inkscape::UI::Widget::RegisteredUnitMenu *>(widg)); +// widg_registered->setUnit(unit.get_abbreviation()); +// widg_registered->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change unit parameter")); +// widg_registered->getUnitMenu()->signal_changed().connect(sigc::mem_fun(*this, &LPEFilletChamfer::convertUnit)); +// widg = widg_registered; + } else if (param->param_key == "chamfer_steps") { Inkscape::UI::Widget::Scalar *widg_registered = Gtk::manage(dynamic_cast<Inkscape::UI::Widget::Scalar *>(widg)); widg_registered->signal_value_changed().connect( @@ -165,12 +175,12 @@ Gtk::Widget *LPEFilletChamfer::newWidget() Gtk::Entry *entry_widget = dynamic_cast<Gtk::Entry *>(childList[1]); entry_widget->set_width_chars(3); } - } else if (param->param_key == "_helper_size") { + } else if (param->param_key == "helper_size") { Inkscape::UI::Widget::Scalar *widg_registered = Gtk::manage(dynamic_cast<Inkscape::UI::Widget::Scalar *>(widg)); widg_registered->signal_value_changed().connect( sigc::mem_fun(*this, &LPEFilletChamfer::refreshKnots)); - } else if (param->param_key == "_only_selected") { + } else if (param->param_key == "only_selected") { Gtk::manage(widg); } Glib::ustring *tip = param->param_getTooltip(); @@ -217,28 +227,37 @@ Gtk::Widget *LPEFilletChamfer::newWidget() void LPEFilletChamfer::refreshKnots() { - if (_satellites_param._knoth) { - _satellites_param._knoth->update_knots(); + if (satellites_param._knoth) { + satellites_param._knoth->update_knots(); } } void LPEFilletChamfer::updateAmount() { - _pathvector_satellites->updateAmount(_radius, _apply_no_radius, _apply_with_radius, _only_selected, - _use_knot_distance, _flexible); - _satellites_param.setPathVectorSatellites(_pathvector_satellites); + _pathvector_satellites->updateAmount(radius, apply_no_radius, apply_with_radius, only_selected, + use_knot_distance, flexible); + satellites_param.setPathVectorSatellites(_pathvector_satellites); } +//void LPEFilletChamfer::convertUnit() +//{ +// SPDocument * document = SP_ACTIVE_DOCUMENT; +// SPNamedView *nv = sp_document_namedview(document, NULL); +// Glib::ustring display_unit = nv->display_units->abbr; +// _pathvector_satellites->convertUnit(unit.get_abbreviation(), display_unit, apply_no_radius, apply_with_radius); +// satellites_param.setPathVectorSatellites(_pathvector_satellites); +//} + void LPEFilletChamfer::updateChamferSteps() { - _pathvector_satellites->updateSteps(_chamfer_steps, _apply_no_radius, _apply_with_radius, _only_selected); - _satellites_param.setPathVectorSatellites(_pathvector_satellites); + _pathvector_satellites->updateSteps(chamfer_steps, apply_no_radius, apply_with_radius, only_selected); + satellites_param.setPathVectorSatellites(_pathvector_satellites); } void LPEFilletChamfer::updateSatelliteType(SatelliteType satellitetype) { - _pathvector_satellites->updateSatelliteType(satellitetype, _apply_no_radius, _apply_with_radius, _only_selected); - _satellites_param.setPathVectorSatellites(_pathvector_satellites); + _pathvector_satellites->updateSatelliteType(satellitetype, apply_no_radius, apply_with_radius, only_selected); + satellites_param.setPathVectorSatellites(_pathvector_satellites); } void LPEFilletChamfer::doBeforeEffect(SPLPEItem const *lpeItem) @@ -252,44 +271,44 @@ void LPEFilletChamfer::doBeforeEffect(SPLPEItem const *lpeItem) c = path->get_original_curve(); } //fillet chamfer specific calls - _satellites_param.setUseDistance(_use_knot_distance); - _satellites_param.setCurrentZoom(getCurrentZoom()); + satellites_param.setUseDistance(use_knot_distance); + satellites_param.setCurrentZoom(current_zoom); //mandatory call - _satellites_param.setEffectType(effectType()); + satellites_param.setEffectType(effectType()); Geom::PathVector const pathv = pathv_to_linear_and_cubic_beziers(c->get_pathvector()); //if are diferent sizes call to poinwise recalculate //TODO: Update the satellite data in paths modified, Goal 0.93 - Satellites satellites = _satellites_param.data(); + Satellites satellites = satellites_param.data(); if (satellites.empty()) { doOnApply(lpeItem); - satellites = _satellites_param.data(); + satellites = satellites_param.data(); } if (_pathvector_satellites) { size_t number_nodes = pathv.nodes().size(); size_t previous_number_nodes = _pathvector_satellites->getTotalSatellites(); if (number_nodes != previous_number_nodes) { Satellite satellite(FILLET); - satellite.setIsTime(_flexible); - satellite.setHasMirror(_mirror_knots); - satellite.setHidden(_hide_knots); + satellite.setIsTime(flexible); + satellite.setHasMirror(mirror_knots); + satellite.setHidden(hide_knots); _pathvector_satellites->recalculateForNewPathVector(pathv, satellite); satellites = _pathvector_satellites->getSatellites(); } } if (_degenerate_hide) { - _satellites_param.setGlobalKnotHide(true); + satellites_param.setGlobalKnotHide(true); } else { - _satellites_param.setGlobalKnotHide(false); + satellites_param.setGlobalKnotHide(false); } - if (_hide_knots) { - _satellites_param.setHelperSize(0); + if (hide_knots) { + satellites_param.setHelperSize(0); } else { - _satellites_param.setHelperSize(_helper_size); + satellites_param.setHelperSize(helper_size); } for (size_t i = 0; i < satellites.size(); ++i) { for (size_t j = 0; j < satellites[i].size(); ++j) { - if (satellites[i][j].is_time != _flexible) { - satellites[i][j].is_time = _flexible; + if (satellites[i][j].is_time != flexible) { + satellites[i][j].is_time = flexible; double amount = satellites[i][j].amount; if (pathv[i].size() == j) { continue; @@ -303,10 +322,10 @@ void LPEFilletChamfer::doBeforeEffect(SPLPEItem const *lpeItem) satellites[i][j].amount = size; } } - if (satellites[i][j].has_mirror != _mirror_knots) { - satellites[i][j].has_mirror = _mirror_knots; + if (satellites[i][j].has_mirror != mirror_knots) { + satellites[i][j].has_mirror = mirror_knots; } - satellites[i][j].hidden = _hide_knots; + satellites[i][j].hidden = hide_knots; } } if (!_pathvector_satellites) { @@ -314,8 +333,11 @@ void LPEFilletChamfer::doBeforeEffect(SPLPEItem const *lpeItem) } _pathvector_satellites->setPathVector(pathv); _pathvector_satellites->setSatellites(satellites); - _pathvector_satellites->setSelected(getSelectedNodes()); - _satellites_param.setPathVectorSatellites(_pathvector_satellites); + if (only_selected) { + setSelectedNodeIndex(pathv); + _pathvector_satellites->setSelected(selected_nodes_index); + } + satellites_param.setPathVectorSatellites(_pathvector_satellites); refreshKnots(); } else { g_warning("LPE Fillet can only be applied to shapes (not groups)."); @@ -470,8 +492,8 @@ LPEFilletChamfer::doEffect_path(Geom::PathVector const &path_in) Geom::Coord rx = radius; Geom::Coord ry = rx; bool eliptical = (is_straight_curve(*curve_it1) && - is_straight_curve(curve_it2) && _method != FM_BEZIER) || - _method == FM_ARC; + is_straight_curve(curve_it2) && method != FM_BEZIER) || + method == FM_ARC; switch (type) { case CHAMFER: { diff --git a/src/live_effects/lpe-fillet-chamfer.h b/src/live_effects/lpe-fillet-chamfer.h index d3f437afd..2cee04a1e 100644 --- a/src/live_effects/lpe-fillet-chamfer.h +++ b/src/live_effects/lpe-fillet-chamfer.h @@ -15,13 +15,14 @@ #include "live_effects/parameter/enum.h" #include "live_effects/parameter/satellitesarray.h" #include "live_effects/effect.h" +#include "live_effects/parameter/unit.h" #include "helper/geom-pathvectorsatellites.h" #include "helper/geom-satellite.h" namespace Inkscape { namespace LivePathEffect { -enum Fillet_method { +enum Filletmethod { FM_AUTO, FM_ARC, FM_BEZIER, @@ -39,24 +40,26 @@ public: void addChamferSteps(Geom::Path &tmp_path, Geom::Path path_chamfer, Geom::Point end_arc_point, size_t steps); void addCanvasIndicators(SPLPEItem const */*lpeitem*/, std::vector<Geom::PathVector> &hp_vec); void updateSatelliteType(SatelliteType satellitetype); + //void convertUnit(); void updateChamferSteps(); void updateAmount(); void refreshKnots(); - SatellitesArrayParam _satellites_param; + SatellitesArrayParam satellites_param; private: - EnumParam<Fillet_method> _method; - ScalarParam _radius; - ScalarParam _chamfer_steps; - BoolParam _flexible; - BoolParam _mirror_knots; - BoolParam _only_selected; - BoolParam _use_knot_distance; - BoolParam _hide_knots; - BoolParam _apply_no_radius; - BoolParam _apply_with_radius; - ScalarParam _helper_size; + UnitParam unit; + EnumParam<Filletmethod> method; + ScalarParam radius; + ScalarParam chamfer_steps; + BoolParam flexible; + BoolParam mirror_knots; + BoolParam only_selected; + BoolParam use_knot_distance; + BoolParam hide_knots; + BoolParam apply_no_radius; + BoolParam apply_with_radius; + ScalarParam helper_size; bool _degenerate_hide; PathVectorSatellites *_pathvector_satellites; Geom::PathVector _hp; 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, "<b>Ctrl+Alt+Click</b> 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( diff --git a/src/live_effects/parameter/satellitesarray.h b/src/live_effects/parameter/satellitesarray.h index 5b2d8a799..edaf2f08d 100644 --- a/src/live_effects/parameter/satellitesarray.h +++ b/src/live_effects/parameter/satellitesarray.h @@ -41,12 +41,9 @@ public: return NULL; } virtual void setHelperSize(int hs); - virtual void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, - SPItem *item); - virtual void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, - SPItem *item, bool mirror); - virtual void addCanvasIndicators(SPLPEItem const *lpeitem, - std::vector<Geom::PathVector> &hp_vec); + virtual void addKnotHolderEntities(KnotHolder *knotholder, SPItem *item); + virtual void addKnotHolderEntities(KnotHolder *knotholder, SPItem *item, bool mirror); + virtual void addCanvasIndicators(SPLPEItem const *lpeitem, std::vector<Geom::PathVector> &hp_vec); virtual void updateCanvasIndicators(); virtual void updateCanvasIndicators(bool mirror); virtual bool providesKnotHolderEntities() const diff --git a/src/ui/tools/node-tool.cpp b/src/ui/tools/node-tool.cpp index 94e684bc4..8561e234f 100644 --- a/src/ui/tools/node-tool.cpp +++ b/src/ui/tools/node-tool.cpp @@ -297,9 +297,9 @@ void sp_update_helperpath() { Inkscape::UI::Node *n = dynamic_cast<Inkscape::UI::Node *>(*i); selectedNodesPositions.push_back(n->position()); } - lpe->setSelectedNodePoints(selectedNodesPositions); + lpe->setSelectedNodePos(selectedNodesPositions); lpe->setCurrentZoom(desktop->current_zoom()); - + SPCurve *c = new SPCurve(); SPCurve *cc = new SPCurve(); std::vector<Geom::PathVector> cs = lpe->getCanvasIndicators(SP_LPE_ITEM(selection->singleItem())); |
