summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohan B. C. Engelen <jbc.engelen@swissonline.ch>2010-02-14 23:53:33 +0000
committerJohan <Johan@JohannesMobile>2010-02-14 23:53:33 +0000
commitbe7994523333ce17d828ef5923b8c183fdb750e7 (patch)
tree028ddd2e838a24351fd3a5c7517c288194cc577d /src
parentGradient editor: don't show pre-snap indicator when hovering above the knot o... (diff)
parentfix bug: when creating an xy-grid, respect the default unit setting. (the pre... (diff)
downloadinkscape-be7994523333ce17d828ef5923b8c183fdb750e7.tar.gz
inkscape-be7994523333ce17d828ef5923b8c183fdb750e7.zip
- fix bug: xy grid default unit was not respected
- color original-d path as normal path in node tool - remove obsolete todo comment - add widget controls for vectorparam in lpe (bzr r9092)
Diffstat (limited to 'src')
-rw-r--r--src/live_effects/effect.cpp1
-rw-r--r--src/live_effects/lpe-rough-hatches.cpp4
-rw-r--r--src/live_effects/parameter/vector.cpp30
-rw-r--r--src/ui/dialog/inkscape-preferences.cpp2
-rw-r--r--src/ui/tool/node-tool.cpp2
-rw-r--r--src/ui/widget/labelled.h2
-rw-r--r--src/ui/widget/point.cpp2
-rw-r--r--src/ui/widget/point.h2
-rw-r--r--src/ui/widget/registered-widget.cpp90
-rw-r--r--src/ui/widget/registered-widget.h25
10 files changed, 138 insertions, 22 deletions
diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp
index d53048c76..f761a6a7c 100644
--- a/src/live_effects/effect.cpp
+++ b/src/live_effects/effect.cpp
@@ -673,7 +673,6 @@ Effect::transform_multiply(Geom::Matrix const& postmul, bool set)
}
}
-// TODO: take _all_ parameters into account, not only PointParams
bool
Effect::providesKnotholder()
{
diff --git a/src/live_effects/lpe-rough-hatches.cpp b/src/live_effects/lpe-rough-hatches.cpp
index 228857ebf..f110aa743 100644
--- a/src/live_effects/lpe-rough-hatches.cpp
+++ b/src/live_effects/lpe-rough-hatches.cpp
@@ -279,6 +279,10 @@ LPERoughHatches::LPERoughHatches(LivePathEffectObject *lpeobject) :
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;
}
diff --git a/src/live_effects/parameter/vector.cpp b/src/live_effects/parameter/vector.cpp
index 35afe7f5d..5496b52f2 100644
--- a/src/live_effects/parameter/vector.cpp
+++ b/src/live_effects/parameter/vector.cpp
@@ -13,8 +13,9 @@
#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 {
@@ -82,28 +83,23 @@ VectorParam::param_getSVGValue() const
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
diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp
index 821a7c095..82bca9da0 100644
--- a/src/ui/dialog/inkscape-preferences.cpp
+++ b/src/ui/dialog/inkscape-preferences.cpp
@@ -1020,7 +1020,7 @@ void InkscapePreferences::initPageGrids()
_page_grids.add_line( false, "", _grids_notebook, "", "", false);
_grids_notebook.append_page(_grids_xy, CanvasGrid::getName( GRID_RECTANGULAR ));
_grids_notebook.append_page(_grids_axonom, CanvasGrid::getName( GRID_AXONOMETRIC ));
- _grids_xy_units.init("/options/grids/units");
+ _grids_xy_units.init("/options/grids/xy/units");
_grids_xy.add_line( false, _("Grid units:"), _grids_xy_units, "", "", false);
_grids_xy_origin_x.init("/options/grids/xy/origin_x", -10000.0, 10000.0, 0.1, 1.0, 0.0, false, false);
_grids_xy_origin_y.init("/options/grids/xy/origin_y", -10000.0, 10000.0, 0.1, 1.0, 0.0, false, false);
diff --git a/src/ui/tool/node-tool.cpp b/src/ui/tool/node-tool.cpp
index 7ddd3316b..443e7f258 100644
--- a/src/ui/tool/node-tool.cpp
+++ b/src/ui/tool/node-tool.cpp
@@ -362,7 +362,7 @@ void gather_items(InkNodeTool *nt, SPItem *base, SPObject *obj, Inkscape::UI::Sh
ShapeRecord r;
r.item = static_cast<SPItem*>(obj);
r.edit_transform = Geom::identity(); // TODO wrong?
- r.role = SHAPE_ROLE_LPE_PARAM;
+ r.role = role;
s.insert(r);
} else if (role != SHAPE_ROLE_NORMAL && (SP_IS_GROUP(obj) || SP_IS_OBJECTGROUP(obj))) {
for (SPObject *c = obj->children; c; c = c->next) {
diff --git a/src/ui/widget/labelled.h b/src/ui/widget/labelled.h
index 3685944a4..5670af0b6 100644
--- a/src/ui/widget/labelled.h
+++ b/src/ui/widget/labelled.h
@@ -39,6 +39,8 @@ public:
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;
diff --git a/src/ui/widget/point.cpp b/src/ui/widget/point.cpp
index 508a8d961..f27cfe8c6 100644
--- a/src/ui/widget/point.cpp
+++ b/src/ui/widget/point.cpp
@@ -194,7 +194,7 @@ Point::setRange(double min, double max)
/** 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 57a46de76..94477d877 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(Geom::Point & p);
+ void setValue(Geom::Point const & p);
void update();
diff --git a/src/ui/widget/registered-widget.cpp b/src/ui/widget/registered-widget.cpp
index 95ddec286..db31d08d3 100644
--- a/src/ui/widget/registered-widget.cpp
+++ b/src/ui/widget/registered-widget.cpp
@@ -587,6 +587,96 @@ RegisteredTransformedPoint::on_value_changed()
}
/*#########################################
+ * 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
*/
diff --git a/src/ui/widget/registered-widget.h b/src/ui/widget/registered-widget.h
index a5c61f68a..7aefbb90e 100644
--- a/src/ui/widget/registered-widget.h
+++ b/src/ui/widget/registered-widget.h
@@ -334,6 +334,31 @@ protected:
};
+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();