summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2013-03-31 23:09:52 +0000
committerJabiertxo Arraiza Zenotz <jtx@jtx.marker.es>2013-03-31 23:09:52 +0000
commita7ced41f3fa6933d0da0151ef42e82e0862581fb (patch)
tree0b4e00c1c9fb4c6b0669ca062c25de97aa2f0524 /src
parentFix bspline icon show (diff)
downloadinkscape-a7ced41f3fa6933d0da0151ef42e82e0862581fb.tar.gz
inkscape-a7ced41f3fa6933d0da0151ef42e82e0862581fb.zip
Fix scale and rotate some nodes
(bzr r11950.1.78)
Diffstat (limited to 'src')
-rw-r--r--src/live_effects/lpe-bspline.cpp22
-rw-r--r--src/ui/tool/node.cpp41
-rw-r--r--src/ui/tool/node.h2
-rw-r--r--src/ui/tool/path-manipulator.cpp26
-rw-r--r--src/ui/tool/path-manipulator.h1
5 files changed, 60 insertions, 32 deletions
diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp
index ee771a54e..37d6a86a5 100644
--- a/src/live_effects/lpe-bspline.cpp
+++ b/src/live_effects/lpe-bspline.cpp
@@ -29,6 +29,7 @@
#include "ui/widget/scalar.h"
#include "selection.h"
#include "gtkmm/checkbutton.h"
+#include "ui/tool/node.h"
// For handling un-continuous paths:
#include "message-stack.h"
#include "inkscape.h"
@@ -337,15 +338,34 @@ LPEBSpline::changeWeight(double weightValue)
DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_LPE,
_("Modified the weight of the BSpline"));
}
-
+//bool
+//LPEBspline::selectedPoint(Geom::Point p){
+// for (SubpathList::iterator i = NodeIterator.begin(); i != NodeIterator.end(); ++i) {
+// if (i->selected() && i.ptr()->getPosition() == p) {
+// return true;
+// }
+// }
+// return false;
+//}
+//bool
+//LPEBspline::hasNodesSelected(){
+// for (SubpathList::iterator i = NodeIterator.begin(); i != NodeIterator.end(); ++i) {
+// if (i->selected() && i.ptr()->getPosition() == p) {
+// return true;
+// }
+// }
+// return false;
+//}
void
LPEBSpline::doBSplineFromWidget(SPCurve * curve, double weightValue , bool ignoreCusp)
{
using Geom::X;
using Geom::Y;
+ //bool hasNodesSelected = LPEBspline::hasNodesSelected();
if(curve->get_segment_count() < 2)
return;
// Make copy of old path as it is changed during processing
+
Geom::PathVector const original_pathv = curve->get_pathvector();
curve->reset();
diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp
index b4976bde5..dfa9c5d84 100644
--- a/src/ui/tool/node.cpp
+++ b/src/ui/tool/node.cpp
@@ -139,7 +139,6 @@ void Handle::move(Geom::Point const &new_pos)
Handle *towards = node_towards ? node_towards->handleAwayFrom(_parent) : NULL;
Handle *towards_second = node_towards ? node_towards->handleToward(_parent) : NULL;
//BSpline
- double pos = 0;
Handle *h = NULL;
Handle *h2 = NULL;
if(_pm().isBSpline){
@@ -189,9 +188,9 @@ void Handle::move(Geom::Point const &new_pos)
if(_pm().isBSpline){
h = this;
setPosition(_pm().BSplineHandleReposition(h));
- pos = _pm().BSplineHandlePosition(h);
+ _parent->bsplineWeight = _pm().BSplineHandlePosition(h);
h2 = this->other();
- this->other()->setPosition(_pm().BSplineHandleReposition(h2,pos));
+ this->other()->setPosition(_pm().BSplineHandleReposition(h2,_parent->bsplineWeight));
}
//BSpline End
return;
@@ -228,9 +227,9 @@ void Handle::move(Geom::Point const &new_pos)
if(_pm().isBSpline){
h = this;
setPosition(_pm().BSplineHandleReposition(h));
- pos = _pm().BSplineHandlePosition(h);
+ _parent->bsplineWeight = _pm().BSplineHandlePosition(h);
h2 = this->other();
- this->other()->setPosition(_pm().BSplineHandleReposition(h2,pos));
+ this->other()->setPosition(_pm().BSplineHandleReposition(h2,_parent->bsplineWeight));
}
//BSpline End
}
@@ -325,12 +324,12 @@ void Handle::handle_2button_press(){
if(_pm().isBSpline){
Handle *h = NULL;
Handle *h2 = NULL;
- double pos = 0;
+ _parent->bsplineWeight = 0;
h = this;
setPosition(_pm().BSplineHandleReposition(h,0.3334));
- pos = _pm().BSplineHandlePosition(h);
+ _parent->bsplineWeight = _pm().BSplineHandlePosition(h);
h2 = this->other();
- this->other()->setPosition(_pm().BSplineHandleReposition(h2,pos));
+ this->other()->setPosition(_pm().BSplineHandleReposition(h2,_parent->bsplineWeight));
_pm().update();
}
}
@@ -386,12 +385,12 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event)
//BSpline
if(_pm().isBSpline){
Handle *h = NULL;
- double pos = 0;
+ _parent->bsplineWeight = 0;
h = this;
setPosition(new_pos);
int steps = _pm().getSteps();
- pos = ceilf(_pm().BSplineHandlePosition(h)*steps)/steps;
- new_pos=_pm().BSplineHandleReposition(h,pos);
+ _parent->bsplineWeight = ceilf(_pm().BSplineHandlePosition(h)*steps)/steps;
+ new_pos=_pm().BSplineHandleReposition(h,_parent->bsplineWeight);
}
//BSpline End
}
@@ -579,6 +578,7 @@ Node::Node(NodeSharedData const &data, Geom::Point const &initial_pos) :
_handles_shown(false)
{
// NOTE we do not set type here, because the handles are still degenerate
+ this->bsplineWeight = 0.3334;
}
Node const *Node::_next() const
@@ -619,7 +619,6 @@ void Node::move(Geom::Point const &new_pos)
Geom::Point delta = new_pos - position();
//BSpline
double prevPos = 0;
- double pos = 0;
double nextPos = 0;
Node *n = this;
Node * nextNode = n->nodeToward(n->front());
@@ -627,9 +626,9 @@ void Node::move(Geom::Point const &new_pos)
if(_pm().isBSpline){
if(prevNode)
prevPos = _pm().BSplineHandlePosition(prevNode->front());
- pos = _pm().BSplineHandlePosition(n->front());
- if(pos == 0)
- pos = _pm().BSplineHandlePosition(n->back());
+ n->bsplineWeight = _pm().BSplineHandlePosition(n->front());
+ if(n->bsplineWeight == 0)
+ n->bsplineWeight = _pm().BSplineHandlePosition(n->back());
if(nextNode)
nextPos = _pm().BSplineHandlePosition(nextNode->back());
}
@@ -653,8 +652,8 @@ void Node::move(Geom::Point const &new_pos)
if(_pm().isBSpline){
Handle* front = &_front;
Handle* back = &_back;
- _front.setPosition(_pm().BSplineHandleReposition(front,pos));
- _back.setPosition(_pm().BSplineHandleReposition(back,pos));
+ _front.setPosition(_pm().BSplineHandleReposition(front,n->bsplineWeight));
+ _back.setPosition(_pm().BSplineHandleReposition(back,n->bsplineWeight));
}
}
@@ -864,10 +863,10 @@ void Node::setType(NodeType type, bool update_handles)
if(isBSpline){
Handle* front = &_front;
Handle* back = &_back;
- double pos = _pm().BSplineHandlePosition(front);
- if(pos !=0) pos = 0.3334;
- _front.setPosition(_pm().BSplineHandleReposition(front,pos));
- _back.setPosition(_pm().BSplineHandleReposition(back,pos));
+ this->bsplineWeight = _pm().BSplineHandlePosition(front);
+ if(this->bsplineWeight !=0) this->bsplineWeight = 0.3334;
+ _front.setPosition(_pm().BSplineHandleReposition(front,this->bsplineWeight));
+ _back.setPosition(_pm().BSplineHandleReposition(back,this->bsplineWeight));
}
//BSpline End
}
diff --git a/src/ui/tool/node.h b/src/ui/tool/node.h
index 2b547256b..f6d5beadc 100644
--- a/src/ui/tool/node.h
+++ b/src/ui/tool/node.h
@@ -180,7 +180,7 @@ public:
bool isEndNode() const;
Handle *front() { return &_front; }
Handle *back() { return &_back; }
-
+ double bsplineWeight;
/**
* Gets the handle that faces the given adjacent node.
* Will abort with error if the given node is not adjacent.
diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp
index 1607585c5..be5514e1f 100644
--- a/src/ui/tool/path-manipulator.cpp
+++ b/src/ui/tool/path-manipulator.cpp
@@ -862,7 +862,6 @@ void PathManipulator::rotateHandle(Node *n, int which, int dir, bool pixel)
int snaps = prefs->getIntLimited("/options/rotationsnapsperpi/value", 12, 1, 1000);
angle = M_PI * dir / snaps;
}
-
h->setRelativePos(h->relativePos() * Geom::Rotate(angle));
update();
@@ -1211,14 +1210,12 @@ double PathManipulator::BSplineHandlePosition(Handle *h){
Node * nextNode = NULL;
if(!n->isEndNode())
nextNode = n->nodeToward(h);
- if(nextNode){
- Geom::Point positionH = h->position();
- positionH = Geom::Point(positionH[X] - 0.0625,positionH[Y] - 0.0625);
- if(nextNode && n->position() != h->position()){
- lineInsideNodes->moveto(n->position());
- lineInsideNodes->lineto(nextNode->position());
- pos = Geom::nearest_point(positionH,*lineInsideNodes->first_segment());
- }
+ Geom::Point positionH = h->position();
+ positionH = Geom::Point(positionH[X] - 0.0625,positionH[Y] - 0.0625);
+ if(nextNode && n->position() != h->position()){
+ lineInsideNodes->moveto(n->position());
+ lineInsideNodes->lineto(nextNode->position());
+ pos = Geom::nearest_point(positionH,*lineInsideNodes->first_segment());
}
return pos;
}
@@ -1250,6 +1247,11 @@ Geom::Point PathManipulator::BSplineHandleReposition(Handle *h,double pos){
return ret;
}
+void PathManipulator::BSplineNodeHandlesReposition(Node *n){
+ n->front()->setPosition(BSplineHandleReposition(n->front(),n->bsplineWeight));
+ n->back()->setPosition(BSplineHandleReposition(n->back(),n->bsplineWeight));
+}
+
/** Construct the geometric representation of nodes and handles, update the outline
* and display
* \param alert_LPE if true, first the LPE is warned what the new path is going to be before updating it
@@ -1264,8 +1266,14 @@ void PathManipulator::_createGeometryFromControlPoints(bool alert_LPE)
continue;
}
NodeList::iterator prev = subpath->begin();
+ if(isBSpline){
+ BSplineNodeHandlesReposition(prev.ptr());
+ }
builder.moveTo(prev->position());
for (NodeList::iterator i = ++subpath->begin(); i != subpath->end(); ++i) {
+ if(isBSpline){
+ BSplineNodeHandlesReposition(i.ptr());
+ }
build_segment(builder, prev.ptr(), i.ptr());
prev = i;
}
diff --git a/src/ui/tool/path-manipulator.h b/src/ui/tool/path-manipulator.h
index e68cabef1..743d70b96 100644
--- a/src/ui/tool/path-manipulator.h
+++ b/src/ui/tool/path-manipulator.h
@@ -115,6 +115,7 @@ private:
double BSplineHandlePosition(Handle *h);
Geom::Point BSplineHandleReposition(Handle *h);
Geom::Point BSplineHandleReposition(Handle *h,double pos);
+ void BSplineNodeHandlesReposition(Node *n);
//BSpline End
void _createGeometryFromControlPoints(bool alert_LPE = false);
unsigned _deleteStretch(NodeList::iterator first, NodeList::iterator last, bool keep_shape);