Adding frame to text display, debugging

This commit is contained in:
Matthias Koefferlein 2023-05-09 22:36:56 +02:00
parent 45394b801a
commit c6f159d720
5 changed files with 36 additions and 3 deletions

View File

@ -847,7 +847,7 @@ Bitmap::render_text (const lay::RenderText &text)
if (y > -0.5 && y < double (height () + ff.height () - 1) - 0.5) {
for ( ; cp1 != cp; ++cp1) {
while (cp1 != cp) {
uint32_t c = tl::utf32_from_utf8 (cp1, cp);
if (c < uint32_t (ff.first_char ()) || c >= uint32_t (ff.n_chars ()) + ff.first_char ()) {

View File

@ -30,6 +30,7 @@
#include "layViewOp.h"
#include "layRenderer.h"
#include "layLayoutViewBase.h"
#include "layTextInfo.h"
#include "tlAssert.h"
namespace lay
@ -625,11 +626,24 @@ 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) {
// draw a frame around the text
lay::TextInfo ti (view ());
db::DCplxTrans vp_trans = vp.trans () * *tr;
db::DBox box = ti.bbox (trans () * m_shape.text (), vp_trans).enlarged (db::DVector (2.0 / vp_trans.mag (), 2.0 / vp_trans.mag ()));
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);
}
} else {
db::CplxTrans t = vp.trans () * trans ();
if (m_shape.is_text () && text) {
// draw a frame around the text
lay::TextInfo ti (view ());
db::DBox box = ti.bbox (trans () * m_shape.text (), vp.trans ()).enlarged (db::DVector (2.0 / vp.trans ().mag (), 2.0 / vp.trans ().mag ()));
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);
}
@ -1081,8 +1095,15 @@ Marker::draw (lay::Renderer &r, const db::CplxTrans &t, lay::CanvasPlane *fill,
} else if (m_type == DPath) {
r.draw (*m_object.dpath, db::DCplxTrans (t), fill, contour, vertex, text);
} else if (m_type == Text) {
// 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) {
// draw a frame around the text
lay::TextInfo ti (view ());
db::DBox box = ti.bbox (*m_object.dtext, db::DCplxTrans (t)).enlarged (db::DVector (2.0 / t.mag (), 2.0 / t.mag ()));
r.draw (box, db::DCplxTrans (t), 0, text, 0, 0);
}
r.draw (*m_object.dtext, db::DCplxTrans (t), fill, contour, vertex, text);
} else if (m_type == Edge) {
r.draw (*m_object.edge, t, fill, contour, vertex, text);
@ -1279,6 +1300,12 @@ 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) {
// draw a frame around the text
lay::TextInfo ti (view ());
db::DBox box = ti.bbox (*m_object.text, t).enlarged (db::DVector (2.0 / t.mag (), 2.0 / t.mag ()));
r.draw (box, t, 0, text, 0, 0);
}
r.draw (*m_object.text, t, fill, contour, vertex, text);
} else if (m_type == Edge) {
r.draw (*m_object.edge, t, fill, contour, vertex, text);

View File

@ -226,6 +226,12 @@ public:
protected:
void get_bitmaps (const Viewport &vp, ViewObjectCanvas &canvas, lay::CanvasPlane *&fill, lay::CanvasPlane *&frame, lay::CanvasPlane *&vertex, lay::CanvasPlane *&text);
lay::LayoutViewBase *view ()
{
return mp_view;
}
private:
tl::Color m_color;
tl::Color m_frame_color;
char m_line_width, m_vertex_size, m_halo;

View File

@ -83,7 +83,7 @@ TextInfo::bbox (const db::DText &text, const db::DCplxTrans &vp_trans) const
db::DVector tp1 (fx * offset, fy * offset + (fy - 1) * 0.5 * h);
db::DVector tp2 (fx * offset, fy * offset + (fy + 1) * 0.5 * h);
db::DPoint dp = db::DPoint () + text.trans ().disp ();
db::DPoint dp = vp_trans * (db::DPoint () + text.trans ().disp ());
db::DBox b (dp + fp (tp1), dp + fp (tp2));

View File

@ -46,7 +46,7 @@ TEST(1)
lay::TextInfo ti (&lv);
EXPECT_EQ (ti.bbox (text, db::DCplxTrans ()).to_string (), "(12,22;36,37)");
EXPECT_EQ (ti.bbox (text, db::DCplxTrans (2.0)).to_string (), "(6,11;18,18.5)");
EXPECT_EQ (ti.bbox (text, db::DCplxTrans (2.0)).to_string (), "(11,21;23,28.5)");
EXPECT_EQ (ti.bbox (text2, db::DCplxTrans ()).to_string (), "(12,22;60,52)");
text3 = text2;