From 125f3b459fa86d41590d450d9515fc378d8f139d Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Tue, 24 Feb 2026 22:10:05 +0100 Subject: [PATCH] Added a marker attribute to turn off label frames: Marker#text_frame_enabled. Set it to false to disable the frame --- src/laybasic/laybasic/gsiDeclLayMarker.cc | 13 +++++++++++++ src/laybasic/laybasic/layMarker.cc | 19 ++++++++++++++----- src/laybasic/laybasic/layMarker.h | 17 +++++++++++++++++ testdata/ruby/layMarkers.rb | 4 ++++ 4 files changed, 48 insertions(+), 5 deletions(-) diff --git a/src/laybasic/laybasic/gsiDeclLayMarker.cc b/src/laybasic/laybasic/gsiDeclLayMarker.cc index c7c59bb29..f75bda6c1 100644 --- a/src/laybasic/laybasic/gsiDeclLayMarker.cc +++ b/src/laybasic/laybasic/gsiDeclLayMarker.cc @@ -197,6 +197,19 @@ Class decl_Marker ("lay", "Marker", "@brief Gets the halo flag\n" "See \\halo= for a description of the halo flag." ) + + gsi::method ("text_frame_enabled=", (void (lay::ManagedDMarker::*) (bool)) &lay::ManagedDMarker::set_text_frame_enabled, gsi::arg ("enabled"), + "@brief Enables or disables the label frame\n" + "With the value set to true (the default), texts (labels) are drawn with a frame indicating the label dimension.\n" + "To turn off that frame, set this attribute to false.\n" + "\n" + "This attribute has been introduced in version 0.30.7." + ) + + gsi::method ("text_frame_enabled", (bool (lay::ManagedDMarker::*) () const) &lay::ManagedDMarker::is_text_frame_enabled, + "@brief Gets a value indicating whether label frames are enabled\n" + "See \\text_frame_enabled= for a description of this attribute." + "\n" + "This attribute has been introduced in version 0.30.7." + ) + gsi::method ("dither_pattern=", (void (lay::ManagedDMarker::*) (int)) &lay::ManagedDMarker::set_dither_pattern, gsi::arg ("index"), "@brief Sets the stipple pattern index\n" "A value of -1 or less than zero indicates that the marker is not filled. Otherwise, the " diff --git a/src/laybasic/laybasic/layMarker.cc b/src/laybasic/laybasic/layMarker.cc index 4855ac37f..f30d1387f 100644 --- a/src/laybasic/laybasic/layMarker.cc +++ b/src/laybasic/laybasic/layMarker.cc @@ -188,7 +188,7 @@ void render_cell_inst (const db::Layout &layout, const db::CellInstArray &inst, MarkerBase::MarkerBase (lay::LayoutViewBase *view) : lay::ViewObject (view ? view->canvas () : 0), - m_line_width (-1), m_vertex_size (-1), m_halo (-1), m_text_enabled (true), m_vertex_shape (lay::ViewOp::Rect), m_line_style (-1), m_dither_pattern (-1), m_frame_pattern (0), mp_view (view) + m_line_width (-1), m_vertex_size (-1), m_halo (-1), m_text_enabled (true), m_text_frame_enabled (true), m_vertex_shape (lay::ViewOp::Rect), m_line_style (-1), m_dither_pattern (-1), m_frame_pattern (0), mp_view (view) { // .. nothing yet .. } @@ -266,6 +266,15 @@ MarkerBase::set_text_enabled (bool en) } } +void +MarkerBase::set_text_frame_enabled (bool en) +{ + if (m_text_frame_enabled != en) { + m_text_frame_enabled = en; + redraw (); + } +} + void MarkerBase::set_frame_pattern (int frame_pattern) { @@ -638,7 +647,7 @@ ShapeMarker::render (const Viewport &vp, ViewObjectCanvas &canvas) if (trans_vector ()) { for (std::vector::const_iterator tr = trans_vector ()->begin (); tr != trans_vector ()->end (); ++tr) { db::CplxTrans t = vp.trans () * *tr * trans (); - if (m_shape.is_text () && text) { + if (m_shape.is_text () && text && is_text_frame_enabled ()) { // draw a frame around the text lay::TextInfo ti (view ()); db::DCplxTrans vp_trans = vp.trans () * *tr; @@ -654,7 +663,7 @@ ShapeMarker::render (const Viewport &vp, ViewObjectCanvas &canvas) } } else { db::CplxTrans t = vp.trans () * trans (); - if (m_shape.is_text () && text) { + if (m_shape.is_text () && text && is_text_frame_enabled ()) { // draw a frame around the text lay::TextInfo ti (view ()); db::Text t; @@ -1118,7 +1127,7 @@ Marker::draw (lay::Renderer &r, const db::CplxTrans &t, lay::CanvasPlane *fill, // TODO: in order to draw the box we'd need a separation of dbu-to-micron and micron-to-pixel transformations ... r.draw (*m_object.text, t, fill, contour, vertex, text); } else if (m_type == DText) { - if (view () && text) { + if (view () && text && is_text_frame_enabled ()) { // draw a frame around the text lay::TextInfo ti (view ()); db::DCplxTrans dt (t); @@ -1323,7 +1332,7 @@ DMarker::render (const Viewport &vp, ViewObjectCanvas &canvas) } else if (m_type == Path) { r.draw (*m_object.path, t, fill, contour, vertex, text); } else if (m_type == Text) { - if (view () && text) { + if (view () && text && is_text_frame_enabled ()) { // draw a frame around the text lay::TextInfo ti (view ()); db::DBox box = ti.bbox (*m_object.text, t).enlarged (text_box_enlargement (t)); diff --git a/src/laybasic/laybasic/layMarker.h b/src/laybasic/laybasic/layMarker.h index 925599dc8..0738e2ffa 100644 --- a/src/laybasic/laybasic/layMarker.h +++ b/src/laybasic/laybasic/layMarker.h @@ -232,6 +232,22 @@ class LAYBASIC_PUBLIC MarkerBase */ void set_text_enabled (bool en); + /** + * @brief Gets a value indicating whether text frame drawing is enabled + * + * If this value is true (the default), labels are drawn with a frame indicating the text box. + * Set this value to value to disable the text box. + */ + bool is_text_frame_enabled () const + { + return m_text_frame_enabled; + } + + /** + * @brief Sets a value indicating whether text drawing is enabled + */ + void set_text_frame_enabled (bool en); + /** * @brief Gets the bounding box */ @@ -255,6 +271,7 @@ class LAYBASIC_PUBLIC MarkerBase tl::Color m_frame_color; int m_line_width, m_vertex_size, m_halo; bool m_text_enabled; + bool m_text_frame_enabled; lay::ViewOp::Shape m_vertex_shape; int m_line_style, m_dither_pattern, m_frame_pattern; lay::LayoutViewBase *mp_view; diff --git a/testdata/ruby/layMarkers.rb b/testdata/ruby/layMarkers.rb index e261c4aa6..3fe496d22 100644 --- a/testdata/ruby/layMarkers.rb +++ b/testdata/ruby/layMarkers.rb @@ -72,6 +72,10 @@ def test_1 m.dither_pattern = 15 assert_equal(m.dither_pattern, 15) + assert_equal(m.text_frame_enabled, true) + m.text_frame_enabled = false + assert_equal(m.text_frame_enabled, false) + # Keep the marker alive after GC.start: # $marker = m