From 7c0dd07d420b79722922918ec46a1adc54ca0a7b Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 4 Aug 2019 00:49:08 +0200 Subject: [PATCH] WIP: lib browser - cleanup and small bug fixes. --- src/db/db/dbLayoutToNetlist.cc | 2 +- src/db/db/dbLibrary.cc | 2 + src/db/db/dbNetlistCompare.cc | 3 - src/edt/edt/edtServiceImpl.cc | 30 +-- src/edt/edt/edtServiceImpl.h | 1 + src/laybasic/laybasic/layLayoutView.cc | 3 - src/laybasic/laybasic/layLibrariesView.cc | 227 +--------------------- src/laybasic/laybasic/layLibrariesView.h | 40 ---- 8 files changed, 25 insertions(+), 283 deletions(-) diff --git a/src/db/db/dbLayoutToNetlist.cc b/src/db/db/dbLayoutToNetlist.cc index 9138a3e4f..bb7399b35 100644 --- a/src/db/db/dbLayoutToNetlist.cc +++ b/src/db/db/dbLayoutToNetlist.cc @@ -208,7 +208,7 @@ size_t LayoutToNetlist::link_net_to_parent_circuit (const Net *subcircuit_net, C connected_clusters &parent_net_clusters = m_net_clusters.clusters_per_cell (parent_circuit->cell_index ()); - size_t id = parent_net_clusters.insert_dummy (); // @@@ + size_t id = parent_net_clusters.insert_dummy (); parent_net_clusters.add_connection (id, db::ClusterInstance (subcircuit_net->cluster_id (), subcircuit_net->circuit ()->cell_index (), trans, 0)); return id; diff --git a/src/db/db/dbLibrary.cc b/src/db/db/dbLibrary.cc index feb9160b0..71989274e 100644 --- a/src/db/db/dbLibrary.cc +++ b/src/db/db/dbLibrary.cc @@ -51,6 +51,7 @@ Library::register_proxy (db::LibraryProxy *lib_proxy, db::Layout *ly) { m_referrers.insert (std::make_pair (ly, 0)).first->second += 1; m_refcount.insert (std::make_pair (lib_proxy->library_cell_index (), 0)).first->second += 1; + retired_state_changed_event (); } void @@ -73,6 +74,7 @@ Library::unregister_proxy (db::LibraryProxy *lib_proxy, db::Layout *ly) layout ().delete_cell (ci); } } + retired_state_changed_event (); } } diff --git a/src/db/db/dbNetlistCompare.cc b/src/db/db/dbNetlistCompare.cc index c1ee28855..0af802934 100644 --- a/src/db/db/dbNetlistCompare.cc +++ b/src/db/db/dbNetlistCompare.cc @@ -3005,9 +3005,6 @@ NetlistComparer::do_device_assignment (const db::Circuit *c1, const db::NetGraph ++j; } - if (i - ii == size_t(2)) { - printf("@@@1\n"); fflush(stdout); - } align (ii, i, jj, j, DeviceConnectionDistance ()); for ( ; ii != i && jj != j; ++ii, ++jj) { diff --git a/src/edt/edt/edtServiceImpl.cc b/src/edt/edt/edtServiceImpl.cc index 4769ea96c..8de181dc9 100644 --- a/src/edt/edt/edtServiceImpl.cc +++ b/src/edt/edt/edtServiceImpl.cc @@ -1288,17 +1288,7 @@ InstService::drop_event (const db::DPoint & /*p*/, const lay::DragDropDataBase * do_cancel_edit (); } - // push the current setup to configuration so the instance dialog will take these as default - // and "apply" of these instance properties doesn't fail because of insistency. - plugin_root ()->config_set (cfg_edit_inst_lib_name, m_lib_name); - plugin_root ()->config_set (cfg_edit_inst_cell_name, m_cell_or_pcell_name); - if (m_is_pcell) { - plugin_root ()->config_set (cfg_edit_inst_pcell_parameters, pcell_parameters_to_string (m_pcell_parameters)); - } else { - plugin_root ()->config_set (cfg_edit_inst_pcell_parameters, std::string ()); - } - plugin_root ()->config_end (); - + sync_to_config (); return true; } else { @@ -1306,6 +1296,21 @@ InstService::drop_event (const db::DPoint & /*p*/, const lay::DragDropDataBase * } } +void +InstService::sync_to_config () +{ + // push the current setup to configuration so the instance dialog will take these as default + // and "apply" of these instance properties doesn't fail because of insistency. + plugin_root ()->config_set (cfg_edit_inst_lib_name, m_lib_name); + plugin_root ()->config_set (cfg_edit_inst_cell_name, m_cell_or_pcell_name); + if (m_is_pcell) { + plugin_root ()->config_set (cfg_edit_inst_pcell_parameters, pcell_parameters_to_string (m_pcell_parameters)); + } else { + plugin_root ()->config_set (cfg_edit_inst_pcell_parameters, std::string ()); + } + plugin_root ()->config_end (); +} + void InstService::do_begin_edit (const db::DPoint &p) { @@ -1679,8 +1684,7 @@ InstService::apply_edits() m_pcell_parameters = mp_pcell_decl->named_parameters (mp_pcell_parameters_dialog->get_parameters ()); } - m_has_valid_cell = false; - update_marker (); + sync_to_config (); } void diff --git a/src/edt/edt/edtServiceImpl.h b/src/edt/edt/edtServiceImpl.h index 024974fea..ca31dd672 100644 --- a/src/edt/edt/edtServiceImpl.h +++ b/src/edt/edt/edtServiceImpl.h @@ -250,6 +250,7 @@ private: bool get_inst (db::CellInstArray &inst); std::pair make_cell (const lay::CellView &cv); tl::Variant get_default_layer_for_pcell (); + void sync_to_config (); }; } diff --git a/src/laybasic/laybasic/layLayoutView.cc b/src/laybasic/laybasic/layLayoutView.cc index d91e38439..3930c678c 100644 --- a/src/laybasic/laybasic/layLayoutView.cc +++ b/src/laybasic/laybasic/layLayoutView.cc @@ -518,9 +518,6 @@ LayoutView::init (db::Manager *mgr, lay::PluginRoot *root, QWidget * /*parent*/) mp_libraries_view = new lay::LibrariesView (this, libraries_frame, "libs"); left_frame_ly->addWidget (mp_libraries_view, 1 /*stretch*/); -#if 0 // @@@ - connect (mp_libraries_view, SIGNAL (cell_selected (cell_path_type, int)), this, SLOT (select_cell_dispatch (cell_path_type, int))); -#endif connect (mp_libraries_view, SIGNAL (active_library_changed (int)), this, SLOT (active_library_changed (int))); } diff --git a/src/laybasic/laybasic/layLibrariesView.cc b/src/laybasic/laybasic/layLibrariesView.cc index 753483840..d0bc69894 100644 --- a/src/laybasic/laybasic/layLibrariesView.cc +++ b/src/laybasic/laybasic/layLibrariesView.cc @@ -204,29 +204,6 @@ LibrariesView::init_menu (lay::AbstractMenu &menu) // doesn't make sense for many libs MenuLayoutEntry ("split_mode", tl::to_string (QObject::tr ("Split Mode")), std::make_pair (cfg_split_lib_views, "?")), #endif -#if 0 // @@@ - MenuLayoutEntry::separator ("operations_group"), - MenuLayoutEntry ("new_cell:edit:edit_mode", tl::to_string (QObject::tr ("New Cell")), SLOT (cm_new_cell ())), - MenuLayoutEntry ("delete_cell:edit:edit_mode", tl::to_string (QObject::tr ("Delete Cell")), SLOT (cm_cell_delete ())), - MenuLayoutEntry ("rename_cell:edit:edit_mode", tl::to_string (QObject::tr ("Rename Cell")), SLOT (cm_cell_rename ())), - MenuLayoutEntry ("replace_cell:edit:edit_mode", tl::to_string (QObject::tr ("Replace Cell")), SLOT (cm_cell_replace ())), - MenuLayoutEntry ("flatten_cell:edit:edit_mode", tl::to_string (QObject::tr ("Flatten Cell")), SLOT (cm_cell_flatten ())), - MenuLayoutEntry ("cell_user_properties", tl::to_string (QObject::tr ("User Properties")), SLOT (cm_cell_user_properties ())), - MenuLayoutEntry::separator ("clipboard_group:edit_mode"), - MenuLayoutEntry ("copy:edit_mode", tl::to_string (QObject::tr ("Copy")), SLOT (cm_cell_copy ())), - MenuLayoutEntry ("cut:edit_mode", tl::to_string (QObject::tr ("Cut")), SLOT (cm_cell_cut ())), - MenuLayoutEntry ("paste:edit_mode", tl::to_string (QObject::tr ("Paste")), SLOT (cm_cell_paste ())), - MenuLayoutEntry::separator ("select_group"), - MenuLayoutEntry ("show_as_top", tl::to_string (QObject::tr ("Show As New Top")), SLOT (cm_cell_select ())), - MenuLayoutEntry::separator ("visibility_group"), - MenuLayoutEntry ("hide_cell", tl::to_string (QObject::tr ("Hide")), SLOT (cm_cell_hide ())), - MenuLayoutEntry ("show_cell", tl::to_string (QObject::tr ("Show")), SLOT (cm_cell_show ())), - MenuLayoutEntry ("show_all", tl::to_string (QObject::tr ("Show All")), SLOT (cm_cell_show_all ())), - MenuLayoutEntry::separator ("utils_group"), - MenuLayoutEntry ("open_current", tl::to_string (QObject::tr ("Where Am I?")), SLOT (cm_open_current_cell ())), - MenuLayoutEntry::separator ("file_group"), - MenuLayoutEntry ("save_cell_as:hide_vo", tl::to_string (QObject::tr ("Save Selected Cells As")), SLOT (cm_save_current_cell_as ())), - #endif MenuLayoutEntry::last () }; @@ -365,7 +342,6 @@ LibrariesView::context_menu (const QPoint &p) QTreeView *cell_list = dynamic_cast (sender ()); if (cell_list) { -// @@@ set_active_celltree_from_sender (); QMenu *ctx_menu = lay::AbstractMenuProvider::instance ()->menu ()->detached_menu ("lib_context_menu"); ctx_menu->exec (cell_list->mapToGlobal (p)); } @@ -395,16 +371,6 @@ LibrariesView::clear_all () mp_cell_lists.clear (); } -void -LibrariesView::cm_cell_select () -{ -#if 0 // @@@ - cell_path_type path; - current_cell (active (), path); - emit cell_selected (path, active ()); -#endif -} - void LibrariesView::search_triggered (const QString &t) { @@ -511,149 +477,27 @@ LibrariesView::search_editing_finished () void LibrariesView::middle_clicked (const QModelIndex &index) { -#if 0 // @@@ - BEGIN_PROTECTED - if (index.isValid ()) { - set_active_celltree_from_sender (); - cell_path_type path; - path_from_index (index, m_active_index, path); - emit cell_selected (path, active ()); - } - END_PROTECTED -#endif + // ... nothing yet .. } -#if 0 // @@@ -void -LibrariesView::path_from_index (const QModelIndex &index, int cv_index, cell_path_type &path) const -{ - // build the path to the cell given by the index - path.clear (); - - if (index.isValid ()) { - - CellTreeItem *item = (CellTreeItem *) index.internalPointer (); - - if (m_flat && cv_index >= 0 && cv_index < int (m_cellviews.size ()) && item) { - - // construct a path in the flat case - lay::CellView cv (m_cellviews [cv_index]); - cv.set_cell (item->cell_index ()); - path = cv.unspecific_path (); - - } else { - - while (item) { - path.push_back (item->cell_index ()); - item = item->parent (); - } - - if (! path.empty ()) { - std::reverse (path.begin (), path.end ()); - } - - } - - } -} - -void -LibrariesView::set_active_celltree_from_sender () -{ - for (int i = 0; i < int (mp_cell_lists.size ()); ++i) { - if (mp_cell_lists [i] == sender ()) { - select_active (i); - return; - } - if (mp_cell_list_headers [i] == sender ()) { - select_active (i); - return; - } - } -} -#endif // @@@ - void LibrariesView::header_clicked () { -#if 0 // @@@ - QToolButton *cb = dynamic_cast (sender ()); - if (cb) { - cb->setChecked (true); - set_active_celltree_from_sender (); - } -#endif + // ... nothing yet .. } void LibrariesView::clicked (const QModelIndex & /*index*/) { -#if 0 // @@@ - set_active_celltree_from_sender (); -#endif + // ... nothing yet .. } void LibrariesView::double_clicked (const QModelIndex &index) { -#if 0 // @@@ - BEGIN_PROTECTED - if (index.isValid ()) { - set_active_celltree_from_sender (); - mp_view->manager ()->transaction (tl::to_string (QObject::tr ("Show or hide cell"))); - CellTreeItem *item = (CellTreeItem *) index.internalPointer (); - if (mp_view->is_cell_hidden (item->cell_index (), m_active_index)) { - mp_view->show_cell (item->cell_index (), m_active_index); - } else { - mp_view->hide_cell (item->cell_index (), m_active_index); - } - mp_view->manager ()->commit (); - } - END_PROTECTED -#endif + // ... nothing yet .. } -#if 0 // @@@ -void -LibrariesView::set_current_cell (int cv_index, const cell_path_type &path) -{ - if (cv_index < 0 || cv_index >= int (mp_cell_lists.size ())) { - return; - } - - QModelIndex index = index_from_path (path, cv_index); - if (index.isValid ()) { - mp_cell_lists [cv_index]->scrollTo (index); - mp_cell_lists [cv_index]->clearSelection (); - mp_cell_lists [cv_index]->setCurrentIndex (index); - } -} -#endif - -#if 0 // @@@ -void -LibrariesView::selected_cells (int cv_index, std::vector &paths) const -{ - if (cv_index >= 0 && cv_index < int (mp_cell_lists.size ())) { - QModelIndexList sel = mp_cell_lists [cv_index]->selectionModel ()->selectedIndexes (); - for (QModelIndexList::const_iterator s = sel.begin (); s != sel.end (); ++s) { - paths.push_back (LibrariesView::cell_path_type ()); - path_from_index (*s, cv_index, paths.back ()); - } - } -} -#endif - -#if 0 // @@@ -void -LibrariesView::current_cell (int cv_index, LibrariesView::cell_path_type &path) const -{ - if (cv_index >= 0 && cv_index < int (mp_cell_lists.size ())) { - path_from_index (mp_cell_lists [cv_index]->currentIndex (), cv_index, path); - } -} -#endif - void LibrariesView::set_background_color (QColor c) { @@ -809,11 +653,9 @@ LibrariesView::do_update_content (int lib_index) cell_list->setContextMenuPolicy (Qt::CustomContextMenu); connect (cell_list, SIGNAL (customContextMenuRequested (const QPoint &)), this, SLOT (context_menu (const QPoint &))); -#if 0 // @@@ connect (cell_list, SIGNAL (cell_clicked (const QModelIndex &)), this, SLOT (clicked (const QModelIndex &))); connect (cell_list, SIGNAL (cell_double_clicked (const QModelIndex &)), this, SLOT (double_clicked (const QModelIndex &))); connect (cell_list, SIGNAL (cell_middle_clicked (const QModelIndex &)), this, SLOT (middle_clicked (const QModelIndex &))); -#endif connect (cell_list, SIGNAL (search_triggered (const QString &)), this, SLOT (search_triggered (const QString &))); mp_cell_lists.push_back (cell_list); @@ -945,67 +787,6 @@ LibrariesView::selection_changed (int index) } } -#if 0 // @@@ -QModelIndex -LibrariesView::index_from_path (const cell_path_type &path, int cv_index) -{ - if (cv_index >= 0 && cv_index < int (mp_cell_lists.size ()) && ! path.empty ()) { - - CellTreeModel *model = dynamic_cast (mp_cell_lists [cv_index]->model ()); - if (! model) { - return QModelIndex (); - } - - if (m_flat) { - - // TODO: linear search might not be effective enough .. - for (int c = 0; c < model->toplevel_items (); ++c) { - CellTreeItem *item = model->toplevel_item (c); - if (item->cell_index () == path.back ()) { - return model->model_index (item); - } - } - - } else { - - for (int c = 0; c < model->toplevel_items (); ++c) { - CellTreeItem *item = model->toplevel_item (c); - if (item->cell_index () == path.front ()) { - item = find_child_item (path.begin () + 1, path.end (), item); - if (item) { - return model->model_index (item); - } - } - } - - } - - } - - return QModelIndex (); -} - -CellTreeItem * -LibrariesView::find_child_item (cell_path_type::const_iterator start, cell_path_type::const_iterator end, CellTreeItem *p) -{ - if (start == end) { - return p; - } else { - - for (int n = 0; n < p->children (); ++n) { - CellTreeItem *item = p->child (n); - if (item && item->cell_index () == *start) { - return find_child_item (start + 1, end, item); - } - } - - // not found - return 0; - - } -} -#endif - std::string LibrariesView::display_string (int n) const { diff --git a/src/laybasic/laybasic/layLibrariesView.h b/src/laybasic/laybasic/layLibrariesView.h index ef51699b6..7960d7985 100644 --- a/src/laybasic/laybasic/layLibrariesView.h +++ b/src/laybasic/laybasic/layLibrariesView.h @@ -162,28 +162,6 @@ public: */ db::Library *active_lib (); -#if 0 // @@@ - /** - * @brief Returns the paths of the selected cells - */ - void selected_cells (int cv_index, std::vector &paths) const; - - /** - * @brief Return the path to the current cell for the given cellview index - * - * The current cell is the cell that is highlighted. - */ - void current_cell (int cv_index, cell_path_type &path) const; - - /** - * @brief Set the path to the current cell - * - * The current cell is the cell that is highlighted. The current cv index - * can be obtained with the "active" method. - */ - void set_current_cell (int cv_index, const cell_path_type &path); -#endif - /** * @brief Update the contents if necessary * @@ -239,9 +217,6 @@ public: } signals: -#if 0 // @@@ - void cell_selected (cell_path_type path, int cellview_index); -#endif void active_library_changed (int cellview_index); public slots: @@ -256,7 +231,6 @@ public slots: void search_editing_finished (); void search_next (); void search_prev (); - void cm_cell_select (); private: db::Layout *mp_layout; @@ -287,23 +261,9 @@ private: // event listener for changes in the cellview and layout void update_required (); -#if 0 // @@@ - // locate the CellTreeItem in the tree corresponding to a partial path starting from p. - CellTreeItem *find_child_item (cell_path_type::const_iterator start, cell_path_type::const_iterator end, CellTreeItem *p); -#endif - // get the current item CellTreeItem *current_item () const; -#if 0 // @@@ - // path from index and item from path .. - void path_from_index (const QModelIndex &index, int cv_index, cell_path_type &path) const; - QModelIndex index_from_path (const cell_path_type &path, int cv_index); - - // select active cellview from sender (sender must be a cell tree) - void set_active_celltree_from_sender (); -#endif - // clears all widgets of the cell lists void clear_all ();