diff options
| author | jtx <javier.arraiza@marker.es> | 2013-03-22 10:53:13 +0000 |
|---|---|---|
| committer | jtx <javier.arraiza@marker.es> | 2013-03-22 10:53:13 +0000 |
| commit | 040f59a8c297ded96fc20318c5eb4985958d346c (patch) | |
| tree | a030e228d274beb3c7c255ef3c27cd9eb374a25f /src/ui | |
| parent | Fixing node fault (diff) | |
| parent | Enabling Mesh (diff) | |
| download | inkscape-040f59a8c297ded96fc20318c5eb4985958d346c.tar.gz inkscape-040f59a8c297ded96fc20318c5eb4985958d346c.zip | |
Adding mesh
(bzr r11950.4.4)
Diffstat (limited to 'src/ui')
| -rw-r--r-- | src/ui/tool/node.cpp | 58 | ||||
| -rw-r--r-- | src/ui/tool/node.h | 7 | ||||
| -rw-r--r-- | src/ui/tool/path-manipulator.cpp | 52 | ||||
| -rw-r--r-- | src/ui/tool/path-manipulator.h | 11 |
4 files changed, 74 insertions, 54 deletions
diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index 93b45bde7..3e4fbd508 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -110,15 +110,9 @@ 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); - std::string strPathManipulatorName = "PathManipulator"; - if(std::string(typeid(_pm()).name()) == strPathManipulatorName) - isBSpline = _pm().isBSpline; - else - //Esto no es cierto realmente pero evita que casque al crear nodos - isBSpline = false; } Handle::~Handle() @@ -145,11 +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(isBSpline){ + if(_pm().isBSpline){ typedef ControlPointSelection::Set Set; Set &nodes = _parent->_selection.allPoints(); for (Set::iterator i = nodes.begin(); i != nodes.end(); ++i) { @@ -193,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); @@ -232,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); @@ -329,7 +322,7 @@ bool Handle::_eventHandler(SPEventContext *event_context, GdkEvent *event) //BSpline void Handle::handle_2button_press(){ - if(isBSpline){ + if(_pm().isBSpline){ Handle *h = NULL; Handle *h2 = NULL; double pos = 0; @@ -391,7 +384,7 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event) } new_pos = result; //BSpline - if(isBSpline){ + if(_pm().isBSpline){ Handle *h = NULL; double pos = 0; h = this; @@ -403,7 +396,7 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event) } std::vector<Inkscape::SnapCandidatePoint> unselected; - if (snap && ( (!held_control(*event) && isBSpline) || !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); @@ -585,12 +578,6 @@ 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 - std::string strPathManipulatorName = "PathManipulator"; - if(std::string(typeid(_pm()).name()) == strPathManipulatorName) - isBSpline = _pm().isBSpline; - else - //Esto no es cierto realmente pero evita que casque al crear nodos - isBSpline = false; } Node const *Node::_next() const @@ -636,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(isBSpline){ + if(_pm().isBSpline){ if(prevNode) prevPos = _pm().BSplineHandlePosition(prevNode->front()); pos = _pm().BSplineHandlePosition(n->front()); @@ -648,7 +635,7 @@ void Node::move(Geom::Point const &new_pos) //BSpline End setPosition(new_pos); //BSpline - if(isBSpline){ + if(_pm().isBSpline){ if(prevNode) prevNode->front()->setPosition(_pm().BSplineHandleReposition(prevNode->front(),prevPos)); if(nextNode) @@ -662,7 +649,7 @@ void Node::move(Geom::Point const &new_pos) // with the segment _fixNeighbors(old_pos, new_pos); //BSpline - if(isBSpline){ + if(_pm().isBSpline){ Handle* front = &_front; Handle* back = &_back; _front.setPosition(_pm().BSplineHandleReposition(front,pos)); @@ -866,21 +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(); - //BSpline - 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 + } void Node::pickBestType() diff --git a/src/ui/tool/node.h b/src/ui/tool/node.h index a384db7cc..af83ac54e 100644 --- a/src/ui/tool/node.h +++ b/src/ui/tool/node.h @@ -120,9 +120,6 @@ protected: virtual bool _hasDragTips() const { return true; } private: - //BSpline - bool isBSpline; - //BSpline End 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 @@ -238,9 +235,7 @@ protected: virtual bool _hasDragTips() const { return true; } private: - //BSpline - bool isBSpline; - //BSpline End + Node(Node const &); void _fixNeighbors(Geom::Point const &old_pos, Geom::Point const &new_pos); void _updateAutoHandles(); diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index e789d5447..8f6651dee 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -9,9 +9,7 @@ * Copyright (C) 2009 Authors * Released under GNU GPL, read the file 'COPYING' for more information */ -//BSpline -#include "live_effects/lpe-bspline.h" -//BSpline end + #include "live_effects/lpe-powerstroke.h" #include <string> #include <sstream> @@ -46,6 +44,9 @@ #include "ui/tool/multi-path-manipulator.h" #include "xml/node.h" #include "xml/node-observer.h" +//BSpline +#include "live_effects/lpe-bspline.h" +//BSpline end namespace Inkscape { namespace UI { @@ -149,8 +150,8 @@ PathManipulator::PathManipulator(MultiPathManipulator &mpm, SPPath *path, sigc::hide( sigc::mem_fun(*this, &PathManipulator::_updateOutlineOnZoomChange))); _createControlPointsFromGeometry(); - - LivePathEffect::LPEBSpline *lpe_bsp = NULL; + //BSpline + 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){ @@ -162,6 +163,7 @@ PathManipulator::PathManipulator(MultiPathManipulator &mpm, SPPath *path, isBSpline = true; controlBSplineSteps = lpe_bsp->steps+1; } + //BSpline End } PathManipulator::~PathManipulator() @@ -674,6 +676,19 @@ unsigned PathManipulator::_deleteStretch(NodeList::iterator start, NodeList::ite nl.erase(start); start = next; } + //BSpline + if(isBSpline){ + double pos = 0; + if(start.prev()){ + pos = BSplineHandlePosition(start.prev()->back()); + start.prev()->front()->setPosition(BSplineHandleReposition(start.prev()->front(),pos)); + } + if(end){ + pos = BSplineHandlePosition(end->front()); + end->back()->setPosition(BSplineHandleReposition(end->back(),pos)); + } + } + //BSpline End return del_len; } @@ -1186,18 +1201,27 @@ void PathManipulator::_createControlPointsFromGeometry() } double PathManipulator::BSplineHandlePosition(Handle *h){ + //BSpline + if(lpe_bsp){ + controlBSplineSteps = lpe_bsp->steps+1; + } + //BSpline End using Geom::X; using Geom::Y; double pos = 0; Node *n = h->parent(); SPCurve *lineInsideNodes = new SPCurve(); - Node * nextNode = n->nodeToward(h); - 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()); + 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()); + } } return pos; } @@ -1214,7 +1238,9 @@ Geom::Point PathManipulator::BSplineHandleReposition(Handle *h,double pos){ Node *n = h->parent(); Geom::D2< Geom::SBasis > SBasisInsideNodes; SPCurve *lineInsideNodes = new SPCurve(); - Node * nextNode = n->nodeToward(h); + Node * nextNode = NULL; + if(!n->isEndNode()) + nextNode = n->nodeToward(h); if(nextNode && pos != 0){ lineInsideNodes->moveto(n->position()); lineInsideNodes->lineto(nextNode->position()); diff --git a/src/ui/tool/path-manipulator.h b/src/ui/tool/path-manipulator.h index c9030b7bd..496bd957c 100644 --- a/src/ui/tool/path-manipulator.h +++ b/src/ui/tool/path-manipulator.h @@ -19,6 +19,9 @@ #include <boost/weak_ptr.hpp> #include "ui/tool/node.h" #include "ui/tool/manipulator.h" +//BSpline +#include "live_effects/lpe-bspline.h" +//BSpline end struct SPCanvasItem; class SPCurve; @@ -94,7 +97,10 @@ public: 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; + int controlBSplineSteps; + //BSpline End // this is necessary for Tab-selection in MultiPathManipulator SubpathList &subpathList() { return _subpaths; } @@ -105,8 +111,7 @@ private: void _createControlPointsFromGeometry(); //BSpline - int controlBSplineSteps; - bool isBSpline; + LivePathEffect::LPEBSpline *lpe_bsp; double BSplineHandlePosition(Handle *h); Geom::Point BSplineHandleReposition(Handle *h); Geom::Point BSplineHandleReposition(Handle *h,double pos); |
