diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2016-06-18 13:07:51 +0000 |
|---|---|---|
| committer | jabiertxof <info@marker.es> | 2016-06-18 13:07:51 +0000 |
| commit | c5f642fbd66ccb150d361d2861d0b1baa744dcba (patch) | |
| tree | c88c9325ef919b473c888fdcda2e5fcbaa85e624 /src | |
| parent | update to trunk (diff) | |
| download | inkscape-c5f642fbd66ccb150d361d2861d0b1baa744dcba.tar.gz inkscape-c5f642fbd66ccb150d361d2861d0b1baa744dcba.zip | |
Pre fixing selected points
(bzr r13645.1.161)
Diffstat (limited to 'src')
| -rw-r--r-- | src/helper/geom-pathvectorsatellites.cpp | 7 | ||||
| -rw-r--r-- | src/live_effects/effect.cpp | 13 | ||||
| -rw-r--r-- | src/live_effects/effect.h | 4 | ||||
| -rw-r--r-- | src/live_effects/lpe-fillet-chamfer.cpp | 53 | ||||
| -rw-r--r-- | src/live_effects/lpe-fillet-chamfer.h | 3 | ||||
| -rw-r--r-- | src/live_effects/parameter/satellitesarray.cpp | 45 | ||||
| -rw-r--r-- | src/ui/dialog/lpe-fillet-chamfer-properties.cpp | 7 | ||||
| -rw-r--r-- | src/ui/tools/node-tool.cpp | 6 |
8 files changed, 80 insertions, 58 deletions
diff --git a/src/helper/geom-pathvectorsatellites.cpp b/src/helper/geom-pathvectorsatellites.cpp index c56887f53..e80d812d7 100644 --- a/src/helper/geom-pathvectorsatellites.cpp +++ b/src/helper/geom-pathvectorsatellites.cpp @@ -63,11 +63,16 @@ std::pair<size_t, size_t> PathVectorSatellites::getIndexData(size_t index) void PathVectorSatellites::setSelected(std::vector<size_t> selected) { size_t counter = 0; + for (size_t h = 0; h < selected.size(); ++h) { + std::cout << selected[h] << "vec\n"; + } for (size_t i = 0; i < _satellites.size(); ++i) { for (size_t j = 0; j < _satellites[i].size(); ++j) { if(find (selected.begin(), selected.end(), counter) != selected.end()){ + std::cout << counter << "true\n"; _satellites[i][j].setSelected(true); } else { + std::cout << "false\n"; _satellites[i][j].setSelected(false); } counter++; @@ -171,6 +176,7 @@ void PathVectorSatellites::updateSatelliteType(SatelliteType satellitetype, bool void PathVectorSatellites::recalculateForNewPathVector(Geom::PathVector const pathv, Satellite const S) { + return; Satellites satellites; bool found = false; //TODO evaluate fix on nodes at same position @@ -194,7 +200,6 @@ void PathVectorSatellites::recalculateForNewPathVector(Geom::PathVector const pa (Geom::are_near(_pathvector[k][l].initialPoint(), pathv[i][j].initialPoint()))) { pathsatellites.push_back(_satellites[k][l]); - std::cout << "dgsgdsgsdgsdgsdgsdgsdgsdgsdgsdgsd\n"; found = true; break; } diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index f60d628f6..515aa26fc 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -406,9 +406,9 @@ Effect::setCurrentZoom(double cZ) } void -Effect::setSelectedNodePoints(std::vector<Geom::Point> selected_node_points) +Effect::setSelectedNodePoints(std::vector<size_t> selected_nodes_pos) { - selectedNodesPoints = selected_node_points; + _selected_nodes_pos = selected_nodes_pos; } std::vector<size_t> @@ -418,7 +418,8 @@ Effect::getSelectedNodes() std::vector<size_t> 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].size_closed() == j-1 && + if ((!pathvector_before_effect[i].closed() && + pathvector_before_effect[i].size_closed() == j-1 && isNodePointSelected( pathvector_before_effect[i][j].finalPoint())) || isNodePointSelected( pathvector_before_effect[i][j].initialPoint())) { @@ -434,11 +435,11 @@ Effect::getSelectedNodes() bool Effect::isNodePointSelected(Geom::Point const &node_point) const { - if (selectedNodesPoints.size() > 0) { + if (_selected_nodes_pos.size() > 0) { using Geom::X; using Geom::Y; - for (std::vector<Geom::Point>::const_iterator i = selectedNodesPoints.begin(); - i != selectedNodesPoints.end(); ++i) { + 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(node_point[X],node_point[Y]); diff --git a/src/live_effects/effect.h b/src/live_effects/effect.h index 1f08a2bae..3b02b14d4 100644 --- a/src/live_effects/effect.h +++ b/src/live_effects/effect.h @@ -59,7 +59,7 @@ public: void doOnApply_impl(SPLPEItem const* lpeitem); void doBeforeEffect_impl(SPLPEItem const* lpeitem); void setCurrentZoom(double cZ); - void setSelectedNodePoints(std::vector<Geom::Point> selected_node_points); + void setSelectedNodePoints(std::vector<Geom::Point> selected_nodes_pos); std::vector<size_t> getSelectedNodes(); bool isNodePointSelected(Geom::Point const &node_point) const; virtual void doOnApply (SPLPEItem const* lpeitem); @@ -163,7 +163,7 @@ protected: SPLPEItem * sp_lpe_item; // these get stored in doBeforeEffect_impl, and derived classes may do as they please with them. double current_zoom; - std::vector<Geom::Point> selectedNodesPoints; + std::vector<Geom::Point> _selected_nodes_pos; SPCurve * sp_curve; Geom::PathVector pathvector_before_effect; private: diff --git a/src/live_effects/lpe-fillet-chamfer.cpp b/src/live_effects/lpe-fillet-chamfer.cpp index f2ed8d4d8..7a663614b 100644 --- a/src/live_effects/lpe-fillet-chamfer.cpp +++ b/src/live_effects/lpe-fillet-chamfer.cpp @@ -260,8 +260,9 @@ void LPEFilletChamfer::doBeforeEffect(SPLPEItem const *lpeItem) //TODO: Update the satellite data in paths modified, Goal 0.93 if (_pathvector_satellites) { size_t number_nodes = pathv.nodes().size(); - size_t satellites_counter = _pathvector_satellites->getTotalSatellites(); - if (number_nodes != satellites_counter) { + size_t previous_number_nodes = _pathvector_satellites->getPathVector().nodes().size(); + if (number_nodes != previous_number_nodes) { + std::cout << "sfsfaasfasfasfasffasdf\n"; Satellite satellite(FILLET); satellite.setIsTime(_flexible); satellite.setHasMirror(_mirror_knots); @@ -329,7 +330,7 @@ LPEFilletChamfer::addCanvasIndicators(SPLPEItem const */*lpeitem*/, std::vector< } void -LPEFilletChamfer::addChamferSteps(Geom::Path &tmp_path, Geom::Path path_chamfer, Geom::Point end_arc_point) +LPEFilletChamfer::addChamferSteps(Geom::Path &tmp_path, Geom::Path path_chamfer, Geom::Point end_arc_point, size_t steps) { double path_subdivision = 1.0 / steps; for (size_t i = 1; i < steps; i++) { @@ -462,14 +463,6 @@ LPEFilletChamfer::doEffect_path(Geom::PathVector const &path_in) if (times[1] == times[0]) { start_arc_point = curve_it1->pointAt(times[0]); } - Geom::Line const x_line(Geom::Point(0, 0), Geom::Point(1, 0)); - Geom::Line const angled_line(start_arc_point, end_arc_point); - double arc_angle = Geom::angle_between(x_line, angled_line); - double _radius = Geom::distance(start_arc_point, - middle_point(start_arc_point, end_arc_point)) / - sin(angle / 2.0); - Geom::Coord rx = _radius; - Geom::Coord ry = rx; if (times[1] != 1) { if (times[1] != times[0] || (times[1] == 1 && times[0] == 1)) { if (!knot_curve_1->isDegenerate()) { @@ -478,14 +471,20 @@ LPEFilletChamfer::doEffect_path(Geom::PathVector const &path_in) } SatelliteType type = satellite.satellite_type; size_t steps = satellite.steps; - if (steps < 1) { - steps = 1; - } + if (!steps) steps = 1; + Geom::Line const x_line(Geom::Point(0, 0), Geom::Point(1, 0)); + Geom::Line const angled_line(start_arc_point, end_arc_point); + double arc_angle = Geom::angle_between(x_line, angled_line); + double radius = Geom::distance(start_arc_point, middle_point(start_arc_point, end_arc_point)) / + sin(angle / 2.0); + 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; switch (type) { - case CHAMFER: + case CHAMFER: + { Geom::Path path_chamfer; path_chamfer.start(tmp_path.finalPoint()); if (eliptical) { @@ -494,9 +493,11 @@ LPEFilletChamfer::doEffect_path(Geom::PathVector const &path_in) } else { path_chamfer.appendNew<Geom::CubicBezier>(handle_1, handle_2, end_arc_point); } - addChamferSteps(tmp_path, path_chamfer, end_arc_point); - break; - case INVERSE_CHAMFER: + addChamferSteps(tmp_path, path_chamfer, end_arc_point, steps); + } + break; + case INVERSE_CHAMFER: + { Geom::Path path_chamfer; path_chamfer.start(tmp_path.finalPoint()); if (eliptical) { @@ -504,22 +505,28 @@ LPEFilletChamfer::doEffect_path(Geom::PathVector const &path_in) } else { path_chamfer.appendNew<Geom::CubicBezier>(inverse_handle_1, inverse_handle_2, end_arc_point); } - addChamferSteps(tmp_path, path_chamfer, end_arc_point); - break; - case INVERSE_FILLET: + addChamferSteps(tmp_path, path_chamfer, end_arc_point, steps); + } + break; + case INVERSE_FILLET: + { if (eliptical) { tmp_path.appendNew<Geom::EllipticalArc>(rx, ry, arc_angle, 0, ccw_toggle, end_arc_point); } else { tmp_path.appendNew<Geom::CubicBezier>(inverse_handle_1, inverse_handle_2, end_arc_point); } - break; - default: //fillet + } + break; + default: //fillet + { if (eliptical) { ccw_toggle = ccw_toggle ? 0 : 1; tmp_path.appendNew<Geom::EllipticalArc>(rx, ry, arc_angle, 0, ccw_toggle, end_arc_point); } else { tmp_path.appendNew<Geom::CubicBezier>(handle_1, handle_2, end_arc_point); } + } + break; } } else { if (!knot_curve_1->isDegenerate()) { diff --git a/src/live_effects/lpe-fillet-chamfer.h b/src/live_effects/lpe-fillet-chamfer.h index 35e9028f3..134886950 100644 --- a/src/live_effects/lpe-fillet-chamfer.h +++ b/src/live_effects/lpe-fillet-chamfer.h @@ -35,7 +35,7 @@ public: virtual void doOnApply(SPLPEItem const *lpeItem); virtual Gtk::Widget *newWidget(); Geom::Ray getRay(Geom::Point start, Geom::Point end, Geom::Curve *curve, bool reverse); - void addChamferSteps(Geom::Path &tmp_path, Geom::Path path_chamfer, Geom::Point end_arc_point); + 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 updateChamferSteps(); @@ -56,7 +56,6 @@ private: 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 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<Geom::Curve *>(&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<Geom::SBasis> d2_out = pathv[path_index][curve_index].toSBasis(); - if (previous_index) { - Geom::D2<Geom::SBasis> d2_in = pathv[path_index][previous_index].toSBasis(); - aprox = ((d2_in)[0].degreesOfFreedom() != 2 || - d2_out[0].degreesOfFreedom() != 2) && - !_pparam->_use_distance - ? true - : false; - } + Geom::D2<Geom::SBasis> d2_in = pathv[path_index][previous_index].toSBasis(); + aprox = ((d2_in)[0].degreesOfFreedom() != 2 || + d2_out[0].degreesOfFreedom() != 2) && + !_pparam->_use_distance + ? true + : false; Inkscape::UI::Dialogs::FilletChamferPropertiesDialog::showDialog( this->desktop, amount, this, _pparam->_use_distance, aprox, _pparam->_vector[path_index][curve_index]); @@ -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; diff --git a/src/ui/dialog/lpe-fillet-chamfer-properties.cpp b/src/ui/dialog/lpe-fillet-chamfer-properties.cpp index c86fc4a20..098a84edf 100644 --- a/src/ui/dialog/lpe-fillet-chamfer-properties.cpp +++ b/src/ui/dialog/lpe-fillet-chamfer-properties.cpp @@ -117,7 +117,8 @@ FilletChamferPropertiesDialog::~FilletChamferPropertiesDialog() } void FilletChamferPropertiesDialog::showDialog( - SPDesktop *desktop, double _amount, + SPDesktop *desktop, + double _amount, const Inkscape::LivePathEffect:: FilletChamferKnotHolderEntity *pt, bool _use_distance, @@ -243,9 +244,9 @@ void FilletChamferPropertiesDialog::_setPt( } -void FilletChamferPropertiesDialog::_setAmount(double amm) +void FilletChamferPropertiesDialog::_setAmount(double amount) { - _amount = amm; + _amount = amount; } diff --git a/src/ui/tools/node-tool.cpp b/src/ui/tools/node-tool.cpp index 60d4c807f..d02b8e6d3 100644 --- a/src/ui/tools/node-tool.cpp +++ b/src/ui/tools/node-tool.cpp @@ -293,14 +293,14 @@ void NodeTool::update_helperpath () { Inkscape::LivePathEffect::Effect *lpe = SP_LPE_ITEM(selection->singleItem())->getCurrentLPE(); if (lpe && lpe->isVisible()/* && lpe->showOrigPath()*/) { Inkscape::UI::ControlPointSelection::Set &selection_nodes = _selected_nodes->allPoints(); - std::vector<Geom::Point> selected_nodes_positions; + std::vector<Geom::Point> selected_nodes_pos; for (Inkscape::UI::ControlPointSelection::Set::iterator i = selection_nodes.begin(); i != selection_nodes.end(); ++i) { if ((*i)->selected()) { Inkscape::UI::Node *n = dynamic_cast<Inkscape::UI::Node *>(*i); - selected_nodes_positions.push_back(n->position()); + selected_nodes_pos.push_back(n->position()); } } - lpe->setSelectedNodePoints(selected_nodes_positions); + lpe->setSelectedNodePoints(selected_nodes_pos); lpe->setCurrentZoom(this->desktop->current_zoom()); SPCurve *c = new SPCurve(); SPCurve *cc = new SPCurve(); |
