freehand-base.cpp revision 02ad3eb3a78e3a217fd64849a3b63408aab9f437
2521N/A#define DRAW_VERBOSE
2521N/A#ifdef HAVE_CONFIG_H
2521N/A#include "live_effects/lpe-patternalongpath.h"
2521N/A#include "display/canvas-bpath.h"
2521N/A#include "desktop-style.h"
2521N/A#include "document.h"
3998N/A#include "ui/draw-anchor.h"
3998N/A#include "message-stack.h"
3998N/A#include "ui/tools/pen-tool.h"
3998N/A#include "ui/tools/lpe-tool.h"
3998N/A#include "preferences.h"
3998N/A#include "selection.h"
3998N/A#include "selection-chemistry.h"
3998N/A#include "sp-namedview.h"
3998N/A#include "live_effects/lpe-powerstroke.h"
2892N/A#include "ui/control-manager.h"
2892N/A#include "ui/clipboard.h"
2892N/A#include "ui/tools/freehand-base.h"
2521N/Astatic void spdc_selection_modified(Inkscape::Selection *sel, guint flags, FreehandBase *dc);
2521N/A , green_closed(false)
, red_curve_is_valid(false)
, anchor_statusbar(false)
if (this->grab) {
if (this->selection) {
spdc_free_colors(this);
sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(this->red_bpath), this->red_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(this->blue_bpath), this->blue_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
if (this->grab) {
if (this->selection) {
spdc_free_colors(this);
case GDK_KEY_PRESS:
case GDK_KEY_Up:
case GDK_KEY_Down:
case GDK_KEY_KP_Up:
case GDK_KEY_KP_Down:
if (!ret) {
return ret;
static void spdc_apply_powerstroke_shape(const std::vector<Geom::Point> & points, FreehandBase *dc, SPItem *item)
if (style_str) {
bool shape_applied = false;
switch (shape) {
case NONE:
case TRIANGLE_IN:
shape_applied = true;
case TRIANGLE_OUT:
shape_applied = true;
case ELLIPSE:
c->curveto((1 + C1) * SHAPE_LENGTH/2, 0, SHAPE_LENGTH, (1 - C1) * SHAPE_HEIGHT/2, SHAPE_LENGTH, SHAPE_HEIGHT/2);
c->curveto(SHAPE_LENGTH, (1 + C1) * SHAPE_HEIGHT/2, (1 + C1) * SHAPE_LENGTH/2, SHAPE_HEIGHT, SHAPE_LENGTH/2, SHAPE_HEIGHT);
c->curveto((1 - C1) * SHAPE_LENGTH/2, SHAPE_HEIGHT, 0, (1 + C1) * SHAPE_HEIGHT/2, 0, SHAPE_HEIGHT/2);
c->closepath();
c->unref();
shape_applied = true;
case CLIPBOARD:
shape_applied = true;
case LAST_APPLIED:
c->unref();
shape_applied = true;
if (shape_applied) {
SPCurve *c;
if ( !c->is_closed() ) {
SPDrawAnchor *a;
// SHIFT disables all snapping, except the angular snapping. After all, the user explicitly asked for angular
// snapping by pressing CTRL, otherwise we wouldn't have arrived here. But although we temporarily disable
// the snapping here, we must still call for a constrained snap in order to apply the constraints (i.e. round
Inkscape::SnappedPoint dummy = m.constrainedAngularSnap(Inkscape::SnapCandidatePoint(p, Inkscape::SNAPSOURCE_NODE_HANDLE), boost::optional<Geom::Point>(), o, snaps);
m.unSetup();
void spdc_endpoint_snap_free(ToolBase const * const ec, Geom::Point& p, boost::optional<Geom::Point> &start_of_line, guint const /*state*/)
// selection->singleItem() is the item that is currently being drawn. This item will not be snapped to (to avoid self-snapping)
if (start_of_line) {
m.unSetup();
return ret;
if (c->is_empty()) {
c->unref();
c->closepath_current();
c->unref();
c = reverse_then_unref(c);
c->unref();
c->unref();
s = reverse_then_unref(s);
c->unref();
e = reverse_then_unref(e);
e = reverse_then_unref(e);
if(cubic){
e = lastSeg;
e->backspace();
e = reverse_then_unref(e);
e->unref();
c->unref();
SPCurve *c;
if (gc) {
} else if (gc) {
c = gc;
c->ref();
if ( c && !c->is_empty() ) {
bool has_lpe = false;
if (has_lpe)
c->unref();
return active;
void spdc_create_single_dot(ToolBase *ec, Geom::Point const &pt, char const *tool, guint event_state) {
if (style_str) {
str = g_strdup_printf("fill:#%06x;stroke:none;", sp_desktop_get_color_tool(desktop, tool, false) >> 8);