diff options
| author | Felipe Corr??a da Silva Sanches <juca@members.fsf.org> | 2011-06-13 08:25:08 +0000 |
|---|---|---|
| committer | Felipe C. da S. Sanches <juca@members.fsf.org> | 2011-06-13 08:25:08 +0000 |
| commit | a36b851b6d1ef714b228474af87e1307be1cdce9 (patch) | |
| tree | 7cb05206be0783df6929e21ef1fe3b6d360d3e13 /src | |
| parent | cmake: (diff) | |
| download | inkscape-a36b851b6d1ef714b228474af87e1307be1cdce9.tar.gz inkscape-a36b851b6d1ef714b228474af87e1307be1cdce9.zip | |
adding preferences page for Measure Tool with option (enabled by default) to ignore first and last points when calculating/displaying distances
(bzr r10295)
Diffstat (limited to 'src')
| -rw-r--r-- | src/measure-context.cpp | 22 | ||||
| -rw-r--r-- | src/ui/dialog/inkscape-preferences.cpp | 6 | ||||
| -rw-r--r-- | src/ui/dialog/inkscape-preferences.h | 2 |
3 files changed, 25 insertions, 5 deletions
diff --git a/src/measure-context.cpp b/src/measure-context.cpp index 371ac3356..a4e81475e 100644 --- a/src/measure-context.cpp +++ b/src/measure-context.cpp @@ -213,7 +213,12 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv GSList *l; int counter=0; std::vector<Geom::Point> intersections; - intersections.push_back(desktop->dt2doc(start_point)); + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + bool ignore_1st_and_last = prefs->getBool("/tools/measure/ignore_1st_and_last", true); + + if (!ignore_1st_and_last){ + intersections.push_back(desktop->dt2doc(start_point)); + } for (l = items; l != NULL; l = l->next){ item = (SPItem*) (l->data); @@ -253,10 +258,15 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv } //g_free(repr); } - intersections.push_back(desktop->dt2doc(motion_dt)); + + if (!ignore_1st_and_last){ + intersections.push_back(desktop->dt2doc(motion_dt)); + } //sort intersections - std::sort(intersections.begin(), intersections.end(), GeomPointSortPredicate); + if (intersections.size()>2){ + std::sort(intersections.begin(), intersections.end(), GeomPointSortPredicate); + } unsigned int idx; for (idx=0; idx<measure_tmp_items.size(); idx++){ @@ -282,10 +292,12 @@ static gint sp_measure_context_root_handler(SPEventContext *event_context, GdkEv } - Inkscape::Preferences *prefs = Inkscape::Preferences::get(); double fontsize = prefs->getInt("/tools/measure/fontsize"); - Geom::Point previous_point = intersections[0]; + Geom::Point previous_point; + if (intersections.size()>0) + previous_point = intersections[0]; + for (idx=1; idx < intersections.size(); idx++){ Geom::Point measure_text_pos = (previous_point + intersections[idx])/2; //TODO: shift label a few pixels in the y coordinate diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index 447e50831..b8b86fac1 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -480,6 +480,12 @@ void InkscapePreferences::initPageTools() AddSelcueCheckbox(_page_zoom, "/tools/zoom", true); AddGradientCheckbox(_page_zoom, "/tools/zoom", false); + //Measure + this->AddPage(_page_measure, _("Measure"), iter_tools, PREFS_PAGE_TOOLS_MEASURE); + PrefCheckButton* cb = Gtk::manage( new PrefCheckButton); + cb->init ( _("Ignore first and last points"), "/tools/measure/ignore_1st_and_last", true); + _page_measure.add_line( false, "", *cb, "", _("The beggining and end of the measurement tool's control line will not be considered for calculating lengths. Only lengths between actual curve intersections will be displayed.")); + //Shapes Gtk::TreeModel::iterator iter_shapes = this->AddPage(_page_shapes, _("Shapes"), iter_tools, PREFS_PAGE_TOOLS_SHAPES); _path_shapes = _page_list.get_model()->get_path(iter_shapes); diff --git a/src/ui/dialog/inkscape-preferences.h b/src/ui/dialog/inkscape-preferences.h index 34bf1e87a..9e51fbf0a 100644 --- a/src/ui/dialog/inkscape-preferences.h +++ b/src/ui/dialog/inkscape-preferences.h @@ -141,6 +141,7 @@ protected: UI::Widget::DialogPage _page_tweak; UI::Widget::DialogPage _page_spray; UI::Widget::DialogPage _page_zoom; + UI::Widget::DialogPage _page_measure; UI::Widget::DialogPage _page_shapes; UI::Widget::DialogPage _page_pencil; UI::Widget::DialogPage _page_pen; @@ -372,6 +373,7 @@ protected: static void AddSelcueCheckbox(UI::Widget::DialogPage& p, Glib::ustring const &prefs_path, bool def_value); static void AddGradientCheckbox(UI::Widget::DialogPage& p, Glib::ustring const &prefs_path, bool def_value); static void AddConvertGuidesCheckbox(UI::Widget::DialogPage& p, Glib::ustring const &prefs_path, bool def_value); + static void AddFirstAndLastCheckbox(UI::Widget::DialogPage& p, Glib::ustring const &prefs_path, bool def_value); static void AddDotSizeSpinbutton(UI::Widget::DialogPage& p, Glib::ustring const &prefs_path, double def_value); static void AddNewObjectsStyle(UI::Widget::DialogPage& p, Glib::ustring const &prefs_path, const gchar* banner = NULL); |
