summaryrefslogtreecommitdiffstats
path: root/src/ui
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2013-12-30 19:41:32 +0000
committerJabiertxof <jtx@jtx.marker.es>2013-12-30 19:41:32 +0000
commit4c6918c72721a35e0347e9e087396238e72eb62e (patch)
tree22d7e8b0c0ecff9d8c6ff73ab0311a2fa9873ae7 /src/ui
parentRefactorizing (diff)
downloadinkscape-4c6918c72721a35e0347e9e087396238e72eb62e.tar.gz
inkscape-4c6918c72721a35e0347e9e087396238e72eb62e.zip
Refactorizing
(bzr r11950.1.212)
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/tool/curve-drag-point.cpp2
-rw-r--r--src/ui/tool/multi-path-manipulator.cpp3
-rw-r--r--src/ui/tool/multi-path-manipulator.h2
-rw-r--r--src/ui/tool/node.cpp21
-rw-r--r--src/ui/tool/node.h9
-rw-r--r--src/ui/tool/path-manipulator.cpp11
-rw-r--r--src/ui/tool/path-manipulator.h7
-rw-r--r--src/ui/tools/freehand-base.cpp8
-rw-r--r--src/ui/tools/freehand-base.h2
-rw-r--r--src/ui/tools/node-tool.h1
-rw-r--r--src/ui/tools/pen-tool.cpp74
-rw-r--r--src/ui/tools/pen-tool.h2
-rw-r--r--src/ui/tools/pencil-tool.cpp8
13 files changed, 29 insertions, 121 deletions
diff --git a/src/ui/tool/curve-drag-point.cpp b/src/ui/tool/curve-drag-point.cpp
index f847a6ab3..5387e597d 100644
--- a/src/ui/tool/curve-drag-point.cpp
+++ b/src/ui/tool/curve-drag-point.cpp
@@ -53,12 +53,10 @@ 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){
first->front()->move(first->front()->position() + delta);
second->back()->move(second->back()->position() - delta);
}
- //BSpline End
_pm.update();
} else {
_segment_was_degenerate = false;
diff --git a/src/ui/tool/multi-path-manipulator.cpp b/src/ui/tool/multi-path-manipulator.cpp
index 6da8b4104..3612f9c56 100644
--- a/src/ui/tool/multi-path-manipulator.cpp
+++ b/src/ui/tool/multi-path-manipulator.cpp
@@ -298,7 +298,6 @@ void MultiPathManipulator::invertSelectionInSubpaths()
invokeForAll(&PathManipulator::invertSelectionInSubpaths);
}
-
void MultiPathManipulator::setNodeType(NodeType type)
{
if (_selection.empty()) return;
@@ -327,7 +326,6 @@ void MultiPathManipulator::setNodeType(NodeType type)
_done(retract_handles ? _("Retract handles") : _("Change node type"));
}
-
void MultiPathManipulator::setSegmentType(SegmentType type)
{
if (_selection.empty()) return;
@@ -691,7 +689,6 @@ bool MultiPathManipulator::event(Inkscape::UI::Tools::ToolBase *event_context, G
deleteNodes(true);
}
else
- //BSpline end
deleteNodes(del_preserves_shape ^ held_control(event->key));
// Delete any selected gradient nodes as well
diff --git a/src/ui/tool/multi-path-manipulator.h b/src/ui/tool/multi-path-manipulator.h
index 4566a7a98..1328372c6 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 70e374424..7266c85bb 100644
--- a/src/ui/tool/node.cpp
+++ b/src/ui/tool/node.cpp
@@ -28,9 +28,7 @@
#include "ui/tool/node.h"
#include "ui/tool/path-manipulator.h"
#include <gdk/gdkkeysyms.h>
-
#include <math.h>
-;
namespace {
@@ -137,7 +135,7 @@ void Handle::move(Geom::Point const &new_pos)
Node *node_away = _parent->nodeAwayFrom(this); // node in the opposite direction
Handle *towards = node_towards ? node_towards->handleAwayFrom(_parent) : NULL;
Handle *towards_second = node_towards ? node_towards->handleToward(_parent) : NULL;
-
+
if (Geom::are_near(new_pos, _parent->position())) {
// The handle becomes degenerate.
// Adjust node type as necessary.
@@ -308,7 +306,6 @@ bool Handle::_eventHandler(Inkscape::UI::Tools::ToolBase *event_context, GdkEven
return ControlPoint::_eventHandler(event_context, event);
}
-
void Handle::handle_2button_press(){
if(_pm().isBSpline){
setPosition(_pm().BSplineHandleReposition(this,0.3334));
@@ -318,7 +315,6 @@ void Handle::handle_2button_press(){
}
}
-
bool Handle::grabbed(GdkEventMotion *)
{
_saved_other_pos = other()->position();
@@ -335,6 +331,7 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event)
SnapManager &sm = _desktop->namedview->snap_manager;
bool snap = held_shift(*event) ? false : sm.someSnapperMightSnap();
boost::optional<Inkscape::Snapper::SnapConstraint> ctrl_constraint;
+
// with Alt, preserve length
if (held_alt(*event)) {
new_pos = parent_pos + Geom::unit_vector(new_pos - parent_pos) * _saved_length;
@@ -366,14 +363,13 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event)
ctrl_constraint = Inkscape::Snapper::SnapConstraint(parent_pos, parent_pos - perp_pos);
}
new_pos = result;
-
+
if(_pm().isBSpline){
setPosition(new_pos);
int steps = _pm().BSplineGetSteps();
_parent->bsplineWeight = ceilf(_pm().BSplineHandlePosition(this)*steps)/steps;
new_pos=_pm().BSplineHandleReposition(this,_parent->bsplineWeight);
}
-
}
std::vector<Inkscape::SnapCandidatePoint> unselected;
@@ -627,22 +623,22 @@ void Node::move(Geom::Point const &new_pos)
// move handles when the node moves.
Geom::Point old_pos = position();
Geom::Point delta = new_pos - position();
-
+
double oldPos = 0.0000;
Node *n = this;
if(_pm().isBSpline){
oldPos = n->bsplineWeight;
}
-
+
setPosition(new_pos);
_front.setPosition(_front.position() + delta);
_back.setPosition(_back.position() + delta);
-
+
// if the node has a smooth handle after a line segment, it should be kept colinear
// with the segment
_fixNeighbors(old_pos, new_pos);
-
+
if(_pm().isBSpline){
_front.setPosition(_pm().BSplineHandleReposition(this->front(),oldPos));
_back.setPosition(_pm().BSplineHandleReposition(this->back(),oldPos));
@@ -774,6 +770,7 @@ void Node::setType(NodeType type, bool update_handles)
updateState(); // The size of the control might have changed
return;
}
+
// if update_handles is true, adjust handle positions to match the node type
// handle degenerate handles appropriately
if (update_handles) {
@@ -861,7 +858,6 @@ void Node::setType(NodeType type, bool update_handles)
_front.setPosition(_pm().BSplineHandleReposition(this->front(),this->bsplineWeight));
_back.setPosition(_pm().BSplineHandleReposition(this->back(),this->bsplineWeight));
}
-
}
_type = type;
_setControlType(nodeTypeToCtrlType(_type));
@@ -1124,7 +1120,6 @@ void Node::_setState(State state)
this->back()->setPosition(_pm().BSplineHandleReposition(this->back(),this->bsplineWeight));
}
}
-
break;
}
SelectableControlPoint::_setState(state);
diff --git a/src/ui/tool/node.h b/src/ui/tool/node.h
index d257db86a..01159e6a0 100644
--- a/src/ui/tool/node.h
+++ b/src/ui/tool/node.h
@@ -97,6 +97,7 @@ public:
virtual void setVisible(bool);
virtual void move(Geom::Point const &p);
+
virtual void setPosition(Geom::Point const &p);
inline void setRelativePos(Geom::Point const &p);
void setLength(double len);
@@ -112,28 +113,25 @@ public:
protected:
Handle(NodeSharedData const &data, Geom::Point const &initial_pos, Node *parent);
- //Bspline
virtual void handle_2button_press();
- //BSpline End
-
virtual bool _eventHandler(Inkscape::UI::Tools::ToolBase *event_context, GdkEvent *event);
-
virtual void dragged(Geom::Point &new_pos, GdkEventMotion *event);
virtual bool grabbed(GdkEventMotion *event);
virtual void ungrabbed(GdkEventButton *event);
virtual bool clicked(GdkEventButton *event);
-
virtual Glib::ustring _getTip(unsigned state) const;
virtual Glib::ustring _getDragTip(GdkEventMotion *event) const;
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
SPCtrlLine *_handle_line;
bool _degenerate; // True if the handle is retracted, i.e. has zero length. This is used often internally so it makes sense to cache this
+
/**
* Control point of a cubic Bezier curve in a path.
*
@@ -190,6 +188,7 @@ public:
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 4aec42100..4cb6ce296 100644
--- a/src/ui/tool/path-manipulator.cpp
+++ b/src/ui/tool/path-manipulator.cpp
@@ -43,10 +43,8 @@
#include "ui/tool/multi-path-manipulator.h"
#include "xml/node.h"
#include "xml/node-observer.h"
-
#include "live_effects/lpe-bspline.h"
-
namespace Inkscape {
namespace UI {
@@ -668,7 +666,6 @@ unsigned PathManipulator::_deleteStretch(NodeList::iterator start, NodeList::ite
nl.erase(start);
start = next;
}
-
if(isBSpline){
double pos = 0.0000;
if(start.prev()){
@@ -680,7 +677,6 @@ unsigned PathManipulator::_deleteStretch(NodeList::iterator start, NodeList::ite
end->back()->setPosition(BSplineHandleReposition(end->back(),pos));
}
}
-
return del_len;
}
@@ -856,9 +852,9 @@ 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();
-
gchar const *key = which < 0 ? "handle:rotate:left" : "handle:rotate:right";
_commit(_("Rotate handle"), key);
}
@@ -915,9 +911,7 @@ void PathManipulator::showHandles(bool show)
/** Set the visibility of outline. */
void PathManipulator::showOutline(bool show)
{
-
if(isBSpline) show = true;
-
if (show == _show_outline) return;
_show_outline = show;
_updateOutline();
@@ -1307,7 +1301,6 @@ void PathManipulator::_createGeometryFromControlPoints(bool alert_LPE)
build_segment(builder, prev.ptr(), i.ptr());
prev = i;
}
-
if (subpath->closed()) {
// Here we link the last and first node if the path is closed.
// If the last segment is Bezier, we add it.
@@ -1319,7 +1312,6 @@ void PathManipulator::_createGeometryFromControlPoints(bool alert_LPE)
}
++spi;
}
-
builder.finish();
Geom::PathVector pathv = builder.peek() * (_edit_transform * _i2d_transform).inverse();
_spcurve->set_pathvector(pathv);
@@ -1380,6 +1372,7 @@ void PathManipulator::_updateOutline()
sp_canvas_item_hide(_outline);
return;
}
+
Geom::PathVector pv = _spcurve->get_pathvector();
pv *= (_edit_transform * _i2d_transform);
// This SPCurve thing has to be killed with extreme prejudice
diff --git a/src/ui/tool/path-manipulator.h b/src/ui/tool/path-manipulator.h
index 547e687a7..31cc0d1fd 100644
--- a/src/ui/tool/path-manipulator.h
+++ b/src/ui/tool/path-manipulator.h
@@ -19,10 +19,8 @@
#include <boost/weak_ptr.hpp>
#include "ui/tool/node.h"
#include "ui/tool/manipulator.h"
-
#include "live_effects/lpe-bspline.h"
-
struct SPCanvasItem;
class SPCurve;
class SPPath;
@@ -97,10 +95,9 @@ public:
NodeList::iterator subdivideSegment(NodeList::iterator after, double t);
NodeList::iterator extremeNode(NodeList::iterator origin, bool search_selected,
bool search_unselected, bool closest);
-
+
bool isBSpline;
int BSplineGetSteps();
-
// this is necessary for Tab-selection in MultiPathManipulator
SubpathList &subpathList() { return _subpaths; }
@@ -110,13 +107,11 @@ private:
typedef boost::shared_ptr<NodeList> SubpathPtr;
void _createControlPointsFromGeometry();
-
void BSpline();
double BSplineHandlePosition(Handle *h);
Geom::Point BSplineHandleReposition(Handle *h);
Geom::Point BSplineHandleReposition(Handle *h,double pos);
void BSplineNodeHandlesReposition(Node *n);
-
void _createGeometryFromControlPoints(bool alert_LPE = false);
unsigned _deleteStretch(NodeList::iterator first, NodeList::iterator last, bool keep_shape);
std::string _createTypeString();
diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp
index 14a5b5b35..b6efaebd9 100644
--- a/src/ui/tools/freehand-base.cpp
+++ b/src/ui/tools/freehand-base.cpp
@@ -247,12 +247,10 @@ static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item,
if (prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1) {
Effect::createAndApply(SPIRO, dc->desktop->doc(), item);
}
- //BSpline
//Añadimos el modo BSpline a los efectos en espera
if (prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2) {
Effect::createAndApply(BSPLINE, dc->desktop->doc(), item);
}
- //BSPline End
int shape = prefs->getInt(tool_name(dc) + "/shape", 0);
bool shape_applied = false;
@@ -489,7 +487,6 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed)
dc->red_curve->reset();
sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(dc->red_bpath), NULL);
-
if (c->is_empty()) {
c->unref();
return;
@@ -520,7 +517,6 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed)
dc->sa->curve->append_continuous(c, 0.0625);
c->unref();
dc->sa->curve->closepath_current();
- //BSpline
//Si la curva tiene un LPE del tipo BSpline ejecutamos spdc_flush_white
//pasándole la curva de inicio necesaria
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
@@ -529,7 +525,6 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed)
dc->white_curves = g_slist_remove(dc->white_curves, dc->sa->curve);
spdc_flush_white(dc, dc->sa->curve);
}else
- //BSpline End
spdc_flush_white(dc, NULL);
return;
}
@@ -657,7 +652,6 @@ SPDrawAnchor *spdc_test_inside(FreehandBase *dc, Geom::Point p)
}
}
- //BSpline
//Modificamos la curva del "anchor" final para que sea igual que la curva de inicio.
//Esta curva fue modificada al continuar la curva y necesitamos que sea igual que la curva en
//la que cerramos el trazado.
@@ -670,7 +664,6 @@ SPDrawAnchor *spdc_test_inside(FreehandBase *dc, Geom::Point p)
active->curve->ref();
}
}
- //BSpline End
return active;
}
@@ -815,4 +808,3 @@ void spdc_create_single_dot(ToolBase *ec, Geom::Point const &pt, char const *too
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
-
diff --git a/src/ui/tools/freehand-base.h b/src/ui/tools/freehand-base.h
index 7d60e217f..7e53684e3 100644
--- a/src/ui/tools/freehand-base.h
+++ b/src/ui/tools/freehand-base.h
@@ -57,7 +57,6 @@ public:
SPCanvasItem *blue_bpath;
SPCurve *blue_curve;
-
// Green
GSList *green_bpaths;
SPCurve *green_curve;
@@ -143,4 +142,3 @@ void spdc_create_single_dot(ToolBase *ec, Geom::Point const &pt, char const *too
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
-
diff --git a/src/ui/tools/node-tool.h b/src/ui/tools/node-tool.h
index b3acb79ad..4d15ab70e 100644
--- a/src/ui/tools/node-tool.h
+++ b/src/ui/tools/node-tool.h
@@ -14,7 +14,6 @@
#include <boost/ptr_container/ptr_map.hpp>
#include <glib.h>
#include "ui/tools/tool-base.h"
-#include "selection.h"
namespace Inkscape {
namespace Display {
diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp
index 178a940a2..f8d8d4c90 100644
--- a/src/ui/tools/pen-tool.cpp
+++ b/src/ui/tools/pen-tool.cpp
@@ -1,4 +1,4 @@
- /** \file
+/** \file
* Pen event context implementation.
*/
@@ -20,7 +20,6 @@
#include <cstring>
#include <string>
-
#include "ui/tools/pen-tool.h"
#include "sp-namedview.h"
#include "desktop.h"
@@ -43,7 +42,6 @@
#include "context-fns.h"
#include "tools-switch.h"
#include "ui/control-manager.h"
-//BSpline
//Incluimos los archivos necesarios para las BSpline y Spiro
#define INKSCAPE_LPE_SPIRO_C
#include "live_effects/lpe-spiro.h"
@@ -64,11 +62,9 @@
#include "live_effects/spiro.h"
-
#define INKSCAPE_LPE_BSPLINE_C
#include "live_effects/lpe-bspline.h"
#include <2geom/nearest-point.h>
-//BSpline End
#include "tool-factory.h"
@@ -80,10 +76,6 @@ namespace UI {
namespace Tools {
static void spdc_pen_set_initial_point(PenTool *pc, Geom::Point const p);
-/*
- *BSpline
- *Added functions
-*/
//Añade los modos spiro y bspline
static void sp_pen_context_set_mode(PenTool *const pc, guint mode);
//Esta función cambia los colores rojo,verde y azul haciendolos transparentes o no en función de si se usa spiro
@@ -112,7 +104,7 @@ static void bspline_spiro_build(PenTool *const pc);
static void bspline_doEffect(SPCurve * curve);
//function spiro cloned from lpe-spiro.cpp
static void spiro_doEffect(SPCurve * curve);
-//BSpline end
+
static void spdc_pen_set_subsequent_point(PenTool *const pc, Geom::Point const p, bool statusbar, guint status = 0);
static void spdc_pen_set_ctrl(PenTool *pc, Geom::Point const p, guint state);
static void spdc_pen_finish_segment(PenTool *pc, Geom::Point p, guint state);
@@ -205,14 +197,11 @@ void sp_pen_context_set_polyline_mode(PenTool *const pc) {
guint mode = prefs->getInt("/tools/freehand/pen/freehand-mode", 0);
pc->polylines_only = (mode == 3 || mode == 4);
pc->polylines_paraxial = (mode == 4);
- //BSpline
//we call the function which defines the Spiro modes and the BSpline
//todo: merge to one function only
sp_pen_context_set_mode(pc, mode);
- //BSpline End
}
-//BSpline
/*
*.Set the mode of draw spiro, and bsplines
*/
@@ -220,7 +209,6 @@ void sp_pen_context_set_mode(PenTool *const pc, guint mode) {
pc->spiro = (mode == 1);
pc->bspline = (mode == 2);
}
-//BSpline End
/**
* Callback to initialize PenTool object.
@@ -422,12 +410,11 @@ static gint pen_handle_button_press(PenTool *const pc, GdkEventButton const &bev
if(!bevent.button == 3 && (pc->spiro || pc->bspline) && pc->npoints > 0 && pc->p[0] == pc->p[3]){
return FALSE;
}
- //BSpline end
gint ret = FALSE;
if (bevent.button == 1 && !event_context->space_panning
// make sure this is not the last click for a waiting LPE (otherwise we want to finish the path)
- && (pc->expecting_clicks_for_LPE != 1)) {
+ && pc->expecting_clicks_for_LPE != 1) {
if (Inkscape::have_viable_layer(desktop, dc->message_context) == false) {
return TRUE;
@@ -487,12 +474,10 @@ static gint pen_handle_button_press(PenTool *const pc, GdkEventButton const &bev
// Set start anchor
pc->sa = anchor;
- //BSpline
//Continuamos una curva existente
if(anchor){
bspline_spiro_start_anchor(pc,(bevent.state & GDK_SHIFT_MASK));
}
- //BSpline End
if (anchor && !sp_pen_context_has_waiting_LPE(pc)) {
// Adjust point to anchor if needed; if we have a waiting LPE, we need
// a fresh path to be created so don't continue an existing one
@@ -544,10 +529,8 @@ static gint pen_handle_button_press(PenTool *const pc, GdkEventButton const &bev
}
}
- //BSpline
//Evitamos la creación de un punto de control para que se cree el nodo en el evento de soltar
pc->state = (pc->spiro || pc->bspline || pc->polylines_only) ? PenTool::POINT : PenTool::CONTROL;
- //BSpline End
ret = TRUE;
break;
@@ -585,6 +568,7 @@ static gint pen_handle_button_press(PenTool *const pc, GdkEventButton const &bev
if (pc->expecting_clicks_for_LPE > 0) {
--pc->expecting_clicks_for_LPE;
}
+
return ret;
}
@@ -609,8 +593,7 @@ static gint pen_handle_motion_notify(PenTool *const pc, GdkEventMotion const &me
}
Geom::Point const event_w(mevent.x,
- mevent.y);
- //BSpline
+ mevent.y);
//we take out the function the const "tolerance" because we need it later
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
gint const tolerance = prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100);
@@ -620,7 +603,6 @@ static gint pen_handle_motion_notify(PenTool *const pc, GdkEventMotion const &me
return FALSE; // Do not drag if we're within tolerance from origin.
}
}
- //BSpline END
// Once the user has moved farther than tolerance from the original location
// (indicating they intend to move the object, not click), then always process the
// motion notify coordinates as given (no snapping back to origin)
@@ -736,7 +718,6 @@ static gint pen_handle_motion_notify(PenTool *const pc, GdkEventMotion const &me
default:
break;
}
- //BSpline
//Lanzamos la función "bspline_spiro_motion" al moverse el ratón o cuando se para.
if(pc->bspline){
bspline_spiro_color(pc);
@@ -748,7 +729,7 @@ static gint pen_handle_motion_notify(PenTool *const pc, GdkEventMotion const &me
pen_drag_origin_w = event_w;
}
}
- //BSpline End
+
return ret;
}
@@ -761,7 +742,7 @@ static gint pen_handle_button_release(PenTool *const pc, GdkEventButton const &r
// skip event processing if events are disabled
return FALSE;
}
-
+
gint ret = FALSE;
ToolBase *event_context = SP_EVENT_CONTEXT(pc);
@@ -776,7 +757,6 @@ static gint pen_handle_button_release(PenTool *const pc, GdkEventButton const &r
// Test whether we hit any anchor.
SPDrawAnchor *anchor = spdc_test_inside(pc, event_w);
- //BSpline
//with this we avoid creating a new point over the existing one
if(pc->spiro || pc->bspline){
//Si intentamos crear un nodo en el mismo sitio que el origen, paramos.
@@ -784,7 +764,7 @@ static gint pen_handle_button_release(PenTool *const pc, GdkEventButton const &r
return FALSE;
}
}
- //BSpline End
+
switch (pc->mode) {
case PenTool::MODE_CLICK:
switch (pc->state) {
@@ -795,14 +775,12 @@ static gint pen_handle_button_release(PenTool *const pc, GdkEventButton const &r
p = anchor->dp;
}
pc->sa = anchor;
- //BSpline
//continuamos una curva existente
if (anchor) {
if(pc->bspline || pc->spiro){
bspline_spiro_start_anchor(pc,(revent.state & GDK_SHIFT_MASK));
}
}
- //BSpline End
spdc_pen_set_initial_point(pc, p);
} else {
// Set end anchor here
@@ -827,12 +805,10 @@ static gint pen_handle_button_release(PenTool *const pc, GdkEventButton const &r
spdc_endpoint_snap(pc, p, revent.state);
}
spdc_pen_finish_segment(pc, p, revent.state);
- //BSpline
//Ocultamos la guia del penultimo nodo al cerrar la curva
if(pc->spiro){
sp_canvas_item_hide(pc->c1);
}
- //BSpline End
spdc_pen_finish(pc, TRUE);
pc->state = PenTool::POINT;
ret = TRUE;
@@ -856,12 +832,10 @@ static gint pen_handle_button_release(PenTool *const pc, GdkEventButton const &r
case PenTool::CLOSE:
spdc_endpoint_snap(pc, p, revent.state);
spdc_pen_finish_segment(pc, p, revent.state);
- //BSpline
//Ocultamos la guia del penultimo nodo al cerrar la curva
if(pc->spiro){
sp_canvas_item_hide(pc->c1);
}
- //BSpline End
if (pc->green_closed) {
// finishing at the start anchor, close curve
spdc_pen_finish(pc, TRUE);
@@ -873,7 +847,7 @@ static gint pen_handle_button_release(PenTool *const pc, GdkEventButton const &r
case PenTool::STOP:
// This is allowed, if we just cancelled curve
break;
- default:
+ default:
break;
}
pc->state = PenTool::POINT;
@@ -911,6 +885,7 @@ static gint pen_handle_button_release(PenTool *const pc, GdkEventButton const &r
// handled in spdc_check_for_and_apply_waiting_LPE() in draw-context.cpp
}
}
+
return ret;
}
@@ -938,20 +913,20 @@ static void pen_redraw_all (PenTool *const pc)
SPCanvasItem *cshape = sp_canvas_bpath_new(sp_desktop_sketch(pc->desktop), pc->green_curve);
sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(cshape), pc->green_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(cshape), 0, SP_WIND_RULE_NONZERO);
+
pc->green_bpaths = g_slist_prepend(pc->green_bpaths, cshape);
}
if (pc->green_anchor)
SP_CTRL(pc->green_anchor->ctrl)->moveto(pc->green_anchor->dp);
+
pc->red_curve->reset();
pc->red_curve->moveto(pc->p[0]);
pc->red_curve->curveto(pc->p[1], pc->p[2], pc->p[3]);
sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(pc->red_bpath), pc->red_curve);
// handles
- //BSpline
//Ocultamos los tiradores en modo BSpline y spiro
if (pc->p[0] != pc->p[1] && !pc->spiro && !pc->bspline) {
- //BSpline End
SP_CTRL(pc->c1)->moveto(pc->p[1]);
pc->cl1->setCoords(pc->p[0], pc->p[1]);
sp_canvas_item_show(pc->c1);
@@ -964,12 +939,10 @@ static void pen_redraw_all (PenTool *const pc)
Geom::Curve const * last_seg = pc->green_curve->last_segment();
if (last_seg) {
Geom::CubicBezier const * cubic = dynamic_cast<Geom::CubicBezier const *>( last_seg );
- //BSpline
//Ocultamos los tiradores en modo BSpline y spiro
if ( cubic &&
(*cubic)[2] != pc->p[0] && !pc->spiro && !pc->bspline )
{
- //BSpline End
Geom::Point p2 = (*cubic)[2];
SP_CTRL(pc->c0)->moveto(p2);
pc->cl0->setCoords(p2, pc->p[0]);
@@ -980,15 +953,12 @@ static void pen_redraw_all (PenTool *const pc)
sp_canvas_item_hide(pc->cl0);
}
}
- //BSpline
+
//Simplemente redibujamos la spiro teniendo en cuenta si el nodo es cusp o symm.
//como es un redibujo simplemente no llamamos a la función global
//sino al final de esta
-
- //BSpline
//Lanzamos solamente el redibujado
bspline_spiro_build(pc);
- //BSpline End
}
static void pen_lastpoint_move (PenTool *const pc, gdouble x, gdouble y)
@@ -1019,11 +989,9 @@ static void pen_lastpoint_move_screen (PenTool *const pc, gdouble x, gdouble y)
static void pen_lastpoint_tocurve (PenTool *const pc)
{
- //BSpline
//Evitamos que si la "red_curve" tiene solo dos puntos -recta- no se pare aqui.
if (pc->npoints != 5 && !pc->spiro && !pc->bspline)
return;
- //BSpline
Geom::CubicBezier const * cubic;
pc->p[1] = pc->red_curve->last_segment()->initialPoint() + (1./3)* (Geom::Point)(pc->red_curve->last_segment()->finalPoint() - pc->red_curve->last_segment()->initialPoint());
//Modificamos el último segmento de la curva verde para que forme el tipo de nodo que deseamos
@@ -1070,13 +1038,11 @@ static void pen_lastpoint_tocurve (PenTool *const pc)
}
}
- //Spiro Live
pen_redraw_all(pc);
}
static void pen_lastpoint_toline (PenTool *const pc)
{
- //BSpline
//Evitamos que si la "red_curve" tiene solo dos puntos -recta- no se pare aqui.
if (pc->npoints != 5 && !pc->bspline)
return;
@@ -1312,7 +1278,6 @@ static gint pen_handle_key_press(PenTool *const pc, GdkEvent *event)
: pc->p[3]));
pc->npoints = 2;
- //BSpline
//Eliminamos el último segmento de la curva verde
if( pc->green_curve->get_segment_count() == 1){
pc->npoints = 5;
@@ -1335,16 +1300,13 @@ static gint pen_handle_key_press(PenTool *const pc, GdkEvent *event)
pc->p[1] = pc->p[0];
}
}
- //BSpline End
sp_canvas_item_hide(pc->cl0);
sp_canvas_item_hide(pc->cl1);
pc->state = PenTool::POINT;
spdc_pen_set_subsequent_point(pc, pt, true);
pen_last_paraxial_dir = !pen_last_paraxial_dir;
- //BSpline
//Redibujamos
bspline_spiro_build(pc);
- //BSpline End
ret = TRUE;
}
break;
@@ -1358,12 +1320,10 @@ static void spdc_reset_colors(PenTool *pc)
{
// Red
pc->red_curve->reset();
-
sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(pc->red_bpath), NULL);
// Blue
pc->blue_curve->reset();
sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(pc->blue_bpath), NULL);
-
// Green
while (pc->green_bpaths) {
sp_canvas_item_destroy(SP_CANVAS_ITEM(pc->green_bpaths->data));
@@ -2111,8 +2071,6 @@ static void spiro_doEffect(SPCurve * curve)
g_free (path);
}
-//BSpline end
-
static void spdc_pen_set_subsequent_point(PenTool *const pc, Geom::Point const p, bool statusbar, guint status)
{
g_assert( pc->npoints != 0 );
@@ -2139,9 +2097,7 @@ static void spdc_pen_set_subsequent_point(PenTool *const pc, Geom::Point const p
is_curve = false;
} else {
// one of the 'regular' modes
- //SpiroLive
if (pc->p[1] != pc->p[0] || pc->spiro) {
- //SpiroLive End
pc->red_curve->curveto(pc->p[1], p, p);
is_curve = true;
} else {
@@ -2156,13 +2112,11 @@ static void spdc_pen_set_subsequent_point(PenTool *const pc, Geom::Point const p
gchar *message = is_curve ?
_("<b>Curve segment</b>: angle %3.2f&#176;, distance %s; with <b>Ctrl</b> to snap angle, <b>Enter</b> to finish the path" ):
_("<b>Line segment</b>: angle %3.2f&#176;, distance %s; with <b>Ctrl</b> to snap angle, <b>Enter</b> to finish the path");
- //BSpline
if(pc->spiro || pc->bspline){
message = is_curve ?
_("<b>Curve segment</b>: angle %3.2f&#176;, distance %s; with <b>Shift</b> to cusp node, <b>Enter</b> to finish the path" ):
_("<b>Line segment</b>: angle %3.2f&#176;, distance %s; with <b>Shift</b> to cusp node, <b>Enter</b> to finish the path");
}
- //BSpline End
spdc_pen_set_angle_distance_status_message(pc, p, 0, message);
}
}
@@ -2369,5 +2323,3 @@ void pen_set_to_nearest_horiz_vert(const PenTool *const pc, Geom::Point &pt, gui
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
-
-
diff --git a/src/ui/tools/pen-tool.h b/src/ui/tools/pen-tool.h
index 553e4c557..b0b56feb4 100644
--- a/src/ui/tools/pen-tool.h
+++ b/src/ui/tools/pen-tool.h
@@ -48,11 +48,9 @@ public:
bool polylines_only;
bool polylines_paraxial;
- //SpiroLive
//Propiedad que guarda si el modo Spiro está activo o no
bool spiro;
bool bspline;
- //SpiroLIve End
int num_clicks;
unsigned int expecting_clicks_for_LPE; // if positive, finish the path after this many clicks
diff --git a/src/ui/tools/pencil-tool.cpp b/src/ui/tools/pencil-tool.cpp
index c10bd15a3..2027f0981 100644
--- a/src/ui/tools/pencil-tool.cpp
+++ b/src/ui/tools/pencil-tool.cpp
@@ -692,10 +692,8 @@ interpolate(PencilTool *pc)
return;
}
- //BSpline
using Geom::X;
using Geom::Y;
- //BSpline end
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
double const tol = prefs->getDoubleLimited("/tools/freehand/pencil/tolerance", 10.0, 1.0, 100.0) * 0.4;
@@ -727,12 +725,9 @@ interpolate(PencilTool *pc)
{
/* Fit and draw and reset state */
pc->green_curve->moveto(b[0]);
- //BSpline
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
guint mode = prefs->getInt("/tools/freehand/pencil/freehand-mode", 0);
- //BSpline End
for (int c = 0; c < n_segs; c++) {
- //BSpline
//Si el modo es BSpline modificamos para que el trazado cree los nodos adhoc
if(mode == 2){
Geom::Point BP = b[4*c+0] + (1./3)*(b[4*c+3] - b[4*c+0]);
@@ -743,7 +738,6 @@ interpolate(PencilTool *pc)
}else{
pc->green_curve->curveto(b[4*c+1], b[4*c+2], b[4*c+3]);
}
- //BSpline
}
sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(pc->red_bpath), pc->green_curve);
@@ -884,7 +878,6 @@ fit_and_split(PencilTool *pc)
/* Fit and draw and reset state */
pc->red_curve->reset();
pc->red_curve->moveto(b[0]);
- //BSpline
using Geom::X;
using Geom::Y;
//Si el modo es BSpline modificamos para que el trazado cree los nodos adhoc
@@ -899,7 +892,6 @@ fit_and_split(PencilTool *pc)
}else{
pc->red_curve->curveto(b[1], b[2], b[3]);
}
- //BSpline End
sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(pc->red_bpath), pc->red_curve);
pc->red_curve_is_valid = true;
} else {