Merge branch 'master' of github.com:KLayout/klayout into complex_drc_ops

This commit is contained in:
Matthias Koefferlein 2021-01-17 22:45:40 +01:00
commit e1312d7a0c
16 changed files with 213 additions and 18 deletions

View File

@ -54,6 +54,7 @@ CommonReader::make_cell (db::Layout &layout, const std::string &cn)
common_reader_error (tl::sprintf (tl::to_string (tr ("A cell with name %s already exists")), cn));
}
m_temp_cells.erase (cell.cell_index ());
cell.set_ghost_cell (false);
return cell.cell_index ();
@ -98,6 +99,7 @@ CommonReader::make_cell (db::Layout &layout, size_t id)
common_reader_error (tl::sprintf (tl::to_string (tr ("A cell with ID %ld already exists")), id));
}
m_temp_cells.erase (cell.cell_index ());
cell.set_ghost_cell (false);
return cell.cell_index ();
@ -180,6 +182,7 @@ CommonReader::rename_cell (db::Layout &layout, size_t id, const std::string &cn)
db::cell_index_type ci = layout.add_anonymous_cell ();
layout.cell (ci).set_ghost_cell (true);
m_temp_cells.insert (ci);
m_id_map [id] = std::make_pair (cn, ci);
m_name_map [cn] = std::make_pair (id, ci);
@ -195,6 +198,7 @@ CommonReader::cell_for_instance (db::Layout &layout, size_t id)
std::map<size_t, std::pair<std::string, db::cell_index_type> >::iterator iid = m_id_map.find (id);
if (iid != m_id_map.end ()) {
m_temp_cells.erase (iid->second.second);
return iid->second.second;
} else {
@ -216,6 +220,7 @@ CommonReader::cell_for_instance (db::Layout &layout, const std::string &cn)
std::map<std::string, std::pair<size_t, db::cell_index_type> >::iterator iname = m_name_map.find (cn);
if (iname != m_name_map.end ()) {
m_temp_cells.erase (iname->second.second);
return iname->second.second;
} else {
@ -423,6 +428,12 @@ CommonReader::finish (db::Layout &layout)
}
// remove temporary cells (some that were "declared" by "rename_cell" but not used by cell_for_instance)
for (std::set<db::cell_index_type>::const_iterator ci = m_temp_cells.begin (); ci != m_temp_cells.end (); ++ci) {
layout.delete_cell (*ci);
}
// resolve layer multi-mapping
for (std::map<std::set<unsigned int>, unsigned int>::const_iterator i = m_multi_mapping_placeholders.begin (); i != m_multi_mapping_placeholders.end (); ++i) {

View File

@ -251,6 +251,7 @@ protected:
private:
std::map<size_t, std::pair<std::string, db::cell_index_type> > m_id_map;
std::map<std::string, std::pair<size_t, db::cell_index_type> > m_name_map;
std::set<db::cell_index_type> m_temp_cells;
std::map<size_t, std::string> m_name_for_id;
CellConflictResolution m_cc_resolution;
bool m_create_layers;

View File

@ -264,6 +264,11 @@ TEST(2_6)
run_test (_this, "2.6");
}
TEST(2_7)
{
run_test (_this, "2.7");
}
TEST(3_1)
{
run_test (_this, "3.1");

View File

@ -6,7 +6,7 @@ TARGET = oasis_tests
include($$PWD/../../../../lib_ut.pri)
SOURCES = \
dbOASISReader.cc \
dbOASISReaderTests.cc \
dbOASISWriter2.cc \
dbOASISWriter.cc \

View File

@ -243,7 +243,84 @@
</widget>
</item>
<item>
<widget class="lay::D25ViewWidget" name="d25_view"/>
<widget class="QStackedWidget" name="gl_stack">
<widget class="QWidget" name="page">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="lay::D25ViewWidget" name="d25_view"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_2">
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QTextBrowser" name="error_text">
<property name="palette">
<palette>
<active>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>213</green>
<blue>213</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>213</green>
<blue>213</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>239</red>
<green>239</green>
<blue>239</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QFrame" name="frame_2">

View File

@ -31,7 +31,7 @@
namespace lay
{
const double initial_elevation = 3.0;
const double initial_elevation = 15.0;
D25View::D25View (QWidget *parent)
: QDialog (parent)
@ -50,6 +50,9 @@ D25View::D25View (QWidget *parent)
connect (mp_ui->fit_bottom, SIGNAL (clicked ()), this, SLOT (fit_button_clicked ()));
connect (mp_ui->zoom_slider, SIGNAL (valueChanged (int)), this, SLOT (scale_slider_changed (int)));
connect (mp_ui->d25_view, SIGNAL (scale_factor_changed (double)), this, SLOT (scale_factor_changed (double)));
connect (mp_ui->d25_view, SIGNAL (init_failed ()), this, SLOT (init_failed ()));
mp_ui->gl_stack->setCurrentIndex (0);
}
D25View::~D25View ()
@ -65,6 +68,13 @@ static QString scale_factor_to_string (double f)
return s;
}
void
D25View::init_failed ()
{
mp_ui->error_text->setPlainText (tl::to_qstring (mp_ui->d25_view->error ()));
mp_ui->gl_stack->setCurrentIndex (1);
}
void
D25View::scale_slider_changed (int value)
{
@ -100,7 +110,7 @@ D25View::exec_dialog (lay::LayoutView *view)
mp_ui->d25_view->reset ();
mp_ui->d25_view->set_cam_azimuth (0.0);
mp_ui->d25_view->set_cam_elevation (initial_elevation);
mp_ui->d25_view->set_cam_elevation (-initial_elevation);
mp_ui->d25_view->fit ();
int ret = QDialog::exec ();
@ -130,8 +140,10 @@ D25View::fit_button_clicked ()
azimuth = -90.0;
elevation = -initial_elevation;
} else if (sender () == mp_ui->fit_top) {
azimuth = 0;
elevation = -90;
} else if (sender () == mp_ui->fit_bottom) {
azimuth = 0;
elevation = 90;
}

View File

@ -58,6 +58,7 @@ private slots:
void fit_button_clicked ();
void scale_factor_changed (double f);
void scale_slider_changed (int value);
void init_failed ();
private:
Ui::D25View *mp_ui;

View File

@ -36,6 +36,9 @@
#include <QWheelEvent>
#include <QMouseEvent>
#include <QKeyEvent>
#include <QImage>
#include <QPainter>
#include <QOpenGLTexture>
#include "math.h"
@ -186,7 +189,7 @@ private:
D25ViewWidget::D25ViewWidget (QWidget *parent)
: QOpenGLWidget (parent),
m_shapes_program (0)
m_shapes_program (0), m_gridplane_program (0)
{
QSurfaceFormat format;
format.setDepthBufferSize (24);
@ -381,9 +384,8 @@ D25ViewWidget::fit ()
QVector3D new_center (0.0, 0.0, -dv / 2.0 + std::max (0.0, -d / (2.0 * tan (cam_fov () * M_PI / 180.0 / 2.0)) + cam_dist ()));
QVector3D new_center_in_scene = cam_trans ().inverted ().map (new_center);
new_center_in_scene.setY (0.0);
m_displacement = (new_center_in_scene - dim * 0.5) / m_scale_factor - bll;
m_displacement.setY (0.0);
refresh ();
@ -694,6 +696,39 @@ static std::pair<double, double> find_grid (double v)
void
D25ViewWidget::initializeGL ()
{
tl_assert (m_shapes_program == 0);
tl_assert (m_gridplane_program == 0);
bool error = false;
try {
do_initialize_gl ();
} catch (tl::Exception &ex) {
m_error = ex.msg ();
error = true;
} catch (std::exception &ex) {
m_error = ex.what ();
error = true;
} catch (...) {
m_error = "(unspecific error)";
error = true;
}
if (error) {
delete m_shapes_program;
m_shapes_program = 0;
delete m_gridplane_program;
m_gridplane_program = 0;
emit init_failed ();
}
}
void
D25ViewWidget::do_initialize_gl ()
{
QOpenGLFunctions::initializeOpenGLFunctions();
@ -824,8 +859,8 @@ D25ViewWidget::initializeGL ()
void
D25ViewWidget::paintGL ()
{
const qreal retinaScale = devicePixelRatio ();
glViewport (0, 0, width () * retinaScale, height () * retinaScale);
const qreal retina_scale = devicePixelRatio ();
glViewport (0, 0, width () * retina_scale, height () * retina_scale);
QColor c = mp_view->background_color ();
float foreground_rgb = (c.green () > 128 ? 0.0f : 1.0f);
@ -835,6 +870,12 @@ D25ViewWidget::paintGL ()
glClearColor (float (c.red ()) / 255.0f, float (c.green ()) / 255.0f, float (c.blue ()) / 255.0f, 1.0);
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
const int positions = 0;
if (! m_shapes_program || ! m_gridplane_program) {
return;
}
QMatrix4x4 scene_trans, scene_trans_wo_y;
// provide the displacement and scaling (in this order!)
@ -846,8 +887,6 @@ D25ViewWidget::paintGL ()
scene_trans_wo_y = scene_trans;
scene_trans_wo_y.translate (QVector3D (0.0, -m_displacement.y (), 0.0));
const int positions = 0;
m_shapes_program->bind ();
// draw the actual layout

View File

@ -104,8 +104,14 @@ public:
refresh ();
}
const std::string &error () const
{
return m_error;
}
signals:
void scale_factor_changed (double f);
void init_failed ();
protected:
virtual void camera_changed ();
@ -119,6 +125,7 @@ private:
std::auto_ptr<D25InteractionMode> mp_mode;
QOpenGLShaderProgram *m_shapes_program, *m_gridplane_program;
std::string m_error;
double m_scale_factor;
QVector3D m_displacement;
lay::LayoutView *mp_view;
@ -126,9 +133,11 @@ private:
double m_zmin, m_zmax;
std::list<chunks_type> m_vertex_chunks;
std::list<chunks_type> m_normals_chunks;
struct LayerInfo {
const chunks_type *vertex_chunk;
const chunks_type *normals_chunk;
GLfloat color [4];
};
@ -138,6 +147,7 @@ private:
void paintGL ();
void resizeGL (int w, int h);
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_polygon (D25ViewWidget::chunks_type &chunks, const db::Polygon &poly, double dbu, double zstart, double zstop);

View File

@ -6,6 +6,6 @@ export LANG
for t in *.ot; do
out=`echo $t | sed 's/.ot$/.oas/'`
echo "$t -> $out"
./mkoasis.tcl $t $out
tclsh ./mkoasis.tcl $t $out
done

View File

@ -14,12 +14,12 @@ header
uint 0 ;# offset table is in start record
for { set i 0 } { $i < 12 } { incr i } { uint 0 }
# XYZ gets assigned 1
# ABC gets assigned 1
record CELLNAME_ID
str ABC
uint 1
# ABC gets assigned 0 implicitly
# XYZ gets assigned 0 implicitly
record CELLNAME
str XYZ ;# FAIL: implicit and explicit assignment may not be mixed

View File

@ -20,12 +20,12 @@ header
uint 0 ;# offset table is in start record
for { set i 0 } { $i < 12 } { incr i } { uint 0 }
# XYZ gets assigned 1
# ABC gets assigned 1
record CELLNAME_ID
str ABC
uint 1
# ABC gets assigned 0
# XYZ gets assigned 0
record CELLNAME_ID
str XYZ
uint 0

View File

@ -14,12 +14,12 @@ header
uint 0 ;# offset table is in start record
for { set i 0 } { $i < 12 } { incr i } { uint 0 }
# XYZ gets assigned 1
# ABC gets assigned 1
record CELLNAME_ID
str ABC
uint 1
# ABC gets assigned 0
# XYZ gets assigned 0
record CELLNAME_ID
str XYZ
uint 0

BIN
testdata/oasis/t2.7.oas vendored Normal file

Binary file not shown.

35
testdata/oasis/t2.7.ot vendored Normal file
View File

@ -0,0 +1,35 @@
# <test>
# <name>t2.7.ot</name>
# <content-description>Two cells, one just declared but not present</content-description>
# <test-intention>Unused CELLNAME must not generate an empty cell</test-intention>
# <content>
# begin_lib 0.001
# begin_cell {XYZ}
# end_cell
# end_lib
# </content>
# </test>
header
real 0 1000.0
uint 0 ;# offset table is in start record
for { set i 0 } { $i < 12 } { incr i } { uint 0 }
# ABC gets assigned 1
record CELLNAME_ID
str ABC
uint 1
# XYZ gets assigned 0
record CELLNAME_ID
str XYZ
uint 0
# Cell XYZ (empty)
record CELL_ID
uint 0
# no body.
tail

4
testdata/oasis/t2.7_au.txt vendored Normal file
View File

@ -0,0 +1,4 @@
begin_lib 0.001
begin_cell {XYZ}
end_cell
end_lib