mirror of https://github.com/KLayout/klayout.git
Edge and edge pair support
This commit is contained in:
parent
c9727c2e60
commit
553d973b69
|
|
@ -82,7 +82,7 @@ z(input(2, 0), height: 300.nm) # adds layer 2/0 for the next 30
|
|||
|
||||
<ul>
|
||||
<li><p><tt>z(</tt>layer [, options]<tt>)</tt></p>
|
||||
<p>Extrudes the given layer. "layer" is a (polygon) DRC layer. "options" declare the z extrusion and display parameters.</p>
|
||||
<p>Extrudes the given layer. "layer" is a DRC layer (polygon, edge or even edge pair). "options" declare the z extrusion and display parameters.</p>
|
||||
</li>
|
||||
<li><p><tt>zz(</tt> [options] <tt>) {</tt> block <tt>}</tt></p>
|
||||
<p>Declares a material group which combines multiple "z" statements under a single display group.
|
||||
|
|
|
|||
|
|
@ -108,8 +108,8 @@ module D25
|
|||
raise("Duplicate layer argument")
|
||||
end
|
||||
layer = a
|
||||
if ! layer.data.is_a?(RBA::Region)
|
||||
raise("Expected a polygon layer")
|
||||
if ! layer.data.is_a?(RBA::Region) && ! layer.data.is_a?(RBA::Edges) && ! layer.data.is_a?(RBA::EdgePairs)
|
||||
raise("Expected a polygon, edge or edge pair layer")
|
||||
end
|
||||
|
||||
elsif a.is_a?(1.class) || a.is_a?(1.0.class)
|
||||
|
|
|
|||
|
|
@ -71,6 +71,12 @@ Class<lay::D25View> decl_D25View (QT_EXTERNAL_BASE (QDialog) "lay", "D25View",
|
|||
gsi::method ("entry", &lay::D25View::entry, gsi::arg ("data"), gsi::arg ("dbu"), gsi::arg ("zstart"), gsi::arg ("zstop"),
|
||||
"@brief Creates a new display entry in the group opened with \\open_display"
|
||||
) +
|
||||
gsi::method ("entry", &lay::D25View::entry_edge, gsi::arg ("data"), gsi::arg ("dbu"), gsi::arg ("zstart"), gsi::arg ("zstop"),
|
||||
"@brief Creates a new display entry in the group opened with \\open_display"
|
||||
) +
|
||||
gsi::method ("entry", &lay::D25View::entry_edge_pair, gsi::arg ("data"), gsi::arg ("dbu"), gsi::arg ("zstart"), gsi::arg ("zstop"),
|
||||
"@brief Creates a new display entry in the group opened with \\open_display"
|
||||
) +
|
||||
gsi::method ("close_display", &lay::D25View::close_display,
|
||||
"@brief Finishes the display group"
|
||||
) +
|
||||
|
|
|
|||
|
|
@ -221,6 +221,22 @@ D25View::entry (const db::Region &data, double dbu, double zstart, double zstop)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
D25View::entry_edge (const db::Edges &data, double dbu, double zstart, double zstop)
|
||||
{
|
||||
if (! mp_ui->d25_view->has_error ()) {
|
||||
mp_ui->d25_view->entry (data, dbu, zstart, zstop);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
D25View::entry_edge_pair (const db::EdgePairs &data, double dbu, double zstart, double zstop)
|
||||
{
|
||||
if (! mp_ui->d25_view->has_error ()) {
|
||||
mp_ui->d25_view->entry (data, dbu, zstart, zstop);
|
||||
}
|
||||
}
|
||||
|
||||
static void layer_info_to_item (const lay::D25ViewWidget::LayerInfo &info, QListWidgetItem *item, size_t index, QSize icon_size)
|
||||
{
|
||||
if (info.has_name) {
|
||||
|
|
|
|||
|
|
@ -43,6 +43,8 @@ namespace lay
|
|||
namespace db
|
||||
{
|
||||
class Region;
|
||||
class Edges;
|
||||
class EdgePairs;
|
||||
struct LayerProperties;
|
||||
}
|
||||
|
||||
|
|
@ -69,6 +71,8 @@ public:
|
|||
void open_display (const color_t *frame_color, const color_t *fill_color, const db::LayerProperties *like, const std::string *name);
|
||||
void close_display ();
|
||||
void entry (const db::Region &data, double dbu, double zstart, double zstop);
|
||||
void entry_edge (const db::Edges &data, double dbu, double zstart, double zstop);
|
||||
void entry_edge_pair (const db::EdgePairs &data, double dbu, double zstart, double zstop);
|
||||
void finish ();
|
||||
|
||||
protected:
|
||||
|
|
|
|||
|
|
@ -31,7 +31,11 @@
|
|||
#include "dbPolygonTools.h"
|
||||
#include "dbClip.h"
|
||||
#include "dbRegion.h"
|
||||
#include "dbEdges.h"
|
||||
#include "dbEdgePairs.h"
|
||||
#include "dbOriginalLayerRegion.h"
|
||||
#include "dbOriginalLayerEdges.h"
|
||||
#include "dbOriginalLayerEdgePairs.h"
|
||||
|
||||
#include "tlException.h"
|
||||
#include "tlProgress.h"
|
||||
|
|
@ -605,7 +609,7 @@ D25ViewWidget::close_display ()
|
|||
}
|
||||
|
||||
void
|
||||
D25ViewWidget::entry (const db::Region &data, double dbu, double zstart, double zstop)
|
||||
D25ViewWidget::enter (const db::RecursiveShapeIterator *iter, double zstart, double zstop)
|
||||
{
|
||||
tl_assert (m_display_open);
|
||||
|
||||
|
|
@ -621,12 +625,10 @@ D25ViewWidget::entry (const db::Region &data, double dbu, double zstart, double
|
|||
LayerInfo &info = m_layers.back ();
|
||||
|
||||
// try to establish a default color from the region's origin if required
|
||||
const db::OriginalLayerRegion *original_region = dynamic_cast<db::OriginalLayerRegion *> (data.delegate ());
|
||||
if (mp_view && info.fill_color [3] == 0.0 && info.frame_color [3] == 0.0) {
|
||||
|
||||
if (original_region) {
|
||||
if (iter) {
|
||||
|
||||
const db::RecursiveShapeIterator *iter = original_region->iter ();
|
||||
if (iter && iter->layout () && iter->layout ()->is_valid_layer (iter->layer ())) {
|
||||
|
||||
db::LayerProperties like = iter->layout ()->get_properties (iter->layer ());
|
||||
|
|
@ -653,11 +655,56 @@ D25ViewWidget::entry (const db::Region &data, double dbu, double zstart, double
|
|||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
D25ViewWidget::entry (const db::Region &data, double dbu, double zstart, double zstop)
|
||||
{
|
||||
// try to establish a default color from the region's origin if required
|
||||
const db::RecursiveShapeIterator *iter = 0;
|
||||
const db::OriginalLayerRegion *original = dynamic_cast<db::OriginalLayerRegion *> (data.delegate ());
|
||||
if (original) {
|
||||
iter = original->iter ();
|
||||
}
|
||||
|
||||
enter (iter, zstart, zstop);
|
||||
|
||||
tl::AbsoluteProgress progress (tl::to_string (tr ("Rendering ...")));
|
||||
render_region (progress, *m_layers.back ().vertex_chunk, *m_layers.back ().line_chunk, data, dbu, db::CplxTrans (dbu).inverted () * m_bbox, zstart, zstop);
|
||||
}
|
||||
|
||||
void
|
||||
D25ViewWidget::entry (const db::Edges &data, double dbu, double zstart, double zstop)
|
||||
{
|
||||
// try to establish a default color from the region's origin if required
|
||||
const db::RecursiveShapeIterator *iter = 0;
|
||||
const db::OriginalLayerEdges *original = dynamic_cast<db::OriginalLayerEdges *> (data.delegate ());
|
||||
if (original) {
|
||||
iter = original->iter ();
|
||||
}
|
||||
|
||||
enter (iter, zstart, zstop);
|
||||
|
||||
tl::AbsoluteProgress progress (tl::to_string (tr ("Rendering ...")));
|
||||
render_edges (progress, *m_layers.back ().vertex_chunk, *m_layers.back ().line_chunk, data, dbu, db::CplxTrans (dbu).inverted () * m_bbox, zstart, zstop);
|
||||
}
|
||||
|
||||
void
|
||||
D25ViewWidget::entry (const db::EdgePairs &data, double dbu, double zstart, double zstop)
|
||||
{
|
||||
// try to establish a default color from the region's origin if required
|
||||
const db::RecursiveShapeIterator *iter = 0;
|
||||
const db::OriginalLayerEdgePairs *original = dynamic_cast<db::OriginalLayerEdgePairs *> (data.delegate ());
|
||||
if (original) {
|
||||
iter = original->iter ();
|
||||
}
|
||||
|
||||
enter (iter, zstart, zstop);
|
||||
|
||||
tl::AbsoluteProgress progress (tl::to_string (tr ("Rendering ...")));
|
||||
render_edge_pairs (progress, *m_layers.back ().vertex_chunk, *m_layers.back ().line_chunk, data, dbu, db::CplxTrans (dbu).inverted () * m_bbox, zstart, zstop);
|
||||
}
|
||||
|
||||
void
|
||||
D25ViewWidget::finish ()
|
||||
{
|
||||
|
|
@ -750,42 +797,6 @@ D25ViewWidget::render_wall (D25ViewWidget::triangle_chunks_type &chunks, D25View
|
|||
line_chunks.add (edge.p1 ().x () * dbu, zstop, edge.p1 ().y () * dbu);
|
||||
}
|
||||
|
||||
// @@@
|
||||
#if 0
|
||||
void
|
||||
D25ViewWidget::render_layout (tl::AbsoluteProgress &progress, D25ViewWidget::triangle_chunks_type &chunks, D25ViewWidget::line_chunks_type &line_chunks, const db::Layout &layout, const db::Cell &cell, const db::Box &clip_box, unsigned int layer, double zstart, double zstop)
|
||||
{
|
||||
std::vector<db::Polygon> poly_heap;
|
||||
|
||||
// TODO: hidden cells, hierarchy depth ...
|
||||
|
||||
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) {
|
||||
|
||||
db::Polygon polygon;
|
||||
s->polygon (polygon);
|
||||
polygon.transform (s.trans ());
|
||||
|
||||
poly_heap.clear ();
|
||||
db::clip_poly (polygon, clip_box, poly_heap, false /*keep holes*/);
|
||||
|
||||
for (std::vector<db::Polygon>::const_iterator p = poly_heap.begin (); p != poly_heap.end (); ++p) {
|
||||
|
||||
++progress;
|
||||
|
||||
render_polygon (chunks, line_chunks, *p, layout.dbu (), zstart, zstop);
|
||||
|
||||
for (db::Polygon::polygon_edge_iterator e = p->begin_edge (); ! e.at_end (); ++e) {
|
||||
render_wall (chunks, line_chunks, *e, layout.dbu (), zstart, zstop);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
D25ViewWidget::render_region (tl::AbsoluteProgress &progress, D25ViewWidget::triangle_chunks_type &chunks, D25ViewWidget::line_chunks_type &line_chunks, const db::Region ®ion, double dbu, const db::Box &clip_box, double zstart, double zstop)
|
||||
{
|
||||
|
|
@ -811,6 +822,43 @@ D25ViewWidget::render_region (tl::AbsoluteProgress &progress, D25ViewWidget::tri
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
D25ViewWidget::render_edges (tl::AbsoluteProgress &progress, D25ViewWidget::triangle_chunks_type &chunks, D25ViewWidget::line_chunks_type &line_chunks, const db::Edges &edges, double dbu, const db::Box &clip_box, double zstart, double zstop)
|
||||
{
|
||||
for (db::Edges::const_iterator e = edges.begin (); !e.at_end (); ++e) {
|
||||
|
||||
++progress;
|
||||
|
||||
std::pair<bool, db::Edge> ec = e->clipped (clip_box);
|
||||
if (ec.first) {
|
||||
render_wall (chunks, line_chunks, ec.second, dbu, zstart, zstop);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
D25ViewWidget::render_edge_pairs (tl::AbsoluteProgress &progress, D25ViewWidget::triangle_chunks_type &chunks, D25ViewWidget::line_chunks_type &line_chunks, const db::EdgePairs &edge_pairs, double dbu, const db::Box &clip_box, double zstart, double zstop)
|
||||
{
|
||||
for (db::EdgePairs::const_iterator e = edge_pairs.begin (); !e.at_end (); ++e) {
|
||||
|
||||
++progress;
|
||||
|
||||
std::pair<bool, db::Edge> ec;
|
||||
|
||||
ec = e->first ().clipped (clip_box);
|
||||
if (ec.first) {
|
||||
render_wall (chunks, line_chunks, ec.second, dbu, zstart, zstop);
|
||||
}
|
||||
|
||||
ec = e->second ().clipped (clip_box);
|
||||
if (ec.first) {
|
||||
render_wall (chunks, line_chunks, ec.second, dbu, zstart, zstop);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
static std::pair<double, double> find_grid (double v)
|
||||
{
|
||||
for (int p = -12; p < 12; ++p) {
|
||||
|
|
|
|||
|
|
@ -43,6 +43,9 @@
|
|||
namespace db
|
||||
{
|
||||
class Region;
|
||||
class Edges;
|
||||
class EdgePairs;
|
||||
class RecursiveShapeIterator;
|
||||
struct LayerProperties;
|
||||
}
|
||||
|
||||
|
|
@ -160,6 +163,8 @@ public:
|
|||
void open_display (const color_t *frame_color, const color_t *fill_color, const db::LayerProperties *like, const std::string *name);
|
||||
void close_display ();
|
||||
void entry (const db::Region &data, double dbu, double zstart, double zstop);
|
||||
void entry (const db::Edges &data, double dbu, double zstart, double zstop);
|
||||
void entry (const db::EdgePairs &data, double dbu, double zstart, double zstop);
|
||||
void finish ();
|
||||
|
||||
signals:
|
||||
|
|
@ -200,12 +205,13 @@ private:
|
|||
void resizeGL (int w, int h);
|
||||
|
||||
void do_initialize_gl ();
|
||||
// @@@ bool prepare_view();
|
||||
// @@@ void render_layout (tl::AbsoluteProgress &progress, D25ViewWidget::triangle_chunks_type &vertex_chunks, D25ViewWidget::line_chunks_type &line_chunks, const db::Layout &layout, const db::Cell &cell, const db::Box &clip_box, unsigned int layer, double zstart, double zstop);
|
||||
void render_region (tl::AbsoluteProgress &progress, D25ViewWidget::triangle_chunks_type &vertex_chunks, D25ViewWidget::line_chunks_type &line_chunks, const db::Region ®ion, double dbu, const db::Box &clip_box, double zstart, double zstop);
|
||||
void render_edges (tl::AbsoluteProgress &progress, D25ViewWidget::triangle_chunks_type &vertex_chunks, D25ViewWidget::line_chunks_type &line_chunks, const db::Edges ®ion, double dbu, const db::Box &clip_box, double zstart, double zstop);
|
||||
void render_edge_pairs (tl::AbsoluteProgress &progress, D25ViewWidget::triangle_chunks_type &vertex_chunks, D25ViewWidget::line_chunks_type &line_chunks, const db::EdgePairs ®ion, double dbu, const db::Box &clip_box, double zstart, double zstop);
|
||||
void render_polygon (D25ViewWidget::triangle_chunks_type &vertex_chunks, D25ViewWidget::line_chunks_type &line_chunks, const db::Polygon &poly, double dbu, double zstart, double zstop);
|
||||
void render_wall (D25ViewWidget::triangle_chunks_type &vertex_chunks, D25ViewWidget::line_chunks_type &line_chunks, const db::Edge &poly, double dbu, double zstart, double zstop);
|
||||
void reset_viewport ();
|
||||
void enter (const db::RecursiveShapeIterator *iter, double zstart, double zstop);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue