From: johanengelen Date: Sat, 22 Mar 2008 21:19:28 +0000 (+0000) Subject: changes to use RegisteredTransformedPoint as widget for LPE point. not complete X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=f84b3e8cf4811cb3ce6c33fb7341d0e836be583c;p=inkscape.git changes to use RegisteredTransformedPoint as widget for LPE point. not complete --- diff --git a/src/live_effects/parameter/point.cpp b/src/live_effects/parameter/point.cpp index 9b48327f6..1dbdbd6aa 100644 --- a/src/live_effects/parameter/point.cpp +++ b/src/live_effects/parameter/point.cpp @@ -78,14 +78,14 @@ PointParam::param_writeSVGValue() const Gtk::Widget * PointParam::param_newWidget(Gtk::Tooltips * tooltips) { - Inkscape::UI::Widget::RegisteredPoint * pointwdg = Gtk::manage( - new Inkscape::UI::Widget::RegisteredPoint( param_label, - param_tooltip, - param_key, - *param_wr, - param_effect->getRepr(), - param_effect->getSPDoc() ) ); - pointwdg->setValue( (*this)[0], (*this)[1] ); + Inkscape::UI::Widget::RegisteredTransformedPoint * pointwdg = Gtk::manage( + new Inkscape::UI::Widget::RegisteredTransformedPoint( param_label, + param_tooltip, + param_key, + *param_wr, + param_effect->getRepr(), + param_effect->getSPDoc() ) ); + pointwdg->setValue( *this ); pointwdg->clearProgrammatically(); pointwdg->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change point parameter")); diff --git a/src/ui/widget/point.cpp b/src/ui/widget/point.cpp index 1efb26a78..508a8d961 100644 --- a/src/ui/widget/point.cpp +++ b/src/ui/widget/point.cpp @@ -194,10 +194,10 @@ Point::setRange(double min, double max) /** Sets the value of the spin button */ void -Point::setValue(double xvalue, double yvalue) +Point::setValue(Geom::Point & p) { - xwidget.setValue(xvalue); - ywidget.setValue(yvalue); + xwidget.setValue(p[0]); + ywidget.setValue(p[1]); } /** Manually forces an update of the spin button */ diff --git a/src/ui/widget/point.h b/src/ui/widget/point.h index a9be05afc..57a46de76 100644 --- a/src/ui/widget/point.h +++ b/src/ui/widget/point.h @@ -64,7 +64,7 @@ public: void setDigits(unsigned digits); void setIncrements(double step, double page); void setRange(double min, double max); - void setValue(double xvalue, double yvalue); + void setValue(Geom::Point & p); void update(); diff --git a/src/ui/widget/registered-widget.cpp b/src/ui/widget/registered-widget.cpp index 1de084f5d..1fd956897 100644 --- a/src/ui/widget/registered-widget.cpp +++ b/src/ui/widget/registered-widget.cpp @@ -481,7 +481,7 @@ RegisteredTransformedPoint::RegisteredTransformedPoint ( const Glib::ustring& la const Glib::ustring& key, Registry& wr, Inkscape::XML::Node* repr_in, SPDocument* doc_in ) : RegisteredWidget (label, tip), - transform(Geom::identity()) + to_svg(Geom::identity()) { init_parent(key, wr, repr_in, doc_in); @@ -492,6 +492,25 @@ RegisteredTransformedPoint::RegisteredTransformedPoint ( const Glib::ustring& la _value_y_changed_connection = signal_y_value_changed().connect (sigc::mem_fun (*this, &RegisteredTransformedPoint::on_value_changed)); } +void +RegisteredTransformedPoint::setValue(Geom::Point & p) +{ + Geom::Point new_p = p * to_svg.inverse(); + Point::setValue(new_p); // the Point widget should display things in canvas coordinates +} + +void +RegisteredTransformedPoint::setTransform(Geom::Matrix & canvas_to_svg) +{ + // check if matrix is singular / has inverse + if ( ! canvas_to_svg.isSingular() ) { + to_svg = canvas_to_svg; + } else { + // set back to default + to_svg = Geom::identity(); + } +} + void RegisteredTransformedPoint::on_value_changed() { @@ -505,7 +524,7 @@ RegisteredTransformedPoint::on_value_changed() _wr->setUpdating (true); - Geom::Point pos = getValue() * transform; + Geom::Point pos = getValue() * to_svg; Inkscape::SVGOStringStream os; os << pos; diff --git a/src/ui/widget/registered-widget.h b/src/ui/widget/registered-widget.h index f34895620..d5f7591ee 100644 --- a/src/ui/widget/registered-widget.h +++ b/src/ui/widget/registered-widget.h @@ -304,12 +304,17 @@ public: Inkscape::XML::Node* repr_in = NULL, SPDocument *doc_in = NULL ); + // redefine setValue, because transform must be applied + void setValue(Geom::Point & p); + + void setTransform(Geom::Matrix & canvas_to_svg); + protected: sigc::connection _value_x_changed_connection; sigc::connection _value_y_changed_connection; void on_value_changed(); - Geom::Matrix transform; + Geom::Matrix to_svg; };