From 4543eaabace3fc20442b222e3db9a1d27e2dff9d Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Mon, 5 Dec 2022 23:47:46 +0100 Subject: [PATCH] Fixed some small flaws in instance properties dialog: sort by cell name, update tree on apply --- src/edt/edt/edtInstPropertiesPage.cc | 69 +++++++++++++++++++------- src/layui/layui/layPropertiesDialog.cc | 8 +++ 2 files changed, 60 insertions(+), 17 deletions(-) diff --git a/src/edt/edt/edtInstPropertiesPage.cc b/src/edt/edt/edtInstPropertiesPage.cc index 96cb7530f..3e4f4df73 100644 --- a/src/edt/edt/edtInstPropertiesPage.cc +++ b/src/edt/edt/edtInstPropertiesPage.cc @@ -45,6 +45,53 @@ namespace edt { +// ------------------------------------------------------------------------- + +static std::string cell_name_from_sel (const edt::Service::obj_iterator &pos, edt::Service *service) +{ + if (! pos->is_cell_inst ()) { + return std::string (); + } + + const lay::CellView &cv = service->view ()->cellview (pos->cv_index ()); + + db::Layout *def_layout = &cv->layout (); + db::cell_index_type def_cell_index = pos->back ().inst_ptr.cell_index (); + std::pair dl = def_layout->defining_library (def_cell_index); + if (dl.first) { + def_layout = &dl.first->layout (); + def_cell_index = dl.second; + } + + std::pair pci = def_layout->is_pcell_instance (def_cell_index); + if (pci.first && def_layout->pcell_declaration (pci.second)) { + return def_layout->pcell_header (pci.second)->get_name (); + } else { + return def_layout->cell_name (def_cell_index); + } +} + +namespace { + +struct SelectionPtrSort +{ + SelectionPtrSort (edt::Service *service) + : mp_service (service) + { + // .. nothing yet .. + } + + bool operator() (const edt::Service::obj_iterator &a, const edt::Service::obj_iterator &b) + { + return cell_name_from_sel (a, mp_service) < cell_name_from_sel (b, mp_service); + } + +private: + edt::Service *mp_service; +}; + +} + // ------------------------------------------------------------------------- // InstPropertiesPage implementation @@ -61,6 +108,9 @@ InstPropertiesPage::InstPropertiesPage (edt::Service *service, db::Manager *mana for (edt::Service::obj_iterator s = service->selection ().begin (); s != service->selection ().end (); ++s) { m_selection_ptrs.push_back (s); } + + std::sort (m_selection_ptrs.begin (), m_selection_ptrs.end (), SelectionPtrSort (service)); + m_prop_id = 0; mp_service->clear_highlights (); @@ -249,9 +299,9 @@ InstPropertiesPage::select_entries (const std::vector &entries) std::string InstPropertiesPage::description (size_t entry) const { - std::string d; - edt::Service::obj_iterator pos = m_selection_ptrs [entry]; + std::string d = cell_name_from_sel (pos, mp_service); + if (! pos->is_cell_inst ()) { return d; } @@ -259,21 +309,6 @@ InstPropertiesPage::description (size_t entry) const const lay::CellView &cv = mp_service->view ()->cellview (pos->cv_index ()); double dbu = cv->layout ().dbu (); - db::Layout *def_layout = &cv->layout (); - db::cell_index_type def_cell_index = pos->back ().inst_ptr.cell_index (); - std::pair dl = def_layout->defining_library (def_cell_index); - if (dl.first) { - def_layout = &dl.first->layout (); - def_cell_index = dl.second; - } - - std::pair pci = def_layout->is_pcell_instance (def_cell_index); - if (pci.first && def_layout->pcell_declaration (pci.second)) { - d += def_layout->pcell_header (pci.second)->get_name (); - } else { - d += def_layout->cell_name (def_cell_index); - } - db::ICplxTrans t (pos->back ().inst_ptr.complex_trans ()); db::DCplxTrans dt = db::CplxTrans (dbu) * t * db::CplxTrans (dbu).inverted (); diff --git a/src/layui/layui/layPropertiesDialog.cc b/src/layui/layui/layPropertiesDialog.cc index 84b867137..49423c928 100644 --- a/src/layui/layui/layPropertiesDialog.cc +++ b/src/layui/layui/layPropertiesDialog.cc @@ -153,6 +153,11 @@ public: } } + void emit_data_changed () + { + emit dataChanged (index (0, 0, QModelIndex ()), index (rowCount (QModelIndex ()) - 1, columnCount (QModelIndex ()) - 1, QModelIndex ())); + } + private: PropertiesDialog *mp_dialog; int m_icon_width, m_icon_height; @@ -566,6 +571,9 @@ BEGIN_PROTECTED m_transaction_id = t.id (); } + // updates cell names in instances for example + mp_tree_model->emit_data_changed (); + END_PROTECTED }