mirror of https://github.com/KLayout/klayout.git
Merge pull request #2281 from KLayout/feature/issue-2278
Added a marker attribute to turn off label frames: Marker#text_frame_…
This commit is contained in:
commit
b5a05b939b
|
|
@ -197,6 +197,19 @@ Class<lay::ManagedDMarker> 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 "
|
||||
|
|
|
|||
|
|
@ -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<db::DCplxTrans>::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));
|
||||
|
|
|
|||
|
|
@ -232,6 +232,22 @@ public:
|
|||
*/
|
||||
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 @@ private:
|
|||
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;
|
||||
|
|
|
|||
|
|
@ -72,6 +72,10 @@ class LAYMarkers_TestClass < TestBase
|
|||
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
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue