summaryrefslogtreecommitdiffstats
path: root/src/ui
diff options
context:
space:
mode:
authorjtx <javier.arraiza@marker.es>2013-03-20 15:15:12 +0000
committerjtx <javier.arraiza@marker.es>2013-03-20 15:15:12 +0000
commit6bdbe4b651d2a643d751803572df3e8f247a8707 (patch)
treeb04d653761d70bc92858723b3f2ecc0e8010c077 /src/ui
parentFixing regression (diff)
parentFor testing, widget added, regression fixed (diff)
downloadinkscape-6bdbe4b651d2a643d751803572df3e8f247a8707.tar.gz
inkscape-6bdbe4b651d2a643d751803572df3e8f247a8707.zip
Fixing node creations in BSpline mode.
(bzr r11950.4.1)
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/tool/curve-drag-point.cpp4
-rw-r--r--src/ui/tool/multi-path-manipulator.h2
-rw-r--r--src/ui/tool/node.cpp18
-rw-r--r--src/ui/tool/path-manipulator.cpp39
-rw-r--r--src/ui/tool/path-manipulator.h6
5 files changed, 28 insertions, 41 deletions
diff --git a/src/ui/tool/curve-drag-point.cpp b/src/ui/tool/curve-drag-point.cpp
index 40dcb5058..fce19f9ad 100644
--- a/src/ui/tool/curve-drag-point.cpp
+++ b/src/ui/tool/curve-drag-point.cpp
@@ -54,7 +54,7 @@ bool CurveDragPoint::grabbed(GdkEventMotion */*event*/)
// delta is a vector equal 1/3 of distance from first to second
Geom::Point delta = (second->position() - first->position()) / 3.0;
//BSpline
- if(!_pm.isBSpline()){
+ if(!_pm.isBSpline){
first->front()->move(first->front()->position() + delta);
second->back()->move(second->back()->position() - delta);
}
@@ -91,7 +91,7 @@ void CurveDragPoint::dragged(Geom::Point &new_pos, GdkEventMotion *event)
Geom::Point offset0 = ((1-weight)/(3*t*(1-t)*(1-t))) * delta;
Geom::Point offset1 = (weight/(3*t*t*(1-t))) * delta;
//BSpline
- if(!_pm.isBSpline()){
+ if(!_pm.isBSpline){
first->front()->move(first->front()->position() + offset0);
second->back()->move(second->back()->position() + offset1);
}else if(weight>=0.8)second->back()->move(new_pos);
diff --git a/src/ui/tool/multi-path-manipulator.h b/src/ui/tool/multi-path-manipulator.h
index 54a9b5753..01033b3e5 100644
--- a/src/ui/tool/multi-path-manipulator.h
+++ b/src/ui/tool/multi-path-manipulator.h
@@ -71,7 +71,7 @@ public:
void setLiveObjects(bool set);
void updateOutlineColors();
void updateHandles();
-
+
sigc::signal<void> signal_coords_changed; /// Emitted whenever the coordinates
/// shown in the status bar need updating
private:
diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp
index a1fa4e55b..e0aec8bb5 100644
--- a/src/ui/tool/node.cpp
+++ b/src/ui/tool/node.cpp
@@ -143,7 +143,7 @@ void Handle::move(Geom::Point const &new_pos)
double pos = 0;
Handle *h = NULL;
Handle *h2 = NULL;
- if(_pm().isBSpline()){
+ if(_pm().isBSpline){
isBSpline = true;
typedef ControlPointSelection::Set Set;
Set &nodes = _parent->_selection.allPoints();
@@ -324,7 +324,7 @@ bool Handle::_eventHandler(SPEventContext *event_context, GdkEvent *event)
//BSpline
void Handle::handle_2button_press(){
- if(_pm().isBSpline()){
+ if(_pm().isBSpline){
Handle *h = NULL;
Handle *h2 = NULL;
double pos = 0;
@@ -386,19 +386,19 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event)
}
new_pos = result;
//BSpline
- if(_pm().isBSpline()){
+ if(_pm().isBSpline){
Handle *h = NULL;
double pos = 0;
h = this;
setPosition(new_pos);
- pos = ceilf(_pm().BSplineHandlePosition(h)*_pm().getControlBsplineSteps())/_pm().getControlBsplineSteps();
+ pos = ceilf(_pm().BSplineHandlePosition(h)*_pm().controlBSplineSteps)/_pm().controlBSplineSteps;
new_pos=_pm().BSplineHandleReposition(h,pos);
}
//BSpline End
}
std::vector<Inkscape::SnapCandidatePoint> unselected;
- if (snap && ( (!held_control(*event) && _pm().isBSpline()) || !_pm().isBSpline())) {
+ if (snap && ( (!held_control(*event) && _pm().isBSpline) || !_pm().isBSpline)) {
ControlPointSelection::Set &nodes = _parent->_selection.allPoints();
for (ControlPointSelection::Set::iterator i = nodes.begin(); i != nodes.end(); ++i) {
Node *n = static_cast<Node*>(*i);
@@ -625,7 +625,7 @@ void Node::move(Geom::Point const &new_pos)
Node *n = this;
Node * nextNode = n->nodeToward(n->front());
Node * prevNode = n->nodeToward(n->back());
- if(_pm().isBSpline()){
+ if(_pm().isBSpline){
if(prevNode)
prevPos = _pm().BSplineHandlePosition(prevNode->front());
pos = _pm().BSplineHandlePosition(n->front());
@@ -637,7 +637,7 @@ void Node::move(Geom::Point const &new_pos)
//BSpline End
setPosition(new_pos);
//BSpline
- if(_pm().isBSpline()){
+ if(_pm().isBSpline){
if(prevNode)
prevNode->front()->setPosition(_pm().BSplineHandleReposition(prevNode->front(),prevPos));
if(nextNode)
@@ -651,7 +651,7 @@ void Node::move(Geom::Point const &new_pos)
// with the segment
_fixNeighbors(old_pos, new_pos);
//BSpline
- if(_pm().isBSpline()){
+ if(_pm().isBSpline){
Handle* front = &_front;
Handle* back = &_back;
_front.setPosition(_pm().BSplineHandleReposition(front,pos));
@@ -774,7 +774,7 @@ void Node::setType(NodeType type, bool update_handles)
}
//BSpline
- if(_pm().isBSpline()){
+ if(_pm().isBSpline){
if (isEndNode()) return;
Handle* front = &_front;
Handle* back = &_back;
diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp
index 853d9336a..e789d5447 100644
--- a/src/ui/tool/path-manipulator.cpp
+++ b/src/ui/tool/path-manipulator.cpp
@@ -149,6 +149,19 @@ PathManipulator::PathManipulator(MultiPathManipulator &mpm, SPPath *path,
sigc::hide( sigc::mem_fun(*this, &PathManipulator::_updateOutlineOnZoomChange)));
_createControlPointsFromGeometry();
+
+ LivePathEffect::LPEBSpline *lpe_bsp = NULL;
+ if (SP_LPE_ITEM(_path) && sp_lpe_item_has_path_effect(SP_LPE_ITEM(_path))){
+ Inkscape::LivePathEffect::Effect* thisEffect = sp_lpe_item_has_path_effect_of_type(SP_LPE_ITEM(_path),Inkscape::LivePathEffect::BSPLINE);
+ if(thisEffect){
+ lpe_bsp = dynamic_cast<LivePathEffect::LPEBSpline*>(thisEffect->getLPEObj()->get_lpe());
+ }
+ }
+ isBSpline = false;
+ if(lpe_bsp){
+ isBSpline = true;
+ controlBSplineSteps = lpe_bsp->steps+1;
+ }
}
PathManipulator::~PathManipulator()
@@ -897,7 +910,7 @@ void PathManipulator::showHandles(bool show)
void PathManipulator::showOutline(bool show)
{
//BSpline
- if(isBSpline()) show = true;
+ if(isBSpline) show = true;
//BSpline
if (show == _show_outline) return;
_show_outline = show;
@@ -1172,30 +1185,6 @@ void PathManipulator::_createControlPointsFromGeometry()
}
}
-
-bool PathManipulator::isBSpline(){
- LivePathEffect::LPEBSpline *lpe_bsp = NULL;
- if (SP_LPE_ITEM(_path) && sp_lpe_item_has_path_effect(SP_LPE_ITEM(_path))){
- lpe_bsp = dynamic_cast<LivePathEffect::LPEBSpline*>(sp_lpe_item_has_path_effect_of_type(SP_LPE_ITEM(_path),Inkscape::LivePathEffect::BSPLINE)->getLPEObj()->get_lpe());
- }else{
- lpe_bsp = NULL;
- }
- if(lpe_bsp){
- return true;
- }
- return false;
-}
-
-int PathManipulator::getControlBsplineSteps(){
- LivePathEffect::LPEBSpline *lpe_bsp = NULL;
- if (SP_LPE_ITEM(_path) && sp_lpe_item_has_path_effect(SP_LPE_ITEM(_path))){
- lpe_bsp = dynamic_cast<LivePathEffect::LPEBSpline*>(sp_lpe_item_has_path_effect_of_type(SP_LPE_ITEM(_path),Inkscape::LivePathEffect::BSPLINE)->getLPEObj()->get_lpe());
- if(lpe_bsp){
- return lpe_bsp->steps+1;
- }
- }
- return 2;
-}
double PathManipulator::BSplineHandlePosition(Handle *h){
using Geom::X;
using Geom::Y;
diff --git a/src/ui/tool/path-manipulator.h b/src/ui/tool/path-manipulator.h
index 79db1a1c1..c9030b7bd 100644
--- a/src/ui/tool/path-manipulator.h
+++ b/src/ui/tool/path-manipulator.h
@@ -89,9 +89,6 @@ public:
void updateHandles();
void setControlsTransform(Geom::Affine const &);
void hideDragPoint();
- //BSpline
- int getControlBsplineSteps();
- //BSpline End
MultiPathManipulator &mpm() { return _multi_path_manipulator; }
NodeList::iterator subdivideSegment(NodeList::iterator after, double t);
@@ -108,7 +105,8 @@ private:
void _createControlPointsFromGeometry();
//BSpline
- bool isBSpline();
+ int controlBSplineSteps;
+ bool isBSpline;
double BSplineHandlePosition(Handle *h);
Geom::Point BSplineHandleReposition(Handle *h);
Geom::Point BSplineHandleReposition(Handle *h,double pos);