From 8cbb49d5f9fb9249ba10b02abf4aa7935d342af9 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 1 May 2022 17:47:00 +0200 Subject: [PATCH] WIP --- src/edt/edt/edtInstPropertiesPage.cc | 26 ++--- src/edt/edt/edtPlugin.cc | 17 +-- src/edt/edt/edtPropertiesPages.cc | 10 +- src/lay/lay/layFillDialog.cc | 7 +- src/lay/lay/laySearchReplacePlugin.cc | 4 +- .../laybasic/layBrowseInstancesForm.cc | 20 ++-- src/laybasic/laybasic/layBrowseShapesForm.cc | 9 +- src/laybasic/laybasic/layLayerControlPanel.cc | 29 +---- src/laybasic/laybasic/layLayoutView.cc | 32 ++---- src/laybasic/laybasic/layLayoutView.h | 19 ++-- src/laybasic/laybasic/layLayoutViewBase.cc | 105 ++++++++++++++++-- src/laybasic/laybasic/layLayoutViewBase.h | 34 +++++- .../laybasic/layLayoutViewFunctions.cc | 2 +- .../laybasic/layNetlistBrowserDialog.cc | 13 +-- .../laybasic/rdbMarkerBrowserDialog.cc | 27 ++--- .../lay_plugin/layBooleanOperationsPlugin.cc | 4 +- .../tools/diff/lay_plugin/layDiffPlugin.cc | 4 +- .../lay_plugin/layNetTracerPlugin.cc | 4 +- .../tools/xor/lay_plugin/layXORPlugin.cc | 4 +- 19 files changed, 189 insertions(+), 181 deletions(-) diff --git a/src/edt/edt/edtInstPropertiesPage.cc b/src/edt/edt/edtInstPropertiesPage.cc index a4fe4ac54..51112874f 100644 --- a/src/edt/edt/edtInstPropertiesPage.cc +++ b/src/edt/edt/edtInstPropertiesPage.cc @@ -206,11 +206,8 @@ END_PROTECTED void InstPropertiesPage::show_props () { - lay::LayoutView *lv = dynamic_cast (mp_service->view ()); - tl_assert (lv != 0); - lay::UserPropertiesForm props_form (this); - if (props_form.show (lv, m_selection_ptrs [m_index]->cv_index (), m_prop_id)) { + if (props_form.show (mp_service->view ()->ui (), m_selection_ptrs [m_index]->cv_index (), m_prop_id)) { emit edited (); } } @@ -384,27 +381,21 @@ InstPropertiesPage::update () void InstPropertiesPage::show_cell () { - lay::LayoutView *lv = dynamic_cast (mp_service->view ()); - tl_assert (lv != 0); - edt::Service::obj_iterator pos = m_selection_ptrs [m_index]; - lay::CellView::unspecific_cell_path_type path (lv->cellview (pos->cv_index ()).combined_unspecific_path ()); + lay::CellView::unspecific_cell_path_type path (mp_service->view ()->cellview (pos->cv_index ()).combined_unspecific_path ()); for (lay::ObjectInstPath::iterator p = pos->begin (); p != pos->end (); ++p) { path.push_back (p->inst_ptr.cell_index ()); } - lv->set_current_cell_path (pos->cv_index (), path); + mp_service->view ()->set_current_cell_path (pos->cv_index (), path); } void InstPropertiesPage::show_inst () { - lay::LayoutView *lv = dynamic_cast (mp_service->view ()); - tl_assert (lv != 0); - InstantiationForm inst_form (this); - inst_form.show (lv, *m_selection_ptrs [m_index]); + inst_form.show (mp_service->view ()->ui (), *m_selection_ptrs [m_index]); } bool @@ -852,9 +843,6 @@ InstPropertiesPage::apply_to_all (bool relative) void InstPropertiesPage::update_pcell_parameters () { - lay::LayoutView *lv = dynamic_cast (mp_service->view ()); - tl_assert (lv != 0); - db::Layout *layout; // find the layout the cell has to be looked up: that is either the layout of the current instance or @@ -866,7 +854,7 @@ InstPropertiesPage::update_pcell_parameters () } else { edt::Service::obj_iterator pos = m_selection_ptrs [m_index]; - const lay::CellView &cv = lv->cellview (pos->cv_index ()); + const lay::CellView &cv = mp_service->view ()->cellview (pos->cv_index ()); layout = &cv->layout (); } @@ -890,7 +878,7 @@ InstPropertiesPage::update_pcell_parameters () std::vector parameters; edt::Service::obj_iterator pos = m_selection_ptrs [m_index]; - const lay::CellView &cv = lv->cellview (pos->cv_index ()); + const lay::CellView &cv = mp_service->view ()->cellview (pos->cv_index ()); db::Cell &cell = cv->layout ().cell (pos->cell_index ()); std::pair pci = cell.is_pcell_instance (pos->back ().inst_ptr); const db::Library *pci_lib = cv->layout ().defining_library (pos->back ().inst_ptr.cell_index ()).first; @@ -924,7 +912,7 @@ InstPropertiesPage::update_pcell_parameters () mp_pcell_parameters = new PCellParametersPage (pcell_tab); connect (mp_pcell_parameters, SIGNAL (edited ()), this, SIGNAL (edited ())); - mp_pcell_parameters->setup (lv, pos->cv_index (), layout->pcell_declaration (pc.second), parameters); + mp_pcell_parameters->setup (mp_service->view ()->ui (), pos->cv_index (), layout->pcell_declaration (pc.second), parameters); pcell_tab->layout ()->addWidget (mp_pcell_parameters); } diff --git a/src/edt/edt/edtPlugin.cc b/src/edt/edt/edtPlugin.cc index 518aaa140..a3cb410dc 100644 --- a/src/edt/edt/edtPlugin.cc +++ b/src/edt/edt/edtPlugin.cc @@ -181,12 +181,9 @@ public: virtual void get_editor_options_pages (std::vector &pages, lay::LayoutViewBase *view, lay::Dispatcher *root) const { - lay::LayoutView *lv = dynamic_cast (view); - tl_assert (lv != 0); - if (mp_pages_f != 0) { size_t nstart = pages.size (); - (*mp_pages_f) (pages, lv, root); + (*mp_pages_f) (pages, view->ui (), root); while (nstart < pages.size ()) { pages [nstart++]->set_plugin_declaration (this); } @@ -332,11 +329,8 @@ public: virtual void get_editor_options_pages (std::vector &pages, lay::LayoutViewBase *view, lay::Dispatcher *dispatcher) const { - lay::LayoutView *lv = dynamic_cast (view); - tl_assert (lv != 0); - // NOTE: we do not set plugin_declaration which makes the page unspecific - EditorOptionsGeneric *generic_opt = new EditorOptionsGeneric (lv, dispatcher); + EditorOptionsGeneric *generic_opt = new EditorOptionsGeneric (view->ui (), dispatcher); pages.push_back (generic_opt); } @@ -421,12 +415,7 @@ static tl::RegisteredClass config_decl_main (new edt::Ma void commit_recent (lay::LayoutViewBase *view) { - lay::LayoutView *lv = dynamic_cast (view); - if (!lv) { - return; - } - - lay::EditorOptionsPages *eo_pages = lv->editor_options_pages (); + lay::EditorOptionsPages *eo_pages = view->ui ()->editor_options_pages (); if (!eo_pages) { return; } diff --git a/src/edt/edt/edtPropertiesPages.cc b/src/edt/edt/edtPropertiesPages.cc index 21b3079c9..6f2232da4 100644 --- a/src/edt/edt/edtPropertiesPages.cc +++ b/src/edt/edt/edtPropertiesPages.cc @@ -360,21 +360,15 @@ ShapePropertiesPage::update_shape () void ShapePropertiesPage::show_inst () { - lay::LayoutView *lv = dynamic_cast (mp_service->view ()); - tl_assert (lv != 0); - InstantiationForm inst_form (this); - inst_form.show (lv, *m_selection_ptrs [m_index]); + inst_form.show (mp_service->view ()->ui (), *m_selection_ptrs [m_index]); } void ShapePropertiesPage::show_props () { - lay::LayoutView *lv = dynamic_cast (mp_service->view ()); - tl_assert (lv != 0); - lay::UserPropertiesForm props_form (this); - if (props_form.show (lv, m_selection_ptrs [m_index]->cv_index (), m_prop_id)) { + if (props_form.show (mp_service->view ()->ui (), m_selection_ptrs [m_index]->cv_index (), m_prop_id)) { emit edited (); } } diff --git a/src/lay/lay/layFillDialog.cc b/src/lay/lay/layFillDialog.cc index ec0e30fed..458c90afa 100644 --- a/src/lay/lay/layFillDialog.cc +++ b/src/lay/lay/layFillDialog.cc @@ -316,12 +316,7 @@ FillDialog::get_fill_parameters () } else if (layer_spec_cbx->currentIndex () == 2) { // get selected layers - std::vector s; - - lay::LayoutView *lv = dynamic_cast (mp_view); - if (lv) { - s = lv->selected_layers (); // @@@ should be part of LayoutViewBase too - } + std::vector s = mp_view->selected_layers (); for (std::vector::const_iterator l = s.begin (); l != s.end (); ++l) { if (! (*l)->has_children () && cv->layout ().is_valid_layer ((*l)->layer_index ())) { diff --git a/src/lay/lay/laySearchReplacePlugin.cc b/src/lay/lay/laySearchReplacePlugin.cc index cca26248a..94d53e141 100644 --- a/src/lay/lay/laySearchReplacePlugin.cc +++ b/src/lay/lay/laySearchReplacePlugin.cc @@ -65,9 +65,7 @@ public: virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutViewBase *view) const { - lay::LayoutView *lv = dynamic_cast (view); - tl_assert (lv != 0); - return new SearchReplaceDialog (root, lv); + return new SearchReplaceDialog (root, view->ui ()); } }; diff --git a/src/laybasic/laybasic/layBrowseInstancesForm.cc b/src/laybasic/laybasic/layBrowseInstancesForm.cc index 1d486a42e..cb2e96b01 100644 --- a/src/laybasic/laybasic/layBrowseInstancesForm.cc +++ b/src/laybasic/laybasic/layBrowseInstancesForm.cc @@ -349,12 +349,9 @@ void BrowseInstancesForm::choose_cell_pressed () { BEGIN_PROTECTED - lay::LayoutView *lv = dynamic_cast (view ()); - if (lv) { - CellSelectionForm form (this, lv, "browse_cell", true /*simple mode*/); - if (form.exec ()) { - change_cell (form.selected_cellview ().cell_index (), form.selected_cellview_index ()); - } + CellSelectionForm form (this, view ()->ui (), "browse_cell", true /*simple mode*/); + if (form.exec ()) { + change_cell (form.selected_cellview ().cell_index (), form.selected_cellview_index ()); } END_PROTECTED } @@ -525,21 +522,18 @@ struct BrowseInstancesCellInfo void BrowseInstancesForm::activated () { - lay::LayoutView *lv = dynamic_cast (view ()); - tl_assert (lv != 0); - - lv->save_view (m_display_state); + view ()->save_view (m_display_state); // if no cellviews are available, don't do anything - if (! lv->cellviews ()) { + if (! view ()->cellviews ()) { return; } // obtain active cellview index and cell index - int cv_index = lv->active_cellview_index (); + int cv_index = view ()->active_cellview_index (); lay::LayoutView::cell_path_type path; - lv->current_cell_path (path); + view ()->current_cell_path (path); // no cell to index if (path.empty ()) { diff --git a/src/laybasic/laybasic/layBrowseShapesForm.cc b/src/laybasic/laybasic/layBrowseShapesForm.cc index a31e6ff42..78db4af73 100644 --- a/src/laybasic/laybasic/layBrowseShapesForm.cc +++ b/src/laybasic/laybasic/layBrowseShapesForm.cc @@ -660,12 +660,9 @@ BrowseShapesForm::cell_inst_changed (QTreeWidgetItem *, QTreeWidgetItem *) void BrowseShapesForm::activated () { - lay::LayoutView *lv = dynamic_cast (view ()); - tl_assert (lv != 0); + view ()->save_view (m_display_state); - lv->save_view (m_display_state); - - std::vector sel_layers = lv->selected_layers (); + std::vector sel_layers = view ()->selected_layers (); if (sel_layers.empty ()) { throw tl::Exception (tl::to_string (QObject::tr ("No layer selected"))); @@ -691,7 +688,7 @@ BrowseShapesForm::activated () } } else { m_cv_index = cv_index; - m_cellview = lv->cellview (m_cv_index); + m_cellview = view ()->cellview (m_cv_index); } } diff --git a/src/laybasic/laybasic/layLayerControlPanel.cc b/src/laybasic/laybasic/layLayerControlPanel.cc index 931f5fd1c..1de876250 100644 --- a/src/laybasic/laybasic/layLayerControlPanel.cc +++ b/src/laybasic/laybasic/layLayerControlPanel.cc @@ -444,39 +444,12 @@ void LayerControlPanel::cm_remove_unused () { BEGIN_PROTECTED_CLEANUP - begin_updates (); - transaction (tl::to_string (QObject::tr ("Clean up views"))); - - bool any_deleted; - do { - - std::vector sel; - - lay::LayerPropertiesConstIterator l = mp_view->begin_layers (); - while (! l.at_end ()) { - if (! l->has_children () && l->bbox ().empty ()) { - sel.push_back (l); - } - ++l; - } - - std::sort (sel.begin (), sel.end (), CompareLayerIteratorBottomUp ()); - any_deleted = false; - for (std::vector::iterator s = sel.begin (); s != sel.end (); ++s) { - mp_view->delete_layer (*s); - any_deleted = true; - } - - } while (any_deleted); - + mp_view->remove_unused_layers (); commit (); - end_updates (); - emit order_changed (); - END_PROTECTED_CLEANUP { recover (); } } diff --git a/src/laybasic/laybasic/layLayoutView.cc b/src/laybasic/laybasic/layLayoutView.cc index 95408cdad..d9b0014d9 100644 --- a/src/laybasic/laybasic/layLayoutView.cc +++ b/src/laybasic/laybasic/layLayoutView.cc @@ -656,30 +656,6 @@ LayoutView::set_selected_layers (const std::vectorhas_selection ()) { - const lay::LayerPropertiesList &lp = get_properties (); - lay::LayerPropertiesConstIterator li = lp.begin_const_recursive (); - while (! li.at_end () && li->has_children ()) { - ++li; - } - if (! li.at_end ()) { - mp_control_panel->set_current_layer (li); - } - } -} - -void -LayoutView::remove_unused_layers () -{ - // @@@ should not be in control panel - if (mp_control_panel) { - mp_control_panel->cm_remove_unused (); - } -} - void LayoutView::begin_layer_updates () { @@ -688,6 +664,14 @@ LayoutView::begin_layer_updates () } } +void +LayoutView::end_layer_updates () +{ + if (mp_control_panel) { + mp_control_panel->end_updates (); + } +} + bool LayoutView::layer_model_updated () { diff --git a/src/laybasic/laybasic/layLayoutView.h b/src/laybasic/laybasic/layLayoutView.h index 7b06b183d..1594dfd08 100644 --- a/src/laybasic/laybasic/layLayoutView.h +++ b/src/laybasic/laybasic/layLayoutView.h @@ -273,11 +273,6 @@ public: */ virtual void set_current_cell_path (int cv_index, const cell_path_type &path); - /** - * @brief Remove unused layers - */ - void remove_unused_layers (); - /** * @brief Internal method: check, if the layer tree is and an consistent state. * @@ -416,6 +411,16 @@ public: return mp_editor_options_frame; } + /** + * @brief Gets the QWidget interface + */ + virtual QWidget *widget () { return this; } + + /** + * @brief Gets the LayoutView interface + */ + virtual LayoutView *ui () { return this; } + /** * @brief Copies to clipboard * @@ -740,7 +745,7 @@ protected: virtual void do_set_background_color (lay::Color color, lay::Color contrast); virtual void do_paste (); virtual void begin_layer_updates (); - virtual void ensure_layer_selected (); + virtual void end_layer_updates (); virtual void update_content_for_cv (int cv_index); virtual void do_set_no_stipples (bool no_stipples); virtual void do_set_phase (int phase); @@ -755,8 +760,6 @@ protected: virtual void emit_title_changed (); virtual void emit_dirty_changed (); virtual void emit_layer_order_changed (); - - virtual QWidget *widget () { return this; } }; } diff --git a/src/laybasic/laybasic/layLayoutViewBase.cc b/src/laybasic/laybasic/layLayoutViewBase.cc index 488402a1d..ab539b49f 100644 --- a/src/laybasic/laybasic/layLayoutViewBase.cc +++ b/src/laybasic/laybasic/layLayoutViewBase.cc @@ -1336,6 +1336,8 @@ LayoutViewBase::insert_layer_list (unsigned index, const LayerPropertiesList &pr manager ()->clear (); } + clear_layer_selection (); + m_layer_properties_lists.insert (m_layer_properties_lists.begin () + index, new LayerPropertiesList (props)); m_layer_properties_lists [index]->attach_view (this, index); merge_dither_pattern (*m_layer_properties_lists [index]); @@ -1363,6 +1365,8 @@ LayoutViewBase::delete_layer_list (unsigned index) manager ()->clear (); } + clear_layer_selection (); + delete m_layer_properties_lists [index]; m_layer_properties_lists.erase (m_layer_properties_lists.begin () + index); @@ -1425,20 +1429,44 @@ LayoutViewBase::set_current_layer (unsigned int cv_index, const db::LayerPropert return false; } +void +LayoutViewBase::clear_layer_selection () +{ + m_current_layer = lay::LayerPropertiesConstIterator (); + m_selected_layers.clear (); +} + void LayoutViewBase::set_current_layer (const lay::LayerPropertiesConstIterator &l) { - // @@@ No checking happens m_current_layer = l; + m_selected_layers.clear (); + m_selected_layers.push_back (l); } lay::LayerPropertiesConstIterator LayoutViewBase::current_layer () const { - // @@@ No checking happens return m_current_layer; } +std::vector +LayoutViewBase::selected_layers () const +{ + return m_selected_layers; +} + +void +LayoutViewBase::set_selected_layers (const std::vector &sel) +{ + m_selected_layers = sel; + if (sel.empty ()) { + m_current_layer = lay::LayerPropertiesConstIterator (); + } else { + m_current_layer = sel.front (); + } +} + void LayoutViewBase::merge_dither_pattern (lay::LayerPropertiesList &props) { @@ -1544,13 +1572,10 @@ LayoutViewBase::set_properties (unsigned int index, const LayerPropertiesList &p merge_dither_pattern (*m_layer_properties_lists [index]); if (index == current_layer_list ()) { - + end_layer_updates (); layer_list_changed_event (3); - redraw (); - m_prop_changed = true; - } } @@ -1607,14 +1632,11 @@ LayoutViewBase::replace_layer_node (unsigned int index, const LayerPropertiesCon non_const_iter->attach_view (this, index); if (index == current_layer_list ()) { - + end_layer_updates (); layer_list_changed_event (2); - // TODO: check, if redraw is actually necessary (this is complex!) redraw (); - m_prop_changed = true; - } } } @@ -1681,6 +1703,7 @@ LayoutViewBase::insert_layer (unsigned int index, const LayerPropertiesConstIter // signal to the observers that something has changed if (index == current_layer_list ()) { + end_layer_updates (); layer_list_changed_event (2); redraw (); m_prop_changed = true; @@ -1713,6 +1736,7 @@ LayoutViewBase::delete_layer (unsigned int index, LayerPropertiesConstIterator & // signal to the observers that something has changed if (index == current_layer_list ()) { + end_layer_updates (); layer_list_changed_event (2); redraw (); m_prop_changed = true; @@ -2088,6 +2112,8 @@ LayoutViewBase::erase_cellview (unsigned int index) m_display_states.clear (); m_display_state_ptr = 0; + end_layer_updates (); + // signal to the observers that something has changed layer_list_changed_event (3); @@ -3178,6 +3204,20 @@ LayoutViewBase::box () const return mp_canvas->viewport ().box (); } +#if defined(HAVE_QT) +QWidget * +LayoutViewBase::widget () +{ + tl_assert (false); +} +#endif + +LayoutView * +LayoutViewBase::ui () +{ + tl_assert (false); +} + // @@@ needs to be called "as often as possible" void LayoutViewBase::timer () @@ -4836,6 +4876,34 @@ LayoutViewBase::cut () lay::Editables::cut (); } +void +LayoutViewBase::remove_unused_layers () +{ + bool any_deleted; + do { + + std::vector sel; + + lay::LayerPropertiesConstIterator l = begin_layers (); + while (! l.at_end ()) { + if (! l->has_children () && l->bbox ().empty ()) { + sel.push_back (l); + } + ++l; + } + + std::sort (sel.begin (), sel.end (), CompareLayerIteratorBottomUp ()); + any_deleted = false; + for (std::vector::iterator s = sel.begin (); s != sel.end (); ++s) { + delete_layer (*s); + any_deleted = true; + } + + } while (any_deleted); + + emit_layer_order_changed (); +} + void LayoutViewBase::add_missing_layers () { @@ -4992,11 +5060,26 @@ LayoutViewBase::begin_layer_updates () } void -LayoutViewBase::ensure_layer_selected () +LayoutViewBase::end_layer_updates () { // .. nothing yet .. } +void +LayoutViewBase::ensure_layer_selected () +{ + if (current_layer () == lay::LayerPropertiesConstIterator ()) { + const lay::LayerPropertiesList &lp = get_properties (); + lay::LayerPropertiesConstIterator li = lp.begin_const_recursive (); + while (! li.at_end () && li->has_children ()) { + ++li; + } + if (! li.at_end ()) { + set_current_layer (li); + } + } +} + void LayoutViewBase::do_set_no_stipples (bool /*no_stipples*/) { diff --git a/src/laybasic/laybasic/layLayoutViewBase.h b/src/laybasic/laybasic/layLayoutViewBase.h index 50346e6a7..9b8d0d67c 100644 --- a/src/laybasic/laybasic/layLayoutViewBase.h +++ b/src/laybasic/laybasic/layLayoutViewBase.h @@ -70,6 +70,7 @@ namespace db { namespace lay { +class LayoutView; class MouseTracker; class ZoomService; class SelectionService; @@ -551,6 +552,18 @@ public: */ virtual lay::LayerPropertiesConstIterator current_layer () const; + /** + * @brief Return the layers that are selected in the layer browser + * + * Returns an empty list if no layer is selected. + */ + virtual std::vector selected_layers () const; + + /** + * @brief Sets the layers that are selected in the layer browser + */ + virtual void set_selected_layers (const std::vector &sel); + /** * @brief Set the custom dither pattern */ @@ -2168,6 +2181,11 @@ public: */ void add_missing_layers (); + /** + * @brief Remove unused layers + */ + void remove_unused_layers (); + /** * @brief Add layers which are not part of the LayerState */ @@ -2484,9 +2502,17 @@ public: virtual void deactivate_all_browsers (); #if defined(HAVE_QT) - virtual QWidget *widget () { return 0; } + /** + * @brief Gets the QWidget interface + */ + virtual QWidget *widget (); #endif + /** + * @brief Gets the LayoutView interface + */ + virtual LayoutView *ui (); + private: // event handlers used to connect to the layout object's events void signal_hier_changed (); @@ -2613,6 +2639,7 @@ private: std::set m_active_cellview_changed_events; lay::LayerPropertiesConstIterator m_current_layer; + std::vector m_selected_layers; std::vector m_current_cell_per_cellview; @@ -2676,7 +2703,8 @@ protected: virtual void do_set_background_color (lay::Color color, lay::Color contrast); virtual void do_paste (); virtual void begin_layer_updates (); - virtual void ensure_layer_selected (); + virtual void end_layer_updates (); + virtual void clear_layer_selection (); virtual void do_set_no_stipples (bool no_stipples); virtual void do_set_phase (int phase); virtual bool is_activated () const; @@ -2684,6 +2712,8 @@ protected: virtual void update_content_for_cv (int cv_index); virtual bool set_hier_levels_basic (std::pair l); + void ensure_layer_selected (); + void enable_active_cellview_changed_event (bool enable, bool silent = false); void active_cellview_changed (int index); diff --git a/src/laybasic/laybasic/layLayoutViewFunctions.cc b/src/laybasic/laybasic/layLayoutViewFunctions.cc index 65188d4de..724e8c137 100644 --- a/src/laybasic/laybasic/layLayoutViewFunctions.cc +++ b/src/laybasic/laybasic/layLayoutViewFunctions.cc @@ -78,7 +78,7 @@ validate_cell_path (const db::Layout &layout, lay::LayoutView::cell_path_type &p } LayoutViewFunctions::LayoutViewFunctions (db::Manager *manager, LayoutViewBase *view) - : lay::Plugin (view), mp_view (dynamic_cast (view)), mp_manager (manager) + : lay::Plugin (view), mp_view (view->ui ()), mp_manager (manager) { m_del_cell_mode = 0; m_move_to_origin_mode_x = 0; diff --git a/src/laybasic/laybasic/layNetlistBrowserDialog.cc b/src/laybasic/laybasic/layNetlistBrowserDialog.cc index b294befc6..577865a3b 100644 --- a/src/laybasic/laybasic/layNetlistBrowserDialog.cc +++ b/src/laybasic/laybasic/layNetlistBrowserDialog.cc @@ -729,22 +729,19 @@ NetlistBrowserDialog::cv_index_changed (int index) void NetlistBrowserDialog::activated () { - lay::LayoutView *lv = dynamic_cast (view ()); - tl_assert (lv != 0); - std::string state; - lv->config_get (cfg_l2ndb_window_state, state); + view ()->config_get (cfg_l2ndb_window_state, state); lay::restore_dialog_state (this, state, false /*don't adjust the section sizes*/); // Switch to the active cellview index when no valid one is set. - lay::CellView cv = lv->cellview (m_cv_index); + lay::CellView cv = view ()->cellview (m_cv_index); if (! cv.is_valid ()) { - m_cv_index = lv->active_cellview_index (); + m_cv_index = view ()->active_cellview_index (); } - if (m_l2n_index < 0 && lv->get_l2ndb (0) != 0) { + if (m_l2n_index < 0 && view ()->get_l2ndb (0) != 0) { - m_l2ndb_name = lv->get_l2ndb (0)->name (); + m_l2ndb_name = view ()->get_l2ndb (0)->name (); l2ndbs_changed (); } else { diff --git a/src/laybasic/laybasic/rdbMarkerBrowserDialog.cc b/src/laybasic/laybasic/rdbMarkerBrowserDialog.cc index a7caa9026..51b93ae88 100644 --- a/src/laybasic/laybasic/rdbMarkerBrowserDialog.cc +++ b/src/laybasic/laybasic/rdbMarkerBrowserDialog.cc @@ -635,22 +635,19 @@ MarkerBrowserDialog::cv_index_changed (int index) void MarkerBrowserDialog::activated () { - lay::LayoutView *lv = dynamic_cast (view ()); - tl_assert (lv != 0); - std::string state; - lv->config_get (cfg_rdb_window_state, state); + view ()->config_get (cfg_rdb_window_state, state); lay::restore_dialog_state (this, state); // Switch to the active cellview index when no valid one is set. - lay::CellView cv = lv->cellview (m_cv_index); + lay::CellView cv = view ()->cellview (m_cv_index); if (! cv.is_valid ()) { - m_cv_index = lv->active_cellview_index (); + m_cv_index = view ()->active_cellview_index (); } - if (m_rdb_index < 0 && lv->get_rdb (0) != 0) { + if (m_rdb_index < 0 && view ()->get_rdb (0) != 0) { - m_rdb_name = lv->get_rdb (0)->name (); + m_rdb_name = view ()->get_rdb (0)->name (); rdbs_changed (); } else { @@ -717,10 +714,7 @@ MarkerBrowserDialog::deactivated () void MarkerBrowserDialog::scan_layer () { - lay::LayoutView *lv = dynamic_cast (view ()); - tl_assert (lv != 0); - - std::vector layers = lv->selected_layers (); + std::vector layers = view ()->selected_layers (); if (layers.empty ()) { throw tl::Exception (tl::to_string (QObject::tr ("No layer selected to get shapes from"))); } @@ -812,16 +806,13 @@ MarkerBrowserDialog::scan_layer () } unsigned int rdb_index = view ()->add_rdb (rdb.release ()); - lv->open_rdb_browser (rdb_index, cv_index); + view ()->ui ()->open_rdb_browser (rdb_index, cv_index); } void MarkerBrowserDialog::scan_layer_flat () { - lay::LayoutView *lv = dynamic_cast (view ()); - tl_assert (lv != 0); - - std::vector layers = lv->selected_layers (); + std::vector layers = view ()->selected_layers (); if (layers.empty ()) { throw tl::Exception (tl::to_string (QObject::tr ("No layer selected to get shapes from"))); } @@ -891,7 +882,7 @@ MarkerBrowserDialog::scan_layer_flat () } unsigned int rdb_index = view ()->add_rdb (rdb.release ()); - lv->open_rdb_browser (rdb_index, cv_index); + view ()->ui ()->open_rdb_browser (rdb_index, cv_index); } void diff --git a/src/plugins/tools/bool/lay_plugin/layBooleanOperationsPlugin.cc b/src/plugins/tools/bool/lay_plugin/layBooleanOperationsPlugin.cc index 892c78351..af7c219bd 100644 --- a/src/plugins/tools/bool/lay_plugin/layBooleanOperationsPlugin.cc +++ b/src/plugins/tools/bool/lay_plugin/layBooleanOperationsPlugin.cc @@ -496,9 +496,7 @@ public: lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutViewBase *view) const { - lay::LayoutView *lv = dynamic_cast (view); - tl_assert (lv != 0); - return new BooleanOperationsPlugin (root, lv); + return new BooleanOperationsPlugin (root, view->ui ()); } }; diff --git a/src/plugins/tools/diff/lay_plugin/layDiffPlugin.cc b/src/plugins/tools/diff/lay_plugin/layDiffPlugin.cc index b44dfa780..8486c8155 100644 --- a/src/plugins/tools/diff/lay_plugin/layDiffPlugin.cc +++ b/src/plugins/tools/diff/lay_plugin/layDiffPlugin.cc @@ -105,9 +105,7 @@ public: lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutViewBase *view) const { - lay::LayoutView *lv = dynamic_cast (view); - tl_assert (lv != 0); - return new DiffPlugin (root, lv); + return new DiffPlugin (root, view->ui ()); } }; diff --git a/src/plugins/tools/net_tracer/lay_plugin/layNetTracerPlugin.cc b/src/plugins/tools/net_tracer/lay_plugin/layNetTracerPlugin.cc index 409e0a71e..27400f4dd 100644 --- a/src/plugins/tools/net_tracer/lay_plugin/layNetTracerPlugin.cc +++ b/src/plugins/tools/net_tracer/lay_plugin/layNetTracerPlugin.cc @@ -78,9 +78,7 @@ public: virtual lay::Plugin *create_plugin (db::Manager * /*manager*/, lay::Dispatcher *root, lay::LayoutViewBase *view) const { - lay::LayoutView *lv = dynamic_cast (view); - tl_assert (lv != 0); - return new NetTracerDialog (root, lv); + return new NetTracerDialog (root, view->ui ()); } }; diff --git a/src/plugins/tools/xor/lay_plugin/layXORPlugin.cc b/src/plugins/tools/xor/lay_plugin/layXORPlugin.cc index 14864a9d9..262969a59 100644 --- a/src/plugins/tools/xor/lay_plugin/layXORPlugin.cc +++ b/src/plugins/tools/xor/lay_plugin/layXORPlugin.cc @@ -113,9 +113,7 @@ public: lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutViewBase *view) const { - lay::LayoutView *lv = dynamic_cast (view); - tl_assert (lv != 0); - return new XORPlugin (root, lv); + return new XORPlugin (root, view->ui ()); } };