Copying meta information of cells on various occasions too (e.g. clipboard copy & paste)

This commit is contained in:
Matthias Koefferlein 2023-04-29 23:27:42 +02:00
parent c8d97871fd
commit 707ebc4114
8 changed files with 55 additions and 8 deletions

View File

@ -356,7 +356,7 @@ CellMapping::do_create_missing_mapping (db::Layout &layout_a, const db::Layout &
&& (! exclude_cells || exclude_cells->find (*b) == exclude_cells->end ())
&& (! include_cells || include_cells->find (*b) != include_cells->end ())) {
db::cell_index_type new_cell = layout_a.add_cell (layout_b.cell_name (*b));
db::cell_index_type new_cell = layout_a.add_cell (layout_b, *b);
new_cells.push_back (new_cell);
new_cells_b.push_back (*b);

View File

@ -275,6 +275,7 @@ VariantsCollectorBase::separate_variants (db::Layout &layout, db::Cell &top_cell
var_name += "$VAR" + tl::to_string (index);
ci_var = layout.add_cell (var_name.c_str ());
layout.add_meta_info (ci_var, layout.begin_meta (*c), layout.end_meta (*c));
copy_shapes (layout, ci_var, *c);
// a new entry for the variant

View File

@ -556,7 +556,7 @@ make_clip_variants (const db::Layout &layout,
for (std::map <std::pair <db::cell_index_type, db::Box>, db::cell_index_type>::iterator v = variants.begin (); v != variants.end (); ++v) {
if (v->first.second != layout.cell (v->first.first).bbox () || &layout != &target_layout) {
// need for a new cell
v->second = target_layout.add_cell (layout.cell_name (v->first.first));
v->second = target_layout.add_cell (layout, v->first.first);
} else {
v->second = v->first.first;
}

View File

@ -201,7 +201,8 @@ ClipboardData::do_insert (db::Layout &layout, const db::ICplxTrans *trans, db::C
cell_map.insert (std::make_pair (c->cell_index (), pc->cell_index ()));
} else {
// fallback: create a new cell
cell_map.insert (std::make_pair (c->cell_index (), layout.add_cell (m_layout.cell_name (c->cell_index ()))));
db::cell_index_type ci = layout.add_cell (m_layout, c->cell_index ());
cell_map.insert (std::make_pair (c->cell_index (), ci));
}
} else {
@ -217,7 +218,8 @@ ClipboardData::do_insert (db::Layout &layout, const db::ICplxTrans *trans, db::C
cell_map.insert (std::make_pair (c->cell_index (), tc));
}
} else {
cell_map.insert (std::make_pair (c->cell_index (), layout.add_cell (m_layout.cell_name (c->cell_index ()))));
db::cell_index_type ci = layout.add_cell (m_layout, c->cell_index ());
cell_map.insert (std::make_pair (c->cell_index (), ci));
}
}
@ -313,7 +315,7 @@ ClipboardData::cell_for_cell (const db::Layout &layout, db::cell_index_type cell
return cm->second;
}
db::cell_index_type target_cell_index = m_layout.add_cell (layout.cell_name (cell_index));
db::cell_index_type target_cell_index = m_layout.add_cell (layout, cell_index);
m_cell_index_map.insert (std::make_pair (cell_index, target_cell_index));
if (incomplete) {

View File

@ -521,7 +521,13 @@ Layout::operator= (const Layout &d)
}
m_dbu = d.m_dbu;
m_meta_info = d.m_meta_info;
m_meta_info_by_cell = d.m_meta_info_by_cell;
m_meta_info_names = d.m_meta_info_names;
m_meta_info_name_map = d.m_meta_info_name_map;
m_tech_name = d.m_tech_name;
}
return *this;
@ -1297,7 +1303,15 @@ Layout::uniquify_cell_name (const char *name) const
}
}
cell_index_type
cell_index_type
Layout::add_cell (const db::Layout &other, db::cell_index_type ci)
{
cell_index_type ci_new = add_cell (other.cell_name (ci));
add_meta_info (ci_new, other.begin_meta (ci), other.end_meta (ci));
return ci_new;
}
cell_index_type
Layout::add_cell (const char *name)
{
std::string b;

View File

@ -761,6 +761,14 @@ public:
*/
cell_index_type add_cell (const char *name = 0);
/**
* @brief Adds a cell using another cell as a template
*
* This method will use the name of the other cell and initialize the
* new cell with the meta info from the other cell.
*/
cell_index_type add_cell (const db::Layout &other, db::cell_index_type ci);
/**
* @brief Add a cell without a name
*
@ -1904,6 +1912,17 @@ public:
*/
void add_meta_info (meta_info_name_id_type name_id, const MetaInfo &i);
/**
* @brief Adds meta information from a sequence
*/
template <class I>
void add_meta_info (const I &b, const I &e)
{
for (I i = b; i != e; ++i) {
m_meta_info.insert (b, e);
}
}
/**
* @brief Removes the meta information object with the given name
* The method will do nothing if no object with that name exists.
@ -1967,6 +1986,17 @@ public:
*/
void add_meta_info (db::cell_index_type ci, meta_info_name_id_type name_id, const MetaInfo &i);
/**
* @brief Adds meta information from a sequence
*/
template <class I>
void add_meta_info (db::cell_index_type ci, const I &b, const I &e)
{
for (I i = b; i != e; ++i) {
m_meta_info_by_cell [ci].insert (b, e);
}
}
/**
* @brief Gets a value indicating whether a meta info with the given name is present for the given cell
*/

View File

@ -218,7 +218,7 @@ merge_layouts (db::Layout &target,
std::map<db::cell_index_type, db::cell_index_type> new_cell_mapping;
for (std::set<db::cell_index_type>::const_iterator c = all_cells_to_copy.begin (); c != all_cells_to_copy.end (); ++c) {
if (cell_mapping.find (*c) == cell_mapping.end ()) {
new_cell_mapping.insert (std::make_pair (*c, target.add_cell (source.cell_name (*c))));
new_cell_mapping.insert (std::make_pair (*c, target.add_cell (source, *c)));
}
}

View File

@ -800,7 +800,7 @@ MainService::cm_make_cell_variants ()
if (needs_variant) {
// need to create a variant: create a new cell
db::cell_index_type new_cell_index = layout.add_cell (layout.cell_name (elem.inst_ptr.cell_index ()));
db::cell_index_type new_cell_index = layout.add_cell (layout, elem.inst_ptr.cell_index ());
// prepare a new variant cell
db::Cell &new_cell = layout.cell (new_cell_index);