From 5bc4ea0cb9456315487a30f3cc782d792a952e7d Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 13 Jun 2021 23:05:16 +0200 Subject: [PATCH] Confine 2.5d view to viewport box --- .../tools/view_25d/lay_plugin/layD25Plugin.cc | 8 +- .../view_25d/lay_plugin/layD25ViewWidget.cc | 74 ++++++++----------- .../view_25d/lay_plugin/layD25ViewWidget.h | 2 +- 3 files changed, 31 insertions(+), 53 deletions(-) diff --git a/src/plugins/tools/view_25d/lay_plugin/layD25Plugin.cc b/src/plugins/tools/view_25d/lay_plugin/layD25Plugin.cc index 8a98ab2c4..5f0be90ab 100644 --- a/src/plugins/tools/view_25d/lay_plugin/layD25Plugin.cc +++ b/src/plugins/tools/view_25d/lay_plugin/layD25Plugin.cc @@ -51,13 +51,7 @@ public: void menu_activated (const std::string &symbol) { if (symbol == "lay::d25_view") { - - if (mp_dialog->exec_dialog (mp_view)) { - - // ... implementation is in layD25ToolDialog.cc ... - - } - + mp_dialog->exec_dialog (mp_view); } } diff --git a/src/plugins/tools/view_25d/lay_plugin/layD25ViewWidget.cc b/src/plugins/tools/view_25d/lay_plugin/layD25ViewWidget.cc index 7e9ce7b09..c3e4f1cc9 100644 --- a/src/plugins/tools/view_25d/lay_plugin/layD25ViewWidget.cc +++ b/src/plugins/tools/view_25d/lay_plugin/layD25ViewWidget.cc @@ -30,6 +30,7 @@ #include "dbEdgeProcessor.h" #include "dbPolygonGenerators.h" #include "dbPolygonTools.h" +#include "dbClip.h" #include "tlException.h" @@ -538,7 +539,6 @@ D25ViewWidget::prepare_view () m_layers.clear (); m_vertex_chunks.clear (); - m_bbox = db::DBox (); bool zset = false; m_zmin = m_zmax = 0.0; @@ -547,6 +547,8 @@ D25ViewWidget::prepare_view () return false; } + m_bbox = mp_view->viewport ().box (); + ZDataCache zdata; bool any = false; @@ -577,9 +579,7 @@ D25ViewWidget::prepare_view () m_layers.push_back (info); const lay::CellView &cv = mp_view->cellview ((unsigned int) lp->cellview_index ()); - render_layout (m_vertex_chunks.back (), cv->layout (), *cv.cell (), (unsigned int) lp->layer_index (), z0, z1); - - m_bbox += db::DBox (cv.cell ()->bbox ((unsigned int) lp->layer_index ())) * cv->layout ().dbu (); + render_layout (m_vertex_chunks.back (), cv->layout (), *cv.cell (), db::CplxTrans (cv->layout ().dbu ()).inverted () * m_bbox, (unsigned int) lp->layer_index (), z0, z1); if (! zset) { m_zmin = z0; @@ -600,7 +600,22 @@ D25ViewWidget::prepare_view () void D25ViewWidget::render_polygon (D25ViewWidget::chunks_type &chunks, const db::Polygon &poly, double dbu, double zstart, double zstop) { - if (poly.hull ().size () > 4) { + if (poly.holes () > 0) { + + std::vector poly_heap; + + db::EdgeProcessor ep; + ep.insert_sequence (poly.begin_edge ()); + db::PolygonContainer pc (poly_heap); + db::PolygonGenerator out (pc, true /*resolve holes*/, true /*min coherence*/); + db::SimpleMerge op; + ep.process (out, op); + + for (std::vector::const_iterator p = poly_heap.begin (); p != poly_heap.end (); ++p) { + render_polygon (chunks, *p, dbu, zstart, zstop); + } + + } else if (poly.hull ().size () > 4) { std::vector poly_heap; @@ -654,13 +669,13 @@ D25ViewWidget::render_wall (D25ViewWidget::chunks_type &chunks, const db::Edge & } void -D25ViewWidget::render_layout (D25ViewWidget::chunks_type &chunks, const db::Layout &layout, const db::Cell &cell, unsigned int layer, double zstart, double zstop) +D25ViewWidget::render_layout (D25ViewWidget::chunks_type &chunks, const db::Layout &layout, const db::Cell &cell, const db::Box &clip_box, unsigned int layer, double zstart, double zstop) { - db::EdgeProcessor ep; std::vector poly_heap; // TODO: hidden cells, hierarchy depth ... - db::RecursiveShapeIterator s (layout, cell, layer); + + db::RecursiveShapeIterator s (layout, cell, layer, clip_box); s.shape_flags (db::ShapeIterator::Polygons | db::ShapeIterator::Paths | db::ShapeIterator::Boxes); for ( ; ! s.at_end (); ++s) { @@ -668,48 +683,17 @@ D25ViewWidget::render_layout (D25ViewWidget::chunks_type &chunks, const db::Layo s->polygon (polygon); polygon.transform (s.trans ()); - if (polygon.holes () == 0 && polygon.hull ().size () <= 4) { + poly_heap.clear (); + db::clip_poly (polygon, clip_box, poly_heap, false /*keep holes*/); - render_polygon (chunks, polygon, layout.dbu (), zstart, zstop); + for (std::vector::const_iterator p = poly_heap.begin (); p != poly_heap.end (); ++p) { - for (db::Polygon::polygon_edge_iterator e = polygon.begin_edge (); ! e.at_end (); ++e) { + render_polygon (chunks, *p, layout.dbu (), zstart, zstop); + + for (db::Polygon::polygon_edge_iterator e = p->begin_edge (); ! e.at_end (); ++e) { render_wall (chunks, *e, layout.dbu (), zstart, zstop); } - } else { - - poly_heap.clear (); - ep.clear (); - - ep.insert_sequence (polygon.begin_edge ()); - { - db::PolygonContainer pc (poly_heap); - db::PolygonGenerator out (pc, true /*resolve holes*/, false /*min coherence for splitting*/); - db::SimpleMerge op; - ep.process (out, op); - } - - for (std::vector::const_iterator p = poly_heap.begin (); p != poly_heap.end (); ++p) { - render_polygon (chunks, *p, layout.dbu (), zstart, zstop); - } - - poly_heap.clear (); - ep.clear (); - - ep.insert_sequence (polygon.begin_edge ()); - { - db::PolygonContainer pc (poly_heap); - db::PolygonGenerator out (pc, false /*don't resolve holes*/, false /*min coherence for splitting*/); - db::SimpleMerge op; - ep.process (out, op); - } - - for (std::vector::const_iterator p = poly_heap.begin (); p != poly_heap.end (); ++p) { - for (db::Polygon::polygon_edge_iterator e = p->begin_edge (); ! e.at_end (); ++e) { - render_wall (chunks, *e, layout.dbu (), zstart, zstop); - } - } - } } diff --git a/src/plugins/tools/view_25d/lay_plugin/layD25ViewWidget.h b/src/plugins/tools/view_25d/lay_plugin/layD25ViewWidget.h index 6c5e21995..cee0c67e5 100644 --- a/src/plugins/tools/view_25d/lay_plugin/layD25ViewWidget.h +++ b/src/plugins/tools/view_25d/lay_plugin/layD25ViewWidget.h @@ -149,7 +149,7 @@ private: void do_initialize_gl (); bool prepare_view(); - void render_layout (D25ViewWidget::chunks_type &chunks, const db::Layout &layout, const db::Cell &cell, unsigned int layer, double zstart, double zstop); + void render_layout (D25ViewWidget::chunks_type &chunks, const db::Layout &layout, const db::Cell &cell, const db::Box &clip_box, unsigned int layer, double zstart, double zstop); void render_polygon (D25ViewWidget::chunks_type &chunks, const db::Polygon &poly, double dbu, double zstart, double zstop); void render_wall (D25ViewWidget::chunks_type &chunks, const db::Edge &poly, double dbu, double zstart, double zstop); };