Fixed issue #1438 (Provide a configuration option to switch back to old-style text selection (at origin only)

This commit is contained in:
Matthias Koefferlein 2023-08-01 21:40:50 +02:00
parent ae3c8c27f6
commit 6014ba9fed
11 changed files with 81 additions and 29 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -66,6 +66,7 @@ public:
options.push_back (std::pair<std::string, std::string> (cfg_apply_text_trans, "true"));
options.push_back (std::pair<std::string, std::string> (cfg_global_trans, "r0"));
options.push_back (std::pair<std::string, std::string> (cfg_default_text_size, "0.1"));
options.push_back (std::pair<std::string, std::string> (cfg_text_point_mode, "false"));
options.push_back (std::pair<std::string, std::string> (cfg_text_font, "0"));
options.push_back (std::pair<std::string, std::string> (cfg_sel_color, cc.to_string (tl::Color ())));
options.push_back (std::pair<std::string, std::string> (cfg_sel_line_width, "1"));

View File

@ -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) {

View File

@ -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 ();

View File

@ -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;
};
}

View File

@ -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");

View File

@ -183,6 +183,13 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="text_point_mode_cb">
<property name="text">
<string>Texts are points (active area is origin)</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="sel_inside_pcells_cb">
<property name="text">

View File

@ -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 ());
}