diff options
| author | Jabier Arraiza <jabier.arraiza@marker.es> | 2017-12-02 15:12:07 +0000 |
|---|---|---|
| committer | Jabier Arraiza <jabier.arraiza@marker.es> | 2017-12-02 15:12:07 +0000 |
| commit | 914e21feed1e2f9981455b5a527b269f325188f6 (patch) | |
| tree | 7d4bacead52468707151039305da25018ca4a60d /src | |
| parent | Clear meassure when dragging knots (diff) | |
| download | inkscape-914e21feed1e2f9981455b5a527b269f325188f6.tar.gz inkscape-914e21feed1e2f9981455b5a527b269f325188f6.zip | |
Optionaly measure only selected elements
Diffstat (limited to 'src')
| -rw-r--r-- | src/ui/tools/measure-tool.cpp | 14 | ||||
| -rw-r--r-- | src/widgets/measure-toolbar.cpp | 30 |
2 files changed, 43 insertions, 1 deletions
diff --git a/src/ui/tools/measure-tool.cpp b/src/ui/tools/measure-tool.cpp index 7df4ccbc3..8037a02a9 100644 --- a/src/ui/tools/measure-tool.cpp +++ b/src/ui/tools/measure-tool.cpp @@ -1159,6 +1159,7 @@ void MeasureTool::showInfoBox(Geom::Point cursor, bool into_groups) double scale = prefs->getDouble("/tools/measure/scale", 100.0) / 100.0; int precision = prefs->getInt("/tools/measure/precision", 2); Glib::ustring unit_name = prefs->getString("/tools/measure/unit"); + bool only_selected = prefs->getBool("/tools/measure/only_selected", false); if (!unit_name.compare("")) { unit_name = "px"; } @@ -1191,6 +1192,14 @@ void MeasureTool::showInfoBox(Geom::Point cursor, bool into_groups) Geom::Point rel_position = Geom::Point(origin, origin); Geom::Point pos = desktop->w2d(cursor); double gap = Inkscape::Util::Quantity::convert(7 + fontsize, "px", unit->abbr); + if (only_selected) { + if (desktop->getSelection()->includes(over)) { + showItemInfoText(pos + (rel_position * zoom),_("Selected"),fontsize); + } else { + showItemInfoText(pos + (rel_position * zoom),_("Not selected"),fontsize); + } + rel_position = Geom::Point(rel_position[Geom::X], rel_position[Geom::Y] + gap); + } if (SP_IS_SHAPE(over)) { precision_str << _("Length") << ": %." << precision << "f %s"; measure_str = g_strdup_printf(precision_str.str().c_str(), item_length, unit_name.c_str()); @@ -1202,7 +1211,6 @@ void MeasureTool::showInfoBox(Geom::Point cursor, bool into_groups) showItemInfoText(pos + (rel_position * zoom),measure_str,fontsize); rel_position = Geom::Point(rel_position[Geom::X], rel_position[Geom::Y] + gap); } - precision_str << "Y: %." << precision << "f %s"; measure_str = g_strdup_printf(precision_str.str().c_str(), item_y, unit_name.c_str()); precision_str.str(""); @@ -1274,8 +1282,12 @@ void MeasureTool::showCanvasItems(bool to_guides, bool to_item, bool to_phantom, current_layer = desktop->currentLayer(); } std::vector<double> intersection_times; + bool only_selected = prefs->getBool("/tools/measure/only_selected", false); for (std::vector<SPItem*>::const_iterator i=items.begin(); i!=items.end(); ++i) { SPItem *item = *i; + if (!desktop->getSelection()->includes(*i) && only_selected) { + continue; + } if(all_layers || (layer_model && layer_model->layerForObject(item) == current_layer)){ if (SP_IS_SHAPE(item)) { calculate_intersections(desktop, item, lineseg, SP_SHAPE(item)->getCurve(), intersection_times); diff --git a/src/widgets/measure-toolbar.cpp b/src/widgets/measure-toolbar.cpp index fc6cfdb11..f031414a4 100644 --- a/src/widgets/measure-toolbar.cpp +++ b/src/widgets/measure-toolbar.cpp @@ -165,6 +165,24 @@ sp_toggle_ignore_1st_and_last( GtkToggleAction* act, gpointer data ) } static void +sp_toggle_only_selected( GtkToggleAction* act, gpointer data ) +{ + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + gboolean active = gtk_toggle_action_get_active(act); + prefs->setBool("/tools/measure/only_selected", active); + SPDesktop *desktop = static_cast<SPDesktop *>(data); + if ( active ) { + desktop->messageStack()->flash(Inkscape::INFORMATION_MESSAGE, _("Measures only selected.")); + } else { + desktop->messageStack()->flash(Inkscape::INFORMATION_MESSAGE, _("Measure all.")); + } + MeasureTool *mt = get_measure_tool(); + if (mt) { + mt->showCanvasItems(); + } +} + +static void sp_toggle_show_hidden( GtkToggleAction* act, gpointer data ) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -335,6 +353,18 @@ void sp_measure_toolbox_prep(SPDesktop * desktop, GtkActionGroup* mainActions, G gtk_action_group_add_action( mainActions, GTK_ACTION(eact) ); } + /* measure only selected */ + { + InkToggleAction* act = ink_toggle_action_new( "MeasureOnlySelected", + _("Measure only selected"), + _("Measure only selected"), + INKSCAPE_ICON("snap-bounding-box-center"), + secondarySize ); + gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/measure/only_selected", false) ); + g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(sp_toggle_only_selected), desktop) ; + gtk_action_group_add_action( mainActions, GTK_ACTION(act) ); + } + /* ignore_1st_and_last */ { InkToggleAction* act = ink_toggle_action_new( "MeasureIgnore1stAndLast", |
