summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2013-03-21 01:32:40 +0000
committerJabiertxo Arraiza Zenotz <jtx@jtx.marker.es>2013-03-21 01:32:40 +0000
commit27c65a6e91a8e79ae5b31e0a62869e3ec0e336c2 (patch)
tree42723c2a30a65ad191a1103ed2ec4e124660e045 /src
parentFor testing, widget added, regression fixed (diff)
parentFixing node fault (diff)
downloadinkscape-27c65a6e91a8e79ae5b31e0a62869e3ec0e336c2.tar.gz
inkscape-27c65a6e91a8e79ae5b31e0a62869e3ec0e336c2.zip
Inserting nodes fixed, cleanup
(bzr r11950.1.63)
Diffstat (limited to 'src')
-rw-r--r--src/ui/tool/curve-drag-point.cpp4
-rw-r--r--src/ui/tool/multi-path-manipulator.cpp2
-rw-r--r--src/ui/tool/multi-path-manipulator.h2
-rw-r--r--src/ui/tool/node.cpp61
-rw-r--r--src/ui/tool/node.h1
-rw-r--r--src/ui/tool/path-manipulator.cpp50
-rw-r--r--src/ui/tool/path-manipulator.h9
7 files changed, 55 insertions, 74 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.cpp b/src/ui/tool/multi-path-manipulator.cpp
index 3623bb006..94860093d 100644
--- a/src/ui/tool/multi-path-manipulator.cpp
+++ b/src/ui/tool/multi-path-manipulator.cpp
@@ -307,7 +307,7 @@ void MultiPathManipulator::setNodeType(NodeType type)
Node *node = dynamic_cast<Node*>(*i);
if (node) {
retract_handles &= (node->type() == NODE_CUSP);
- node->setType(type,true);
+ node->setType(type);
}
}
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..3e4fbd508 100644
--- a/src/ui/tool/node.cpp
+++ b/src/ui/tool/node.cpp
@@ -110,7 +110,7 @@ Handle::Handle(NodeSharedData const &data, Geom::Point const &initial_pos, Node
_handle_colors, data.handle_group),
_parent(parent),
_handle_line(ControlManager::getManager().createControlLine(data.handle_line_group)),
- _degenerate(true),controlBsplineSteps(2)
+ _degenerate(true)
{
setVisible(false);
}
@@ -139,12 +139,10 @@ 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
- bool isBSpline = false;
double pos = 0;
Handle *h = NULL;
Handle *h2 = NULL;
- if(_pm().isBSpline()){
- isBSpline = true;
+ if(_pm().isBSpline){
typedef ControlPointSelection::Set Set;
Set &nodes = _parent->_selection.allPoints();
for (Set::iterator i = nodes.begin(); i != nodes.end(); ++i) {
@@ -188,7 +186,7 @@ void Handle::move(Geom::Point const &new_pos)
}
setPosition(new_pos);
//BSpline
- if(isBSpline){
+ if(_pm().isBSpline){
h = this;
setPosition(_pm().BSplineHandleReposition(h));
pos = _pm().BSplineHandlePosition(h);
@@ -227,7 +225,7 @@ void Handle::move(Geom::Point const &new_pos)
}
setPosition(new_pos);
//BSpline
- if(isBSpline){
+ if(_pm().isBSpline){
h = this;
setPosition(_pm().BSplineHandleReposition(h));
pos = _pm().BSplineHandlePosition(h);
@@ -324,7 +322,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 +384,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 +623,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 +635,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 +649,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));
@@ -773,27 +771,6 @@ void Node::setType(NodeType type, bool update_handles)
return;
}
- //BSpline
- if(_pm().isBSpline()){
- if (isEndNode()) return;
- Handle* front = &_front;
- Handle* back = &_back;
- double pos = 0.3334;
- switch (type) {
- case NODE_CUSP:
- if(update_handles)
- pos = 0;
- else
- pos = _pm().BSplineHandlePosition(front);;
- break;
- default: break;
- }
- type = NODE_CUSP;
- _front.setPosition(_pm().BSplineHandleReposition(front,pos));
- _back.setPosition(_pm().BSplineHandleReposition(back,pos));
- }
- //BSpline End
-
// if update_handles is true, adjust handle positions to match the node type
// handle degenerate handles appropriately
if (update_handles) {
@@ -876,12 +853,28 @@ void Node::setType(NodeType type, bool update_handles)
break;
default: break;
}
+ //BSpline
+ bool isBSpline = false;
+ try {
+ isBSpline = nodeList().subpathList().pm().isBSpline;
+ }
+ catch( char * str ) {
+ }
+ if(isBSpline){
+ Handle* front = &_front;
+ Handle* back = &_back;
+ double pos = _pm().BSplineHandlePosition(front);
+ _front.setPosition(_pm().BSplineHandleReposition(front,pos));
+ _back.setPosition(_pm().BSplineHandleReposition(back,pos));
+ }
+ //BSpline End
}
_type = type;
_setControlType(nodeTypeToCtrlType(_type));
updateState();
+
}
void Node::pickBestType()
diff --git a/src/ui/tool/node.h b/src/ui/tool/node.h
index 7152f37fd..af83ac54e 100644
--- a/src/ui/tool/node.h
+++ b/src/ui/tool/node.h
@@ -120,7 +120,6 @@ protected:
virtual bool _hasDragTips() const { return true; }
private:
-
inline PathManipulator &_pm();
Node *_parent; // the handle's lifetime does not extend beyond that of the parent node,
// so a naked pointer is OK and allows setting it during Node's construction
diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp
index c3ab19a4e..fc4439711 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()
@@ -651,6 +664,12 @@ unsigned PathManipulator::_deleteStretch(NodeList::iterator start, NodeList::ite
start.prev()->front()->setPosition(result[1]);
end->back()->setPosition(result[2]);
+ //BSpline
+ if(isBSpline){
+ start.prev()->front()->setPosition(BSplineHandleReposition(start.prev()->front()));
+ end->back()->setPosition(BSplineHandleReposition(end->back()));
+ }
+ //BSpline End
}
// We can't use nl->erase(start, end), because it would break when the stretch
@@ -897,7 +916,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,35 +1191,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))){
- 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());
- }else{
- lpe_bsp = NULL;
- }
- }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..948d4544b 100644
--- a/src/ui/tool/path-manipulator.h
+++ b/src/ui/tool/path-manipulator.h
@@ -89,15 +89,14 @@ 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);
NodeList::iterator extremeNode(NodeList::iterator origin, bool search_selected,
bool search_unselected, bool closest);
-
+ //BSpline
+ bool isBSpline;
+ //BSpline End
// this is necessary for Tab-selection in MultiPathManipulator
SubpathList &subpathList() { return _subpaths; }
@@ -108,7 +107,7 @@ private:
void _createControlPointsFromGeometry();
//BSpline
- bool isBSpline();
+ int controlBSplineSteps;
double BSplineHandlePosition(Handle *h);
Geom::Point BSplineHandleReposition(Handle *h);
Geom::Point BSplineHandleReposition(Handle *h,double pos);