589
589
/*#########################################
590
* Registered TRANSFORMEDPOINT
593
RegisteredVector::~RegisteredVector()
595
_value_x_changed_connection.disconnect();
596
_value_y_changed_connection.disconnect();
599
RegisteredVector::RegisteredVector ( const Glib::ustring& label, const Glib::ustring& tip,
600
const Glib::ustring& key, Registry& wr, Inkscape::XML::Node* repr_in,
602
: RegisteredWidget<Point> (label, tip),
605
init_parent(key, wr, repr_in, doc_in);
607
setRange (-1e6, 1e6);
609
setIncrements(0.1, 1.0);
610
_value_x_changed_connection = signal_x_value_changed().connect (sigc::mem_fun (*this, &RegisteredVector::on_value_changed));
611
_value_y_changed_connection = signal_y_value_changed().connect (sigc::mem_fun (*this, &RegisteredVector::on_value_changed));
615
RegisteredVector::setValue(Geom::Point const & p)
617
if (!_polar_coords) {
621
polar[Geom::X] = atan2(p) *180/M_PI;
622
polar[Geom::Y] = p.length();
623
Point::setValue(polar);
628
RegisteredVector::setValue(Geom::Point const & p, Geom::Point const & origin)
630
RegisteredVector::setValue(p);
635
* Changes the widgets text to polar coordinates. The SVG output will still be a normal carthesian vector.
636
* Careful: when calling getValue(), the return value's X-coord will be the angle, Y-value will be the distance/length.
637
* After changing the coords type (polar/non-polar), the value has to be reset (setValue).
640
RegisteredVector::setPolarCoords(bool polar_coords)
642
_polar_coords = polar_coords;
644
xwidget.setLabelText("Angle:");
645
ywidget.setLabelText("Distance:");
647
xwidget.setLabelText("X:");
648
ywidget.setLabelText("Y:");
653
RegisteredVector::on_value_changed()
655
if (setProgrammatically()) {
656
clearProgrammatically();
660
if (_wr->isUpdating())
663
_wr->setUpdating (true);
665
Geom::Point origin = _origin;
666
Geom::Point vector = getValue();
668
vector = Geom::Point::polar(vector[Geom::X]*M_PI/180, vector[Geom::Y]);
671
Inkscape::SVGOStringStream os;
672
os << origin << " , " << vector;
674
write_to_xml(os.str().c_str());
676
_wr->setUpdating (false);
679
/*#########################################
590
680
* Registered RANDOM