summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2016-06-18 16:53:51 +0000
committerjabiertxof <info@marker.es>2016-06-18 16:53:51 +0000
commit38a1a4d45114a681408e763c3afec79f0bc21940 (patch)
tree8d51eece5c253fbfadee4ad1b353ca5d23b02d12 /src
parentPre fixing selected points (diff)
downloadinkscape-38a1a4d45114a681408e763c3afec79f0bc21940.tar.gz
inkscape-38a1a4d45114a681408e763c3afec79f0bc21940.zip
fixing bug moving nodes
(bzr r13645.1.162)
Diffstat (limited to 'src')
-rw-r--r--src/helper/geom-pathvectorsatellites.cpp1
-rw-r--r--src/live_effects/effect.cpp27
-rw-r--r--src/live_effects/effect.h10
-rw-r--r--src/live_effects/lpe-bspline.cpp8
-rw-r--r--src/live_effects/lpe-fillet-chamfer.cpp14
-rw-r--r--src/live_effects/parameter/satellitesarray.cpp7
-rw-r--r--src/ui/tools/node-tool.cpp2
7 files changed, 35 insertions, 34 deletions
diff --git a/src/helper/geom-pathvectorsatellites.cpp b/src/helper/geom-pathvectorsatellites.cpp
index e80d812d7..1f71a2e91 100644
--- a/src/helper/geom-pathvectorsatellites.cpp
+++ b/src/helper/geom-pathvectorsatellites.cpp
@@ -176,7 +176,6 @@ 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
diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp
index 515aa26fc..7b36e30f9 100644
--- a/src/live_effects/effect.cpp
+++ b/src/live_effects/effect.cpp
@@ -363,14 +363,13 @@ Effect::Effect(LivePathEffectObject *lpeobject)
lpeobj(lpeobject),
concatenate_before_pwd2(false),
sp_lpe_item(NULL),
- current_zoom(1),
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
+ is_ready(false), // is automatically set to false if providesOwnFlashPaths() is not overridden
+ _current_zoom(1.0)
{
registerParameter( dynamic_cast<Parameter *>(&is_visible) );
is_visible.widget_is_visible = false;
- current_zoom = 0.0;
}
Effect::~Effect()
@@ -400,13 +399,19 @@ Effect::doOnApply (SPLPEItem const*/*lpeitem*/)
}
void
-Effect::setCurrentZoom(double cZ)
+Effect::setCurrentZoom(double zoom)
{
- current_zoom = cZ;
+ _current_zoom = zoom;
+}
+
+double
+Effect::getCurrentZoom()
+{
+ return _current_zoom;
}
void
-Effect::setSelectedNodePoints(std::vector<size_t> selected_nodes_pos)
+Effect::setSelectedNodes(std::vector<Geom::Point> selected_nodes_pos)
{
_selected_nodes_pos = selected_nodes_pos;
}
@@ -419,9 +424,9 @@ Effect::getSelectedNodes()
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 &&
- isNodePointSelected( pathvector_before_effect[i][j].finalPoint())) ||
- isNodePointSelected( pathvector_before_effect[i][j].initialPoint()))
+ 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);
}
@@ -433,15 +438,15 @@ Effect::getSelectedNodes()
bool
-Effect::isNodePointSelected(Geom::Point const &node_point) const
+Effect::isNodeSelected(Geom::Point const &node_point) const
{
if (_selected_nodes_pos.size() > 0) {
using Geom::X;
using Geom::Y;
+ Geom::Affine transformCoordinate = sp_lpe_item->i2dt_affine();
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]);
p2 *= transformCoordinate;
if (Geom::are_near(p, p2, 0.01)) {
diff --git a/src/live_effects/effect.h b/src/live_effects/effect.h
index 3b02b14d4..ac83d9b75 100644
--- a/src/live_effects/effect.h
+++ b/src/live_effects/effect.h
@@ -58,10 +58,11 @@ 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 cZ);
- void setSelectedNodePoints(std::vector<Geom::Point> selected_nodes_pos);
+ void setCurrentZoom(double zoom);
+ double getCurrentZoom();
+ void setSelectedNodes(std::vector<Geom::Point> selected_nodes_pos);
std::vector<size_t> getSelectedNodes();
- bool isNodePointSelected(Geom::Point const &node_point) const;
+ bool isNodeSelected(Geom::Point const &node_point) const;
virtual void doOnApply (SPLPEItem const* lpeitem);
virtual void doBeforeEffect (SPLPEItem const* lpeitem);
@@ -162,7 +163,6 @@ 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.
- double current_zoom;
std::vector<Geom::Point> _selected_nodes_pos;
SPCurve * sp_curve;
Geom::PathVector pathvector_before_effect;
@@ -170,7 +170,7 @@ 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-bspline.cpp b/src/live_effects/lpe-bspline.cpp
index 1423e670a..3fed11d5a 100644
--- a/src/live_effects/lpe-bspline.cpp
+++ b/src/live_effects/lpe-bspline.cpp
@@ -398,7 +398,7 @@ void LPEBSpline::doBSplineFromWidget(SPCurve *curve, double weight_ammount)
(apply_no_weight && Geom::are_near((*cubic)[1], point_at0)) ||
(apply_with_weight && !Geom::are_near((*cubic)[1], point_at0)))
{
- if (isNodePointSelected(point_at0) || !only_selected) {
+ if (isNodeSelected(point_at0) || !only_selected) {
point_at1 = sbasis_in.valueAt(weight_ammount);
if (weight_ammount != NO_POWER) {
point_at1 =
@@ -414,7 +414,7 @@ void LPEBSpline::doBSplineFromWidget(SPCurve *curve, double weight_ammount)
(apply_no_weight && Geom::are_near((*cubic)[2], point_at3)) ||
(apply_with_weight && !Geom::are_near((*cubic)[2], point_at3)))
{
- if (isNodePointSelected(point_at3) || !only_selected) {
+ if (isNodeSelected(point_at3) || !only_selected) {
point_at2 = sbasis_in.valueAt(1 - weight_ammount);
if (weight_ammount != NO_POWER) {
point_at2 =
@@ -431,14 +431,14 @@ void LPEBSpline::doBSplineFromWidget(SPCurve *curve, double weight_ammount)
(apply_no_weight && weight_ammount == NO_POWER) ||
(apply_with_weight && weight_ammount != NO_POWER))
{
- if (isNodePointSelected(point_at0) || !only_selected) {
+ if (isNodeSelected(point_at0) || !only_selected) {
point_at1 = sbasis_in.valueAt(weight_ammount);
point_at1 =
Geom::Point(point_at1[X] + HANDLE_CUBIC_GAP, point_at1[Y] + HANDLE_CUBIC_GAP);
} else {
point_at1 = in->first_segment()->initialPoint();
}
- if (isNodePointSelected(point_at3) || !only_selected) {
+ if (isNodeSelected(point_at3) || !only_selected) {
point_at2 = sbasis_in.valueAt(1 - weight_ammount);
point_at2 =
Geom::Point(point_at2[X] + HANDLE_CUBIC_GAP, point_at2[Y] + HANDLE_CUBIC_GAP);
diff --git a/src/live_effects/lpe-fillet-chamfer.cpp b/src/live_effects/lpe-fillet-chamfer.cpp
index 7a663614b..c9d3d4afd 100644
--- a/src/live_effects/lpe-fillet-chamfer.cpp
+++ b/src/live_effects/lpe-fillet-chamfer.cpp
@@ -252,7 +252,7 @@ void LPEFilletChamfer::doBeforeEffect(SPLPEItem const *lpeItem)
}
//fillet chamfer specific calls
_satellites_param.setUseDistance(_use_knot_distance);
- _satellites_param.setCurrentZoom(current_zoom);
+ _satellites_param.setCurrentZoom(getCurrentZoom());
//mandatory call
_satellites_param.setEffectType(effectType());
Geom::PathVector const pathv = pathv_to_linear_and_cubic_beziers(c->get_pathvector());
@@ -262,7 +262,6 @@ void LPEFilletChamfer::doBeforeEffect(SPLPEItem const *lpeItem)
size_t number_nodes = pathv.nodes().size();
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);
@@ -348,7 +347,8 @@ LPEFilletChamfer::doEffect_path(Geom::PathVector const &path_in)
size_t path = 0;
const double K = (4.0 / 3.0) * (sqrt(2.0) - 1.0);
_degenerate_hide = false;
- Geom::PathVector pathv = pathv_to_linear_and_cubic_beziers(path_in);
+ Geom::PathVector const pathv = pathv_to_linear_and_cubic_beziers(path_in);
+ Satellites satellites = _pathvector_satellites->getSatellites();
for (Geom::PathVector::const_iterator path_it = pathv.begin(); path_it != pathv.end(); ++path_it) {
if (path_it->empty()) {
continue;
@@ -363,7 +363,6 @@ LPEFilletChamfer::doEffect_path(Geom::PathVector const &path_in)
}
double time0 = 0;
size_t curve = 0;
- Satellites satellites = _pathvector_satellites->getSatellites();
for (Geom::Path::const_iterator curve_it1 = path_it->begin(); curve_it1 != path_it->end(); ++curve_it1) {
size_t next_index = curve + 1;
if (curve == pathv[path].size() - 1 && pathv[path].closed()) {
@@ -377,8 +376,10 @@ LPEFilletChamfer::doEffect_path(Geom::PathVector const &path_in)
}
continue;
}
+ Geom::Curve const &curve_it2 = pathv[path][next_index];
Satellite satellite = satellites[path][next_index];
- if (Geom::are_near((*curve_it1).initialPoint(),(*curve_it1).finalPoint())) {
+ if (Geom::are_near((*curve_it1).initialPoint(), (*curve_it1).finalPoint()) ||
+ Geom::are_near(curve_it2.initialPoint(), curve_it2.finalPoint())) {
_degenerate_hide = true;
g_warning("Knots hidded if consecutive nodes has the same position.");
return path_in;
@@ -391,7 +392,6 @@ LPEFilletChamfer::doEffect_path(Geom::PathVector const &path_in)
}
}
bool last = pathv[path].size() - 1 == curve;
- Geom::Curve const &curve_it2 = pathv[path][next_index];
double s = satellite.arcDistance(curve_it2);
double time1 = satellite.time(s, true, (*curve_it1));
double time2 = satellite.time(curve_it2);
@@ -406,6 +406,7 @@ LPEFilletChamfer::doEffect_path(Geom::PathVector const &path_in)
times.push_back(time1);
times.push_back(time2);
Geom::Curve *knot_curve_1 = curve_it1->portion(times[0], times[1]);
+ Geom::Curve *knot_curve_2 = curve_it2.portion(times[2], 1);
if (curve > 0) {
knot_curve_1->setInitial(tmp_path.finalPoint());
} else {
@@ -432,7 +433,6 @@ LPEFilletChamfer::doEffect_path(Geom::PathVector const &path_in)
if (time0 == 1) {
handle_1 = start_arc_point;
}
- Geom::Curve *knot_curve_2 = curve_it2.portion(times[2], 1);
Geom::CubicBezier const *cubic_2 =
dynamic_cast<Geom::CubicBezier const *>(&*knot_curve_2);
Geom::Ray ray_2(curve_it2.initialPoint(), end_arc_point);
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<SPLPEItem *>(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;
}
diff --git a/src/ui/tools/node-tool.cpp b/src/ui/tools/node-tool.cpp
index d02b8e6d3..6a1feb760 100644
--- a/src/ui/tools/node-tool.cpp
+++ b/src/ui/tools/node-tool.cpp
@@ -300,7 +300,7 @@ void NodeTool::update_helperpath () {
selected_nodes_pos.push_back(n->position());
}
}
- lpe->setSelectedNodePoints(selected_nodes_pos);
+ lpe->setSelectedNodes(selected_nodes_pos);
lpe->setCurrentZoom(this->desktop->current_zoom());
SPCurve *c = new SPCurve();
SPCurve *cc = new SPCurve();