From 707ebc4114b5beb0cc9a6058a49544c68c0400ef Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 29 Apr 2023 23:27:42 +0200 Subject: [PATCH] Copying meta information of cells on various occasions too (e.g. clipboard copy & paste) --- src/db/db/dbCellMapping.cc | 2 +- src/db/db/dbCellVariants.cc | 1 + src/db/db/dbClip.cc | 2 +- src/db/db/dbClipboardData.cc | 8 +++++--- src/db/db/dbLayout.cc | 16 +++++++++++++++- src/db/db/dbLayout.h | 30 ++++++++++++++++++++++++++++++ src/db/db/dbLayoutUtils.cc | 2 +- src/edt/edt/edtMainService.cc | 2 +- 8 files changed, 55 insertions(+), 8 deletions(-) diff --git a/src/db/db/dbCellMapping.cc b/src/db/db/dbCellMapping.cc index c4255f762..1cb4d698d 100644 --- a/src/db/db/dbCellMapping.cc +++ b/src/db/db/dbCellMapping.cc @@ -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); diff --git a/src/db/db/dbCellVariants.cc b/src/db/db/dbCellVariants.cc index 741dded37..a71d9eb52 100644 --- a/src/db/db/dbCellVariants.cc +++ b/src/db/db/dbCellVariants.cc @@ -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 diff --git a/src/db/db/dbClip.cc b/src/db/db/dbClip.cc index 72c926afc..d3d7bde90 100644 --- a/src/db/db/dbClip.cc +++ b/src/db/db/dbClip.cc @@ -556,7 +556,7 @@ make_clip_variants (const db::Layout &layout, for (std::map , 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; } diff --git a/src/db/db/dbClipboardData.cc b/src/db/db/dbClipboardData.cc index 36c515333..c8ade46af 100644 --- a/src/db/db/dbClipboardData.cc +++ b/src/db/db/dbClipboardData.cc @@ -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) { diff --git a/src/db/db/dbLayout.cc b/src/db/db/dbLayout.cc index 30b732167..b191d4126 100644 --- a/src/db/db/dbLayout.cc +++ b/src/db/db/dbLayout.cc @@ -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; diff --git a/src/db/db/dbLayout.h b/src/db/db/dbLayout.h index 73918fb5f..cb79d2a8a 100644 --- a/src/db/db/dbLayout.h +++ b/src/db/db/dbLayout.h @@ -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 + 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 + 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 */ diff --git a/src/db/db/dbLayoutUtils.cc b/src/db/db/dbLayoutUtils.cc index b22464d51..0e7faf14a 100644 --- a/src/db/db/dbLayoutUtils.cc +++ b/src/db/db/dbLayoutUtils.cc @@ -218,7 +218,7 @@ merge_layouts (db::Layout &target, std::map new_cell_mapping; for (std::set::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))); } } diff --git a/src/edt/edt/edtMainService.cc b/src/edt/edt/edtMainService.cc index ec1e8bdc5..b678b1b62 100644 --- a/src/edt/edt/edtMainService.cc +++ b/src/edt/edt/edtMainService.cc @@ -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);