diff --git a/src/ant/ant/antObject.cc b/src/ant/ant/antObject.cc index 5603de0d8..1dedd9281 100644 --- a/src/ant/ant/antObject.cc +++ b/src/ant/ant/antObject.cc @@ -247,7 +247,9 @@ Object::set_points (const point_list &points) db::DPoint Object::seg_p1 (size_t seg_index) const { - if (seg_index < m_points.size ()) { + if (seg_index == std::numeric_limits::max ()) { + return p1 (); + } else if (seg_index < m_points.size ()) { return m_points[seg_index]; } else if (m_points.empty ()) { return db::DPoint (); @@ -259,7 +261,9 @@ Object::seg_p1 (size_t seg_index) const db::DPoint Object::seg_p2 (size_t seg_index) const { - if (seg_index + 1 < m_points.size ()) { + if (seg_index == std::numeric_limits::max ()) { + return p2 (); + } else if (seg_index + 1 < m_points.size ()) { return m_points[seg_index + 1]; } else if (m_points.empty ()) { return db::DPoint (); diff --git a/src/ant/ant/antObject.h b/src/ant/ant/antObject.h index 6358417c0..7304c5bed 100644 --- a/src/ant/ant/antObject.h +++ b/src/ant/ant/antObject.h @@ -329,7 +329,7 @@ public: */ db::DPoint p2 () const { - return seg_p2 (0); + return seg_p2 (segments () - 1); } /** diff --git a/src/ant/ant/antPropertiesPage.cc b/src/ant/ant/antPropertiesPage.cc index 035755297..7e55c2afc 100644 --- a/src/ant/ant/antPropertiesPage.cc +++ b/src/ant/ant/antPropertiesPage.cc @@ -30,11 +30,39 @@ namespace ant { +// ------------------------------------------------------------------------- +// A ruler that tells us if he was modified + +class RulerWithModifiedProperty + : public ant::Object +{ +public: + RulerWithModifiedProperty () + : ant::Object (), m_modified (false) + { + // .. nothing yet .. + } + + bool is_modified () const + { + return m_modified; + } + +protected: + void property_changed () + { + m_modified = true; + ant::Object::property_changed (); + } + + bool m_modified; +}; + // ------------------------------------------------------------------------- // PropertiesPage implementation PropertiesPage::PropertiesPage (ant::Service *rulers, db::Manager *manager, QWidget *parent) - : lay::PropertiesPage (parent, manager, rulers), mp_rulers (rulers), m_enable_cb_callback (true), m_in_text_changed (false) + : lay::PropertiesPage (parent, manager, rulers), mp_rulers (rulers), m_enable_cb_callback (true), m_in_something_changed (false) { mp_rulers->get_selection (m_selection); m_pos = m_selection.begin (); @@ -54,27 +82,27 @@ PropertiesPage::PropertiesPage (ant::Service *rulers, db::Manager *manager, QWid if (! readonly ()) { - connect (fmt_le, SIGNAL (editingFinished ()), this, SIGNAL (edited ())); - connect (fmt_x_le, SIGNAL (editingFinished ()), this, SIGNAL (edited ())); - connect (fmt_y_le, SIGNAL (editingFinished ()), this, SIGNAL (edited ())); - connect (x0, SIGNAL (editingFinished ()), this, SIGNAL (edited ())); - connect (x1, SIGNAL (editingFinished ()), this, SIGNAL (edited ())); - connect (x2, SIGNAL (editingFinished ()), this, SIGNAL (edited ())); - connect (y0, SIGNAL (editingFinished ()), this, SIGNAL (edited ())); - connect (y1, SIGNAL (editingFinished ()), this, SIGNAL (edited ())); - connect (y2, SIGNAL (editingFinished ()), this, SIGNAL (edited ())); + connect (fmt_le, SIGNAL (editingFinished ()), this, SLOT (something_changed ())); + connect (fmt_x_le, SIGNAL (editingFinished ()), this, SLOT (something_changed ())); + connect (fmt_y_le, SIGNAL (editingFinished ()), this, SLOT (something_changed ())); + connect (x0, SIGNAL (editingFinished ()), this, SLOT (something_changed ())); + connect (x1, SIGNAL (editingFinished ()), this, SLOT (something_changed ())); + connect (x2, SIGNAL (editingFinished ()), this, SLOT (something_changed ())); + connect (y0, SIGNAL (editingFinished ()), this, SLOT (something_changed ())); + connect (y1, SIGNAL (editingFinished ()), this, SLOT (something_changed ())); + connect (y2, SIGNAL (editingFinished ()), this, SLOT (something_changed ())); - connect (style_cb, SIGNAL (activated (int)), this, SIGNAL (edited ())); - connect (outline_cb, SIGNAL (activated (int)), this, SIGNAL (edited ())); - connect (main_position, SIGNAL (activated (int)), this, SIGNAL (edited ())); - connect (main_xalign, SIGNAL (activated (int)), this, SIGNAL (edited ())); - connect (main_yalign, SIGNAL (activated (int)), this, SIGNAL (edited ())); - connect (xlabel_xalign, SIGNAL (activated (int)), this, SIGNAL (edited ())); - connect (xlabel_yalign, SIGNAL (activated (int)), this, SIGNAL (edited ())); - connect (ylabel_xalign, SIGNAL (activated (int)), this, SIGNAL (edited ())); - connect (ylabel_yalign, SIGNAL (activated (int)), this, SIGNAL (edited ())); + connect (style_cb, SIGNAL (activated (int)), this, SLOT (something_changed ())); + connect (outline_cb, SIGNAL (activated (int)), this, SLOT (something_changed ())); + connect (main_position, SIGNAL (activated (int)), this, SLOT (something_changed ())); + connect (main_xalign, SIGNAL (activated (int)), this, SLOT (something_changed ())); + connect (main_yalign, SIGNAL (activated (int)), this, SLOT (something_changed ())); + connect (xlabel_xalign, SIGNAL (activated (int)), this, SLOT (something_changed ())); + connect (xlabel_yalign, SIGNAL (activated (int)), this, SLOT (something_changed ())); + connect (ylabel_xalign, SIGNAL (activated (int)), this, SLOT (something_changed ())); + connect (ylabel_yalign, SIGNAL (activated (int)), this, SLOT (something_changed ())); - connect (points_edit, SIGNAL (textChanged ()), this, SLOT (text_changed ())); + connect (points_edit, SIGNAL (textChanged ()), this, SLOT (something_changed ())); } else { @@ -234,19 +262,28 @@ PropertiesPage::get_points (ant::Object::point_list &points) } void -PropertiesPage::text_changed () +PropertiesPage::something_changed () { - if (m_in_text_changed) { + if (m_in_something_changed) { return; } try { - m_in_text_changed = true; - update_with (get_object ()); - emit edited (); - m_in_text_changed = false; + + m_in_something_changed = true; + + RulerWithModifiedProperty obj; + obj.ant::Object::operator= (current ()); + get_object (obj); + if (obj.is_modified ()) { + update_with (obj); + emit edited (); + } + + m_in_something_changed = false; + } catch (...) { - m_in_text_changed = false; + m_in_something_changed = false; // ignore exceptions - the edit field will be highlighted anyway } } @@ -395,16 +432,20 @@ PropertiesPage::update_with (const ant::Object &obj) ylabel_xalign->setCurrentIndex (obj.ylabel_xalign ()); ylabel_yalign->setCurrentIndex (obj.ylabel_yalign ()); - int tab = 2; - if (obj.points ().size () == 1) { - tab = 0; - } else if (obj.points ().size () == 2) { - tab = 1; - } - - if (! m_in_text_changed) { - segments_tab->setCurrentIndex (tab); + // change tabs if required + if (segments_tab->currentIndex () == 1) { + if (obj.points ().size () > 2 || obj.points ().size () == 0) { + segments_tab->setCurrentIndex (2); + } + } else if (segments_tab->currentIndex () == 0) { + if (obj.points ().size () > 2 || obj.points ().size () == 0) { + segments_tab->setCurrentIndex (2); + } else if (obj.points ().size () > 1) { + segments_tab->setCurrentIndex (1); + } } + segments_tab->setTabEnabled (0, obj.points ().size () == 1); + segments_tab->setTabEnabled (1, obj.points ().size () <= 2 && obj.points ().size () > 0); point_list->clear (); for (auto p = obj.points ().begin (); p != obj.points ().end (); ++p) { @@ -413,7 +454,7 @@ PropertiesPage::update_with (const ant::Object &obj) item->setData (1, Qt::DisplayRole, QVariant (tl::to_qstring (tl::micron_to_string (p->y ())))); } - if (! m_in_text_changed) { + if (! m_in_something_changed || segments_tab->currentIndex () != 3) { std::string text; for (auto p = obj.points ().begin (); p != obj.points ().end (); ++p) { @@ -461,14 +502,13 @@ PropertiesPage::readonly () void PropertiesPage::apply () { - mp_rulers->change_ruler (*m_pos, get_object ()); + ant::Object obj; + get_object (obj); + mp_rulers->change_ruler (*m_pos, obj); } -ant::Object -PropertiesPage::get_object () +void PropertiesPage::get_object(ant::Object &obj) { - ant::Object ruler; - std::string fmt = tl::to_string (fmt_le->text ()); std::string fmt_x = tl::to_string (fmt_x_le->text ()); std::string fmt_y = tl::to_string (fmt_y_le->text ()); @@ -485,28 +525,26 @@ PropertiesPage::get_object () p2 = p1; } - ruler = ant::Object (p1, p2, current ().id (), fmt_x, fmt_y, fmt, style, outline, current ().snap (), current ().angle_constraint ()); + obj = ant::Object (p1, p2, current ().id (), fmt_x, fmt_y, fmt, style, outline, current ().snap (), current ().angle_constraint ()); } else if (segments_tab->currentIndex () == 2 || segments_tab->currentIndex () == 3) { ant::Object::point_list points; get_points (points); - ruler = ant::Object (points, current ().id (), fmt_x, fmt_y, fmt, style, outline, current ().snap (), current ().angle_constraint ()); + obj = ant::Object (points, current ().id (), fmt_x, fmt_y, fmt, style, outline, current ().snap (), current ().angle_constraint ()); } - ruler.set_main_position (Object::position_type (main_position->currentIndex ())); - ruler.set_main_xalign (Object::alignment_type (main_xalign->currentIndex ())); - ruler.set_main_yalign (Object::alignment_type (main_yalign->currentIndex ())); - ruler.set_xlabel_xalign (Object::alignment_type (xlabel_xalign->currentIndex ())); - ruler.set_xlabel_yalign (Object::alignment_type (xlabel_yalign->currentIndex ())); - ruler.set_ylabel_xalign (Object::alignment_type (ylabel_xalign->currentIndex ())); - ruler.set_ylabel_yalign (Object::alignment_type (ylabel_yalign->currentIndex ())); + obj.set_main_position (Object::position_type (main_position->currentIndex ())); + obj.set_main_xalign (Object::alignment_type (main_xalign->currentIndex ())); + obj.set_main_yalign (Object::alignment_type (main_yalign->currentIndex ())); + obj.set_xlabel_xalign (Object::alignment_type (xlabel_xalign->currentIndex ())); + obj.set_xlabel_yalign (Object::alignment_type (xlabel_yalign->currentIndex ())); + obj.set_ylabel_xalign (Object::alignment_type (ylabel_xalign->currentIndex ())); + obj.set_ylabel_yalign (Object::alignment_type (ylabel_yalign->currentIndex ())); - ruler.set_category (current ().category ()); - - return ruler; + obj.set_category (current ().category ()); } } diff --git a/src/ant/ant/antPropertiesPage.h b/src/ant/ant/antPropertiesPage.h index 26e351e2d..1f1ead4da 100644 --- a/src/ant/ant/antPropertiesPage.h +++ b/src/ant/ant/antPropertiesPage.h @@ -57,21 +57,21 @@ public: private slots: void swap_points_clicked (); void snap_to_layout_clicked (); - void text_changed (); + void something_changed (); private: std::vector m_selection; std::vector ::iterator m_pos; ant::Service *mp_rulers; bool m_enable_cb_callback; - bool m_in_text_changed; + bool m_in_something_changed; const ant::Object ¤t () const; void get_points (db::DPoint &p1, db::DPoint &p2); void get_point (db::DPoint &p); void get_points (ant::Object::point_list &points); void update_with (const ant::Object &obj); - ant::Object get_object (); + void get_object (ant::Object &obj); }; } diff --git a/src/ant/ant/antService.cc b/src/ant/ant/antService.cc index a93c05885..ffd1e22cb 100644 --- a/src/ant/ant/antService.cc +++ b/src/ant/ant/antService.cc @@ -113,6 +113,8 @@ tick_spacings (double d, double min_d, int &minor_ticks, double &ticks) * @param pos The position where to draw the text * @param bitmap The bitmap to draw the ruler on * @param renderer The renderer object + * @param first_segment True, if we're drawing the first segment + * @param last_segment True, if we're drawing the last segment */ void draw_ruler (const db::DPoint &q1, @@ -123,7 +125,9 @@ draw_ruler (const db::DPoint &q1, bool right, ant::Object::style_type style, lay::CanvasPlane *bitmap, - lay::Renderer &renderer) + lay::Renderer &renderer, + bool first_segment, + bool last_segment) { double arrow_width = 8 / renderer.resolution (); double arrow_length = 12 / renderer.resolution (); @@ -189,12 +193,16 @@ draw_ruler (const db::DPoint &q1, db::DVector qw = qq * (sel_width * 0.5); db::DVector dq1, dq2; - if (style == ant::Object::STY_arrow_both || style == ant::Object::STY_arrow_start) { + if (! first_segment) { + // no start indicator if not first segment + } else if (style == ant::Object::STY_arrow_both || style == ant::Object::STY_arrow_start) { dq1 = qu * (arrow_length - 1); } else if (style == ant::Object::STY_cross_both || style == ant::Object::STY_cross_start) { dq1 = qu * (sel_width * 0.5); } - if (style == ant::Object::STY_arrow_both || style == ant::Object::STY_arrow_end) { + if (! last_segment) { + // no end indicator if not last segment + } else if (style == ant::Object::STY_arrow_both || style == ant::Object::STY_arrow_end) { dq2 = qu * -(arrow_length - 1); } else if (style == ant::Object::STY_cross_both || style == ant::Object::STY_cross_end) { dq2 = qu * -(sel_width * 0.5); @@ -212,7 +220,11 @@ draw_ruler (const db::DPoint &q1, } - if (style == ant::Object::STY_arrow_end || style == ant::Object::STY_arrow_both) { + if (! last_segment) { + + // no end indicator if not last segment + + } else if (style == ant::Object::STY_arrow_end || style == ant::Object::STY_arrow_both) { db::DPolygon p; db::DPoint points[] = { @@ -239,7 +251,11 @@ draw_ruler (const db::DPoint &q1, } - if (style == ant::Object::STY_arrow_start || style == ant::Object::STY_arrow_both) { + if (! first_segment) { + + // no start indicator if not first segment + + } else if (style == ant::Object::STY_arrow_start || style == ant::Object::STY_arrow_both) { db::DPolygon p; db::DPoint points[] = { @@ -572,6 +588,9 @@ draw_ellipse (const db::DPoint &q1, void draw_ruler_segment (const ant::Object &ruler, size_t index, const db::DCplxTrans &trans, bool sel, lay::CanvasPlane *bitmap, lay::Renderer &renderer) { + bool last_segment = (index == ruler.segments () - 1 || index == std::numeric_limits::max ()); + bool first_segment = (index == 0 || index == std::numeric_limits::max ()); + db::DPoint p1 = ruler.seg_p1 (index), p2 = ruler.seg_p2 (index); // round the starting point, shift both, and round the end point @@ -585,7 +604,7 @@ draw_ruler_segment (const ant::Object &ruler, size_t index, const db::DCplxTrans double mu = double (min_tick_spc) / trans.ctrans (1.0); if (ruler.outline () == Object::OL_diag) { - draw_ruler (q1, q2, lu, mu, sel, q2.x () < q1.x (), ruler.style (), bitmap, renderer); + draw_ruler (q1, q2, lu, mu, sel, q2.x () < q1.x (), ruler.style (), bitmap, renderer, first_segment, last_segment); draw_text (q1, q2, lu, ruler.text (index), q2.x () < q1.x (), ruler.style (), ruler.main_position (), ruler.main_xalign (), ruler.main_yalign (), bitmap, renderer); } @@ -595,12 +614,12 @@ draw_ruler_segment (const ant::Object &ruler, size_t index, const db::DCplxTrans bool r = (q2.x () > q1.x ()) ^ (q2.y () < q1.y ()); if (ruler.outline () == Object::OL_diag_xy || ruler.outline () == Object::OL_diag_yx) { - draw_ruler (q1, q2, lu, mu, sel, !r, ruler.style (), bitmap, renderer); + draw_ruler (q1, q2, lu, mu, sel, !r, ruler.style (), bitmap, renderer, first_segment, last_segment); draw_text (q1, q2, lu, ruler.text (index), !r, ruler.style (), ruler.main_position (), ruler.main_xalign (), ruler.main_yalign (), bitmap, renderer); } - draw_ruler (q1, db::DPoint (q2.x (), q1.y ()), lu, mu, sel, r, ruler.style (), bitmap, renderer); + draw_ruler (q1, db::DPoint (q2.x (), q1.y ()), lu, mu, sel, r, ruler.style (), bitmap, renderer, false, false); draw_text (q1, db::DPoint (q2.x (), q1.y ()), lu, ruler.text_x (index, trans.fp_trans ()), r, ruler.style (), ant::Object::POS_center, ruler.xlabel_xalign (), ruler.xlabel_yalign (), bitmap, renderer); - draw_ruler (db::DPoint (q2.x (), q1.y ()), q2, lu, mu, sel, r, ruler.style (), bitmap, renderer); + draw_ruler (db::DPoint (q2.x (), q1.y ()), q2, lu, mu, sel, r, ruler.style (), bitmap, renderer, false, false); draw_text (db::DPoint (q2.x (), q1.y ()), q2, lu, ruler.text_y (index, trans.fp_trans ()), r, ruler.style (), ant::Object::POS_center, ruler.ylabel_xalign (), ruler.ylabel_yalign (), bitmap, renderer); } @@ -611,12 +630,12 @@ draw_ruler_segment (const ant::Object &ruler, size_t index, const db::DCplxTrans bool r = (q2.x () > q1.x ()) ^ (q2.y () > q1.y ()); if (ruler.outline () == Object::OL_diag_xy || ruler.outline () == Object::OL_diag_yx) { - draw_ruler (q1, q2, lu, mu, sel, !r, ruler.style (), bitmap, renderer); + draw_ruler (q1, q2, lu, mu, sel, !r, ruler.style (), bitmap, renderer, first_segment, last_segment); draw_text (q1, q2, lu, ruler.text (index), !r, ruler.style (), ruler.main_position (), ruler.main_xalign (), ruler.main_yalign (), bitmap, renderer); } - draw_ruler (q1, db::DPoint (q1.x (), q2.y ()), lu, mu, sel, r, ruler.style (), bitmap, renderer); + draw_ruler (q1, db::DPoint (q1.x (), q2.y ()), lu, mu, sel, r, ruler.style (), bitmap, renderer, false, false); draw_text (q1, db::DPoint (q1.x (), q2.y ()), lu, ruler.text_y (index, trans.fp_trans ()), r, ruler.style (), ant::Object::POS_center, ruler.ylabel_xalign (), ruler.ylabel_yalign (), bitmap, renderer); - draw_ruler (db::DPoint (q1.x (), q2.y ()), q2, lu, mu, sel, r, ruler.style (), bitmap, renderer); + draw_ruler (db::DPoint (q1.x (), q2.y ()), q2, lu, mu, sel, r, ruler.style (), bitmap, renderer, false, false); draw_text (db::DPoint (q1.x (), q2.y ()), q2, lu, ruler.text_x (index, trans.fp_trans ()), r, ruler.style (), ant::Object::POS_center, ruler.xlabel_xalign (), ruler.xlabel_yalign (), bitmap, renderer); } @@ -625,12 +644,12 @@ draw_ruler_segment (const ant::Object &ruler, size_t index, const db::DCplxTrans bool r = (q2.x () > q1.x ()) ^ (q2.y () < q1.y ()); - draw_ruler (q1, db::DPoint (q2.x (), q1.y ()), lu, mu, sel, r, ruler.style (), bitmap, renderer); + draw_ruler (q1, db::DPoint (q2.x (), q1.y ()), lu, mu, sel, r, ruler.style (), bitmap, renderer, true, true); draw_text (q1, db::DPoint (q2.x (), q1.y ()), lu, ruler.text_x (index, trans.fp_trans ()), r, ruler.style (), ant::Object::POS_center, ruler.xlabel_xalign (), ruler.xlabel_yalign (), bitmap, renderer); - draw_ruler (db::DPoint (q2.x (), q1.y ()), q2, lu, mu, sel, r, ruler.style (), bitmap, renderer); + draw_ruler (db::DPoint (q2.x (), q1.y ()), q2, lu, mu, sel, r, ruler.style (), bitmap, renderer, true, true); draw_text (db::DPoint (q2.x (), q1.y ()), q2, lu, ruler.text_y (index, trans.fp_trans ()), r, ruler.style (), ant::Object::POS_center, ruler.ylabel_xalign (), ruler.ylabel_yalign (), bitmap, renderer); - draw_ruler (q1, db::DPoint (q1.x (), q2.y ()), lu, mu, sel, !r, ruler.style (), bitmap, renderer); - draw_ruler (db::DPoint (q1.x (), q2.y ()), q2, lu, mu, sel, !r, ruler.style (), bitmap, renderer); + draw_ruler (q1, db::DPoint (q1.x (), q2.y ()), lu, mu, sel, !r, ruler.style (), bitmap, renderer, true, true); + draw_ruler (db::DPoint (q1.x (), q2.y ()), q2, lu, mu, sel, !r, ruler.style (), bitmap, renderer, true, true); draw_text (q1, q2, lu, ruler.text (index), !r, ant::Object::STY_none, ruler.main_position (), ruler.main_xalign (), ruler.main_yalign (), bitmap, renderer); } else if (ruler.outline () == Object::OL_ellipse) { @@ -649,18 +668,29 @@ draw_ruler_segment (const ant::Object &ruler, size_t index, const db::DCplxTrans void draw_ruler (const ant::Object &ruler, const db::DCplxTrans &trans, bool sel, lay::CanvasPlane *bitmap, lay::Renderer &renderer) { - for (size_t index = 0; index < ruler.segments (); ++index) { - draw_ruler_segment (ruler, index, trans, sel, bitmap, renderer); + if (ruler.outline () == Object::OL_box || ruler.outline () == Object::OL_ellipse) { + + draw_ruler_segment (ruler, std::numeric_limits::max (), trans, sel, bitmap, renderer); + + } else { + + // other styles support segments, so paint them individually + for (size_t index = 0; index < ruler.segments (); ++index) { + draw_ruler_segment (ruler, index, trans, sel, bitmap, renderer); + } + } } static bool is_selected (const ant::Object &ruler, size_t index, const db::DPoint &pos, double enl, double &distance) { + ant::Object::outline_type outline = ruler.outline (); + db::DPoint p1 = ruler.seg_p1 (index), p2 = ruler.seg_p2 (index); db::DBox b (p1, p2); - if (ruler.outline () == ant::Object::OL_ellipse) { + if (outline == ant::Object::OL_ellipse) { // special handling of the (non-degenerated) ellipse case if (b.height () > 1e-6 && b.width () > 1e-6) { @@ -695,24 +725,24 @@ is_selected (const ant::Object &ruler, size_t index, const db::DPoint &pos, doub db::DEdge edges[4]; unsigned int nedges = 0; - if (ruler.outline () == ant::Object::OL_diag || - ruler.outline () == ant::Object::OL_diag_xy || - ruler.outline () == ant::Object::OL_diag_yx) { - edges [nedges++] = db::DEdge (ruler.p1 (), ruler.p2 ()); + if (outline == ant::Object::OL_diag || + outline == ant::Object::OL_diag_xy || + outline == ant::Object::OL_diag_yx) { + edges [nedges++] = db::DEdge (p1, p2); } - if (ruler.outline () == ant::Object::OL_xy || - ruler.outline () == ant::Object::OL_diag_xy || - ruler.outline () == ant::Object::OL_box || - ruler.outline () == ant::Object::OL_ellipse) { - edges [nedges++] = db::DEdge (ruler.p1 (), db::DPoint (ruler.p2 ().x (), ruler.p1 ().y ())); - edges [nedges++] = db::DEdge (db::DPoint (ruler.p2 ().x (), ruler.p1 ().y ()), ruler.p2 ()); + if (outline == ant::Object::OL_xy || + outline == ant::Object::OL_diag_xy || + outline == ant::Object::OL_box || + outline == ant::Object::OL_ellipse) { + edges [nedges++] = db::DEdge (p1, db::DPoint (p2.x (), p1.y ())); + edges [nedges++] = db::DEdge (db::DPoint (p2.x (), p1.y ()), p2); } - if (ruler.outline () == ant::Object::OL_yx || - ruler.outline () == ant::Object::OL_diag_yx || - ruler.outline () == ant::Object::OL_box || - ruler.outline () == ant::Object::OL_ellipse) { - edges [nedges++] = db::DEdge (ruler.p1 (), db::DPoint (ruler.p1 ().x (), ruler.p2 ().y ())); - edges [nedges++] = db::DEdge (db::DPoint (ruler.p1 ().x (), ruler.p2 ().y ()), ruler.p2 ()); + if (outline == ant::Object::OL_yx || + outline == ant::Object::OL_diag_yx || + outline == ant::Object::OL_box || + outline == ant::Object::OL_ellipse) { + edges [nedges++] = db::DEdge (p1, db::DPoint (p1.x (), p2.y ())); + edges [nedges++] = db::DEdge (db::DPoint (p1.x (), p2.y ()), p2); } for (unsigned int i = 0; i < nedges; ++i) { @@ -729,6 +759,10 @@ is_selected (const ant::Object &ruler, size_t index, const db::DPoint &pos, doub static bool is_selected (const ant::Object &ruler, const db::DPoint &pos, double enl, double &distance) { + if (ruler.outline () == ant::Object::OL_box || ruler.outline () == ant::Object::OL_ellipse) { + return is_selected (ruler, std::numeric_limits::max (), pos, enl, distance); + } + bool any = false; for (size_t index = 0; index < ruler.segments (); ++index) { // NOTE: we check *all* since distance is updated herein.