pen-tool.cpp revision d13b4119a328361e04470bc22746db46f2eaf48d
/** \file
* Pen event context implementation.
*/
/*
* Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
* bulia byak <buliabyak@users.sf.net>
* Jon A. Cruz <jon@joncruz.org>
*
* Copyright (C) 2000 Lauris Kaplinski
* Copyright (C) 2000-2001 Ximian, Inc.
* Copyright (C) 2002 Lauris Kaplinski
* Copyright (C) 2004 Monash University
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#include <gdk/gdkkeysyms.h>
#include <cstring>
#include <string>
#include "ui/tools/pen-tool.h"
#include "sp-namedview.h"
#include "desktop.h"
#include "desktop-handles.h"
#include "selection.h"
#include "selection-chemistry.h"
#include "draw-anchor.h"
#include "message-stack.h"
#include "message-context.h"
#include "preferences.h"
#include "sp-path.h"
#include "display/sp-canvas.h"
#include "pixmaps/cursor-pen.xpm"
#include "display/canvas-bpath.h"
#include "display/sp-ctrlline.h"
#include "display/sodipodi-ctrl.h"
#include "macros.h"
#include "context-fns.h"
#include "tools-switch.h"
#include "ui/control-manager.h"
//spanish: incluimos los archivos necesarios para las BSpline y Spiro
#define INKSCAPE_LPE_SPIRO_C
#include "live_effects/lpe-spiro.h"
#include <typeinfo>
#include "helper/geom-nodetype.h"
#include "helper/geom-curves.h"
// For handling un-continuous paths:
#include "message-stack.h"
#include "inkscape.h"
#include "desktop.h"
#include "live_effects/spiro.h"
#define INKSCAPE_LPE_BSPLINE_C
#include "live_effects/lpe-bspline.h"
#include "tool-factory.h"
using Inkscape::ControlManager;
namespace Inkscape {
namespace UI {
namespace Tools {
//spanish: añade los modos spiro y bspline
//spanish: esta función cambia los colores rojo,verde y azul haciendolos transparentes o no en función de si se usa spiro
//spanish: crea un nodo en modo bspline o spiro
//spanish: crea un nodo de modo spiro o bspline
//spanish: crea un nodo de tipo CUSP
//spanish: continua una curva existente en modo bspline o spiro
//spanish: continua una curva exsitente con el nodo de union en modo bspline o spiro
//spanish: continua una curva existente con el nodo de union en modo CUSP
//spanish: modifica la "red_curve" cuando se detecta movimiento
//spanish: cierra la curva con el último nodo en modo bspline o spiro
//spanish: cierra la curva con el último nodo en modo CUSP
//spanish: unimos todas las curvas en juego y llamamos a la función doEffect.
//function bspline cloned from lpe-bspline.cpp
//function spiro cloned from lpe-spiro.cpp
static void spdc_pen_set_subsequent_point(PenTool *const pc, Geom::Point const p, bool statusbar, guint status = 0);
static bool pen_within_tolerance = false;
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
namespace {
ToolBase* createPenContext() {
return new PenTool();
}
bool penContextRegistered = ToolFactory::instance().registerObject("/tools/freehand/pen", createPenContext);
}
}
this->polylines_only = false;
this->polylines_paraxial = false;
this->expecting_clicks_for_LPE = 0;
this->cursor_shape = cursor_pen_xpm;
this->hot_x = 4;
this->hot_y = 4;
this->npoints = 0;
this->mode = MODE_CLICK;
this->events_disabled = 0;
this->num_clicks = 0;
this->waiting_LPE = NULL;
this->waiting_item = NULL;
}
if (this->c0) {
sp_canvas_item_destroy(this->c0);
}
if (this->c1) {
sp_canvas_item_destroy(this->c1);
}
if (this->cl0) {
sp_canvas_item_destroy(this->cl0);
}
if (this->cl1) {
sp_canvas_item_destroy(this->cl1);
}
if (this->expecting_clicks_for_LPE > 0) {
// we received too few clicks to sanely set the parameter path so we remove the LPE from the item
this->waiting_item->removeCurrentPathEffect(false);
}
}
//spanish: cambiamos los modos para dar cabida al modo bspline
//we call the function which defines the Spiro modes and the BSpline
//todo: merge to one function only
}
/*
*.Set the mode of draw spiro, and bsplines
*/
//spanish: definimos los modos
}
/**
* Callback to initialize PenTool object.
*/
FreehandBase::setup();
// Pen indicators
sp_canvas_item_hide(this->c0);
sp_canvas_item_hide(this->c1);
sp_canvas_item_hide(this->cl0);
sp_canvas_item_hide(this->cl1);
sp_event_context_read(this, "mode");
this->anchor_statusbar = false;
this->enableSelectionCue();
}
}
{
pc->num_clicks = 0;
}
/**
* Finalization callback.
*/
if (this->npoints != 0) {
pen_cancel(this);
}
FreehandBase::finish();
}
/**
* Callback that sets key to value in pen context.
*/
if (name == "mode") {
} else {
this->mode = MODE_CLICK;
}
}
}
/**
* Snaps new node relative to the previous node.
*/
{
}
} else {
// We cannot use shift here to disable snapping because the shift-key is already used
// to toggle the paraxial direction; if the user wants to disable snapping (s)he will
// have to use the %-key, the menu, or the snap toolbar
// snap constrained
} else {
// snap freely
spdc_endpoint_snap_free(pc, p, origin, state); // pass the origin, to allow for perpendicular / tangential snapping
}
}
}
/**
* Snaps new node's handle relative to the new node.
*/
{
} else {
}
}
}
case GDK_BUTTON_PRESS:
break;
case GDK_BUTTON_RELEASE:
break;
default:
break;
}
if (!ret) {
}
return ret;
}
/**
* Callback to handle all pen events.
*/
case GDK_BUTTON_PRESS:
break;
case GDK_MOTION_NOTIFY:
break;
case GDK_BUTTON_RELEASE:
break;
case GDK_2BUTTON_PRESS:
break;
case GDK_KEY_PRESS:
break;
default:
break;
}
if (!ret) {
}
return ret;
}
/**
* Handle mouse button press event.
*/
{
if (pc->events_disabled) {
// skip event processing if events are disabled
return FALSE;
}
//Test whether we hit any anchor.
//with this we avoid creating a new point over the existing one
return FALSE;
}
// make sure this is not the last click for a waiting LPE (otherwise we want to finish the path)
return TRUE;
}
// Grab mouse, so release will not pass unnoticed
}
pen_within_tolerance = true;
case PenTool::MODE_CLICK:
// In click mode we add point on release
break;
// This is allowed, if we just canceled curve
break;
default:
break;
}
break;
// This is allowed, if we just canceled curve
p = event_dt;
m.unSetup();
}
break;
}
// TODO: Perhaps it would be nicer to rearrange the following case
// distinction so that the case of a waiting LPE is treated separately
// Set start anchor
//spanish: continuamos una curva existente
if(anchor){
}
// 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
} else {
// This is the first click of a new curve; deselect item so that
// this curve is not combined with it (unless it is drawn from its
// anchor, which is handled by the sibling branch above)
// if we have a waiting LPE, we need a fresh path to be created
// so don't append to an existing one
}
// Create green anchor
p = event_dt;
}
} else {
// Set end anchor
if (anchor) {
// we hit an anchor, will finish the curve (either with or without closing)
// in release handler
// we clicked on the current curve start, so close it even if
// we drag a handle away from it
}
break;
} else {
p = event_dt;
spdc_pen_set_subsequent_point(pc, p, true);
}
}
//spanish: evitamos la creación de un punto de control para que se cree el nodo en el evento de soltar
break;
g_warning("Button down in CONTROL state");
break;
g_warning("Button down in CLOSE state");
break;
default:
break;
}
break;
default:
break;
}
// when the last click for a waiting LPE occurs we want to finish the path
if (pc->green_closed) {
// finishing at the start anchor, close curve
} else {
// finishing at some other anchor, finish curve but not close
}
// right click - finish path
}
if (pc->expecting_clicks_for_LPE > 0) {
}
return ret;
}
/**
* Handle motion_notify event.
*/
{
if (event_context->space_panning || mevent.state & GDK_BUTTON2_MASK || mevent.state & GDK_BUTTON3_MASK) {
// allow scrolling
return FALSE;
}
if (pc->events_disabled) {
// skip motion events if pen events are disabled
return FALSE;
}
mevent.y);
//we take out the function the const "tolerance" because we need it later
if (pen_within_tolerance) {
return FALSE; // Do not drag if we're within tolerance from origin.
}
}
// 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)
pen_within_tolerance = false;
// Find desktop coordinates
// Test, whether we hit any anchor
case PenTool::MODE_CLICK:
// Only set point, if we are already appending
spdc_pen_set_subsequent_point(pc, p, true);
} else if (!sp_event_context_knot_mouseover(pc)) {
m.unSetup();
}
break;
// Placing controls is last operation in CLOSE state
break;
// This is perfectly valid
break;
default:
break;
}
break;
// Only set point, if we are already appending
if (!anchor) { // Snap node only if not hitting anchor
} else {
}
pc->message_context->set(Inkscape::NORMAL_MESSAGE, _("<b>Click</b> or <b>click and drag</b> to close and finish the path."));
}else{
pc->message_context->set(Inkscape::NORMAL_MESSAGE, _("<b>Click</b> or <b>click and drag</b> to close and finish the path. Shift to cusp node"));
}
pc->anchor_statusbar = true;
pc->anchor_statusbar = false;
}
} else {
pc->message_context->set(Inkscape::NORMAL_MESSAGE, _("<b>Click</b> or <b>click and drag</b> to continue the path from this point."));
}else{
pc->message_context->set(Inkscape::NORMAL_MESSAGE, _("<b>Click</b> or <b>click and drag</b> to continue the path from this point. Shift to cusp node"));
}
pc->anchor_statusbar = true;
pc->anchor_statusbar = false;
}
if (!sp_event_context_knot_mouseover(pc)) {
m.unSetup();
}
}
break;
// Placing controls is last operation in CLOSE state
// snap the handle
if (!pc->polylines_only) {
} else {
}
break;
// This is perfectly valid
break;
default:
if (!sp_event_context_knot_mouseover(pc)) {
m.unSetup();
}
break;
}
break;
default:
break;
}
//spanish: lanzamos la función "bspline_spiro_motion" al moverse el ratón o cuando se para.
}else{
}
}
return ret;
}
/**
* Handle mouse button release event.
*/
{
if (pc->events_disabled) {
// skip event processing if events are disabled
return FALSE;
}
revent.y);
// Find desktop coordinates
// Test whether we hit any anchor.
//with this we avoid creating a new point over the existing one
//spanish: si intentamos crear un nodo en el mismo sitio que el origen, paramos.
return FALSE;
}
}
case PenTool::MODE_CLICK:
// Start new thread only with button release
if (anchor) {
}
//spanish: continuamos una curva existente
if (anchor) {
}
}
} else {
// Set end anchor here
if (anchor) {
}
}
break;
// End current segment
break;
// End current segment
if (!anchor) { // Snap node only if not hitting anchor
}
//spanish: ocultamos la guia del penultimo nodo al cerrar la curva
}
break;
// This is allowed, if we just canceled curve
break;
default:
break;
}
break;
break;
//spanish: ocultamos la guia del penultimo nodo al cerrar la curva
}
if (pc->green_closed) {
// finishing at the start anchor, close curve
} else {
// finishing at some other anchor, finish curve but not close
}
break;
// This is allowed, if we just cancelled curve
break;
default:
break;
}
break;
default:
break;
}
// Release grab now
}
}
// TODO: can we be sure that the path was created correctly?
// TODO: should we offer an option to collect the clicks in a list?
if (pc->waiting_LPE) {
// we have an already created LPE waiting for a path
} else {
// the case that we need to create a new LPE and apply it to the just-drawn path is
// handled in spdc_check_for_and_apply_waiting_LPE() in draw-context.cpp
}
}
return ret;
}
{
// only end on LMB double click. Otherwise horizontal scrolling causes ending of the path
}
return ret;
}
{
// green
if (pc->green_bpaths) {
// remove old piecewise green canvasitems
while (pc->green_bpaths) {
}
// one canvas bpath for all of green_curve
sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(cshape), pc->green_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
}
if (pc->green_anchor)
// handles
//spanish: ocultamos los tiradores en modo bspline y spiro
} else {
}
if (last_seg) {
//spanish: ocultamos los tiradores en modo bspline y spiro
if ( cubic &&
{
} else {
}
}
//spanish: simplemente redibujamos la spiro.
//como es un redibujo simplemente no llamamos a la función global sino al final de esta
//Lanzamos solamente el redibujado
}
{
return;
// green
} else {
// start anchor too
if (pc->green_anchor) {
}
}
// red
}
{
}
{
//spanish: evitamos que si la "red_curve" tiene solo dos puntos -recta- no se pare aqui.
return;
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());
//spanish: modificamos el último segmento de la curva verde para que forme el tipo de nodo que deseamos
//We obtain the last segment 4 points in the previous curve
if ( cubic ){
A = (*cubic)[0];
B = (*cubic)[1];
}else
C = pc->green_curve->last_segment()->finalPoint() + (1./3)* (Geom::Point)(pc->green_curve->last_segment()->initialPoint() - pc->green_curve->last_segment()->finalPoint());
D = (*cubic)[3];
}else{
else
C = pc->green_curve->last_segment()->finalPoint() + (1./3)* (Geom::Point)(pc->green_curve->last_segment()->initialPoint() - pc->green_curve->last_segment()->finalPoint());
}
}else{
//we eliminate the last segment
//and we add it again with the recreation
}
}
//spanish: si el último nodo es una union con otra curva
bspline_spiro_start_anchor(pc, false);
}
}
}
{
//spanish: evitamos que si la "red_curve" tiene solo dos puntos -recta- no se pare aqui.
return;
//spanish: modificamos el último segmento de la curva verde para que forme el tipo de nodo que deseamos
Geom::CubicBezier const * cubic = dynamic_cast<Geom::CubicBezier const *>( pc->green_curve->last_segment() );
if ( cubic ) {
B = (*cubic)[1];
D = C;
} else {
//We obtain the last segment 4 points in the previous curve
B = A;
D = C;
}
}else{
//we eliminate the last segment
//and we add it again with the recreation
}
}
//spanish: si el último nodo es una union con otra curva
bspline_spiro_start_anchor(pc, true);
}
}
}
{
gdouble const nudge = prefs->getDoubleLimited("/options/nudgedistance/value", 2, 0, 1000, "px"); // in px
case GDK_KEY_Left: // move last point left
case GDK_KEY_KP_Left:
}
else { // no alt
}
}
break;
case GDK_KEY_Up: // move last point up
case GDK_KEY_KP_Up:
}
else { // no alt
}
}
break;
case GDK_KEY_Right: // move last point right
case GDK_KEY_KP_Right:
}
else { // no alt
}
}
break;
case GDK_KEY_Down: // move last point down
case GDK_KEY_KP_Down:
}
else { // no alt
}
}
break;
/*TODO: this is not yet enabled?? looks like some traces of the Geometry tool
case GDK_KEY_P:
case GDK_KEY_p:
if (MOD__SHIFT_ONLY(event)) {
sp_pen_context_wait_for_LPE_mouse_clicks(pc, Inkscape::LivePathEffect::PARALLEL, 2);
ret = TRUE;
}
break;
case GDK_KEY_C:
case GDK_KEY_c:
if (MOD__SHIFT_ONLY(event)) {
sp_pen_context_wait_for_LPE_mouse_clicks(pc, Inkscape::LivePathEffect::CIRCLE_3PTS, 3);
ret = TRUE;
}
break;
case GDK_KEY_B:
case GDK_KEY_b:
if (MOD__SHIFT_ONLY(event)) {
sp_pen_context_wait_for_LPE_mouse_clicks(pc, Inkscape::LivePathEffect::PERP_BISECTOR, 2);
ret = TRUE;
}
break;
case GDK_KEY_A:
case GDK_KEY_a:
if (MOD__SHIFT_ONLY(event)) {
sp_pen_context_wait_for_LPE_mouse_clicks(pc, Inkscape::LivePathEffect::ANGLE_BISECTOR, 3);
ret = TRUE;
}
break;
*/
case GDK_KEY_U:
case GDK_KEY_u:
if (MOD__SHIFT_ONLY(event)) {
}
break;
case GDK_KEY_L:
case GDK_KEY_l:
if (MOD__SHIFT_ONLY(event)) {
}
break;
case GDK_KEY_Return:
case GDK_KEY_KP_Enter:
}
break;
case GDK_KEY_Escape:
// if drawing, cancel, otherwise pass it up for deselecting
pen_cancel (pc);
}
break;
case GDK_KEY_z:
case GDK_KEY_Z:
// if drawing, cancel, otherwise pass it up for undo
pen_cancel (pc);
}
break;
case GDK_KEY_g:
case GDK_KEY_G:
if (MOD__SHIFT_ONLY(event)) {
ret = true;
}
break;
case GDK_KEY_BackSpace:
case GDK_KEY_Delete:
case GDK_KEY_KP_Delete:
pen_cancel (pc);
} else {
// do nothing; this event should be handled upstream
}
} else {
// Reset red curve
// Destroy topmost green bpath
if (pc->green_bpaths) {
}
// Get last segment
g_warning("pen_handle_key_press, case GDK_KP_Delete: Green curve is empty");
break;
}
// The code below assumes that pc->green_curve has only ONE path !
if ( cubic ) {
} else {
}
//spanish: asignamos el valor a un tercio de distancia del último segmento.
}
: pc->p[3]));
//spanish: eliminamos el último segmento de la curva verde
if (pc->green_bpaths) {
}
}else{
}
//spanish: asignamos el valor de pc->p[1] a el opuesto de el ultimo segmento de la línea verde
if ( cubic ) {
} else {
}
}
//spanish: redibujamos
}
break;
default:
break;
}
return ret;
}
{
// Red
// Blue
// Green
while (pc->green_bpaths) {
}
if (pc->green_anchor) {
}
pc->red_curve_is_valid = false;
}
{
pc->p[0] = p;
pc->p[1] = p;
}
/**
* two parameters ("angle %3.2f°, distance %s").
*/
static void spdc_pen_set_angle_distance_status_message(PenTool *const pc, Geom::Point const p, int pc_point_to_compare, gchar const *message)
{
if (angle < 0) {
angle += 360;
}
}
}
//spanish: esta función cambia los colores rojo,verde y azul haciendolos transparentes o no en función de si se usa spiro
{
bool remake_green_bpaths = false;
//If the colour is not defined as trasparent, por example when changing
//from drawing to spiro mode or when selecting the pen tool
//We change the green and red colours to transparent, so this lines are not necessary
//to the drawing with spiro
remake_green_bpaths = true;
}
}else{
//If we come from working with the spiro curve and change the mode the "green_curve" colour is transparent
//since we are not im spiro mode, we assign the original colours
//to the red and the green curve, removing their transparency
remake_green_bpaths = true;
}
}
}
//We erase all the "green_bpaths" to recreate them after with the colour
//transparency recently modified
// remove old piecewise green canvasitems
while (pc->green_bpaths) {
}
// one canvas bpath for all of 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_stroke(SP_CANVAS_BPATH(pc->red_bpath), pc->red_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
}
{
return;
if(!pc->anchor_statusbar)
}
{
using Geom::X;
using Geom::Y;
}
}
{
}
}
{
return;
return;
if(shift)
else
}
{
using Geom::X;
using Geom::Y;
Geom::CubicBezier const * cubic = dynamic_cast<Geom::CubicBezier const*>(&*tmpCurve->last_segment());
if(cubic){
}else{
}
}else{
//we eliminate the last segment
//and we add it again with the recreation
}
}
}
{
Geom::CubicBezier const * cubic = dynamic_cast<Geom::CubicBezier const*>(&*tmpCurve->last_segment());
if(cubic){
}else{
//we eliminate the last segment
//and we add it again with the recreation
}
}
}
}
return;
using Geom::X;
using Geom::Y;
}else{
}
Geom::CubicBezier const * cubic = dynamic_cast<Geom::CubicBezier const*>(&*tmpCurve->last_segment());
if(cubic){
if(shift)
}else{
}
}else{
if(shift)
}
}
if(shift)
else
}
}
{
using Geom::X;
using Geom::Y;
Geom::CubicBezier const * cubic = dynamic_cast<Geom::CubicBezier const*>(&*tmpCurve->last_segment());
C = tmpCurve->last_segment()->finalPoint() + (1./3)*(tmpCurve->last_segment()->initialPoint() - tmpCurve->last_segment()->finalPoint());
}else{
}
if(cubic){
}else{
lastSeg->curveto(tmpCurve->last_segment()->initialPoint(),C,tmpCurve->last_segment()->finalPoint());
}
}else{
//we eliminate the last segment
//and we add it again with the recreation
}
}else{
Geom::CubicBezier const * cubic = dynamic_cast<Geom::CubicBezier const*>(&*tmpCurve->last_segment());
C = tmpCurve->last_segment()->finalPoint() + (1./3)*(tmpCurve->last_segment()->initialPoint() - tmpCurve->last_segment()->finalPoint());
}else{
}
if(cubic){
}else{
lastSeg->curveto(tmpCurve->last_segment()->initialPoint(),C,tmpCurve->last_segment()->finalPoint());
}
}else{
//we eliminate the last segment
//and we add it again with the recreation
}
}
}
}
{
Geom::CubicBezier const * cubic = dynamic_cast<Geom::CubicBezier const*>(&*tmpCurve->last_segment());
if(cubic){
}else{
//we eliminate the last segment
//and we add it again with the recreation
}
}
}else{
Geom::CubicBezier const * cubic = dynamic_cast<Geom::CubicBezier const*>(&*tmpCurve->last_segment());
if(cubic){
}else{
//we eliminate the last segment
//and we add it again with the recreation
}
}
}
}
}
//spanish: preparates the curves for its trasformation into BSline curves.
{
return;
//We create the base curve
//If we continuate the existing curve we add it at the start
}
}
//and the red one
}
//spanish: cerramos la curva si estan cerca los puntos finales de la curva spiro
}
//TODO: CALL TO CLONED FUNCTION SPIRO::doEffect IN lpe-spiro.cpp
//For example
//using namespace Inkscape::LivePathEffect;
//LivePathEffectObject *lpeobj = static_cast<LivePathEffectObject*> (curve);
//Effect *spr = static_cast<Effect*> ( new LPEbspline(lpeobj) );
//spr->doEffect(curve);
}else{
}
sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(pc->blue_bpath), pc->blue_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
//We hide the holders that doesn't contribute anything
}else
}else{
//if the curve is empty
}
}
{
//spanish: comentado en funcion "doEffect" de src/live_effects/lpe-bspline.cpp
return;
for(Geom::PathVector::const_iterator path_it = original_pathv.begin(); path_it != original_pathv.end(); ++path_it) {
continue;
Geom::Path::const_iterator curve_endit = path_it->end_default(); // this determines when the loop has to stop
const Geom::Curve &closingline = path_it->back_closed(); // the closing line segment is always of type Geom::LineSegment.
}
}
while ( curve_it2 != curve_endit )
{
if(cubic){
}else{
}
delete in;
if(cubic){
}else{
}
delete out;
lineHelper->reset();
delete lineHelper;
previousNode = node;
curveHelper->reset();
delete curveHelper;
++curve_it1;
++curve_it2;
}
if(cubic){
}else{
}
delete start;
if(cubic){
}else{
}
delete end;
lineHelper->reset();
delete lineHelper;
}else{
delete start;
}
curveHelper->reset();
delete curveHelper;
}
delete nCurve;
}
}
//Spiro function cloned from lpe-spiro.cpp
//spanish: comentado en funcion "doEffect" de src/live_effects/lpe-spiro.cpp
{
using Geom::X;
using Geom::Y;
int ip = 0;
for(Geom::PathVector::const_iterator path_it = original_pathv.begin(); path_it != original_pathv.end(); ++path_it) {
continue;
{
ip++;
}
}
}
while ( curve_it2 != curve_endit )
{
{
if (this_is_line && !next_is_line) {
} else if (next_is_line && !this_is_line) {
} else {
}
} else {
}
++curve_it1;
++curve_it2;
ip++;
}
switch (nodetype) {
ip++;
break;
break;
case Geom::NODE_SMOOTH:
break;
}
} else {
ip++;
}
ip = 0;
}
}
static void spdc_pen_set_subsequent_point(PenTool *const pc, Geom::Point const p, bool statusbar, guint status)
{
// todo: Check callers to see whether 2 <= npoints is guaranteed.
pc->p[2] = p;
pc->p[3] = p;
pc->p[4] = p;
bool is_curve;
// we are drawing horizontal/vertical lines and hit an anchor;
// if the previous point and the anchor are not aligned either horizontally or vertically...
// ...then we should draw an L-shaped path, consisting of two paraxial segments
}
is_curve = false;
} else {
// one of the 'regular' modes
is_curve = true;
} else {
is_curve = false;
}
}
if (statusbar) {
_("<b>Curve segment</b>: angle %3.2f°, distance %s; with <b>Ctrl</b> to snap angle, <b>Enter</b> to finish the path" ):
_("<b>Line segment</b>: angle %3.2f°, distance %s; with <b>Ctrl</b> to snap angle, <b>Enter</b> to finish the path");
_("<b>Curve segment</b>: angle %3.2f°, distance %s; with <b>Shift</b> to cusp node, <b>Enter</b> to finish the path" ):
_("<b>Line segment</b>: angle %3.2f°, distance %s; with <b>Shift</b> to cusp node, <b>Enter</b> to finish the path");
}
}
}
{
pc->p[1] = p;
spdc_pen_set_angle_distance_status_message(pc, p, 0, _("<b>Curve handle</b>: angle %3.2f°, length %s; with <b>Ctrl</b> to snap angle"));
pc->p[4] = p;
bool is_symm = false;
is_symm = true;
}
_("<b>Curve handle, symmetric</b>: angle %3.2f°, length %s; with <b>Ctrl</b> to snap angle, with <b>Shift</b> to move this handle only") :
_("<b>Curve handle</b>: angle %3.2f°, length %s; with <b>Ctrl</b> to snap angle, with <b>Shift</b> to move this handle only");
} else {
}
}
{
if (pc->polylines_paraxial) {
}
++pc->num_clicks;
/// \todo fixme:
sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(cshape), pc->green_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
}
}
{
// don't let the path be finished before we have collected the required number of mouse clicks
return;
}
pc->num_clicks = 0;
if (pc->green_anchor) {
}
}
pc->events_disabled++;
}
pc->events_disabled--;
}
void sp_pen_context_wait_for_LPE_mouse_clicks(PenTool *pc, Inkscape::LivePathEffect::EffectType effect_type,
unsigned int num_clicks, bool use_polylines)
{
return;
}
{
pc->expecting_clicks_for_LPE = 0;
}
//
// after the first mouse click we determine whether the mouse pointer is closest to a
// horizontal or vertical segment; for all subsequent mouse clicks, we use the direction
// orthogonal to the last one; pressing Shift toggles the direction
//
// num_clicks is not reliable because spdc_pen_finish_segment is sometimes called too early
// (on first mouse release), in which case num_clicks immediately becomes 1.
// if (pc->num_clicks == 0) {
// first mouse click
return pen_last_paraxial_dir;
} else {
// subsequent mouse click
}
}
void pen_set_to_nearest_horiz_vert(const PenTool *const pc, Geom::Point &pt, guint const state, bool snap)
{
if (!snap) {
if (next_dir == 0) {
// line is forced to be horizontal
} else {
// line is forced to be vertical
}
} else {
// Create a horizontal or vertical constraint line
// Snap along the constraint line; if we didn't snap then still the constraint will be applied
// selection->singleItem() is the item that is currently being drawn. This item will not be snapped to (to avoid self-snapping)
// TODO: Allow snapping to the stationary parts of the item, and only ignore the last segment
m.unSetup();
}
}
}
}
}
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :