From 6014ba9fedca5ebca1a0693fd65180f1c7eea37b Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Tue, 1 Aug 2023 21:40:50 +0200 Subject: [PATCH] Fixed issue #1438 (Provide a configuration option to switch back to old-style text selection (at origin only) --- src/edt/edt/edtPartialService.cc | 4 ++-- src/laybasic/laybasic/layFinder.cc | 2 +- src/laybasic/laybasic/layLayoutViewBase.cc | 19 ++++++++++++++++- src/laybasic/laybasic/layLayoutViewBase.h | 17 +++++++++++++++ src/laybasic/laybasic/layLayoutViewConfig.cc | 1 + src/laybasic/laybasic/layMarker.cc | 16 ++++++++++---- src/laybasic/laybasic/layTextInfo.cc | 16 ++++++-------- src/laybasic/laybasic/layTextInfo.h | 22 ++++++++++---------- src/laybasic/laybasic/laybasicConfig.h | 1 + src/layui/layui/LayoutViewConfigPage2c.ui | 7 +++++++ src/layui/layui/layLayoutViewConfigPages.cc | 5 +++++ 11 files changed, 81 insertions(+), 29 deletions(-) diff --git a/src/edt/edt/edtPartialService.cc b/src/edt/edt/edtPartialService.cc index 765c6d2a7..7fa115c4c 100644 --- a/src/edt/edt/edtPartialService.cc +++ b/src/edt/edt/edtPartialService.cc @@ -853,7 +853,7 @@ PartialShapeFinder::visit_cell (const db::Cell &cell, const db::Box &hit_box, co db::Point tp (shape->text_trans () * db::Point ()); - if (text_info ()) { + if (text_info () && ! text_info ()->point_mode ()) { db::CplxTrans t_dbu = db::CplxTrans (layout ().dbu ()) * t; db::Text text; @@ -1004,7 +1004,7 @@ PartialShapeFinder::visit_cell (const db::Cell &cell, const db::Box &hit_box, co db::Point tp (shape->text_trans () * db::Point ()); - if (text_info ()) { + if (text_info () && ! text_info ()->point_mode ()) { db::CplxTrans t_dbu = db::CplxTrans (layout ().dbu ()) * t; db::Text text; diff --git a/src/laybasic/laybasic/layFinder.cc b/src/laybasic/laybasic/layFinder.cc index df2cdcc36..b806fb74a 100644 --- a/src/laybasic/laybasic/layFinder.cc +++ b/src/laybasic/laybasic/layFinder.cc @@ -432,7 +432,7 @@ ShapeFinder::find_internal (lay::LayoutViewBase *view, unsigned int cv_index, co try { - if ((m_flags & db::ShapeIterator::Texts) != 0 && mp_text_info) { + if ((m_flags & db::ShapeIterator::Texts) != 0 && mp_text_info && ! mp_text_info->point_mode ()) { m_flags = db::ShapeIterator::Texts; diff --git a/src/laybasic/laybasic/layLayoutViewBase.cc b/src/laybasic/laybasic/layLayoutViewBase.cc index fb4ffd020..199df4ab7 100644 --- a/src/laybasic/laybasic/layLayoutViewBase.cc +++ b/src/laybasic/laybasic/layLayoutViewBase.cc @@ -345,6 +345,7 @@ LayoutViewBase::init (db::Manager *mgr) m_show_properties = false; m_apply_text_trans = true; m_default_text_size = 0.1; + m_text_point_mode = false; m_text_font = 0; m_show_markers = true; m_no_stipples = false; @@ -984,6 +985,13 @@ LayoutViewBase::configure (const std::string &name, const std::string &value) default_text_size (sz); return true; + } else if (name == cfg_text_point_mode) { + + bool flag; + tl::from_string (value, flag); + text_point_mode (flag); + return true; + } else if (name == cfg_text_font) { int n; @@ -5174,7 +5182,16 @@ LayoutViewBase::default_text_size (double fs) } } -void +void +LayoutViewBase::text_point_mode (bool pm) +{ + if (m_text_point_mode != pm) { + m_text_point_mode = pm; + redraw (); + } +} + +void LayoutViewBase::clear_ruler_new_cell (bool f) { m_clear_ruler_new_cell = f; diff --git a/src/laybasic/laybasic/layLayoutViewBase.h b/src/laybasic/laybasic/layLayoutViewBase.h index f22e4cc34..44c2134ce 100644 --- a/src/laybasic/laybasic/layLayoutViewBase.h +++ b/src/laybasic/laybasic/layLayoutViewBase.h @@ -1188,6 +1188,22 @@ public: return m_default_text_size; } + /** + * @brief Sets text point mode + * + * In point mode, the text is treated like a point. + * Selection happens at the texts' origin. + */ + void text_point_mode (bool pm); + + /** + * @brief Gets text point mode + */ + bool text_point_mode () const + { + return m_text_point_mode; + } + /** * @brief Show or hide markers */ @@ -2804,6 +2820,7 @@ private: tl::Color m_text_color; bool m_apply_text_trans; double m_default_text_size; + bool m_text_point_mode; unsigned int m_text_font; bool m_show_markers; bool m_no_stipples; diff --git a/src/laybasic/laybasic/layLayoutViewConfig.cc b/src/laybasic/laybasic/layLayoutViewConfig.cc index 00d3162a1..a21e172e4 100644 --- a/src/laybasic/laybasic/layLayoutViewConfig.cc +++ b/src/laybasic/laybasic/layLayoutViewConfig.cc @@ -66,6 +66,7 @@ public: options.push_back (std::pair (cfg_apply_text_trans, "true")); options.push_back (std::pair (cfg_global_trans, "r0")); options.push_back (std::pair (cfg_default_text_size, "0.1")); + options.push_back (std::pair (cfg_text_point_mode, "false")); options.push_back (std::pair (cfg_text_font, "0")); options.push_back (std::pair (cfg_sel_color, cc.to_string (tl::Color ()))); options.push_back (std::pair (cfg_sel_line_width, "1")); diff --git a/src/laybasic/laybasic/layMarker.cc b/src/laybasic/laybasic/layMarker.cc index 16d0ca19b..3092111d3 100644 --- a/src/laybasic/laybasic/layMarker.cc +++ b/src/laybasic/laybasic/layMarker.cc @@ -640,7 +640,9 @@ ShapeMarker::render (const Viewport &vp, ViewObjectCanvas &canvas) db::Text t; m_shape.text (t); db::DBox box = ti.bbox (trans () * t, vp_trans).enlarged (text_box_enlargement (vp_trans)); - r.draw (box, vp_trans, 0, text, 0, 0); + if (! box.is_point ()) { + r.draw (box, vp_trans, 0, text, 0, 0); + } } r.draw (m_shape, t, fill, contour, vertex, text); r.draw_propstring (m_shape, &ly->properties_repository (), text, t); @@ -653,7 +655,9 @@ ShapeMarker::render (const Viewport &vp, ViewObjectCanvas &canvas) db::Text t; m_shape.text (t); db::DBox box = ti.bbox (trans () * t, vp.trans ()).enlarged (text_box_enlargement (vp.trans ())); - r.draw (box, vp.trans (), 0, text, 0, 0); + if (! box.is_point ()) { + r.draw (box, vp.trans (), 0, text, 0, 0); + } } r.draw (m_shape, t, fill, contour, vertex, text); r.draw_propstring (m_shape, &ly->properties_repository (), text, t); @@ -1114,7 +1118,9 @@ Marker::draw (lay::Renderer &r, const db::CplxTrans &t, lay::CanvasPlane *fill, lay::TextInfo ti (view ()); db::DCplxTrans dt (t); db::DBox box = ti.bbox (*m_object.dtext, dt).enlarged (text_box_enlargement (dt)); - r.draw (box, dt, 0, text, 0, 0); + if (! box.is_point ()) { + r.draw (box, dt, 0, text, 0, 0); + } } r.draw (*m_object.dtext, db::DCplxTrans (t), fill, contour, vertex, text); } else if (m_type == Edge) { @@ -1316,7 +1322,9 @@ DMarker::render (const Viewport &vp, ViewObjectCanvas &canvas) // draw a frame around the text lay::TextInfo ti (view ()); db::DBox box = ti.bbox (*m_object.text, t).enlarged (text_box_enlargement (t)); - r.draw (box, t, 0, text, 0, 0); + if (! box.is_point ()) { + r.draw (box, t, 0, text, 0, 0); + } } r.draw (*m_object.text, t, fill, contour, vertex, text); } else if (m_type == Edge) { diff --git a/src/laybasic/laybasic/layTextInfo.cc b/src/laybasic/laybasic/layTextInfo.cc index 8b700c127..ab0534c88 100644 --- a/src/laybasic/laybasic/layTextInfo.cc +++ b/src/laybasic/laybasic/layTextInfo.cc @@ -33,16 +33,8 @@ TextInfo::TextInfo (const LayoutViewBase *view) : m_default_text_size (view->default_text_size ()), m_default_font (db::Font (view->text_font ())), m_apply_text_trans (view->apply_text_trans ()), - m_resolution (view->canvas ()->resolution ()) -{ - // .. nothing yet .. -} - -TextInfo::TextInfo (double default_text_size, const db::Font &default_font, bool apply_text_trans, double resolution) - : m_default_text_size (default_text_size), - m_default_font (default_font), - m_apply_text_trans (apply_text_trans), - m_resolution (resolution) + m_resolution (view->canvas ()->resolution ()), + m_point_mode (view->text_point_mode ()) { // .. nothing yet .. } @@ -50,6 +42,10 @@ TextInfo::TextInfo (double default_text_size, const db::Font &default_font, bool db::DBox TextInfo::bbox (const db::DText &text, const db::DCplxTrans &vp_trans) const { + if (m_point_mode) { + return text.box (); + } + // offset in pixels (space between origin and text) const double offset = 2.0 / vp_trans.mag (); diff --git a/src/laybasic/laybasic/layTextInfo.h b/src/laybasic/laybasic/layTextInfo.h index c99a47563..98737cf73 100644 --- a/src/laybasic/laybasic/layTextInfo.h +++ b/src/laybasic/laybasic/layTextInfo.h @@ -49,17 +49,6 @@ public: */ TextInfo (const LayoutViewBase *view); - /** - * @brief Constructor - * - * @param default_text_size The default text size in micron - * @param default_font The default font - * @param apply_text_trans True if text transformations are to be applied - * @param resolution The resolution value (logical pixel size per physical unit pixel) - * @param vp_trans The effective micron-to-pixel transformation - */ - TextInfo (double default_text_size, const db::Font &default_font, bool apply_text_trans, double resolution); - /** * @brief Gets the visual bounding box of the given DText object * @@ -71,12 +60,23 @@ public: * @param vp_trans The effective micron-to-pixel transformation */ db::DBox bbox (const db::DText &text, const db::DCplxTrans &vp_trans) const; + + /** + * @brief Gets a value indicating whether the text info uses point mode + * + * In point mode, a text is considered a point-like object. + */ + bool point_mode () const + { + return m_point_mode; + } private: double m_default_text_size; db::Font m_default_font; bool m_apply_text_trans; double m_resolution; + bool m_point_mode; }; } diff --git a/src/laybasic/laybasic/laybasicConfig.h b/src/laybasic/laybasic/laybasicConfig.h index d96709ef2..5731b82be 100644 --- a/src/laybasic/laybasic/laybasicConfig.h +++ b/src/laybasic/laybasic/laybasicConfig.h @@ -95,6 +95,7 @@ static const std::string cfg_global_trans ("global-trans"); static const std::string cfg_no_stipple ("no-stipple"); static const std::string cfg_stipple_offset ("stipple-offset"); static const std::string cfg_default_text_size ("default-text-size"); +static const std::string cfg_text_point_mode ("text-point-mode"); static const std::string cfg_text_font ("text-font"); static const std::string cfg_full_hier_new_cell ("full-hierarchy-new-cell"); static const std::string cfg_initial_hier_depth ("initial-hier-depth"); diff --git a/src/layui/layui/LayoutViewConfigPage2c.ui b/src/layui/layui/LayoutViewConfigPage2c.ui index ec01634f5..ffadaf23e 100644 --- a/src/layui/layui/LayoutViewConfigPage2c.ui +++ b/src/layui/layui/LayoutViewConfigPage2c.ui @@ -183,6 +183,13 @@ + + + + Texts are points (active area is origin) + + + diff --git a/src/layui/layui/layLayoutViewConfigPages.cc b/src/layui/layui/layLayoutViewConfigPages.cc index 4b8da6c99..d8e2ccb4e 100644 --- a/src/layui/layui/layLayoutViewConfigPages.cc +++ b/src/layui/layui/layLayoutViewConfigPages.cc @@ -372,6 +372,10 @@ LayoutViewConfigPage2c::setup (lay::Dispatcher *root) root->config_get (cfg_sel_inside_pcells_mode, ipm); mp_ui->sel_inside_pcells_cb->setChecked (ipm); + bool tpm = 0; + root->config_get (cfg_text_point_mode, tpm); + mp_ui->text_point_mode_cb->setChecked (tpm); + unsigned int sr = 0; root->config_get (cfg_search_range, sr); mp_ui->search_range_spinbx->setValue (sr); @@ -392,6 +396,7 @@ LayoutViewConfigPage2c::commit (lay::Dispatcher *root) root->config_set (cfg_sel_halo, mp_ui->halo_cb->isChecked ()); root->config_set (cfg_sel_transient_mode, mp_ui->transient_mode_cb->isChecked ()); root->config_set (cfg_sel_inside_pcells_mode, mp_ui->sel_inside_pcells_cb->isChecked ()); + root->config_set (cfg_text_point_mode, mp_ui->text_point_mode_cb->isChecked ()); root->config_set (cfg_search_range, (unsigned int) mp_ui->search_range_spinbx->value ()); root->config_set (cfg_search_range_box, (unsigned int) mp_ui->search_range_box_spinbx->value ()); }