summaryrefslogtreecommitdiffstats
path: root/src/ui/tool
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2015-03-21 11:52:05 +0000
committerJabiertxof <jtx@jtx.marker.es>2015-03-21 11:52:05 +0000
commit35dbee2c542660e1ab2c2aa3ed8f0bc052ebd0a1 (patch)
tree1339b657212153803c8b575b3862a4864928da71 /src/ui/tool
parentupdate to trunk (diff)
parentImprove the cache system of bspline, "Correctly" show bspline weight power on... (diff)
downloadinkscape-35dbee2c542660e1ab2c2aa3ed8f0bc052ebd0a1.tar.gz
inkscape-35dbee2c542660e1ab2c2aa3ed8f0bc052ebd0a1.zip
update to trunk
(bzr r13645.1.48)
Diffstat (limited to 'src/ui/tool')
-rw-r--r--src/ui/tool/curve-drag-point.cpp4
-rw-r--r--src/ui/tool/node.cpp33
-rw-r--r--src/ui/tool/path-manipulator.cpp27
3 files changed, 39 insertions, 25 deletions
diff --git a/src/ui/tool/curve-drag-point.cpp b/src/ui/tool/curve-drag-point.cpp
index 49c949107..a90dfb155 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;
// only update the nodes if the mode is bspline
- if(!_pm.isBSpline(false)){
+ 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 offset1 = (weight/(3*t*t*(1-t))) * delta;
//modified so that, if the trace is bspline, it only acts if the SHIFT key is pressed
- if(!_pm.isBSpline(false)){
+ if(!_pm.isBSpline()){
first->front()->move(first->front()->position() + offset0);
second->back()->move(second->back()->position() + offset1);
}else if(weight>=0.8){
diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp
index 5cfc2a0ca..08cc6708d 100644
--- a/src/ui/tool/node.cpp
+++ b/src/ui/tool/node.cpp
@@ -175,7 +175,7 @@ void Handle::move(Geom::Point const &new_pos)
setPosition(new_pos);
//move the handler and its oposite the same proportion
- if(_pm().isBSpline(false)){
+ if(_pm().isBSpline()){
setPosition(_pm().BSplineHandleReposition(this,this));
this->other()->setPosition(_pm().BSplineHandleReposition(this->other(),this));
}
@@ -192,7 +192,7 @@ void Handle::move(Geom::Point const &new_pos)
setRelativePos(new_delta);
//move the handler and its oposite the same proportion
- if(_pm().isBSpline(false)){
+ if(_pm().isBSpline()){
setPosition(_pm().BSplineHandleReposition(this,this));
this->other()->setPosition(_pm().BSplineHandleReposition(this->other(),this));
}
@@ -218,11 +218,10 @@ void Handle::move(Geom::Point const &new_pos)
setPosition(new_pos);
// moves the handler and its oposite the same proportion
- if(_pm().isBSpline(false)){
+ if(_pm().isBSpline()){
setPosition(_pm().BSplineHandleReposition(this,this));
this->other()->setPosition(_pm().BSplineHandleReposition(this->other(),this));
}
-
}
void Handle::setPosition(Geom::Point const &p)
@@ -313,7 +312,7 @@ bool Handle::_eventHandler(Inkscape::UI::Tools::ToolBase *event_context, GdkEven
//this function moves the handler and its oposite to the default proportion of defaultStartPower
void Handle::handle_2button_press(){
- if(_pm().isBSpline(false)){
+ if(_pm().isBSpline()){
setPosition(_pm().BSplineHandleReposition(this,defaultStartPower));
this->other()->setPosition(_pm().BSplineHandleReposition(this->other(),defaultStartPower));
_pm().update();
@@ -373,7 +372,7 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event)
new_pos = result;
// moves the handler and its oposite in X fixed positions depending on parameter "steps with control"
// by default in live BSpline
- if(_pm().isBSpline(false)){
+ if(_pm().isBSpline()){
setPosition(new_pos);
int steps = _pm().BSplineGetSteps();
new_pos=_pm().BSplineHandleReposition(this,ceilf(_pm().BSplineHandlePosition(this,this)*steps)/steps);
@@ -382,7 +381,7 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event)
std::vector<Inkscape::SnapCandidatePoint> unselected;
//if the snap adjustment is activated and it is not bspline
- if (snap && !_pm().isBSpline(false)) {
+ if (snap && !_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);
@@ -423,7 +422,7 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event)
}
}
//if it is bspline but SHIFT or CONTROL are not pressed it fixes it in the original position
- if(_pm().isBSpline(false) && !held_shift(*event) && !held_control(*event)){
+ if(_pm().isBSpline() && !held_shift(*event) && !held_control(*event)){
new_pos=_last_drag_origin();
}
move(new_pos); // needed for correct update, even though it's redundant
@@ -486,7 +485,7 @@ Glib::ustring Handle::_getTip(unsigned state) const
char const *more;
// a trick to mark as bspline if the node has no strength, we are going to use it later
// to show the appropiate messages. We cannot do it in any different way becasue the function is constant
-
+ Handle *h = const_cast<Handle *>(this);
bool isBSpline = _pm().isBSpline();
bool can_shift_rotate = _parent->type() == NODE_CUSP && !other()->isDegenerate();
if (can_shift_rotate && !isBSpline) {
@@ -550,7 +549,7 @@ Glib::ustring Handle::_getTip(unsigned state) const
"<b>Auto node handle</b>: drag to convert to smooth node (%s)"), more);
}else{
return format_tip(C_("Path handle tip",
- "<b>BSpline node handle</b>: Shift to drag, double click to reset (%s)"), more);
+ "<b>BSpline node handle</b>: Shift to drag, double click to reset (%s). %g power"),more,_pm().BSplineHandlePosition(h,NULL));
}
}
}
@@ -656,7 +655,7 @@ void Node::move(Geom::Point const &new_pos)
_fixNeighbors(old_pos, new_pos);
// move the affected handlers. First the node ones, later the adjoining ones.
- if(_pm().isBSpline(false)){
+ if(_pm().isBSpline()){
_front.setPosition(_pm().BSplineHandleReposition(this->front(),nodeWeight));
_back.setPosition(_pm().BSplineHandleReposition(this->back(),nodeWeight));
if(prevNode){
@@ -709,7 +708,7 @@ void Node::transform(Geom::Affine const &m)
_fixNeighbors(old_pos, position());
// move the involved handlers, first the node ones, later the adjoining ones
- if(_pm().isBSpline(false)){
+ if(_pm().isBSpline()){
_front.setPosition(_pm().BSplineHandleReposition(this->front(),nodeWeight));
_back.setPosition(_pm().BSplineHandleReposition(this->back(),nodeWeight));
if(prevNode){
@@ -916,7 +915,7 @@ void Node::setType(NodeType type, bool update_handles)
}
/* in node type changes, about bspline traces, we can mantain them with noPower power in border mode,
or we give them the default power in curve mode */
- if(_pm().isBSpline(false)){
+ if(_pm().isBSpline()){
double weight = noPower;
if(_pm().BSplineHandlePosition(this->front()) != noPower ){
weight = defaultStartPower;
@@ -1172,7 +1171,7 @@ void Node::_setState(State state)
mgr.setActive(_canvas_item, true);
mgr.setPrelight(_canvas_item, false);
//this shows the handlers when selecting the nodes
- if(_pm().isBSpline(false)){
+ if(_pm().isBSpline()){
this->front()->setPosition(_pm().BSplineHandleReposition(this->front()));
this->back()->setPosition(_pm().BSplineHandleReposition(this->back()));
}
@@ -1435,6 +1434,8 @@ Node *Node::nodeAwayFrom(Handle *h)
Glib::ustring Node::_getTip(unsigned state) const
{
bool isBSpline = _pm().isBSpline();
+ Handle *h = const_cast<Handle *>(&_front);
+ Handle *h2 = const_cast<Handle *>(&_back);
if (state_held_shift(state)) {
bool can_drag_out = (_next() && _front.isDegenerate()) || (_prev() && _back.isDegenerate());
if (can_drag_out) {
@@ -1469,7 +1470,7 @@ Glib::ustring Node::_getTip(unsigned state) const
"<b>%s</b>: drag to shape the path (more: Shift, Ctrl, Alt)"), nodetype);
}else if(_selection.size() == 1){
return format_tip(C_("Path node tip",
- "<b>BSpline node</b>: %g weight, drag to shape the path (more: Shift, Ctrl, Alt)"),noPower/*this->bsplineWeight*/);
+ "<b>BSpline node</b>: drag to shape the path (more: Shift, Ctrl, Alt). %g power"),_pm().BSplineHandlePosition(h,h2));
}
return format_tip(C_("Path node tip",
"<b>%s</b>: drag to shape the path, click to toggle scale/rotation handles (more: Shift, Ctrl, Alt)"), nodetype);
@@ -1479,7 +1480,7 @@ Glib::ustring Node::_getTip(unsigned state) const
"<b>%s</b>: drag to shape the path, click to select only this node (more: Shift, Ctrl, Alt)"), nodetype);
}else{
return format_tip(C_("Path node tip",
- "<b>BSpline node</b>: drag to shape the path, click to select only this node (more: Shift, Ctrl, Alt)"));
+ "<b>BSpline node</b>: drag to shape the path, click to select only this node (more: Shift, Ctrl, Alt). %g power"),_pm().BSplineHandlePosition(h,h2));
}
}
diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp
index 64eba3921..8b735f3e6 100644
--- a/src/ui/tool/path-manipulator.cpp
+++ b/src/ui/tool/path-manipulator.cpp
@@ -670,7 +670,7 @@ unsigned PathManipulator::_deleteStretch(NodeList::iterator start, NodeList::ite
start = next;
}
// if we are removing, we readjust the handlers
- if(isBSpline(false)){
+ if(isBSpline()){
if(start.prev()){
start.prev()->front()->setPosition(BSplineHandleReposition(start.prev()->front(),start.prev()->back()));
}
@@ -999,7 +999,7 @@ NodeList::iterator PathManipulator::subdivideSegment(NodeList::iterator first, d
// set new handle positions
Node *n = new Node(_multi_path_manipulator._path_data.node_data, seg2[0]);
- if(!isBSpline(false)){
+ if(!isBSpline()){
n->back()->setPosition(seg1[2]);
n->front()->setPosition(seg2[1]);
n->setType(NODE_SMOOTH, false);
@@ -1240,17 +1240,29 @@ int PathManipulator::BSplineGetSteps() const {
// determines if the trace has bspline effect
bool PathManipulator::isBSpline(bool recalculate){
if(recalculate){
- _is_bspline = this->BSplineGetSteps() > 0;
+ SPLPEItem * path = dynamic_cast<SPLPEItem *>(_path);
+ if (path){
+ if(path->hasPathEffect()){
+ Inkscape::LivePathEffect::Effect const *thisEffect = path->getPathEffectOfType(Inkscape::LivePathEffect::BSPLINE);
+ if(thisEffect){
+ _is_bspline = true;
+ return _is_bspline;
+ }
+ }
+ }
+
}
+ _is_bspline = false;
return _is_bspline;
}
-bool PathManipulator::isBSpline(false) const {
- return BSplineGetSteps() > 0;
+bool PathManipulator::isBSpline() const {
+ return _is_bspline;
}
// returns the corresponding strength to the position of the handlers
-double PathManipulator::BSplineHandlePosition(Handle *h, Handle *h2){
+double PathManipulator::BSplineHandlePosition(Handle *h, Handle *h2)
+{
using Geom::X;
using Geom::Y;
if(h2){
@@ -1275,7 +1287,8 @@ double PathManipulator::BSplineHandlePosition(Handle *h, Handle *h2){
}
// give the location for the handler in the corresponding position
-Geom::Point PathManipulator::BSplineHandleReposition(Handle *h, Handle *h2){
+Geom::Point PathManipulator::BSplineHandleReposition(Handle *h, Handle *h2)
+{
double pos = this->BSplineHandlePosition(h, h2);
return BSplineHandleReposition(h,pos);
}