summaryrefslogtreecommitdiffstats
path: root/src/ui/tools/node-tool.cpp
diff options
context:
space:
mode:
authorAlexander Brock <Brock.Alexander@web.de>2015-06-08 14:23:08 +0000
committerAlexander Brock <Brock.Alexander@web.de>2015-06-08 14:23:08 +0000
commit83ff4841d5b11aed63f1deb9e1b606eee87f30bb (patch)
treec0994aace2b001b5ef34dfffc9fe8865ee7ec0a5 /src/ui/tools/node-tool.cpp
parentcmake: Drop todo for icons; the install of share takes care of this (diff)
downloadinkscape-83ff4841d5b11aed63f1deb9e1b606eee87f30bb.tar.gz
inkscape-83ff4841d5b11aed63f1deb9e1b606eee87f30bb.zip
Show angle of selected line segments relative to X-axis
(bzr r14195.1.1)
Diffstat (limited to 'src/ui/tools/node-tool.cpp')
-rw-r--r--src/ui/tools/node-tool.cpp29
1 files changed, 26 insertions, 3 deletions
diff --git a/src/ui/tools/node-tool.cpp b/src/ui/tools/node-tool.cpp
index 761492f41..5c97a4c7f 100644
--- a/src/ui/tools/node-tool.cpp
+++ b/src/ui/tools/node-tool.cpp
@@ -665,9 +665,32 @@ void NodeTool::update_tip(GdkEvent *event) {
unsigned total = this->_selected_nodes->allPoints().size();
if (sz != 0) {
- char *nodestring = g_strdup_printf(
- ngettext("<b>%u of %u</b> node selected.", "<b>%u of %u</b> nodes selected.", total),
- sz, total);
+ char *nodestring;
+ if (sz == 2) {
+ Inkscape::UI::ControlPointSelection::Set &selectionNodes = this->_selected_nodes->allPoints();
+ std::vector<Geom::Point> selectedNodesPositions;
+ for (Inkscape::UI::ControlPointSelection::Set::iterator i = selectionNodes.begin(); i != selectionNodes.end(); ++i) {
+ if ((*i)->selected()) {
+ Inkscape::UI::Node *n = dynamic_cast<Inkscape::UI::Node *>(*i);
+ selectedNodesPositions.push_back(n->position());
+ }
+ }
+ g_assert(selectedNodesPositions.size() == 2);
+ Geom::Point difference = selectedNodesPositions[0] - selectedNodesPositions[1];
+ double angle = Geom::atan2(difference);
+ if (angle < 0) {
+ angle += 2*M_PI;
+ }
+ angle *= 180.0/M_PI;
+ nodestring = g_strdup_printf(
+ "<b>%u of %u</b> nodes selected, angle: %.2f°.",
+ sz, total, angle);
+ }
+ else {
+ nodestring = g_strdup_printf(
+ ngettext("<b>%u of %u</b> node selected.", "<b>%u of %u</b> nodes selected.", total),
+ sz, total);
+ }
if (this->_last_over) {
// TRANSLATORS: The %s below is where the "%u of %u nodes selected" sentence gets put