summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 63beb77)
raw | patch | inline | side by side (parent: 63beb77)
author | Johan <Johan@JohannesMobile> | |
Sun, 14 Feb 2010 21:56:16 +0000 (22:56 +0100) | ||
committer | Johan <Johan@JohannesMobile> | |
Sun, 14 Feb 2010 21:56:16 +0000 (22:56 +0100) |
index 228857ebf86f99cfe63ef229b2075c97882fcd87..f110aa7433b328980b343a29789fa4e848b7643c 100644 (file)
front_thickness.param_set_range(0, NR_HUGE);
back_thickness.param_set_range(0, NR_HUGE);
+ // hide the widgets for direction and bender vectorparams
+ direction.widget_is_visible = false;
+ bender.widget_is_visible = false;
+
concatenate_before_pwd2 = false;
show_orig_path = true;
}
index 35afe7f5d39ff8eb3f2ef414981d9b48fcf780fc..5496b52f29ee31d5c58cb4b4191bb0bab7857bfd 100644 (file)
#include "svg/stringstream.h"
#include <gtkmm.h>
-// needed for on-canvas editting:
-class SPDesktop;
+#include "ui/widget/registered-widget.h"
+#include "live_effects/effect.h"
+#include "desktop.h"
namespace Inkscape {
Gtk::Widget *
VectorParam::param_newWidget(Gtk::Tooltips * /*tooltips*/)
{
-/*
- 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() ) );
- // TODO: fix to get correct desktop (don't use SP_ACTIVE_DESKTOP)
- SPDesktop *desktop = SP_ACTIVE_DESKTOP;
- Geom::Matrix transf = desktop->doc2dt();
- pointwdg->setTransform(transf);
- pointwdg->setValue( *this );
+ Inkscape::UI::Widget::RegisteredVector * pointwdg = Gtk::manage(
+ new Inkscape::UI::Widget::RegisteredVector( param_label,
+ param_tooltip,
+ param_key,
+ *param_wr,
+ param_effect->getRepr(),
+ param_effect->getSPDoc() ) );
+ pointwdg->setPolarCoords();
+ pointwdg->setValue( vector, origin );
pointwdg->clearProgrammatically();
- pointwdg->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change point parameter"));
+ pointwdg->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change vector parameter"));
Gtk::HBox * hbox = Gtk::manage( new Gtk::HBox() );
static_cast<Gtk::HBox*>(hbox)->pack_start(*pointwdg, true, true);
static_cast<Gtk::HBox*>(hbox)->show_all_children();
return dynamic_cast<Gtk::Widget *> (hbox);
- */ return NULL;
}
void
index 3685944a41c43ef688160ca7951b65b039a3f619..5670af0b6657d6e36c49dd26573cacae28ae7909 100644 (file)
--- a/src/ui/widget/labelled.h
+++ b/src/ui/widget/labelled.h
Gtk::Widget const *getWidget() const;
Gtk::Label const *getLabel() const;
+ void setLabelText(const Glib::ustring &str) { _label->set_text(str); };
+
protected:
Gtk::Widget *_widget;
Gtk::Label *_label;
index 508a8d96186abc0d68d26ee6a22f25f5b802d012..f27cfe8c686b9e2fba56947e021cebfc92076176 100644 (file)
--- a/src/ui/widget/point.cpp
+++ b/src/ui/widget/point.cpp
/** Sets the value of the spin button */
void
-Point::setValue(Geom::Point & p)
+Point::setValue(Geom::Point const & p)
{
xwidget.setValue(p[0]);
ywidget.setValue(p[1]);
diff --git a/src/ui/widget/point.h b/src/ui/widget/point.h
index 57a46de766eb12263d42fc34742fa43412717519..94477d877c7532f8a0d0cbbea9d68e366829cf5a 100644 (file)
--- a/src/ui/widget/point.h
+++ b/src/ui/widget/point.h
void setDigits(unsigned digits);
void setIncrements(double step, double page);
void setRange(double min, double max);
- void setValue(Geom::Point & p);
+ void setValue(Geom::Point const & p);
void update();
index 95ddec286c4a8641d0dcacb5bb3988fa22a5b330..db31d08d340288573c82cf06bf0ddb0251919dee 100644 (file)
_wr->setUpdating (false);
}
+/*#########################################
+ * Registered TRANSFORMEDPOINT
+ */
+
+RegisteredVector::~RegisteredVector()
+{
+ _value_x_changed_connection.disconnect();
+ _value_y_changed_connection.disconnect();
+}
+
+RegisteredVector::RegisteredVector ( const Glib::ustring& label, const Glib::ustring& tip,
+ const Glib::ustring& key, Registry& wr, Inkscape::XML::Node* repr_in,
+ SPDocument* doc_in )
+ : RegisteredWidget<Point> (label, tip),
+ _polar_coords(false)
+{
+ init_parent(key, wr, repr_in, doc_in);
+
+ setRange (-1e6, 1e6);
+ setDigits (2);
+ setIncrements(0.1, 1.0);
+ _value_x_changed_connection = signal_x_value_changed().connect (sigc::mem_fun (*this, &RegisteredVector::on_value_changed));
+ _value_y_changed_connection = signal_y_value_changed().connect (sigc::mem_fun (*this, &RegisteredVector::on_value_changed));
+}
+
+void
+RegisteredVector::setValue(Geom::Point const & p)
+{
+ if (!_polar_coords) {
+ Point::setValue(p);
+ } else {
+ Geom::Point polar;
+ polar[Geom::X] = atan2(p) *180/M_PI;
+ polar[Geom::Y] = p.length();
+ Point::setValue(polar);
+ }
+}
+
+void
+RegisteredVector::setValue(Geom::Point const & p, Geom::Point const & origin)
+{
+ RegisteredVector::setValue(p);
+ _origin = origin;
+}
+
+/**
+ * Changes the widgets text to polar coordinates. The SVG output will still be a normal carthesian vector.
+ * Careful: when calling getValue(), the return value's X-coord will be the angle, Y-value will be the distance/length.
+ * After changing the coords type (polar/non-polar), the value has to be reset (setValue).
+ */
+void
+RegisteredVector::setPolarCoords(bool polar_coords)
+{
+ _polar_coords = polar_coords;
+ if (polar_coords) {
+ xwidget.setLabelText("Angle:");
+ ywidget.setLabelText("Distance:");
+ } else {
+ xwidget.setLabelText("X:");
+ ywidget.setLabelText("Y:");
+ }
+}
+
+void
+RegisteredVector::on_value_changed()
+{
+ if (setProgrammatically()) {
+ clearProgrammatically();
+ return;
+ }
+
+ if (_wr->isUpdating())
+ return;
+
+ _wr->setUpdating (true);
+
+ Geom::Point origin = _origin;
+ Geom::Point vector = getValue();
+ if (_polar_coords) {
+ vector = Geom::Point::polar(vector[Geom::X]*M_PI/180, vector[Geom::Y]);
+ }
+
+ Inkscape::SVGOStringStream os;
+ os << origin << " , " << vector;
+
+ write_to_xml(os.str().c_str());
+
+ _wr->setUpdating (false);
+}
+
/*#########################################
* Registered RANDOM
*/
index a5c61f68a445fe57ef0b099fe074643c73e7351d..7aefbb90e4005d4cf343050ef12104ef837b0f0c 100644 (file)
};
+class RegisteredVector : public RegisteredWidget<Point> {
+public:
+ virtual ~RegisteredVector();
+ RegisteredVector (const Glib::ustring& label,
+ const Glib::ustring& tip,
+ const Glib::ustring& key,
+ Registry& wr,
+ Inkscape::XML::Node* repr_in = NULL,
+ SPDocument *doc_in = NULL );
+
+ // redefine setValue, because transform must be applied
+ void setValue(Geom::Point const & p);
+ void setValue(Geom::Point const & p, Geom::Point const & origin);
+ void setPolarCoords(bool polar_coords = true);
+
+protected:
+ sigc::connection _value_x_changed_connection;
+ sigc::connection _value_y_changed_connection;
+ void on_value_changed();
+
+ Geom::Point _origin;
+ bool _polar_coords;
+};
+
+
class RegisteredRandom : public RegisteredWidget<Random> {
public:
virtual ~RegisteredRandom();