MCPcopy Create free account
hub / github.com/KLayout/klayout / cellview

Method cellview

src/laybasic/laybasic/layDisplayState.cc:167–246  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

165}
166
167lay::CellView
168DisplayState::cellview (unsigned int index, lay::LayoutHandle *layout_h) const
169{
170 // try to restore the cell path
171 lay::CellView::unspecific_cell_path_type cell_path;
172
173 std::list<CellPath>::const_iterator cvi = m_paths.begin ();
174 for (unsigned int i = 0; i < index && cvi != m_paths.end (); ++i) {
175 ++cvi;
176 }
177
178 // create the cellview to return
179 lay::CellView cv;
180 cv.set (layout_h);
181
182 if (cvi != m_paths.end ()) {
183
184 // check, if we can reconstruct the path from the names
185 bool valid_path = false;
186
187 for (std::vector<std::string>::const_iterator cn = cvi->begin_path (); cn != cvi->end_path (); ++cn) {
188 std::pair<bool, db::cell_index_type> pci = layout_h->layout ().cell_by_name (cn->c_str ());
189 if (pci.first) {
190 cell_path.push_back (pci.second);
191 valid_path = true;
192 } else {
193 tl::warn << tl::to_string (tr ("Cellname cannot be reconstructed: ")) << *cn;
194 valid_path = false;
195 break;
196 }
197 }
198
199 // if available, take the path that was reconstructed
200 if (valid_path) {
201
202 cv.set_unspecific_path (cell_path);
203
204 tl_assert (! cell_path.empty ());
205 const db::Cell *pc = &layout_h->layout ().cell (cell_path.back ());
206
207 std::vector<db::InstElement> context_path;
208
209 // try further to extract the context path component
210 valid_path = false;
211 for (std::vector<SpecificInst>::const_iterator ci = cvi->begin_context_path (); ci != cvi->end_context_path (); ++ci) {
212 std::pair<bool, db::InstElement> ie = ci->to_inst_element (layout_h->layout (), *pc);
213 if (ie.first) {
214 context_path.push_back (ie.second);
215 pc = &layout_h->layout ().cell (ie.second.inst_ptr.cell_index ());
216 valid_path = true;
217 } else {
218 tl::warn << tl::to_string (tr ("Specific instance cannot be reconstructed: instantiated cell is ")) << ci->cell_name
219 << tl::to_string (tr (", parent cell is ")) << layout_h->layout ().cell_name (pc->cell_index ());
220 valid_path = false;
221 }
222 }
223
224 // if possible, establish the context path now

Callers 15

test_1Method · 0.80
test_1aMethod · 0.80
test_3Method · 0.80
test_2Method · 0.80
test_3Method · 0.80
test_9Method · 0.80
test_20Method · 0.80
test_1Method · 0.80
test_1aMethod · 0.80
test_3Method · 0.80
initializeMethod · 0.80
grayscale.rbFile · 0.80

Calls 15

set_unspecific_pathMethod · 0.80
to_inst_elementMethod · 0.80
set_specific_pathMethod · 0.80
to_stringFunction · 0.50
trFunction · 0.50
beginMethod · 0.45
endMethod · 0.45
setMethod · 0.45
cell_by_nameMethod · 0.45
layoutMethod · 0.45
c_strMethod · 0.45
push_backMethod · 0.45

Tested by 10

test_1Method · 0.64
test_1aMethod · 0.64
test_3Method · 0.64
test_2Method · 0.64
test_3Method · 0.64
test_9Method · 0.64
test_20Method · 0.64
test_1Method · 0.64
test_1aMethod · 0.64
test_3Method · 0.64