summaryrefslogtreecommitdiffstats
path: root/src/pen-context.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/pen-context.cpp')
-rw-r--r--src/pen-context.cpp276
1 files changed, 143 insertions, 133 deletions
diff --git a/src/pen-context.cpp b/src/pen-context.cpp
index e251c1125..bb263382a 100644
--- a/src/pen-context.cpp
+++ b/src/pen-context.cpp
@@ -67,86 +67,89 @@
#include "live_effects/lpe-bspline.h"
#include <2geom/nearest-point.h>
//BSpline End
+
+#include "tool-factory.h"
+
+
using Inkscape::ControlManager;
-static void spdc_pen_set_initial_point(SPPenContext *pc, Geom::Point const p);
+namespace Inkscape {
+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(SPPenContext *const pc, guint mode);
+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
-static void bspline_spiro_color(SPPenContext *const pc);
+static void bspline_spiro_color(PenTool *const pc);
//Crea un nodo en modo bspline o spiro
-static void bspline_spiro(SPPenContext *const pc,bool shift);
+static void bspline_spiro(PenTool *const pc,bool shift);
//Crea un nodo de modo spiro o bspline
-static void bspline_spiro_on(SPPenContext *const pc);
+static void bspline_spiro_on(PenTool *const pc);
//Crea un nodo de tipo CUSP
-static void bspline_spiro_off(SPPenContext *const pc);
+static void bspline_spiro_off(PenTool *const pc);
//Continua una curva existente en modo bspline o spiro
-static void bspline_spiro_start_anchor(SPPenContext *const pc,bool shift);
+static void bspline_spiro_start_anchor(PenTool *const pc,bool shift);
//Continua una curva exsitente con el nodo de union en modo bspline o spiro
-static void bspline_spiro_start_anchor_on(SPPenContext *const pc);
+static void bspline_spiro_start_anchor_on(PenTool *const pc);
//Continua una curva existente con el nodo de union en modo CUSP
-static void bspline_spiro_start_anchor_off(SPPenContext *const pc);
+static void bspline_spiro_start_anchor_off(PenTool *const pc);
//Modifica la "red_curve" cuando se detecta movimiento
-static void bspline_spiro_motion(SPPenContext *const pc,bool shift);
+static void bspline_spiro_motion(PenTool *const pc,bool shift);
//Cierra la curva con el último nodo en modo bspline o spiro
-static void bspline_spiro_end_anchor_on(SPPenContext *const pc);
+static void bspline_spiro_end_anchor_on(PenTool *const pc);
//Cierra la curva con el último nodo en modo CUSP
-static void bspline_spiro_end_anchor_off(SPPenContext *const pc);
+static void bspline_spiro_end_anchor_off(PenTool *const pc);
//Unimos todas las curvas en juego y llamamos a la función doEffect.
-static void bspline_spiro_build(SPPenContext *const pc);
+static void bspline_spiro_build(PenTool *const pc);
//function bspline cloned from lpe-bspline.cpp
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);
+static void spdc_pen_finish(PenTool *pc, gboolean closed);
-static void spdc_pen_set_subsequent_point(SPPenContext *const pc, Geom::Point const p, bool statusbar, guint status = 0);
-static void spdc_pen_set_ctrl(SPPenContext *pc, Geom::Point const p, guint state);
-static void spdc_pen_finish_segment(SPPenContext *pc, Geom::Point p, guint state);
+static gint pen_handle_button_press(PenTool *const pc, GdkEventButton const &bevent);
+static gint pen_handle_motion_notify(PenTool *const pc, GdkEventMotion const &mevent);
+static gint pen_handle_button_release(PenTool *const pc, GdkEventButton const &revent);
+static gint pen_handle_2button_press(PenTool *const pc, GdkEventButton const &bevent);
+static gint pen_handle_key_press(PenTool *const pc, GdkEvent *event);
+static void spdc_reset_colors(PenTool *pc);
-static void spdc_pen_finish(SPPenContext *pc, gboolean closed);
-
-static gint pen_handle_button_press(SPPenContext *const pc, GdkEventButton const &bevent);
-static gint pen_handle_motion_notify(SPPenContext *const pc, GdkEventMotion const &mevent);
-static gint pen_handle_button_release(SPPenContext *const pc, GdkEventButton const &revent);
-static gint pen_handle_2button_press(SPPenContext *const pc, GdkEventButton const &bevent);
-static gint pen_handle_key_press(SPPenContext *const pc, GdkEvent *event);
-static void spdc_reset_colors(SPPenContext *pc);
-
-static void pen_disable_events(SPPenContext *const pc);
-static void pen_enable_events(SPPenContext *const pc);
+static void pen_disable_events(PenTool *const pc);
+static void pen_enable_events(PenTool *const pc);
static Geom::Point pen_drag_origin_w(0, 0);
static bool pen_within_tolerance = false;
-static int pen_next_paraxial_direction(const SPPenContext *const pc, Geom::Point const &pt, Geom::Point const &origin, guint state);
-static void pen_set_to_nearest_horiz_vert(const SPPenContext *const pc, Geom::Point &pt, guint const state, bool snap);
+static int pen_next_paraxial_direction(const PenTool *const pc, Geom::Point const &pt, Geom::Point const &origin, guint state);
+static void pen_set_to_nearest_horiz_vert(const PenTool *const pc, Geom::Point &pt, guint const state, bool snap);
static int pen_last_paraxial_dir = 0; // last used direction in horizontal/vertical mode; 0 = horizontal, 1 = vertical
-
-#include "tool-factory.h"
-
namespace {
- SPEventContext* createPenContext() {
- return new SPPenContext();
+ ToolBase* createPenContext() {
+ return new PenTool();
}
bool penContextRegistered = ToolFactory::instance().registerObject("/tools/freehand/pen", createPenContext);
}
-const std::string& SPPenContext::getPrefsPath() {
- return SPPenContext::prefsPath;
+const std::string& PenTool::getPrefsPath() {
+ return PenTool::prefsPath;
}
-const std::string SPPenContext::prefsPath = "/tools/freehand/pen";
+const std::string PenTool::prefsPath = "/tools/freehand/pen";
-SPPenContext::SPPenContext() : SPDrawContext() {
+PenTool::PenTool() : SPDrawContext() {
this->polylines_only = false;
this->polylines_paraxial = false;
this->expecting_clicks_for_LPE = 0;
@@ -171,7 +174,7 @@ SPPenContext::SPPenContext() : SPDrawContext() {
this->waiting_item = NULL;
}
-SPPenContext::~SPPenContext() {
+PenTool::~PenTool() {
if (this->c0) {
sp_canvas_item_destroy(this->c0);
this->c0 = NULL;
@@ -195,7 +198,7 @@ SPPenContext::~SPPenContext() {
}
}
-void sp_pen_context_set_polyline_mode(SPPenContext *const pc) {
+void sp_pen_context_set_polyline_mode(PenTool *const pc) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
guint mode = prefs->getInt("/tools/freehand/pen/freehand-mode", 0);
pc->polylines_only = (mode == 3 || mode == 4);
@@ -211,16 +214,16 @@ void sp_pen_context_set_polyline_mode(SPPenContext *const pc) {
/*
*.Set the mode of draw spiro, and bsplines
*/
-void sp_pen_context_set_mode(SPPenContext *const pc, guint mode) {
+void sp_pen_context_set_mode(PenTool *const pc, guint mode) {
pc->spiro = (mode == 1);
pc->bspline = (mode == 2);
}
//BSpline End
/**
- * Callback to initialize SPPenContext object.
+ * Callback to initialize PenTool object.
*/
-void SPPenContext::setup() {
+void PenTool::setup() {
SPDrawContext::setup();
ControlManager &mgr = ControlManager::getManager();
@@ -252,10 +255,10 @@ void SPPenContext::setup() {
}
}
-static void pen_cancel (SPPenContext *const pc)
+static void pen_cancel (PenTool *const pc)
{
pc->num_clicks = 0;
- pc->state = SPPenContext::STOP;
+ pc->state = PenTool::STOP;
spdc_reset_colors(pc);
sp_canvas_item_hide(pc->c0);
sp_canvas_item_hide(pc->c1);
@@ -270,7 +273,7 @@ static void pen_cancel (SPPenContext *const pc)
/**
* Finalization callback.
*/
-void SPPenContext::finish() {
+void PenTool::finish() {
sp_event_context_discard_delayed_snap_event(this);
if (this->npoints != 0) {
@@ -283,7 +286,7 @@ void SPPenContext::finish() {
/**
* Callback that sets key to value in pen context.
*/
-void SPPenContext::set(const Inkscape::Preferences::Entry& val) {
+void PenTool::set(const Inkscape::Preferences::Entry& val) {
Glib::ustring name = val.getEntryName();
if (name == "mode") {
@@ -298,7 +301,7 @@ void SPPenContext::set(const Inkscape::Preferences::Entry& val) {
/**
* Snaps new node relative to the previous node.
*/
-static void spdc_endpoint_snap(SPPenContext const *const pc, Geom::Point &p, guint const state)
+static void spdc_endpoint_snap(PenTool const *const pc, Geom::Point &p, guint const state)
{
if ((state & GDK_CONTROL_MASK) && !pc->polylines_paraxial) { //CTRL enables angular snapping
if (pc->npoints > 0) {
@@ -322,7 +325,7 @@ static void spdc_endpoint_snap(SPPenContext const *const pc, Geom::Point &p, gui
/**
* Snaps new node's handle relative to the new node.
*/
-static void spdc_endpoint_snap_handle(SPPenContext const *const pc, Geom::Point &p, guint const state)
+static void spdc_endpoint_snap_handle(PenTool const *const pc, Geom::Point &p, guint const state)
{
g_return_if_fail(( pc->npoints == 2 ||
pc->npoints == 5 ));
@@ -337,7 +340,7 @@ static void spdc_endpoint_snap_handle(SPPenContext const *const pc, Geom::Point
}
}
-bool SPPenContext::item_handler(SPItem* item, GdkEvent* event) {
+bool PenTool::item_handler(SPItem* item, GdkEvent* event) {
gint ret = FALSE;
switch (event->type) {
@@ -361,7 +364,7 @@ bool SPPenContext::item_handler(SPItem* item, GdkEvent* event) {
/**
* Callback to handle all pen events.
*/
-bool SPPenContext::root_handler(GdkEvent* event) {
+bool PenTool::root_handler(GdkEvent* event) {
gint ret = FALSE;
switch (event->type) {
@@ -399,7 +402,7 @@ bool SPPenContext::root_handler(GdkEvent* event) {
/**
* Handle mouse button press event.
*/
-static gint pen_handle_button_press(SPPenContext *const pc, GdkEventButton const &bevent)
+static gint pen_handle_button_press(PenTool *const pc, GdkEventButton const &bevent)
{
if (pc->events_disabled) {
// skip event processing if events are disabled
@@ -410,7 +413,7 @@ static gint pen_handle_button_press(SPPenContext *const pc, GdkEventButton const
SPDesktop * const desktop = SP_EVENT_CONTEXT_DESKTOP(dc);
Geom::Point const event_w(bevent.x, bevent.y);
Geom::Point event_dt(desktop->w2d(event_w));
- SPEventContext *event_context = SP_EVENT_CONTEXT(pc);
+ ToolBase *event_context = SP_EVENT_CONTEXT(pc);
//Test whether we hit any anchor.
SPDrawAnchor * const anchor = spdc_test_inside(pc, event_w);
//with this we avoid creating a new point over the existing one
@@ -418,6 +421,7 @@ static gint pen_handle_button_press(SPPenContext *const pc, GdkEventButton const
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)
@@ -440,27 +444,26 @@ static gint pen_handle_button_press(SPPenContext *const pc, GdkEventButton const
pen_within_tolerance = true;
switch (pc->mode) {
- case SPPenContext::MODE_CLICK:
+ case PenTool::MODE_CLICK:
// In click mode we add point on release
switch (pc->state) {
- case SPPenContext::POINT:
- case SPPenContext::CONTROL:
- case SPPenContext::CLOSE:
+ case PenTool::POINT:
+ case PenTool::CONTROL:
+ case PenTool::CLOSE:
break;
- case SPPenContext::STOP:
+ case PenTool::STOP:
// This is allowed, if we just canceled curve
- pc->state = SPPenContext::POINT;
+ pc->state = PenTool::POINT;
break;
default:
break;
}
break;
- case SPPenContext::MODE_DRAG:
+ case PenTool::MODE_DRAG:
switch (pc->state) {
- case SPPenContext::STOP:
+ case PenTool::STOP:
// This is allowed, if we just canceled curve
-
- case SPPenContext::POINT:
+ case PenTool::POINT:
if (pc->npoints == 0) {
Geom::Point p;
@@ -522,7 +525,7 @@ static gint pen_handle_button_press(SPPenContext *const pc, GdkEventButton const
p = anchor->dp;
// we hit an anchor, will finish the curve (either with or without closing)
// in release handler
- pc->state = SPPenContext::CLOSE;
+ pc->state = PenTool::CLOSE;
if (pc->green_anchor && pc->green_anchor->active) {
// we clicked on the current curve start, so close it even if
@@ -541,15 +544,15 @@ static gint pen_handle_button_press(SPPenContext *const pc, GdkEventButton const
//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) ? SPPenContext::POINT : SPPenContext::CONTROL;
+ pc->state = (pc->spiro || pc->bspline || pc->polylines_only) ? PenTool::POINT : PenTool::CONTROL;
//BSpline End
ret = TRUE;
break;
- case SPPenContext::CONTROL:
+ case PenTool::CONTROL:
g_warning("Button down in CONTROL state");
break;
- case SPPenContext::CLOSE:
+ case PenTool::CLOSE:
g_warning("Button down in CLOSE state");
break;
default:
@@ -586,11 +589,11 @@ static gint pen_handle_button_press(SPPenContext *const pc, GdkEventButton const
/**
* Handle motion_notify event.
*/
-static gint pen_handle_motion_notify(SPPenContext *const pc, GdkEventMotion const &mevent)
+static gint pen_handle_motion_notify(PenTool *const pc, GdkEventMotion const &mevent)
{
gint ret = FALSE;
- SPEventContext *event_context = SP_EVENT_CONTEXT(pc);
+ ToolBase *event_context = SP_EVENT_CONTEXT(pc);
SPDesktop * const dt = SP_EVENT_CONTEXT_DESKTOP(event_context);
if (event_context->space_panning || mevent.state & GDK_BUTTON2_MASK || mevent.state & GDK_BUTTON3_MASK) {
@@ -626,9 +629,9 @@ static gint pen_handle_motion_notify(SPPenContext *const pc, GdkEventMotion cons
// Test, whether we hit any anchor
SPDrawAnchor *anchor = spdc_test_inside(pc, event_w);
switch (pc->mode) {
- case SPPenContext::MODE_CLICK:
+ case PenTool::MODE_CLICK:
switch (pc->state) {
- case SPPenContext::POINT:
+ case PenTool::POINT:
if ( pc->npoints != 0 ) {
// Only set point, if we are already appending
spdc_endpoint_snap(pc, p, mevent.state);
@@ -641,23 +644,23 @@ static gint pen_handle_motion_notify(SPPenContext *const pc, GdkEventMotion cons
m.unSetup();
}
break;
- case SPPenContext::CONTROL:
- case SPPenContext::CLOSE:
+ case PenTool::CONTROL:
+ case PenTool::CLOSE:
// Placing controls is last operation in CLOSE state
spdc_endpoint_snap(pc, p, mevent.state);
spdc_pen_set_ctrl(pc, p, mevent.state);
ret = TRUE;
break;
- case SPPenContext::STOP:
+ case PenTool::STOP:
// This is perfectly valid
break;
default:
break;
}
break;
- case SPPenContext::MODE_DRAG:
+ case PenTool::MODE_DRAG:
switch (pc->state) {
- case SPPenContext::POINT:
+ case PenTool::POINT:
if ( pc->npoints > 0 ) {
// Only set point, if we are already appending
@@ -701,8 +704,8 @@ static gint pen_handle_motion_notify(SPPenContext *const pc, GdkEventMotion cons
}
}
break;
- case SPPenContext::CONTROL:
- case SPPenContext::CLOSE:
+ case PenTool::CONTROL:
+ case PenTool::CLOSE:
// Placing controls is last operation in CLOSE state
// snap the handle
spdc_endpoint_snap_handle(pc, p, mevent.state);
@@ -715,7 +718,7 @@ static gint pen_handle_motion_notify(SPPenContext *const pc, GdkEventMotion cons
gobble_motion_events(GDK_BUTTON1_MASK);
ret = TRUE;
break;
- case SPPenContext::STOP:
+ case PenTool::STOP:
// This is perfectly valid
break;
default:
@@ -750,7 +753,7 @@ static gint pen_handle_motion_notify(SPPenContext *const pc, GdkEventMotion cons
/**
* Handle mouse button release event.
*/
-static gint pen_handle_button_release(SPPenContext *const pc, GdkEventButton const &revent)
+static gint pen_handle_button_release(PenTool *const pc, GdkEventButton const &revent)
{
if (pc->events_disabled) {
// skip event processing if events are disabled
@@ -758,8 +761,10 @@ static gint pen_handle_button_release(SPPenContext *const pc, GdkEventButton con
}
gint ret = FALSE;
- SPEventContext *event_context = SP_EVENT_CONTEXT(pc);
- if ( revent.button == 1 && !event_context->space_panning ) {
+
+ ToolBase *event_context = SP_EVENT_CONTEXT(pc);
+ if ( revent.button == 1 && !event_context->space_panning) {
+
SPDrawContext *dc = SP_DRAW_CONTEXT (pc);
Geom::Point const event_w(revent.x,
@@ -779,9 +784,9 @@ static gint pen_handle_button_release(SPPenContext *const pc, GdkEventButton con
}
//BSpline End
switch (pc->mode) {
- case SPPenContext::MODE_CLICK:
+ case PenTool::MODE_CLICK:
switch (pc->state) {
- case SPPenContext::POINT:
+ case PenTool::POINT:
if ( pc->npoints == 0 ) {
// Start new thread only with button release
if (anchor) {
@@ -804,17 +809,17 @@ static gint pen_handle_button_release(SPPenContext *const pc, GdkEventButton con
p = anchor->dp;
}
}
- pc->state = SPPenContext::CONTROL;
+ pc->state = PenTool::CONTROL;
ret = TRUE;
break;
- case SPPenContext::CONTROL:
+ case PenTool::CONTROL:
// End current segment
spdc_endpoint_snap(pc, p, revent.state);
spdc_pen_finish_segment(pc, p, revent.state);
- pc->state = SPPenContext::POINT;
+ pc->state = PenTool::POINT;
ret = TRUE;
break;
- case SPPenContext::CLOSE:
+ case PenTool::CLOSE:
// End current segment
if (!anchor) { // Snap node only if not hitting anchor
spdc_endpoint_snap(pc, p, revent.state);
@@ -827,26 +832,26 @@ static gint pen_handle_button_release(SPPenContext *const pc, GdkEventButton con
}
//BSpline End
spdc_pen_finish(pc, TRUE);
- pc->state = SPPenContext::POINT;
+ pc->state = PenTool::POINT;
ret = TRUE;
break;
- case SPPenContext::STOP:
+ case PenTool::STOP:
// This is allowed, if we just canceled curve
- pc->state = SPPenContext::POINT;
+ pc->state = PenTool::POINT;
ret = TRUE;
break;
default:
break;
}
break;
- case SPPenContext::MODE_DRAG:
+ case PenTool::MODE_DRAG:
switch (pc->state) {
- case SPPenContext::POINT:
- case SPPenContext::CONTROL:
+ case PenTool::POINT:
+ case PenTool::CONTROL:
spdc_endpoint_snap(pc, p, revent.state);
spdc_pen_finish_segment(pc, p, revent.state);
break;
- case SPPenContext::CLOSE:
+ case PenTool::CLOSE:
spdc_endpoint_snap(pc, p, revent.state);
spdc_pen_finish_segment(pc, p, revent.state);
//BSpline
@@ -863,13 +868,13 @@ static gint pen_handle_button_release(SPPenContext *const pc, GdkEventButton con
spdc_pen_finish(pc, FALSE);
}
break;
- case SPPenContext::STOP:
+ case PenTool::STOP:
// This is allowed, if we just cancelled curve
break;
default:
break;
}
- pc->state = SPPenContext::POINT;
+ pc->state = PenTool::POINT;
ret = TRUE;
break;
default:
@@ -891,7 +896,7 @@ static gint pen_handle_button_release(SPPenContext *const pc, GdkEventButton con
if (pc->expecting_clicks_for_LPE == 0 && sp_pen_context_has_waiting_LPE(pc)) {
sp_pen_context_set_polyline_mode(pc);
- SPEventContext *ec = SP_EVENT_CONTEXT(pc);
+ ToolBase *ec = SP_EVENT_CONTEXT(pc);
Inkscape::Selection *selection = sp_desktop_selection (ec->desktop);
if (pc->waiting_LPE) {
@@ -907,7 +912,7 @@ static gint pen_handle_button_release(SPPenContext *const pc, GdkEventButton con
return ret;
}
-static gint pen_handle_2button_press(SPPenContext *const pc, GdkEventButton const &bevent)
+static gint pen_handle_2button_press(PenTool *const pc, GdkEventButton const &bevent)
{
gint ret = FALSE;
// only end on LMB double click. Otherwise horizontal scrolling causes ending of the path
@@ -918,7 +923,7 @@ static gint pen_handle_2button_press(SPPenContext *const pc, GdkEventButton cons
return ret;
}
-static void pen_redraw_all (SPPenContext *const pc)
+static void pen_redraw_all (PenTool *const pc)
{
// green
if (pc->green_bpaths) {
@@ -984,7 +989,7 @@ static void pen_redraw_all (SPPenContext *const pc)
//BSpline End
}
-static void pen_lastpoint_move (SPPenContext *const pc, gdouble x, gdouble y)
+static void pen_lastpoint_move (PenTool *const pc, gdouble x, gdouble y)
{
if (pc->npoints != 5)
return;
@@ -1005,12 +1010,12 @@ static void pen_lastpoint_move (SPPenContext *const pc, gdouble x, gdouble y)
pen_redraw_all(pc);
}
-static void pen_lastpoint_move_screen (SPPenContext *const pc, gdouble x, gdouble y)
+static void pen_lastpoint_move_screen (PenTool *const pc, gdouble x, gdouble y)
{
pen_lastpoint_move (pc, x / pc->desktop->current_zoom(), y / pc->desktop->current_zoom());
}
-static void pen_lastpoint_tocurve (SPPenContext *const pc)
+static void pen_lastpoint_tocurve (PenTool *const pc)
{
//BSpline
//Evitamos que si la "red_curve" tiene solo dos puntos -recta- no se pare aqui.
@@ -1067,7 +1072,7 @@ static void pen_lastpoint_tocurve (SPPenContext *const pc)
pen_redraw_all(pc);
}
-static void pen_lastpoint_toline (SPPenContext *const 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.
@@ -1117,7 +1122,7 @@ static void pen_lastpoint_toline (SPPenContext *const pc)
}
-static gint pen_handle_key_press(SPPenContext *const pc, GdkEvent *event)
+static gint pen_handle_key_press(PenTool *const pc, GdkEvent *event)
{
gint ret = FALSE;
@@ -1331,7 +1336,7 @@ static gint pen_handle_key_press(SPPenContext *const pc, GdkEvent *event)
//BSpline End
sp_canvas_item_hide(pc->cl0);
sp_canvas_item_hide(pc->cl1);
- pc->state = SPPenContext::POINT;
+ pc->state = PenTool::POINT;
spdc_pen_set_subsequent_point(pc, pt, true);
pen_last_paraxial_dir = !pen_last_paraxial_dir;
//BSpline
@@ -1347,7 +1352,7 @@ static gint pen_handle_key_press(SPPenContext *const pc, GdkEvent *event)
return ret;
}
-static void spdc_reset_colors(SPPenContext *pc)
+static void spdc_reset_colors(PenTool *pc)
{
// Red
pc->red_curve->reset();
@@ -1373,7 +1378,7 @@ static void spdc_reset_colors(SPPenContext *pc)
}
-static void spdc_pen_set_initial_point(SPPenContext *const pc, Geom::Point const p)
+static void spdc_pen_set_initial_point(PenTool *const pc, Geom::Point const p)
{
g_assert( pc->npoints == 0 );
@@ -1390,7 +1395,7 @@ static void spdc_pen_set_initial_point(SPPenContext *const pc, Geom::Point const
* This type of message always shows angle/distance as the last
* two parameters ("angle %3.2f&#176;, distance %s").
*/
-static void spdc_pen_set_angle_distance_status_message(SPPenContext *const pc, Geom::Point const p, int pc_point_to_compare, gchar const *message)
+static void spdc_pen_set_angle_distance_status_message(PenTool *const pc, Geom::Point const p, int pc_point_to_compare, gchar const *message)
{
g_assert(pc != NULL);
g_assert((pc_point_to_compare == 0) || (pc_point_to_compare == 3)); // exclude control handles
@@ -1413,8 +1418,9 @@ static void spdc_pen_set_angle_distance_status_message(SPPenContext *const pc, G
g_string_free(dist, FALSE);
}
+
//Esta función cambia los colores rojo,verde y azul haciendolos transparentes o no en función de si se usa spiro
-static void bspline_spiro_color(SPPenContext *const pc)
+static void bspline_spiro_color(PenTool *const pc)
{
bool remake_green_bpaths = false;
if(pc->spiro){
@@ -1459,7 +1465,7 @@ static void bspline_spiro_color(SPPenContext *const pc)
}
-static void bspline_spiro(SPPenContext *const pc, bool shift)
+static void bspline_spiro(PenTool *const pc, bool shift)
{
if(!pc->spiro && !pc->bspline)
return;
@@ -1470,7 +1476,7 @@ static void bspline_spiro(SPPenContext *const pc, bool shift)
bspline_spiro_build(pc);
}
-static void bspline_spiro_on(SPPenContext *const pc)
+static void bspline_spiro_on(PenTool *const pc)
{
if(!pc->red_curve->is_empty()){
using Geom::X;
@@ -1483,7 +1489,7 @@ static void bspline_spiro_on(SPPenContext *const pc)
}
}
-static void bspline_spiro_off(SPPenContext *const pc)
+static void bspline_spiro_off(PenTool *const pc)
{
if(!pc->red_curve->is_empty()){
pc->npoints = 5;
@@ -1493,7 +1499,7 @@ static void bspline_spiro_off(SPPenContext *const pc)
}
}
-static void bspline_spiro_start_anchor(SPPenContext *const pc, bool shift)
+static void bspline_spiro_start_anchor(PenTool *const pc, bool shift)
{
if(!pc->spiro && !pc->bspline)
return;
@@ -1507,7 +1513,7 @@ static void bspline_spiro_start_anchor(SPPenContext *const pc, bool shift)
bspline_spiro_start_anchor_on(pc);
}
-static void bspline_spiro_start_anchor_on(SPPenContext *const pc)
+static void bspline_spiro_start_anchor_on(PenTool *const pc)
{
using Geom::X;
using Geom::Y;
@@ -1543,7 +1549,7 @@ static void bspline_spiro_start_anchor_on(SPPenContext *const pc)
pc->sa->curve = tmpCurve;
}
-static void bspline_spiro_start_anchor_off(SPPenContext *const pc)
+static void bspline_spiro_start_anchor_off(PenTool *const pc)
{
SPCurve *tmpCurve = new SPCurve();
tmpCurve = pc->sa->curve->copy();
@@ -1571,7 +1577,7 @@ static void bspline_spiro_start_anchor_off(SPPenContext *const pc)
}
-static void bspline_spiro_motion(SPPenContext *const pc, bool shift){
+static void bspline_spiro_motion(PenTool *const pc, bool shift){
if(!pc->spiro && !pc->bspline)
return;
@@ -1628,7 +1634,7 @@ static void bspline_spiro_motion(SPPenContext *const pc, bool shift){
bspline_spiro_build(pc);
}
-static void bspline_spiro_end_anchor_on(SPPenContext *const pc)
+static void bspline_spiro_end_anchor_on(PenTool *const pc)
{
using Geom::X;
@@ -1699,7 +1705,7 @@ static void bspline_spiro_end_anchor_on(SPPenContext *const pc)
}
}
-static void bspline_spiro_end_anchor_off(SPPenContext *const pc)
+static void bspline_spiro_end_anchor_off(PenTool *const pc)
{
pc->p[2] = pc->p[3];
@@ -1750,7 +1756,7 @@ static void bspline_spiro_end_anchor_off(SPPenContext *const pc)
//preparates the curves for its trasformation into BSline curves.
-static void bspline_spiro_build(SPPenContext *const pc)
+static void bspline_spiro_build(PenTool *const pc)
{
if(!pc->spiro && !pc->bspline)
return;
@@ -2103,7 +2109,7 @@ static void spiro_doEffect(SPCurve * curve)
//BSpline end
-static void spdc_pen_set_subsequent_point(SPPenContext *const pc, Geom::Point const p, bool statusbar, guint status)
+static void spdc_pen_set_subsequent_point(PenTool *const pc, Geom::Point const p, bool statusbar, guint status)
{
g_assert( pc->npoints != 0 );
// todo: Check callers to see whether 2 <= npoints is guaranteed.
@@ -2157,7 +2163,7 @@ static void spdc_pen_set_subsequent_point(SPPenContext *const pc, Geom::Point co
}
}
-static void spdc_pen_set_ctrl(SPPenContext *const pc, Geom::Point const p, guint const state)
+static void spdc_pen_set_ctrl(PenTool *const pc, Geom::Point const p, guint const state)
{
sp_canvas_item_show(pc->c1);
sp_canvas_item_show(pc->cl1);
@@ -2174,8 +2180,8 @@ static void spdc_pen_set_ctrl(SPPenContext *const pc, Geom::Point const p, guint
sp_canvas_item_show(pc->c0);
sp_canvas_item_show(pc->cl0);
bool is_symm = false;
- if ( ( ( pc->mode == SPPenContext::MODE_CLICK ) && ( state & GDK_CONTROL_MASK ) ) ||
- ( ( pc->mode == SPPenContext::MODE_DRAG ) && !( state & GDK_SHIFT_MASK ) ) ) {
+ if ( ( ( pc->mode == PenTool::MODE_CLICK ) && ( state & GDK_CONTROL_MASK ) ) ||
+ ( ( pc->mode == PenTool::MODE_DRAG ) && !( state & GDK_SHIFT_MASK ) ) ) {
Geom::Point delta = p - pc->p[3];
pc->p[2] = pc->p[3] - delta;
is_symm = true;
@@ -2197,7 +2203,7 @@ static void spdc_pen_set_ctrl(SPPenContext *const pc, Geom::Point const p, guint
}
}
-static void spdc_pen_finish_segment(SPPenContext *const pc, Geom::Point const p, guint const state)
+static void spdc_pen_finish_segment(PenTool *const pc, Geom::Point const p, guint const state)
{
if (pc->polylines_paraxial) {
pen_last_paraxial_dir = pen_next_paraxial_direction(pc, p, pc->p[0], state);
@@ -2224,7 +2230,7 @@ static void spdc_pen_finish_segment(SPPenContext *const pc, Geom::Point const p,
}
}
-static void spdc_pen_finish(SPPenContext *const pc, gboolean const closed)
+static void spdc_pen_finish(PenTool *const pc, gboolean const closed)
{
if (pc->expecting_clicks_for_LPE > 1) {
// don't let the path be finished before we have collected the required number of mouse clicks
@@ -2244,7 +2250,7 @@ static void spdc_pen_finish(SPPenContext *const pc, gboolean const closed)
pc->ea = NULL;
pc->npoints = 0;
- pc->state = SPPenContext::POINT;
+ pc->state = PenTool::POINT;
sp_canvas_item_hide(pc->c0);
sp_canvas_item_hide(pc->c1);
@@ -2261,17 +2267,17 @@ static void spdc_pen_finish(SPPenContext *const pc, gboolean const closed)
pen_enable_events(pc);
}
-static void pen_disable_events(SPPenContext *const pc) {
+static void pen_disable_events(PenTool *const pc) {
pc->events_disabled++;
}
-static void pen_enable_events(SPPenContext *const pc) {
+static void pen_enable_events(PenTool *const pc) {
g_return_if_fail(pc->events_disabled != 0);
pc->events_disabled--;
}
-void sp_pen_context_wait_for_LPE_mouse_clicks(SPPenContext *pc, Inkscape::LivePathEffect::EffectType effect_type,
+void sp_pen_context_wait_for_LPE_mouse_clicks(PenTool *pc, Inkscape::LivePathEffect::EffectType effect_type,
unsigned int num_clicks, bool use_polylines)
{
if (effect_type == Inkscape::LivePathEffect::INVALID_LPE)
@@ -2283,14 +2289,14 @@ void sp_pen_context_wait_for_LPE_mouse_clicks(SPPenContext *pc, Inkscape::LivePa
pc->polylines_paraxial = false; // TODO: think if this is correct for all cases
}
-void sp_pen_context_cancel_waiting_for_LPE(SPPenContext *pc)
+void sp_pen_context_cancel_waiting_for_LPE(PenTool *pc)
{
pc->waiting_LPE_type = Inkscape::LivePathEffect::INVALID_LPE;
pc->expecting_clicks_for_LPE = 0;
sp_pen_context_set_polyline_mode(pc);
}
-static int pen_next_paraxial_direction(const SPPenContext *const pc,
+static int pen_next_paraxial_direction(const PenTool *const pc,
Geom::Point const &pt, Geom::Point const &origin, guint state) {
//
// after the first mouse click we determine whether the mouse pointer is closest to a
@@ -2314,7 +2320,7 @@ static int pen_next_paraxial_direction(const SPPenContext *const pc,
}
}
-void pen_set_to_nearest_horiz_vert(const SPPenContext *const pc, Geom::Point &pt, guint const state, bool snap)
+void pen_set_to_nearest_horiz_vert(const PenTool *const pc, Geom::Point &pt, guint const state, bool snap)
{
Geom::Point const origin = pc->p[0];
@@ -2345,6 +2351,10 @@ void pen_set_to_nearest_horiz_vert(const SPPenContext *const pc, Geom::Point &pt
}
}
+}
+}
+}
+
/*
Local Variables:
mode:c++