Code

Move single-dot-creation function to a better location (and rename it accordingly)
[inkscape.git] / src / pencil-context.cpp
1 /** \file
2  * Pencil event context implementation.
3  */
5 /*
6  * Authors:
7  *   Lauris Kaplinski <lauris@kaplinski.com>
8  *   bulia byak <buliabyak@users.sf.net>
9  *
10  * Copyright (C) 2000 Lauris Kaplinski
11  * Copyright (C) 2000-2001 Ximian, Inc.
12  * Copyright (C) 2002 Lauris Kaplinski
13  * Copyright (C) 2004 Monash University
14  *
15  * Released under GNU GPL, read the file 'COPYING' for more information
16  */
18 #include <gdk/gdkkeysyms.h>
20 #include "pencil-context.h"
21 #include "desktop.h"
22 #include "desktop-handles.h"
23 #include "selection.h"
24 #include "selection-chemistry.h"
25 #include "draw-anchor.h"
26 #include "message-stack.h"
27 #include "message-context.h"
28 #include "modifier-fns.h"
29 #include "sp-path.h"
30 #include "prefs-utils.h"
31 #include "snap.h"
32 #include "pixmaps/cursor-pencil.xpm"
33 #include "display/bezier-utils.h"
34 #include "display/canvas-bpath.h"
35 #include <glibmm/i18n.h>
36 #include "libnr/in-svg-plane.h"
37 #include "context-fns.h"
38 #include "sp-namedview.h"
39 #include "xml/repr.h"
40 #include "document.h"
41 #include "desktop-style.h"
42 #include "macros.h"
43 #include "display/curve.h"
45 static void sp_pencil_context_class_init(SPPencilContextClass *klass);
46 static void sp_pencil_context_init(SPPencilContext *pc);
47 static void sp_pencil_context_setup(SPEventContext *ec);
48 static void sp_pencil_context_dispose(GObject *object);
50 static gint sp_pencil_context_root_handler(SPEventContext *event_context, GdkEvent *event);
51 static gint pencil_handle_button_press(SPPencilContext *const pc, GdkEventButton const &bevent);
52 static gint pencil_handle_motion_notify(SPPencilContext *const pc, GdkEventMotion const &mevent);
53 static gint pencil_handle_button_release(SPPencilContext *const pc, GdkEventButton const &revent);
54 static gint pencil_handle_key_press(SPPencilContext *const pc, guint const keyval, guint const state);
56 static void spdc_set_startpoint(SPPencilContext *pc, NR::Point const p);
57 static void spdc_set_endpoint(SPPencilContext *pc, NR::Point const p);
58 static void spdc_finish_endpoint(SPPencilContext *pc);
59 static void spdc_add_freehand_point(SPPencilContext *pc, NR::Point p, guint state);
60 static void fit_and_split(SPPencilContext *pc);
63 static SPDrawContextClass *pencil_parent_class;
64 static NR::Point pencil_drag_origin_w(0, 0);
65 static bool pencil_within_tolerance = false;
67 /**
68  * Register SPPencilContext class with Gdk and return its type number.
69  */
70 GType
71 sp_pencil_context_get_type()
72 {
73     static GType type = 0;
74     if (!type) {
75         GTypeInfo info = {
76             sizeof(SPPencilContextClass),
77             NULL, NULL,
78             (GClassInitFunc) sp_pencil_context_class_init,
79             NULL, NULL,
80             sizeof(SPPencilContext),
81             4,
82             (GInstanceInitFunc) sp_pencil_context_init,
83             NULL,   /* value_table */
84         };
85         type = g_type_register_static(SP_TYPE_DRAW_CONTEXT, "SPPencilContext", &info, (GTypeFlags)0);
86     }
87     return type;
88 }
90 /**
91  * Initialize SPPencilContext vtable.
92  */
93 static void
94 sp_pencil_context_class_init(SPPencilContextClass *klass)
95 {
96     GObjectClass *object_class;
97     SPEventContextClass *event_context_class;
99     object_class = (GObjectClass *) klass;
100     event_context_class = (SPEventContextClass *) klass;
102     pencil_parent_class = (SPDrawContextClass*)g_type_class_peek_parent(klass);
104     object_class->dispose = sp_pencil_context_dispose;
106     event_context_class->setup = sp_pencil_context_setup;
107     event_context_class->root_handler = sp_pencil_context_root_handler;
110 /**
111  * Callback to initialize SPPencilContext object.
112  */
113 static void
114 sp_pencil_context_init(SPPencilContext *pc)
116     SPEventContext *event_context = SP_EVENT_CONTEXT(pc);
118     event_context->cursor_shape = cursor_pencil_xpm;
119     event_context->hot_x = 4;
120     event_context->hot_y = 4;
122     pc->npoints = 0;
123     pc->state = SP_PENCIL_CONTEXT_IDLE;
124     pc->req_tangent = NR::Point(0, 0);
127 /**
128  * Callback to setup SPPencilContext object.
129  */
130 static void
131 sp_pencil_context_setup(SPEventContext *ec)
133     if (prefs_get_int_attribute("tools.freehand.pencil", "selcue", 0) != 0) {
134         ec->enableSelectionCue();
135     }
137     if (((SPEventContextClass *) pencil_parent_class)->setup) {
138         ((SPEventContextClass *) pencil_parent_class)->setup(ec);
139     }
141     SPPencilContext *const pc = SP_PENCIL_CONTEXT(ec);
142     pc->is_drawing = false;
144     pc->anchor_statusbar = false;
147 static void
148 sp_pencil_context_dispose(GObject *object)
150     G_OBJECT_CLASS(pencil_parent_class)->dispose(object);
153 /** Snaps new node relative to the previous node. */
154 static void
155 spdc_endpoint_snap(SPPencilContext const *pc, NR::Point &p, guint const state)
157     if ((state & GDK_CONTROL_MASK)) { //CTRL enables constrained snapping
158         spdc_endpoint_snap_rotation(pc, p, pc->p[0], state);
159     } else {
160         if (!(state & GDK_SHIFT_MASK)) { //SHIFT disables all snapping, except the angular snapping above
161                                          //After all, the user explicitely asked for angular snapping by
162                                          //pressing CTRL
163             spdc_endpoint_snap_free(pc, p, state);
164         }
165     }
168 /**
169  * Callback for handling all pencil context events.
170  */
171 gint
172 sp_pencil_context_root_handler(SPEventContext *const ec, GdkEvent *event)
174     SPPencilContext *const pc = SP_PENCIL_CONTEXT(ec);
176     gint ret = FALSE;
178     switch (event->type) {
179         case GDK_BUTTON_PRESS:
180             ret = pencil_handle_button_press(pc, event->button);
181             break;
183         case GDK_MOTION_NOTIFY:
184             ret = pencil_handle_motion_notify(pc, event->motion);
185             break;
187         case GDK_BUTTON_RELEASE:
188             ret = pencil_handle_button_release(pc, event->button);
189             break;
191         case GDK_KEY_PRESS:
192             ret = pencil_handle_key_press(pc, get_group0_keyval (&event->key), event->key.state);
193             break;
195         default:
196             break;
197     }
199     if (!ret) {
200         gint (*const parent_root_handler)(SPEventContext *, GdkEvent *)
201             = ((SPEventContextClass *) pencil_parent_class)->root_handler;
202         if (parent_root_handler) {
203             ret = parent_root_handler(ec, event);
204         }
205     }
207     return ret;
210 static gint
211 pencil_handle_button_press(SPPencilContext *const pc, GdkEventButton const &bevent)
213     gint ret = FALSE;
214     SPEventContext *event_context = SP_EVENT_CONTEXT(pc);
215     if ( bevent.button == 1  && !event_context->space_panning) {
217         SPDrawContext *dc = SP_DRAW_CONTEXT (pc);
218         SPDesktop *desktop = SP_EVENT_CONTEXT_DESKTOP(dc);
219         Inkscape::Selection *selection = sp_desktop_selection(desktop);
221         if (Inkscape::have_viable_layer(desktop, dc->_message_context) == false) {
222             return TRUE;
223         }
225         NR::Point const button_w(bevent.x, bevent.y);
227         /* Find desktop coordinates */
228         Geom::Point p = pc->desktop->w2d(button_w);
230         /* Test whether we hit any anchor. */
231         SPDrawAnchor *anchor = spdc_test_inside(pc, button_w);
233         pencil_drag_origin_w = NR::Point(bevent.x,bevent.y);
234         pencil_within_tolerance = true;
236         switch (pc->state) {
237             case SP_PENCIL_CONTEXT_ADDLINE:
238                 /* Current segment will be finished with release */
239                 ret = TRUE;
240                 break;
241             default:
242                 /* Set first point of sequence */
243                 if (bevent.state & GDK_CONTROL_MASK) {
244                     spdc_create_single_dot(event_context, from_2geom(p), "tools.freehand.pencil", bevent.state);
245                     ret = true;
246                     break;
247                 }
248                 if (anchor) {
249                     p = to_2geom(anchor->dp);
250                     desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Continuing selected path"));
251                 } else {
253                     if (!(bevent.state & GDK_SHIFT_MASK)) {
255                         // This is the first click of a new curve; deselect item so that
256                         // this curve is not combined with it (unless it is drawn from its
257                         // anchor, which is handled by the sibling branch above)
258                         selection->clear();
259                         desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Creating new path"));
260                         SnapManager &m = desktop->namedview->snap_manager;
261                         m.setup(desktop);
262                         m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, p);
263                     } else if (selection->singleItem() && SP_IS_PATH(selection->singleItem())) {
264                         desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Appending to selected path"));
265                     }
266                 }
267                 pc->sa = anchor;
268                 spdc_set_startpoint(pc, from_2geom(p));
269                 ret = TRUE;
270                 break;
271         }
273         pc->is_drawing = true;
274     }
275     return ret;
278 static gint
279 pencil_handle_motion_notify(SPPencilContext *const pc, GdkEventMotion const &mevent)
281     if ((mevent.state & GDK_CONTROL_MASK) && (mevent.state & GDK_BUTTON1_MASK)) {
282         // mouse was accidentally moved during Ctrl+click;
283         // ignore the motion and create a single point
284         pc->is_drawing = false;
285         return TRUE;
286     }
287     gint ret = FALSE;
288     SPDesktop *const dt = pc->desktop;
290     SPEventContext *event_context = SP_EVENT_CONTEXT(pc);
291     if (event_context->space_panning || mevent.state & GDK_BUTTON2_MASK || mevent.state & GDK_BUTTON3_MASK) {
292         // allow scrolling
293         return FALSE;
294     }
296     if ( ( mevent.state & GDK_BUTTON1_MASK ) && !pc->grab && pc->is_drawing) {
297         /* Grab mouse, so release will not pass unnoticed */
298         pc->grab = SP_CANVAS_ITEM(dt->acetate);
299         sp_canvas_item_grab(pc->grab, ( GDK_KEY_PRESS_MASK | GDK_BUTTON_PRESS_MASK   |
300                                         GDK_BUTTON_RELEASE_MASK |
301                                         GDK_POINTER_MOTION_MASK  ),
302                             NULL, mevent.time);
303     }
305     /* Find desktop coordinates */
306     Geom::Point p = to_2geom(dt->w2d(NR::Point(mevent.x, mevent.y)));
308     /* Test whether we hit any anchor. */
309     SPDrawAnchor *anchor = spdc_test_inside(pc, NR::Point(mevent.x, mevent.y));
311     if (pencil_within_tolerance) {
312         gint const tolerance = prefs_get_int_attribute_limited("options.dragtolerance",
313                                                                "value", 0, 0, 100);
314         if ( NR::LInfty( NR::Point(mevent.x,mevent.y) - pencil_drag_origin_w ) < tolerance ) {
315             return FALSE;   // Do not drag if we're within tolerance from origin.
316         }
317     }
319     // Once the user has moved farther than tolerance from the original location
320     // (indicating they intend to move the object, not click), then always process the
321     // motion notify coordinates as given (no snapping back to origin)
322     pencil_within_tolerance = false;
324     switch (pc->state) {
325         case SP_PENCIL_CONTEXT_ADDLINE:
326             /* Set red endpoint */
327             if (anchor) {
328                 p = to_2geom(anchor->dp);
329             } else {
330                 NR::Point ptnr = from_2geom(p);
331                 spdc_endpoint_snap(pc, ptnr, mevent.state);
332                 p = to_2geom(ptnr);
333             }
334             spdc_set_endpoint(pc, from_2geom(p));
335             ret = TRUE;
336             break;
337         default:
338             /* We may be idle or already freehand */
339             if ( mevent.state & GDK_BUTTON1_MASK && pc->is_drawing ) {
340                 pc->state = SP_PENCIL_CONTEXT_FREEHAND;
341                 if ( !pc->sa && !pc->green_anchor ) {
342                     /* Create green anchor */
343                     pc->green_anchor = sp_draw_anchor_new(pc, pc->green_curve, TRUE, pc->p[0]);
344                 }
345                 /** \todo
346                  * fixme: I am not sure whether we want to snap to anchors
347                  * in middle of freehand (Lauris)
348                  */
349                 if (anchor) {
350                     p = to_2geom(anchor->dp);
351                 } else if ((mevent.state & GDK_SHIFT_MASK) == 0) {
352                     SnapManager &m = dt->namedview->snap_manager;
353                     m.setup(dt);
354                     m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, p);
355                 }
356                 if ( pc->npoints != 0 ) { // buttonpress may have happened before we entered draw context!
357                     spdc_add_freehand_point(pc, from_2geom(p), mevent.state);
358                     ret = TRUE;
359                 }
361                 if (anchor && !pc->anchor_statusbar) {
362                     pc->_message_context->set(Inkscape::NORMAL_MESSAGE, _("<b>Release</b> here to close and finish the path."));
363                     pc->anchor_statusbar = true;
364                 } else if (!anchor && pc->anchor_statusbar) {
365                     pc->_message_context->clear();
366                     pc->anchor_statusbar = false;
367                 } else if (!anchor) {
368                     pc->_message_context->set(Inkscape::NORMAL_MESSAGE, _("Drawing a freehand path"));
369                 }
371             } else {
372                 if (anchor && !pc->anchor_statusbar) {
373                     pc->_message_context->set(Inkscape::NORMAL_MESSAGE, _("<b>Drag</b> to continue the path from this point."));
374                     pc->anchor_statusbar = true;
375                 } else if (!anchor && pc->anchor_statusbar) {
376                     pc->_message_context->clear();
377                     pc->anchor_statusbar = false;
378                 }
379             }
380             break;
381     }
382     return ret;
385 static gint
386 pencil_handle_button_release(SPPencilContext *const pc, GdkEventButton const &revent)
388     gint ret = FALSE;
390     SPEventContext *event_context = SP_EVENT_CONTEXT(pc);
391     if ( revent.button == 1 && pc->is_drawing && !event_context->space_panning) {
392         SPDesktop *const dt = pc->desktop;
394         pc->is_drawing = false;
396         /* Find desktop coordinates */
397         NR::Point p = dt->w2d(NR::Point(revent.x, revent.y));
399         /* Test whether we hit any anchor. */
400         SPDrawAnchor *anchor = spdc_test_inside(pc, NR::Point(revent.x,
401                                                               revent.y));
403         switch (pc->state) {
404             case SP_PENCIL_CONTEXT_IDLE:
405                 /* Releasing button in idle mode means single click */
406                 /* We have already set up start point/anchor in button_press */
407                 if (!(revent.state & GDK_CONTROL_MASK)) {
408                     // Ctrl+click creates a single point so only set context in ADDLINE mode when Ctrl isn't pressed
409                     pc->state = SP_PENCIL_CONTEXT_ADDLINE;
410                 }
411                 ret = TRUE;
412                 break;
413             case SP_PENCIL_CONTEXT_ADDLINE:
414                 /* Finish segment now */
415                 if (anchor) {
416                     p = anchor->dp;
417                 } else {
418                     spdc_endpoint_snap(pc, p, revent.state);
419                 }
420                 pc->ea = anchor;
421                 spdc_set_endpoint(pc, p);
422                 spdc_finish_endpoint(pc);
423                 pc->state = SP_PENCIL_CONTEXT_IDLE;
424                 ret = TRUE;
425                 break;
426             case SP_PENCIL_CONTEXT_FREEHAND:
427                 /* Finish segment now */
428                 /// \todo fixme: Clean up what follows (Lauris)
429                 if (anchor) {
430                     p = anchor->dp;
431                 }
432                 pc->ea = anchor;
433                 /* Write curves to object */
435                 dt->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Finishing freehand"));
437                 spdc_concat_colors_and_flush(pc, FALSE);
438                 pc->sa = NULL;
439                 pc->ea = NULL;
440                 if (pc->green_anchor) {
441                     pc->green_anchor = sp_draw_anchor_destroy(pc->green_anchor);
442                 }
443                 pc->state = SP_PENCIL_CONTEXT_IDLE;
444                 ret = TRUE;
445                 break;
446             default:
447                 break;
448         }
450         if (pc->grab) {
451             /* Release grab now */
452             sp_canvas_item_ungrab(pc->grab, revent.time);
453             pc->grab = NULL;
454         }
456         ret = TRUE;
457     }
458     return ret;
461 static void
462 pencil_cancel (SPPencilContext *const pc) 
464     if (pc->grab) {
465         /* Release grab now */
466         sp_canvas_item_ungrab(pc->grab, 0);
467         pc->grab = NULL;
468     }
470     pc->is_drawing = false;
472     pc->state = SP_PENCIL_CONTEXT_IDLE;
474     pc->red_curve->reset();
475     sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(pc->red_bpath), NULL);
476     while (pc->green_bpaths) {
477         gtk_object_destroy(GTK_OBJECT(pc->green_bpaths->data));
478         pc->green_bpaths = g_slist_remove(pc->green_bpaths, pc->green_bpaths->data);
479     }
480     pc->green_curve->reset();
481     if (pc->green_anchor) {
482         pc->green_anchor = sp_draw_anchor_destroy(pc->green_anchor);
483     }
485     pc->_message_context->clear();
486     pc->_message_context->flash(Inkscape::NORMAL_MESSAGE, _("Drawing cancelled"));
488     sp_canvas_end_forced_full_redraws(pc->desktop->canvas);
491 static gint
492 pencil_handle_key_press(SPPencilContext *const pc, guint const keyval, guint const state)
494     gint ret = FALSE;
495     switch (keyval) {
496         case GDK_Up:
497         case GDK_Down:
498         case GDK_KP_Up:
499         case GDK_KP_Down:
500             // Prevent the zoom field from activation.
501             if (!mod_ctrl_only(state)) {
502                 ret = TRUE;
503             }
504             break;
505         case GDK_Escape:
506             if (pc->npoints != 0) {
507                 // if drawing, cancel, otherwise pass it up for deselecting
508                 if (pc->state != SP_PENCIL_CONTEXT_IDLE) {
509                     pencil_cancel (pc);
510                     ret = TRUE;
511                 }
512             }
513             break;
514         case GDK_z:
515         case GDK_Z:
516             if (mod_ctrl_only(state) && pc->npoints != 0) {
517                 // if drawing, cancel, otherwise pass it up for undo
518                 if (pc->state != SP_PENCIL_CONTEXT_IDLE) {
519                     pencil_cancel (pc);
520                     ret = TRUE;
521                 }
522             }
523             break;
524         case GDK_g:
525         case GDK_G:
526             if (mod_shift_only(state)) {
527                 sp_selection_to_guides(SP_EVENT_CONTEXT(pc)->desktop);
528                 ret = true;
529             }
530             break;
531         default:
532             break;
533     }
534     return ret;
537 /**
538  * Reset points and set new starting point.
539  */
540 static void
541 spdc_set_startpoint(SPPencilContext *const pc, NR::Point const p)
543     pc->npoints = 0;
544     pc->red_curve_is_valid = false;
545     if (in_svg_plane(p)) {
546         pc->p[pc->npoints++] = p;
547     }
550 /**
551  * Change moving endpoint position.
552  * <ul>
553  * <li>Ctrl constrains to moving to H/V direction, snapping in given direction.
554  * <li>Otherwise we snap freely to whatever attractors are available.
555  * </ul>
556  *
557  * Number of points is (re)set to 2 always, 2nd point is modified.
558  * We change RED curve.
559  */
560 static void
561 spdc_set_endpoint(SPPencilContext *const pc, NR::Point const p)
563     if (pc->npoints == 0) {
564         return;
565         /* May occur if first point wasn't in SVG plane (e.g. weird w2d transform, perhaps from bad
566          * zoom setting).
567          */
568     }
569     g_return_if_fail( pc->npoints > 0 );
571     pc->red_curve->reset();
572     if ( ( p == pc->p[0] )
573          || !in_svg_plane(p) )
574     {
575         pc->npoints = 1;
576     } else {
577         pc->p[1] = p;
578         pc->npoints = 2;
580         pc->red_curve->moveto(pc->p[0]);
581         pc->red_curve->lineto(pc->p[1]);
582         pc->red_curve_is_valid = true;
584         sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(pc->red_bpath), pc->red_curve);
585     }
588 /**
589  * Finalize addline.
590  *
591  * \todo
592  * fixme: I'd like remove red reset from concat colors (lauris).
593  * Still not sure, how it will make most sense.
594  */
595 static void
596 spdc_finish_endpoint(SPPencilContext *const pc)
598     if ( ( pc->red_curve->is_empty() )
599          || ( *(pc->red_curve->first_point()) == *(pc->red_curve->second_point())   ) )
600     {
601         pc->red_curve->reset();
602         sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(pc->red_bpath), NULL);
603     } else {
604         /* Write curves to object. */
605         spdc_concat_colors_and_flush(pc, FALSE);
606         pc->sa = NULL;
607         pc->ea = NULL;
608     }
611 static void
612 spdc_add_freehand_point(SPPencilContext *pc, NR::Point p, guint /*state*/)
614     g_assert( pc->npoints > 0 );
615     g_return_if_fail(unsigned(pc->npoints) < G_N_ELEMENTS(pc->p));
617     if ( ( p != pc->p[ pc->npoints - 1 ] )
618          && in_svg_plane(p) )
619     {
620         pc->p[pc->npoints++] = p;
621         fit_and_split(pc);
622     }
625 static inline double
626 square(double const x)
628     return x * x;
631 static void
632 fit_and_split(SPPencilContext *pc)
634     g_assert( pc->npoints > 1 );
636     double const tol = prefs_get_double_attribute_limited("tools.freehand.pencil",                                                                             "tolerance", 10.0, 1.0, 100.0);
637     double const tolerance_sq = 0.02 * square( NR::expansion(pc->desktop->w2d()) * tol) 
638         * exp(0.2*tol - 2);
640     NR::Point b[4];
641     g_assert(is_zero(pc->req_tangent)
642              || is_unit_vector(pc->req_tangent));
643     NR::Point const tHatEnd(0, 0);
644     int const n_segs = sp_bezier_fit_cubic_full(b, NULL, pc->p, pc->npoints,
645                                                 pc->req_tangent, tHatEnd, tolerance_sq, 1);
646     if ( n_segs > 0
647          && unsigned(pc->npoints) < G_N_ELEMENTS(pc->p) )
648     {
649         /* Fit and draw and reset state */
650         pc->red_curve->reset();
651         pc->red_curve->moveto(b[0]);
652         pc->red_curve->curveto(b[1], b[2], b[3]);
653         sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(pc->red_bpath), pc->red_curve);
654         pc->red_curve_is_valid = true;
655     } else {
656         /* Fit and draw and copy last point */
658         g_assert(!pc->red_curve->is_empty());
660         /* Set up direction of next curve. */
661         {
662             Geom::CubicBezier const * last_seg = dynamic_cast<Geom::CubicBezier const *>(pc->red_curve->last_segment());
663             g_assert( last_seg );      // Relevance: validity of (*last_seg)[2]
664             pc->p[0] = last_seg->finalPoint();
665             pc->npoints = 1;
666             NR::Point const req_vec( pc->p[0] - (*last_seg)[2] );
667             pc->req_tangent = ( ( NR::is_zero(req_vec) || !in_svg_plane(req_vec) )
668                                 ? NR::Point(0, 0)
669                                 : NR::unit_vector(req_vec) );
670         }
672         pc->green_curve->append_continuous(pc->red_curve, 0.0625);
673         SPCurve *curve = pc->red_curve->copy();
675         /// \todo fixme:
676         SPCanvasItem *cshape = sp_canvas_bpath_new(sp_desktop_sketch(pc->desktop), curve);
677         curve->unref();
678         sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(cshape), pc->green_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
680         pc->green_bpaths = g_slist_prepend(pc->green_bpaths, cshape);
682         pc->red_curve_is_valid = false;
683     }
687 /*
688   Local Variables:
689   mode:c++
690   c-file-style:"stroustrup"
691   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
692   indent-tabs-mode:nil
693   fill-column:99
694   End:
695 */
696 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :