Lines Matching defs:dc

64 static void spdc_selection_changed(Inkscape::Selection *sel, FreehandBase *dc);
65 static void spdc_selection_modified(Inkscape::Selection *sel, guint flags, FreehandBase *dc);
67 static void spdc_attach_selection(FreehandBase *dc, Inkscape::Selection *sel);
75 static void spdc_flush_white(FreehandBase *dc, SPCurve *gc);
77 static void spdc_reset_white(FreehandBase *dc);
78 static void spdc_free_colors(FreehandBase *dc);
213 static Glib::ustring const tool_name(FreehandBase *dc)
215 return ( SP_IS_PEN_CONTEXT(dc)
220 static void spdc_paste_curve_as_freehand_shape(Geom::PathVector const &newpath, FreehandBase *dc, SPItem *item)
226 Effect::createAndApply(PATTERN_ALONG_PATH, dc->desktop->doc(), item);
231 static void spdc_apply_powerstroke_shape(const std::vector<Geom::Point> & points, FreehandBase *dc, SPItem *item)
235 Effect::createAndApply(POWERSTROKE, dc->desktop->doc(), item);
240 SPDesktop *desktop = dc->desktop;
245 char const* tool = SP_IS_PEN_CONTEXT(dc) ? "/tools/freehand/pen" : "/tools/freehand/pencil";
273 static void spdc_apply_bend_shape(gchar const *svgd, FreehandBase *dc, SPItem *item)
281 Effect::createAndApply(BEND_PATH, dc->desktop->doc(), item);
292 static void spdc_apply_simplify(std::string threshold, FreehandBase *dc, SPItem *item)
296 Effect::createAndApply(SIMPLIFY, dc->desktop->doc(), item);
310 static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, SPCurve *curve)
316 bool simplify = prefs->getInt(tool_name(dc) + "/simplify", 0);
322 spdc_apply_simplify(ss.str(), dc, item);
325 if (prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1) {
326 Effect::createAndApply(SPIRO, dc->desktop->doc(), item);
329 if (prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2) {
330 Effect::createAndApply(BSPLINE, dc->desktop->doc(), item);
340 shapeType shape = (shapeType)prefs->getInt(tool_name(dc) + "/shape", 0);
367 spdc_apply_powerstroke_shape(points, dc, item);
378 spdc_apply_powerstroke_shape(points, dc, item);
394 spdc_paste_curve_as_freehand_shape(c->get_pathvector(), dc, item);
405 SPItem * pasted_clipboard = dc->selection->singleItem();
411 dc->selection->remove(SP_OBJECT(pasted_clipboard));
414 spdc_paste_curve_as_freehand_shape(previous_shape_pathv, dc, item);
435 bend_item = dc->selection->singleItem();
439 spdc_apply_bend_shape(svgd, dc, bend_item);
440 dc->selection->add(SP_OBJECT(bend_item));
457 spdc_paste_curve_as_freehand_shape(previous_shape_pathv, dc, item);
467 dc->selection->add(SP_OBJECT(bend_item));
468 sp_selection_duplicate(dc->desktop);
469 dc->selection->remove(SP_OBJECT(bend_item));
470 bend_item = dc->selection->singleItem();
478 spdc_apply_bend_shape(svgd, dc, bend_item);
479 dc->selection->add(SP_OBJECT(bend_item));
511 if (dc->waiting_LPE_type != INVALID_LPE) {
512 Effect::createAndApply(dc->waiting_LPE_type, dc->desktop->doc(), item);
513 dc->waiting_LPE_type = INVALID_LPE;
515 if (SP_IS_LPETOOL_CONTEXT(dc)) {
517 lpetool_context_switch_mode(SP_LPETOOL_CONTEXT(dc), INVALID_LPE);
520 if (SP_IS_PEN_CONTEXT(dc)) {
521 SP_PEN_CONTEXT(dc)->setPolylineMode();
530 static void spdc_selection_changed(Inkscape::Selection *sel, FreehandBase *dc)
532 if (dc->attach) {
533 spdc_attach_selection(dc, sel);
539 static void spdc_selection_modified(Inkscape::Selection *sel, guint /*flags*/, FreehandBase *dc)
541 if (dc->attach) {
542 spdc_attach_selection(dc, sel);
546 static void spdc_attach_selection(FreehandBase *dc, Inkscape::Selection */*sel*/)
549 spdc_reset_white(dc);
550 dc->sa = NULL;
551 dc->ea = NULL;
553 SPItem *item = dc->selection ? dc->selection->singleItem() : NULL;
558 dc->white_item = item;
563 norm->transform((dc->white_item)->i2dt_affine());
565 dc->white_curves = g_slist_reverse(norm->split());
569 for (GSList *l = dc->white_curves; l != NULL; l = l->next) {
575 a = sp_draw_anchor_new(dc, c, TRUE, *(c->first_point()));
577 dc->white_anchors = g_slist_prepend(dc->white_anchors, a);
578 a = sp_draw_anchor_new(dc, c, FALSE, *(c->last_point()));
580 dc->white_anchors = g_slist_prepend(dc->white_anchors, a);
645 void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed)
648 SPCurve *c = dc->green_curve;
651 dc->green_curve = new SPCurve();
652 while (dc->green_bpaths) {
653 sp_canvas_item_destroy(SP_CANVAS_ITEM(dc->green_bpaths->data));
654 dc->green_bpaths = g_slist_remove(dc->green_bpaths, dc->green_bpaths->data);
658 c->append_continuous(dc->blue_curve, 0.0625);
659 dc->blue_curve->reset();
660 sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(dc->blue_bpath), NULL);
663 if (dc->red_curve_is_valid) {
664 c->append_continuous(dc->red_curve, 0.0625);
666 dc->red_curve->reset();
667 sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(dc->red_bpath), NULL);
675 if ( forceclosed || ( dc->green_anchor && dc->green_anchor->active ) ) {
677 dc->desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Path is closed."));
680 spdc_flush_white(dc, c);
686 if ( dc->sa && dc->ea
687 && ( dc->sa->curve == dc->ea->curve )
688 && ( ( dc->sa != dc->ea )
689 || dc->sa->curve->is_closed() ) )
692 dc->desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Closing path."));
693 if (dc->sa->start && !(dc->sa->curve->is_closed()) ) {
696 if(prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1 ||
697 prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2){
698 dc->overwrite_curve->append_continuous(c, 0.0625);
700 dc->overwrite_curve->closepath_current();
701 if(dc->sa){
702 dc->white_curves = g_slist_remove(dc->white_curves, dc->sa->curve);
703 dc->white_curves = g_slist_append(dc->white_curves, dc->overwrite_curve);
706 dc->sa->curve->append_continuous(c, 0.0625);
708 dc->sa->curve->closepath_current();
710 spdc_flush_white(dc, NULL);
715 if (dc->sa) {
716 SPCurve *s = dc->sa->curve;
717 dc->white_curves = g_slist_remove(dc->white_curves, s);
718 if(prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1 ||
719 prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2){
720 s = dc->overwrite_curve;
722 if (dc->sa->start) {
728 } else /* Step D - test end */ if (dc->ea) {
729 SPCurve *e = dc->ea->curve;
730 dc->white_curves = g_slist_remove(dc->white_curves, e);
731 if (!dc->ea->start) {
734 if(prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1 ||
735 prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2){
758 spdc_flush_white(dc, c);
763 static void spdc_flush_white(FreehandBase *dc, SPCurve *gc)
766 if (dc->white_curves) {
767 g_assert(dc->white_item);
768 c = SPCurve::concat(dc->white_curves);
769 g_slist_free(dc->white_curves);
770 dc->white_curves = NULL;
782 c->transform( dc->white_item
783 ? (dc->white_item)->dt2i_affine()
784 : dc->desktop->dt2doc() );
786 SPDesktop *desktop = dc->desktop;
796 if (dc->white_item) {
797 repr = dc->white_item->getRepr();
798 has_lpe = SP_LPE_ITEM(dc->white_item)->hasPathEffectRecursive();
802 sp_desktop_apply_style_tool(desktop, repr, tool_name(dc).data(), false);
813 if (!dc->white_item) {
817 spdc_check_for_and_apply_waiting_LPE(dc, item, c);
819 dc->selection->set(repr);
830 DocumentUndo::done(doc, SP_IS_PEN_CONTEXT(dc)? SP_VERB_CONTEXT_PEN : SP_VERB_CONTEXT_PENCIL,
838 spdc_selection_modified(desktop->getSelection(), 0, dc);
847 SPDrawAnchor *spdc_test_inside(FreehandBase *dc, Geom::Point p)
852 if (dc->green_anchor) {
853 active = sp_draw_anchor_test(dc->green_anchor, p, TRUE);
856 for (GSList *l = dc->white_anchors; l != NULL; l = l->next) {
865 static void spdc_reset_white(FreehandBase *dc)
867 if (dc->white_item) {
869 dc->white_item = NULL;
871 while (dc->white_curves) {
872 reinterpret_cast<SPCurve *>(dc->white_curves->data)->unref();
873 dc->white_curves = g_slist_remove(dc->white_curves, dc->white_curves->data);
875 while (dc->white_anchors) {
876 sp_draw_anchor_destroy(static_cast<SPDrawAnchor*>(dc->white_anchors->data));
877 dc->white_anchors = g_slist_remove(dc->white_anchors, dc->white_anchors->data);
881 static void spdc_free_colors(FreehandBase *dc)
884 if (dc->red_bpath) {
885 sp_canvas_item_destroy(SP_CANVAS_ITEM(dc->red_bpath));
886 dc->red_bpath = NULL;
888 if (dc->red_curve) {
889 dc->red_curve = dc->red_curve->unref();
893 if (dc->blue_bpath) {
894 sp_canvas_item_destroy(SP_CANVAS_ITEM(dc->blue_bpath));
895 dc->blue_bpath = NULL;
897 if (dc->blue_curve) {
898 dc->blue_curve = dc->blue_curve->unref();
902 while (dc->green_bpaths) {
903 sp_canvas_item_destroy(SP_CANVAS_ITEM(dc->green_bpaths->data));
904 dc->green_bpaths = g_slist_remove(dc->green_bpaths, dc->green_bpaths->data);
906 if (dc->green_curve) {
907 dc->green_curve = dc->green_curve->unref();
909 if (dc->green_anchor) {
910 dc->green_anchor = sp_draw_anchor_destroy(dc->green_anchor);
914 if (dc->white_item) {
916 dc->white_item = NULL;
918 while (dc->white_curves) {
919 reinterpret_cast<SPCurve *>(dc->white_curves->data)->unref();
920 dc->white_curves = g_slist_remove(dc->white_curves, dc->white_curves->data);
922 while (dc->white_anchors) {
923 sp_draw_anchor_destroy(static_cast<SPDrawAnchor *>(dc->white_anchors->data));
924 dc->white_anchors = g_slist_remove(dc->white_anchors, dc->white_anchors->data);