diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2015-08-26 19:35:34 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx.marker.es> | 2015-08-26 19:35:34 +0000 |
| commit | 8e2a1a4407a19fc9b794c2c29cc1e6eb41c83559 (patch) | |
| tree | 062e8e1f329373a873532a746c3ef2ca81d6fc94 /src | |
| parent | add 'little' comment (diff) | |
| parent | Prevent crash when "vector" doesn't exist (i.e. for mesh gradient). (diff) | |
| download | inkscape-8e2a1a4407a19fc9b794c2c29cc1e6eb41c83559.tar.gz inkscape-8e2a1a4407a19fc9b794c2c29cc1e6eb41c83559.zip | |
update to trunk
(bzr r13645.1.115)
Diffstat (limited to 'src')
| -rw-r--r-- | src/Makefile.am | 1 | ||||
| -rw-r--r-- | src/attributes.cpp | 1 | ||||
| -rw-r--r-- | src/attributes.h | 1 | ||||
| -rw-r--r-- | src/libgdl/gdl-dock-item-grip.c | 3 | ||||
| -rw-r--r-- | src/libgdl/gdl-dock-item.c | 3 | ||||
| -rw-r--r-- | src/live_effects/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | src/live_effects/Makefile_insert | 2 | ||||
| -rw-r--r-- | src/live_effects/effect-enum.h | 1 | ||||
| -rw-r--r-- | src/live_effects/effect.cpp | 5 | ||||
| -rw-r--r-- | src/live_effects/lpe-bspline.cpp | 83 | ||||
| -rw-r--r-- | src/live_effects/lpe-transform_2pts.cpp | 320 | ||||
| -rw-r--r-- | src/live_effects/lpe-transform_2pts.h | 80 | ||||
| -rw-r--r-- | src/sp-factory.cpp | 2 | ||||
| -rw-r--r-- | src/sp-guide.cpp | 7 | ||||
| -rw-r--r-- | src/sp-namedview.cpp | 12 | ||||
| -rw-r--r-- | src/sp-paint-server.cpp | 4 |
16 files changed, 460 insertions, 67 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 7a37f13e8..04e33c471 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -46,7 +46,6 @@ all_libs = \ $(FREETYPE_LIBS) \ $(kdeldadd) \ $(win32ldflags) \ - $(CARBON_LDFLAGS) \ $(LIBWPG_LIBS) \ $(LIBVISIO_LIBS) \ $(LIBCDR_LIBS) \ diff --git a/src/attributes.cpp b/src/attributes.cpp index af19360c1..991834cb2 100644 --- a/src/attributes.cpp +++ b/src/attributes.cpp @@ -125,6 +125,7 @@ static SPStyleProp const props[] = { /* SPGuide */ {SP_ATTR_ORIENTATION, "orientation"}, {SP_ATTR_POSITION, "position"}, + {SP_ATTR_INKSCAPE_COLOR, "inkscape:color"}, /* SPImage */ {SP_ATTR_X, "x"}, {SP_ATTR_Y, "y"}, diff --git a/src/attributes.h b/src/attributes.h index 7d6ea70a0..47f1388b0 100644 --- a/src/attributes.h +++ b/src/attributes.h @@ -127,6 +127,7 @@ enum SPAttributeEnum { /* SPGuide */ SP_ATTR_ORIENTATION, SP_ATTR_POSITION, + SP_ATTR_INKSCAPE_COLOR, /* SPImage */ SP_ATTR_X, SP_ATTR_Y, diff --git a/src/libgdl/gdl-dock-item-grip.c b/src/libgdl/gdl-dock-item-grip.c index d23eb7f98..9b3810c20 100644 --- a/src/libgdl/gdl-dock-item-grip.c +++ b/src/libgdl/gdl-dock-item-grip.c @@ -149,6 +149,8 @@ gdl_dock_item_grip_expose (GtkWidget *widget, } +/* see bug #950556: may contribute to regression with GTK2/Quartz */ +#if !defined(GDK_WINDOWING_QUARTZ) if (gdl_dock_item_or_child_has_focus(grip->item)) { gtk_paint_focus (gtk_widget_get_style (widget), @@ -157,6 +159,7 @@ gdl_dock_item_grip_expose (GtkWidget *widget, &event->area, widget, NULL, 0, 0, -1, -1); } +#endif //GDK_WINDOWING_QUARTZ return GTK_WIDGET_CLASS (gdl_dock_item_grip_parent_class)->expose_event (widget, event); } diff --git a/src/libgdl/gdl-dock-item.c b/src/libgdl/gdl-dock-item.c index afcd4dfcb..af630e681 100644 --- a/src/libgdl/gdl-dock-item.c +++ b/src/libgdl/gdl-dock-item.c @@ -1064,8 +1064,11 @@ gdl_dock_item_paint (GtkWidget *widget, "dockitem", 0, 0, -1, -1); +/* see bug #950556: avoid regression with GTK2/Quartz */ +#if !defined(GDK_WINDOWING_QUARTZ) if (GTK_IS_WIDGET(item->_priv->grip)) gtk_widget_queue_draw (GTK_WIDGET(item->_priv->grip)); +#endif } static gint diff --git a/src/live_effects/CMakeLists.txt b/src/live_effects/CMakeLists.txt index ab7ba6b4e..a1aa811a9 100644 --- a/src/live_effects/CMakeLists.txt +++ b/src/live_effects/CMakeLists.txt @@ -6,6 +6,7 @@ set(live_effects_SRC lpe-bounding-box.cpp lpe-bspline.cpp lpe-circle_3pts.cpp + lpe-transform_2pts.cpp lpe-circle_with_radius.cpp lpe-clone-original.cpp lpe-constructgrid.cpp @@ -83,6 +84,7 @@ set(live_effects_SRC lpe-bounding-box.h lpe-bspline.h lpe-circle_3pts.h + lpe-transform_2pts.h lpe-circle_with_radius.h lpe-clone-original.h lpe-constructgrid.h diff --git a/src/live_effects/Makefile_insert b/src/live_effects/Makefile_insert index c2c2ce93c..b5bee55c8 100644 --- a/src/live_effects/Makefile_insert +++ b/src/live_effects/Makefile_insert @@ -74,6 +74,8 @@ ink_common_sources += \ live_effects/lpe-mirror_symmetry.h \ live_effects/lpe-circle_3pts.cpp \ live_effects/lpe-circle_3pts.h \ + live_effects/lpe-transform_2pts.cpp \ + live_effects/lpe-transform_2pts.h \ live_effects/lpe-angle_bisector.cpp \ live_effects/lpe-angle_bisector.h \ live_effects/lpe-parallel.cpp \ diff --git a/src/live_effects/effect-enum.h b/src/live_effects/effect-enum.h index 383eec19e..eea26184c 100644 --- a/src/live_effects/effect-enum.h +++ b/src/live_effects/effect-enum.h @@ -38,6 +38,7 @@ enum EffectType { TANGENT_TO_CURVE, MIRROR_SYMMETRY, CIRCLE_3PTS, + TRANSFORM_2PTS, ANGLE_BISECTOR, PARALLEL, COPY_ROTATE, diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index 332d81777..fe7bf3a97 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -57,6 +57,7 @@ #include "live_effects/lpe-sketch.h" #include "live_effects/lpe-spiro.h" #include "live_effects/lpe-tangent_to_curve.h" +#include "live_effects/lpe-transform_2pts.h" #include "live_effects/lpe-taperstroke.h" #include "live_effects/lpe-test-doEffect-stack.h" #include "live_effects/lpe-text_label.h" @@ -150,6 +151,7 @@ const Util::EnumData<EffectType> LPETypeData[] = { {PERSPECTIVE_ENVELOPE, N_("Perspective/Envelope"), "perspective-envelope"}, {FILLET_CHAMFER, N_("Fillet/Chamfer"), "fillet-chamfer"}, {INTERPOLATE_POINTS, N_("Interpolate points"), "interpolate_points"}, + {TRANSFORM_2PTS, N_("Transform by 2 points"), "transform_2pts"}, }; const Util::EnumDataConverter<EffectType> LPETypeConverter(LPETypeData, sizeof(LPETypeData)/sizeof(*LPETypeData)); @@ -315,6 +317,9 @@ Effect::New(EffectType lpenr, LivePathEffectObject *lpeobj) case SHOW_HANDLES: neweffect = static_cast<Effect*> ( new LPEShowHandles(lpeobj) ); break; + case TRANSFORM_2PTS: + neweffect = static_cast<Effect*> ( new LPETransform2Pts(lpeobj) ); + break; default: g_warning("LivePathEffect::Effect::New called with invalid patheffect type (%d)", lpenr); neweffect = NULL; diff --git a/src/live_effects/lpe-bspline.cpp b/src/live_effects/lpe-bspline.cpp index 019584943..0cae1dcb6 100644 --- a/src/live_effects/lpe-bspline.cpp +++ b/src/live_effects/lpe-bspline.cpp @@ -365,91 +365,52 @@ void LPEBSpline::doBSplineFromWidget(SPCurve *curve, double weight_ammount) point_at0 = in->first_segment()->initialPoint(); point_at3 = in->first_segment()->finalPoint(); sbasis_in = in->first_segment()->toSBasis(); - if (!only_selected) { - if (cubic) { - if (!ignore_cusp || !Geom::are_near((*cubic)[1], point_at0)) { + if (cubic) { + if (!ignore_cusp || !Geom::are_near((*cubic)[1], point_at0)) { + if (isNodePointSelected(point_at0) || !only_selected) { point_at1 = sbasis_in.valueAt(weight_ammount); if (weight_ammount != NO_POWER) { point_at1 = Geom::Point(point_at1[X] + HANDLE_CUBIC_GAP, point_at1[Y] + HANDLE_CUBIC_GAP); } } else { - point_at1 = in->first_segment()->initialPoint(); - } - if (!ignore_cusp || !Geom::are_near((*cubic)[2], point_at3)) { - point_at2 = sbasis_in.valueAt(1 - weight_ammount); - if (weight_ammount != NO_POWER) { - point_at2 = - Geom::Point(point_at2[X] + HANDLE_CUBIC_GAP, point_at2[Y] + HANDLE_CUBIC_GAP); - } - } else { - point_at2 = in->first_segment()->finalPoint(); + point_at1 = (*cubic)[1]; } } else { - if (!ignore_cusp && weight_ammount != NO_POWER) { - point_at1 = sbasis_in.valueAt(weight_ammount); - if (weight_ammount != NO_POWER) { - point_at1 = - Geom::Point(point_at1[X] + HANDLE_CUBIC_GAP, point_at1[Y] + HANDLE_CUBIC_GAP); - } + point_at1 = in->first_segment()->initialPoint(); + } + if (!ignore_cusp || !Geom::are_near((*cubic)[2], point_at3)) { + if (isNodePointSelected(point_at3) || !only_selected) { point_at2 = sbasis_in.valueAt(1 - weight_ammount); if (weight_ammount != NO_POWER) { point_at2 = Geom::Point(point_at2[X] + HANDLE_CUBIC_GAP, point_at2[Y] + HANDLE_CUBIC_GAP); } } else { - point_at1 = in->first_segment()->initialPoint(); - point_at2 = in->first_segment()->finalPoint(); + point_at2 = (*cubic)[2]; } + } else { + point_at2 = in->first_segment()->finalPoint(); } } else { - if (cubic) { - if (!ignore_cusp || !Geom::are_near((*cubic)[1], point_at0)) { - if (isNodePointSelected(point_at0)) { - point_at1 = sbasis_in.valueAt(weight_ammount); - if (weight_ammount != NO_POWER) { - point_at1 = - Geom::Point(point_at1[X] + HANDLE_CUBIC_GAP, point_at1[Y] + HANDLE_CUBIC_GAP); - } - } else { - point_at1 = (*cubic)[1]; - } + if (!ignore_cusp && weight_ammount != NO_POWER) { + if (isNodePointSelected(point_at0) || !only_selected) { + point_at1 = sbasis_in.valueAt(weight_ammount); + point_at1 = + Geom::Point(point_at1[X] + HANDLE_CUBIC_GAP, point_at1[Y] + HANDLE_CUBIC_GAP); } else { point_at1 = in->first_segment()->initialPoint(); } - if (!ignore_cusp || !Geom::are_near((*cubic)[2], point_at3)) { - if (isNodePointSelected(point_at3)) { - point_at2 = sbasis_in.valueAt(1 - weight_ammount); - if (weight_ammount != NO_POWER) { - point_at2 = - Geom::Point(point_at2[X] + HANDLE_CUBIC_GAP, point_at2[Y] + HANDLE_CUBIC_GAP); - } - } else { - point_at2 = (*cubic)[2]; - } + if (isNodePointSelected(point_at3) || !only_selected) { + point_at2 = sbasis_in.valueAt(weight_ammount); + point_at2 = + Geom::Point(point_at2[X] + HANDLE_CUBIC_GAP, point_at2[Y] + HANDLE_CUBIC_GAP); } else { point_at2 = in->first_segment()->finalPoint(); } } else { - if (!ignore_cusp && weight_ammount != NO_POWER) { - if (isNodePointSelected(point_at0)) { - point_at1 = sbasis_in.valueAt(weight_ammount); - point_at1 = - Geom::Point(point_at1[X] + HANDLE_CUBIC_GAP, point_at1[Y] + HANDLE_CUBIC_GAP); - } else { - point_at1 = in->first_segment()->initialPoint(); - } - if (isNodePointSelected(point_at3)) { - point_at2 = sbasis_in.valueAt(weight_ammount); - point_at2 = - Geom::Point(point_at2[X] + HANDLE_CUBIC_GAP, point_at2[Y] + HANDLE_CUBIC_GAP); - } else { - point_at2 = in->first_segment()->finalPoint(); - } - } else { - point_at1 = in->first_segment()->initialPoint(); - point_at2 = in->first_segment()->finalPoint(); - } + point_at1 = in->first_segment()->initialPoint(); + point_at2 = in->first_segment()->finalPoint(); } } in->reset(); diff --git a/src/live_effects/lpe-transform_2pts.cpp b/src/live_effects/lpe-transform_2pts.cpp new file mode 100644 index 000000000..b70b68968 --- /dev/null +++ b/src/live_effects/lpe-transform_2pts.cpp @@ -0,0 +1,320 @@ +/** \file + * LPE "Transform through 2 points" implementation + */ + +/* + * Authors: + * Jabier Arraiza Cenoz<jabier.arraiza@marker.es> + * + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include <gtkmm.h> + +#include "live_effects/lpe-transform_2pts.h" +#include "display/curve.h" +#include <2geom/transforms.h> +#include <2geom/pathvector.h> +#include "sp-path.h" +#include "ui/icon-names.h" + +#include <glibmm/i18n.h> + +namespace Inkscape { +namespace LivePathEffect { + +LPETransform2Pts::LPETransform2Pts(LivePathEffectObject *lpeobject) : + Effect(lpeobject), + from_original_width(_("From original width"), _("From original width"), "from_original_width", &wr, this, false,"", INKSCAPE_ICON("on"), INKSCAPE_ICON("off")), + start(_("Start"), _("Start point"), "start", &wr, this, "Start point"), + end(_("End"), _("End point"), "end", &wr, this, "End point"), + first_knot(_("First Knot"), _("First Knot"), "first_knot", &wr, this, 1), + last_knot(_("Last Knot"), _("Last Knot"), "last_knot", &wr, this, 1), + from_original_width_toggler(false), + point_a(Geom::Point()), + point_b(Geom::Point()), + pathvector(), + append_path(false) +{ + registerParameter(&start); + registerParameter(&end); + registerParameter(&first_knot); + registerParameter(&last_knot); + registerParameter(&from_original_width); + + first_knot.param_make_integer(true); + last_knot.param_make_integer(true); +} + +LPETransform2Pts::~LPETransform2Pts() +{ +} + +void +LPETransform2Pts::doOnApply(SPLPEItem const* lpeitem) +{ + using namespace Geom; + original_bbox(lpeitem); + + point_a = Point(boundingbox_X.min(), boundingbox_Y.middle()); + point_b = Point(boundingbox_X.max(), boundingbox_Y.middle()); + SPLPEItem * splpeitem = const_cast<SPLPEItem *>(lpeitem); + SPPath *sp_path = dynamic_cast<SPPath *>(splpeitem); + if (sp_path) { + pathvector = sp_path->get_original_curve()->get_pathvector(); + } + if(!pathvector.empty()) { + point_a = pathvector.initialPoint(); + point_b = pathvector.finalPoint(); + if(are_near(point_a,point_b)){ + point_b = pathvector.back().finalCurve().initialPoint(); + } + size_t nnodes = nodeCount(pathvector); + last_knot.param_set_value(nnodes); + } + start.param_update_default(point_a); + start.param_set_default(); + end.param_update_default(point_b); + end.param_set_default(); +} + +void +LPETransform2Pts::doBeforeEffect (SPLPEItem const* lpeitem) +{ + using namespace Geom; + original_bbox(lpeitem); + point_a = Point(boundingbox_X.min(), boundingbox_Y.middle()); + point_b = Point(boundingbox_X.max(), boundingbox_Y.middle()); + + SPLPEItem * splpeitem = const_cast<SPLPEItem *>(lpeitem); + SPPath *sp_path = dynamic_cast<SPPath *>(splpeitem); + if (sp_path) { + pathvector = sp_path->get_original_curve()->get_pathvector(); + } + if(from_original_width_toggler != from_original_width) { + from_original_width_toggler = from_original_width; + reset(); + } + if(!pathvector.empty() && !from_original_width) { + append_path = false; + point_a = pointAtNodeIndex(pathvector,(size_t)first_knot-1); + point_b = pointAtNodeIndex(pathvector,(size_t)last_knot-1); + size_t nnodes = nodeCount(pathvector); + std::cout << nnodes << "nnodes\n"; + first_knot.param_set_range(1, last_knot-1); + last_knot.param_set_range(first_knot+1, nnodes); + from_original_width.param_setValue(false); + } else { + first_knot.param_set_value(1); + last_knot.param_set_value(2); + first_knot.param_set_range(1,1); + last_knot.param_set_range(2,2); + from_original_width.param_setValue(true); + append_path = false; + } + splpeitem->apply_to_clippath(splpeitem); + splpeitem->apply_to_mask(splpeitem); +} + +void +LPETransform2Pts::updateIndex() +{ + SPLPEItem * splpeitem = const_cast<SPLPEItem *>(sp_lpe_item); + SPPath *sp_path = dynamic_cast<SPPath *>(splpeitem); + if (sp_path) { + pathvector = sp_path->get_original_curve()->get_pathvector(); + } + if(!pathvector.empty() && !from_original_width) { + point_a = pointAtNodeIndex(pathvector,(size_t)first_knot-1); + point_b = pointAtNodeIndex(pathvector,(size_t)last_knot-1); + start.param_update_default(point_a); + start.param_set_default(); + end.param_update_default(point_b); + end.param_set_default(); + start.param_update_default(point_a); + end.param_update_default(point_b); + start.param_set_default(); + end.param_set_default(); + } +} +//todo migrate to PathVector class? +size_t +LPETransform2Pts::nodeCount(Geom::PathVector pathvector) const +{ + size_t n = 0; + for (Geom::PathVector::iterator it = pathvector.begin(); it != pathvector.end(); ++it) { + n += it->size_closed(); + } + return n; +} +//todo migrate to PathVector class? +Geom::Point +LPETransform2Pts::pointAtNodeIndex(Geom::PathVector pathvector, size_t index) const +{ + size_t n = 0; + for (Geom::PathVector::iterator pv_it = pathvector.begin(); pv_it != pathvector.end(); ++pv_it) { + for (Geom::Path::iterator curve_it = pv_it->begin(); curve_it != pv_it->end_closed(); ++curve_it) { + if(index == n){ + return curve_it->initialPoint(); + } + n++; + } + } + return Geom::Point(); +} +//todo migrate to PathVector class? Not used +Geom::Path +LPETransform2Pts::pathAtNodeIndex(Geom::PathVector pathvector, size_t index) const +{ + size_t n = 0; + for (Geom::PathVector::iterator pv_it = pathvector.begin(); pv_it != pathvector.end(); ++pv_it) { + for (Geom::Path::iterator curve_it = pv_it->begin(); curve_it != pv_it->end_closed(); ++curve_it) { + if(index == n){ + return *pv_it; + } + n++; + } + } + return Geom::Path(); +} + + +void +LPETransform2Pts::reset() +{ + point_a = Geom::Point(boundingbox_X.min(), boundingbox_Y.middle()); + point_b = Geom::Point(boundingbox_X.max(), boundingbox_Y.middle()); + if(!pathvector.empty() && !from_original_width) { + size_t nnodes = nodeCount(pathvector); + first_knot.param_set_range(1, last_knot-1); + last_knot.param_set_range(first_knot+1, nnodes); + first_knot.param_set_value(1); + last_knot.param_set_value(nnodes); + point_a = pathvector.initialPoint(); + point_b = pathvector.finalPoint(); + } else { + first_knot.param_set_value(1); + last_knot.param_set_value(2); + } + start.param_update_default(point_a); + end.param_update_default(point_b); + start.param_set_default(); + end.param_set_default(); +} + +Gtk::Widget *LPETransform2Pts::newWidget() +{ + // use manage here, because after deletion of Effect object, others might + // still be pointing to this widget. + Gtk::VBox *vbox = Gtk::manage(new Gtk::VBox(Effect::newWidget())); + + vbox->set_border_width(5); + vbox->set_homogeneous(false); + vbox->set_spacing(6); + + std::vector<Parameter *>::iterator it = param_vector.begin(); + Gtk::HBox * button = Gtk::manage(new Gtk::HBox(true,0)); + while (it != param_vector.end()) { + if ((*it)->widget_is_visible) { + Parameter *param = *it; + Gtk::Widget *widg = dynamic_cast<Gtk::Widget *>(param->param_newWidget()); + Glib::ustring *tip = param->param_getTooltip(); + if (param->param_key == "first_knot" || param->param_key == "last_knot") { + Inkscape::UI::Widget::Scalar *registered_widget = Gtk::manage(dynamic_cast<Inkscape::UI::Widget::Scalar *>(widg)); + registered_widget->signal_value_changed().connect(sigc::mem_fun(*this, &LPETransform2Pts::updateIndex)); + widg = registered_widget; + if (widg) { + Gtk::HBox *hbox_scalar = dynamic_cast<Gtk::HBox *>(widg); + std::vector<Gtk::Widget *> child_list = hbox_scalar->get_children(); + Gtk::Entry *entry_widget = dynamic_cast<Gtk::Entry *>(child_list[1]); + entry_widget->set_width_chars(3); + vbox->pack_start(*widg, true, true, 2); + if (tip) { + widg->set_tooltip_text(*tip); + } else { + widg->set_tooltip_text(""); + widg->set_has_tooltip(false); + } + } + } else if (param->param_key == "from_original_width") { + Glib::ustring * tip = param->param_getTooltip(); + if (widg) { + button->pack_start(*widg, true, true, 2); + if (tip) { + widg->set_tooltip_text(*tip); + } else { + widg->set_tooltip_text(""); + widg->set_has_tooltip(false); + } + } + } else if (widg) { + vbox->pack_start(*widg, true, true, 2); + if (tip) { + widg->set_tooltip_text(*tip); + } else { + widg->set_tooltip_text(""); + widg->set_has_tooltip(false); + } + } + } + + ++it; + } + Gtk::Button *reset = Gtk::manage(new Gtk::Button(Glib::ustring(_("Reset")))); + reset->signal_clicked().connect(sigc::mem_fun(*this, &LPETransform2Pts::reset)); + button->pack_start(*reset, true, true, 2); + vbox->pack_start(*button, true, true, 2); + return dynamic_cast<Gtk::Widget *>(vbox); +} + +Geom::Piecewise<Geom::D2<Geom::SBasis> > +LPETransform2Pts::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in) +{ + Geom::Piecewise<Geom::D2<Geom::SBasis> > output; + double sca = Geom::distance((Geom::Point)start,(Geom::Point)end)/Geom::distance(point_a,point_b); + Geom::Ray original(point_a,point_b); + Geom::Ray transformed((Geom::Point)start,(Geom::Point)end); + double rot = transformed.angle() - original.angle(); + Geom::Path helper; + helper.start(point_a); + helper.appendNew<Geom::LineSegment>(point_b); + Geom::Affine m; + m *= Geom::Scale(sca); + m *= Geom::Rotate(rot); + helper *= m; + m *= Geom::Translate((Geom::Point)start - helper.initialPoint()); + output.concat(pwd2_in * m); + + return output; +} + +void +LPETransform2Pts::addCanvasIndicators(SPLPEItem const */*lpeitem*/, std::vector<Geom::PathVector> &hp_vec) +{ + using namespace Geom; + hp_vec.clear(); + Geom::Path hp; + hp.start((Geom::Point)start); + hp.appendNew<Geom::LineSegment>((Geom::Point)end); + Geom::PathVector pathv; + pathv.push_back(hp); + hp_vec.push_back(pathv); +} + + +/* ######################## */ + +} //namespace LivePathEffect +} /* namespace Inkscape */ + +/* + 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 : diff --git a/src/live_effects/lpe-transform_2pts.h b/src/live_effects/lpe-transform_2pts.h new file mode 100644 index 000000000..855780a7a --- /dev/null +++ b/src/live_effects/lpe-transform_2pts.h @@ -0,0 +1,80 @@ +#ifndef INKSCAPE_LPE_TRANSFORM_2PTS_H +#define INKSCAPE_LPE_TRANSFORM_2PTS_H + +/** \file + * LPE "Transform through 2 points" implementation + */ + +/* + * Authors: + * + * + * + * Released under GNU GPL, read the file 'COPYING' for more information + */ + +#include "live_effects/effect.h" +#include "live_effects/lpegroupbbox.h" +#include "live_effects/parameter/parameter.h" +#include "live_effects/parameter/togglebutton.h" +#include "live_effects/parameter/point.h" + +namespace Inkscape { +namespace LivePathEffect { + +class LPETransform2Pts : public Effect, GroupBBoxEffect { +public: + LPETransform2Pts(LivePathEffectObject *lpeobject); + virtual ~LPETransform2Pts(); + + virtual void doOnApply (SPLPEItem const* lpeitem); + + virtual Geom::Piecewise<Geom::D2<Geom::SBasis> > doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_in); + + virtual void doBeforeEffect (SPLPEItem const* lpeitem); + + virtual Gtk::Widget *newWidget(); + + void updateIndex(); + + size_t nodeCount(Geom::PathVector pathvector) const; + + Geom::Point pointAtNodeIndex(Geom::PathVector pathvector, size_t index) const; + + Geom::Path pathAtNodeIndex(Geom::PathVector pathvector, size_t index) const; + + void reset(); + +protected: + virtual void addCanvasIndicators(SPLPEItem const *lpeitem, std::vector<Geom::PathVector> &hp_vec); + +private: + ToggleButtonParam from_original_width; + PointParam start; + PointParam end; + ScalarParam first_knot; + ScalarParam last_knot; + bool from_original_width_toggler; + Geom::Point point_a; + Geom::Point point_b; + Geom::PathVector pathvector; + bool append_path; + LPETransform2Pts(const LPETransform2Pts&); + LPETransform2Pts& operator=(const LPETransform2Pts&); +}; + +} //namespace LivePathEffect +} //namespace Inkscape + +#endif + +/* + 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 : diff --git a/src/sp-factory.cpp b/src/sp-factory.cpp index 84329eaaf..20472d425 100644 --- a/src/sp-factory.cpp +++ b/src/sp-factory.cpp @@ -294,6 +294,8 @@ SPObject *SPFactory::createObject(std::string const& id) {} else if (id == "inkscape:clipboard") // SP node not necessary {} + else if (id == "inkscape:_templateinfo") // ? + {} else if (id.empty()) // comments {} else { diff --git a/src/sp-guide.cpp b/src/sp-guide.cpp index 4e1c5913d..b9c124138 100644 --- a/src/sp-guide.cpp +++ b/src/sp-guide.cpp @@ -26,6 +26,7 @@ #include "display/sp-canvas.h" #include "display/guideline.h" #include "svg/svg.h" +#include "svg/svg-color.h" #include "svg/stringstream.h" #include "attributes.h" #include "sp-guide.h" @@ -70,6 +71,7 @@ void SPGuide::build(SPDocument *document, Inkscape::XML::Node *repr) { SPObject::build(document, repr); + this->readAttr( "inkscape:color" ); this->readAttr( "inkscape:label" ); this->readAttr( "orientation" ); this->readAttr( "position" ); @@ -95,6 +97,11 @@ void SPGuide::release() void SPGuide::set(unsigned int key, const gchar *value) { switch (key) { + case SP_ATTR_INKSCAPE_COLOR: + if (value) { + this->setColor(sp_svg_read_color(value, 0x0000ff00) | 0x7f); + } + break; case SP_ATTR_INKSCAPE_LABEL: if (this->label) g_free(this->label); diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp index 12c2cdf8e..b8554f352 100644 --- a/src/sp-namedview.cpp +++ b/src/sp-namedview.cpp @@ -249,6 +249,7 @@ void SPNamedView::build(SPDocument *document, Inkscape::XML::Node *repr) { //g_object_set(G_OBJECT(g), "color", nv->guidecolor, "hicolor", nv->guidehicolor, NULL); g->setColor(this->guidecolor); g->setHiColor(this->guidehicolor); + g->readAttr( "inkscape:color" ); } } @@ -325,8 +326,9 @@ void SPNamedView::set(unsigned int key, const gchar* value) { } for (GSList *l = this->guides; l != NULL; l = l->next) { - //g_object_set(G_OBJECT(l->data), "color", nv->guidecolor, NULL); - SP_GUIDE(l->data)->setColor(this->guidecolor); + SPGuide * g = SP_GUIDE(l->data); + g->setColor(this->guidecolor); + g->readAttr("inkscape:color"); } this->requestModified(SP_OBJECT_MODIFIED_FLAG); @@ -336,8 +338,9 @@ void SPNamedView::set(unsigned int key, const gchar* value) { sp_nv_read_opacity(value, &this->guidecolor); for (GSList *l = this->guides; l != NULL; l = l->next) { - //g_object_set(G_OBJECT(l->data), "color", nv->guidecolor, NULL); - SP_GUIDE(l->data)->setColor(this->guidecolor); + SPGuide * g = SP_GUIDE(l->data); + g->setColor(this->guidecolor); + g->readAttr("inkscape:color"); } this->requestModified(SP_OBJECT_MODIFIED_FLAG); @@ -662,6 +665,7 @@ void SPNamedView::child_added(Inkscape::XML::Node *child, Inkscape::XML::Node *r //g_object_set(G_OBJECT(g), "color", this->guidecolor, "hicolor", this->guidehicolor, NULL); g->setColor(this->guidecolor); g->setHiColor(this->guidehicolor); + g->readAttr("inkscape:color"); if (this->editable) { for (GSList *l = this->views; l != NULL; l = l->next) { diff --git a/src/sp-paint-server.cpp b/src/sp-paint-server.cpp index c3416c6c8..d445ca0a7 100644 --- a/src/sp-paint-server.cpp +++ b/src/sp-paint-server.cpp @@ -39,7 +39,9 @@ SPPaintServer::~SPPaintServer() { bool SPPaintServer::isSwatch() const { - return swatch; + if( this ) // Protect against assumption that "vector" always exists. + return swatch; + return( false ); } |
