Skip to content

Commit

Permalink
Merge pull request #1495 from KLayout/wip2
Browse files Browse the repository at this point in the history
Wip2
  • Loading branch information
klayoutmatthias authored Oct 6, 2023
2 parents 87aef17 + 3583292 commit 01c1904
Show file tree
Hide file tree
Showing 25 changed files with 402 additions and 74 deletions.
Binary file modified src/doc/doc/about/25d_screenshot2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 9 additions & 9 deletions src/doc/doc/about/25d_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -171,19 +171,19 @@ end
</p>

<pre>
poly = input(2, 0)
active = input(1, 0)
gate = input(1, 0)
active = input(2, 0)

z(poly, zstart: 0, height: 20.nm, name: "POLY")
z(active, zstart: 0, height: 20.nm, name: "ACTIVE")

zz(name: "ACTIVE", like: "1/0") do
zz(name: "GATE", like: "1/0") do

poly_sized = poly.sized(10.nm)
active_over_poly_sized = poly_sized &amp; active
active_sized = active.sized(10.nm)
gate_over_active_sized = active_sized &amp; gate

z(active - poly, zstart: 0, height: 10.nm) # bottom sheet
z(active_over_poly_sized - poly, height: 10.nm) # center sheet
z(active_over_poly_sized, height: 10.nm) # top sheet
z(gate - active, zstart: 0, height: 10.nm)
z(gate_over_active_sized - active, height: 10.nm)
z(gate_over_active_sized, height: 10.nm)

end
</pre>
Expand Down
2 changes: 1 addition & 1 deletion src/drc/drc/built-in-macros/_drc_engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1595,7 +1595,7 @@ def output_cell(cellname)
if ! @def_output
if @def_layout
# establish a new default output from the default layout on this occasion
@def_output = LayoutOutputChannel::new(self, @def_layout, cellname.to_s, nil)
@def_output = LayoutOutputChannel::new(self, @def_layout, @def_layout.cell(cellname.to_s), nil)
end
else
@def_output.cellname = cellname.to_s
Expand Down
10 changes: 10 additions & 0 deletions src/drc/unit_tests/drcSimpleTests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1547,6 +1547,16 @@ TEST(60d_issue1216)
run_test (_this, "60", true);
}

TEST(61_issue1485)
{
run_test (_this, "61", false);
}

TEST(61d_issue1485)
{
run_test (_this, "61", true);
}

TEST(70_props)
{
run_test (_this, "70", false);
Expand Down
53 changes: 30 additions & 23 deletions src/edt/edt/EditorOptionsGeneric.ui
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,30 @@
<property name="verticalSpacing">
<number>2</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_5">
<item row="0" column="2">
<widget class="QLineEdit" name="edit_grid_le">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Enter the grid in micron. Can be anisotropic (&quot;gx,gy&quot;)</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Grid</string>
<string>Objects </string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="3">
<widget class="QCheckBox" name="snap_objects_cbx">
<property name="text">
<string>Snap to other objects</string>
</property>
</widget>
</item>
Expand Down Expand Up @@ -130,17 +150,10 @@
</item>
</widget>
</item>
<item row="1" column="1" colspan="3">
<widget class="QCheckBox" name="snap_objects_cbx">
<property name="text">
<string>Snap to other objects</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_6">
<item row="0" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Objects </string>
<string>Grid</string>
</property>
</widget>
</item>
Expand All @@ -157,16 +170,10 @@
</property>
</spacer>
</item>
<item row="0" column="2">
<widget class="QLineEdit" name="edit_grid_le">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>Enter the grid in micron. Can be anisotropic (&quot;gx,gy&quot;)</string>
<item row="2" column="1" colspan="3">
<widget class="QCheckBox" name="snap_objects_to_grid_cbx">
<property name="text">
<string>Snap to grid while moving</string>
</property>
</widget>
</item>
Expand Down
1 change: 1 addition & 0 deletions src/edt/edt/edtConfig.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ namespace edt

std::string cfg_edit_grid ("edit-grid");
std::string cfg_edit_snap_to_objects ("edit-snap-to-objects");
std::string cfg_edit_snap_objects_to_grid ("edit-snap-objects-to-grid");
std::string cfg_edit_move_angle_mode ("edit-move-angle-mode");
std::string cfg_edit_connect_angle_mode ("edit-connect-angle-mode");
std::string cfg_edit_text_string ("edit-text-string");
Expand Down
1 change: 1 addition & 0 deletions src/edt/edt/edtConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ namespace edt
*/
extern EDT_PUBLIC std::string cfg_edit_grid;
extern EDT_PUBLIC std::string cfg_edit_snap_to_objects;
extern EDT_PUBLIC std::string cfg_edit_snap_objects_to_grid;
extern EDT_PUBLIC std::string cfg_edit_move_angle_mode;
extern EDT_PUBLIC std::string cfg_edit_connect_angle_mode;
extern EDT_PUBLIC std::string cfg_edit_text_string;
Expand Down
6 changes: 6 additions & 0 deletions src/edt/edt/edtEditorOptionsPages.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ EditorOptionsGeneric::EditorOptionsGeneric (lay::LayoutViewBase *view, lay::Disp
connect (mp_ui->hier_sel_cbx, SIGNAL (clicked ()), this, SLOT (edited ()));
connect (mp_ui->hier_copy_mode_cbx, SIGNAL (activated (int)), this, SLOT (edited ()));
connect (mp_ui->snap_objects_cbx, SIGNAL (clicked ()), this, SLOT (edited ()));
connect (mp_ui->snap_objects_to_grid_cbx, SIGNAL (clicked ()), this, SLOT (edited ()));
connect (mp_ui->max_shapes_le, SIGNAL (editingFinished ()), this, SLOT (edited ()));
connect (mp_ui->show_shapes_cbx, SIGNAL (clicked ()), this, SLOT (edited ()));
}
Expand Down Expand Up @@ -132,6 +133,7 @@ EditorOptionsGeneric::apply (lay::Dispatcher *root)
int cpm = mp_ui->hier_copy_mode_cbx->currentIndex ();
root->config_set (cfg_edit_hier_copy_mode, tl::to_string ((cpm < 0 || cpm > 1) ? -1 : cpm));
root->config_set (cfg_edit_snap_to_objects, tl::to_string (mp_ui->snap_objects_cbx->isChecked ()));
root->config_set (cfg_edit_snap_objects_to_grid, tl::to_string (mp_ui->snap_objects_to_grid_cbx->isChecked ()));

configure_from_line_edit<unsigned int> (root, mp_ui->max_shapes_le, cfg_edit_max_shapes_of_instances);
root->config_set (cfg_edit_show_shapes_of_instances, tl::to_string (mp_ui->show_shapes_cbx->isChecked ()));
Expand Down Expand Up @@ -194,6 +196,10 @@ EditorOptionsGeneric::setup (lay::Dispatcher *root)
root->config_get (cfg_edit_snap_to_objects, snap_to_objects);
mp_ui->snap_objects_cbx->setChecked (snap_to_objects);

bool snap_objects_to_grid = false;
root->config_get (cfg_edit_snap_objects_to_grid, snap_objects_to_grid);
mp_ui->snap_objects_to_grid_cbx->setChecked (snap_objects_to_grid);

unsigned int max_shapes = 1000;
root->config_get (cfg_edit_max_shapes_of_instances, max_shapes);
mp_ui->max_shapes_le->setText (tl::to_qstring (tl::to_string (max_shapes)));
Expand Down
93 changes: 89 additions & 4 deletions src/edt/edt/edtPartialService.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1102,6 +1102,7 @@ PartialService::PartialService (db::Manager *manager, lay::LayoutViewBase *view,
m_buttons (0),
m_connect_ac (lay::AC_Any), m_move_ac (lay::AC_Any), m_alt_ac (lay::AC_Global),
m_snap_to_objects (true),
m_snap_objects_to_grid (true),
m_top_level_sel (false),
m_hover (false),
m_hover_wait (false),
Expand Down Expand Up @@ -1341,6 +1342,9 @@ PartialService::configure (const std::string &name, const std::string &value)
} else if (name == cfg_edit_snap_to_objects) {
tl::from_string (value, m_snap_to_objects);
return true; // taken
} else if (name == cfg_edit_snap_objects_to_grid) {
tl::from_string (value, m_snap_objects_to_grid);
return true; // taken
} else if (name == cfg_edit_move_angle_mode) {
acc.from_string (value, m_move_ac);
return true; // taken
Expand Down Expand Up @@ -1651,7 +1655,7 @@ PartialService::mouse_move_event (const db::DPoint &p, unsigned int buttons, boo
// thus, we can bring the point on grid or to an object's edge or vertex
snap_details = snap2 (p);
if (snap_details.object_snap == lay::PointSnapToObjectResult::NoObject) {
m_current = m_start + snap (p - m_start);
m_current = m_start + snap_move (p - m_start);
} else {
m_current = snap_details.snapped_point;
mouse_cursor_from_snap_details (snap_details);
Expand All @@ -1660,7 +1664,7 @@ PartialService::mouse_move_event (const db::DPoint &p, unsigned int buttons, boo
} else {

// snap movement to angle and grid without object
m_current = m_start + snap (p - m_start);
m_current = m_start + snap_move (p - m_start);
clear_mouse_cursors ();

}
Expand Down Expand Up @@ -2198,9 +2202,86 @@ PartialService::begin_move (MoveMode mode, const db::DPoint &p, lay::angle_const
}
}

void
PartialService::update_vector_snapped_point (const db::DPoint &pt, db::DVector &vr, bool &result_set) const
{
db::DVector v = snap (pt) - pt;

if (! result_set || v.length () < vr.length ()) {
result_set = true;
vr = v;
}
}

db::DVector
PartialService::snap_marker_to_grid (const db::DVector &v, bool &snapped) const
{
if (! m_snap_objects_to_grid) {
return v;
}

snapped = false;
db::DVector vr;

// max. 10000 checks
size_t count = 10000;

db::DVector snapped_to (1.0, 1.0);
db::DVector vv = lay::snap_angle (v, move_ac (), &snapped_to);

TransformationVariants tv (view ());

for (auto r = m_selection.begin (); r != m_selection.end (); ++r) {

if (! r->first.is_valid (view ()) || r->first.is_cell_inst ()) {
continue;
}

const lay::CellView &cv = view ()->cellview (r->first.cv_index ());
const std::vector<db::DCplxTrans> *tv_list = tv.per_cv_and_layer (r->first.cv_index (), r->first.layer ());
if (!tv_list || tv_list->empty ()) {
continue;
}

db::CplxTrans tr = db::DCplxTrans (vv) * tv_list->front () * db::CplxTrans (cv->layout ().dbu ()) * cv.context_trans () * r->first.trans ();

for (auto e = r->second.begin (); e != r->second.end () && count > 0; ++e) {
update_vector_snapped_point (tr * e->p1 (), vr, snapped);
--count;
if (count > 0) {
update_vector_snapped_point (tr * e->p2 (), vr, snapped);
--count;
}
}

}

if (snapped) {
vr += vv;
return db::DVector (vr.x () * snapped_to.x (), vr.y () * snapped_to.y ());
} else {
return db::DVector ();
}
}

db::DVector
PartialService::snap_move (const db::DVector &v) const
{
bool snapped = false;
db::DVector vs = snap_marker_to_grid (v, snapped);
if (! snapped) {
vs = snap (v);
}
return vs;
}

void
PartialService::move (const db::DPoint &p, lay::angle_constraint_type ac)
{
if (! m_dragging) {
return;
}

m_alt_ac = ac;

set_cursor (lay::Cursor::size_all);
Expand All @@ -2214,7 +2295,7 @@ PartialService::move (const db::DPoint &p, lay::angle_constraint_type ac)
// thus, we can bring the point on grid or to an object's edge or vertex
snap_details = snap2 (p);
if (snap_details.object_snap == lay::PointSnapToObjectResult::NoObject) {
m_current = m_start + snap (p - m_start);
m_current = m_start + snap_move (p - m_start);
} else {
m_current = snap_details.snapped_point;
mouse_cursor_from_snap_details (snap_details);
Expand All @@ -2223,7 +2304,7 @@ PartialService::move (const db::DPoint &p, lay::angle_constraint_type ac)
} else {

// snap movement to angle and grid without object
m_current = m_start + snap (p - m_start);
m_current = m_start + snap_move (p - m_start);
clear_mouse_cursors ();

}
Expand All @@ -2236,6 +2317,10 @@ PartialService::move (const db::DPoint &p, lay::angle_constraint_type ac)
void
PartialService::end_move (const db::DPoint & /*p*/, lay::angle_constraint_type ac)
{
if (! m_dragging) {
return;
}

m_alt_ac = ac;

if (m_current != m_start) {
Expand Down
4 changes: 4 additions & 0 deletions src/edt/edt/edtPartialService.h
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ public slots:
lay::angle_constraint_type m_connect_ac, m_move_ac, m_alt_ac;
db::DVector m_edit_grid;
bool m_snap_to_objects;
bool m_snap_objects_to_grid;
db::DVector m_global_grid;
bool m_top_level_sel;

Expand Down Expand Up @@ -373,6 +374,9 @@ public slots:
db::DPoint snap (const db::DPoint &p) const;
db::DVector snap (const db::DVector &p) const;
lay::PointSnapToObjectResult snap2 (const db::DPoint &p) const;
void update_vector_snapped_point (const db::DPoint &pt, db::DVector &vr, bool &result_set) const;
db::DVector snap_marker_to_grid (const db::DVector &v, bool &snapped) const;
db::DVector snap_move(const db::DVector &p) const;

void enter_edge (const EdgeWithIndex &e, size_t &nmarker, partial_objects::const_iterator sel, const std::map <PointWithIndex, db::Point> &new_points, const std::map <EdgeWithIndex, db::Edge> &new_edges, const db::ICplxTrans &gt, const std::vector<db::DCplxTrans> &tv, bool transient);
void enter_vertices (size_t &nmarker, partial_objects::const_iterator sel, const std::map <PointWithIndex, db::Point> &new_points, const std::map <EdgeWithIndex, db::Edge> &new_edges, const db::ICplxTrans &gt, const std::vector<db::DCplxTrans> &tv, bool transient);
Expand Down
1 change: 1 addition & 0 deletions src/edt/edt/edtPlugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ class MainPluginDeclaration
options.push_back (std::pair<std::string, std::string> (cfg_edit_hier_copy_mode, "-1"));
options.push_back (std::pair<std::string, std::string> (cfg_edit_grid, ""));
options.push_back (std::pair<std::string, std::string> (cfg_edit_snap_to_objects, "false"));
options.push_back (std::pair<std::string, std::string> (cfg_edit_snap_objects_to_grid, "true"));
options.push_back (std::pair<std::string, std::string> (cfg_edit_move_angle_mode, "any"));
options.push_back (std::pair<std::string, std::string> (cfg_edit_connect_angle_mode, "any"));
options.push_back (std::pair<std::string, std::string> (cfg_edit_combine_mode, "add"));
Expand Down
Loading

0 comments on commit 01c1904

Please sign in to comment.