Added some more GSI methods:

* LayoutView#zoom_fit_sel
* ObjectInstPath#layout, ObjectInstPath#dtrans and ObjectInstPath#source_dtrans
This commit is contained in:
Matthias Koefferlein 2017-10-31 23:54:07 +01:00
parent 226f39c920
commit 5d9513b6a5
3 changed files with 89 additions and 4 deletions

View File

@ -53,6 +53,47 @@ static const db::InstElement &path_nth (const lay::ObjectInstPath *p, unsigned i
return *e; return *e;
} }
static db::Layout *layout_from_inst_path (const lay::ObjectInstPath *p)
{
db::Cell *cell = 0;
if (p->is_cell_inst ()) {
db::Instances *instances = p->back ().inst_ptr.instances ();
if (instances) {
cell = instances->cell ();
}
} else {
const db::Shapes *shapes = p->shape ().shapes ();
if (shapes) {
cell = shapes->cell ();
}
}
return cell ? cell->layout () : 0;
}
static db::DCplxTrans source_dtrans (const lay::ObjectInstPath *p)
{
const db::Layout *layout = layout_from_inst_path (p);
if (layout) {
double dbu = layout->dbu ();
return db::CplxTrans (dbu) * p->trans () * db::VCplxTrans (1.0 / dbu);
} else {
return db::DCplxTrans ();
}
}
static db::DCplxTrans dtrans (const lay::ObjectInstPath *p)
{
const db::Layout *layout = layout_from_inst_path (p);
if (layout) {
double dbu = layout->dbu ();
return db::CplxTrans (dbu) * p->trans_tot () * db::VCplxTrans (1.0 / dbu);
} else {
return db::DCplxTrans ();
}
}
gsi::Class<lay::ObjectInstPath> decl_ObjectInstPath ("ObjectInstPath", gsi::Class<lay::ObjectInstPath> decl_ObjectInstPath ("ObjectInstPath",
gsi::method ("<", &lay::ObjectInstPath::operator<, gsi::method ("<", &lay::ObjectInstPath::operator<,
"@brief Provides an order criterion for two ObjectInstPath objects\n" "@brief Provides an order criterion for two ObjectInstPath objects\n"
@ -108,6 +149,14 @@ gsi::Class<lay::ObjectInstPath> decl_ObjectInstPath ("ObjectInstPath",
"This property is set implicitly by setting the top cell and adding elements to the instantiation path.\n" "This property is set implicitly by setting the top cell and adding elements to the instantiation path.\n"
"To obtain the index of the container cell, use \\source.\n" "To obtain the index of the container cell, use \\source.\n"
) + ) +
gsi::method_ext ("layout", &layout_from_inst_path,
"@brief Gets the Layout object the selected object lives in.\n"
"\n"
"This method returns the \\Layout object that the selected object lives in. This method may return nil, if "
"the selection does not point to a valid object.\n"
"\n"
"This method has been introduced in version 0.25.\n"
) +
gsi::method ("source", &lay::ObjectInstPath::cell_index, gsi::method ("source", &lay::ObjectInstPath::cell_index,
"@brief Returns to the cell index of the cell that the selected element resides inside.\n" "@brief Returns to the cell index of the cell that the selected element resides inside.\n"
"\n" "\n"
@ -127,6 +176,20 @@ gsi::Class<lay::ObjectInstPath> decl_ObjectInstPath ("ObjectInstPath",
"This property is set implicitly by setting the top cell and adding elements to the instantiation path.\n" "This property is set implicitly by setting the top cell and adding elements to the instantiation path.\n"
"This method is not applicable for instance selections. A more generic attribute is \\source_trans.\n" "This method is not applicable for instance selections. A more generic attribute is \\source_trans.\n"
) + ) +
gsi::method_ext ("dtrans", &dtrans,
"@brief Gets the transformation applicable for the shape in micron space.\n"
"\n"
"This method returns the same transformation than \\trans, but applicable to objects in micrometer units:\n"
"\n"
"@code\n"
"# renders the micrometer-unit polygon in top cell coordinates:\n"
"dpolygon_in_top = sel.dtrans * sel.shape.dpolygon\n"
"@/code\n"
"\n"
"This method is not applicable to instance selections. A more generic attribute is \\source_dtrans.\n"
"\n"
"The method has been introduced in version 0.25.\n"
) +
gsi::method ("source_trans", &lay::ObjectInstPath::trans, gsi::method ("source_trans", &lay::ObjectInstPath::trans,
"@brief Gets the transformation applicable for an instance and shape.\n" "@brief Gets the transformation applicable for an instance and shape.\n"
"\n" "\n"
@ -139,6 +202,18 @@ gsi::Class<lay::ObjectInstPath> decl_ObjectInstPath ("ObjectInstPath",
"\n" "\n"
"This method has been added in version 0.16." "This method has been added in version 0.16."
) + ) +
gsi::method_ext ("source_dtrans", &source_dtrans,
"@brief Gets the transformation applicable for an instance and shape in micron space.\n"
"\n"
"This method returns the same transformation than \\source_trans, but applicable to objects in micrometer units:\n"
"\n"
"@code\n"
"# renders the cell instance as seen from top level:\n"
"dcell_inst_in_top = sel.source_dtrans * sel.inst.dcell_inst\n"
"@/code\n"
"\n"
"The method has been introduced in version 0.25.\n"
) +
gsi::method ("layer", &lay::ObjectInstPath::layer, gsi::method ("layer", &lay::ObjectInstPath::layer,
"@brief Gets the layer index that describes which layer the selected shape is on\n" "@brief Gets the layer index that describes which layer the selected shape is on\n"
"\n" "\n"

View File

@ -740,6 +740,11 @@ Class<lay::LayoutView> decl_LayoutView ("LayoutView",
gsi::method ("zoom_fit", &lay::LayoutView::zoom_fit, gsi::method ("zoom_fit", &lay::LayoutView::zoom_fit,
"@brief Fits the contents of the current view into the window" "@brief Fits the contents of the current view into the window"
) + ) +
gsi::method ("zoom_fit_sel", &lay::LayoutView::zoom_fit_sel,
"@brief Fits the contents of the current selection into the window\n"
"\n"
"This method has been introduced in version 0.25.\n"
) +
gsi::method ("zoom_box", &lay::LayoutView::zoom_box, gsi::method ("zoom_box", &lay::LayoutView::zoom_box,
"@brief Sets the viewport to the given box\n" "@brief Sets the viewport to the given box\n"
"\n" "\n"

View File

@ -158,6 +158,11 @@ class EDT_TestClass < TestBase
lv.each_object_selected { |o| sel << o } lv.each_object_selected { |o| sel << o }
assert_equal(sel.size, 1) assert_equal(sel.size, 1)
assert_equal(sel[0] == p2, true) assert_equal(sel[0] == p2, true)
assert_equal(sel[0].layout.object_id, ly.object_id)
assert_equal(sel[0].trans.to_s, "r0 *1 10,20")
assert_equal(sel[0].dtrans.to_s, "r0 *1 0.01,0.02")
assert_equal(sel[0].source_trans.to_s, "r0 *1 10,20")
assert_equal(sel[0].source_dtrans.to_s, "r0 *1 0.01,0.02")
# without a mouse pointer we can't test more than this: # without a mouse pointer we can't test more than this:
assert_equal(lv.has_transient_object_selection?, false) assert_equal(lv.has_transient_object_selection?, false)