From f6a6acd20ee2ae9312ad1a0c05d0eaf1bb573953 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Tue, 4 Feb 2020 00:33:07 +0100 Subject: [PATCH 01/32] WIP: new LayoutView features for pya/RBA. --- src/laybasic/laybasic/gsiDeclLayLayoutView.cc | 123 +++++++++++++++++- src/laybasic/laybasic/layLayoutView.cc | 22 ++++ src/laybasic/laybasic/layLayoutView.h | 1 + 3 files changed, 143 insertions(+), 3 deletions(-) diff --git a/src/laybasic/laybasic/gsiDeclLayLayoutView.cc b/src/laybasic/laybasic/gsiDeclLayLayoutView.cc index 5ac536d89..f0fab85b2 100644 --- a/src/laybasic/laybasic/gsiDeclLayLayoutView.cc +++ b/src/laybasic/laybasic/gsiDeclLayLayoutView.cc @@ -402,20 +402,137 @@ static LayerPropertiesConstIteratorWrapper each_layer2 (lay::LayoutView *view, u return LayerPropertiesConstIteratorWrapper (view->begin_layers (list_index)); } -static lay::LayoutView *new_view () +static lay::LayoutView *new_view (QWidget *parent, bool editable, db::Manager *manager, unsigned int options) { - return new lay::LayoutView (0, false, 0); + lay::LayoutView *lv = new lay::LayoutView (manager, editable, 0 /*plugin parent*/, parent, "view", options); + if (parent) { + // transfer ownership to the parent + lv->keep (); + } + return lv; } Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "LayoutView", - gsi::constructor ("new", &new_view, + gsi::constructor ("new", &new_view, gsi::arg ("parent", (QWidget *) 0), gsi::arg ("editable", false), gsi::arg ("manager", (db::Manager *) 0), gsi::arg ("options", (unsigned int) 0), "@brief Creates a standalone view\n" "\n" "This constructor is for special purposes only. To create a view in the context of a main window, " "use \\MainWindow#create_view and related methods.\n" "\n" + "@param parent The parent widget in which to embed the view\n" + "@param editable True to make the view editable\n" + "@param manager The \\Manager object to enable undo/redo\n" + "@param options A combination of the values in the LV_... constants\n" + "\n" "This constructor has been introduced in version 0.25.\n" + "It has been enhanced with the arguments in version 0.26.4.\n" ) + + gsi::constant ("LV_NoLayers", (unsigned int) laybasic::LayoutView::LV_NoLayers, + "@brief With this option, no layers view will be provided (see \\layer_control_frame)\n" + "Use this value with the constructor's 'options' argument.\n" + "\n" + "This constant has been introduced in version 0.26.4.\n" + ) + + gsi::constant ("LV_NoHierarchyPanel", (unsigned int) laybasic::LayoutView::LV_NoHierarchyPanel, + "@brief With this option, no cell hierarchy view will be provided (see \\hierarchy_control_frame)\n" + "Use this value with the constructor's 'options' argument.\n" + "\n" + "This constant has been introduced in version 0.26.4.\n" + ) + + gsi::constant ("LV_NoLibrariesView", (unsigned int) laybasic::LayoutView::LV_NoLibrariesView, + "@brief With this option, no library view will be provided (see \\libraries_frame)\n" + "Use this value with the constructor's 'options' argument.\n" + "\n" + "This constant has been introduced in version 0.26.4.\n" + ) + + gsi::constant ("LV_NoBookmarksView", (unsigned int) laybasic::LayoutView::LV_NoBookmarksView, + "@brief With this option, no bookmarks view will be provided (see \\bookmarks_frame)\n" + "Use this value with the constructor's 'options' argument.\n" + "\n" + "This constant has been introduced in version 0.26.4.\n" + ) + + gsi::constant ("LV_Naked", (unsigned int) laybasic::LayoutView::LV_Naked, + "@brief With this option, no separate views will be provided\n" + "Use this value with the constructor's 'options' argument.\n" + "This option is basically equivalent to using \\LV_NoLayers+\\LV_NoHierarchyPanel+\\LV_NoLibrariesView+\\LV_NoBookmarksView\n" + "\n" + "This constant has been introduced in version 0.26.4.\n" + ) + + gsi::constant ("LV_NoZoom", (unsigned int) laybasic::LayoutView::LV_NoZoom, + "@brief With this option, zooming is disabled\n" + "Use this value with the constructor's 'options' argument.\n" + "\n" + "This constant has been introduced in version 0.26.4.\n" + ) + + gsi::constant ("LV_NoGrid", (unsigned int) laybasic::LayoutView::LV_NoGrid, + "@brief With this option, the grid background is not shown\n" + "Use this value with the constructor's 'options' argument.\n" + "\n" + "This constant has been introduced in version 0.26.4.\n" + ) + + gsi::constant ("LV_NoMove", (unsigned int) laybasic::LayoutView::LV_NoMove, + "@brief With this option, move operations are not supported\n" + "Use this value with the constructor's 'options' argument.\n" + "\n" + "This constant has been introduced in version 0.26.4.\n" + ) + + gsi::constant ("LV_NoTracker", (unsigned int) laybasic::LayoutView::LV_NoTracker, + "@brief With this option, mouse position tracking is not supported\n" + "Use this value with the constructor's 'options' argument.\n" + "This option is not useful currently as no mouse tracking support is provided.\n" + "\n" + "This constant has been introduced in version 0.26.4.\n" + ) + + gsi::constant ("LV_NoSelection", (unsigned int) laybasic::LayoutView::LV_NoSelection, + "@brief With this option, objects cannot be selected\n" + "Use this value with the constructor's 'options' argument.\n" + "\n" + "This constant has been introduced in version 0.26.4.\n" + ) + + gsi::constant ("LV_NoPlugins", (unsigned int) laybasic::LayoutView::LV_NoPlugins, + "@brief With this option, all plugins are disabled\n" + "Use this value with the constructor's 'options' argument.\n" + "\n" + "This constant has been introduced in version 0.26.4.\n" + ) + + gsi::constant ("LV_NoServices", (unsigned int) laybasic::LayoutView::LV_NoServices, + "@brief This option disables all services except the ones for pure viewing\n" + "Use this value with the constructor's 'options' argument.\n" + "With this option, all manipulation features are disabled, except zooming.\n" + "It is equivalent to \\LV_NoMove + \\LV_NoTracker + \\LV_NoSelection + \\LV_NoPlugins.\n" + "\n" + "This constant has been introduced in version 0.26.4.\n" + ) + +#if defined(HAVE_QTBINDINGS) + gsi::method ("layer_control_frame", &lay::LayoutView::layer_control_frame, + "@brief Gets the layer control side widget\n" + "A 'side widget' is a widget attached to the view. It does not have a parent, so you can " + "embed it into a different context. Please note that with embedding through 'setParent' it will be " + "destroyed when your parent widget gets destroyed. It will be lost then to the view.\n" + "\n" + "The side widget can be configured through the views configuration interface.\n" + "\n" + "This method has been introduced in version 0.26.4\n" + ) + + gsi::method ("hierarchy_control_frame", &lay::LayoutView::hierarchy_control_frame, + "@brief Gets the cell view (hierarchy view) side widget\n" + "For details about side widgets see \\layer_control_frame.\n" + "\n" + "This method has been introduced in version 0.26.4\n" + ) + + gsi::method ("libraries_frame", &lay::LayoutView::libraries_frame, + "@brief Gets the library view side widget\n" + "For details about side widgets see \\layer_control_frame.\n" + "\n" + "This method has been introduced in version 0.26.4\n" + ) + + gsi::method ("bookmarks_frame", &lay::LayoutView::bookmarks_frame, + "@brief Gets the bookmarks side widget\n" + "For details about side widgets see \\layer_control_frame.\n" + "\n" + "This method has been introduced in version 0.26.4\n" + ) + +#endif gsi::method ("current", &lay::LayoutView::current, "@brief Returns the current view\n" "The current view is the one that is shown in the current tab. Returns nil if no layout is loaded.\n" diff --git a/src/laybasic/laybasic/layLayoutView.cc b/src/laybasic/laybasic/layLayoutView.cc index eda3aa1d4..c3c419ff2 100644 --- a/src/laybasic/laybasic/layLayoutView.cc +++ b/src/laybasic/laybasic/layLayoutView.cc @@ -477,6 +477,7 @@ LayoutView::init (db::Manager *mgr, lay::PluginRoot *root, QWidget * /*parent*/) connect (mp_hierarchy_panel, SIGNAL (cell_selected (cell_path_type, int)), this, SLOT (select_cell_dispatch (cell_path_type, int))); connect (mp_hierarchy_panel, SIGNAL (active_cellview_changed (int)), this, SLOT (active_cellview_changed (int))); + connect (mp_hierarchy_frame, SIGNAL (destroyed ()), this, SLOT (side_panel_destroyed ())); QFrame *levels_frame = new QFrame (hierarchy_frame); levels_frame->setObjectName (QString::fromUtf8 ("lvl_frame")); @@ -521,6 +522,8 @@ LayoutView::init (db::Manager *mgr, lay::PluginRoot *root, QWidget * /*parent*/) mp_bookmarks_view = new lay::BookmarksView (this, bookmarks_frame, "bookmarks"); left_frame_ly->addWidget (mp_bookmarks_view, 1 /*stretch*/); + connect (mp_bookmarks_frame, SIGNAL (destroyed ()), this, SLOT (side_panel_destroyed ())); + } if ((m_options & LV_NoLibrariesView) == 0 && (m_options & LV_Naked) == 0) { @@ -536,6 +539,7 @@ LayoutView::init (db::Manager *mgr, lay::PluginRoot *root, QWidget * /*parent*/) left_frame_ly->addWidget (mp_libraries_view, 1 /*stretch*/); connect (mp_libraries_view, SIGNAL (active_library_changed (int)), this, SLOT (active_library_changed (int))); + connect (mp_libraries_frame, SIGNAL (destroyed ()), this, SLOT (side_panel_destroyed ())); } @@ -559,6 +563,7 @@ LayoutView::init (db::Manager *mgr, lay::PluginRoot *root, QWidget * /*parent*/) mp_control_panel = new lay::LayerControlPanel (this, manager (), 0, "lcp"); mp_control_frame = mp_control_panel; + connect (mp_control_frame, SIGNAL (destroyed ()), this, SLOT (side_panel_destroyed ())); connect (mp_control_panel, SIGNAL (tab_changed ()), this, SLOT (layer_tab_changed ())); connect (mp_control_panel, SIGNAL (order_changed ()), this, SLOT (layer_order_changed ())); /* @@ -679,6 +684,23 @@ LayoutView::~LayoutView () mp_bookmarks_view = 0; } +void LayoutView::side_panel_destroyed () +{ + if (sender () == mp_control_frame) { + mp_control_frame = 0; + mp_control_panel = 0; + } else if (sender () == mp_hierarchy_frame) { + mp_hierarchy_frame = 0; + mp_hierarchy_panel = 0; + } else if (sender () == mp_libraries_frame) { + mp_libraries_frame = 0; + mp_libraries_view = 0; + } else if (sender () == mp_bookmarks_frame) { + mp_bookmarks_frame = 0; + mp_bookmarks_view = 0; + } +} + void LayoutView::hideEvent (QHideEvent *) { hide_event (); diff --git a/src/laybasic/laybasic/layLayoutView.h b/src/laybasic/laybasic/layLayoutView.h index 172d1bc46..feab2526a 100644 --- a/src/laybasic/laybasic/layLayoutView.h +++ b/src/laybasic/laybasic/layLayoutView.h @@ -2685,6 +2685,7 @@ private slots: void active_cellview_changed (int index); void active_library_changed (int index); void goto_bookmark (); + void side_panel_destroyed (); signals: /** From 0f69c24e7905caf58415c1c015ca125c24f7c2db Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Tue, 4 Feb 2020 20:50:46 +0100 Subject: [PATCH 02/32] WIP: avoids a segfault because of missing manager --- src/db/db/dbManager.cc | 11 +- src/db/db/dbManager.h | 11 +- src/db/db/dbObject.h | 20 +++ src/db/db/dbStatic.h | 19 --- src/db/unit_tests/dbCell.cc | 16 +- src/db/unit_tests/dbCellGraphUtils.cc | 2 +- src/db/unit_tests/dbCellHullGenerator.cc | 4 +- src/db/unit_tests/dbEdgeProcessor.cc | 2 +- src/db/unit_tests/dbLibraries.cc | 6 +- src/db/unit_tests/dbObject.cc | 8 +- src/db/unit_tests/dbPCells.cc | 4 +- .../dbRecursiveShapeIteratorTests.cc | 16 +- src/db/unit_tests/dbShape.cc | 28 ++-- src/db/unit_tests/dbShapeRepository.cc | 2 +- src/db/unit_tests/dbShapes.cc | 68 ++++---- src/lay/lay/layApplication.cc | 3 +- src/lay/lay/layMainWindow.cc | 5 +- src/lay/lay/layMainWindow.h | 2 +- src/laybasic/laybasic/gsiDeclLayLayoutView.cc | 24 +-- .../laybasic/layEditLineStylesForm.cc | 2 +- src/laybasic/laybasic/layEditStipplesForm.cc | 2 +- .../laybasic/layHierarchyControlPanel.cc | 8 +- src/laybasic/laybasic/layLayerControlPanel.cc | 148 +++++++++--------- src/laybasic/laybasic/layLayoutView.cc | 4 +- .../laybasic/layLayoutViewConfigPages.cc | 6 +- .../unit_tests/layAnnotationShapes.cc | 14 +- src/laybasic/unit_tests/layLayerProperties.cc | 12 +- src/laybasic/unit_tests/laySnap.cc | 2 +- .../streamers/cif/unit_tests/dbCIFReader.cc | 2 +- .../streamers/gds2/unit_tests/dbGDS2Reader.cc | 8 +- .../streamers/gds2/unit_tests/dbGDS2Writer.cc | 32 ++-- .../lefdef/unit_tests/dbLEFDEFImport.cc | 2 +- .../streamers/magic/unit_tests/dbMAGReader.cc | 2 +- .../oasis/unit_tests/dbOASISReader.cc | 12 +- .../oasis/unit_tests/dbOASISWriter.cc | 38 ++--- .../oasis/unit_tests/dbOASISWriter2.cc | 2 +- .../lay_plugin/layBooleanOperationsPlugin.cc | 6 +- .../net_tracer/unit_tests/dbNetTracer.cc | 4 +- .../net_tracer/unit_tests/dbTraceAllNets.cc | 2 +- 39 files changed, 286 insertions(+), 273 deletions(-) diff --git a/src/db/db/dbManager.cc b/src/db/db/dbManager.cc index a44fc1195..405c0f45b 100644 --- a/src/db/db/dbManager.cc +++ b/src/db/db/dbManager.cc @@ -33,10 +33,11 @@ namespace db { -Manager::Manager () +Manager::Manager (bool enabled) : m_transactions (), m_current (m_transactions.begin ()), - m_opened (false), m_replay (false) + m_opened (false), m_replay (false), + m_enabled (enabled) { // .. nothing yet .. } @@ -110,7 +111,7 @@ Manager::erase_transactions (transactions_t::iterator from, transactions_t::iter Manager::transaction_id_t Manager::transaction (const std::string &description, transaction_id_t join_with) { - if (db::transactions_enabled ()) { + if (m_enabled) { // close transactions that are still open (was an assertion before) if (m_opened) { @@ -146,7 +147,7 @@ Manager::last_transaction_id () const void Manager::cancel () { - if (db::transactions_enabled ()) { + if (m_enabled) { // commit and undo - revert changes done so far commit (); @@ -162,7 +163,7 @@ Manager::cancel () void Manager::commit () { - if (db::transactions_enabled ()) { + if (m_enabled) { tl_assert (m_opened); tl_assert (! m_replay); diff --git a/src/db/db/dbManager.h b/src/db/db/dbManager.h index 451ec2d13..0c293ed7c 100644 --- a/src/db/db/dbManager.h +++ b/src/db/db/dbManager.h @@ -85,13 +85,21 @@ public: /** * @brief Default constructor */ - Manager (); + Manager (bool enabled = true); /** * @brief Destructor */ ~Manager (); + /** + * @brief Gets a value indicating whether the manager is enabled + */ + bool is_enabled () const + { + return m_enabled; + } + /** * @brief Release an object with the given id. * @@ -255,6 +263,7 @@ private: transactions_t::iterator m_current; bool m_opened; bool m_replay; + bool m_enabled; void erase_transactions (transactions_t::iterator from, transactions_t::iterator to); }; diff --git a/src/db/db/dbObject.h b/src/db/db/dbObject.h index 3615845b4..dc81c22eb 100644 --- a/src/db/db/dbObject.h +++ b/src/db/db/dbObject.h @@ -130,6 +130,26 @@ public: return manager () && manager ()->replaying (); } + /** + * @brief Begins a transaction (same as calling manager ()->transaction (), but safe against null manager ()) + */ + void transaction (const std::string &description, db::Manager::transaction_id_t join_with = 0) + { + if (manager ()) { + manager ()->transaction (description, join_with); + } + } + + /** + * @brief Ends a transaction (same as calling manager ()->commit (), but safe against null manager ()) + */ + void commit () + { + if (manager ()) { + manager ()->commit (); + } + } + private: db::Manager::ident_t m_id; db::Manager *mp_manager; diff --git a/src/db/db/dbStatic.h b/src/db/db/dbStatic.h index 86ad1f496..2b42f6825 100644 --- a/src/db/db/dbStatic.h +++ b/src/db/db/dbStatic.h @@ -70,25 +70,6 @@ inline unsigned int num_circle_points () */ void DB_PUBLIC set_num_circle_points (unsigned int n); -// ----------------------------------------------------------- -// transaction enable - -/** - * @brief Return true, if undo buffering is enabled - */ -inline bool transactions_enabled () -{ - extern DB_PUBLIC bool ms_transactions_enabled; - return ms_transactions_enabled; -} - -/** - * @brief Enable or disable transaction buffering - * - * @param enabled True to enable undo buffering - */ -void DB_PUBLIC enable_transactions (bool enable); - } #endif diff --git a/src/db/unit_tests/dbCell.cc b/src/db/unit_tests/dbCell.cc index 07d585a74..7e3dfec0e 100644 --- a/src/db/unit_tests/dbCell.cc +++ b/src/db/unit_tests/dbCell.cc @@ -28,7 +28,7 @@ TEST(1) { - db::Manager m; + db::Manager m (true); db::Layout g (&m); db::Cell &c1 (g.cell (g.add_cell ())); db::Cell &c2 (g.cell (g.add_cell ())); @@ -265,7 +265,7 @@ TEST(2) { ::pi = 0; - db::Manager m; + db::Manager m (true); db::Layout g (&m); db::Cell &c0 (g.cell (g.add_cell ())); db::Cell &c1 (g.cell (g.add_cell ())); @@ -615,7 +615,7 @@ TEST(3) { ::pi = 0; - db::Manager m; + db::Manager m (true); db::Layout g (&m); db::Cell &c0 (g.cell (g.add_cell ())); db::Cell &c1 (g.cell (g.add_cell ())); @@ -672,7 +672,7 @@ TEST(3a) { ::pi = 0; - db::Manager m; + db::Manager m (true); db::Layout g (&m); db::Cell &c0 (g.cell (g.add_cell ())); db::Cell &c1 (g.cell (g.add_cell ())); @@ -728,7 +728,7 @@ TEST(3b) { ::pi = 0; - db::Manager m; + db::Manager m (true); db::Layout g (&m); db::Cell &c0 (g.cell (g.add_cell ())); db::Cell &c1 (g.cell (g.add_cell ())); @@ -805,7 +805,7 @@ TEST(4) { ::pi = 0; - db::Manager m; + db::Manager m (true); db::Layout g (&m); db::Cell &c0 (g.cell (g.add_cell ())); db::Cell &c1 (g.cell (g.add_cell ())); @@ -842,7 +842,7 @@ TEST(4) TEST(5) { - db::Manager m; + db::Manager m (true); db::Layout g (&m); db::Cell &c0 (g.cell (g.add_cell ())); db::Cell &c1 (g.cell (g.add_cell ())); @@ -888,7 +888,7 @@ TEST(5) TEST(6) { - db::Manager m; + db::Manager m (true); db::Layout g (&m); db::Cell &c0 (g.cell (g.add_cell ())); db::Cell &c1 (g.cell (g.add_cell ())); diff --git a/src/db/unit_tests/dbCellGraphUtils.cc b/src/db/unit_tests/dbCellGraphUtils.cc index 03090d126..76631c029 100644 --- a/src/db/unit_tests/dbCellGraphUtils.cc +++ b/src/db/unit_tests/dbCellGraphUtils.cc @@ -29,7 +29,7 @@ TEST(1) { - db::Manager m; + db::Manager m (true); db::Layout g (&m); db::Cell &c0 (g.cell (g.add_cell ())); db::Cell &c1 (g.cell (g.add_cell ())); diff --git a/src/db/unit_tests/dbCellHullGenerator.cc b/src/db/unit_tests/dbCellHullGenerator.cc index 2cc92eb1c..0ffc7bafe 100644 --- a/src/db/unit_tests/dbCellHullGenerator.cc +++ b/src/db/unit_tests/dbCellHullGenerator.cc @@ -61,7 +61,7 @@ static bool check_hull (const std::vector &hull, const db::Shapes & TEST(1) { - db::Manager m; + db::Manager m (true); db::Layout g (&m); unsigned int l1 = g.insert_layer (db::LayerProperties (1, 0)); unsigned int l2 = g.insert_layer (db::LayerProperties (2, 0)); @@ -238,7 +238,7 @@ TEST(1) TEST(2) { - db::Manager m; + db::Manager m (true); db::Layout g (&m); unsigned int l1 = g.insert_layer (db::LayerProperties (1, 0)); db::Cell &c1 (g.cell (g.add_cell ())); diff --git a/src/db/unit_tests/dbEdgeProcessor.cc b/src/db/unit_tests/dbEdgeProcessor.cc index 4a77e3fd7..84051e0be 100644 --- a/src/db/unit_tests/dbEdgeProcessor.cc +++ b/src/db/unit_tests/dbEdgeProcessor.cc @@ -417,7 +417,7 @@ TEST(3special) void run_test_size (tl::TestBase *_this, const char *file, const char *au_file, int mode, db::Coord dx, db::Coord dy, bool min_coherence = true, bool flat = true) { - db::Manager m; + db::Manager m (true); db::Layout layout_org (&m); db::Layout layout_au (&m); diff --git a/src/db/unit_tests/dbLibraries.cc b/src/db/unit_tests/dbLibraries.cc index 523923681..1be0d58f6 100644 --- a/src/db/unit_tests/dbLibraries.cc +++ b/src/db/unit_tests/dbLibraries.cc @@ -308,7 +308,7 @@ TEST(1) EXPECT_EQ (lib->layout ().get_properties(1).to_string (), "16/0"); EXPECT_EQ (lib->layout ().get_properties(2).to_string (), "24/0"); - db::Manager m; + db::Manager m (true); db::Layout layout(&m); layout.dbu (0.001); @@ -460,7 +460,7 @@ TEST(2) bool equal; db::Writer writer = db::Writer (db::SaveLayoutOptions ()); - db::Manager m; + db::Manager m (true); db::Layout layout(&m); layout.dbu (0.001); @@ -571,7 +571,7 @@ TEST(3) // This test tests the ability to reference libraries out of other libraries ("B" references "A"), // the ability to persist that and whether this survives a write/read cycle. - db::Manager m; + db::Manager m (true); db::Layout layout(&m); layout.dbu (0.001); diff --git a/src/db/unit_tests/dbObject.cc b/src/db/unit_tests/dbObject.cc index b0a7ad851..301b26b82 100644 --- a/src/db/unit_tests/dbObject.cc +++ b/src/db/unit_tests/dbObject.cc @@ -69,7 +69,7 @@ struct A : public db::Object TEST(1) { - db::Manager *man = new db::Manager (); + db::Manager *man = new db::Manager (true); { EXPECT_EQ (man->available_undo ().first, false); EXPECT_EQ (man->available_redo ().first, false); @@ -176,7 +176,7 @@ struct B : public db::Object TEST(2) { - db::Manager *man = new db::Manager (); + db::Manager *man = new db::Manager (true); { EXPECT_EQ (man->available_undo ().first, false); EXPECT_EQ (man->available_redo ().first, false); @@ -234,7 +234,7 @@ TEST(2) TEST(3) { - db::Manager *man = new db::Manager (); + db::Manager *man = new db::Manager (true); { EXPECT_EQ (man->available_undo ().first, false); EXPECT_EQ (man->available_redo ().first, false); @@ -268,7 +268,7 @@ TEST(3) TEST(4) { - db::Manager *man = new db::Manager (); + db::Manager *man = new db::Manager (true); { EXPECT_EQ (man->available_undo ().first, false); EXPECT_EQ (man->available_redo ().first, false); diff --git a/src/db/unit_tests/dbPCells.cc b/src/db/unit_tests/dbPCells.cc index 0a0ed267f..1c59b8b43 100644 --- a/src/db/unit_tests/dbPCells.cc +++ b/src/db/unit_tests/dbPCells.cc @@ -92,7 +92,7 @@ class PD TEST(0) { - db::Manager m; + db::Manager m (true); db::Layout layout(&m); layout.dbu (0.001); db::Layout layout_au(&m); @@ -114,7 +114,7 @@ TEST(0) TEST(1) { - db::Manager m; + db::Manager m (true); db::Layout layout(&m); layout.dbu (0.001); diff --git a/src/db/unit_tests/dbRecursiveShapeIteratorTests.cc b/src/db/unit_tests/dbRecursiveShapeIteratorTests.cc index a8d7bcf29..ad19619f8 100644 --- a/src/db/unit_tests/dbRecursiveShapeIteratorTests.cc +++ b/src/db/unit_tests/dbRecursiveShapeIteratorTests.cc @@ -65,7 +65,7 @@ std::string collect_with_copy(db::RecursiveShapeIterator s, const db::Layout &la TEST(1) { - db::Manager m; + db::Manager m (true); db::Layout g (&m); g.insert_layer (0); g.insert_layer (1); @@ -326,7 +326,7 @@ TEST(1) TEST(1a) { - db::Manager m; + db::Manager m (true); db::Layout g (&m); g.insert_layer (0); g.insert_layer (1); @@ -472,7 +472,7 @@ TEST(1a) TEST(1b) { - db::Manager m; + db::Manager m (true); db::Layout g (&m); g.insert_layer (0); db::Cell &c0 (g.cell (g.add_cell ())); @@ -508,7 +508,7 @@ TEST(1b) TEST(2) { - db::Manager m; + db::Manager m (true); db::Layout g (&m); g.insert_layer(0); @@ -562,7 +562,7 @@ TEST(2) TEST(3) { - db::Manager m; + db::Manager m (true); db::Layout g (&m); g.insert_layer(0); @@ -742,7 +742,7 @@ TEST(4) { // Big fun - db::Manager m; + db::Manager m (true); db::Layout g (&m); g.insert_layer(0); @@ -827,7 +827,7 @@ TEST(5) { // Big fun with cells - db::Manager m; + db::Manager m (true); db::Layout g (&m); g.insert_layer(0); @@ -1013,7 +1013,7 @@ private: // Push mode with cells TEST(10) { - db::Manager m; + db::Manager m (true); db::Layout g (&m); g.insert_layer(0); diff --git a/src/db/unit_tests/dbShape.cc b/src/db/unit_tests/dbShape.cc index 40ee9c283..baa47a59c 100644 --- a/src/db/unit_tests/dbShape.cc +++ b/src/db/unit_tests/dbShape.cc @@ -32,7 +32,7 @@ TEST(1) { - db::Manager m; + db::Manager m (true); db::Shapes s (&m, 0, db::default_editable_mode ()); db::Polygon p1; @@ -129,7 +129,7 @@ TEST(1) TEST(2) { - db::Manager m; + db::Manager m (true); db::Shapes s (&m, 0, db::default_editable_mode ()); db::Polygon p1; @@ -209,7 +209,7 @@ TEST(2) TEST(3) { - db::Manager m; + db::Manager m (true); db::Shapes s (&m, 0, db::default_editable_mode ()); db::Polygon p1; @@ -272,7 +272,7 @@ TEST(3) TEST(1BOX) { - db::Manager m; + db::Manager m (true); db::Shapes s (&m, 0, db::default_editable_mode ()); db::Polygon p1; @@ -342,7 +342,7 @@ TEST(1BOX) TEST(2BOX) { - db::Manager m; + db::Manager m (true); db::Shapes s (&m, 0, db::default_editable_mode ()); db::Polygon p1; @@ -400,7 +400,7 @@ TEST(2BOX) TEST(3BOX) { - db::Manager m; + db::Manager m (true); db::Shapes s (&m, 0, db::default_editable_mode ()); db::Polygon p1; @@ -463,7 +463,7 @@ TEST(3BOX) TEST(1SBOX) { - db::Manager m; + db::Manager m (true); db::Shapes s (&m, 0, db::default_editable_mode ()); db::Polygon p1; @@ -533,7 +533,7 @@ TEST(1SBOX) TEST(2SBOX) { - db::Manager m; + db::Manager m (true); db::Shapes s (&m, 0, db::default_editable_mode ()); db::Polygon p1; @@ -591,7 +591,7 @@ TEST(2SBOX) TEST(3SBOX) { - db::Manager m; + db::Manager m (true); db::Shapes s (&m, 0, db::default_editable_mode ()); db::Polygon p1; @@ -654,7 +654,7 @@ TEST(3SBOX) TEST(4) { - db::Manager m; + db::Manager m (true); db::Shapes s (&m, 0, db::default_editable_mode ()); db::Box bx1 (db::Point (0, 0), db::Point (1000, 100)); @@ -684,7 +684,7 @@ TEST(4) TEST(5) { if (db::default_editable_mode ()) { return; } // currently Boxes are treated as ones with properties - db::Manager m; + db::Manager m (true); db::Shapes s (&m, 0, db::default_editable_mode ()); db::Box bx1 (db::Point (0, 0), db::Point (1000, 100)); @@ -720,7 +720,7 @@ TEST(5) TEST(6) { - db::Manager m; + db::Manager m (true); db::Shapes s (&m, 0, db::default_editable_mode ()); db::Box bx1 (db::Point (0, 0), db::Point (1000, 100)); @@ -745,7 +745,7 @@ TEST(6) TEST(7) { if (db::default_editable_mode ()) { return; } // currently Boxes are treated as ones with properties - db::Manager m; + db::Manager m (true); db::Shapes s (&m, 0, db::default_editable_mode ()); db::Box bx2 (db::Point (0, 1000), db::Point (100, 2000)); @@ -766,7 +766,7 @@ TEST(7) TEST(8) { - db::Manager m; + db::Manager m (true); db::Shapes s (&m, 0, db::default_editable_mode ()); db::PropertiesRepository proprep; diff --git a/src/db/unit_tests/dbShapeRepository.cc b/src/db/unit_tests/dbShapeRepository.cc index 7c68403b3..95ca72e38 100644 --- a/src/db/unit_tests/dbShapeRepository.cc +++ b/src/db/unit_tests/dbShapeRepository.cc @@ -256,7 +256,7 @@ TEST(2SIMPLE) TEST(3) { db::GenericRepository *rep = new db::GenericRepository (); - db::Manager m; + db::Manager m (true); std::vector c1; c1.push_back (db::Point (100, 0)); diff --git a/src/db/unit_tests/dbShapes.cc b/src/db/unit_tests/dbShapes.cc index e6204733c..a43778b8f 100644 --- a/src/db/unit_tests/dbShapes.cc +++ b/src/db/unit_tests/dbShapes.cc @@ -30,7 +30,7 @@ TEST(1) { - db::Manager m; + db::Manager m (true); db::Shapes s (&m, 0, db::default_editable_mode ()); db::Box b_empty; @@ -60,7 +60,7 @@ TEST(1) TEST(1a) { - db::Manager m; + db::Manager m (true); db::Shapes s (&m, 0, true); db::Box b_empty; @@ -88,7 +88,7 @@ TEST(1a) TEST(1b) { - db::Manager m; + db::Manager m (true); db::Shapes s (&m, 0, false); db::Box b_empty; @@ -393,7 +393,7 @@ struct plus1 TEST(2) { - db::Manager m; + db::Manager m (true); db::Layout other_layout (&m); db::Cell &other_topcell = other_layout.cell (other_layout.add_cell ()); @@ -644,7 +644,7 @@ TEST(2) TEST(2A) { - db::Manager m; + db::Manager m (true); db::Layout layout (&m); unsigned int lindex = read_testdata (layout, 0x1); @@ -737,7 +737,7 @@ TEST(2A) TEST(3) { - db::Manager m; + db::Manager m (true); db::Layout other_layout (&m); db::Cell &other_topcell = other_layout.cell (other_layout.add_cell ()); @@ -988,7 +988,7 @@ TEST(3) TEST(4) { - db::Manager m; + db::Manager m (true); db::Layout other_layout (&m); db::Cell &other_topcell = other_layout.cell (other_layout.add_cell ()); @@ -1238,7 +1238,7 @@ TEST(4) TEST(5) { - db::Manager m; + db::Manager m (true); db::Layout other_layout (&m); db::Cell &other_topcell = other_layout.cell (other_layout.add_cell ()); @@ -1489,7 +1489,7 @@ TEST(5) TEST(6) { - db::Manager m; + db::Manager m (true); db::Layout other_layout (&m); db::Cell &other_topcell = other_layout.cell (other_layout.add_cell ()); @@ -1711,7 +1711,7 @@ TEST(6) TEST(7) { - db::Manager m; + db::Manager m (true); db::Layout other_layout (&m); db::Cell &other_topcell = other_layout.cell (other_layout.add_cell ()); @@ -2017,7 +2017,7 @@ TEST(10A) { if (db::default_editable_mode ()) { - db::Manager m; + db::Manager m (true); db::Layout layout (&m); unsigned int lindex = read_testdata (layout, 0x1); @@ -2076,7 +2076,7 @@ TEST(10C) { if (db::default_editable_mode ()) { - db::Manager m; + db::Manager m (true); db::Layout layout (&m); unsigned int lindex = read_testdata (layout, 0x1); @@ -2101,7 +2101,7 @@ TEST(10D) { if (db::default_editable_mode ()) { - db::Manager m; + db::Manager m (true); db::Layout layout (&m); unsigned int lindex = read_testdata (layout, 0x1); @@ -2126,7 +2126,7 @@ TEST(11A) { if (db::default_editable_mode ()) { - db::Manager m; + db::Manager m (true); db::Layout layout (&m); unsigned int lindex = read_testdata (layout, 0x20); @@ -2182,7 +2182,7 @@ TEST(11C) { if (db::default_editable_mode ()) { - db::Manager m; + db::Manager m (true); db::Layout layout (&m); unsigned int lindex = read_testdata (layout, 0x20); @@ -2207,7 +2207,7 @@ TEST(11D) { if (db::default_editable_mode ()) { - db::Manager m; + db::Manager m (true); db::Layout layout (&m); unsigned int lindex = read_testdata (layout, 0x20); @@ -2232,7 +2232,7 @@ TEST(11E) { if (db::default_editable_mode ()) { - db::Manager m; + db::Manager m (true); db::Layout layout (&m); m.transaction ("y"); unsigned int lindex = read_testdata (layout, 0x20); @@ -2268,7 +2268,7 @@ TEST(11F) { if (db::default_editable_mode ()) { - db::Manager m; + db::Manager m (true); db::Layout layout (&m); m.transaction ("y"); unsigned int lindex = read_testdata (layout, 0x20); @@ -2369,7 +2369,7 @@ TEST(12A) { if (db::default_editable_mode ()) { - db::Manager m; + db::Manager m (true); db::Layout layout (&m); unsigned int lindex = read_testdata (layout, 0x20 | 0x80); // short box, no arrays @@ -2414,7 +2414,7 @@ TEST(12B) { if (db::default_editable_mode ()) { - db::Manager m; + db::Manager m (true); db::Layout layout (&m); unsigned int lindex = read_testdata (layout, 0x20 | 0x80); // short box, no arrays @@ -2442,7 +2442,7 @@ TEST(12C) { if (db::default_editable_mode ()) { - db::Manager m; + db::Manager m (true); db::Layout layout (&m); unsigned int lindex = read_testdata (layout, 0x10 | 0x80); // box, no arrays @@ -2487,7 +2487,7 @@ TEST(12D) { if (db::default_editable_mode ()) { - db::Manager m; + db::Manager m (true); db::Layout layout (&m); unsigned int lindex = read_testdata (layout, 0x10 | 0x80); // box, no arrays @@ -2515,7 +2515,7 @@ TEST(12E) { if (db::default_editable_mode ()) { - db::Manager m; + db::Manager m (true); db::Layout layout (&m); unsigned int lindex = read_testdata (layout, 0x01 | 0x80); // simple polygon, no arrays @@ -2577,7 +2577,7 @@ TEST(12F) { if (db::default_editable_mode ()) { - db::Manager m; + db::Manager m (true); db::Layout layout (&m); unsigned int lindex = read_testdata (layout, 0x01 | 0x80); // simple polygon, no arrays @@ -2614,7 +2614,7 @@ TEST(12G) { if (db::default_editable_mode ()) { - db::Manager m; + db::Manager m (true); db::Layout layout (&m); unsigned int lindex = read_testdata (layout, 0x02 | 0x80); // polygon, no arrays @@ -2676,7 +2676,7 @@ TEST(12H) { if (db::default_editable_mode ()) { - db::Manager m; + db::Manager m (true); db::Layout layout (&m); unsigned int lindex = read_testdata (layout, 0x02 | 0x80); // polygon, no arrays @@ -2713,7 +2713,7 @@ TEST(12I) { if (db::default_editable_mode ()) { - db::Manager m; + db::Manager m (true); db::Layout layout (&m); unsigned int lindex = read_testdata (layout, 0x04 | 0x80); // path, no arrays @@ -2773,7 +2773,7 @@ TEST(12J) { if (db::default_editable_mode ()) { - db::Manager m; + db::Manager m (true); db::Layout layout (&m); unsigned int lindex = read_testdata (layout, 0x08 | 0x80); // text, no arrays @@ -2831,7 +2831,7 @@ TEST(12J) TEST(13) { - db::Manager m; + db::Manager m (true); db::Layout layout (&m); unsigned int lindex = read_testdata (layout, 0x3f); // all with arrays @@ -2859,7 +2859,7 @@ TEST(13) TEST(14) { - db::Manager m; + db::Manager m (true); db::Layout layout (&m); unsigned int lindex = read_testdata (layout, 0x10); // boxes @@ -2947,7 +2947,7 @@ TEST(14) TEST(15) { - db::Manager m; + db::Manager m (true); db::Layout layout (&m); unsigned int lindex = read_testdata (layout, 0x1); @@ -3058,7 +3058,7 @@ TEST(15) TEST(16) { - db::Manager m; + db::Manager m (true); db::Layout layout (&m); unsigned int lindex = read_testdata (layout, 0x1); @@ -3276,7 +3276,7 @@ TEST(22) // Edge pairs TEST(23) { - db::Manager m; + db::Manager m (true); db::Shapes s (&m, 0, db::default_editable_mode ()); db::Box b_empty; @@ -3312,7 +3312,7 @@ TEST(23) // Bug #107 TEST(100) { - db::Manager m; + db::Manager m (true); db::Shapes shapes1 (&m, 0, true); m.transaction ("y"); diff --git a/src/lay/lay/layApplication.cc b/src/lay/lay/layApplication.cc index 0d5024e9f..5e2b13b15 100644 --- a/src/lay/lay/layApplication.cc +++ b/src/lay/lay/layApplication.cc @@ -731,7 +731,6 @@ ApplicationBase::init_app () } db::set_default_editable_mode (m_editable); - db::enable_transactions (m_enable_undo); if (! m_gtf_record.empty ()) { // since the recorder tracks QAction connections etc., it must be instantiated before every other @@ -1485,7 +1484,7 @@ GuiApplication::setup () tl_assert (mp_mw == 0 && mp_plugin_root == 0); mp_plugin_root = new lay::PluginRootToMainWindow (); - mp_mw = new lay::MainWindow (this, mp_plugin_root, "main_window"); + mp_mw = new lay::MainWindow (this, mp_plugin_root, "main_window", is_undo_enabled ()); mp_plugin_root->attach_to (mp_mw); QObject::connect (mp_mw, SIGNAL (closed ()), this, SLOT (quit ())); diff --git a/src/lay/lay/layMainWindow.cc b/src/lay/lay/layMainWindow.cc index aa229c1ad..be39fa22b 100644 --- a/src/lay/lay/layMainWindow.cc +++ b/src/lay/lay/layMainWindow.cc @@ -419,7 +419,7 @@ MainWindow::instance () // ----------------------------------- -MainWindow::MainWindow (QApplication *app, lay::Plugin *plugin_parent, const char *name) +MainWindow::MainWindow (QApplication *app, lay::Plugin *plugin_parent, const char *name, bool undo_enabled) : QMainWindow (0), lay::Plugin (plugin_parent), m_text_progress (this, 10 /*verbosity threshold*/), @@ -438,7 +438,8 @@ MainWindow::MainWindow (QApplication *app, lay::Plugin *plugin_parent, const cha m_synchronized_views (false), m_synchronous (false), m_busy (false), - mp_app (app) + mp_app (app), + m_manager (true) { // ensures the deferred method scheduler is present tl::DeferredMethodScheduler::instance (); diff --git a/src/lay/lay/layMainWindow.h b/src/lay/lay/layMainWindow.h index 108fd4284..4429ee394 100644 --- a/src/lay/lay/layMainWindow.h +++ b/src/lay/lay/layMainWindow.h @@ -132,7 +132,7 @@ public: /** * @brief Constructor */ - MainWindow (QApplication *app = 0, lay::Plugin *parent_plugin = 0, const char *name = "main_window"); + MainWindow (QApplication *app = 0, lay::Plugin *parent_plugin = 0, const char *name = "main_window", bool undo_enabled = true); /** * @brief Destructor diff --git a/src/laybasic/laybasic/gsiDeclLayLayoutView.cc b/src/laybasic/laybasic/gsiDeclLayLayoutView.cc index f0fab85b2..74a650fae 100644 --- a/src/laybasic/laybasic/gsiDeclLayLayoutView.cc +++ b/src/laybasic/laybasic/gsiDeclLayLayoutView.cc @@ -427,75 +427,75 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "This constructor has been introduced in version 0.25.\n" "It has been enhanced with the arguments in version 0.26.4.\n" ) + - gsi::constant ("LV_NoLayers", (unsigned int) laybasic::LayoutView::LV_NoLayers, + gsi::constant ("LV_NoLayers", (unsigned int) lay::LayoutView::LV_NoLayers, "@brief With this option, no layers view will be provided (see \\layer_control_frame)\n" "Use this value with the constructor's 'options' argument.\n" "\n" "This constant has been introduced in version 0.26.4.\n" ) + - gsi::constant ("LV_NoHierarchyPanel", (unsigned int) laybasic::LayoutView::LV_NoHierarchyPanel, + gsi::constant ("LV_NoHierarchyPanel", (unsigned int) lay::LayoutView::LV_NoHierarchyPanel, "@brief With this option, no cell hierarchy view will be provided (see \\hierarchy_control_frame)\n" "Use this value with the constructor's 'options' argument.\n" "\n" "This constant has been introduced in version 0.26.4.\n" ) + - gsi::constant ("LV_NoLibrariesView", (unsigned int) laybasic::LayoutView::LV_NoLibrariesView, + gsi::constant ("LV_NoLibrariesView", (unsigned int) lay::LayoutView::LV_NoLibrariesView, "@brief With this option, no library view will be provided (see \\libraries_frame)\n" "Use this value with the constructor's 'options' argument.\n" "\n" "This constant has been introduced in version 0.26.4.\n" ) + - gsi::constant ("LV_NoBookmarksView", (unsigned int) laybasic::LayoutView::LV_NoBookmarksView, + gsi::constant ("LV_NoBookmarksView", (unsigned int) lay::LayoutView::LV_NoBookmarksView, "@brief With this option, no bookmarks view will be provided (see \\bookmarks_frame)\n" "Use this value with the constructor's 'options' argument.\n" "\n" "This constant has been introduced in version 0.26.4.\n" ) + - gsi::constant ("LV_Naked", (unsigned int) laybasic::LayoutView::LV_Naked, + gsi::constant ("LV_Naked", (unsigned int) lay::LayoutView::LV_Naked, "@brief With this option, no separate views will be provided\n" "Use this value with the constructor's 'options' argument.\n" "This option is basically equivalent to using \\LV_NoLayers+\\LV_NoHierarchyPanel+\\LV_NoLibrariesView+\\LV_NoBookmarksView\n" "\n" "This constant has been introduced in version 0.26.4.\n" ) + - gsi::constant ("LV_NoZoom", (unsigned int) laybasic::LayoutView::LV_NoZoom, + gsi::constant ("LV_NoZoom", (unsigned int) lay::LayoutView::LV_NoZoom, "@brief With this option, zooming is disabled\n" "Use this value with the constructor's 'options' argument.\n" "\n" "This constant has been introduced in version 0.26.4.\n" ) + - gsi::constant ("LV_NoGrid", (unsigned int) laybasic::LayoutView::LV_NoGrid, + gsi::constant ("LV_NoGrid", (unsigned int) lay::LayoutView::LV_NoGrid, "@brief With this option, the grid background is not shown\n" "Use this value with the constructor's 'options' argument.\n" "\n" "This constant has been introduced in version 0.26.4.\n" ) + - gsi::constant ("LV_NoMove", (unsigned int) laybasic::LayoutView::LV_NoMove, + gsi::constant ("LV_NoMove", (unsigned int) lay::LayoutView::LV_NoMove, "@brief With this option, move operations are not supported\n" "Use this value with the constructor's 'options' argument.\n" "\n" "This constant has been introduced in version 0.26.4.\n" ) + - gsi::constant ("LV_NoTracker", (unsigned int) laybasic::LayoutView::LV_NoTracker, + gsi::constant ("LV_NoTracker", (unsigned int) lay::LayoutView::LV_NoTracker, "@brief With this option, mouse position tracking is not supported\n" "Use this value with the constructor's 'options' argument.\n" "This option is not useful currently as no mouse tracking support is provided.\n" "\n" "This constant has been introduced in version 0.26.4.\n" ) + - gsi::constant ("LV_NoSelection", (unsigned int) laybasic::LayoutView::LV_NoSelection, + gsi::constant ("LV_NoSelection", (unsigned int) lay::LayoutView::LV_NoSelection, "@brief With this option, objects cannot be selected\n" "Use this value with the constructor's 'options' argument.\n" "\n" "This constant has been introduced in version 0.26.4.\n" ) + - gsi::constant ("LV_NoPlugins", (unsigned int) laybasic::LayoutView::LV_NoPlugins, + gsi::constant ("LV_NoPlugins", (unsigned int) lay::LayoutView::LV_NoPlugins, "@brief With this option, all plugins are disabled\n" "Use this value with the constructor's 'options' argument.\n" "\n" "This constant has been introduced in version 0.26.4.\n" ) + - gsi::constant ("LV_NoServices", (unsigned int) laybasic::LayoutView::LV_NoServices, + gsi::constant ("LV_NoServices", (unsigned int) lay::LayoutView::LV_NoServices, "@brief This option disables all services except the ones for pure viewing\n" "Use this value with the constructor's 'options' argument.\n" "With this option, all manipulation features are disabled, except zooming.\n" diff --git a/src/laybasic/laybasic/layEditLineStylesForm.cc b/src/laybasic/laybasic/layEditLineStylesForm.cc index dcd503935..76fb5b1f8 100644 --- a/src/laybasic/laybasic/layEditLineStylesForm.cc +++ b/src/laybasic/laybasic/layEditLineStylesForm.cc @@ -52,7 +52,7 @@ struct CurrentStyleOp EditLineStylesForm::EditLineStylesForm (lay::LayoutView *view, const lay::LineStyles &styles) : QDialog (view), db::Object (0), - m_selected (-1), m_styles (styles), mp_view (view) + m_selected (-1), m_styles (styles), m_manager (true), mp_view (view) { m_selection_changed_enabled = false; diff --git a/src/laybasic/laybasic/layEditStipplesForm.cc b/src/laybasic/laybasic/layEditStipplesForm.cc index df65e9ab5..edc7d9f95 100644 --- a/src/laybasic/laybasic/layEditStipplesForm.cc +++ b/src/laybasic/laybasic/layEditStipplesForm.cc @@ -52,7 +52,7 @@ struct CurrentPatternOp EditStipplesForm::EditStipplesForm (lay::LayoutView *view, const lay::DitherPattern &pattern) : QDialog (view), db::Object (0), - m_selected (-1), m_pattern (pattern), mp_view (view) + m_selected (-1), m_pattern (pattern), m_manager (true), mp_view (view) { m_selection_changed_enabled = false; diff --git a/src/laybasic/laybasic/layHierarchyControlPanel.cc b/src/laybasic/laybasic/layHierarchyControlPanel.cc index 14d5815ee..fc4930f25 100644 --- a/src/laybasic/laybasic/layHierarchyControlPanel.cc +++ b/src/laybasic/laybasic/layHierarchyControlPanel.cc @@ -632,14 +632,14 @@ HierarchyControlPanel::double_clicked (const QModelIndex &index) BEGIN_PROTECTED if (index.isValid ()) { set_active_celltree_from_sender (); - mp_view->manager ()->transaction (tl::to_string (QObject::tr ("Show or hide cell"))); + mp_view->transaction (tl::to_string (QObject::tr ("Show or hide cell"))); CellTreeItem *item = (CellTreeItem *) index.internalPointer (); if (mp_view->is_cell_hidden (item->cell_or_pcell_index (), m_active_index)) { mp_view->show_cell (item->cell_or_pcell_index (), m_active_index); } else { mp_view->hide_cell (item->cell_or_pcell_index (), m_active_index); } - mp_view->manager ()->commit (); + mp_view->commit (); } END_PROTECTED } @@ -1085,14 +1085,14 @@ HierarchyControlPanel::cut () } } - mp_view->manager ()->transaction (tl::to_string (QObject::tr ("Cut Cells"))); + mp_view->transaction (tl::to_string (QObject::tr ("Cut Cells"))); if (cut_mode == 1) { layout.prune_cells (cells_to_delete); } else { layout.delete_cells (cells_to_delete); } layout.cleanup (); - mp_view->manager ()->commit (); + mp_view->commit (); // If one of the cells in the path was deleted, establish a valid path diff --git a/src/laybasic/laybasic/layLayerControlPanel.cc b/src/laybasic/laybasic/layLayerControlPanel.cc index 5a824807c..844b53128 100644 --- a/src/laybasic/laybasic/layLayerControlPanel.cc +++ b/src/laybasic/laybasic/layLayerControlPanel.cc @@ -496,7 +496,9 @@ void LayerControlPanel::recover () { cancel_updates (); - manager ()->clear (); + if (manager ()) { + manager ()->clear (); + } } void @@ -504,13 +506,13 @@ LayerControlPanel::cm_delete () { BEGIN_PROTECTED_CLEANUP - manager ()->transaction (tl::to_string (QObject::tr ("Delete layer views"))); + transaction (tl::to_string (QObject::tr ("Delete layer views"))); do_delete (); - manager ()->commit (); + commit (); END_PROTECTED_CLEANUP { recover (); - manager ()->commit (); + commit (); } } @@ -535,7 +537,7 @@ LayerControlPanel::do_delete () mp_view->delete_layer (*s); } - if (manager ()->transacting ()) { + if (transacting ()) { manager ()->queue (this, new LayerSelectionClearOp ()); } @@ -553,7 +555,7 @@ LayerControlPanel::cm_remove_unused () begin_updates (); - manager ()->transaction (tl::to_string (QObject::tr ("Clean up views"))); + transaction (tl::to_string (QObject::tr ("Clean up views"))); bool any_deleted; do { @@ -577,7 +579,7 @@ LayerControlPanel::cm_remove_unused () } while (any_deleted); - manager ()->commit (); + commit (); end_updates (); @@ -592,9 +594,9 @@ LayerControlPanel::cm_add_missing () BEGIN_PROTECTED_CLEANUP begin_updates (); - manager ()->transaction (tl::to_string (QObject::tr ("Add other views"))); + transaction (tl::to_string (QObject::tr ("Add other views"))); mp_view->add_missing_layers (); - manager ()->commit (); + commit (); end_updates (); END_PROTECTED_CLEANUP { recover (); } @@ -618,18 +620,18 @@ LayerControlPanel::cm_insert () BEGIN_PROTECTED_CLEANUP - manager ()->transaction (tl::to_string (QObject::tr ("Insert views"))); + transaction (tl::to_string (QObject::tr ("Insert views"))); props.set_source (tl::to_string (n)); mp_view->init_layer_properties (props); const LayerPropertiesNode &lp = mp_view->insert_layer (sel, props); - if (manager ()->transacting ()) { + if (transacting ()) { manager ()->queue (this, new LayerSelectionClearOp ()); } mp_layer_list->set_current (sel); - manager ()->commit (); + commit (); emit order_changed (); @@ -656,7 +658,7 @@ LayerControlPanel::cm_group () begin_updates (); - manager ()->transaction (tl::to_string (QObject::tr ("Group layer views"))); + transaction (tl::to_string (QObject::tr ("Group layer views"))); lay::LayerPropertiesNode node; for (std::vector::const_iterator s = sel.begin (); s != sel.end (); ++s) { @@ -678,11 +680,11 @@ LayerControlPanel::cm_group () mp_view->insert_layer (ins_pos, node); - if (manager ()->transacting ()) { + if (transacting ()) { manager ()->queue (this, new LayerSelectionClearOp ()); } - manager ()->commit (); + commit (); end_updates (); @@ -705,7 +707,7 @@ LayerControlPanel::cm_ungroup () begin_updates (); - manager ()->transaction (tl::to_string (QObject::tr ("Ungroup layer views"))); + transaction (tl::to_string (QObject::tr ("Ungroup layer views"))); lay::LayerPropertiesNode node = *sel; @@ -720,12 +722,12 @@ LayerControlPanel::cm_ungroup () mp_view->insert_layer (ins_pos, c->flat ()); } - if (manager ()->transacting ()) { + if (transacting ()) { manager ()->queue (this, new LayerSelectionClearOp ()); } set_selection (std::vector ()); // clear selection - manager ()->commit (); + commit (); end_updates (); @@ -870,7 +872,7 @@ LayerControlPanel::paste () } } - if (manager ()->transacting ()) { + if (transacting ()) { manager ()->queue (this, new LayerSelectionClearOp ()); } @@ -904,9 +906,9 @@ LayerControlPanel::cm_source () props.set_source (tl::to_string (n)); - manager ()->transaction (tl::to_string (QObject::tr ("Select source"))); + transaction (tl::to_string (QObject::tr ("Select source"))); mp_view->set_properties (sel, props); - manager ()->commit (); + commit (); END_PROTECTED_CLEANUP { recover (); } @@ -937,9 +939,9 @@ LayerControlPanel::cm_rename () props.set_name (tl::to_string (n)); - manager ()->transaction (tl::to_string (QObject::tr ("Rename layer"))); + transaction (tl::to_string (QObject::tr ("Rename layer"))); mp_view->set_properties (sel, props); - manager ()->commit (); + commit (); END_PROTECTED_CLEANUP { recover (); } @@ -953,7 +955,7 @@ LayerControlPanel::cm_show_only () { BEGIN_PROTECTED_CLEANUP - manager ()->transaction (tl::to_string (QObject::tr ("Show selected layers"))); + transaction (tl::to_string (QObject::tr ("Show selected layers"))); std::vector sel = mp_view->selected_layers (); std::set sel_set (sel.begin (), sel.end ()); @@ -996,7 +998,7 @@ LayerControlPanel::cm_show_only () } } - manager ()->commit (); + commit (); END_PROTECTED_CLEANUP { recover (); } } @@ -1006,7 +1008,7 @@ LayerControlPanel::cm_show () { BEGIN_PROTECTED_CLEANUP - manager ()->transaction (tl::to_string (QObject::tr ("Show layer"))); + transaction (tl::to_string (QObject::tr ("Show layer"))); std::vector sel = mp_view->selected_layers (); @@ -1016,7 +1018,7 @@ LayerControlPanel::cm_show () mp_view->set_properties (*l, props); } - manager ()->commit (); + commit (); END_PROTECTED_CLEANUP { recover (); } } @@ -1026,7 +1028,7 @@ LayerControlPanel::cm_show_all () { BEGIN_PROTECTED_CLEANUP - manager ()->transaction (tl::to_string (QObject::tr ("Show all layers"))); + transaction (tl::to_string (QObject::tr ("Show all layers"))); for (lay::LayerPropertiesConstIterator l = mp_view->begin_layers (); ! l.at_end (); ++l) { lay::LayerProperties props (*l); @@ -1034,7 +1036,7 @@ LayerControlPanel::cm_show_all () mp_view->set_properties (l, props); } - manager ()->commit (); + commit (); END_PROTECTED_CLEANUP { recover (); } } @@ -1044,7 +1046,7 @@ LayerControlPanel::cm_rename_tab () { BEGIN_PROTECTED_CLEANUP - manager ()->transaction (tl::to_string (QObject::tr ("Rename layer tab"))); + transaction (tl::to_string (QObject::tr ("Rename layer tab"))); bool ok = false; QString n = QInputDialog::getText (this, @@ -1060,7 +1062,7 @@ LayerControlPanel::cm_rename_tab () end_updates (); } - manager ()->commit (); + commit (); END_PROTECTED_CLEANUP { recover (); } } @@ -1070,7 +1072,7 @@ LayerControlPanel::cm_remove_tab () { BEGIN_PROTECTED_CLEANUP - manager ()->transaction (tl::to_string (QObject::tr ("Remove layer tab"))); + transaction (tl::to_string (QObject::tr ("Remove layer tab"))); if (mp_view->layer_lists () == 1) { throw tl::Exception (tl::to_string (QObject::tr ("Cannot remove last layer tab"))); @@ -1080,7 +1082,7 @@ LayerControlPanel::cm_remove_tab () mp_view->delete_layer_list (mp_view->current_layer_list ()); end_updates (); - manager ()->commit (); + commit (); emit order_changed (); @@ -1092,13 +1094,13 @@ LayerControlPanel::cm_new_tab () { BEGIN_PROTECTED_CLEANUP - manager ()->transaction (tl::to_string (QObject::tr ("New layer tab"))); + transaction (tl::to_string (QObject::tr ("New layer tab"))); begin_updates (); mp_view->insert_layer_list (mp_view->current_layer_list () + 1, mp_view->get_properties ()); end_updates (); - manager ()->commit (); + commit (); emit order_changed (); @@ -1110,7 +1112,7 @@ LayerControlPanel::cm_make_valid () { BEGIN_PROTECTED_CLEANUP - manager ()->transaction (tl::to_string (QObject::tr ("Make layer valid"))); + transaction (tl::to_string (QObject::tr ("Make layer valid"))); std::vector sel = mp_view->selected_layers (); @@ -1120,7 +1122,7 @@ LayerControlPanel::cm_make_valid () mp_view->set_properties (*l, props); } - manager ()->commit (); + commit (); END_PROTECTED_CLEANUP { recover (); } } @@ -1130,7 +1132,7 @@ LayerControlPanel::cm_make_invalid () { BEGIN_PROTECTED_CLEANUP - manager ()->transaction (tl::to_string (QObject::tr ("Make layer invalid"))); + transaction (tl::to_string (QObject::tr ("Make layer invalid"))); std::vector sel = mp_view->selected_layers (); @@ -1140,7 +1142,7 @@ LayerControlPanel::cm_make_invalid () mp_view->set_properties (*l, props); } - manager ()->commit (); + commit (); END_PROTECTED_CLEANUP { recover (); } } @@ -1150,7 +1152,7 @@ LayerControlPanel::cm_hide () { BEGIN_PROTECTED_CLEANUP - manager ()->transaction (tl::to_string (QObject::tr ("Hide layer"))); + transaction (tl::to_string (QObject::tr ("Hide layer"))); std::vector sel = mp_view->selected_layers (); @@ -1160,7 +1162,7 @@ LayerControlPanel::cm_hide () mp_view->set_properties (*l, props); } - manager ()->commit (); + commit (); END_PROTECTED_CLEANUP { recover (); } } @@ -1170,7 +1172,7 @@ LayerControlPanel::cm_hide_all () { BEGIN_PROTECTED_CLEANUP - manager ()->transaction (tl::to_string (QObject::tr ("Hide all layers"))); + transaction (tl::to_string (QObject::tr ("Hide all layers"))); for (lay::LayerPropertiesConstIterator l = mp_view->begin_layers (); ! l.at_end (); ++l) { if (l.parent ().is_null ()) { @@ -1182,7 +1184,7 @@ LayerControlPanel::cm_hide_all () } } - manager ()->commit (); + commit (); END_PROTECTED_CLEANUP { recover (); } } @@ -1214,7 +1216,7 @@ LayerControlPanel::set_selection (const std::vectorset_selection (new_sel); // :TODO: save selection for undo? Currently we just clear it. - if (manager ()->transacting ()) { + if (transacting ()) { manager ()->queue (this, new LayerSelectionClearOp ()); } @@ -1304,9 +1306,9 @@ LayerControlPanel::cm_regroup_flatten () { BEGIN_PROTECTED_CLEANUP - manager ()->transaction (tl::to_string (QObject::tr ("Flatten layers"))); + transaction (tl::to_string (QObject::tr ("Flatten layers"))); regroup_layers (RegroupFlatten); - manager ()->commit (); + commit (); emit order_changed (); @@ -1318,9 +1320,9 @@ LayerControlPanel::cm_regroup_by_index () { BEGIN_PROTECTED_CLEANUP - manager ()->transaction (tl::to_string (QObject::tr ("Regroup layers"))); + transaction (tl::to_string (QObject::tr ("Regroup layers"))); regroup_layers (RegroupByIndex); - manager ()->commit (); + commit (); emit order_changed (); @@ -1332,9 +1334,9 @@ LayerControlPanel::cm_regroup_by_datatype () { BEGIN_PROTECTED_CLEANUP - manager ()->transaction (tl::to_string (QObject::tr ("Regroup layers"))); + transaction (tl::to_string (QObject::tr ("Regroup layers"))); regroup_layers (RegroupByDatatype); - manager ()->commit (); + commit (); emit order_changed (); @@ -1346,9 +1348,9 @@ LayerControlPanel::cm_regroup_by_layer () { BEGIN_PROTECTED_CLEANUP - manager ()->transaction (tl::to_string (QObject::tr ("Regroup layers"))); + transaction (tl::to_string (QObject::tr ("Regroup layers"))); regroup_layers (RegroupByLayer); - manager ()->commit (); + commit (); emit order_changed (); @@ -1360,9 +1362,9 @@ LayerControlPanel::cm_sort_by_name () { BEGIN_PROTECTED_CLEANUP - manager ()->transaction (tl::to_string (QObject::tr ("Sort layers"))); + transaction (tl::to_string (QObject::tr ("Sort layers"))); sort_layers (ByName); - manager ()->commit (); + commit (); emit order_changed (); @@ -1374,9 +1376,9 @@ LayerControlPanel::cm_sort_by_ild () { BEGIN_PROTECTED_CLEANUP - manager ()->transaction (tl::to_string (QObject::tr ("Sort layers"))); + transaction (tl::to_string (QObject::tr ("Sort layers"))); sort_layers (ByIndexLayerDatatype); - manager ()->commit (); + commit (); emit order_changed (); @@ -1388,9 +1390,9 @@ LayerControlPanel::cm_sort_by_idl () { BEGIN_PROTECTED_CLEANUP - manager ()->transaction (tl::to_string (QObject::tr ("Sort layers"))); + transaction (tl::to_string (QObject::tr ("Sort layers"))); sort_layers (ByIndexDatatypeLayer); - manager ()->commit (); + commit (); emit order_changed (); @@ -1402,9 +1404,9 @@ LayerControlPanel::cm_sort_by_ldi () { BEGIN_PROTECTED_CLEANUP - manager ()->transaction (tl::to_string (QObject::tr ("Sort layers"))); + transaction (tl::to_string (QObject::tr ("Sort layers"))); sort_layers (ByLayerDatatypeIndex); - manager ()->commit (); + commit (); emit order_changed (); @@ -1416,9 +1418,9 @@ LayerControlPanel::cm_sort_by_dli () { BEGIN_PROTECTED_CLEANUP - manager ()->transaction (tl::to_string (QObject::tr ("Sort layers"))); + transaction (tl::to_string (QObject::tr ("Sort layers"))); sort_layers (ByDatatypeLayerIndex); - manager ()->commit (); + commit (); emit order_changed (); @@ -1725,14 +1727,14 @@ LayerControlPanel::double_clicked (const QModelIndex &index, Qt::KeyboardModifie props.set_visible (! props.visible (false)); if (props.visible (false)) { - manager ()->transaction (tl::to_string (QObject::tr ("Show layer"))); + transaction (tl::to_string (QObject::tr ("Show layer"))); } else { - manager ()->transaction (tl::to_string (QObject::tr ("Hide layer"))); + transaction (tl::to_string (QObject::tr ("Hide layer"))); } mp_view->set_properties (item, props); - manager ()->commit (); + commit (); } @@ -2213,9 +2215,9 @@ LayerControlPanel::up_clicked () BEGIN_PROTECTED_CLEANUP if (mp_view) { - mp_view->manager ()->transaction (tl::to_string (QObject::tr ("Move up"))); + mp_view->transaction (tl::to_string (QObject::tr ("Move up"))); do_move (1 /*up*/); - mp_view->manager ()->commit (); + mp_view->commit (); } END_PROTECTED_CLEANUP { recover (); } @@ -2227,9 +2229,9 @@ LayerControlPanel::down_clicked () BEGIN_PROTECTED_CLEANUP if (mp_view) { - mp_view->manager ()->transaction (tl::to_string (QObject::tr ("Move down"))); + mp_view->transaction (tl::to_string (QObject::tr ("Move down"))); do_move (0 /*down*/); - mp_view->manager ()->commit (); + mp_view->commit (); } END_PROTECTED_CLEANUP { recover (); } @@ -2241,9 +2243,9 @@ LayerControlPanel::downdown_clicked () BEGIN_PROTECTED_CLEANUP if (mp_view) { - mp_view->manager ()->transaction (tl::to_string (QObject::tr ("Move fully down"))); + mp_view->transaction (tl::to_string (QObject::tr ("Move fully down"))); do_move (2 /*downdown*/); - mp_view->manager ()->commit (); + mp_view->commit (); } END_PROTECTED_CLEANUP { recover (); } @@ -2255,9 +2257,9 @@ LayerControlPanel::upup_clicked () BEGIN_PROTECTED_CLEANUP if (mp_view) { - mp_view->manager ()->transaction (tl::to_string (QObject::tr ("Move fully up"))); + mp_view->transaction (tl::to_string (QObject::tr ("Move fully up"))); do_move (3 /*upup*/); - mp_view->manager ()->commit (); + mp_view->commit (); } END_PROTECTED_CLEANUP { recover (); } diff --git a/src/laybasic/laybasic/layLayoutView.cc b/src/laybasic/laybasic/layLayoutView.cc index c3c419ff2..1bb082683 100644 --- a/src/laybasic/laybasic/layLayoutView.cc +++ b/src/laybasic/laybasic/layLayoutView.cc @@ -5778,7 +5778,7 @@ LayoutView::cm_cell_flatten () bool supports_undo = true; - if (db::transactions_enabled ()) { + if (manager () && manager ()->is_enabled ()) { lay::TipDialog td (QApplication::activeWindow (), tl::to_string (QObject::tr ("Undo buffering for the following operation can be memory and time consuming.\nChoose \"Yes\" to use undo buffering or \"No\" for no undo buffering. Warning: in the latter case, the undo history will be lost.\n\nChoose undo buffering?")), @@ -6969,7 +6969,7 @@ LayoutView::cm_copy_layer () bool supports_undo = true; - if (db::transactions_enabled ()) { + if (manager () && manager ()->is_enabled ()) { lay::TipDialog td (QApplication::activeWindow (), tl::to_string (QObject::tr ("Undo buffering for the following operation can be memory and time consuming.\nChoose \"Yes\" to use undo buffering or \"No\" for no undo buffering. Warning: in the latter case, the undo history will be lost.\n\nChoose undo buffering?")), diff --git a/src/laybasic/laybasic/layLayoutViewConfigPages.cc b/src/laybasic/laybasic/layLayoutViewConfigPages.cc index e867fe923..103631132 100644 --- a/src/laybasic/laybasic/layLayoutViewConfigPages.cc +++ b/src/laybasic/laybasic/layLayoutViewConfigPages.cc @@ -618,7 +618,7 @@ static QToolButton * (Ui::LayoutViewConfigPage4::*cfg4_buttons []) = { LayoutViewConfigPage4::LayoutViewConfigPage4 (QWidget *parent) : lay::ConfigPage (parent), - m_edit_order_changed_disabled (false) + m_manager (true), m_edit_order_changed_disabled (false) { // install the manager at db::Object manager (&m_manager); @@ -952,7 +952,7 @@ static QToolButton * (Ui::LayoutViewConfigPage6::*cfg6_buttons []) = { LayoutViewConfigPage6::LayoutViewConfigPage6 (QWidget *parent) : lay::ConfigPage (parent), - m_edit_order_changed_disabled (false) + m_manager (true), m_edit_order_changed_disabled (false) { // install the manager at db::Object manager (&m_manager); @@ -1239,7 +1239,7 @@ static QToolButton * (Ui::LayoutViewConfigPage6a::*cfg6a_buttons []) = { }; LayoutViewConfigPage6a::LayoutViewConfigPage6a (QWidget *parent) - : lay::ConfigPage (parent) + : lay::ConfigPage (parent), m_manager (true) { // install the manager at db::Object manager (&m_manager); diff --git a/src/laybasic/unit_tests/layAnnotationShapes.cc b/src/laybasic/unit_tests/layAnnotationShapes.cc index 0b56a6e9f..ca2890614 100644 --- a/src/laybasic/unit_tests/layAnnotationShapes.cc +++ b/src/laybasic/unit_tests/layAnnotationShapes.cc @@ -104,7 +104,7 @@ db::DUserObject us (const Sh &sh) TEST(1) { - db::Manager m; + db::Manager m (true); lay::AnnotationShapes s (&m); db::DBox b_empty; @@ -205,7 +205,7 @@ void read_testdata (lay::AnnotationShapes &shapes, unsigned int what = 0xff) TEST(2) { - db::Manager m; + db::Manager m (true); lay::AnnotationShapes shapes (&m); read_testdata (shapes, 0x1); @@ -244,7 +244,7 @@ TEST(2) TEST(3) { - db::Manager m; + db::Manager m (true); lay::AnnotationShapes shapes (&m); read_testdata (shapes, 0x4); @@ -283,7 +283,7 @@ TEST(3) TEST(4) { - db::Manager m; + db::Manager m (true); lay::AnnotationShapes shapes (&m); read_testdata (shapes, 0x4); @@ -333,7 +333,7 @@ TEST(4) TEST(5) { - db::Manager m; + db::Manager m (true); lay::AnnotationShapes shapes (&m); read_testdata (shapes, 0x4); @@ -369,7 +369,7 @@ TEST(5) TEST(6) { - db::Manager m; + db::Manager m (true); lay::AnnotationShapes shapes (&m); read_testdata (shapes, 0x10); @@ -396,7 +396,7 @@ TEST(6) TEST(7) { - db::Manager m; + db::Manager m (true); lay::AnnotationShapes shapes (&m); read_testdata (shapes, 0x10); diff --git a/src/laybasic/unit_tests/layLayerProperties.cc b/src/laybasic/unit_tests/layLayerProperties.cc index f796c49d8..e23ecd1e9 100644 --- a/src/laybasic/unit_tests/layLayerProperties.cc +++ b/src/laybasic/unit_tests/layLayerProperties.cc @@ -1303,7 +1303,7 @@ TEST (16) { lay::LayerPropertiesList list; - db::Manager mgr; + db::Manager mgr (true); lay::LayoutView view (&mgr, is_editable (), 0); list.attach_view (&view, 0); @@ -1355,7 +1355,7 @@ TEST (17) { lay::LayerPropertiesList list; - db::Manager mgr; + db::Manager mgr (true); lay::LayoutView view (&mgr, is_editable (), 0); list.attach_view (&view, 0); @@ -1422,7 +1422,7 @@ TEST (18) { lay::LayerPropertiesList list; - db::Manager mgr; + db::Manager mgr (true); lay::LayoutView view (&mgr, is_editable (), 0); list.attach_view (&view, 0); @@ -1490,7 +1490,7 @@ TEST (19) { lay::LayerPropertiesList list; - db::Manager mgr; + db::Manager mgr (true); lay::LayoutView view (&mgr, is_editable (), 0); list.attach_view (&view, 0); @@ -1559,7 +1559,7 @@ TEST (20) { lay::LayerPropertiesList list; - db::Manager mgr; + db::Manager mgr (true); lay::LayoutView view (&mgr, is_editable (), 0); list.attach_view (&view, 0); @@ -1631,7 +1631,7 @@ TEST (21) { lay::LayerPropertiesList list; - db::Manager mgr; + db::Manager mgr (true); lay::LayoutView view (&mgr, is_editable (), 0); list.attach_view (&view, 0); diff --git a/src/laybasic/unit_tests/laySnap.cc b/src/laybasic/unit_tests/laySnap.cc index 07201ca81..39a177a1f 100644 --- a/src/laybasic/unit_tests/laySnap.cc +++ b/src/laybasic/unit_tests/laySnap.cc @@ -27,7 +27,7 @@ TEST(1) { - db::Manager mgr; + db::Manager mgr (true); lay::LayoutView view (&mgr, is_editable (), 0); int cv1 = view.create_layout ("", true, false); diff --git a/src/plugins/streamers/cif/unit_tests/dbCIFReader.cc b/src/plugins/streamers/cif/unit_tests/dbCIFReader.cc index c347525a1..efa8dcafe 100644 --- a/src/plugins/streamers/cif/unit_tests/dbCIFReader.cc +++ b/src/plugins/streamers/cif/unit_tests/dbCIFReader.cc @@ -54,7 +54,7 @@ static void run_test (tl::TestBase *_this, const std::string &base, const char * db::LoadLayoutOptions options; options.set_options (opt); - db::Manager m; + db::Manager m (false); db::Layout layout (&m), layout2 (&m), layout2_cif (&m), layout_au (&m); { diff --git a/src/plugins/streamers/gds2/unit_tests/dbGDS2Reader.cc b/src/plugins/streamers/gds2/unit_tests/dbGDS2Reader.cc index 132b91c11..6b738f6bc 100644 --- a/src/plugins/streamers/gds2/unit_tests/dbGDS2Reader.cc +++ b/src/plugins/streamers/gds2/unit_tests/dbGDS2Reader.cc @@ -222,7 +222,7 @@ TEST(1) { tl::InputMemoryStream im ((const char *) data, sizeof (data)); - db::Manager m; + db::Manager m (false); db::Layout layout (&m); tl::InputStream file (im); db::Reader reader (file); @@ -264,7 +264,7 @@ TEST(2) { tl::InputMemoryStream im ((const char *) data, sizeof (data)); - db::Manager m; + db::Manager m (false); db::Layout layout (&m); db::LayerMap map_full; @@ -351,7 +351,7 @@ TEST(2) TEST(Bug_121_1) { - db::Manager m; + db::Manager m (false); db::Layout layout (&m); { @@ -372,7 +372,7 @@ TEST(Bug_121_1) TEST(Bug_121_2) { - db::Manager m; + db::Manager m (false); db::Layout layout (&m); { diff --git a/src/plugins/streamers/gds2/unit_tests/dbGDS2Writer.cc b/src/plugins/streamers/gds2/unit_tests/dbGDS2Writer.cc index c42911e4d..fea27aad3 100644 --- a/src/plugins/streamers/gds2/unit_tests/dbGDS2Writer.cc +++ b/src/plugins/streamers/gds2/unit_tests/dbGDS2Writer.cc @@ -33,7 +33,7 @@ void run_test (tl::TestBase *_this, const char *file, const char *file_ref, bool priv = false, const db::GDS2WriterOptions &opt = db::GDS2WriterOptions ()) { - db::Manager m; + db::Manager m (false); db::Layout layout_org (&m); { std::string fn (priv ? tl::testsrc_private () : tl::testsrc ()); @@ -85,7 +85,7 @@ TEST(1) TEST(2) { - db::Manager m; + db::Manager m (false); db::Layout layout_org (&m); db::cell_index_type cid = layout_org.add_cell ("TOP"); @@ -131,7 +131,7 @@ TEST(2) // Test the writer's capabilities to cut a polygon into small pieces correctly TEST(3) { - db::Manager m; + db::Manager m (false); db::Layout layout_org (&m); { std::string fn (tl::testsrc ()); @@ -190,7 +190,7 @@ TEST(4) { db::ShapeProcessor sp; - db::Manager m; + db::Manager m (false); db::Layout layout_org (&m); { std::string fn (tl::testsrc ()); @@ -247,7 +247,7 @@ TEST(4) TEST(100) { - db::Manager m; + db::Manager m (false); db::Layout g (&m); db::LayerProperties lp0; @@ -329,7 +329,7 @@ TEST(100) TEST(101) { - db::Manager m; + db::Manager m (false); db::Layout g (&m); db::LayerProperties lp0; @@ -401,7 +401,7 @@ TEST(101) TEST(102) { - db::Manager m; + db::Manager m (false); db::Layout g (&m); db::LayerProperties lp0; @@ -481,7 +481,7 @@ TEST(102) TEST(103) { - db::Manager m; + db::Manager m (false); db::Layout g (&m); db::LayerProperties lp0; @@ -554,7 +554,7 @@ TEST(103) TEST(110) { - db::Manager m; + db::Manager m (false); db::Layout g (&m); db::LayerProperties lp0; @@ -630,7 +630,7 @@ TEST(110) TEST(111) { - db::Manager m; + db::Manager m (false); db::Layout g (&m); db::LayerProperties lp0; @@ -703,7 +703,7 @@ TEST(111) TEST(112) { - db::Manager m; + db::Manager m (false); db::Layout g (&m); db::LayerProperties lp0; @@ -780,7 +780,7 @@ TEST(112) TEST(113) { - db::Manager m; + db::Manager m (false); db::Layout g (&m); db::LayerProperties lp0; @@ -856,7 +856,7 @@ TEST(114) { // text alignment flags, font and text size - db::Manager m; + db::Manager m (false); db::Layout g (&m); db::LayerProperties lp0; @@ -946,7 +946,7 @@ TEST(115) { // polygons and boxes without area - db::Manager m; + db::Manager m (false); db::Layout g (&m); db::LayerProperties lp1; @@ -1012,7 +1012,7 @@ TEST(116) { // big paths with multi-xy - db::Manager m; + db::Manager m (false); db::Layout g (&m); db::LayerProperties lp1; @@ -1073,7 +1073,7 @@ TEST(117) { // big polygons with multi-xy - db::Manager m; + db::Manager m (false); db::Layout g (&m); db::LayerProperties lp1; diff --git a/src/plugins/streamers/lefdef/unit_tests/dbLEFDEFImport.cc b/src/plugins/streamers/lefdef/unit_tests/dbLEFDEFImport.cc index 315a5fc34..7dcdfa686 100644 --- a/src/plugins/streamers/lefdef/unit_tests/dbLEFDEFImport.cc +++ b/src/plugins/streamers/lefdef/unit_tests/dbLEFDEFImport.cc @@ -47,7 +47,7 @@ static void run_test (tl::TestBase *_this, const char *lef_dir, const char *file tc.set_blockages_suffix (".BLK"); db::LEFDEFLayerDelegate ld (&tc); - db::Manager m; + db::Manager m (false); db::Layout layout (&m), layout2 (&m), layout_au (&m); tl::Extractor ex (filename); diff --git a/src/plugins/streamers/magic/unit_tests/dbMAGReader.cc b/src/plugins/streamers/magic/unit_tests/dbMAGReader.cc index e295b6bec..64ce8e3e1 100644 --- a/src/plugins/streamers/magic/unit_tests/dbMAGReader.cc +++ b/src/plugins/streamers/magic/unit_tests/dbMAGReader.cc @@ -57,7 +57,7 @@ static void run_test (tl::TestBase *_this, const std::string &base, const char * db::LoadLayoutOptions options; options.set_options (opt); - db::Manager m; + db::Manager m (false); db::Layout layout (&m), layout2 (&m), layout2_mag (&m), layout_au (&m); { diff --git a/src/plugins/streamers/oasis/unit_tests/dbOASISReader.cc b/src/plugins/streamers/oasis/unit_tests/dbOASISReader.cc index 4f895efe5..8534e0ab4 100644 --- a/src/plugins/streamers/oasis/unit_tests/dbOASISReader.cc +++ b/src/plugins/streamers/oasis/unit_tests/dbOASISReader.cc @@ -81,7 +81,7 @@ compare_ref (tl::TestBase *_this, const char *test, const db::Layout &layout) void run_test (tl::TestBase *_this, const char *test) { - db::Manager m; + db::Manager m (false); db::Layout layout (&m); std::string fn (tl::testsrc ()); fn += "/testdata/oasis/t"; @@ -106,7 +106,7 @@ run_test (tl::TestBase *_this, const char *test) void run_test_error (tl::TestBase *_this, const char *test, const char *msg_au) { - db::Manager m; + db::Manager m (false); db::Layout layout (&m); std::string fn (tl::testsrc ()); fn += "/testdata/oasis/t"; @@ -435,7 +435,7 @@ TEST(99) "end_lib\n" ; - db::Manager m; + db::Manager m (false); db::Layout layout (&m); { @@ -518,7 +518,7 @@ TEST(100) "end_lib\n" ; - db::Manager m; + db::Manager m (false); db::Layout layout (&m); { @@ -540,7 +540,7 @@ TEST(100) TEST(Bug_121_1) { - db::Manager m; + db::Manager m (false); db::Layout layout (&m); { @@ -561,7 +561,7 @@ TEST(Bug_121_1) TEST(Bug_121_2) { - db::Manager m; + db::Manager m (false); db::Layout layout (&m); { diff --git a/src/plugins/streamers/oasis/unit_tests/dbOASISWriter.cc b/src/plugins/streamers/oasis/unit_tests/dbOASISWriter.cc index d668159ff..ce4f6c479 100644 --- a/src/plugins/streamers/oasis/unit_tests/dbOASISWriter.cc +++ b/src/plugins/streamers/oasis/unit_tests/dbOASISWriter.cc @@ -36,7 +36,7 @@ void run_test (tl::TestBase *_this, const char *file, bool scaling_test, int compr, bool recompress) { { - db::Manager m; + db::Manager m (false); db::Layout layout_org (&m); std::string fn (tl::testsrc ()); fn += "/testdata/oasis/"; @@ -81,7 +81,7 @@ void run_test (tl::TestBase *_this, const char *file, bool scaling_test, int com } { - db::Manager m; + db::Manager m (false); db::Layout layout_org (&m); std::string fn (tl::testsrc ()); fn += "/testdata/oasis/"; @@ -137,7 +137,7 @@ void run_test (tl::TestBase *_this, const char *file, bool scaling_test, int com } { - db::Manager m; + db::Manager m (false); db::Layout layout_org (&m); std::string fn (tl::testsrc ()); fn += "/testdata/oasis/"; @@ -186,7 +186,7 @@ void run_test (tl::TestBase *_this, const char *file, bool scaling_test, int com } { - db::Manager m; + db::Manager m (false); db::Layout layout_org (&m); std::string fn (tl::testsrc ()); fn += "/testdata/oasis/"; @@ -237,7 +237,7 @@ void run_test (tl::TestBase *_this, const char *file, bool scaling_test, int com if (scaling_test) { - db::Manager m; + db::Manager m (false); db::Layout layout (&m); std::string fn (tl::testsrc ()); fn += "/testdata/oasis/"; @@ -513,7 +513,7 @@ TEST(40) TEST(100) { - db::Manager m; + db::Manager m (false); db::Layout g (&m); db::LayerProperties lp0; @@ -596,7 +596,7 @@ TEST(100) TEST(101) { - db::Manager m; + db::Manager m (false); db::Layout g (&m); db::LayerProperties lp0; @@ -669,7 +669,7 @@ TEST(101) TEST(102) { - db::Manager m; + db::Manager m (false); db::Layout g (&m); db::LayerProperties lp0; @@ -750,7 +750,7 @@ TEST(102) TEST(103) { - db::Manager m; + db::Manager m (false); db::Layout g (&m); db::LayerProperties lp0; @@ -824,7 +824,7 @@ TEST(103) TEST(110) { - db::Manager m; + db::Manager m (false); db::Layout g (&m); db::LayerProperties lp0; @@ -901,7 +901,7 @@ TEST(110) TEST(111) { - db::Manager m; + db::Manager m (false); db::Layout g (&m); db::LayerProperties lp0; @@ -975,7 +975,7 @@ TEST(111) TEST(112) { - db::Manager m; + db::Manager m (false); db::Layout g (&m); db::LayerProperties lp0; @@ -1053,7 +1053,7 @@ TEST(112) TEST(113) { - db::Manager m; + db::Manager m (false); db::Layout g (&m); db::LayerProperties lp0; @@ -1127,7 +1127,7 @@ TEST(113) TEST(114) { - db::Manager m; + db::Manager m (false); db::Layout g (&m); db::LayerProperties lp1; @@ -1182,7 +1182,7 @@ TEST(114) TEST(115) { - db::Manager m; + db::Manager m (false); db::Layout g (&m); db::property_names_id_type n1, n2, n3; @@ -1262,7 +1262,7 @@ TEST(115) TEST(116) { - db::Manager m; + db::Manager m (false); db::Layout g (&m); db::property_names_id_type n1, n2, n3; @@ -1612,7 +1612,7 @@ TEST(117) { // polygons and boxes without area - db::Manager m; + db::Manager m (false); db::Layout g (&m); db::LayerProperties lp1; @@ -1679,7 +1679,7 @@ TEST(118) { // 1x1 arrays (#902) - db::Manager m; + db::Manager m (false); db::Layout g (&m); db::LayerProperties lp1; @@ -1734,7 +1734,7 @@ TEST(119_WithAndWithoutContext) { // PCells with context and without - db::Manager m; + db::Manager m (false); db::Layout g (&m); // Note: this sample requires the BASIC lib diff --git a/src/plugins/streamers/oasis/unit_tests/dbOASISWriter2.cc b/src/plugins/streamers/oasis/unit_tests/dbOASISWriter2.cc index 046d9cba8..35c93b04d 100644 --- a/src/plugins/streamers/oasis/unit_tests/dbOASISWriter2.cc +++ b/src/plugins/streamers/oasis/unit_tests/dbOASISWriter2.cc @@ -34,7 +34,7 @@ TEST(1) { db::ShapeProcessor sp; - db::Manager m; + db::Manager m (false); db::Layout layout_org (&m); { std::string fn (tl::testsrc ()); diff --git a/src/plugins/tools/bool/lay_plugin/layBooleanOperationsPlugin.cc b/src/plugins/tools/bool/lay_plugin/layBooleanOperationsPlugin.cc index 201b69fa0..aec42598b 100644 --- a/src/plugins/tools/bool/lay_plugin/layBooleanOperationsPlugin.cc +++ b/src/plugins/tools/bool/lay_plugin/layBooleanOperationsPlugin.cc @@ -107,7 +107,7 @@ public: bool supports_undo = true; - if (db::transactions_enabled ()) { + if (mp_view->manager () && mp_view->manager ()->is_enabled ()) { lay::TipDialog td (QApplication::activeWindow (), tl::to_string (QObject::tr ("Undo buffering for the following operation can be memory and time consuming.\nChoose \"Yes\" to use undo buffering or \"No\" for no undo buffering. Warning: in the latter case, the undo history will be lost.\n\nChoose undo buffering?")), @@ -244,7 +244,7 @@ public: bool supports_undo = true; - if (db::transactions_enabled ()) { + if (mp_view->manager () && mp_view->manager ()->is_enabled ()) { lay::TipDialog td (QApplication::activeWindow (), tl::to_string (QObject::tr ("Undo buffering for the following operation can be memory and time consuming.\nChoose \"Yes\" to use undo buffering or \"No\" for no undo buffering. Warning: in the latter case, the undo history will be lost.\n\nChoose undo buffering?")), @@ -359,7 +359,7 @@ public: bool supports_undo = true; - if (db::transactions_enabled ()) { + if (mp_view->manager () && mp_view->manager ()->is_enabled ()) { lay::TipDialog td (QApplication::activeWindow (), tl::to_string (QObject::tr ("Undo buffering for the following operation can be memory and time consuming.\nChoose \"Yes\" to use undo buffering or \"No\" for no undo buffering. Warning: in the latter case, the undo history will be lost.\n\nChoose undo buffering?")), diff --git a/src/plugins/tools/net_tracer/unit_tests/dbNetTracer.cc b/src/plugins/tools/net_tracer/unit_tests/dbNetTracer.cc index dfb204650..bc300797a 100644 --- a/src/plugins/tools/net_tracer/unit_tests/dbNetTracer.cc +++ b/src/plugins/tools/net_tracer/unit_tests/dbNetTracer.cc @@ -92,7 +92,7 @@ static db::NetTracerNet trace (db::NetTracer &tracer, const db::Layout &layout, void run_test (tl::TestBase *_this, const std::string &file, const db::NetTracerTechnologyComponent &tc, const db::LayerProperties &lp_start, const db::Point &p_start, const std::string &file_au, const char *net_name = 0) { - db::Manager m; + db::Manager m (false); db::Layout layout_org (&m); { @@ -126,7 +126,7 @@ void run_test (tl::TestBase *_this, const std::string &file, const db::NetTracer void run_test2 (tl::TestBase *_this, const std::string &file, const db::NetTracerTechnologyComponent &tc, const db::LayerProperties &lp_start, const db::Point &p_start, const db::LayerProperties &lp_stop, const db::Point &p_stop, const std::string &file_au, const char *net_name = 0) { - db::Manager m; + db::Manager m (false); db::Layout layout_org (&m); { diff --git a/src/plugins/tools/net_tracer/unit_tests/dbTraceAllNets.cc b/src/plugins/tools/net_tracer/unit_tests/dbTraceAllNets.cc index 6bdc7f453..949c083cc 100644 --- a/src/plugins/tools/net_tracer/unit_tests/dbTraceAllNets.cc +++ b/src/plugins/tools/net_tracer/unit_tests/dbTraceAllNets.cc @@ -52,7 +52,7 @@ static db::NetTracerSymbolInfo symbol (const std::string &s, const std::string & void run_test (tl::TestBase *_this, const std::string &file, const db::NetTracerTechnologyComponent &tc, const std::string &file_au) { - db::Manager m; + db::Manager m (false); db::Layout layout_org (&m); { From 22b3a5faced064621b61ed8369e8678c07bbd95f Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Tue, 4 Feb 2020 21:33:14 +0100 Subject: [PATCH 03/32] WIP: refactoring - at least some local context menus for detached views --- src/ant/ant/antPlugin.cc | 10 ++++++---- src/edt/edt/edtPlugin.cc | 6 +++--- src/lay/lay/layTechnologyController.cc | 4 ++-- src/laybasic/laybasic/layBookmarksView.cc | 6 ++++-- .../laybasic/layHierarchyControlPanel.cc | 6 ++++-- src/laybasic/laybasic/layLayerControlPanel.cc | 12 ++++++++---- src/laybasic/laybasic/layLayoutView.cc | 17 +++++++++++++++++ src/laybasic/laybasic/layLayoutView.h | 9 +++++++++ src/laybasic/laybasic/layLibrariesView.cc | 6 ++++-- 9 files changed, 57 insertions(+), 19 deletions(-) diff --git a/src/ant/ant/antPlugin.cc b/src/ant/ant/antPlugin.cc index af283337f..5a9391fff 100644 --- a/src/ant/ant/antPlugin.cc +++ b/src/ant/ant/antPlugin.cc @@ -150,10 +150,6 @@ PluginDeclaration::configure (const std::string &name, const std::string &value) void PluginDeclaration::config_finalize () { - if (!lay::AbstractMenuProvider::instance ()) { - return; - } - if (m_templates_updated) { update_menu (); @@ -217,6 +213,9 @@ void PluginDeclaration::update_current_template () { lay::AbstractMenuProvider *mp = lay::AbstractMenuProvider::instance (); + if (! mp || ! mp->menu ()) { + return; + } if (m_current_template >= 0 && m_current_template < int (m_templates.size ())) { @@ -240,6 +239,9 @@ void PluginDeclaration::update_menu () { lay::AbstractMenuProvider *mp = lay::AbstractMenuProvider::instance (); + if (! mp || ! mp->menu ()) { + return; + } if (m_current_template < 0 || m_current_template >= int (m_templates.size ())) { m_current_template = 0; diff --git a/src/edt/edt/edtPlugin.cc b/src/edt/edt/edtPlugin.cc index dae12d5af..38c2c9fd4 100644 --- a/src/edt/edt/edtPlugin.cc +++ b/src/edt/edt/edtPlugin.cc @@ -273,7 +273,7 @@ public: virtual void initialize (lay::PluginRoot *root) { lay::AbstractMenuProvider *mp = lay::AbstractMenuProvider::instance (); - if (! mp) { + if (! mp || ! mp->menu ()) { return; } @@ -312,7 +312,7 @@ public: void update_menu (combine_mode_type cm) { lay::AbstractMenuProvider *mp = lay::AbstractMenuProvider::instance (); - if (! mp) { + if (! mp || ! mp->menu ()) { return; } @@ -375,7 +375,7 @@ public: void initialized (lay::PluginRoot *root) { lay::AbstractMenuProvider *mp = lay::AbstractMenuProvider::instance (); - if (! mp) { + if (! mp || ! mp->menu ()) { return; } diff --git a/src/lay/lay/layTechnologyController.cc b/src/lay/lay/layTechnologyController.cc index ab637df3a..66efa75eb 100644 --- a/src/lay/lay/layTechnologyController.cc +++ b/src/lay/lay/layTechnologyController.cc @@ -299,7 +299,7 @@ void TechnologyController::update_current_technology () { lay::AbstractMenuProvider *pr = lay::AbstractMenuProvider::instance (); - if (! pr) { + if (! pr || ! pr->menu ()) { return; } @@ -326,7 +326,7 @@ void TechnologyController::update_menu () { lay::AbstractMenuProvider *pr = lay::AbstractMenuProvider::instance (); - if (! pr) { + if (! pr || ! pr->menu ()) { return; } diff --git a/src/laybasic/laybasic/layBookmarksView.cc b/src/laybasic/laybasic/layBookmarksView.cc index 3313f5a61..57831e651 100644 --- a/src/laybasic/laybasic/layBookmarksView.cc +++ b/src/laybasic/laybasic/layBookmarksView.cc @@ -182,11 +182,13 @@ BookmarksView::refresh () void BookmarksView::context_menu (const QPoint &p) { - tl_assert (lay::AbstractMenuProvider::instance () != 0); + if (! mp_view->menu ()) { + return; + } QListView *bm_list = dynamic_cast (sender ()); if (bm_list) { - QMenu *ctx_menu = lay::AbstractMenuProvider::instance ()->menu ()->detached_menu ("bookmarks_context_menu"); + QMenu *ctx_menu = mp_view->menu ()->detached_menu ("bookmarks_context_menu"); ctx_menu->exec (bm_list->mapToGlobal (p)); } } diff --git a/src/laybasic/laybasic/layHierarchyControlPanel.cc b/src/laybasic/laybasic/layHierarchyControlPanel.cc index fc4930f25..304445681 100644 --- a/src/laybasic/laybasic/layHierarchyControlPanel.cc +++ b/src/laybasic/laybasic/layHierarchyControlPanel.cc @@ -370,12 +370,14 @@ HierarchyControlPanel::event (QEvent *e) void HierarchyControlPanel::context_menu (const QPoint &p) { - tl_assert (lay::AbstractMenuProvider::instance () != 0); + if (! mp_view->menu ()) { + return; + } QTreeView *cell_list = dynamic_cast (sender ()); if (cell_list) { set_active_celltree_from_sender (); - QMenu *ctx_menu = lay::AbstractMenuProvider::instance ()->menu ()->detached_menu ("hcp_context_menu"); + QMenu *ctx_menu = mp_view->menu ()->detached_menu ("hcp_context_menu"); ctx_menu->exec (cell_list->mapToGlobal (p)); } } diff --git a/src/laybasic/laybasic/layLayerControlPanel.cc b/src/laybasic/laybasic/layLayerControlPanel.cc index 844b53128..152862370 100644 --- a/src/laybasic/laybasic/layLayerControlPanel.cc +++ b/src/laybasic/laybasic/layLayerControlPanel.cc @@ -1686,9 +1686,11 @@ LayerControlPanel::cm_expand_all () void LayerControlPanel::tab_context_menu (const QPoint &p) { - tl_assert (lay::AbstractMenuProvider::instance () != 0); + if (! mp_view->menu ()) { + return; + } - QMenu *ctx_menu = lay::AbstractMenuProvider::instance ()->menu ()->detached_menu ("lcp_tabs_context_menu"); + QMenu *ctx_menu = mp_view->menu ()->detached_menu ("lcp_tabs_context_menu"); if (ctx_menu) { ctx_menu->exec (mp_tab_bar->mapToGlobal (p)); } @@ -1697,9 +1699,11 @@ LayerControlPanel::tab_context_menu (const QPoint &p) void LayerControlPanel::context_menu (const QPoint &p) { - tl_assert (lay::AbstractMenuProvider::instance () != 0); + if (! mp_view->menu ()) { + return; + } - QMenu *ctx_menu = lay::AbstractMenuProvider::instance ()->menu ()->detached_menu ("lcp_context_menu"); + QMenu *ctx_menu = mp_view->menu ()->detached_menu ("lcp_context_menu"); if (ctx_menu) { ctx_menu->exec (mp_layer_list->mapToGlobal (p)); } diff --git a/src/laybasic/laybasic/layLayoutView.cc b/src/laybasic/laybasic/layLayoutView.cc index 1bb082683..7d14bd803 100644 --- a/src/laybasic/laybasic/layLayoutView.cc +++ b/src/laybasic/laybasic/layLayoutView.cc @@ -44,6 +44,7 @@ #include "tlAssert.h" #include "tlExceptions.h" #include "layLayoutView.h" +#include "layAbstractMenuProvider.h" #include "layViewOp.h" #include "layViewObject.h" #include "layLayoutViewConfigPages.h" @@ -255,6 +256,7 @@ static LayoutView *ms_current = 0; LayoutView::LayoutView (db::Manager *manager, bool editable, lay::Plugin *plugin_parent, QWidget *parent, const char *name, unsigned int options) : QFrame (parent), lay::Plugin (plugin_parent), + m_menu (0), m_editable (editable), m_options (options), m_annotation_shapes (manager), @@ -270,6 +272,7 @@ LayoutView::LayoutView (db::Manager *manager, bool editable, lay::Plugin *plugin LayoutView::LayoutView (lay::LayoutView *source, db::Manager *manager, bool editable, lay::PluginRoot *root, QWidget *parent, const char *name, unsigned int options) : QFrame (parent), lay::Plugin (root), + m_menu (0), m_editable (editable), m_options (options), m_annotation_shapes (manager), @@ -348,6 +351,10 @@ LayoutView::init (db::Manager *mgr, lay::PluginRoot *root, QWidget * /*parent*/) { manager (mgr); + if (! lay::AbstractMenuProvider::instance () || ! lay::AbstractMenuProvider::instance ()->menu ()) { + init_menu (m_menu); + } + m_annotation_shapes.manager (mgr); m_visibility_changed = false; @@ -6461,6 +6468,16 @@ LayoutView::intrinsic_mouse_modes (std::vector *descriptions) return 2; } +AbstractMenu * +LayoutView::menu () +{ + if (lay::AbstractMenuProvider::instance () && lay::AbstractMenuProvider::instance ()->menu ()) { + return lay::AbstractMenuProvider::instance ()->menu (); + } else { + return &m_menu; + } +} + int LayoutView::default_mode () { diff --git a/src/laybasic/laybasic/layLayoutView.h b/src/laybasic/laybasic/layLayoutView.h index feab2526a..fe7e34e1d 100644 --- a/src/laybasic/laybasic/layLayoutView.h +++ b/src/laybasic/laybasic/layLayoutView.h @@ -36,6 +36,7 @@ #include #include "layLayerProperties.h" +#include "layAbstractMenu.h" #include "layAnnotationShapes.h" #include "layLayoutCanvas.h" #include "layColorPalette.h" @@ -1666,6 +1667,12 @@ public: */ static void update_menu (lay::LayoutView *view, lay::AbstractMenu &menu); + /** + * @brief Get the menu abstraction object + * This is either the global abstract menu or a view-local one if the view is not embedded into a main window. + */ + AbstractMenu *menu (); + /** * @brief Query the default mode */ @@ -2750,6 +2757,8 @@ protected: void activate (); private: + lay::AbstractMenu m_menu; + bool m_editable; int m_disabled_edits; unsigned int m_options; diff --git a/src/laybasic/laybasic/layLibrariesView.cc b/src/laybasic/laybasic/layLibrariesView.cc index 58b4c0737..ad8d84346 100644 --- a/src/laybasic/laybasic/layLibrariesView.cc +++ b/src/laybasic/laybasic/layLibrariesView.cc @@ -338,11 +338,13 @@ LibrariesView::event (QEvent *e) void LibrariesView::context_menu (const QPoint &p) { - tl_assert (lay::AbstractMenuProvider::instance () != 0); + if (! mp_view->menu ()) { + return; + } QTreeView *cell_list = dynamic_cast (sender ()); if (cell_list) { - QMenu *ctx_menu = lay::AbstractMenuProvider::instance ()->menu ()->detached_menu ("lib_context_menu"); + QMenu *ctx_menu = mp_view->menu ()->detached_menu ("lib_context_menu"); ctx_menu->exec (cell_list->mapToGlobal (p)); } } From b2e6085ba1c390684f5da5951b1df2022be4f9e3 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Tue, 4 Feb 2020 23:54:29 +0100 Subject: [PATCH 04/32] WIP: not quite further ... --- src/laybasic/laybasic/layAbstractMenu.cc | 55 ++++++++------ src/laybasic/laybasic/layAbstractMenu.h | 4 +- .../laybasic/layAbstractMenuProvider.cc | 4 +- .../laybasic/layAbstractMenuProvider.h | 7 +- src/laybasic/laybasic/layLayoutView.cc | 75 ++++++++++++++++++- src/laybasic/laybasic/layLayoutView.h | 31 ++++++-- src/laybasic/laybasic/layPlugin.cc | 15 ++-- src/laybasic/laybasic/layPlugin.h | 2 +- 8 files changed, 147 insertions(+), 46 deletions(-) diff --git a/src/laybasic/laybasic/layAbstractMenu.cc b/src/laybasic/laybasic/layAbstractMenu.cc index cad1e30a6..5c0089904 100644 --- a/src/laybasic/laybasic/layAbstractMenu.cc +++ b/src/laybasic/laybasic/layAbstractMenu.cc @@ -590,7 +590,7 @@ Action::no_shortcut () Action::Action (const std::string &title) { - mp_handle = AbstractMenu::create_action (title); + mp_handle = AbstractMenu::create_action (title, 0); gtf::action_connect (mp_handle->ptr (), SIGNAL (triggered ()), this, SLOT (triggered_slot ())); mp_handle->add_ref (); } @@ -1008,9 +1008,12 @@ ConfigureAction::configure (const std::string &value) // AbstractMenu implementation ActionHandle * -AbstractMenu::create_action (const std::string &s) +AbstractMenu::create_action (const std::string &s, AbstractMenuProvider *provider) { - tl_assert (lay::AbstractMenuProvider::instance () != 0); + if (! provider) { + provider = lay::AbstractMenuProvider::instance (); + } + tl_assert (provider != 0); std::string title; std::string shortcut; @@ -1019,7 +1022,7 @@ AbstractMenu::create_action (const std::string &s) parse_menu_title (s, title, shortcut, res, tool_tip); - ActionHandle *ah = new ActionHandle (lay::AbstractMenuProvider::instance ()->menu_parent_widget ()); + ActionHandle *ah = new ActionHandle (provider->menu_parent_widget ()); ah->ptr ()->setText (tl::to_qstring (title)); if (! tool_tip.empty ()) { @@ -1129,15 +1132,17 @@ AbstractMenu::build_detached (const std::string &name, QFrame *mbar) void AbstractMenu::build (QMenuBar *mbar, QToolBar *tbar) { - tl_assert (mp_provider != 0); - m_helper_menu_items.clear (); - tbar->clear (); + if (tbar) { + tbar->clear (); + } std::set > present_actions; - QList a = mbar->actions (); - for (QList::const_iterator i = a.begin (); i != a.end (); ++i) { - present_actions.insert (std::make_pair (id_from_action (*i), *i)); + if (mbar) { + QList a = mbar->actions (); + for (QList::const_iterator i = a.begin (); i != a.end (); ++i) { + present_actions.insert (std::make_pair (id_from_action (*i), *i)); + } } for (std::list::iterator c = m_root.children.begin (); c != m_root.children.end (); ++c) { @@ -1146,7 +1151,9 @@ AbstractMenu::build (QMenuBar *mbar, QToolBar *tbar) if (c->name () == "@toolbar") { - build (tbar, c->children); + if (tbar) { + build (tbar, c->children); + } } else if (c->name ().find ("@@") == 0) { @@ -1160,14 +1167,16 @@ AbstractMenu::build (QMenuBar *mbar, QToolBar *tbar) // Otherwise, the keyboard shortcuts do not work for menu items inside such a // popup menu. It seems not to have a negative effect to add the menu to the // main widget. - mp_provider->menu_parent_widget ()->addAction (menu->menuAction ()); + if (mp_provider) { + mp_provider->menu_parent_widget ()->addAction (menu->menuAction ()); + } c->set_action (Action (new ActionHandle (menu)), true); } // prepare a detached menu which can be used as context menues build (c->menu (), c->children); - } else { + } else if (mbar) { if (c->menu () == 0) { QMenu *menu = new QMenu (); @@ -1192,7 +1201,7 @@ AbstractMenu::build (QMenuBar *mbar, QToolBar *tbar) } - } else { + } else if (mbar) { // Move the action to the end if present in the menu already std::set >::iterator a = present_actions.find (std::make_pair (id_from_action (c->action ().qaction ()), c->action ().qaction ())); if (a != present_actions.end ()) { @@ -1209,8 +1218,10 @@ AbstractMenu::build (QMenuBar *mbar, QToolBar *tbar) } // Remove all actions that have vanished - for (std::set >::iterator a = present_actions.begin (); a != present_actions.end (); ++a) { - mbar->removeAction (a->second); + if (mbar) { + for (std::set >::iterator a = present_actions.begin (); a != present_actions.end (); ++a) { + mbar->removeAction (a->second); + } } } @@ -1399,8 +1410,6 @@ AbstractMenu::insert_item (const std::string &p, const std::string &name, const void AbstractMenu::insert_separator (const std::string &p, const std::string &name) { - tl_assert (mp_provider != 0); // required to get the parent for the new QAction (via ActionHandle) - typedef std::vector::iterator > > path_type; path_type path = find_item (p); if (! path.empty ()) { @@ -1410,7 +1419,7 @@ AbstractMenu::insert_separator (const std::string &p, const std::string &name) parent->children.insert (iter, AbstractMenuItem ()); --iter; - Action action (new ActionHandle (mp_provider->menu_parent_widget ())); + Action action (new ActionHandle (mp_provider ? mp_provider->menu_parent_widget () : 0)); action.set_separator (true); iter->setup_item (parent->name (), name, action); @@ -1452,7 +1461,7 @@ AbstractMenu::insert_menu (const std::string &p, const std::string &name, const void AbstractMenu::insert_menu (const std::string &path, const std::string &name, const std::string &title) { - insert_menu (path, name, create_action (title)); + insert_menu (path, name, create_action (title, mp_provider)); } void @@ -1715,8 +1724,6 @@ AbstractMenu::find_item (const std::string &p) void AbstractMenu::transfer (const MenuLayoutEntry *layout, AbstractMenuItem &item) { - tl_assert (mp_provider != 0); - while (layout->name) { item.children.push_back (AbstractMenuItem ()); @@ -1724,7 +1731,9 @@ AbstractMenu::transfer (const MenuLayoutEntry *layout, AbstractMenuItem &item) lay::Action a; - if (layout->slot) { + if (! mp_provider) { + a = lay::Action (new ActionHandle ((QWidget *) 0)); + } else if (layout->slot) { // reuse any actions already registered for this slot a = mp_provider->action_for_slot (layout->slot); } else if (! layout->kv_pair.first.empty ()) { diff --git a/src/laybasic/laybasic/layAbstractMenu.h b/src/laybasic/laybasic/layAbstractMenu.h index d919cc9cc..588d60afd 100644 --- a/src/laybasic/laybasic/layAbstractMenu.h +++ b/src/laybasic/laybasic/layAbstractMenu.h @@ -887,10 +887,10 @@ private: * The format of the string is: ["("shortcut")"]["<"icon-resource">"] * * @param s The title, key and icon resource string in the format given above - * @param parent The widget to which to attach the QAction object + * @param provider The abstract menu provider (the global one will be used if this instance is 0) * @return The ActionHandle object created */ - static ActionHandle *create_action (const std::string &s); + static ActionHandle *create_action (const std::string &s, lay::AbstractMenuProvider *provider); AbstractMenuProvider *mp_provider; AbstractMenuItem m_root; diff --git a/src/laybasic/laybasic/layAbstractMenuProvider.cc b/src/laybasic/laybasic/layAbstractMenuProvider.cc index 2b7a90ce2..543a6f84e 100644 --- a/src/laybasic/laybasic/layAbstractMenuProvider.cc +++ b/src/laybasic/laybasic/layAbstractMenuProvider.cc @@ -28,9 +28,9 @@ namespace lay static AbstractMenuProvider *ms_instance = 0; -AbstractMenuProvider::AbstractMenuProvider () +AbstractMenuProvider::AbstractMenuProvider (bool reg_inst) { - if (! ms_instance) { + if (reg_inst && ! ms_instance) { ms_instance = this; } } diff --git a/src/laybasic/laybasic/layAbstractMenuProvider.h b/src/laybasic/laybasic/layAbstractMenuProvider.h index 6f16521bb..4c2d6b26e 100644 --- a/src/laybasic/laybasic/layAbstractMenuProvider.h +++ b/src/laybasic/laybasic/layAbstractMenuProvider.h @@ -45,8 +45,9 @@ class LAYBASIC_PUBLIC AbstractMenuProvider public: /** * @brief Constructor + * If "reg_inst" is true, this instance will become the global instance */ - AbstractMenuProvider (); + AbstractMenuProvider (bool reg_inst = true); /** * @brief Destructor @@ -71,14 +72,14 @@ public: /** * @brief Create a configuration action with the given title, parameter name and value * - * The action will be owned by the main window but can be deleted to remove the action from the main window. + * The action will be owned by the abstract menu provider but can be deleted to remove it from there. */ virtual lay::Action *create_config_action (const std::string &title, const std::string &cname, const std::string &cvalue) = 0; /** * @brief Create a configuration action with the given parameter name and value * - * The action will be owned by the main window but can be deleted to remove the action from the main window. + * The action will be owned by the abstract menu provider but can be deleted to remove it from there. * This version is provided for applications, where the title is set later. */ virtual lay::Action *create_config_action (const std::string &cname, const std::string &cvalue) = 0; diff --git a/src/laybasic/laybasic/layLayoutView.cc b/src/laybasic/laybasic/layLayoutView.cc index 7d14bd803..33845acd0 100644 --- a/src/laybasic/laybasic/layLayoutView.cc +++ b/src/laybasic/laybasic/layLayoutView.cc @@ -256,23 +256,29 @@ static LayoutView *ms_current = 0; LayoutView::LayoutView (db::Manager *manager, bool editable, lay::Plugin *plugin_parent, QWidget *parent, const char *name, unsigned int options) : QFrame (parent), lay::Plugin (plugin_parent), - m_menu (0), + lay::AbstractMenuProvider (false /* don't register as global instance */), + m_menu (this), m_editable (editable), m_options (options), m_annotation_shapes (manager), dm_prop_changed (this, &LayoutView::do_prop_changed) { + if (! plugin_root_maybe_null ()) { + mp_plugin_root.reset (new lay::PluginRoot (true, false)); + } + // ensures the deferred method scheduler is present tl::DeferredMethodScheduler::instance (); setObjectName (QString::fromUtf8 (name)); - init (manager, plugin_root_maybe_null (), parent); + init (manager, plugin_root_maybe_null () ? plugin_root_maybe_null () : mp_plugin_root.get (), parent); } LayoutView::LayoutView (lay::LayoutView *source, db::Manager *manager, bool editable, lay::PluginRoot *root, QWidget *parent, const char *name, unsigned int options) : QFrame (parent), lay::Plugin (root), - m_menu (0), + lay::AbstractMenuProvider (false /* don't register as global instance */), + m_menu (this), m_editable (editable), m_options (options), m_annotation_shapes (manager), @@ -353,6 +359,8 @@ LayoutView::init (db::Manager *mgr, lay::PluginRoot *root, QWidget * /*parent*/) if (! lay::AbstractMenuProvider::instance () || ! lay::AbstractMenuProvider::instance ()->menu ()) { init_menu (m_menu); + // build the context menus, nothing else so far. + m_menu.build (0, 0); } m_annotation_shapes.manager (mgr); @@ -691,6 +699,67 @@ LayoutView::~LayoutView () mp_bookmarks_view = 0; } +QWidget *LayoutView::menu_parent_widget () +{ + return this; +} + +lay::Action & +LayoutView::action_for_slot (const char *slot) +{ + std::map::iterator a = m_actions_for_slot.find (std::string (slot)); + if (a != m_actions_for_slot.end ()) { + return a->second; + } else { + Action a = Action::create_free_action (this); + gtf::action_connect (a.qaction (), SIGNAL (triggered ()), this, slot); + return m_actions_for_slot.insert (std::make_pair (std::string (slot), a)).first->second; + } +} + +lay::Action * +LayoutView::create_config_action (const std::string &title, const std::string &cname, const std::string &cvalue) +{ + lay::ConfigureAction *ca = new lay::ConfigureAction(plugin_root (), title, cname, cvalue); + m_ca_collection.push_back (ca); + return ca; +} + +lay::Action * +LayoutView::create_config_action (const std::string &cname, const std::string &cvalue) +{ + lay::ConfigureAction *ca = new lay::ConfigureAction(plugin_root (), std::string (), cname, cvalue); + m_ca_collection.push_back (ca); + return ca; +} + +void +LayoutView::register_config_action (const std::string &name, lay::ConfigureAction *action) +{ + std::map >::iterator ca = m_configuration_actions.insert (std::make_pair (name, std::vector ())).first; + for (std::vector::iterator a = ca->second.begin (); a != ca->second.end (); ++a) { + if (*a == action) { + return; // already registered + } + } + + ca->second.push_back (action); +} + +void +LayoutView::unregister_config_action (const std::string &name, lay::ConfigureAction *action) +{ + std::map >::iterator ca = m_configuration_actions.find (name); + if (ca != m_configuration_actions.end ()) { + for (std::vector::iterator a = ca->second.begin (); a != ca->second.end (); ++a) { + if (*a == action) { + ca->second.erase (a); + return; + } + } + } +} + void LayoutView::side_panel_destroyed () { if (sender () == mp_control_frame) { diff --git a/src/laybasic/laybasic/layLayoutView.h b/src/laybasic/laybasic/layLayoutView.h index fe7e34e1d..f3fa53245 100644 --- a/src/laybasic/laybasic/layLayoutView.h +++ b/src/laybasic/laybasic/layLayoutView.h @@ -31,12 +31,14 @@ #include #include #include +#include #include #include #include "layLayerProperties.h" #include "layAbstractMenu.h" +#include "layAbstractMenuProvider.h" #include "layAnnotationShapes.h" #include "layLayoutCanvas.h" #include "layColorPalette.h" @@ -79,6 +81,8 @@ class SelectionService; class MoveService; class Browser; class ColorButton; +class PluginRoot; +class ConfigureAction; /** * @brief Stores a layer reference to create layers which have been added by some action @@ -155,7 +159,8 @@ struct LAYBASIC_PUBLIC LayerDisplayProperties class LAYBASIC_PUBLIC LayoutView : public QFrame, public lay::Editables, - public lay::Plugin + public lay::Plugin, + public lay::AbstractMenuProvider { Q_OBJECT @@ -217,6 +222,12 @@ public: */ static LayoutView *current (); + /** + * @brief Gets the abstract menu object for this view + * This is either the global menu object or the local one. + */ + AbstractMenu *menu (); + /** * @brief Determine if there is something to copy * @@ -1667,12 +1678,6 @@ public: */ static void update_menu (lay::LayoutView *view, lay::AbstractMenu &menu); - /** - * @brief Get the menu abstraction object - * This is either the global abstract menu or a view-local one if the view is not embedded into a main window. - */ - AbstractMenu *menu (); - /** * @brief Query the default mode */ @@ -2758,6 +2763,10 @@ protected: private: lay::AbstractMenu m_menu; + std::auto_ptr mp_plugin_root; + std::map m_actions_for_slot; + std::map > m_configuration_actions; + tl::shared_collection m_ca_collection; bool m_editable; int m_disabled_edits; @@ -2939,6 +2948,14 @@ private: std::list::iterator cellview_iter (int cv_index); std::list::const_iterator cellview_iter (int cv_index) const; + + // implementation of AbstractMenuProvider + virtual QWidget *menu_parent_widget (); + virtual lay::Action &action_for_slot (const char *slot); + virtual lay::Action *create_config_action (const std::string &title, const std::string &cname, const std::string &cvalue); + virtual lay::Action *create_config_action (const std::string &cname, const std::string &cvalue); + virtual void register_config_action (const std::string &name, lay::ConfigureAction *action); + virtual void unregister_config_action (const std::string &name, lay::ConfigureAction *action); }; } diff --git a/src/laybasic/laybasic/layPlugin.cc b/src/laybasic/laybasic/layPlugin.cc index 7beb06a14..0743f2504 100644 --- a/src/laybasic/laybasic/layPlugin.cc +++ b/src/laybasic/laybasic/layPlugin.cc @@ -368,9 +368,12 @@ Plugin::get_config_names (std::vector &names) const PluginRoot * Plugin::plugin_root () { - PluginRoot *pr = plugin_root_maybe_null (); - tl_assert (pr != 0); - return pr; + Plugin *p = this; + while (p->mp_parent) { + p = p->mp_parent; + } + + return dynamic_cast (p); } PluginRoot * @@ -436,10 +439,12 @@ Plugin::do_config_set (const std::string &name, const std::string &value, bool f static PluginRoot *ms_root_instance = 0; -PluginRoot::PluginRoot (bool standalone) +PluginRoot::PluginRoot (bool standalone, bool reg_inst) : Plugin (0, standalone) { - ms_root_instance = this; + if (reg_inst) { + ms_root_instance = this; + } } PluginRoot::~PluginRoot () diff --git a/src/laybasic/laybasic/layPlugin.h b/src/laybasic/laybasic/layPlugin.h index 0f1413187..4922da7b7 100644 --- a/src/laybasic/laybasic/layPlugin.h +++ b/src/laybasic/laybasic/layPlugin.h @@ -805,7 +805,7 @@ public: /** * @brief The constructor */ - PluginRoot (bool standalone = false); + PluginRoot (bool standalone = false, bool reg_inst = true); /** * @brief Destructor From 4f03710f65867ea14b985460fe30625344de13f3 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Wed, 5 Feb 2020 00:02:12 +0100 Subject: [PATCH 05/32] WIP: target will be version 0.27. --- src/laybasic/laybasic/gsiDeclLayLayoutView.cc | 34 +++++++++---------- src/laybasic/laybasic/layLayoutView.cc | 4 +-- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/laybasic/laybasic/gsiDeclLayLayoutView.cc b/src/laybasic/laybasic/gsiDeclLayLayoutView.cc index 74a650fae..7d6081638 100644 --- a/src/laybasic/laybasic/gsiDeclLayLayoutView.cc +++ b/src/laybasic/laybasic/gsiDeclLayLayoutView.cc @@ -425,75 +425,75 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "@param options A combination of the values in the LV_... constants\n" "\n" "This constructor has been introduced in version 0.25.\n" - "It has been enhanced with the arguments in version 0.26.4.\n" + "It has been enhanced with the arguments in version 0.27.\n" ) + gsi::constant ("LV_NoLayers", (unsigned int) lay::LayoutView::LV_NoLayers, "@brief With this option, no layers view will be provided (see \\layer_control_frame)\n" "Use this value with the constructor's 'options' argument.\n" "\n" - "This constant has been introduced in version 0.26.4.\n" + "This constant has been introduced in version 0.27.\n" ) + gsi::constant ("LV_NoHierarchyPanel", (unsigned int) lay::LayoutView::LV_NoHierarchyPanel, "@brief With this option, no cell hierarchy view will be provided (see \\hierarchy_control_frame)\n" "Use this value with the constructor's 'options' argument.\n" "\n" - "This constant has been introduced in version 0.26.4.\n" + "This constant has been introduced in version 0.27.\n" ) + gsi::constant ("LV_NoLibrariesView", (unsigned int) lay::LayoutView::LV_NoLibrariesView, "@brief With this option, no library view will be provided (see \\libraries_frame)\n" "Use this value with the constructor's 'options' argument.\n" "\n" - "This constant has been introduced in version 0.26.4.\n" + "This constant has been introduced in version 0.27.\n" ) + gsi::constant ("LV_NoBookmarksView", (unsigned int) lay::LayoutView::LV_NoBookmarksView, "@brief With this option, no bookmarks view will be provided (see \\bookmarks_frame)\n" "Use this value with the constructor's 'options' argument.\n" "\n" - "This constant has been introduced in version 0.26.4.\n" + "This constant has been introduced in version 0.27.\n" ) + gsi::constant ("LV_Naked", (unsigned int) lay::LayoutView::LV_Naked, "@brief With this option, no separate views will be provided\n" "Use this value with the constructor's 'options' argument.\n" "This option is basically equivalent to using \\LV_NoLayers+\\LV_NoHierarchyPanel+\\LV_NoLibrariesView+\\LV_NoBookmarksView\n" "\n" - "This constant has been introduced in version 0.26.4.\n" + "This constant has been introduced in version 0.27.\n" ) + gsi::constant ("LV_NoZoom", (unsigned int) lay::LayoutView::LV_NoZoom, "@brief With this option, zooming is disabled\n" "Use this value with the constructor's 'options' argument.\n" "\n" - "This constant has been introduced in version 0.26.4.\n" + "This constant has been introduced in version 0.27.\n" ) + gsi::constant ("LV_NoGrid", (unsigned int) lay::LayoutView::LV_NoGrid, "@brief With this option, the grid background is not shown\n" "Use this value with the constructor's 'options' argument.\n" "\n" - "This constant has been introduced in version 0.26.4.\n" + "This constant has been introduced in version 0.27.\n" ) + gsi::constant ("LV_NoMove", (unsigned int) lay::LayoutView::LV_NoMove, "@brief With this option, move operations are not supported\n" "Use this value with the constructor's 'options' argument.\n" "\n" - "This constant has been introduced in version 0.26.4.\n" + "This constant has been introduced in version 0.27.\n" ) + gsi::constant ("LV_NoTracker", (unsigned int) lay::LayoutView::LV_NoTracker, "@brief With this option, mouse position tracking is not supported\n" "Use this value with the constructor's 'options' argument.\n" "This option is not useful currently as no mouse tracking support is provided.\n" "\n" - "This constant has been introduced in version 0.26.4.\n" + "This constant has been introduced in version 0.27.\n" ) + gsi::constant ("LV_NoSelection", (unsigned int) lay::LayoutView::LV_NoSelection, "@brief With this option, objects cannot be selected\n" "Use this value with the constructor's 'options' argument.\n" "\n" - "This constant has been introduced in version 0.26.4.\n" + "This constant has been introduced in version 0.27.\n" ) + gsi::constant ("LV_NoPlugins", (unsigned int) lay::LayoutView::LV_NoPlugins, "@brief With this option, all plugins are disabled\n" "Use this value with the constructor's 'options' argument.\n" "\n" - "This constant has been introduced in version 0.26.4.\n" + "This constant has been introduced in version 0.27.\n" ) + gsi::constant ("LV_NoServices", (unsigned int) lay::LayoutView::LV_NoServices, "@brief This option disables all services except the ones for pure viewing\n" @@ -501,7 +501,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "With this option, all manipulation features are disabled, except zooming.\n" "It is equivalent to \\LV_NoMove + \\LV_NoTracker + \\LV_NoSelection + \\LV_NoPlugins.\n" "\n" - "This constant has been introduced in version 0.26.4.\n" + "This constant has been introduced in version 0.27.\n" ) + #if defined(HAVE_QTBINDINGS) gsi::method ("layer_control_frame", &lay::LayoutView::layer_control_frame, @@ -512,25 +512,25 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "The side widget can be configured through the views configuration interface.\n" "\n" - "This method has been introduced in version 0.26.4\n" + "This method has been introduced in version 0.27\n" ) + gsi::method ("hierarchy_control_frame", &lay::LayoutView::hierarchy_control_frame, "@brief Gets the cell view (hierarchy view) side widget\n" "For details about side widgets see \\layer_control_frame.\n" "\n" - "This method has been introduced in version 0.26.4\n" + "This method has been introduced in version 0.27\n" ) + gsi::method ("libraries_frame", &lay::LayoutView::libraries_frame, "@brief Gets the library view side widget\n" "For details about side widgets see \\layer_control_frame.\n" "\n" - "This method has been introduced in version 0.26.4\n" + "This method has been introduced in version 0.27\n" ) + gsi::method ("bookmarks_frame", &lay::LayoutView::bookmarks_frame, "@brief Gets the bookmarks side widget\n" "For details about side widgets see \\layer_control_frame.\n" "\n" - "This method has been introduced in version 0.26.4\n" + "This method has been introduced in version 0.27\n" ) + #endif gsi::method ("current", &lay::LayoutView::current, diff --git a/src/laybasic/laybasic/layLayoutView.cc b/src/laybasic/laybasic/layLayoutView.cc index 33845acd0..13a29ea6f 100644 --- a/src/laybasic/laybasic/layLayoutView.cc +++ b/src/laybasic/laybasic/layLayoutView.cc @@ -720,7 +720,7 @@ LayoutView::action_for_slot (const char *slot) lay::Action * LayoutView::create_config_action (const std::string &title, const std::string &cname, const std::string &cvalue) { - lay::ConfigureAction *ca = new lay::ConfigureAction(plugin_root (), title, cname, cvalue); + lay::ConfigureAction *ca = new lay::ConfigureAction (plugin_root (), title, cname, cvalue); m_ca_collection.push_back (ca); return ca; } @@ -728,7 +728,7 @@ LayoutView::create_config_action (const std::string &title, const std::string &c lay::Action * LayoutView::create_config_action (const std::string &cname, const std::string &cvalue) { - lay::ConfigureAction *ca = new lay::ConfigureAction(plugin_root (), std::string (), cname, cvalue); + lay::ConfigureAction *ca = new lay::ConfigureAction (plugin_root (), std::string (), cname, cvalue); m_ca_collection.push_back (ca); return ca; } From 0caddcf0f96a60bc347bd97d2967d875e4591d2c Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Wed, 5 Feb 2020 00:07:53 +0100 Subject: [PATCH 06/32] Added TODO as notes. --- TODO | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 TODO diff --git a/TODO b/TODO new file mode 100644 index 000000000..6f8b38b07 --- /dev/null +++ b/TODO @@ -0,0 +1,25 @@ + +Plan: + +1. Combine AbstractMenuProvider, PluginRoot and the AbstractMenuProvider's + implementation in MainWindow/LayoutView into lay::Dispatcher + +2. Base MainWindow and LayoutView on lay::Dispatcher + +3. lay::Plugin::plugin_root -> lay::Dispatcher *lay::Plugin::dispatcher() + This method will find the MainWindow or LayoutView depending + which is the root. + +4. Don't use AbstractMenuProvider::instance anymore, rather use lay::Dispatcher::instance + when necessary (should not be) + +5. Instead of slots, bind abstract menu items to symbols passed to + Dispatcher::menu_activated + +6. MainWindow will automatically dispatch menu_activated to LayoutView + +7. GSI-expose menu_activated in LayoutView and MainWindow + +8. We can move menu initialization of LV-specifics to the LayoutView and + remove the cm_... and the code which just passes signals to the current view! :) + From 4c445d55ccb7db206c722c335085258e7548ee20 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Wed, 5 Feb 2020 00:09:20 +0100 Subject: [PATCH 07/32] WIP: TODO updates. --- TODO | 3 +++ 1 file changed, 3 insertions(+) diff --git a/TODO b/TODO index 6f8b38b07..12ae488a9 100644 --- a/TODO +++ b/TODO @@ -23,3 +23,6 @@ Plan: 8. We can move menu initialization of LV-specifics to the LayoutView and remove the cm_... and the code which just passes signals to the current view! :) +9. BTW: make QWidget::setParent and QObject::setParent transfer ownership for + Qt binding. + From ebd5b3738ebb5a5d39c3a7326790b14179ecf7d5 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Wed, 5 Feb 2020 00:10:40 +0100 Subject: [PATCH 08/32] WIP: TODO updates. --- TODO | 2 ++ 1 file changed, 2 insertions(+) diff --git a/TODO b/TODO index 12ae488a9..13111d8c3 100644 --- a/TODO +++ b/TODO @@ -26,3 +26,5 @@ Plan: 9. BTW: make QWidget::setParent and QObject::setParent transfer ownership for Qt binding. +10. Provide the layer toolbox for GSI + From d6589f1d0e5b99651c6ecfbca28620dbaafae4d9 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Fri, 7 Feb 2020 00:41:37 +0100 Subject: [PATCH 09/32] WIP: refactoring ongoing. --- src/lay/lay/gsiDeclLayMainWindow.cc | 664 +++--- src/lay/lay/lay.pro | 4 - src/lay/lay/layApplication.cc | 2 +- src/lay/lay/layApplication.h | 4 +- src/lay/lay/layMacroController.h | 6 +- src/lay/lay/layMainConfigPages.h | 32 +- src/lay/lay/layMainWindow.cc | 2099 +++-------------- src/lay/lay/layMainWindow.h | 243 +- src/lay/lay/layNavigator.cc | 58 +- src/lay/lay/layNavigator.h | 2 - src/lay/lay/laySaltController.h | 10 +- src/lay/lay/laySettingsForm.cc | 4 +- src/lay/lay/laySettingsForm.h | 6 +- src/lay/lay/layTechnologyController.h | 8 +- .../laybasic}/LayoutStatistics.ui | 0 .../laybasic}/SelectCellViewForm.ui | 0 src/laybasic/laybasic/gsiDeclLayLayoutView.cc | 12 + src/laybasic/laybasic/gsiDeclLayPlugin.cc | 148 +- src/laybasic/laybasic/layAbstractMenu.cc | 181 +- src/laybasic/laybasic/layAbstractMenu.h | 88 +- .../laybasic/layAbstractMenuProvider.cc | 51 - .../laybasic/layAbstractMenuProvider.h | 107 - src/laybasic/laybasic/layBookmarksView.cc | 45 +- src/laybasic/laybasic/layBookmarksView.h | 2 - src/laybasic/laybasic/layDispatcher.cc | 282 +++ src/laybasic/laybasic/layDispatcher.h | 175 ++ src/laybasic/laybasic/layGridNet.cc | 2 +- src/laybasic/laybasic/layGridNet.h | 6 +- .../laybasic/layHierarchyControlPanel.cc | 99 +- .../laybasic/layHierarchyControlPanel.h | 5 - src/laybasic/laybasic/layLayerControlPanel.cc | 172 +- src/laybasic/laybasic/layLayerControlPanel.h | 5 - .../laybasic}/layLayoutStatistics.qrc | 0 .../laybasic}/layLayoutStatisticsForm.cc | 0 .../laybasic}/layLayoutStatisticsForm.h | 0 src/laybasic/laybasic/layLayoutView.cc | 759 +++++- src/laybasic/laybasic/layLayoutView.h | 42 +- .../laybasic/layLayoutViewConfigPages.h | 56 +- src/laybasic/laybasic/layLibrariesView.cc | 43 +- src/laybasic/laybasic/layLibrariesView.h | 5 - .../laybasic/layLoadLayoutOptionsDialog.h | 4 +- src/laybasic/laybasic/layNetlistBrowser.h | 8 +- src/laybasic/laybasic/layPlugin.cc | 323 +-- src/laybasic/laybasic/layPlugin.h | 249 +- .../laybasic/laySaveLayoutOptionsDialog.h | 2 +- .../laybasic}/laySelectCellViewForm.cc | 0 .../laybasic}/laySelectCellViewForm.h | 0 src/laybasic/laybasic/laybasic.pro | 16 +- src/laybasic/laybasic/rdbMarkerBrowser.h | 8 +- 49 files changed, 2476 insertions(+), 3561 deletions(-) rename src/{lay/lay => laybasic/laybasic}/LayoutStatistics.ui (100%) rename src/{lay/lay => laybasic/laybasic}/SelectCellViewForm.ui (100%) delete mode 100644 src/laybasic/laybasic/layAbstractMenuProvider.cc delete mode 100644 src/laybasic/laybasic/layAbstractMenuProvider.h create mode 100644 src/laybasic/laybasic/layDispatcher.cc create mode 100644 src/laybasic/laybasic/layDispatcher.h rename src/{lay/lay => laybasic/laybasic}/layLayoutStatistics.qrc (100%) rename src/{lay/lay => laybasic/laybasic}/layLayoutStatisticsForm.cc (100%) rename src/{lay/lay => laybasic/laybasic}/layLayoutStatisticsForm.h (100%) rename src/{lay/lay => laybasic/laybasic}/laySelectCellViewForm.cc (100%) rename src/{lay/lay => laybasic/laybasic}/laySelectCellViewForm.h (100%) diff --git a/src/lay/lay/gsiDeclLayMainWindow.cc b/src/lay/lay/gsiDeclLayMainWindow.cc index 396290f04..149594c69 100644 --- a/src/lay/lay/gsiDeclLayMainWindow.cc +++ b/src/lay/lay/gsiDeclLayMainWindow.cc @@ -43,6 +43,145 @@ void enable_edits (lay::MainWindow * /*main_window*/, bool enable) } } +// NOTE: match this with the cm_method_decl's below +static const char *cm_symbols[] = { + "cm_reset_window_state", + "cm_select_all", + "cm_unselect_all", + "cm_undo", + "cm_redo", + "cm_delete", + "cm_show_properties", + "cm_copy", + "cm_paste", + "cm_cut", + "cm_zoom_fit_sel", + "cm_zoom_fit", + "cm_zoom_in", + "cm_zoom_out", + "cm_pan_up", + "cm_pan_down", + "cm_pan_left", + "cm_pan_right", + "cm_save_session", + "cm_restore_session", + "cm_setup", + "cm_save_as", + "cm_save", + "cm_save_all", + "cm_reload", + "cm_close", + "cm_close_all", + "cm_clone", + "cm_layout_props", + "cm_inc_max_hier", + "cm_dec_max_hier", + "cm_max_hier", + "cm_max_hier_0", + "cm_max_hier_1", + "cm_prev_display_state|#cm_last_display_state", + "cm_next_display_state", + "cm_cancel", + "cm_redraw", + "cm_screenshot", + "cm_save_layer_props", + "cm_load_layer_props", + "cm_save_bookmarks", + "cm_load_bookmarks", + "cm_select_cell", + "cm_select_current_cell", + "cm_print", + "cm_exit", + "cm_view_log", + "cm_bookmark_view", + "cm_manage_bookmarks", + "cm_macro_editor", + "cm_goto_position", + "cm_help_about", + "cm_technologies", + "cm_packages", + "cm_open_too", + "cm_open_new_view", + "cm_open", + "cm_pull_in", + "cm_reader_options", + "cm_new_layout", + "cm_new_panel", + "cm_adjust_origin", + "cm_new_cell", + "cm_new_layer", + "cm_clear_layer", + "cm_delete_layer", + "cm_edit_layer", + "cm_copy_layer", + "cm_sel_flip_x", + "cm_sel_flip_y", + "cm_sel_rot_cw", + "cm_sel_rot_ccw", + "cm_sel_free_rot", + "cm_sel_scale", + "cm_sel_move", + "cm_sel_move_to", + "cm_lv_new_tab", + "cm_lv_remove_tab", + "cm_lv_rename_tab", + "cm_lv_hide", + "cm_lv_hide_all", + "cm_lv_show", + "cm_lv_show_all", + "cm_lv_show_only", + "cm_lv_rename", + "cm_lv_select_all", + "cm_lv_delete", + "cm_lv_insert", + "cm_lv_group", + "cm_lv_ungroup", + "cm_lv_source", + "cm_lv_sort_by_name", + "cm_lv_sort_by_ild", + "cm_lv_sort_by_idl", + "cm_lv_sort_by_ldi", + "cm_lv_sort_by_dli", + "cm_lv_regroup_by_index", + "cm_lv_regroup_by_datatype", + "cm_lv_regroup_by_layer", + "cm_lv_regroup_flatten", + "cm_lv_expand_all", + "cm_lv_add_missing", + "cm_lv_remove_unused", + "cm_cell_delete", + "cm_cell_rename", + "cm_cell_copy", + "cm_cell_cut", + "cm_cell_paste", + "cm_cell_select", + "cm_open_current_cell", + "cm_save_current_cell_as", + "cm_cell_hide", + "cm_cell_flatten", + "cm_cell_show", + "cm_cell_show_all", + "cm_navigator_close", + "cm_navigator_freeze" +}; + +template +void call_cm_method (lay::MainWindow *mw) +{ + tl_assert (NUM < sizeof (cm_symbols) / sizeof (cm_symbols [0])); + mw->menu_activated (cm_symbols [NUM]); +} + +template +gsi::Methods cm_method_decl () +{ + tl_assert (NUM < sizeof (cm_symbols) / sizeof (cm_symbols [0])); + return gsi::method (std::string ("#") + cm_symbols [NUM], &call_cm_method, + std::string ("@brief '") + cm_symbols[NUM] + "' action.\n" + "This method has been added in version 0.25 and is deprecated in version 0.27.\n" + "Use \"call_menu('" + std::string (cm_symbols[NUM]) + "')\" instead."); +} + Class decl_MainWindow (QT_EXTERNAL_BASE (QMainWindow) "lay", "MainWindow", // QMainWindow interface @@ -378,405 +517,138 @@ Class decl_MainWindow (QT_EXTERNAL_BASE (QMainWindow) "lay", "M "\n" "This method has been introduced in version 0.26.\n" ) + - gsi::method ("cm_reset_window_state", &lay::MainWindow::cm_reset_window_state, - "@brief 'cm_reset_window_state' action (bound to a menu)" + gsi::method ("call_menu", &lay::MainWindow::menu_activated, + "@brief Calls the menu item with the provided symbol.\n" + "To obtain all symbols, use get_menu_symbols.\n" "\n" - "This method has been added in version 0.25.\n" + "This method has been introduced in version 0.27 and replaces the previous cm_... methods. " + "Instead of calling a specific cm_... method, use LayoutView#call_menu with 'cm_...' as the symbol." ) + - gsi::method ("cm_select_all", &lay::MainWindow::cm_select_all, - "@brief 'cm_select_all' action (bound to a menu)" + gsi::method ("get_menu_symbols", &lay::MainWindow::menu_symbols, + "@brief Calls the menu item with the provided symbol.\n" + "To obtain all available symbols, use get_menu_symbols.\n" "\n" - "This method has been added in version 0.22.\n" - ) + - gsi::method ("cm_unselect_all", &lay::MainWindow::cm_unselect_all, - "@brief 'cm_unselect_all' action (bound to a menu)" - "\n" - "This method has been added in version 0.22.\n" - ) + - gsi::method ("cm_undo", &lay::MainWindow::cm_undo, - "@brief 'cm_undo' action (bound to a menu)" - ) + - gsi::method ("cm_redo", &lay::MainWindow::cm_redo, - "@brief 'cm_redo' action (bound to a menu)" - ) + - gsi::method ("cm_delete", &lay::MainWindow::cm_delete, - "@brief 'cm_delete' action (bound to a menu)" - ) + - gsi::method ("cm_show_properties", &lay::MainWindow::cm_show_properties, - "@brief 'cm_show_properties' action (bound to a menu)" - ) + - gsi::method ("cm_copy", &lay::MainWindow::cm_copy, - "@brief 'cm_copy' action (bound to a menu)" - ) + - gsi::method ("cm_paste", &lay::MainWindow::cm_paste, - "@brief 'cm_paste' action (bound to a menu)" - ) + - gsi::method ("cm_cut", &lay::MainWindow::cm_cut, - "@brief 'cm_cut' action (bound to a menu)" - ) + - gsi::method ("cm_zoom_fit_sel", &lay::MainWindow::cm_zoom_fit, - "@brief 'cm_zoom_fit_sel' action (bound to a menu)" - "\nThis method has been added in version 0.18." - ) + - gsi::method ("cm_zoom_fit", &lay::MainWindow::cm_zoom_fit, - "@brief 'cm_zoom_fit' action (bound to a menu)" - ) + - gsi::method ("cm_zoom_in", &lay::MainWindow::cm_zoom_in, - "@brief 'cm_zoom_in' action (bound to a menu)" - ) + - gsi::method ("cm_zoom_out", &lay::MainWindow::cm_zoom_out, - "@brief 'cm_zoom_out' action (bound to a menu)" - ) + - gsi::method ("cm_pan_up", &lay::MainWindow::cm_pan_up, - "@brief 'cm_pan_up' action (bound to a menu)" - ) + - gsi::method ("cm_pan_down", &lay::MainWindow::cm_pan_down, - "@brief 'cm_pan_down' action (bound to a menu)" - ) + - gsi::method ("cm_pan_left", &lay::MainWindow::cm_pan_left, - "@brief 'cm_pan_left' action (bound to a menu)" - ) + - gsi::method ("cm_pan_right", &lay::MainWindow::cm_pan_right, - "@brief 'cm_pan_right' action (bound to a menu)" - ) + - gsi::method ("cm_save_session", &lay::MainWindow::cm_save_session, - "@brief 'cm_save_session' action (bound to a menu)" - "\nThis method has been added in version 0.18." - ) + - gsi::method ("cm_restore_session", &lay::MainWindow::cm_restore_session, - "@brief 'cm_restore_session' action (bound to a menu)" - "\nThis method has been added in version 0.18." - ) + - gsi::method ("cm_setup", &lay::MainWindow::cm_setup, - "@brief 'cm_setup' action (bound to a menu)" - ) + - gsi::method ("cm_save_as", &lay::MainWindow::cm_save_as, - "@brief 'cm_save_as' action (bound to a menu)" - "\nThis method has been added in version 0.18." - ) + - gsi::method ("cm_save", &lay::MainWindow::cm_save, - "@brief 'cm_save' action (bound to a menu)" - "\nThis method has been added in version 0.18." - ) + - gsi::method ("cm_save_all", &lay::MainWindow::cm_save_all, - "@brief 'cm_save_all' action (bound to a menu)\n" - "This method has been added in version 0.24.\n" - ) + - gsi::method ("cm_reload", &lay::MainWindow::cm_reload, - "@brief 'cm_reload' action (bound to a menu)" - ) + - gsi::method ("cm_close", &lay::MainWindow::cm_close, - "@brief 'cm_close' action (bound to a menu)" - ) + - gsi::method ("cm_close_all", &lay::MainWindow::cm_close_all, - "@brief 'cm_close_all' action (bound to a menu)\n" - "This method has been added in version 0.24.\n" - ) + - gsi::method ("cm_clone", &lay::MainWindow::cm_clone, - "@brief 'cm_clone' action (bound to a menu)" - ) + - gsi::method ("cm_layout_props", &lay::MainWindow::cm_layout_props, - "@brief 'cm_layout_props' action (bound to a menu)" - ) + - gsi::method ("cm_inc_max_hier", &lay::MainWindow::cm_inc_max_hier, - "@brief 'cm_inc_max_hier' action (bound to a menu)" - ) + - gsi::method ("cm_dec_max_hier", &lay::MainWindow::cm_dec_max_hier, - "@brief 'cm_dec_max_hier' action (bound to a menu)" - ) + - gsi::method ("cm_max_hier", &lay::MainWindow::cm_max_hier, - "@brief 'cm_max_hier' action (bound to a menu)" - ) + - gsi::method ("cm_max_hier_0", &lay::MainWindow::cm_max_hier_0, - "@brief 'cm_max_hier_0' action (bound to a menu)" - ) + - gsi::method ("cm_max_hier_1", &lay::MainWindow::cm_max_hier_1, - "@brief 'cm_max_hier_1' action (bound to a menu)" - ) + - gsi::method ("cm_prev_display_state|#cm_last_display_state", &lay::MainWindow::cm_prev_display_state, - "@brief 'cm_prev_display_state' action (bound to a menu)" - ) + - gsi::method ("cm_next_display_state", &lay::MainWindow::cm_next_display_state, - "@brief 'cm_next_display_state' action (bound to a menu)" - ) + - gsi::method ("cm_cancel", &lay::MainWindow::cm_cancel, - "@brief 'cm_cancel' action (bound to a menu)" - ) + - gsi::method ("cm_redraw", &lay::MainWindow::cm_redraw, - "@brief 'cm_redraw' action (bound to a menu)" - ) + - gsi::method ("cm_screenshot", &lay::MainWindow::cm_screenshot, - "@brief 'cm_screenshot' action (bound to a menu)" - ) + - gsi::method ("cm_save_layer_props", &lay::MainWindow::cm_save_layer_props, - "@brief 'cm_save_layer_props' action (bound to a menu)" - ) + - gsi::method ("cm_load_layer_props", &lay::MainWindow::cm_load_layer_props, - "@brief 'cm_load_layer_props' action (bound to a menu)" - ) + - gsi::method ("cm_save_bookmarks", &lay::MainWindow::cm_save_bookmarks, - "@brief 'cm_save_bookmarks' action (bound to a menu)" - ) + - gsi::method ("cm_load_bookmarks", &lay::MainWindow::cm_load_bookmarks, - "@brief 'cm_load_bookmarks' action (bound to a menu)" - ) + - gsi::method ("cm_select_cell", &lay::MainWindow::cm_select_cell, - "@brief 'cm_select_cell' action (bound to a menu)" - ) + - gsi::method ("cm_select_current_cell", &lay::MainWindow::cm_select_current_cell, - "@brief 'cm_select_current_cell' action (bound to a menu)" - ) + - gsi::method ("cm_print", &lay::MainWindow::cm_print, - "@brief 'cm_print' action (bound to a menu)\n" - "This method has been added in version 0.21.13." - ) + - gsi::method ("cm_exit", &lay::MainWindow::cm_exit, - "@brief 'cm_exit' action (bound to a menu)" - ) + - gsi::method ("cm_view_log", &lay::MainWindow::cm_view_log, - "@brief 'cm_view_log' action (bound to a menu)" - "\nThis method has been added in version 0.20." - ) + - gsi::method ("cm_bookmark_view", &lay::MainWindow::cm_bookmark_view, - "@brief 'cm_bookmark_view' action (bound to a menu)" - ) + - gsi::method ("cm_manage_bookmarks", &lay::MainWindow::cm_manage_bookmarks, - "@brief 'cm_manage_bookmarks' action (bound to a menu)" - ) + - gsi::method ("cm_macro_editor", &lay::MainWindow::cm_macro_editor, - "@brief 'cm_macro_editor' action (bound to a menu)" - ) + - gsi::method ("cm_goto_position", &lay::MainWindow::cm_goto_position, - "@brief 'cm_goto_position' action (bound to a menu)" - ) + - gsi::method ("cm_help_about", &lay::MainWindow::cm_help_about, - "@brief 'cm_help_about' action (bound to a menu)" - ) + - gsi::method ("cm_technologies", &lay::MainWindow::cm_technologies, - "@brief 'cm_technologies' action (bound to a menu)" - "\nThis method has been added in version 0.22." - ) + - gsi::method ("cm_packages", &lay::MainWindow::cm_packages, - "@brief 'cm_packages' action (bound to a menu)" - "\nThis method has been added in version 0.25." - ) + - gsi::method ("cm_open_too", &lay::MainWindow::cm_open_too, - "@brief 'cm_open_too' action (bound to a menu)" - ) + - gsi::method ("cm_open_new_view", &lay::MainWindow::cm_open_new_view, - "@brief 'cm_open_new_view' action (bound to a menu)" - ) + - gsi::method ("cm_open", &lay::MainWindow::cm_open, - "@brief 'cm_open' action (bound to a menu)" - ) + - gsi::method ("cm_pull_in", &lay::MainWindow::cm_pull_in, - "@brief 'cm_pull_in' action (bound to a menu)" - "\nThis method has been added in version 0.20." - ) + - gsi::method ("cm_reader_options", &lay::MainWindow::cm_reader_options, - "@brief 'cm_reader_options' action (bound to a menu)" - "\nThis method has been added in version 0.18." - ) + - gsi::method ("cm_new_layout", &lay::MainWindow::cm_new_layout, - "@brief 'cm_new_layout' action (bound to a menu)" - "\nThis method has been added in version 0.18." - ) + - gsi::method ("cm_new_panel", &lay::MainWindow::cm_new_panel, - "@brief 'cm_new_panel' action (bound to a menu)" - "\nThis method has been added in version 0.20." - ) + - gsi::method ("cm_adjust_origin", &lay::MainWindow::cm_adjust_origin, - "@brief 'cm_adjust_origin' action (bound to a menu)" - "\nThis method has been added in version 0.18." - ) + - gsi::method ("cm_new_cell", &lay::MainWindow::cm_new_cell, - "@brief 'cm_new_cell' action (bound to a menu)" - "\nThis method has been added in version 0.18." - ) + - gsi::method ("cm_new_layer", &lay::MainWindow::cm_new_layer, - "@brief 'cm_new_layer' action (bound to a menu)" - "\nThis method has been added in version 0.18." - ) + - gsi::method ("cm_clear_layer", &lay::MainWindow::cm_clear_layer, - "@brief 'cm_clear_layer' action (bound to a menu)" - "\nThis method has been added in version 0.18." - ) + - gsi::method ("cm_delete_layer", &lay::MainWindow::cm_delete_layer, - "@brief 'cm_delete_layer' action (bound to a menu)" - "\nThis method has been added in version 0.18." - ) + - gsi::method ("cm_edit_layer", &lay::MainWindow::cm_edit_layer, - "@brief 'cm_edit_layer' action (bound to a menu)" - "\nThis method has been added in version 0.18." - ) + - gsi::method ("cm_copy_layer", &lay::MainWindow::cm_copy_layer, - "@brief 'cm_copy_layer' action (bound to a menu)" - "\nThis method has been added in version 0.22." - ) + - gsi::method ("cm_sel_flip_x", &lay::MainWindow::cm_sel_flip_x, - "@brief 'cm_sel_flip_x' action (bound to a menu)" - "\nThis method has been added in version 0.18." - ) + - gsi::method ("cm_sel_flip_y", &lay::MainWindow::cm_sel_flip_y, - "@brief 'cm_sel_flip_y' action (bound to a menu)" - "\nThis method has been added in version 0.18." - ) + - gsi::method ("cm_sel_rot_cw", &lay::MainWindow::cm_sel_rot_cw, - "@brief 'cm_sel_rot_cw' action (bound to a menu)" - "\nThis method has been added in version 0.18." - ) + - gsi::method ("cm_sel_rot_ccw", &lay::MainWindow::cm_sel_rot_ccw, - "@brief 'cm_sel_rot_ccw' action (bound to a menu)" - "\nThis method has been added in version 0.18." - ) + - gsi::method ("cm_sel_free_rot", &lay::MainWindow::cm_sel_free_rot, - "@brief 'cm_sel_free_rot' action (bound to a menu)" - "\nThis method has been added in version 0.18." - ) + - gsi::method ("cm_sel_scale", &lay::MainWindow::cm_sel_scale, - "@brief 'cm_sel_scale' action (bound to a menu)" - "\nThis method has been added in version 0.18." - ) + - gsi::method ("cm_sel_move", &lay::MainWindow::cm_sel_move, - "@brief 'cm_sel_move' action (bound to a menu)" - "\nThis method has been added in version 0.18." - ) + - gsi::method ("cm_sel_move_to", &lay::MainWindow::cm_sel_move_to, - "@brief 'cm_sel_move_to' action (bound to a menu)" - "\nThis method has been added in version 0.24." - ) + - gsi::method ("cm_lv_new_tab", &lay::MainWindow::cm_lv_new_tab, - "@brief 'cm_lv_new_tab' action (bound to a menu)" - ) + - gsi::method ("cm_lv_remove_tab", &lay::MainWindow::cm_lv_remove_tab, - "@brief 'cm_lv_remove_tab' action (bound to a menu)" - ) + - gsi::method ("cm_lv_rename_tab", &lay::MainWindow::cm_lv_rename_tab, - "@brief 'cm_lv_rename_tab' action (bound to a menu)" - ) + - gsi::method ("cm_lv_hide", &lay::MainWindow::cm_lv_hide, - "@brief 'cm_lv_hide' action (bound to a menu)" - ) + - gsi::method ("cm_lv_hide_all", &lay::MainWindow::cm_lv_hide_all, - "@brief 'cm_lv_hide_all' action (bound to a menu)" - ) + - gsi::method ("cm_lv_show", &lay::MainWindow::cm_lv_show, - "@brief 'cm_lv_show' action (bound to a menu)" - ) + - gsi::method ("cm_lv_show_all", &lay::MainWindow::cm_lv_show_all, - "@brief 'cm_lv_show_all' action (bound to a menu)" - ) + - gsi::method ("cm_lv_show_only", &lay::MainWindow::cm_lv_show_only, - "@brief 'cm_lv_show_only' action (bound to a menu)" - "\nThis method has been added in version 0.20." - ) + - gsi::method ("cm_lv_rename", &lay::MainWindow::cm_lv_rename, - "@brief 'cm_lv_rename' action (bound to a menu)" - ) + - gsi::method ("cm_lv_select_all", &lay::MainWindow::cm_lv_select_all, - "@brief 'cm_lv_select_all' action (bound to a menu)" - ) + - gsi::method ("cm_lv_delete", &lay::MainWindow::cm_lv_delete, - "@brief 'cm_lv_delete' action (bound to a menu)" - ) + - gsi::method ("cm_lv_insert", &lay::MainWindow::cm_lv_insert, - "@brief 'cm_lv_insert' action (bound to a menu)" - ) + - gsi::method ("cm_lv_group", &lay::MainWindow::cm_lv_group, - "@brief 'cm_lv_group' action (bound to a menu)" - ) + - gsi::method ("cm_lv_ungroup", &lay::MainWindow::cm_lv_ungroup, - "@brief 'cm_lv_ungroup' action (bound to a menu)" - ) + - gsi::method ("cm_lv_source", &lay::MainWindow::cm_lv_source, - "@brief 'cm_lv_source' action (bound to a menu)" - ) + - gsi::method ("cm_lv_sort_by_name", &lay::MainWindow::cm_lv_sort_by_name, - "@brief 'cm_lv_sort_by_name' action (bound to a menu)" - ) + - gsi::method ("cm_lv_sort_by_ild", &lay::MainWindow::cm_lv_sort_by_ild, - "@brief 'cm_lv_sort_by_ild' action (bound to a menu)" - ) + - gsi::method ("cm_lv_sort_by_idl", &lay::MainWindow::cm_lv_sort_by_idl, - "@brief 'cm_lv_sort_by_idl' action (bound to a menu)" - ) + - gsi::method ("cm_lv_sort_by_ldi", &lay::MainWindow::cm_lv_sort_by_ldi, - "@brief 'cm_lv_sort_by_ldi' action (bound to a menu)" - ) + - gsi::method ("cm_lv_sort_by_dli", &lay::MainWindow::cm_lv_sort_by_dli, - "@brief 'cm_lv_sort_by_dli' action (bound to a menu)" - ) + - gsi::method ("cm_lv_regroup_by_index", &lay::MainWindow::cm_lv_regroup_by_index, - "@brief 'cm_lv_regroup_by_index' action (bound to a menu)" - ) + - gsi::method ("cm_lv_regroup_by_datatype", &lay::MainWindow::cm_lv_regroup_by_datatype, - "@brief 'cm_lv_regroup_by_datatype' action (bound to a menu)" - ) + - gsi::method ("cm_lv_regroup_by_layer", &lay::MainWindow::cm_lv_regroup_by_layer, - "@brief 'cm_lv_regroup_by_layer' action (bound to a menu)" - ) + - gsi::method ("cm_lv_regroup_flatten", &lay::MainWindow::cm_lv_regroup_flatten, - "@brief 'cm_lv_regroup_flatten' action (bound to a menu)" - ) + - gsi::method ("cm_lv_expand_all", &lay::MainWindow::cm_lv_expand_all, - "@brief 'cm_lv_expand_all' action (bound to a menu)" - ) + - gsi::method ("cm_lv_add_missing", &lay::MainWindow::cm_lv_add_missing, - "@brief 'cm_lv_add_missing' action (bound to a menu)" - ) + - gsi::method ("cm_lv_remove_unused", &lay::MainWindow::cm_lv_remove_unused, - "@brief 'cm_lv_remove_unused' action (bound to a menu)" - ) + - gsi::method ("cm_cell_delete", &lay::MainWindow::cm_cell_delete, - "@brief 'cm_cell_delete' action (bound to a menu)" - "\nThis method has been added in version 0.18." - ) + - gsi::method ("cm_cell_rename", &lay::MainWindow::cm_cell_rename, - "@brief 'cm_cell_rename' action (bound to a menu)" - "\nThis method has been added in version 0.18." - ) + - gsi::method ("cm_cell_copy", &lay::MainWindow::cm_cell_copy, - "@brief 'cm_cell_copy' action (bound to a menu)" - "\nThis method has been added in version 0.20." - ) + - gsi::method ("cm_cell_cut", &lay::MainWindow::cm_cell_cut, - "@brief 'cm_cell_cut' action (bound to a menu)" - "\nThis method has been added in version 0.20." - ) + - gsi::method ("cm_cell_paste", &lay::MainWindow::cm_cell_paste, - "@brief 'cm_cell_paste' action (bound to a menu)" - "\nThis method has been added in version 0.20." - ) + - gsi::method ("cm_cell_select", &lay::MainWindow::cm_cell_select, - "@brief 'cm_cell_select' action (bound to a menu)" - ) + - gsi::method ("cm_open_current_cell", &lay::MainWindow::cm_open_current_cell, - "@brief 'cm_open_current_cell' action (bound to a menu)" - "\nThis method has been added in version 0.18." - ) + - gsi::method ("cm_save_current_cell_as", &lay::MainWindow::cm_save_current_cell_as, - "@brief 'cm_save_current_cell_as' action (bound to a menu)" - "\nThis method has been added in version 0.18." - ) + - gsi::method ("cm_cell_hide", &lay::MainWindow::cm_cell_hide, - "@brief 'cm_cell_hide' action (bound to a menu)" - ) + - gsi::method ("cm_cell_flatten", &lay::MainWindow::cm_cell_flatten, - "@brief 'cm_cell_flatten' action (bound to a menu)" - ) + - gsi::method ("cm_cell_show", &lay::MainWindow::cm_cell_show, - "@brief 'cm_cell_show' action (bound to a menu)" - ) + - gsi::method ("cm_cell_show_all", &lay::MainWindow::cm_cell_show_all, - "@brief 'cm_cell_show_all' action (bound to a menu)" - ) + - gsi::method ("cm_navigator_close", &lay::MainWindow::cm_navigator_close, - "@brief 'cm_navigator_close' action (bound to a menu)" - ) + - gsi::method ("cm_navigator_freeze", &lay::MainWindow::cm_navigator_freeze, - "@brief 'cm_navigator_freeze' action (bound to a menu)" - ), - + "This method has been introduced in version 0.27." + ) + + // backward compatibility (cm_... methods, deprecated) + cm_method_decl<0> () + + cm_method_decl<1> () + + cm_method_decl<2> () + + cm_method_decl<3> () + + cm_method_decl<4> () + + cm_method_decl<5> () + + cm_method_decl<6> () + + cm_method_decl<7> () + + cm_method_decl<8> () + + cm_method_decl<9> () + + cm_method_decl<10> () + + cm_method_decl<11> () + + cm_method_decl<12> () + + cm_method_decl<13> () + + cm_method_decl<14> () + + cm_method_decl<15> () + + cm_method_decl<16> () + + cm_method_decl<17> () + + cm_method_decl<18> () + + cm_method_decl<19> () + + cm_method_decl<20> () + + cm_method_decl<21> () + + cm_method_decl<22> () + + cm_method_decl<23> () + + cm_method_decl<24> () + + cm_method_decl<25> () + + cm_method_decl<26> () + + cm_method_decl<27> () + + cm_method_decl<28> () + + cm_method_decl<29> () + + cm_method_decl<30> () + + cm_method_decl<31> () + + cm_method_decl<32> () + + cm_method_decl<33> () + + cm_method_decl<34> () + + cm_method_decl<35> () + + cm_method_decl<36> () + + cm_method_decl<37> () + + cm_method_decl<38> () + + cm_method_decl<39> () + + cm_method_decl<40> () + + cm_method_decl<41> () + + cm_method_decl<42> () + + cm_method_decl<43> () + + cm_method_decl<44> () + + cm_method_decl<45> () + + cm_method_decl<46> () + + cm_method_decl<47> () + + cm_method_decl<48> () + + cm_method_decl<49> () + + cm_method_decl<50> () + + cm_method_decl<51> () + + cm_method_decl<52> () + + cm_method_decl<53> () + + cm_method_decl<54> () + + cm_method_decl<55> () + + cm_method_decl<56> () + + cm_method_decl<57> () + + cm_method_decl<58> () + + cm_method_decl<59> () + + cm_method_decl<60> () + + cm_method_decl<61> () + + cm_method_decl<62> () + + cm_method_decl<63> () + + cm_method_decl<64> () + + cm_method_decl<65> () + + cm_method_decl<66> () + + cm_method_decl<67> () + + cm_method_decl<68> () + + cm_method_decl<69> () + + cm_method_decl<70> () + + cm_method_decl<71> () + + cm_method_decl<72> () + + cm_method_decl<73> () + + cm_method_decl<74> () + + cm_method_decl<75> () + + cm_method_decl<76> () + + cm_method_decl<77> () + + cm_method_decl<78> () + + cm_method_decl<79> () + + cm_method_decl<80> () + + cm_method_decl<81> () + + cm_method_decl<82> () + + cm_method_decl<83> () + + cm_method_decl<84> () + + cm_method_decl<85> () + + cm_method_decl<86> () + + cm_method_decl<87> () + + cm_method_decl<88> () + + cm_method_decl<89> () + + cm_method_decl<90> () + + cm_method_decl<91> () + + cm_method_decl<92> () + + cm_method_decl<93> () + + cm_method_decl<94> () + + cm_method_decl<95> () + + cm_method_decl<96> () + + cm_method_decl<97> () + + cm_method_decl<98> () + + cm_method_decl<99> () + + cm_method_decl<100> () + + cm_method_decl<101> () + + cm_method_decl<102> () + + cm_method_decl<103> () + + cm_method_decl<104> () + + cm_method_decl<105> () + + cm_method_decl<106> () + + cm_method_decl<107> () + + cm_method_decl<108> () + + cm_method_decl<109> () + + cm_method_decl<110> () + + cm_method_decl<111> () + + cm_method_decl<112> () + + cm_method_decl<113> () + + cm_method_decl<114> () + + cm_method_decl<115> () + + cm_method_decl<116> () + + cm_method_decl<117> (), "@brief The main application window and central controller object\n" "\n" "This object first is the main window but also the main controller. The main controller " diff --git a/src/lay/lay/lay.pro b/src/lay/lay/lay.pro index a4599dfca..b5c376219 100644 --- a/src/lay/lay/lay.pro +++ b/src/lay/lay/lay.pro @@ -15,7 +15,6 @@ HEADERS = \ layHelpDialog.h \ layHelpProvider.h \ layHelpSource.h \ - layLayoutStatisticsForm.h \ layLogViewerDialog.h \ layMacroEditorDialog.h \ layMacroEditorPage.h \ @@ -32,7 +31,6 @@ HEADERS = \ laySearchReplaceConfigPage.h \ laySearchReplaceDialog.h \ laySearchReplacePropertiesWidgets.h \ - laySelectCellViewForm.h \ laySession.h \ laySettingsForm.h \ layTechSetupDialog.h \ @@ -68,7 +66,6 @@ FORMS = \ DeleteModeDialog.ui \ FillDialog.ui \ HelpAboutDialog.ui \ - LayoutStatistics.ui \ LogViewerDialog.ui \ MacroEditorDialog.ui \ MacroPropertiesDialog.ui \ @@ -122,7 +119,6 @@ SOURCES = \ layHelpDialog.cc \ layHelpProvider.cc \ layHelpSource.cc \ - layLayoutStatisticsForm.cc \ layLogViewerDialog.cc \ layMacroEditorDialog.cc \ layMacroEditorPage.cc \ diff --git a/src/lay/lay/layApplication.cc b/src/lay/lay/layApplication.cc index 5e2b13b15..33f7dc0c4 100644 --- a/src/lay/lay/layApplication.cc +++ b/src/lay/lay/layApplication.cc @@ -1483,7 +1483,7 @@ GuiApplication::setup () { tl_assert (mp_mw == 0 && mp_plugin_root == 0); - mp_plugin_root = new lay::PluginRootToMainWindow (); + mp_plugin_root = new lay::DispatcherToMainWindow (); mp_mw = new lay::MainWindow (this, mp_plugin_root, "main_window", is_undo_enabled ()); mp_plugin_root->attach_to (mp_mw); diff --git a/src/lay/lay/layApplication.h b/src/lay/lay/layApplication.h index 8ef31e2d5..b121138b2 100644 --- a/src/lay/lay/layApplication.h +++ b/src/lay/lay/layApplication.h @@ -57,7 +57,7 @@ namespace lay { class MainWindow; -class PluginRootToMainWindow; +class DispatcherToMainWindow; class PluginRoot; class ProgressReporter; class ProgressBar; @@ -445,7 +445,7 @@ protected: private: MainWindow *mp_mw; - PluginRootToMainWindow *mp_plugin_root; + DispatcherToMainWindow *mp_plugin_root; gtf::Recorder *mp_recorder; }; diff --git a/src/lay/lay/layMacroController.h b/src/lay/lay/layMacroController.h index 5f00b4686..13cd5dd3e 100644 --- a/src/lay/lay/layMacroController.h +++ b/src/lay/lay/layMacroController.h @@ -89,12 +89,12 @@ public: /** * @brief Reimplementation of the PluginDeclaration interface */ - virtual void initialized (lay::PluginRoot *root); + virtual void initialized (lay::Dispatcher *root); /** * @brief Reimplementation of the PluginDeclaration interface */ - virtual void uninitialize (lay::PluginRoot *root); + virtual void uninitialize (lay::Dispatcher *root); /** * @brief Reimplementation of the PluginDeclaration interface @@ -109,7 +109,7 @@ public: /** * @brief Reimplementation of the PluginDeclaration interface */ - virtual bool can_exit (lay::PluginRoot *root) const; + virtual bool can_exit (lay::Dispatcher *root) const; /** * @brief Gets a value indicating whether the plugin will accept a dropped file with the given URL or path diff --git a/src/lay/lay/layMainConfigPages.h b/src/lay/lay/layMainConfigPages.h index 6a88bae83..6401546f8 100644 --- a/src/lay/lay/layMainConfigPages.h +++ b/src/lay/lay/layMainConfigPages.h @@ -59,8 +59,8 @@ public: MainConfigPage (QWidget *parent); ~MainConfigPage (); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); private: Ui::MainConfigPage *mp_ui; @@ -75,8 +75,8 @@ public: MainConfigPage2 (QWidget *parent); ~MainConfigPage2 (); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); private: Ui::MainConfigPage2 *mp_ui; @@ -91,8 +91,8 @@ public: MainConfigPage3 (QWidget *parent); ~MainConfigPage3 (); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); private: Ui::MainConfigPage3 *mp_ui; @@ -107,8 +107,8 @@ public: MainConfigPage4 (QWidget *parent); ~MainConfigPage4 (); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); private: Ui::MainConfigPage4 *mp_ui; @@ -123,8 +123,8 @@ public: MainConfigPage5 (QWidget *parent); ~MainConfigPage5 (); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); private: Ui::MainConfigPage5 *mp_ui; @@ -139,8 +139,8 @@ public: MainConfigPage6 (QWidget *parent); ~MainConfigPage6 (); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); private: Ui::MainConfigPage6 *mp_ui; @@ -155,8 +155,8 @@ public: MainConfigPage7 (QWidget *parent); ~MainConfigPage7 (); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); private: Ui::MainConfigPage7 *mp_ui; @@ -171,8 +171,8 @@ public: CustomizeMenuConfigPage (QWidget *parent); ~CustomizeMenuConfigPage (); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); private slots: void current_changed (QTreeWidgetItem *current, QTreeWidgetItem *previous); diff --git a/src/lay/lay/layMainWindow.cc b/src/lay/lay/layMainWindow.cc index be39fa22b..74560e83e 100644 --- a/src/lay/lay/layMainWindow.cc +++ b/src/lay/lay/layMainWindow.cc @@ -64,7 +64,6 @@ #include "layApplication.h" #include "layVersion.h" #include "layConverters.h" -#include "layCellSelectionForm.h" #include "layDialogs.h" #include "laybasicConfig.h" #include "layConfig.h" @@ -85,12 +84,10 @@ #include "layLogViewerDialog.h" #include "layLayerToolbox.h" #include "laySettingsForm.h" +#include "laySelectCellViewForm.h" #include "layTechnologyController.h" #include "laySaltController.h" #include "layTipDialog.h" -#include "laySelectCellViewForm.h" -#include "layLayoutPropertiesForm.h" -#include "layLayoutStatisticsForm.h" #include "layMacroController.h" #include "layInit.h" #include "antObject.h" @@ -421,7 +418,7 @@ MainWindow::instance () MainWindow::MainWindow (QApplication *app, lay::Plugin *plugin_parent, const char *name, bool undo_enabled) : QMainWindow (0), - lay::Plugin (plugin_parent), + lay::Dispatcher (plugin_parent, false), m_text_progress (this, 10 /*verbosity threshold*/), m_mode (std::numeric_limits::max ()), mp_setup_form (0), @@ -433,13 +430,12 @@ MainWindow::MainWindow (QApplication *app, lay::Plugin *plugin_parent, const cha dm_exit (this, &MainWindow::exit), m_grid_micron (0.001), m_default_grids_updated (true), - m_new_cell_window_size (2.0), m_new_layout_current_panel (false), m_synchronized_views (false), m_synchronous (false), m_busy (false), mp_app (app), - m_manager (true) + m_manager (undo_enabled) { // ensures the deferred method scheduler is present tl::DeferredMethodScheduler::instance (); @@ -453,7 +449,7 @@ MainWindow::MainWindow (QApplication *app, lay::Plugin *plugin_parent, const cha lay::register_help_handler (this, SLOT (show_help (const QString &)), SLOT (show_modal_help (const QString &))); - mp_setup_form = new SettingsForm (0, plugin_root (), "setup_form"), + mp_setup_form = new SettingsForm (0, dispatcher (), "setup_form"), db::LibraryManager::instance ().changed_event.add (this, &MainWindow::libraries_changed); @@ -557,9 +553,9 @@ MainWindow::MainWindow (QApplication *app, lay::Plugin *plugin_parent, const cha QMenuBar *mbar = menuBar (); mbar->setObjectName (QString::fromUtf8 ("menubar")); - mp_menu->build (mbar, mp_tool_bar); + menu ()->build (mbar, mp_tool_bar); - connect (mp_menu, SIGNAL (changed ()), this, SLOT (menu_changed ())); + connect (menu (), SIGNAL (changed ()), this, SLOT (menu_changed ())); mp_status_bar = statusBar (); mp_status_bar->setObjectName (QString::fromUtf8 ("status_bar")); @@ -708,7 +704,7 @@ MainWindow::~MainWindow () // since the configuration actions unregister themselves, we need to do this before the main // window is gone: - m_ca_collection.clear (); + clear_configuration_actions (); mw_instance = 0; @@ -720,9 +716,6 @@ MainWindow::~MainWindow () // delete the Menu after the views because they may want to access them in the destructor - delete mp_menu; - mp_menu = 0; - delete mp_pr; mp_pr = 0; @@ -739,332 +732,17 @@ MainWindow::~MainWindow () void MainWindow::init_menu () { - // default menu layout - - MenuLayoutEntry secret_menu [] = { - MenuLayoutEntry ("paste_interactive:edit", tl::to_string (QObject::tr ("Paste Interactive")), SLOT (cm_paste_interactive ())), - MenuLayoutEntry ("duplicate_interactive:edit", tl::to_string (QObject::tr ("Duplicate Interactive")), SLOT (cm_duplicate_interactive ())), - MenuLayoutEntry ("sel_move_interactive", tl::to_string (QObject::tr ("Move Interactive")), SLOT (cm_sel_move_interactive ())), - MenuLayoutEntry::last () - }; - - MenuLayoutEntry empty_menu [] = { - MenuLayoutEntry::last () - }; - - MenuLayoutEntry file_menu [] = { - MenuLayoutEntry ("new_layout:edit:edit_mode", tl::to_string (QObject::tr ("New Layout")), SLOT (cm_new_layout ())), - MenuLayoutEntry ("new_panel:edit:edit_mode", tl::to_string (QObject::tr ("New Panel")), SLOT (cm_new_panel ())), - MenuLayoutEntry::separator ("post_new_group:edit_mode"), - MenuLayoutEntry ("open:edit", tl::to_string (QObject::tr ("Open")), SLOT (cm_open ())), - MenuLayoutEntry ("open_same_panel:edit", tl::to_string (QObject::tr ("Open In Same Panel(Shift+Ctrl+O)")), SLOT (cm_open_too ())), - MenuLayoutEntry ("open_new_panel", tl::to_string (QObject::tr ("Open In New Panel(Ctrl+O)")), SLOT (cm_open_new_view ())), - MenuLayoutEntry ("close:edit", tl::to_string (QObject::tr ("Close(Ctrl+W)")), SLOT (cm_close ())), - MenuLayoutEntry ("close_all:edit", tl::to_string (QObject::tr ("Close All(Shift+Ctrl+W)")), SLOT (cm_close_all ())), - MenuLayoutEntry ("clone", tl::to_string (QObject::tr ("Clone Panel")), SLOT (cm_clone ())), - MenuLayoutEntry ("reload:edit", tl::to_string (QObject::tr ("Reload(Ctrl+R)")), SLOT (cm_reload ())), - MenuLayoutEntry ("pull_in:edit", tl::to_string (QObject::tr ("Pull In Other Layout")), SLOT (cm_pull_in ())), - MenuLayoutEntry ("reader_options", tl::to_string (QObject::tr ("Reader Options")), SLOT (cm_reader_options ())), - MenuLayoutEntry::separator ("open_recent_group"), - MenuLayoutEntry ("open_recent_menu:edit", tl::to_string (QObject::tr ("Open Recent")), empty_menu), - MenuLayoutEntry::separator ("import_group"), - MenuLayoutEntry ("import_menu:edit", tl::to_string (QObject::tr ("Import")), empty_menu), - MenuLayoutEntry::separator ("save_group"), - MenuLayoutEntry ("save:hide_vo", tl::to_string (QObject::tr ("Save")), SLOT (cm_save ())), - MenuLayoutEntry ("save_as:hide_vo", tl::to_string (QObject::tr ("Save As")), SLOT (cm_save_as ())), - MenuLayoutEntry ("save_all:hide_vo", tl::to_string (QObject::tr ("Save All")), SLOT (cm_save_all ())), - MenuLayoutEntry ("writer_options:hide_vo", tl::to_string (QObject::tr ("Writer Options")), SLOT (cm_writer_options ())), - MenuLayoutEntry::separator ("setup_group"), - MenuLayoutEntry ("setup:edit", tl::to_string (QObject::tr ("Setup")), SLOT (cm_setup ())), - MenuLayoutEntry::separator ("misc_group"), - MenuLayoutEntry ("screenshot:edit", tl::to_string (QObject::tr ("Screenshot(Print)")), SLOT (cm_screenshot ())), - MenuLayoutEntry ("layout_props:edit", tl::to_string (QObject::tr ("Layout Properties")), SLOT (cm_layout_props ())), - MenuLayoutEntry ("layout_stats:edit", tl::to_string (QObject::tr ("Layout Statistics")), SLOT (cm_layout_stats ())), - MenuLayoutEntry::separator ("layer_group"), - MenuLayoutEntry ("load_layer_props:edit", tl::to_string (QObject::tr ("Load Layer Properties")), SLOT (cm_load_layer_props ())), - MenuLayoutEntry ("save_layer_props:edit", tl::to_string (QObject::tr ("Save Layer Properties")), SLOT (cm_save_layer_props ())), - MenuLayoutEntry::separator ("session_group"), - MenuLayoutEntry ("restore_session:edit", tl::to_string (QObject::tr ("Restore Session")), SLOT (cm_restore_session ())), - MenuLayoutEntry ("save_session", tl::to_string (QObject::tr ("Save Session")), SLOT (cm_save_session ())), - MenuLayoutEntry::separator ("log_group"), - MenuLayoutEntry ("view_log", tl::to_string (QObject::tr ("Log Viewer")), SLOT (cm_view_log ())), - MenuLayoutEntry::separator ("print_group"), - MenuLayoutEntry ("print", tl::to_string (QObject::tr ("Print(Ctrl+P)")), SLOT (cm_print ())), - MenuLayoutEntry::separator ("exit_group"), - MenuLayoutEntry ("exit", tl::to_string (QObject::tr ("Exit(Ctrl+Q)")), SLOT (cm_exit ())), - MenuLayoutEntry::last () - }; - - MenuLayoutEntry edit_utilities_menu [] = { - MenuLayoutEntry::last () - }; - - MenuLayoutEntry edit_layout_menu [] = { - MenuLayoutEntry ("lay_flip_x:edit_mode", tl::to_string (QObject::tr ("Flip Horizontally")), SLOT (cm_lay_flip_x ())), - MenuLayoutEntry ("lay_flip_y:edit_mode", tl::to_string (QObject::tr ("Flip Vertically")), SLOT (cm_lay_flip_y ())), - MenuLayoutEntry ("lay_rot_cw:edit_mode", tl::to_string (QObject::tr ("Rotate Clockwise")), SLOT (cm_lay_rot_cw ())), - MenuLayoutEntry ("lay_rot_ccw:edit_mode", tl::to_string (QObject::tr ("Rotate Counterclockwise")), SLOT (cm_lay_rot_ccw ())), - MenuLayoutEntry ("lay_free_rot:edit_mode", tl::to_string (QObject::tr ("Rotation By Angle")), SLOT (cm_lay_free_rot ())), - MenuLayoutEntry ("lay_scale:edit_mode", tl::to_string (QObject::tr ("Scale")), SLOT (cm_lay_scale ())), - MenuLayoutEntry ("lay_move:edit_mode", tl::to_string (QObject::tr ("Move By")), SLOT (cm_lay_move ())), - MenuLayoutEntry::separator ("cellop_group"), - MenuLayoutEntry ("lay_convert_to_static:edit_mode", tl::to_string (QObject::tr ("Convert All Cells To Static")), SLOT (cm_lay_convert_to_static ())), - MenuLayoutEntry::last () - }; - - MenuLayoutEntry edit_cell_menu [] = { - 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::separator ("ops_group"), - MenuLayoutEntry ("adjust_cell_origin:edit:edit_mode", tl::to_string (QObject::tr ("Adjust Origin")), SLOT (cm_adjust_origin ())), - MenuLayoutEntry ("convert_cell_to_static:edit_mode", tl::to_string (QObject::tr ("Convert Cell To Static")), SLOT (cm_cell_convert_to_static ())), - MenuLayoutEntry::separator ("props_group"), - MenuLayoutEntry ("user_properties", tl::to_string (QObject::tr ("User Properties")), SLOT (cm_cell_user_properties ())), - MenuLayoutEntry::last () - }; - - MenuLayoutEntry edit_layer_menu [] = { - MenuLayoutEntry ("new_layer:edit:edit_mode", tl::to_string (QObject::tr ("New Layer")), SLOT (cm_new_layer ())), - MenuLayoutEntry ("clear_layer:edit:edit_mode", tl::to_string (QObject::tr ("Clear Layer")), SLOT (cm_clear_layer ())), - MenuLayoutEntry ("delete_layer:edit:edit_mode", tl::to_string (QObject::tr ("Delete Layer")), SLOT (cm_delete_layer ())), - MenuLayoutEntry ("copy_layer:edit:edit_mode", tl::to_string (QObject::tr ("Copy Layer")), SLOT (cm_copy_layer ())), - MenuLayoutEntry ("edit_layer:edit:edit_mode", tl::to_string (QObject::tr ("Edit Layer Specification")), SLOT (cm_edit_layer ())), - MenuLayoutEntry::last () - }; - - MenuLayoutEntry edit_selection_menu [] = { - MenuLayoutEntry ("sel_flip_x", tl::to_string (QObject::tr ("Flip Horizontally")), SLOT (cm_sel_flip_x ())), - MenuLayoutEntry ("sel_flip_y", tl::to_string (QObject::tr ("Flip Vertically")), SLOT (cm_sel_flip_y ())), - MenuLayoutEntry ("sel_rot_cw", tl::to_string (QObject::tr ("Rotate Clockwise")), SLOT (cm_sel_rot_cw ())), - MenuLayoutEntry ("sel_rot_ccw", tl::to_string (QObject::tr ("Rotate Counterclockwise")), SLOT (cm_sel_rot_ccw ())), - MenuLayoutEntry ("sel_free_rot", tl::to_string (QObject::tr ("Rotation By Angle")), SLOT (cm_sel_free_rot ())), - MenuLayoutEntry ("sel_scale", tl::to_string (QObject::tr ("Scale")), SLOT (cm_sel_scale ())), - MenuLayoutEntry ("sel_move", tl::to_string (QObject::tr ("Move By")), SLOT (cm_sel_move ())), - MenuLayoutEntry ("sel_move_to", tl::to_string (QObject::tr ("Move To")), SLOT (cm_sel_move_to ())), - MenuLayoutEntry::last () - }; - - MenuLayoutEntry view_menu [] = { - MenuLayoutEntry ("show_grid", tl::to_string (QObject::tr ("Show Grid")), std::make_pair (cfg_grid_visible, "?")), - MenuLayoutEntry ("default_grid:default_grids_group", tl::to_string (QObject::tr ("Grid")), empty_menu), - MenuLayoutEntry::separator ("layout_group"), - MenuLayoutEntry ("show_markers", tl::to_string (QObject::tr ("Show Markers")), std::make_pair (cfg_markers_visible, "?")), - MenuLayoutEntry ("show_texts", tl::to_string (QObject::tr ("Show Texts")), std::make_pair (cfg_text_visible, "?")), - MenuLayoutEntry ("show_cell_boxes", tl::to_string (QObject::tr ("Show Cell Frames")), std::make_pair (cfg_cell_box_visible, "?")), - MenuLayoutEntry ("no_stipples", tl::to_string (QObject::tr ("Show Layers Without Fill")), std::make_pair (cfg_no_stipple, "?")), - MenuLayoutEntry ("synchronized_views", tl::to_string (QObject::tr ("Synchronized Views")), std::make_pair (cfg_synchronized_views, "?")), - MenuLayoutEntry ("edit_top_level_selection:edit_mode", tl::to_string (QObject::tr ("Select Top Level Objects")), std::make_pair (edt::cfg_edit_top_level_selection, "?")), - MenuLayoutEntry::separator ("panels_group"), - MenuLayoutEntry ("show_toolbar", tl::to_string (QObject::tr ("Toolbar")), std::make_pair (cfg_show_toolbar, "?")), - MenuLayoutEntry ("show_navigator", tl::to_string (QObject::tr ("Navigator")), std::make_pair (cfg_show_navigator, "?")), - MenuLayoutEntry ("show_layer_panel", tl::to_string (QObject::tr ("Layers")), std::make_pair (cfg_show_layer_panel, "?")), - MenuLayoutEntry ("show_layer_toolbox", tl::to_string (QObject::tr ("Layer Toolbox")), std::make_pair (cfg_show_layer_toolbox, "?")), - MenuLayoutEntry ("show_hierarchy_panel", tl::to_string (QObject::tr ("Cells")), std::make_pair (cfg_show_hierarchy_panel, "?")), - MenuLayoutEntry ("show_libraries_view", tl::to_string (QObject::tr ("Libraries")), std::make_pair (cfg_show_libraries_view, "?")), - MenuLayoutEntry ("show_bookmarks_view", tl::to_string (QObject::tr ("Bookmarks")), std::make_pair (cfg_show_bookmarks_view, "?")), - MenuLayoutEntry ("reset_window_state", tl::to_string (QObject::tr ("Restore Window")), SLOT (cm_reset_window_state ())), - MenuLayoutEntry::separator ("selection_group"), - MenuLayoutEntry ("transient_selection", tl::to_string (QObject::tr ("Highlight Object Under Mouse")), std::make_pair (cfg_sel_transient_mode, "?")), - MenuLayoutEntry::last () - }; - - MenuLayoutEntry edit_select_menu [] = { - MenuLayoutEntry ("select_all", tl::to_string (QObject::tr ("Select All")), SLOT (cm_select_all ())), - MenuLayoutEntry ("unselect_all", tl::to_string (QObject::tr ("Unselect All")), SLOT (cm_unselect_all ())), - MenuLayoutEntry::separator ("edit_select_basic_group"), - MenuLayoutEntry ("enable_all", tl::to_string (QObject::tr ("Enable All")), SLOT (enable_all ())), - MenuLayoutEntry ("disable_all", tl::to_string (QObject::tr ("Disable All")), SLOT (disable_all ())), - MenuLayoutEntry::separator ("edit_select_individual_group"), - MenuLayoutEntry::last () - }; - - MenuLayoutEntry edit_menu [] = { - MenuLayoutEntry ("undo:edit", tl::to_string (QObject::tr ("Undo(Ctrl+Z)")), SLOT (cm_undo ())), - MenuLayoutEntry ("redo:edit", tl::to_string (QObject::tr ("Redo(Ctrl+Y)")), SLOT (cm_redo ())), - MenuLayoutEntry::separator ("basic_group"), - MenuLayoutEntry ("layout_menu:edit:edit_mode", tl::to_string (QObject::tr ("Layout")), edit_layout_menu), - MenuLayoutEntry ("cell_menu:edit:edit_mode", tl::to_string (QObject::tr ("Cell")), edit_cell_menu), - MenuLayoutEntry ("layer_menu:edit:edit_mode", tl::to_string (QObject::tr ("Layer")), edit_layer_menu), - MenuLayoutEntry ("selection_menu:edit", tl::to_string (QObject::tr ("Selection")), edit_selection_menu), - MenuLayoutEntry::separator ("utils_group"), - MenuLayoutEntry ("utils_menu:edit:edit_mode", tl::to_string (QObject::tr ("Utilities")), edit_utilities_menu), - MenuLayoutEntry::separator ("misc_group") , - MenuLayoutEntry ("delete:edit", tl::to_string (QObject::tr ("Delete(Del)")), SLOT (cm_delete ())), - MenuLayoutEntry ("show_properties:edit", tl::to_string (QObject::tr ("Properties(Q)")), SLOT (cm_show_properties ())), - MenuLayoutEntry::separator ("cpc_group"), - MenuLayoutEntry ("copy:edit", tl::to_string (QObject::tr ("Copy(Ctrl+C)")), SLOT (cm_copy ())), - MenuLayoutEntry ("cut:edit", tl::to_string (QObject::tr ("Cut(Ctrl+X)")), SLOT (cm_cut ())), - MenuLayoutEntry ("paste:edit", tl::to_string (QObject::tr ("Paste(Ctrl+V)")), SLOT (cm_paste ())), - MenuLayoutEntry ("duplicate:edit", tl::to_string (QObject::tr ("Duplicate(Ctrl+B)")), SLOT (cm_duplicate ())), - MenuLayoutEntry::separator ("modes_group"), - MenuLayoutEntry ("mode_menu", tl::to_string (QObject::tr ("Mode")), empty_menu), - MenuLayoutEntry ("select_menu", tl::to_string (QObject::tr ("Select")), edit_select_menu), - MenuLayoutEntry::separator ("cancel_group"), - MenuLayoutEntry ("cancel", tl::to_string (QObject::tr ("Cancel(Esc)")), SLOT (cm_cancel ())), - MenuLayoutEntry::last () - }; - - MenuLayoutEntry bookmark_menu [] = { - MenuLayoutEntry ("goto_bookmark_menu", tl::to_string (QObject::tr ("Goto Bookmark")), empty_menu), - MenuLayoutEntry ("bookmark_view", tl::to_string (QObject::tr ("Bookmark This View")), SLOT (cm_bookmark_view ())), - MenuLayoutEntry::separator ("bookmark_mgm_group"), - MenuLayoutEntry ("manage_bookmarks", tl::to_string (QObject::tr ("Manage Bookmarks")), SLOT (cm_manage_bookmarks ())), - MenuLayoutEntry ("load_bookmarks", tl::to_string (QObject::tr ("Load Bookmarks")), SLOT (cm_load_bookmarks ())), - MenuLayoutEntry ("save_bookmarks", tl::to_string (QObject::tr ("Save Bookmarks")), SLOT (cm_save_bookmarks ())), - MenuLayoutEntry::last () - }; - - MenuLayoutEntry global_trans_menu [] = { - MenuLayoutEntry ("r0", tl::to_string (QObject::tr ("\\(r0\\)<:/r0.png>")), std::make_pair (cfg_global_trans, "?r0 *1 0,0")), - MenuLayoutEntry ("r90", tl::to_string (QObject::tr ("\\(r90\\)<:/r90.png>")), std::make_pair (cfg_global_trans, "?r90 *1 0,0")), - MenuLayoutEntry ("r180", tl::to_string (QObject::tr ("\\(r180\\)<:/r180.png>")), std::make_pair (cfg_global_trans, "?r180 *1 0,0")), - MenuLayoutEntry ("r270", tl::to_string (QObject::tr ("\\(r270\\)<:/r270.png>")), std::make_pair (cfg_global_trans, "?r270 *1 0,0")), - MenuLayoutEntry ("m0", tl::to_string (QObject::tr ("\\(m0\\)<:/m0.png>")), std::make_pair (cfg_global_trans, "?m0 *1 0,0")), - MenuLayoutEntry ("m45", tl::to_string (QObject::tr ("\\(m45\\)<:/m45.png>")), std::make_pair (cfg_global_trans, "?m45 *1 0,0")), - MenuLayoutEntry ("m90", tl::to_string (QObject::tr ("\\(m90\\)<:/m90.png>")), std::make_pair (cfg_global_trans, "?m90 *1 0,0")), - MenuLayoutEntry ("m135", tl::to_string (QObject::tr ("\\(m135\\)<:/m135.png>")), std::make_pair (cfg_global_trans, "?m135 *1 0,0")), - MenuLayoutEntry::last () - }; - - MenuLayoutEntry zoom_menu [] = { - MenuLayoutEntry ("global_trans", tl::to_string (QObject::tr ("Global Transformation")), global_trans_menu), - MenuLayoutEntry ("synchronized_views", tl::to_string (QObject::tr ("Synchronized Views")), std::make_pair (cfg_synchronized_views, "?")), - MenuLayoutEntry::separator ("hier_group"), - MenuLayoutEntry ("max_hier", tl::to_string (QObject::tr ("Full Hierarchy(*)")), SLOT (cm_max_hier ())), - MenuLayoutEntry ("max_hier_0", tl::to_string (QObject::tr ("Box Only(0)")), SLOT (cm_max_hier_0 ())), - MenuLayoutEntry ("max_hier_1", tl::to_string (QObject::tr ("Top Level Only(1)")), SLOT (cm_max_hier_1 ())), - MenuLayoutEntry ("inc_max_hier", tl::to_string (QObject::tr ("Increment Hierarchy(+)")), SLOT (cm_inc_max_hier ())), - MenuLayoutEntry ("dec_max_hier", tl::to_string (QObject::tr ("Decrement Hierarchy(-)")), SLOT (cm_dec_max_hier ())), - MenuLayoutEntry::separator ("zoom_group"), - MenuLayoutEntry ("zoom_fit", tl::to_string (QObject::tr ("Zoom Fit(F2)")), SLOT (cm_zoom_fit ())), - MenuLayoutEntry ("zoom_fit_sel", tl::to_string (QObject::tr ("Zoom Fit Selection(Shift+F2)")), SLOT (cm_zoom_fit_sel ())), - MenuLayoutEntry ("zoom_in", tl::to_string (QObject::tr ("Zoom In(Return)")), SLOT (cm_zoom_in ())), - MenuLayoutEntry ("zoom_out", tl::to_string (QObject::tr ("Zoom Out(Shift+Return)")), SLOT (cm_zoom_out ())), - /* disabled because that interferes with the use of the arrow keys for moving the selection - MenuLayoutEntry::separator ("pan_group"), - MenuLayoutEntry ("pan_up", tl::to_string (QObject::tr ("Pan Up(Up)")), SLOT (cm_pan_up ())), - MenuLayoutEntry ("pan_down", tl::to_string (QObject::tr ("Pan Down(Down)")), SLOT (cm_pan_down ())), - MenuLayoutEntry ("pan_left", tl::to_string (QObject::tr ("Pan Left(Left)")), SLOT (cm_pan_left ())), - MenuLayoutEntry ("pan_right", tl::to_string (QObject::tr ("Pan Right(Right)")), SLOT (cm_pan_right ())), - */ - MenuLayoutEntry::separator ("redraw_group"), - MenuLayoutEntry ("redraw", tl::to_string (QObject::tr ("Redraw")), SLOT (cm_redraw ())), - MenuLayoutEntry::separator ("state_group"), - MenuLayoutEntry ("prev_display_state", tl::to_string (QObject::tr ("Back(Shift+Tab)<:/back.png>")), SLOT (cm_prev_display_state ())), - MenuLayoutEntry ("next_display_state", tl::to_string (QObject::tr ("Forward(Tab)<:/forward.png>")), SLOT (cm_next_display_state ())), - MenuLayoutEntry::separator ("select_group"), - MenuLayoutEntry ("select_cell:edit", tl::to_string (QObject::tr ("Select Cell")), SLOT (cm_select_cell ())), - MenuLayoutEntry ("select_current_cell", tl::to_string (QObject::tr ("Show As New Top(Ctrl+S)")), SLOT (cm_select_current_cell ())), - MenuLayoutEntry ("goto_position", tl::to_string (QObject::tr ("Goto Position(Ctrl+G)")), SLOT (cm_goto_position ())), - MenuLayoutEntry::last () - }; - - MenuLayoutEntry help_menu [] = { - MenuLayoutEntry ("show_all_tips", tl::to_string (QObject::tr ("Show All Tips")), SLOT (cm_show_all_tips ())), - MenuLayoutEntry::separator ("help_topics_group"), - MenuLayoutEntry ("assistant", tl::to_string (QObject::tr ("Assistant")), SLOT (cm_show_assistant ())), - MenuLayoutEntry ("about", tl::to_string (QObject::tr ("About")), SLOT (cm_help_about ())), - MenuLayoutEntry ("about_qt", tl::to_string (QObject::tr ("About Qt")), SLOT (cm_help_about_qt ())), - MenuLayoutEntry::last () - }; - - MenuLayoutEntry tools_menu [] = { - MenuLayoutEntry ("packages", tl::to_string (QObject::tr ("Manage Packages")), SLOT (cm_packages ())), - MenuLayoutEntry ("technologies", tl::to_string (QObject::tr ("Manage Technologies")), SLOT (cm_technologies ())), - MenuLayoutEntry::separator ("verification_group"), - MenuLayoutEntry::separator ("post_verification_group"), - MenuLayoutEntry::last () - }; - - MenuLayoutEntry macros_menu [] = { - MenuLayoutEntry ("macro_development", tl::to_string (QObject::tr ("Macro Development(F5)")), SLOT (cm_macro_editor ())), - MenuLayoutEntry::separator ("macros_group"), - MenuLayoutEntry::last () - }; - - MenuLayoutEntry toolbar_entries [] = { - MenuLayoutEntry ("prev_display_state", "-", SLOT (cm_prev_display_state ())), - MenuLayoutEntry ("next_display_state", "-", SLOT (cm_next_display_state ())), - MenuLayoutEntry::separator ("toolbar_post_navigation_group"), - MenuLayoutEntry::last () - }; - - MenuLayoutEntry main_menu [] = { - MenuLayoutEntry ("file_menu", tl::to_string (QObject::tr ("&File")), file_menu), - MenuLayoutEntry ("edit_menu", tl::to_string (QObject::tr ("&Edit")), edit_menu), - MenuLayoutEntry ("view_menu", tl::to_string (QObject::tr ("&View")), view_menu), - MenuLayoutEntry ("bookmark_menu", tl::to_string (QObject::tr ("&Bookmarks")), bookmark_menu), - MenuLayoutEntry ("zoom_menu", tl::to_string (QObject::tr ("&Display")), zoom_menu), - MenuLayoutEntry ("tools_menu", tl::to_string (QObject::tr ("&Tools")), tools_menu), - MenuLayoutEntry ("macros_menu", tl::to_string (QObject::tr ("&Macros")), macros_menu), - MenuLayoutEntry::separator ("help_group"), - MenuLayoutEntry ("help_menu", tl::to_string (QObject::tr ("&Help")), help_menu), - MenuLayoutEntry ("@secrets", tl::to_string (QObject::tr ("Secret Features")), secret_menu), - MenuLayoutEntry ("@toolbar", "", toolbar_entries), - MenuLayoutEntry::last () - }; - - mp_menu = new AbstractMenu (this); - mp_menu->init (main_menu); - - lay::LayoutView::init_menu (*mp_menu); - lay::Navigator::init_menu (*mp_menu); - - // Fill the mode menu file items from the intrinsic mouse modes - // TODO: map the intrinsic modes to standard plugins and remove this code along - // with related code in LayoutView. After this we can simplify the menu inititialization - // inside PluginDeclaration as well. - - std::vector mode_titles; - lay::LayoutView::intrinsic_mouse_modes (&mode_titles); - - int mode_id = 0; - for (std::vector ::const_iterator t = mode_titles.begin (); t != mode_titles.end (); ++t, --mode_id) { - - if (! t->empty ()) { - - // extract first part, which is the name, separated by a tab from the title. - std::string name = tl::sprintf ("mode_i%d", 1 - mode_id); - std::string title = *t; - const char *tab = strchr (t->c_str (), '\t'); - if (tab) { - name = std::string (*t, 0, tab - t->c_str ()); - title = tab + 1; - } - - Action action (title); - action.set_checkable (true); - action.qaction ()->setData (QVariant (mode_id)); - action.add_to_exclusive_group (mp_menu, "mouse_mode_exclusive_group"); - - mp_menu->insert_item ("edit_menu.mode_menu.end", name, action); - mp_menu->insert_item ("@toolbar.end", name, action); - - gtf::action_connect (action.qaction (), SIGNAL (triggered ()), this, SLOT (intrinsic_mode_triggered ())); - - } - - } - - // Add a hook for inserting new items after the modes - Action end_modes; - end_modes.set_separator (true); - mp_menu->insert_item ("@toolbar.end", "end_modes", end_modes); - // make the plugins create their menu items for (tl::Registrar::iterator cls = tl::Registrar::begin (); cls != tl::Registrar::end (); ++cls) { // TODO: get rid of the const_cast hack - const_cast (&*cls)->init_menu (); + const_cast (&*cls)->init_menu (this); } // if in "viewer-only mode", hide all entries in the "hide_vo" group if ((lay::ApplicationBase::instance () && lay::ApplicationBase::instance ()->is_vo_mode ())) { - std::vector hide_vo_grp = mp_menu->group ("hide_vo"); + std::vector hide_vo_grp = menu ()->group ("hide_vo"); for (std::vector::const_iterator g = hide_vo_grp.begin (); g != hide_vo_grp.end (); ++g) { - mp_menu->action (*g).set_visible (false); + menu ()->action (*g).set_visible (false); } } @@ -1072,14 +750,14 @@ MainWindow::init_menu () // TODO: later do this on each change of the view - each view might get it's own editable mode bool view_mode = (lay::ApplicationBase::instance () && !lay::ApplicationBase::instance ()->is_editable ()); - std::vector edit_mode_grp = mp_menu->group ("edit_mode"); + std::vector edit_mode_grp = menu ()->group ("edit_mode"); for (std::vector::const_iterator g = edit_mode_grp.begin (); g != edit_mode_grp.end (); ++g) { - mp_menu->action (*g).set_visible (! view_mode); + menu ()->action (*g).set_visible (! view_mode); } - std::vector view_mode_grp = mp_menu->group ("view_mode"); + std::vector view_mode_grp = menu ()->group ("view_mode"); for (std::vector::const_iterator g = view_mode_grp.begin (); g != view_mode_grp.end (); ++g) { - mp_menu->action (*g).set_visible (view_mode); + menu ()->action (*g).set_visible (view_mode); } } @@ -1087,17 +765,17 @@ void MainWindow::dock_widget_visibility_changed (bool /*visible*/) { if (sender () == mp_lp_dock_widget) { - plugin_root ()->config_set (cfg_show_layer_panel, tl::to_string (!mp_lp_dock_widget->isHidden ())); + dispatcher ()->config_set (cfg_show_layer_panel, tl::to_string (!mp_lp_dock_widget->isHidden ())); } else if (sender () == mp_hp_dock_widget) { - plugin_root ()->config_set (cfg_show_hierarchy_panel, tl::to_string (!mp_hp_dock_widget->isHidden ())); + dispatcher ()->config_set (cfg_show_hierarchy_panel, tl::to_string (!mp_hp_dock_widget->isHidden ())); } else if (sender () == mp_libs_dock_widget) { - plugin_root ()->config_set (cfg_show_libraries_view, tl::to_string (!mp_libs_dock_widget->isHidden ())); + dispatcher ()->config_set (cfg_show_libraries_view, tl::to_string (!mp_libs_dock_widget->isHidden ())); } else if (sender () == mp_bm_dock_widget) { - plugin_root ()->config_set (cfg_show_bookmarks_view, tl::to_string (!mp_bm_dock_widget->isHidden ())); + dispatcher ()->config_set (cfg_show_bookmarks_view, tl::to_string (!mp_bm_dock_widget->isHidden ())); } else if (sender () == mp_navigator_dock_widget) { - plugin_root ()->config_set (cfg_show_navigator, tl::to_string (!mp_navigator_dock_widget->isHidden ())); + dispatcher ()->config_set (cfg_show_navigator, tl::to_string (!mp_navigator_dock_widget->isHidden ())); } else if (sender () == mp_layer_toolbox_dock_widget) { - plugin_root ()->config_set (cfg_show_layer_toolbox, tl::to_string (!mp_layer_toolbox_dock_widget->isHidden ())); + dispatcher ()->config_set (cfg_show_layer_toolbox, tl::to_string (!mp_layer_toolbox_dock_widget->isHidden ())); } } @@ -1294,7 +972,7 @@ MainWindow::about_to_exec () lay::TipDialog::button_type button = lay::TipDialog::null_button; if (td.exec_dialog (button)) { if (button == lay::TipDialog::yes_button) { - plugin_root ()->config_set (cfg_full_hier_new_cell, true); + dispatcher ()->config_set (cfg_full_hier_new_cell, true); } // Don't bother the user with more dialogs. return; @@ -1489,12 +1167,7 @@ MainWindow::config_finalize () bool MainWindow::configure (const std::string &name, const std::string &value) { - std::map >::iterator ca = m_configuration_actions.find (name); - if (ca != m_configuration_actions.end ()) { - for (std::vector::const_iterator a = ca->second.begin (); a != ca->second.end (); ++a) { - (*a)->configure (value); - } - } + lay::Dispatcher::configure (name, value); if (name == cfg_grid) { @@ -1814,16 +1487,16 @@ MainWindow::edits_enabled_changed () { bool enable = edits_enabled (); - std::vector edit_grp = mp_menu->group ("edit"); + std::vector edit_grp = menu ()->group ("edit"); for (std::vector::const_iterator g = edit_grp.begin (); g != edit_grp.end (); ++g) { - mp_menu->action (*g).set_enabled (enable); + menu ()->action (*g).set_enabled (enable); } } void MainWindow::menu_needs_update () { - lay::LayoutView::update_menu (current_view (), *mp_menu); + lay::LayoutView::update_menu (current_view (), *menu ()); } void @@ -1840,12 +1513,12 @@ MainWindow::libraries_changed () void MainWindow::read_dock_widget_state () { - plugin_root ()->config_set (cfg_show_layer_panel, tl::to_string (!mp_lp_dock_widget->isHidden ())); - plugin_root ()->config_set (cfg_show_hierarchy_panel, tl::to_string (!mp_hp_dock_widget->isHidden ())); - plugin_root ()->config_set (cfg_show_libraries_view, tl::to_string (!mp_libs_dock_widget->isHidden ())); - plugin_root ()->config_set (cfg_show_bookmarks_view, tl::to_string (!mp_bm_dock_widget->isHidden ())); - plugin_root ()->config_set (cfg_show_navigator, tl::to_string (!mp_navigator_dock_widget->isHidden ())); - plugin_root ()->config_set (cfg_show_layer_toolbox, tl::to_string (!mp_layer_toolbox_dock_widget->isHidden ())); + dispatcher ()->config_set (cfg_show_layer_panel, tl::to_string (!mp_lp_dock_widget->isHidden ())); + dispatcher ()->config_set (cfg_show_hierarchy_panel, tl::to_string (!mp_hp_dock_widget->isHidden ())); + dispatcher ()->config_set (cfg_show_libraries_view, tl::to_string (!mp_libs_dock_widget->isHidden ())); + dispatcher ()->config_set (cfg_show_bookmarks_view, tl::to_string (!mp_bm_dock_widget->isHidden ())); + dispatcher ()->config_set (cfg_show_navigator, tl::to_string (!mp_navigator_dock_widget->isHidden ())); + dispatcher ()->config_set (cfg_show_layer_toolbox, tl::to_string (!mp_layer_toolbox_dock_widget->isHidden ())); } void @@ -1970,7 +1643,7 @@ MainWindow::can_close () for (tl::Registrar::iterator cls = tl::Registrar::begin (); cls != tl::Registrar::end (); ++cls) { lay::PluginDeclaration *pd = const_cast (&*cls); - if (! pd->can_exit (plugin_root ())) { + if (! pd->can_exit (dispatcher ())) { return false; } } @@ -2015,8 +1688,8 @@ MainWindow::save_state_to_config () { // save the dock widget state with all views closed (that state can be // used for staring klayout without any layout) - plugin_root ()->config_set (cfg_window_geometry, (const char *) saveGeometry ().toBase64 ().data ()); - plugin_root ()->config_set (cfg_window_state, (const char *) saveState ().toBase64 ().data ()); + dispatcher ()->config_set (cfg_window_geometry, (const char *) saveGeometry ().toBase64 ().data ()); + dispatcher ()->config_set (cfg_window_state, (const char *) saveState ().toBase64 ().data ()); } void @@ -2040,29 +1713,23 @@ MainWindow::closeEvent (QCloseEvent *event) void MainWindow::cm_navigator_freeze () { - BEGIN_PROTECTED if (mp_navigator) { mp_navigator->freeze_clicked (); } - END_PROTECTED } void MainWindow::cm_navigator_close () { - BEGIN_PROTECTED if (mp_navigator) { mp_navigator->close (); } - END_PROTECTED } void MainWindow::cm_view_log () { - BEGIN_PROTECTED mp_log_viewer_dialog->show (); - END_PROTECTED } void @@ -2070,8 +1737,6 @@ MainWindow::cm_print () { // TODO: move to lay::LayoutView - BEGIN_PROTECTED - // Late-initialize the printer to save time on startup if (! mp_printer.get ()) { mp_printer.reset (new QPrinter ()); @@ -2134,16 +1799,12 @@ MainWindow::cm_print () } } - - END_PROTECTED } void MainWindow::cm_exit () { - BEGIN_PROTECTED exit (); - END_PROTECTED } lay::LayoutView * @@ -2190,205 +1851,6 @@ MainWindow::current_view () const return lay::LayoutView::current (); } -void -MainWindow::cm_show_properties () -{ - if (current_view ()) { - current_view ()->show_properties (this); - } -} - -void -MainWindow::cm_delete () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->del (); - // because a "delete" might involve objects currently edited, we cancel the edit after we have deleted the object - current_view ()->cancel (); - current_view ()->clear_selection (); - } - - END_PROTECTED -} - -void -MainWindow::cm_lv_paste () -{ - BEGIN_PROTECTED - current_view ()->cm_layer_paste (); - END_PROTECTED -} - -void -MainWindow::cm_lv_cut () -{ - BEGIN_PROTECTED - current_view ()->cm_layer_cut (); - END_PROTECTED -} - -void -MainWindow::cm_lv_copy () -{ - BEGIN_PROTECTED - current_view ()->cm_layer_copy (); - END_PROTECTED -} - -void -MainWindow::cm_cell_paste () -{ - BEGIN_PROTECTED - current_view ()->cm_cell_paste (); - END_PROTECTED -} - -void -MainWindow::cm_cell_cut () -{ - BEGIN_PROTECTED - current_view ()->cm_cell_cut (); - END_PROTECTED -} - -void -MainWindow::cm_cell_copy () -{ - BEGIN_PROTECTED - current_view ()->cm_cell_copy (); - END_PROTECTED -} - -void -MainWindow::do_cm_duplicate (bool interactive) -{ - BEGIN_PROTECTED - - if (current_view ()) { - - // Do duplicate simply by concatenating copy & paste currently. - // Save the clipboard state before in order to preserve the current content - db::Clipboard saved_clipboard; - db::Clipboard::instance ().swap (saved_clipboard); - - try { - current_view ()->copy (); - current_view ()->clear_selection (); - current_view ()->cancel (); - if (interactive) { - current_view ()->paste_interactive (); - } else { - current_view ()->paste (); - } - db::Clipboard::instance ().swap (saved_clipboard); - } catch (...) { - db::Clipboard::instance ().swap (saved_clipboard); - throw; - } - - } - - END_PROTECTED -} - -void -MainWindow::cm_duplicate () -{ - BEGIN_PROTECTED - - do_cm_duplicate (false); - - END_PROTECTED -} - -void -MainWindow::cm_duplicate_interactive () -{ - BEGIN_PROTECTED - - do_cm_duplicate (true); - - END_PROTECTED -} - -void -MainWindow::cm_copy () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->copy (); - current_view ()->clear_selection (); - } - - END_PROTECTED -} - -void -MainWindow::do_cm_paste (bool interactive) -{ - BEGIN_PROTECTED - - if (current_view () && ! db::Clipboard::instance ().empty ()) { - current_view ()->cancel (); - current_view ()->clear_selection (); - if (interactive) { - current_view ()->paste_interactive (); - } else { - current_view ()->paste (); - } - } - - END_PROTECTED -} - -void -MainWindow::cm_paste () -{ - do_cm_paste (false); -} - -void -MainWindow::cm_paste_interactive () -{ - do_cm_paste (true); -} - -void -MainWindow::cm_cut () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cut (); - current_view ()->cancel (); // see del() for reason why cancel is after cut - current_view ()->clear_selection (); - } - - END_PROTECTED -} - -void -MainWindow::intrinsic_mode_triggered () -{ - BEGIN_PROTECTED - - QAction *action = dynamic_cast (sender ()); - if (action) { - - int mode = action->data ().toInt (); - - plugin_root ()->select_mode (mode); - - action->setChecked (true); - - } - - END_PROTECTED -} - void MainWindow::select_mode (int m) { @@ -2418,37 +1880,17 @@ MainWindow::select_mode (int m) void MainWindow::enable_all () { - BEGIN_PROTECTED - for (tl::Registrar::iterator cls = tl::Registrar::begin (); cls != tl::Registrar::end (); ++cls) { cls->set_editable_enabled (true); } - - END_PROTECTED } void MainWindow::disable_all () { - BEGIN_PROTECTED - for (tl::Registrar::iterator cls = tl::Registrar::begin (); cls != tl::Registrar::end (); ++cls) { cls->set_editable_enabled (false); } - - END_PROTECTED -} - -void -MainWindow::cm_unselect_all () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->select (db::DBox (), lay::Editable::Reset); - } - - END_PROTECTED } void @@ -2458,25 +1900,9 @@ MainWindow::cm_reset_window_state () restoreGeometry (m_default_window_geometry); } -void -MainWindow::cm_select_all () -{ - BEGIN_PROTECTED - - if (current_view ()) { - // TODO: "select all" with an empty box is not well implemented in most services. - // Hence we use the overlapp box currently. - current_view ()->select (current_view ()->full_box (), lay::Editable::Replace); - } - - END_PROTECTED -} - void MainWindow::cm_undo () { - BEGIN_PROTECTED - if (current_view () && m_manager.available_undo ().first) { for (std::vector ::iterator vp = mp_views.begin (); vp != mp_views.end (); ++vp) { (*vp)->clear_selection (); @@ -2484,15 +1910,11 @@ MainWindow::cm_undo () } m_manager.undo (); } - - END_PROTECTED } void MainWindow::cm_redo () { - BEGIN_PROTECTED - if (current_view () && m_manager.available_redo ().first) { for (std::vector ::iterator vp = mp_views.begin (); vp != mp_views.end (); ++vp) { (*vp)->clear_selection (); @@ -2500,15 +1922,11 @@ MainWindow::cm_redo () } m_manager.redo (); } - - END_PROTECTED } void MainWindow::cm_goto_position () { - BEGIN_PROTECTED - if (current_view ()) { while (true) { @@ -2585,141 +2003,31 @@ MainWindow::cm_goto_position () } } - - END_PROTECTED } void MainWindow::cm_manage_bookmarks () { - BEGIN_PROTECTED - if (current_view ()) { current_view ()->manage_bookmarks (); } - - END_PROTECTED } void MainWindow::cm_bookmark_view () { - BEGIN_PROTECTED - if (current_view ()) { current_view ()->bookmark_current_view (); } - - END_PROTECTED } void MainWindow::update_content () { - BEGIN_PROTECTED - mp_setup_form->setup (); if (current_view ()) { current_view ()->update_content (); } - - END_PROTECTED -} - -void -MainWindow::cm_zoom_fit_sel () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->zoom_fit_sel (); - } - - END_PROTECTED -} - -void -MainWindow::cm_zoom_fit () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->zoom_fit (); - } - - END_PROTECTED -} - -void -MainWindow::cm_pan_left () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->pan_left (); - } - - END_PROTECTED -} - -void -MainWindow::cm_pan_right () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->pan_right (); - } - - END_PROTECTED -} - -void -MainWindow::cm_pan_up () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->pan_up (); - } - - END_PROTECTED -} - -void -MainWindow::cm_pan_down () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->pan_down (); - } - - END_PROTECTED -} - -void -MainWindow::cm_zoom_in () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->zoom_in (); - } - - END_PROTECTED -} - -void -MainWindow::cm_zoom_out () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->zoom_out (); - } - - END_PROTECTED } void @@ -2727,9 +2035,9 @@ MainWindow::update_action_states () { try { - if (mp_menu->is_valid ("edit_menu.undo")) { + if (menu ()->is_valid ("edit_menu.undo")) { - Action undo_action = mp_menu->action ("edit_menu.undo"); + Action undo_action = menu ()->action ("edit_menu.undo"); std::string undo_txt (tl::to_string (QObject::tr ("&Undo"))); bool undo_enable = false; @@ -2742,9 +2050,9 @@ MainWindow::update_action_states () } - if (mp_menu->is_valid ("edit_menu.redo")) { + if (menu ()->is_valid ("edit_menu.redo")) { - Action redo_action = mp_menu->action ("edit_menu.redo"); + Action redo_action = menu ()->action ("edit_menu.redo"); std::string redo_txt (tl::to_string (QObject::tr ("&Redo"))); bool redo_enable = false; @@ -2757,18 +2065,18 @@ MainWindow::update_action_states () } - if (mp_menu->is_valid ("edit_menu.paste")) { - Action paste_action = mp_menu->action ("edit_menu.paste"); + if (menu ()->is_valid ("edit_menu.paste")) { + Action paste_action = menu ()->action ("edit_menu.paste"); paste_action.set_enabled (! db::Clipboard::instance ().empty () && edits_enabled ()); } - if (mp_menu->is_valid ("zoom_menu.next_display_state")) { - Action next_display_state_action = mp_menu->action ("zoom_menu.next_display_state"); + if (menu ()->is_valid ("zoom_menu.next_display_state")) { + Action next_display_state_action = menu ()->action ("zoom_menu.next_display_state"); next_display_state_action.set_enabled (has_next_display_state ()); } - if (mp_menu->is_valid ("zoom_menu.prev_display_state")) { - Action prev_display_state_action = mp_menu->action ("zoom_menu.prev_display_state"); + if (menu ()->is_valid ("zoom_menu.prev_display_state")) { + Action prev_display_state_action = menu ()->action ("zoom_menu.prev_display_state"); prev_display_state_action.set_enabled (has_prev_display_state ()); } @@ -2777,14 +2085,6 @@ MainWindow::update_action_states () } } -void -MainWindow::cm_redraw () -{ - BEGIN_PROTECTED - redraw (); - END_PROTECTED -} - void MainWindow::redraw () { @@ -2796,9 +2096,7 @@ MainWindow::redraw () void MainWindow::cm_cancel () { - BEGIN_PROTECTED cancel (); - END_PROTECTED } /** @@ -2820,23 +2118,6 @@ MainWindow::cancel () select_mode (lay::LayoutView::default_mode ()); } -void -MainWindow::cm_save_layer_props () -{ - BEGIN_PROTECTED - - if (current_view ()) { - std::string fn; - if (mp_lprops_fdia->get_save (fn, tl::to_string (QObject::tr ("Save Layer Properties File")))) { - current_view ()->save_layer_props (fn); - } - } else { - throw tl::Exception (tl::to_string (QObject::tr ("No view open to save the layer properties from"))); - } - - END_PROTECTED -} - void MainWindow::load_layer_properties (const std::string &fn, bool all_views, bool add_default) { @@ -2893,11 +2174,22 @@ MainWindow::is_single_cv_layer_properties_file (const std::string &fn) return (cv.size () == 1); } +void +MainWindow::cm_save_layer_props () +{ + if (current_view ()) { + std::string fn; + if (mp_lprops_fdia->get_save (fn, tl::to_string (QObject::tr ("Save Layer Properties File")))) { + current_view ()->save_layer_props (fn); + } + } else { + throw tl::Exception (tl::to_string (QObject::tr ("No view open to save the layer properties from"))); + } +} + void MainWindow::cm_load_layer_props () { - BEGIN_PROTECTED - if (current_view ()) { std::string fn; if (mp_lprops_fdia->get_open (fn, tl::to_string (QObject::tr ("Load Layer Properties File")))) { @@ -2935,8 +2227,6 @@ MainWindow::cm_load_layer_props () } else { throw tl::Exception (tl::to_string (QObject::tr ("No view open to load the layer properties for"))); } - - END_PROTECTED } void @@ -2961,8 +2251,6 @@ MainWindow::restore_session (const std::string &fn) void MainWindow::cm_save_session () { - BEGIN_PROTECTED - std::string df_list; int dirty_layouts = dirty_files (df_list); @@ -2979,15 +2267,11 @@ MainWindow::cm_save_session () } } - - END_PROTECTED } void MainWindow::cm_restore_session () { - BEGIN_PROTECTED - std::string fn = m_current_session; if (mp_session_fdia->get_open (fn, tl::to_string (QObject::tr ("Load Session File")))) { @@ -3014,15 +2298,11 @@ MainWindow::cm_restore_session () } } - - END_PROTECTED } void MainWindow::cm_save_bookmarks () { - BEGIN_PROTECTED - if (current_view ()) { std::string fn; if (mp_bookmarks_fdia->get_save (fn, tl::to_string (QObject::tr ("Save Bookmarks File")))) { @@ -3031,15 +2311,11 @@ MainWindow::cm_save_bookmarks () } else { throw tl::Exception (tl::to_string (QObject::tr ("No view open to save the bookmarks from"))); } - - END_PROTECTED } void MainWindow::cm_load_bookmarks () { - BEGIN_PROTECTED - if (current_view ()) { std::string fn; if (mp_bookmarks_fdia->get_open (fn, tl::to_string (QObject::tr ("Load Bookmarks File")))) { @@ -3050,66 +2326,11 @@ MainWindow::cm_load_bookmarks () } else { throw tl::Exception (tl::to_string (QObject::tr ("No view open to load the bookmarks for"))); } - - END_PROTECTED -} - -void -MainWindow::cm_select_current_cell () -{ - BEGIN_PROTECTED - - lay::LayoutView *view = current_view (); - if (view && view->active_cellview_index () >= 0) { - lay::LayoutView::cell_path_type path; - int cvi = view->active_cellview_index (); - view->current_cell_path (path); - view->select_cell_fit (path, cvi); - } - - END_PROTECTED -} - -void -MainWindow::cm_open_current_cell () -{ - BEGIN_PROTECTED - - if (current_view () && current_view ()->active_cellview_index () >= 0) { - current_view ()->cm_open_current_cell (); - } - - END_PROTECTED -} - -void -MainWindow::cm_select_cell () -{ - BEGIN_PROTECTED - - if (current_view () && current_view ()->active_cellview_index () >= 0) { - - CellSelectionForm form (0, current_view (), "cell_selection_form"); - - if (form.exec () == QDialog::Accepted && - form.selected_cellview_index () >= 0) { - current_view ()->select_cell (form.selected_cellview ().combined_unspecific_path (), form.selected_cellview_index ()); - current_view ()->set_current_cell_path (form.selected_cellview_index (), form.selected_cellview ().combined_unspecific_path ()); - current_view ()->zoom_fit (); - } - - } else { - throw tl::Exception (tl::to_string (QObject::tr ("No view open to select a cell for"))); - } - - END_PROTECTED } void MainWindow::cm_screenshot () { - BEGIN_PROTECTED - if (current_view ()) { std::string fn; if (mp_screenshot_fdia->get_save (fn, tl::to_string (QObject::tr ("Save Screenshot")))) { @@ -3118,15 +2339,11 @@ MainWindow::cm_screenshot () } else { throw tl::Exception (tl::to_string (QObject::tr ("No view open to create a screenshot from"))); } - - END_PROTECTED } void MainWindow::cm_save_current_cell_as () { - BEGIN_PROTECTED - if (current_view ()) { int cv_index = current_view ()->active_cellview_index (); @@ -3174,8 +2391,6 @@ MainWindow::cm_save_current_cell_as () } } - - END_PROTECTED } void @@ -3193,8 +2408,6 @@ MainWindow::cm_save_as () void MainWindow::do_save (bool as) { - BEGIN_PROTECTED - if (current_view ()) { std::vector cv_indexes; @@ -3252,49 +2465,43 @@ MainWindow::do_save (bool as) } else { throw tl::Exception (tl::to_string (QObject::tr ("No view open to save"))); } - - END_PROTECTED } void MainWindow::cm_save_all () { - BEGIN_PROTECTED + for (int view_index = 0; view_index < int (views ()); ++view_index) { - for (int view_index = 0; view_index < int (views ()); ++view_index) { + for (unsigned int cv_index = 0; cv_index < view (view_index)->cellviews (); ++cv_index) { - for (unsigned int cv_index = 0; cv_index < view (view_index)->cellviews (); ++cv_index) { + const lay::CellView &cv = view (view_index)->cellview (cv_index); + std::string fn = cv->filename (); - const lay::CellView &cv = view (view_index)->cellview (cv_index); - std::string fn = cv->filename (); + if (! fn.empty () || mp_layout_fdia->get_save (fn, tl::to_string (tr ("Save Layout '%1'").arg (tl::to_qstring (cv->name ()))))) { - if (! fn.empty () || mp_layout_fdia->get_save (fn, tl::to_string (tr ("Save Layout '%1'").arg (tl::to_qstring (cv->name ()))))) { + db::SaveLayoutOptions options (cv->save_options ()); + options.set_dbu (cv->layout ().dbu ()); - db::SaveLayoutOptions options (cv->save_options ()); - options.set_dbu (cv->layout ().dbu ()); + options.set_format_from_filename (fn); - options.set_format_from_filename (fn); + tl::OutputStream::OutputStreamMode om = tl::OutputStream::OM_Auto; - tl::OutputStream::OutputStreamMode om = tl::OutputStream::OM_Auto; - - // initialize the specific options from the configuration if required - for (tl::Registrar::iterator cls = tl::Registrar::begin (); cls != tl::Registrar::end (); ++cls) { - const StreamWriterPluginDeclaration *decl = dynamic_cast (&*cls); - if (decl) { - options.set_options (decl->create_specific_options ()); - } + // initialize the specific options from the configuration if required + for (tl::Registrar::iterator cls = tl::Registrar::begin (); cls != tl::Registrar::end (); ++cls) { + const StreamWriterPluginDeclaration *decl = dynamic_cast (&*cls); + if (decl) { + options.set_options (decl->create_specific_options ()); } - - view (view_index)->save_as (cv_index, fn, om, options, true); - add_mru (fn, current_view ()->cellview (cv_index)->tech_name ()); - } + view (view_index)->save_as (cv_index, fn, om, options, true); + add_mru (fn, current_view ()->cellview (cv_index)->tech_name ()); + } } - END_PROTECTED + } } void @@ -3394,8 +2601,6 @@ MainWindow::cm_open () void MainWindow::cm_pull_in () { - BEGIN_PROTECTED - std::vector names; lay::LayoutHandle::get_names (names); @@ -3457,20 +2662,18 @@ MainWindow::cm_pull_in () } } - - END_PROTECTED } void MainWindow::cm_reader_options () { - mp_layout_load_options->edit_global_options (plugin_root (), db::Technologies::instance ()); + mp_layout_load_options->edit_global_options (dispatcher (), db::Technologies::instance ()); } void MainWindow::cm_writer_options () { - mp_layout_save_options->edit_global_options (plugin_root (), db::Technologies::instance ()); + mp_layout_save_options->edit_global_options (dispatcher (), db::Technologies::instance ()); } void @@ -3482,257 +2685,32 @@ MainWindow::cm_new_panel () void MainWindow::cm_new_layout () { - BEGIN_PROTECTED - std::string technology = m_initial_technology; + static std::string s_new_cell_cell_name; + static double s_new_cell_window_size = 2.0; double dbu = 0.0; lay::NewLayoutPropertiesDialog dialog (this); - if (dialog.exec_dialog (technology, m_new_cell_cell_name, dbu, m_new_cell_window_size, m_new_layout_current_panel)) { + if (dialog.exec_dialog (technology, s_new_cell_cell_name, dbu, s_new_cell_window_size, m_new_layout_current_panel)) { lay::CellViewRef cellview = create_or_load_layout (0, 0, technology, m_new_layout_current_panel ? 2 : 1 /*= new view*/); if (dbu > 1e-10) { cellview->layout ().dbu (dbu); } - db::cell_index_type new_ci = cellview->layout ().add_cell (m_new_cell_cell_name.empty () ? 0 : m_new_cell_cell_name.c_str ()); + db::cell_index_type new_ci = cellview->layout ().add_cell (s_new_cell_cell_name.empty () ? 0 : s_new_cell_cell_name.c_str ()); cellview.set_cell (new_ci); - current_view ()->zoom_box_and_set_hier_levels (db::DBox (-0.5 * m_new_cell_window_size, -0.5 * m_new_cell_window_size, 0.5 * m_new_cell_window_size, 0.5 * m_new_cell_window_size), std::make_pair (0, 1)); + current_view ()->zoom_box_and_set_hier_levels (db::DBox (-0.5 * s_new_cell_window_size, -0.5 * s_new_cell_window_size, 0.5 * s_new_cell_window_size, 0.5 * s_new_cell_window_size), std::make_pair (0, 1)); } - - END_PROTECTED -} - -void -MainWindow::call_on_current_view (void (lay::LayoutView::*func) (), const std::string &op_desc) -{ - BEGIN_PROTECTED - - lay::LayoutView *curr = current_view (); - if (! curr || curr->active_cellview_index () < 0) { - throw tl::Exception (tl::to_string (QObject::tr ("No view open for operation: ")) + op_desc); - } - - (curr->*func) (); - - END_PROTECTED -} - -void -MainWindow::cm_adjust_origin () -{ - call_on_current_view (&lay::LayoutView::cm_align_cell_origin, tl::to_string (QObject::tr ("adjust cell origin"))); -} - -void -MainWindow::cm_new_cell () -{ - // TODO: move this function to lay::LayoutView - - BEGIN_PROTECTED - - lay::LayoutView *curr = current_view (); - if (! curr || curr->active_cellview_index () < 0) { - throw tl::Exception (tl::to_string (QObject::tr ("No view open to create a new cell inside"))); - } - - NewCellPropertiesDialog cell_prop_dia (this); - if (cell_prop_dia.exec_dialog (& curr->cellview (curr->active_cellview_index ())->layout (), m_new_cell_cell_name, m_new_cell_window_size)) { - - db::cell_index_type new_ci = curr->new_cell (curr->active_cellview_index (), m_new_cell_cell_name.c_str ()); - curr->select_cell (new_ci, curr->active_cellview_index ()); - - db::DBox zoom_box = db::DBox (-0.5 * m_new_cell_window_size, -0.5 * m_new_cell_window_size, 0.5 * m_new_cell_window_size, 0.5 * m_new_cell_window_size); - if (curr->get_max_hier_levels () < 1 || curr->get_min_hier_levels () > 0) { - curr->zoom_box_and_set_hier_levels (zoom_box, std::make_pair (0, 1)); - } else { - curr->zoom_box (zoom_box); - } - - } - - END_PROTECTED -} - -void -MainWindow::cm_cell_convert_to_static () -{ - call_on_current_view (&lay::LayoutView::cm_cell_convert_to_static, tl::to_string (QObject::tr ("convert cell to static"))); -} - -void -MainWindow::cm_lay_convert_to_static () -{ - call_on_current_view (&lay::LayoutView::cm_lay_convert_to_static, tl::to_string (QObject::tr ("convert all cells to static"))); -} - -void -MainWindow::cm_lay_move () -{ - call_on_current_view (&lay::LayoutView::cm_lay_move, tl::to_string (QObject::tr ("move layout"))); -} - -void -MainWindow::cm_lay_scale () -{ - call_on_current_view (&lay::LayoutView::cm_lay_scale, tl::to_string (QObject::tr ("scale layout"))); -} - -void -MainWindow::cm_lay_free_rot () -{ - call_on_current_view (&lay::LayoutView::cm_lay_free_rot, tl::to_string (QObject::tr ("free rotation of layout"))); -} - -void -MainWindow::cm_lay_rot_ccw () -{ - call_on_current_view (&lay::LayoutView::cm_lay_rot_ccw, tl::to_string (QObject::tr ("counter clockwise rotation of layout"))); -} - -void -MainWindow::cm_lay_rot_cw () -{ - call_on_current_view (&lay::LayoutView::cm_lay_rot_cw, tl::to_string (QObject::tr ("clockwise rotation of layout"))); -} - -void -MainWindow::cm_lay_flip_y () -{ - call_on_current_view (&lay::LayoutView::cm_lay_flip_y, tl::to_string (QObject::tr ("vertical flip of layout"))); -} - -void -MainWindow::cm_lay_flip_x () -{ - call_on_current_view (&lay::LayoutView::cm_lay_flip_x, tl::to_string (QObject::tr ("horizontal flip of layout"))); -} - -void -MainWindow::cm_sel_move () -{ - call_on_current_view (&lay::LayoutView::cm_sel_move, tl::to_string (QObject::tr ("move selection"))); -} - -void -MainWindow::cm_sel_move_to () -{ - call_on_current_view (&lay::LayoutView::cm_sel_move_to, tl::to_string (QObject::tr ("move selection to position"))); -} - -void -MainWindow::cm_sel_move_interactive () -{ - call_on_current_view (&lay::LayoutView::cm_sel_move_interactive, tl::to_string (QObject::tr ("move selection interactively"))); -} - -void -MainWindow::cm_sel_scale () -{ - call_on_current_view (&lay::LayoutView::cm_sel_scale, tl::to_string (QObject::tr ("scale selection"))); -} - -void -MainWindow::cm_sel_free_rot () -{ - call_on_current_view (&lay::LayoutView::cm_sel_free_rot, tl::to_string (QObject::tr ("free rotation of selection"))); -} - -void -MainWindow::cm_sel_rot_ccw () -{ - call_on_current_view (&lay::LayoutView::cm_sel_rot_ccw, tl::to_string (QObject::tr ("counter clockwise rotation of selection"))); -} - -void -MainWindow::cm_sel_rot_cw () -{ - call_on_current_view (&lay::LayoutView::cm_sel_rot_cw, tl::to_string (QObject::tr ("clockwise rotation of selection"))); -} - -void -MainWindow::cm_sel_flip_y () -{ - call_on_current_view (&lay::LayoutView::cm_sel_flip_y, tl::to_string (QObject::tr ("vertical flip of selection"))); -} - -void -MainWindow::cm_sel_flip_x () -{ - call_on_current_view (&lay::LayoutView::cm_sel_flip_x, tl::to_string (QObject::tr ("horizontal flip of selection"))); -} - -void -MainWindow::cm_edit_layer () -{ - call_on_current_view (&lay::LayoutView::cm_edit_layer, tl::to_string (QObject::tr ("edit a layer specification"))); -} - -void -MainWindow::cm_delete_layer () -{ - call_on_current_view (&lay::LayoutView::cm_delete_layer, tl::to_string (QObject::tr ("delete a layer"))); -} - -void -MainWindow::cm_clear_layer () -{ - call_on_current_view (&lay::LayoutView::cm_clear_layer, tl::to_string (QObject::tr ("clear a layer"))); -} - -void -MainWindow::cm_copy_layer () -{ - call_on_current_view (&lay::LayoutView::cm_copy_layer, tl::to_string (QObject::tr ("copy layer"))); -} - -void -MainWindow::cm_new_layer () -{ - call_on_current_view (&lay::LayoutView::cm_new_layer, tl::to_string (QObject::tr ("create a new layer"))); -} - -void -MainWindow::cm_layout_props () -{ - BEGIN_PROTECTED - - lay::LayoutView *curr = current_view (); - if (! curr) { - throw tl::Exception (tl::to_string (QObject::tr ("No view open to show layout properties for"))); - } - - LayoutPropertiesForm lp_form (this, curr, "layout_props_form"); - lp_form.exec (); - - END_PROTECTED -} - -void -MainWindow::cm_layout_stats () -{ - BEGIN_PROTECTED - - lay::LayoutView *curr = current_view (); - if (! curr) { - throw tl::Exception (tl::to_string (QObject::tr ("No view open to show layout statistics for"))); - } - - LayoutStatisticsForm lp_form (this, curr, "layout_props_form"); - lp_form.exec (); - - END_PROTECTED } void MainWindow::cm_clone () { - BEGIN_PROTECTED clone_current_view (); - END_PROTECTED } void @@ -3745,7 +2723,7 @@ MainWindow::clone_current_view () } // create a new view - view = new lay::LayoutView (current_view (), &m_manager, lay::ApplicationBase::instance ()->is_editable (), plugin_root (), mp_view_stack); + view = new lay::LayoutView (current_view (), &m_manager, lay::ApplicationBase::instance ()->is_editable (), dispatcher (), mp_view_stack); add_view (view); // set initial attributes @@ -4059,83 +3037,6 @@ MainWindow::close_view (int index) } } -void -MainWindow::cm_reload () -{ - BEGIN_PROTECTED - - if (current_view ()) { - - std::vector selected; - - if (current_view ()->cellviews () > 1) { - - SelectCellViewForm form (0, current_view (), tl::to_string (QObject::tr ("Select Layouts To Reload"))); - form.select_all (); - - if (form.exec () == QDialog::Accepted) { - selected = form.selected_cellviews (); - } - - } else if (current_view ()->cellviews () > 0) { - selected.push_back (0); - } - - if (selected.size () > 0) { - - int dirty_layouts = 0; - std::string dirty_files; - - for (std::vector ::const_iterator i = selected.begin (); i != selected.end (); ++i) { - - const lay::CellView &cv = current_view ()->cellview (*i); - - if (cv->layout ().is_editable () && cv->is_dirty ()) { - ++dirty_layouts; - if (dirty_layouts == max_dirty_files) { - dirty_files += "\n..."; - } else if (dirty_layouts < max_dirty_files) { - if (! dirty_files.empty ()) { - dirty_files += "\n"; - } - dirty_files += cv->name (); - } - } - - } - - bool can_reload = true; - if (dirty_layouts != 0) { - - QMessageBox mbox (this); - mbox.setText (tl::to_qstring (tl::to_string (QObject::tr ("The following layouts need saving:\n\n")) + dirty_files + "\n\nPress 'Reload Without Saving' to reload anyhow and discard changes.")); - mbox.setWindowTitle (QObject::tr ("Save Needed")); - mbox.setIcon (QMessageBox::Warning); - QAbstractButton *yes_button = mbox.addButton (QObject::tr ("Reload Without Saving"), QMessageBox::YesRole); - mbox.addButton (QMessageBox::Cancel); - - mbox.exec (); - - can_reload = (mbox.clickedButton() == yes_button); - - } - - if (can_reload) { - - // Actually reload - for (std::vector ::const_iterator i = selected.begin (); i != selected.end (); ++i) { - reload_layout (*i); - } - - } - - } - - } - - END_PROTECTED -} - void MainWindow::add_mru (const std::string &fn_rel) { @@ -4173,7 +3074,7 @@ MainWindow::add_mru (const std::string &fn_rel, const std::string &tech) } } - plugin_root ()->config_set (cfg_mru, config_str); + dispatcher ()->config_set (cfg_mru, config_str); } void @@ -4181,15 +3082,15 @@ MainWindow::do_update_file_menu () { std::string mru_menu = "file_menu.open_recent_menu"; - if (mp_menu->is_valid (mru_menu)) { + if (menu ()->is_valid (mru_menu)) { - Action open_recent_action = mp_menu->action (mru_menu); + Action open_recent_action = menu ()->action (mru_menu); open_recent_action.set_enabled (true); if (m_mru.size () > 0 && edits_enabled ()) { // rebuild MRU menu - mp_menu->clear_menu (mru_menu); + menu ()->clear_menu (mru_menu); for (std::vector >::iterator mru = m_mru.end (); mru != m_mru.begin (); ) { --mru; @@ -4198,7 +3099,7 @@ MainWindow::do_update_file_menu () gtf::action_connect (action.qaction (), SIGNAL (triggered ()), this, SLOT (open_recent ())); action.set_title (mru->first); action.qaction ()->setData (QVariant (int (i))); - mp_menu->insert_item (mru_menu + ".end", tl::sprintf ("open_recent_%d", i + 1), action); + menu ()->insert_item (mru_menu + ".end", tl::sprintf ("open_recent_%d", i + 1), action); } } else { @@ -4226,7 +3127,7 @@ MainWindow::open_recent () return; } - if (mp_layout_load_options->show_always () && !mp_layout_load_options->edit_global_options (plugin_root (), db::Technologies::instance ())) { + if (mp_layout_load_options->show_always () && !mp_layout_load_options->edit_global_options (dispatcher (), db::Technologies::instance ())) { return; } @@ -4275,7 +3176,7 @@ MainWindow::open (int mode) return; } - if (mp_layout_load_options->show_always () && !mp_layout_load_options->edit_global_options (plugin_root (), db::Technologies::instance ())) { + if (mp_layout_load_options->show_always () && !mp_layout_load_options->edit_global_options (dispatcher (), db::Technologies::instance ())) { return; } @@ -4366,7 +3267,7 @@ int MainWindow::do_create_view () { // create a new view - lay::LayoutView *view = new lay::LayoutView (&m_manager, lay::ApplicationBase::instance ()->is_editable (), plugin_root (), mp_view_stack); + lay::LayoutView *view = new lay::LayoutView (&m_manager, lay::ApplicationBase::instance ()->is_editable (), dispatcher (), mp_view_stack); add_view (view); // set initial attributes @@ -4571,56 +3472,6 @@ MainWindow::grid_micron () const return m_grid_micron; } -void -MainWindow::cm_inc_max_hier () -{ - BEGIN_PROTECTED - - int new_to = get_max_hier_levels () + 1; - set_hier_levels (std::make_pair (get_min_hier_levels (), new_to)); - - END_PROTECTED -} - -void -MainWindow::cm_dec_max_hier () -{ - BEGIN_PROTECTED - - int new_to = get_max_hier_levels () > 0 ? get_max_hier_levels () - 1 : 0; - set_hier_levels (std::make_pair (std::min (get_min_hier_levels (), new_to), new_to)); - - END_PROTECTED -} - -void -MainWindow::cm_max_hier () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->max_hier (); - } - - END_PROTECTED -} - -void -MainWindow::cm_max_hier_0 () -{ - BEGIN_PROTECTED - set_hier_levels (std::make_pair (std::min (get_min_hier_levels (), 0), 0)); - END_PROTECTED -} - -void -MainWindow::cm_max_hier_1 () -{ - BEGIN_PROTECTED - set_hier_levels (std::make_pair (std::min (get_min_hier_levels (), 0), 1)); - END_PROTECTED -} - void MainWindow::set_hier_levels (std::pair l) { @@ -4641,18 +3492,6 @@ MainWindow::get_hier_levels () const } } -void -MainWindow::cm_prev_display_state () -{ - BEGIN_PROTECTED - - if (has_prev_display_state ()) { - current_view ()->prev_display_state (); - } - - END_PROTECTED -} - bool MainWindow::has_prev_display_state () { @@ -4663,18 +3502,6 @@ MainWindow::has_prev_display_state () } } -void -MainWindow::cm_next_display_state () -{ - BEGIN_PROTECTED - - if (has_next_display_state ()) { - current_view ()->next_display_state (); - } - - END_PROTECTED -} - bool MainWindow::has_next_display_state () { @@ -4903,7 +3730,7 @@ MainWindow::show_assistant_topic (const std::string &s, bool modal) void MainWindow::cm_show_all_tips () { - plugin_root ()->config_set (cfg_tip_window_hidden, ""); + dispatcher ()->config_set (cfg_tip_window_hidden, ""); } void @@ -4919,71 +3746,110 @@ MainWindow::cm_help_about_qt () QApplication::aboutQt (); } -lay::Action & -MainWindow::action_for_slot (const char *slot) +std::vector +MainWindow::menu_symbols () { - std::map::iterator a = m_actions_for_slot.find (std::string (slot)); - if (a != m_actions_for_slot.end ()) { - return a->second; - } else { - Action a = Action::create_free_action (this); - gtf::action_connect (a.qaction (), SIGNAL (triggered ()), this, slot); - return m_actions_for_slot.insert (std::make_pair (std::string (slot), a)).first->second; - } -} - -lay::Action * -MainWindow::create_config_action (const std::string &title, const std::string &cname, const std::string &cvalue) -{ - lay::ConfigureAction *ca = new lay::ConfigureAction(plugin_root (), title, cname, cvalue); - m_ca_collection.push_back (ca); - return ca; -} - -lay::Action * -MainWindow::create_config_action (const std::string &cname, const std::string &cvalue) -{ - lay::ConfigureAction *ca = new lay::ConfigureAction(plugin_root (), std::string (), cname, cvalue); - m_ca_collection.push_back (ca); - return ca; -} - -void -MainWindow::register_config_action (const std::string &name, lay::ConfigureAction *action) -{ - std::map >::iterator ca = m_configuration_actions.insert (std::make_pair (name, std::vector ())).first; - for (std::vector::iterator a = ca->second.begin (); a != ca->second.end (); ++a) { - if (*a == action) { - return; // already registered - } - } - - ca->second.push_back (action); -} - -void -MainWindow::unregister_config_action (const std::string &name, lay::ConfigureAction *action) -{ - std::map >::iterator ca = m_configuration_actions.find (name); - if (ca != m_configuration_actions.end ()) { - for (std::vector::iterator a = ca->second.begin (); a != ca->second.end (); ++a) { - if (*a == action) { - ca->second.erase (a); - return; - } - } - } + // TODO: currently these are all symbols from all plugins + return lay::PluginDeclaration::menu_symbols (); } void MainWindow::menu_activated (const std::string &symbol) { - // TODO: this can be part of the Plugin scheme, but the plugin root has no idea which is the active - // view. - if (current_view ()) { - current_view ()->menu_activated (symbol); + if (symbol == "cm_navigator_freeze") { + cm_navigator_freeze (); + } else if (symbol == "cm_navigator_close") { + cm_navigator_close (); + } else if (symbol == "cm_view_log") { + cm_view_log (); + } else if (symbol == "cm_print") { + cm_print (); + } else if (symbol == "cm_exit") { + cm_exit (); + } else if (symbol == "cm_reset_window_state") { + cm_reset_window_state (); + } else if (symbol == "cm_undo") { + cm_undo (); + } else if (symbol == "cm_redo") { + cm_redo (); + } else if (symbol == "cm_goto_position") { + cm_goto_position (); + } else if (symbol == "cm_manage_bookmarks") { + cm_manage_bookmarks (); + } else if (symbol == "cm_bookmark_view") { + cm_bookmark_view (); + } else if (symbol == "cm_cancel") { + cm_cancel (); + } else if (symbol == "cm_save_layer_props") { + cm_save_layer_props (); + } else if (symbol == "cm_load_layer_props") { + cm_load_layer_props (); + } else if (symbol == "cm_save_session") { + cm_save_session (); + } else if (symbol == "cm_restore_session") { + cm_restore_session (); + } else if (symbol == "cm_save_bookmarks") { + cm_save_bookmarks (); + } else if (symbol == "cm_load_bookmarks") { + cm_load_bookmarks (); + } else if (symbol == "cm_screenshot") { + cm_screenshot (); + } else if (symbol == "cm_save_current_cell_as") { + cm_save_current_cell_as (); + } else if (symbol == "cm_save") { + cm_save (); + } else if (symbol == "cm_save_as") { + cm_save_as (); + } else if (symbol == "cm_save_all") { + cm_save_all (); + } else if (symbol == "cm_setup") { + cm_setup (); + } else if (symbol == "cm_open_too") { + cm_open_too (); + } else if (symbol == "cm_open_new_view") { + cm_open_new_view (); + } else if (symbol == "cm_open") { + cm_open (); + } else if (symbol == "cm_pull_in") { + cm_pull_in (); + } else if (symbol == "cm_reader_options") { + cm_reader_options (); + } else if (symbol == "cm_writer_options") { + cm_writer_options (); + } else if (symbol == "cm_new_panel") { + cm_new_panel (); + } else if (symbol == "cm_new_layout") { + cm_new_layout (); + } else if (symbol == "cm_clone") { + cm_clone (); + } else if (symbol == "cm_close_all") { + cm_close_all (); + } else if (symbol == "cm_close") { + cm_close (); + } else if (symbol == "cm_packages") { + cm_packages (); + } else if (symbol == "cm_technologies") { + cm_technologies (); + } else if (symbol == "cm_macro_editor") { + cm_macro_editor (); + } else if (symbol == "cm_show_assistant") { + cm_show_assistant (); + } else if (symbol == "cm_show_all_tips") { + cm_show_all_tips (); + } else if (symbol == "cm_help_about") { + cm_help_about (); + } else if (symbol == "cm_help_about_qt") { + cm_help_about_qt (); } else { - throw tl::Exception (tl::to_string (QObject::tr ("No view is active"))); + + // TODO: this can be part of the Plugin scheme, but the plugin root has no idea which is the active + // view. + if (current_view ()) { + current_view ()->menu_activated (symbol); + } else { + throw tl::Exception (tl::to_string (QObject::tr ("No view is active"))); + } + } } @@ -4997,463 +3863,13 @@ MainWindow::menu_changed () void MainWindow::do_update_menu () { - mp_menu->build (menuBar (), mp_tool_bar); + menu ()->build (menuBar (), mp_tool_bar); lay::GuiApplication *app = dynamic_cast (qApp); if (app) { app->force_update_app_menu (); } } -void -MainWindow::cm_cell_user_properties () -{ - call_on_current_view (&lay::LayoutView::cm_cell_user_properties, tl::to_string (QObject::tr ("edit cell's user properties"))); -} - -void -MainWindow::cm_cell_delete () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_cell_delete (); - } - - END_PROTECTED -} - -void -MainWindow::cm_cell_replace () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_cell_replace (); - } - - END_PROTECTED -} - -void -MainWindow::cm_cell_rename () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_cell_rename (); - } - - END_PROTECTED -} - -void -MainWindow::cm_cell_flatten () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_cell_flatten (); - } - - END_PROTECTED -} - -void -MainWindow::cm_cell_select () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_cell_select (); - } - - END_PROTECTED -} - -void -MainWindow::cm_cell_hide () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_cell_hide (); - } - - END_PROTECTED -} - -void -MainWindow::cm_cell_show () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_cell_show (); - } - - END_PROTECTED -} - -void -MainWindow::cm_cell_show_all () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_cell_show_all (); - } - - END_PROTECTED -} - -void -MainWindow::cm_lv_select_all () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_select_all (); - } - - END_PROTECTED -} - -void -MainWindow::cm_lv_new_tab () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_new_tab (); - } - - END_PROTECTED -} - -void -MainWindow::cm_lv_rename_tab () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_rename_tab (); - } - - END_PROTECTED -} - -void -MainWindow::cm_lv_remove_tab () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_remove_tab (); - } - - END_PROTECTED -} - -void -MainWindow::cm_lv_make_invalid () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_make_invalid (); - } - - END_PROTECTED -} - -void -MainWindow::cm_lv_make_valid () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_make_valid (); - } - - END_PROTECTED -} - -void -MainWindow::cm_lv_hide_all () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_hide_all (); - } - - END_PROTECTED -} - -void -MainWindow::cm_lv_hide () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_hide (); - } - - END_PROTECTED -} - -void -MainWindow::cm_lv_show_only () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_show_only (); - } - - END_PROTECTED -} - -void -MainWindow::cm_lv_show_all () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_show_all (); - } - - END_PROTECTED -} - -void -MainWindow::cm_lv_show () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_show (); - } - - END_PROTECTED -} - -void -MainWindow::cm_lv_rename () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_rename (); - } - - END_PROTECTED -} - -void -MainWindow::cm_lv_delete () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_delete (); - } - - END_PROTECTED -} - -void -MainWindow::cm_lv_insert () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_insert (); - } - - END_PROTECTED -} - -void -MainWindow::cm_lv_group () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_group (); - } - - END_PROTECTED -} - -void -MainWindow::cm_lv_ungroup () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_ungroup (); - } - - END_PROTECTED -} - -void -MainWindow::cm_lv_source () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_source (); - } - - END_PROTECTED -} - -void -MainWindow::cm_lv_sort_by_name () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_sort_by_name (); - } - - END_PROTECTED -} - -void -MainWindow::cm_lv_sort_by_ild () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_sort_by_ild (); - } - - END_PROTECTED -} - -void -MainWindow::cm_lv_sort_by_idl () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_sort_by_idl (); - } - - END_PROTECTED -} - -void -MainWindow::cm_lv_sort_by_ldi () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_sort_by_ldi (); - } - - END_PROTECTED -} - -void -MainWindow::cm_lv_sort_by_dli () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_sort_by_dli (); - } - - END_PROTECTED -} - -void -MainWindow::cm_lv_regroup_by_index () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_regroup_by_index (); - } - - END_PROTECTED -} - -void -MainWindow::cm_lv_regroup_by_datatype () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_regroup_by_datatype (); - } - - END_PROTECTED -} - -void -MainWindow::cm_lv_regroup_by_layer () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_regroup_by_layer (); - } - - END_PROTECTED -} - -void -MainWindow::cm_lv_regroup_flatten () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_regroup_flatten (); - } - - END_PROTECTED -} - -void -MainWindow::cm_lv_expand_all () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_expand_all (); - } - - END_PROTECTED -} - -void -MainWindow::cm_lv_add_missing () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_add_missing (); - } - - END_PROTECTED -} - -void -MainWindow::cm_lv_remove_unused () -{ - BEGIN_PROTECTED - - if (current_view ()) { - current_view ()->cm_remove_unused (); - } - - END_PROTECTED -} - void MainWindow::dragEnterEvent(QDragEnterEvent *event) { @@ -5637,11 +4053,11 @@ MainWindow::plugin_registered (lay::PluginDeclaration *cls) // store current state in configuration save_state_to_config (); - cls->init_menu (); + cls->init_menu (dispatcher ()); // recreate all plugins for (std::vector ::iterator vp = mp_views.begin (); vp != mp_views.end (); ++vp) { - (*vp)->create_plugins (plugin_root ()); + (*vp)->create_plugins (); } } @@ -5652,27 +4068,29 @@ MainWindow::plugin_removed (lay::PluginDeclaration *cls) // recreate all plugins except the one that got removed for (std::vector ::iterator vp = mp_views.begin (); vp != mp_views.end (); ++vp) { - (*vp)->create_plugins (plugin_root (), cls); + (*vp)->create_plugins (cls); } } // ------------------------------------------------------------ // Implementation of the PluginRootToMainWindow bride -PluginRootToMainWindow::PluginRootToMainWindow () - : mp_main_window (0) +DispatcherToMainWindow::DispatcherToMainWindow () + : lay::Dispatcher (0, false), + mp_main_window (0) + { // .. nothing yet .. } void -PluginRootToMainWindow::attach_to (lay::MainWindow *main_window) +DispatcherToMainWindow::attach_to (lay::MainWindow *main_window) { mp_main_window = main_window; } void -PluginRootToMainWindow::plugin_registered (lay::PluginDeclaration *cls) +DispatcherToMainWindow::plugin_registered (lay::PluginDeclaration *cls) { if (mp_main_window.get ()) { mp_main_window->plugin_registered (cls); @@ -5683,7 +4101,7 @@ PluginRootToMainWindow::plugin_registered (lay::PluginDeclaration *cls) } void -PluginRootToMainWindow::plugin_removed (lay::PluginDeclaration *cls) +DispatcherToMainWindow::plugin_removed (lay::PluginDeclaration *cls) { if (mp_main_window.get ()) { mp_main_window->plugin_removed (cls); @@ -5694,7 +4112,7 @@ PluginRootToMainWindow::plugin_removed (lay::PluginDeclaration *cls) } void -PluginRootToMainWindow::select_mode (int mode) +DispatcherToMainWindow::select_mode (int mode) { if (mp_main_window.get ()) { mp_main_window->select_mode (mode); @@ -5702,7 +4120,7 @@ PluginRootToMainWindow::select_mode (int mode) } void -PluginRootToMainWindow::menu_activated (const std::string &symbol) +DispatcherToMainWindow::menu_activated (const std::string &symbol) { if (mp_main_window.get ()) { mp_main_window->menu_activated (symbol); @@ -5811,5 +4229,118 @@ HelpAboutDialog::~HelpAboutDialog () mp_ui = 0; } +// ------------------------------------------------------------ +// Declaration of the "plugin" for the menu entries + +class MainWindowPluginDeclaration + : public lay::PluginDeclaration +{ +public: + virtual void get_menu_entries (std::vector &menu_entries) const + { + std::string at; + + at = ".end"; + menu_entries.push_back (lay::submenu ("file_menu", at, tl::to_string (QObject::tr ("&File")))); + menu_entries.push_back (lay::submenu ("edit_menu", at, tl::to_string (QObject::tr ("&Edit")))); + menu_entries.push_back (lay::submenu ("view_menu", at, tl::to_string (QObject::tr ("&View")))); + menu_entries.push_back (lay::submenu ("bookmark_menu", at, tl::to_string (QObject::tr ("&Bookmarks")))); + menu_entries.push_back (lay::submenu ("zoom_menu", at, tl::to_string (QObject::tr ("&Display")))); + menu_entries.push_back (lay::submenu ("tools_menu", at, tl::to_string (QObject::tr ("&Tools")))); + menu_entries.push_back (lay::submenu ("macros_menu", at, tl::to_string (QObject::tr ("&Macros")))); + menu_entries.push_back (lay::separator ("help_group", at)); + menu_entries.push_back (lay::submenu ("help_menu", at, tl::to_string (QObject::tr ("&Help")))); + menu_entries.push_back (lay::submenu ("@secrets", at, tl::to_string (QObject::tr ("Secret Features")))); + menu_entries.push_back (lay::submenu ("@toolbar", at, std::string ())); + + at = "file_menu.end"; + menu_entries.push_back (lay::menu_item ("cm_new_layout", "new_layout:edit:edit_mode", at, tl::to_string (QObject::tr ("New Layout")))); + menu_entries.push_back (lay::menu_item ("cm_new_panel", "new_panel:edit:edit_mode", at, tl::to_string (QObject::tr ("New Panel")))); + menu_entries.push_back (lay::separator ("post_new_group:edit_mode", at)); + menu_entries.push_back (lay::menu_item ("cm_open", "open:edit", at, tl::to_string (QObject::tr ("Open")))); + menu_entries.push_back (lay::menu_item ("cm_open_too", "open_same_panel:edit", at, tl::to_string (QObject::tr ("Open In Same Panel(Shift+Ctrl+O)")))); + menu_entries.push_back (lay::menu_item ("cm_open_new_view", "open_new_panel", at, tl::to_string (QObject::tr ("Open In New Panel(Ctrl+O)")))); + menu_entries.push_back (lay::menu_item ("cm_close", "close:edit", at, tl::to_string (QObject::tr ("Close(Ctrl+W)")))); + menu_entries.push_back (lay::menu_item ("cm_close_all", "close_all:edit", at, tl::to_string (QObject::tr ("Close All(Shift+Ctrl+W)")))); + menu_entries.push_back (lay::menu_item ("cm_clone", "clone", at, tl::to_string (QObject::tr ("Clone Panel")))); + menu_entries.push_back (lay::menu_item ("cm_reload", "reload:edit", at, tl::to_string (QObject::tr ("Reload(Ctrl+R)")))); + menu_entries.push_back (lay::menu_item ("cm_pull_in", "pull_in:edit", at, tl::to_string (QObject::tr ("Pull In Other Layout")))); + menu_entries.push_back (lay::menu_item ("cm_reader_options", "reader_options", at, tl::to_string (QObject::tr ("Reader Options")))); + menu_entries.push_back (lay::separator ("open_recent_group", at)); + menu_entries.push_back (lay::submenu ("open_recent_menu:edit", at, tl::to_string (QObject::tr ("Open Recent")))); + menu_entries.push_back (lay::separator ("import_group", at)); + menu_entries.push_back (lay::submenu ("import_menu:edit", at, tl::to_string (QObject::tr ("Import")))); + menu_entries.push_back (lay::separator ("save_group", at)); + menu_entries.push_back (lay::menu_item ("cm_save", "save:hide_vo", at, tl::to_string (QObject::tr ("Save")))); + menu_entries.push_back (lay::menu_item ("cm_save_as", "save_as:hide_vo", at, tl::to_string (QObject::tr ("Save As")))); + menu_entries.push_back (lay::menu_item ("cm_save_all", "save_all:hide_vo", at, tl::to_string (QObject::tr ("Save All")))); + menu_entries.push_back (lay::menu_item ("cm_writer_options", "writer_options:hide_vo", at, tl::to_string (QObject::tr ("Writer Options")))); + menu_entries.push_back (lay::separator ("setup_group", at)); + menu_entries.push_back (lay::menu_item ("cm_setup", "setup:edit", at, tl::to_string (QObject::tr ("Setup")))); + menu_entries.push_back (lay::separator ("misc_group", at)); + menu_entries.push_back (lay::menu_item ("cm_screenshot", "screenshot:edit", at, tl::to_string (QObject::tr ("Screenshot(Print)")))); + menu_entries.push_back (lay::menu_item ("cm_layout_props", "layout_props:edit", at, tl::to_string (QObject::tr ("Layout Properties")))); + menu_entries.push_back (lay::menu_item ("cm_layout_stats", "layout_stats:edit", at, tl::to_string (QObject::tr ("Layout Statistics")))); + menu_entries.push_back (lay::separator ("layer_group", at)); + menu_entries.push_back (lay::menu_item ("cm_load_layer_props", "load_layer_props:edit", at, tl::to_string (QObject::tr ("Load Layer Properties")))); + menu_entries.push_back (lay::menu_item ("cm_save_layer_props", "save_layer_props:edit", at, tl::to_string (QObject::tr ("Save Layer Properties")))); + menu_entries.push_back (lay::separator ("session_group", at)); + menu_entries.push_back (lay::menu_item ("cm_restore_session", "restore_session:edit", at, tl::to_string (QObject::tr ("Restore Session")))); + menu_entries.push_back (lay::menu_item ("cm_save_session", "save_session", at, tl::to_string (QObject::tr ("Save Session")))); + menu_entries.push_back (lay::separator ("log_group", at)); + menu_entries.push_back (lay::menu_item ("cm_view_log", "view_log", at, tl::to_string (QObject::tr ("Log Viewer")))); + menu_entries.push_back (lay::separator ("print_group", at)); + menu_entries.push_back (lay::menu_item ("cm_print", "print", at, tl::to_string (QObject::tr ("Print(Ctrl+P)")))); + menu_entries.push_back (lay::separator ("exit_group", at)); + menu_entries.push_back (lay::menu_item ("cm_exit", "exit", at, tl::to_string (QObject::tr ("Exit(Ctrl+Q)")))); + + at = "view_menu.end"; + menu_entries.push_back (lay::config_menu_item ("show_grid", at, tl::to_string (QObject::tr ("Show Grid")), cfg_grid_visible, "?")), + menu_entries.push_back (lay::submenu ("default_grid:default_grids_group", at, tl::to_string (QObject::tr ("Grid")))); + menu_entries.push_back (lay::separator ("layout_group", at)); + menu_entries.push_back (lay::config_menu_item ("show_markers", at, tl::to_string (QObject::tr ("Show Markers")), cfg_markers_visible, "?")); + menu_entries.push_back (lay::config_menu_item ("show_texts", at, tl::to_string (QObject::tr ("Show Texts")), cfg_text_visible, "?")); + menu_entries.push_back (lay::config_menu_item ("show_cell_boxes", at, tl::to_string (QObject::tr ("Show Cell Frames")), cfg_cell_box_visible, "?")); + menu_entries.push_back (lay::config_menu_item ("no_stipples", at, tl::to_string (QObject::tr ("Show Layers Without Fill")), cfg_no_stipple, "?")); + menu_entries.push_back (lay::config_menu_item ("synchronized_views", at, tl::to_string (QObject::tr ("Synchronized Views")), cfg_synchronized_views, "?")); + menu_entries.push_back (lay::config_menu_item ("edit_top_level_selection:edit_mode", at, tl::to_string (QObject::tr ("Select Top Level Objects")), edt::cfg_edit_top_level_selection, "?")); + menu_entries.push_back (lay::separator ("panels_group", at)); + menu_entries.push_back (lay::config_menu_item ("show_toolbar", at, tl::to_string (QObject::tr ("Toolbar")), cfg_show_toolbar, "?")); + menu_entries.push_back (lay::config_menu_item ("show_navigator", at, tl::to_string (QObject::tr ("Navigator")), cfg_show_navigator, "?")); + menu_entries.push_back (lay::config_menu_item ("show_layer_panel", at, tl::to_string (QObject::tr ("Layers")), cfg_show_layer_panel, "?")); + menu_entries.push_back (lay::config_menu_item ("show_layer_toolbox", at, tl::to_string (QObject::tr ("Layer Toolbox")), cfg_show_layer_toolbox, "?")); + menu_entries.push_back (lay::config_menu_item ("show_hierarchy_panel", at, tl::to_string (QObject::tr ("Cells")), cfg_show_hierarchy_panel, "?")); + menu_entries.push_back (lay::config_menu_item ("show_libraries_view", at, tl::to_string (QObject::tr ("Libraries")), cfg_show_libraries_view, "?")); + menu_entries.push_back (lay::config_menu_item ("show_bookmarks_view", at, tl::to_string (QObject::tr ("Bookmarks")), cfg_show_bookmarks_view, "?")); + menu_entries.push_back (lay::menu_item ("cm_reset_window_state", "reset_window_state", at, tl::to_string (QObject::tr ("Restore Window")))), + menu_entries.push_back (lay::separator ("selection_group", at)); + menu_entries.push_back (lay::config_menu_item ("transient_selection", at, tl::to_string (QObject::tr ("Highlight Object Under Mouse")), cfg_sel_transient_mode, "?")); + + at = "help_menu.end"; + menu_entries.push_back (lay::menu_item ("cm_show_all_tips", "show_all_tips", at, tl::to_string (QObject::tr ("Show All Tips")))); + menu_entries.push_back (lay::separator ("help_topics_group", at)); + menu_entries.push_back (lay::menu_item ("cm_show_assistant", "assistant", at, tl::to_string (QObject::tr ("Assistant")))); + menu_entries.push_back (lay::menu_item ("cm_help_about", "about", at, tl::to_string (QObject::tr ("About")))); + menu_entries.push_back (lay::menu_item ("cm_help_about_qt", "about_qt", at, tl::to_string (QObject::tr ("About Qt")))); + + at = "tools_menu.end"; + menu_entries.push_back (lay::menu_item ("cm_packages", "packages", at, tl::to_string (QObject::tr ("Manage Packages")))); + menu_entries.push_back (lay::menu_item ("cm_technologies", "technologies", at, tl::to_string (QObject::tr ("Manage Technologies")))); + menu_entries.push_back (lay::separator ("verification_group", at)); + menu_entries.push_back (lay::separator ("post_verification_group", at)); + + at = "macros_menu.end"; + menu_entries.push_back (lay::menu_item ("cm_macro_editor", "macro_development", at, tl::to_string (QObject::tr ("Macro Development(F5)")))); + menu_entries.push_back (lay::separator ("macros_group", at)); + + at = "@toolbar.end"; + menu_entries.push_back (lay::menu_item ("cm_prev_display_state", "prev_display_state", at, "-")); + menu_entries.push_back (lay::menu_item ("cm_next_display_state", "next_display_state", at, "-")); + menu_entries.push_back (lay::separator ("toolbar_post_navigation_group", at)); + } +}; + +static tl::RegisteredClass config_decl (new MainWindowPluginDeclaration (), -100, "MainWindowPlugin"); + } // namespace lay diff --git a/src/lay/lay/layMainWindow.h b/src/lay/lay/layMainWindow.h index 4429ee394..78d133f7f 100644 --- a/src/lay/lay/layMainWindow.h +++ b/src/lay/lay/layMainWindow.h @@ -40,7 +40,7 @@ #include "dbManager.h" #include "dbLoadLayoutOptions.h" #include "layAbstractMenu.h" -#include "layAbstractMenuProvider.h" +#include "layDispatcher.h" #include "layLayoutView.h" #include "layPlugin.h" #include "layProgress.h" @@ -118,8 +118,7 @@ private: class LAY_PUBLIC MainWindow : public QMainWindow, - public lay::Plugin, - public lay::AbstractMenuProvider + public lay::Dispatcher { Q_OBJECT public: @@ -140,21 +139,13 @@ public: ~MainWindow (); /** - * @brief Implementation of the AbstractMenuProvider interface + * @brief Implementation of the Dispatcher interface */ QWidget *menu_parent_widget () { return this; } - /** - * @brief Get the main menu abstraction object - */ - AbstractMenu *menu () - { - return mp_menu; - } - /** * @brief Shows the window * @@ -407,12 +398,12 @@ public: bool show_progress_bar (bool show); /** - * @brief Implementation of the PluginRoot interface + * @brief Implementation of the Plugin interface */ bool configure (const std::string &name, const std::string &value); /** - * @brief Implementation of the PluginRoot interface + * @brief Implementation of the Plugin interface */ void config_finalize (); @@ -536,6 +527,11 @@ public: */ void menu_activated (const std::string &symbol); + /** + * @brief Gets the available menu symbols + */ + static std::vector menu_symbols (); + /** * @brief Get the action for a slot */ @@ -664,11 +660,6 @@ public slots: */ void select_mode (int m); - /** - * @brief Called when one of the built-in modes (i.e. select, move) is selected - */ - void intrinsic_mode_triggered (); - void update_action_states (); void cancel (); void redraw (); @@ -681,157 +672,6 @@ public slots: void view_selected (int index); void view_title_changed (); - // menu callbacks for main window - void cm_reset_window_state (); - void cm_select_all (); - void cm_unselect_all (); - void cm_undo (); - void cm_redo (); - void cm_delete (); - void cm_show_properties (); - void cm_copy (); - void cm_paste (); - void cm_paste_interactive (); - void cm_duplicate (); - void cm_duplicate_interactive (); - void cm_cut (); - void cm_zoom_fit_sel (); - void cm_zoom_fit (); - void cm_zoom_in (); - void cm_zoom_out (); - void cm_pan_up (); - void cm_pan_down (); - void cm_pan_left (); - void cm_pan_right (); - void cm_save_session (); - void cm_restore_session (); - void cm_setup (); - void cm_save_as (); - void cm_save_all (); - void cm_save (); - void cm_reload (); - void cm_close (); - void cm_close_all (); - void cm_clone (); - void cm_layout_props (); - void cm_layout_stats (); - void cm_inc_max_hier (); - void cm_dec_max_hier (); - void cm_max_hier (); - void cm_max_hier_0 (); - void cm_max_hier_1 (); - void cm_prev_display_state (); - void cm_next_display_state (); - void cm_cancel (); - void cm_redraw (); - void cm_screenshot (); - void cm_save_layer_props (); - void cm_load_layer_props (); - void cm_save_bookmarks (); - void cm_load_bookmarks (); - void cm_select_cell (); - void cm_select_current_cell (); - void cm_print (); - void cm_exit (); - void cm_view_log (); - void cm_bookmark_view (); - void cm_manage_bookmarks (); - void cm_goto_position (); - void cm_show_all_tips (); - void cm_help_about (); - void cm_help_about_qt (); - void cm_macro_editor (); - void cm_packages (); - void cm_technologies (); - void cm_open_too (); - void cm_open_new_view (); - void cm_open (); - void cm_pull_in (); - void cm_reader_options (); - void cm_writer_options (); - void cm_new_layout (); - void cm_new_panel (); - void cm_adjust_origin (); - void cm_new_cell (); - void cm_new_layer (); - void cm_clear_layer (); - void cm_delete_layer (); - void cm_edit_layer (); - void cm_copy_layer (); - void cm_lay_convert_to_static (); - void cm_lay_flip_x (); - void cm_lay_flip_y (); - void cm_lay_rot_cw (); - void cm_lay_rot_ccw (); - void cm_lay_free_rot (); - void cm_lay_scale (); - void cm_lay_move (); - void cm_sel_flip_x (); - void cm_sel_flip_y (); - void cm_sel_rot_cw (); - void cm_sel_rot_ccw (); - void cm_sel_free_rot (); - void cm_sel_scale (); - void cm_sel_move (); - void cm_sel_move_to (); - void cm_sel_move_interactive (); - void cm_show_assistant (); - - // forwarded to the current view: layer list context menu - void cm_lv_new_tab (); - void cm_lv_remove_tab (); - void cm_lv_rename_tab (); - void cm_lv_make_valid (); - void cm_lv_make_invalid (); - void cm_lv_hide (); - void cm_lv_hide_all (); - void cm_lv_show (); - void cm_lv_show_all (); - void cm_lv_show_only (); - void cm_lv_rename (); - void cm_lv_select_all (); - void cm_lv_delete (); - void cm_lv_insert (); - void cm_lv_group (); - void cm_lv_ungroup (); - void cm_lv_source (); - void cm_lv_sort_by_name (); - void cm_lv_sort_by_ild (); - void cm_lv_sort_by_idl (); - void cm_lv_sort_by_ldi (); - void cm_lv_sort_by_dli (); - void cm_lv_regroup_by_index (); - void cm_lv_regroup_by_datatype (); - void cm_lv_regroup_by_layer (); - void cm_lv_regroup_flatten (); - void cm_lv_expand_all (); - void cm_lv_add_missing (); - void cm_lv_remove_unused (); - void cm_lv_copy (); - void cm_lv_cut (); - void cm_lv_paste (); - - // forwarded to the current view: cell list context menu - void cm_cell_user_properties (); - void cm_cell_delete (); - void cm_cell_replace (); - void cm_cell_rename (); - void cm_cell_flatten (); - void cm_cell_convert_to_static (); - void cm_cell_copy (); - void cm_cell_cut (); - void cm_cell_paste (); - void cm_cell_select (); - void cm_open_current_cell (); - void cm_save_current_cell_as (); - void cm_cell_hide (); - void cm_cell_show (); - void cm_cell_show_all (); - - // forwarded to the navigator - void cm_navigator_freeze (); - void cm_navigator_close (); - /** * @brief shows the given URL as a non-modal help window * Intended as a connection target for QLabel linkVisisted signals. @@ -865,12 +705,11 @@ protected: void do_update_file_menu (); private: - friend class PluginRootToMainWindow; + friend class DispatcherToMainWindow; TextProgressDelegate m_text_progress; // Main menu - AbstractMenu *mp_menu; QTabBar *mp_tab_bar; QToolBar *mp_tool_bar; QDockWidget *mp_navigator_dock_widget; @@ -922,9 +761,7 @@ private: bool m_default_grids_updated; std::vector m_default_grid_actions; std::vector > m_key_bindings; - double m_new_cell_window_size; bool m_new_layout_current_panel; - std::string m_new_cell_cell_name; bool m_synchronized_views; bool m_synchronous; bool m_busy; @@ -935,10 +772,6 @@ private: std::auto_ptr mp_printer; std::vector m_changed_files; - std::map m_actions_for_slot; - std::map > m_configuration_actions; - tl::shared_collection m_ca_collection; - // the object manager (undo/redo mechanism and others) db::Manager m_manager; @@ -949,8 +782,48 @@ private: void closeEvent (QCloseEvent *event); void resizeEvent (QResizeEvent *event); - void do_cm_paste (bool interactive); - void do_cm_duplicate (bool interactive); + void cm_navigator_freeze (); + void cm_navigator_close (); + void cm_view_log (); + void cm_print (); + void cm_exit (); + void cm_reset_window_state (); + void cm_undo (); + void cm_redo (); + void cm_goto_position (); + void cm_manage_bookmarks (); + void cm_bookmark_view (); + void cm_cancel (); + void cm_save_layer_props (); + void cm_load_layer_props (); + void cm_save_session (); + void cm_restore_session (); + void cm_save_bookmarks (); + void cm_load_bookmarks (); + void cm_screenshot (); + void cm_save_current_cell_as (); + void cm_save (); + void cm_save_as (); + void cm_save_all (); + void cm_setup (); + void cm_open_too (); + void cm_open_new_view (); + void cm_open (); + void cm_pull_in (); + void cm_reader_options (); + void cm_writer_options (); + void cm_new_panel (); + void cm_new_layout (); + void cm_clone (); + void cm_close_all (); + void cm_close (); + void cm_packages (); + void cm_technologies (); + void cm_macro_editor (); + void cm_show_assistant (); + void cm_show_all_tips (); + void cm_help_about (); + void cm_help_about_qt (); void format_message (); @@ -982,11 +855,11 @@ private: void apply_hidden (const std::vector > &hidden); }; -class LAY_PUBLIC PluginRootToMainWindow - : public lay::PluginRoot +class LAY_PUBLIC DispatcherToMainWindow + : public lay::Dispatcher { public: - PluginRootToMainWindow (); + DispatcherToMainWindow (); void attach_to (lay::MainWindow *main_window); @@ -996,8 +869,8 @@ public: virtual void menu_activated (const std::string &symbol); private: - PluginRootToMainWindow (const PluginRootToMainWindow &); - PluginRootToMainWindow &operator= (const PluginRootToMainWindow &); + DispatcherToMainWindow (const DispatcherToMainWindow &); + DispatcherToMainWindow &operator= (const DispatcherToMainWindow &); tl::weak_ptr mp_main_window; }; diff --git a/src/lay/lay/layNavigator.cc b/src/lay/lay/layNavigator.cc index 3fe535075..3b7d6801b 100644 --- a/src/lay/lay/layNavigator.cc +++ b/src/lay/lay/layNavigator.cc @@ -503,32 +503,6 @@ Navigator::~Navigator () } } -void -Navigator::init_menu (AbstractMenu &menu) -{ - MenuLayoutEntry navigator_main_menu [] = { - MenuLayoutEntry ("navigator_show_images", tl::to_string (QObject::tr ("Show Images")), std::make_pair (cfg_navigator_show_images, "?")), - MenuLayoutEntry ("navigator_all_hier_levels", tl::to_string (QObject::tr ("Show All Hierarchy Levels")), std::make_pair (cfg_navigator_all_hier_levels, "?")), - MenuLayoutEntry::separator ("navigator_options_group"), - MenuLayoutEntry ("navigator_freeze", tl::to_string (QObject::tr ("Freeze")), SLOT (cm_navigator_freeze ())), - MenuLayoutEntry::last () - }; - - MenuLayoutEntry navigator_menu [] = { - MenuLayoutEntry ("navigator_main_menu", tl::to_string (QObject::tr ("Options")), navigator_main_menu), - MenuLayoutEntry::last () - }; - - MenuLayoutEntry navigator_detached_menu [] = { - MenuLayoutEntry ("@@navigator_menu", "", navigator_menu), - MenuLayoutEntry::last () - }; - - menu.init (navigator_detached_menu); - - menu.action (freeze_action_path).set_checkable (true); -} - void Navigator::menu_changed () { @@ -598,8 +572,8 @@ Navigator::showEvent (QShowEvent *) void Navigator::closeEvent (QCloseEvent *) { - lay::PluginRoot::instance ()->config_set (cfg_show_navigator, "false"); - lay::PluginRoot::instance ()->config_end (); + mp_main_window->config_set (cfg_show_navigator, "false"); + mp_main_window->config_end (); } void @@ -793,5 +767,33 @@ Navigator::update () mp_service->update_marker (); } +// ------------------------------------------------------------ +// Declaration of the "plugin" for the menu entries + +class NavigatorPluginDeclaration + : public lay::PluginDeclaration +{ +public: + virtual void get_menu_entries (std::vector &menu_entries) const + { + std::string at; + + at = ".end"; + menu_entries.push_back (lay::submenu ("@@navigator_menu", at, std::string ())); + + at = "@@navigator_menu.end"; + menu_entries.push_back (lay::submenu ("navigator_main_menu", at, tl::to_string (QObject::tr ("Options")))); + + at = "@@navigator_menu.navigator_main_menu.end"; + menu_entries.push_back (lay::config_menu_item ("navigator_show_images", at, tl::to_string (QObject::tr ("Show Images")), cfg_navigator_show_images, "?")); + menu_entries.push_back (lay::config_menu_item ("navigator_all_hier_levels", at, tl::to_string (QObject::tr ("Show All Hierarchy Levels")), cfg_navigator_all_hier_levels, "?")); + menu_entries.push_back (lay::separator ("navigator_options_group", at)); + menu_entries.push_back (lay::menu_item ("cm_navigator_freeze", "navigator_freeze", at, tl::to_string (QObject::tr ("Freeze")))); + menu_entries.back ().checkable = true; + } +}; + +static tl::RegisteredClass config_decl (new NavigatorPluginDeclaration (), -1, "NavigatorPlugin"); + } diff --git a/src/lay/lay/layNavigator.h b/src/lay/lay/layNavigator.h index a3571c951..7b1702582 100644 --- a/src/lay/lay/layNavigator.h +++ b/src/lay/lay/layNavigator.h @@ -84,8 +84,6 @@ public: void all_hier_levels (bool f); void show_images (bool f); - static void init_menu (AbstractMenu &menu); - protected: virtual void closeEvent (QCloseEvent *event); virtual void showEvent (QShowEvent *event); diff --git a/src/lay/lay/laySaltController.h b/src/lay/lay/laySaltController.h index 882fcbb25..b4e2d6792 100644 --- a/src/lay/lay/laySaltController.h +++ b/src/lay/lay/laySaltController.h @@ -69,17 +69,17 @@ public: /** * @brief Reimplementation of the PluginDeclaration interface */ - virtual void initialize (lay::PluginRoot *root); + virtual void initialize (lay::Dispatcher *root); /** * @brief Reimplementation of the PluginDeclaration interface */ - virtual void initialized (lay::PluginRoot *root); + virtual void initialized (lay::Dispatcher *root); /** * @brief Reimplementation of the PluginDeclaration interface */ - virtual void uninitialize (lay::PluginRoot *root); + virtual void uninitialize (lay::Dispatcher *root); /** * @brief Reimplementation of the PluginDeclaration interface @@ -104,7 +104,7 @@ public: /** * @brief Reimplementation of the PluginDeclaration interface */ - bool can_exit (lay::PluginRoot *root) const; + bool can_exit (lay::Dispatcher *root) const; /** * @brief Reimplementation of the PluginDeclaration interface @@ -191,7 +191,7 @@ signals: private: lay::SaltManagerDialog *mp_salt_dialog; lay::MainWindow *mp_mw; - lay::PluginRoot * mp_plugin_root; + lay::Dispatcher * mp_plugin_root; std::string m_salt_mine_url; lay::Salt m_salt; tl::FileSystemWatcher *m_file_watcher; diff --git a/src/lay/lay/laySettingsForm.cc b/src/lay/lay/laySettingsForm.cc index 3d43062e2..cc8fcb394 100644 --- a/src/lay/lay/laySettingsForm.cc +++ b/src/lay/lay/laySettingsForm.cc @@ -40,9 +40,9 @@ namespace lay // ------------------------------------------------------------- -SettingsForm::SettingsForm (QWidget *parent, lay::PluginRoot *plugin_root, const char *name) +SettingsForm::SettingsForm (QWidget *parent, lay::Dispatcher *dispatcher, const char *name) : QDialog (parent), Ui::SettingsForm (), - mp_plugin_root (plugin_root), m_finalize_recursion (false) + mp_plugin_root (dispatcher), m_finalize_recursion (false) { setObjectName (QString::fromUtf8 (name)); diff --git a/src/lay/lay/laySettingsForm.h b/src/lay/lay/laySettingsForm.h index 166dcb422..504d40c2f 100644 --- a/src/lay/lay/laySettingsForm.h +++ b/src/lay/lay/laySettingsForm.h @@ -37,7 +37,7 @@ namespace lay { -class PluginRoot; +class Dispatcher; class ConfigPage; class SettingsForm @@ -46,7 +46,7 @@ class SettingsForm Q_OBJECT public: - SettingsForm (QWidget *parent, lay::PluginRoot *plugin_root, const char *name); + SettingsForm (QWidget *parent, lay::Dispatcher *dispatcher, const char *name); void setup (); void commit (); @@ -58,7 +58,7 @@ public slots: void item_changed (QTreeWidgetItem *, QTreeWidgetItem *); private: - lay::PluginRoot *mp_plugin_root; + lay::Dispatcher *mp_dispatcher; std::vector m_config_pages; bool m_finalize_recursion; }; diff --git a/src/lay/lay/layTechnologyController.h b/src/lay/lay/layTechnologyController.h index 63e57e0dc..aeae6f5f0 100644 --- a/src/lay/lay/layTechnologyController.h +++ b/src/lay/lay/layTechnologyController.h @@ -54,9 +54,9 @@ public: */ TechnologyController (); - void initialize (lay::PluginRoot *root); - void initialized (lay::PluginRoot *root); - void uninitialize (lay::PluginRoot *root); + void initialize (lay::Dispatcher *root); + void initialized (lay::Dispatcher *root); + void uninitialize (lay::Dispatcher *root); void get_options (std::vector < std::pair > &options) const; void get_menu_entries (std::vector &menu_entries) const; @@ -132,7 +132,7 @@ private: bool m_technologies_configured; lay::TechSetupDialog *mp_editor; lay::MainWindow *mp_mw; - lay::PluginRoot *mp_plugin_root; + lay::Dispatcher *mp_plugin_root; std::vector m_paths; std::vector m_temp_tech; db::Technology *mp_active_technology; diff --git a/src/lay/lay/LayoutStatistics.ui b/src/laybasic/laybasic/LayoutStatistics.ui similarity index 100% rename from src/lay/lay/LayoutStatistics.ui rename to src/laybasic/laybasic/LayoutStatistics.ui diff --git a/src/lay/lay/SelectCellViewForm.ui b/src/laybasic/laybasic/SelectCellViewForm.ui similarity index 100% rename from src/lay/lay/SelectCellViewForm.ui rename to src/laybasic/laybasic/SelectCellViewForm.ui diff --git a/src/laybasic/laybasic/gsiDeclLayLayoutView.cc b/src/laybasic/laybasic/gsiDeclLayLayoutView.cc index 7d6081638..b409a7740 100644 --- a/src/laybasic/laybasic/gsiDeclLayLayoutView.cc +++ b/src/laybasic/laybasic/gsiDeclLayLayoutView.cc @@ -533,6 +533,18 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "This method has been introduced in version 0.27\n" ) + #endif + gsi::method ("call_menu", &lay::LayoutView::menu_activated, + "@brief Calls the menu item with the provided symbol.\n" + "To obtain all symbols, use get_menu_symbols.\n" + "\n" + "This method has been introduced in version 0.27." + ) + + gsi::method ("get_menu_symbols", &lay::LayoutView::get_menu_symbols, + "@brief Calls the menu item with the provided symbol.\n" + "To obtain all available symbols, use get_menu_symbols.\n" + "\n" + "This method has been introduced in version 0.27." + ) + gsi::method ("current", &lay::LayoutView::current, "@brief Returns the current view\n" "The current view is the one that is shown in the current tab. Returns nil if no layout is loaded.\n" diff --git a/src/laybasic/laybasic/gsiDeclLayPlugin.cc b/src/laybasic/laybasic/gsiDeclLayPlugin.cc index 1c87df4f4..4c81d652e 100644 --- a/src/laybasic/laybasic/gsiDeclLayPlugin.cc +++ b/src/laybasic/laybasic/gsiDeclLayPlugin.cc @@ -56,14 +56,14 @@ namespace gsi // of the factory, this hack is a quick but dirty workaround. static bool s_in_create_plugin = false; static lay::LayoutView *sp_view = 0; -static lay::PluginRoot *sp_root = 0; +static lay::Dispatcher *sp_dispatcher = 0; class PluginBase : public lay::Plugin, public lay::ViewService { public: PluginBase () - : lay::Plugin (sp_root), lay::ViewService (sp_view ? sp_view->view_object_widget () : 0) + : lay::Plugin (sp_dispatcher), lay::ViewService (sp_view ? sp_view->view_object_widget () : 0) { if (! s_in_create_plugin) { throw tl::Exception (tl::to_string (QObject::tr ("A PluginBase object can only be created in the PluginFactory's create_plugin method"))); @@ -334,7 +334,7 @@ public: } } - virtual void initialize (lay::PluginRoot *root) + virtual void initialize (lay::Dispatcher *root) { if (f_initialize.can_issue ()) { f_initialize.issue (&lay::PluginDeclaration::initialize, root); @@ -343,7 +343,7 @@ public: } } - virtual void uninitialize (lay::PluginRoot *root) + virtual void uninitialize (lay::Dispatcher *root) { if (f_uninitialize.can_issue ()) { f_uninitialize.issue (&lay::PluginDeclaration::uninitialize, root); @@ -352,7 +352,7 @@ public: } } - virtual lay::Plugin *create_plugin (db::Manager *manager, lay::PluginRoot *root, lay::LayoutView *view) const + virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *root, lay::LayoutView *view) const { if (f_create_plugin.can_issue ()) { return create_plugin_gsi (manager, root, view); @@ -361,22 +361,22 @@ public: } } - virtual gsi::PluginBase *create_plugin_gsi (db::Manager *manager, lay::PluginRoot *root, lay::LayoutView *view) const + virtual gsi::PluginBase *create_plugin_gsi (db::Manager *manager, lay::Dispatcher *root, lay::LayoutView *view) const { // TODO: this is a hack. See notes above at s_in_create_plugin s_in_create_plugin = true; sp_view = view; - sp_root = root; + sp_dispatcher = root; gsi::PluginBase *ret = 0; try { - ret = f_create_plugin.issue (&PluginFactoryBase::create_plugin_gsi, manager, root, view); + ret = f_create_plugin.issue (&PluginFactoryBase::create_plugin_gsi, manager, root, view); s_in_create_plugin = false; sp_view = 0; - sp_root = 0; + sp_dispatcher = 0; } catch (...) { s_in_create_plugin = false; sp_view = 0; - sp_root = 0; + sp_dispatcher = 0; } return ret; @@ -394,17 +394,31 @@ public: void add_menu_entry1 (const std::string &menu_name, const std::string &insert_pos) { - m_menu_entries.push_back (lay::MenuEntry (menu_name, insert_pos)); + m_menu_entries.push_back (lay::separator (menu_name, insert_pos)); } void add_menu_entry2 (const std::string &symbol, const std::string &menu_name, const std::string &insert_pos, const std::string &title) { - m_menu_entries.push_back (lay::MenuEntry (symbol, menu_name, insert_pos, title)); + m_menu_entries.push_back (lay::menu_item (symbol, menu_name, insert_pos, title)); + } + + void add_submenu (const std::string &menu_name, const std::string &insert_pos, const std::string &title) + { + m_menu_entries.push_back (lay::submenu (menu_name, insert_pos, title)); + } + + void add_config_menu_item (const std::string &menu_name, const std::string &insert_pos, const std::string &title, const std::string &cname, const std::string &cvalue) + { + m_menu_entries.push_back (lay::config_menu_item (menu_name, insert_pos, title, cname, cvalue)); } void add_menu_entry3 (const std::string &symbol, const std::string &menu_name, const std::string &insert_pos, const std::string &title, bool sub_menu) { - m_menu_entries.push_back (lay::MenuEntry (symbol, menu_name, insert_pos, title, sub_menu)); + if (sub_menu) { + m_menu_entries.push_back (lay::submenu (symbol, menu_name, insert_pos, title)); + } else { + m_menu_entries.push_back (lay::menu_item (symbol, menu_name, insert_pos, title)); + } } void add_option (const std::string &name, const std::string &default_value) @@ -439,9 +453,8 @@ private: }; Class decl_PluginFactory ("lay", "PluginFactory", - method ("register", &PluginFactoryBase::register_gsi, + method ("register", &PluginFactoryBase::register_gsi, gsi::arg ("position"), gsi::arg ("name"), gsi::arg ("title"), "@brief Registers the plugin factory\n" - "@args position, name, title\n" "@param position An integer that determines the order in which the plugins are created. The internal plugins use the values from 1000 to 50000.\n" "@param name The plugin name. This is an arbitrary string which should be unique. Hence it is recommended to use a unique prefix, i.e. \"myplugin::ThePluginClass\".\n" "@param title The title string which is supposed to appear in the tool bar and menu related to this plugin.\n" @@ -449,9 +462,8 @@ Class decl_PluginFactory ("lay", "PluginFactory", "Registration of the plugin factory makes the object known to the system. Registration requires that the menu items have been set " "already. Hence it is recommended to put the registration at the end of the initialization method of the factory class.\n" ) + - method ("register", &PluginFactoryBase::register_gsi2, + method ("register", &PluginFactoryBase::register_gsi2, gsi::arg ("position"), gsi::arg ("name"), gsi::arg ("title"), gsi::arg ("icon"), "@brief Registers the plugin factory\n" - "@args position, name, title, icon\n" "@param position An integer that determines the order in which the plugins are created. The internal plugins use the values from 1000 to 50000.\n" "@param name The plugin name. This is an arbitrary string which should be unique. Hence it is recommended to use a unique prefix, i.e. \"myplugin::ThePluginClass\".\n" "@param title The title string which is supposed to appear in the tool bar and menu related to this plugin.\n" @@ -462,9 +474,8 @@ Class decl_PluginFactory ("lay", "PluginFactory", "Registration of the plugin factory makes the object known to the system. Registration requires that the menu items have been set " "already. Hence it is recommended to put the registration at the end of the initialization method of the factory class.\n" ) + - callback ("configure", &gsi::PluginFactoryBase::configure, &gsi::PluginFactoryBase::f_configure, + callback ("configure", &gsi::PluginFactoryBase::configure, &gsi::PluginFactoryBase::f_configure, gsi::arg ("name"), gsi::arg ("value"), "@brief Gets called for configuration events for the plugin singleton\n" - "@args name, value\n" "This method can be reimplemented to receive configuration events " "for the plugin singleton. Before a configuration can be received it must be " "registered by calling \\add_option in the plugin factories' constructor.\n" @@ -479,14 +490,12 @@ Class decl_PluginFactory ("lay", "PluginFactory", ) + callback ("config_finalize", &gsi::PluginFactoryBase::config_finalize, &gsi::PluginFactoryBase::f_config_finalize, "@brief Gets called after a set of configuration events has been sent\n" - "@args\n" "This method can be reimplemented and is called after a set of configuration events " "has been sent to the plugin factory singleton with \\configure. It can be used to " "set up user interfaces properly for example.\n" ) + - callback ("menu_activated", &gsi::PluginFactoryBase::menu_activated, &gsi::PluginFactoryBase::f_menu_activated, + callback ("menu_activated", &gsi::PluginFactoryBase::menu_activated, &gsi::PluginFactoryBase::f_menu_activated, gsi::arg ("symbol"), "@brief Gets called when a menu item is selected\n" - "@args symbol\n" "\n" "Usually, menu-triggered functionality is implemented in the per-view instance of the plugin. " "However, using this method it is possible to implement functionality globally for all plugin " @@ -496,37 +505,32 @@ Class decl_PluginFactory ("lay", "PluginFactory", "If this method was handling the menu event, it should return true. This indicates that the event " "will not be propagated to other plugins hence avoiding duplicate calls.\n" ) + - callback ("initialized", &gsi::PluginFactoryBase::initialize, &gsi::PluginFactoryBase::f_initialize, + callback ("initialized", &gsi::PluginFactoryBase::initialize, &gsi::PluginFactoryBase::f_initialize, gsi::arg ("dispatcher"), "@brief Gets called when the plugin singleton is initialized, i.e. when the application has been started.\n" - "@args root\n" - "@param root The reference to the \\MainWindow object\n" + "@param dispatcher The reference to the \\MainWindow object\n" ) + - callback ("uninitialized", &gsi::PluginFactoryBase::uninitialize, &gsi::PluginFactoryBase::f_uninitialize, + callback ("uninitialized", &gsi::PluginFactoryBase::uninitialize, &gsi::PluginFactoryBase::f_uninitialize, gsi::arg ("dispatcher"), "@brief Gets called when the application shuts down and the plugin is unregistered\n" "This event can be used to free resources allocated with this factory singleton.\n" - "@args root\n" - "@param root The reference to the \\MainWindow object\n" + "@param dispatcher The reference to the \\MainWindow object\n" ) + - factory_callback ("create_plugin", &gsi::PluginFactoryBase::create_plugin_gsi, &gsi::PluginFactoryBase::f_create_plugin, + factory_callback ("create_plugin", &gsi::PluginFactoryBase::create_plugin_gsi, &gsi::PluginFactoryBase::f_create_plugin, gsi::arg ("manager"), gsi::arg ("dispatcher"), gsi::arg ("view"), "@brief Creates the plugin\n" "This is the basic functionality that the factory must provide. This method must create a plugin of the " "specific type.\n" - "@args manager, root, view\n" "@param manager The database manager object responsible for handling database transactions\n" - "@param root The reference to the \\MainWindow object\n" + "@param dispatcher The reference to the \\MainWindow object\n" "@param view The \\LayoutView that is plugin is created for\n" "@return The new \\Plugin implementation object\n" ) + - method ("add_menu_entry", &gsi::PluginFactoryBase::add_menu_entry1, + method ("add_menu_entry", &gsi::PluginFactoryBase::add_menu_entry1, gsi::arg ("menu_name"), gsi::arg ("insert_pos"), "@brief Specifies a separator\n" - "@args menu_name, insert_pos\n" "Call this method in the factory constructor to build the menu items that this plugin shall create.\n" "This specific call inserts a separator at the given position (insert_pos). The position uses abstract menu item paths " "and \"menu_name\" names the component that will be created. See \\AbstractMenu for a description of the path.\n" ) + - method ("add_menu_entry", &gsi::PluginFactoryBase::add_menu_entry2, + method ("add_menu_entry", &gsi::PluginFactoryBase::add_menu_entry2, gsi::arg ("symbol"), gsi::arg ("menu_name"), gsi::arg ("insert_pos"), gsi::arg ("title"), "@brief Specifies a menu item\n" - "@args symbol, menu_name, insert_pos, title\n" "Call this method in the factory constructor to build the menu items that this plugin shall create.\n" "This specific call inserts a menu item at the specified position (insert_pos). The position uses abstract menu item paths " "and \"menu_name\" names the component that will be created. See \\AbstractMenu for a description of the path.\n" @@ -537,15 +541,28 @@ Class decl_PluginFactory ("lay", "PluginFactory", "@param insert_pos The position where to create the entry\n" "@param title The title string for the item. The title can contain a keyboard shortcut in round braces after the title text, i.e. \"My Menu Item(F12)\"\n" ) + - method ("add_menu_entry", &gsi::PluginFactoryBase::add_menu_entry3, + method ("#add_menu_entry", &gsi::PluginFactoryBase::add_menu_entry3, gsi::arg ("symbol"), gsi::arg ("menu_name"), gsi::arg ("insert_pos"), gsi::arg ("title"), gsi::arg ("sub_menu"), "@brief Specifies a menu item or sub-menu\n" - "@args symbol, menu_name, insert_pos, title, sub_menu\n" "Similar to the previous form of \"add_menu_entry\", but this version allows also to create sub-menus by setting the " - "last parameter to \"true\"" + "last parameter to \"true\".\n" + "\n" + "With version 0.27 it's more convenient to use \\add_submenu." ) + - method ("add_option", &gsi::PluginFactoryBase::add_option, + method ("add_submenu", &gsi::PluginFactoryBase::add_submenu, gsi::arg ("menu_name"), gsi::arg ("insert_pos"), gsi::arg ("title"), + "@brief Specifies a menu item or sub-menu\n" + "\n" + "This method has been introduced in version 0.27." + ) + + method ("add_config_menu_item", &gsi::PluginFactoryBase::add_config_menu_item, gsi::arg ("menu_name"), gsi::arg ("insert_pos"), gsi::arg ("title"), gsi::arg ("cname"), gsi::arg ("cvalue"), + "@brief Adds a configuration menu item\n" + "\n" + "Menu items created this way will send a configuration request with 'cname' as the configuration parameter name " + "and 'cvalue' as the configuration parameter value.\n" + "\n" + "This method has been introduced in version 0.27." + ) + + method ("add_option", &gsi::PluginFactoryBase::add_option, gsi::arg ("name"), gsi::arg ("default_value"), "@brief Specifies configuration variables.\n" - "@args name, default_value\n" "Call this method in the factory constructor to add configuration key/value pairs to the configuration repository. " "Without specifying configuration variables, the status of a plugin cannot be persisted. " "\n\n" @@ -555,9 +572,8 @@ Class decl_PluginFactory ("lay", "PluginFactory", "doing so has the advantage that it is guaranteed that a variable with this keys exists and has the given default value initially." "\n\n" ) + - method ("has_tool_entry=", &gsi::PluginFactoryBase::has_tool_entry, + method ("has_tool_entry=", &gsi::PluginFactoryBase::has_tool_entry, gsi::arg ("f"), "@brief Enables or disables the tool bar entry\n" - "@args f\n" "Initially this property is set to true. This means that the plugin will have a visible entry in the toolbar. " "This property can be set to false to disable this feature. In that case, the title and icon given on registration will be ignored. " ), @@ -601,7 +617,7 @@ Class decl_PluginFactory ("lay", "PluginFactory", " end\n" " \n" " # Create a new plugin instance of the custom type\n" - " def create_plugin(manager, root, view)\n" + " def create_plugin(manager, dispatcher, view)\n" " return PluginTest.new\n" " end\n" "\n" @@ -849,22 +865,22 @@ Class decl_ButtonState ("lay", "ButtonState", ); static std::vector -get_config_names (lay::PluginRoot *root) +get_config_names (lay::Dispatcher *dispatcher) { std::vector names; - root->get_config_names (names); + dispatcher->get_config_names (names); return names; } -static lay::PluginRoot *config_root_instance () +static lay::Dispatcher *dispatcher_instance () { - return lay::PluginRoot::instance (); + return lay::Dispatcher::instance (); } -static tl::Variant get_config (lay::PluginRoot *root, const std::string &name) +static tl::Variant get_config (lay::Dispatcher *dispatcher, const std::string &name) { std::string value; - if (root->config_get (name, value)) { + if (dispatcher->config_get (name, value)) { return tl::Variant (value); } else { return tl::Variant (); @@ -872,54 +888,50 @@ static tl::Variant get_config (lay::PluginRoot *root, const std::string &name) } /** - * @brief Exposes the PluginRoot interface + * @brief Exposes the Dispatcher interface * * This interface is intentionally not derived from Plugin. It is used currently to - * identify the plugin root node for configuration. The Plugin nature of this interface + * identify the dispatcher node for configuration. The Plugin nature of this interface * is somewhat artificial and may be removed later. * * TODO: this is a duplicate of the respective methods in LayoutView and Application. * This is intentional since we don't want to spend the only derivation path on this. * Once there is a mixin concept, provide a path through that concept. */ -Class decl_PluginRoot ("lay", "PluginRoot", - method ("clear_config", &lay::PluginRoot::clear_config, +Class decl_Dispatcher ("lay", "Dispatcher", + method ("clear_config", &lay::Dispatcher::clear_config, "@brief Clears the configuration parameters\n" ) + - method ("instance", &config_root_instance, + method ("instance", &dispatcher_instance, "@brief Gets the singleton instance of the PluginRoot object\n" "\n" "@return The instance\n" ) + - method ("write_config", &lay::PluginRoot::write_config, + method ("write_config", &lay::Dispatcher::write_config, gsi::arg ("file_name"), "@brief Writes configuration to a file\n" - "@args file_name\n" "@return A value indicating whether the operation was successful\n" "\n" "If the configuration file cannot be written, false \n" "is returned but no exception is thrown.\n" ) + - method ("read_config", &lay::PluginRoot::read_config, + method ("read_config", &lay::Dispatcher::read_config, gsi::arg ("file_name"), "@brief Reads the configuration from a file\n" - "@args file_name\n" "@return A value indicating whether the operation was successful\n" "\n" "This method siletly does nothing, if the config file does not\n" "exist. If it does and an error occurred, the error message is printed\n" "on stderr. In both cases, false is returned.\n" ) + - method_ext ("get_config", &get_config, + method_ext ("get_config", &get_config, gsi::arg ("name"), "@brief Gets the value of a local configuration parameter\n" "\n" - "@args name\n" "@param name The name of the configuration parameter whose value shall be obtained (a string)\n" "\n" "@return The value of the parameter or nil if there is no such parameter\n" ) + - method ("set_config", (void (lay::PluginRoot::*) (const std::string &, const std::string &)) &lay::PluginRoot::config_set, + method ("set_config", (void (lay::Dispatcher::*) (const std::string &, const std::string &)) &lay::Dispatcher::config_set, gsi::arg ("name"), gsi::arg ("value"), "@brief Set a local configuration parameter with the given name to the given value\n" "\n" - "@args name, value\n" "@param name The name of the configuration parameter to set\n" "@param value The value to which to set the configuration parameter\n" "\n" @@ -937,14 +949,14 @@ Class decl_PluginRoot ("lay", "PluginRoot", "This method returns the names of all known configuration parameters. These names can be used to " "get and set configuration parameter values.\n" ) + - method ("commit_config", &lay::PluginRoot::config_end, + method ("commit_config", &lay::Dispatcher::config_end, "@brief Commits the configuration settings\n" "\n" "Some configuration options are queued for performance reasons and become active only after 'commit_config' has been called. " "After a sequence of \\set_config calls, this method should be called to activate the " "settings made by these calls.\n" ), - "@brief Root of the configuration space in the plugin context\n" + "@brief Root of the configuration space in the plugin context and menu dispatcher\n" "\n" "This class provides access to the root configuration space in the context " "of plugin programming. You can use this class to obtain configuration parameters " @@ -952,12 +964,12 @@ Class decl_PluginRoot ("lay", "PluginRoot", "preferred way of plugin configuration is through \\Plugin#configure.\n" "\n" "Currently, the application object provides an identical entry point for configuration modification. " - "For example, \"Application::instance.set_config\" is identical to \"PluginRoot::instance.set_config\". " - "Hence there is little motivation for the PluginRoot class currently and " + "For example, \"Application::instance.set_config\" is identical to \"Dispatcher::instance.set_config\". " + "Hence there is little motivation for the Dispatcher class currently and " "this interface may be modified or removed in the future." "\n" - "\n" - "This class has been introduced in version 0.25.\n" + "This class has been introduced in version 0.25 as 'PluginRoot'.\n" + "It is renamed and enhanced as 'Dispatcher' in 0.27." ); } diff --git a/src/laybasic/laybasic/layAbstractMenu.cc b/src/laybasic/laybasic/layAbstractMenu.cc index 5c0089904..5c63d1d24 100644 --- a/src/laybasic/laybasic/layAbstractMenu.cc +++ b/src/laybasic/laybasic/layAbstractMenu.cc @@ -22,9 +22,9 @@ #include "layAbstractMenu.h" -#include "layAbstractMenuProvider.h" -#include "tlExceptions.h" +#include "layDispatcher.h" #include "layPlugin.h" +#include "tlExceptions.h" #include "tlAssert.h" #include "gtf.h" #include "gsi.h" @@ -574,8 +574,8 @@ ActionHandle::get_key_sequence_for (const std::string &sc) const Action::Action () : mp_handle (0) { - if (lay::AbstractMenuProvider::instance ()) { - mp_handle = new ActionHandle (lay::AbstractMenuProvider::instance ()->menu_parent_widget ()); + if (lay::Dispatcher::instance ()) { + mp_handle = new ActionHandle (lay::Dispatcher::instance ()->menu_parent_widget ()); gtf::action_connect (mp_handle->ptr (), SIGNAL (triggered ()), this, SLOT (triggered_slot ())); mp_handle->add_ref (); } @@ -920,14 +920,14 @@ Action::set_object_name (const std::string &name) // --------------------------------------------------------------- // ConfigureAction implementation -ConfigureAction::ConfigureAction (lay::PluginRoot *pr) - : Action (), m_pr (pr), m_type (ConfigureAction::setter_type) +ConfigureAction::ConfigureAction (lay::Dispatcher *dispatcher) + : Action (), m_dispatcher (dispatcher), m_type (ConfigureAction::setter_type) { // .. nothing yet .. } -ConfigureAction::ConfigureAction (lay::PluginRoot *pr, const std::string &cname, const std::string &cvalue) - : Action (), m_pr (pr), m_cname (cname), m_cvalue (cvalue), m_type (ConfigureAction::setter_type) +ConfigureAction::ConfigureAction (lay::Dispatcher *dispatcher, const std::string &cname, const std::string &cvalue) + : Action (), m_dispatcher (dispatcher), m_cname (cname), m_cvalue (cvalue), m_type (ConfigureAction::setter_type) { if (cvalue == "?") { m_type = boolean_type; @@ -937,8 +937,8 @@ ConfigureAction::ConfigureAction (lay::PluginRoot *pr, const std::string &cname, reg (); } -ConfigureAction::ConfigureAction (lay::PluginRoot *pr, const std::string &title, const std::string &cname, const std::string &cvalue) - : Action (title), m_pr (pr), m_cname (cname), m_cvalue (cvalue), m_type (ConfigureAction::setter_type) +ConfigureAction::ConfigureAction (lay::Dispatcher *dispatcher, const std::string &title, const std::string &cname, const std::string &cvalue) + : Action (title), m_dispatcher (dispatcher), m_cname (cname), m_cvalue (cvalue), m_type (ConfigureAction::setter_type) { if (cvalue == "?") { // A "?" notation indicates a boolean toogle entry @@ -966,23 +966,19 @@ ConfigureAction::triggered () m_cvalue = tl::to_string (is_checked ()); } - m_pr->config_set (m_cname, m_cvalue); + m_dispatcher->config_set (m_cname, m_cvalue); } void ConfigureAction::reg () { - if (lay::AbstractMenuProvider::instance ()) { - lay::AbstractMenuProvider::instance ()->register_config_action (m_cname, this); - } + m_dispatcher->register_config_action (m_cname, this); } void ConfigureAction::unreg () { - if (lay::AbstractMenuProvider::instance ()) { - lay::AbstractMenuProvider::instance ()->unregister_config_action (m_cname, this); - } + m_dispatcher->unregister_config_action (m_cname, this); } void @@ -1008,13 +1004,8 @@ ConfigureAction::configure (const std::string &value) // AbstractMenu implementation ActionHandle * -AbstractMenu::create_action (const std::string &s, AbstractMenuProvider *provider) +AbstractMenu::create_action (const std::string &s, lay::Dispatcher *dispatcher) { - if (! provider) { - provider = lay::AbstractMenuProvider::instance (); - } - tl_assert (provider != 0); - std::string title; std::string shortcut; std::string res; @@ -1022,7 +1013,7 @@ AbstractMenu::create_action (const std::string &s, AbstractMenuProvider *provide parse_menu_title (s, title, shortcut, res, tool_tip); - ActionHandle *ah = new ActionHandle (provider->menu_parent_widget ()); + ActionHandle *ah = new ActionHandle (dispatcher->menu_parent_widget ()); ah->ptr ()->setText (tl::to_qstring (title)); if (! tool_tip.empty ()) { @@ -1040,8 +1031,8 @@ AbstractMenu::create_action (const std::string &s, AbstractMenuProvider *provide return ah; } -AbstractMenu::AbstractMenu (AbstractMenuProvider *provider) - : mp_provider (provider) +AbstractMenu::AbstractMenu (Dispatcher *dispatcher) + : mp_dispatcher (dispatcher) { // .. nothing yet .. } @@ -1051,13 +1042,6 @@ AbstractMenu::~AbstractMenu () // .. nothing yet .. } -void -AbstractMenu::init (const MenuLayoutEntry *layout) -{ - m_root.set_has_submenu (); - transfer (layout, m_root); -} - QActionGroup * AbstractMenu::make_exclusive_group (const std::string &name) { @@ -1167,8 +1151,8 @@ AbstractMenu::build (QMenuBar *mbar, QToolBar *tbar) // Otherwise, the keyboard shortcuts do not work for menu items inside such a // popup menu. It seems not to have a negative effect to add the menu to the // main widget. - if (mp_provider) { - mp_provider->menu_parent_widget ()->addAction (menu->menuAction ()); + if (mp_dispatcher->menu_parent_widget ()) { + mp_dispatcher->menu_parent_widget ()->addAction (menu->menuAction ()); } c->set_action (Action (new ActionHandle (menu)), true); } @@ -1379,27 +1363,32 @@ AbstractMenu::items (const std::string &path) const void AbstractMenu::insert_item (const std::string &p, const std::string &name, const Action &action) { - typedef std::vector::iterator > > path_type; - path_type path = find_item (p); - if (! path.empty ()) { + tl::Extractor extr (p.c_str ()); + while (! extr.at_end ()) { - AbstractMenuItem *parent = path.back ().first; - std::list::iterator iter = path.back ().second; + typedef std::vector::iterator > > path_type; + path_type path = find_item (extr); + if (! path.empty ()) { - // insert the new item - parent->children.insert (iter, AbstractMenuItem ()); - --iter; + AbstractMenuItem *parent = path.back ().first; + std::list::iterator iter = path.back ().second; - iter->setup_item (parent->name (), name, action); + // insert the new item + parent->children.insert (iter, AbstractMenuItem ()); + --iter; - // find any items with the same name and remove them - for (std::list::iterator existing = parent->children.begin (); existing != parent->children.end (); ) { - std::list::iterator existing_next = existing; - ++existing_next; - if (existing->name () == iter->name () && existing != iter) { - parent->children.erase (existing); + iter->setup_item (parent->name (), name, action); + + // find any items with the same name and remove them + for (std::list::iterator existing = parent->children.begin (); existing != parent->children.end (); ) { + std::list::iterator existing_next = existing; + ++existing_next; + if (existing->name () == iter->name () && existing != iter) { + parent->children.erase (existing); + } + existing = existing_next; } - existing = existing_next; + } } @@ -1411,7 +1400,8 @@ void AbstractMenu::insert_separator (const std::string &p, const std::string &name) { typedef std::vector::iterator > > path_type; - path_type path = find_item (p); + tl::Extractor extr (p.c_str ()); + path_type path = find_item (extr); if (! path.empty ()) { AbstractMenuItem *parent = path.back ().first; @@ -1419,7 +1409,7 @@ AbstractMenu::insert_separator (const std::string &p, const std::string &name) parent->children.insert (iter, AbstractMenuItem ()); --iter; - Action action (new ActionHandle (mp_provider ? mp_provider->menu_parent_widget () : 0)); + Action action (new ActionHandle (mp_dispatcher->menu_parent_widget ())); action.set_separator (true); iter->setup_item (parent->name (), name, action); @@ -1432,7 +1422,8 @@ void AbstractMenu::insert_menu (const std::string &p, const std::string &name, const Action &action) { typedef std::vector::iterator > > path_type; - path_type path = find_item (p); + tl::Extractor extr (p.c_str ()); + path_type path = find_item (extr); if (! path.empty ()) { AbstractMenuItem *parent = path.back ().first; @@ -1461,14 +1452,15 @@ AbstractMenu::insert_menu (const std::string &p, const std::string &name, const void AbstractMenu::insert_menu (const std::string &path, const std::string &name, const std::string &title) { - insert_menu (path, name, create_action (title, mp_provider)); + insert_menu (path, name, create_action (title, mp_dispatcher)); } void AbstractMenu::clear_menu (const std::string &p) { typedef std::vector::iterator > > path_type; - path_type path = find_item (p); + tl::Extractor extr (p.c_str ()); + path_type path = find_item (extr); if (! path.empty () && ! path.back ().second->children.empty ()) { path.back ().second->children.clear (); emit changed (); @@ -1479,7 +1471,8 @@ void AbstractMenu::delete_item (const std::string &p) { typedef std::vector::iterator > > path_type; - path_type path = find_item (p); + tl::Extractor extr (p.c_str ()); + path_type path = find_item (extr); if (! path.empty ()) { for (path_type::const_reverse_iterator p = path.rbegin (); p != path.rend (); ++p) { @@ -1588,18 +1581,21 @@ AbstractMenu::find_item_exact (const std::string &path) } std::vector::iterator> > -AbstractMenu::find_item (const std::string &p) +AbstractMenu::find_item (tl::Extractor &extr) { typedef std::vector::iterator> > path_type; path_type path; - tl::Extractor extr (p.c_str ()); AbstractMenuItem *parent = &m_root; std::list::iterator iter = m_root.children.end (); while (parent && ! extr.at_end ()) { - if (extr.test ("#")) { + if (extr.test (";")) { + + break; + + } else if (extr.test ("#")) { unsigned int n = 0; extr.try_read (n); @@ -1721,71 +1717,6 @@ AbstractMenu::find_item (const std::string &p) return path; } -void -AbstractMenu::transfer (const MenuLayoutEntry *layout, AbstractMenuItem &item) -{ - while (layout->name) { - - item.children.push_back (AbstractMenuItem ()); - AbstractMenuItem &new_item = item.children.back (); - - lay::Action a; - - if (! mp_provider) { - a = lay::Action (new ActionHandle ((QWidget *) 0)); - } else if (layout->slot) { - // reuse any actions already registered for this slot - a = mp_provider->action_for_slot (layout->slot); - } else if (! layout->kv_pair.first.empty ()) { - a = *mp_provider->create_config_action (layout->kv_pair.first, layout->kv_pair.second); - } else { - a = lay::Action (new ActionHandle (mp_provider->menu_parent_widget ())); - } - - if (layout->title == "-") { - - // reuse title from other entry - - } else if (! layout->title.empty ()) { - - std::string title; - std::string shortcut; - std::string res; - std::string tool_tip; - - parse_menu_title (layout->title, title, shortcut, res, tool_tip); - - a.set_separator (false); - a.set_title (title); - - if (! shortcut.empty ()) { - a.set_default_shortcut (shortcut); - } - - if (! tool_tip.empty ()) { - a.set_tool_tip (tool_tip); - } - - if (! res.empty ()) { - a.set_icon (res); - } - - } else { - a.set_separator (true); - } - - new_item.setup_item (item.name (), layout->name, a); - - if (layout->submenu) { - new_item.set_has_submenu (); - transfer (layout->submenu, item.children.back ()); - } - - ++layout; - - } -} - std::vector AbstractMenu::group (const std::string &name) const { diff --git a/src/laybasic/laybasic/layAbstractMenu.h b/src/laybasic/laybasic/layAbstractMenu.h index 588d60afd..728e5f343 100644 --- a/src/laybasic/laybasic/layAbstractMenu.h +++ b/src/laybasic/laybasic/layAbstractMenu.h @@ -50,10 +50,9 @@ class QMenu; namespace lay { -class AbstractMenuProvider; class Action; class AbstractMenu; -class PluginRoot; +class Dispatcher; /** * @brief A utility function to convert the packed key binding in the cfg_key_bindings string to a vector @@ -406,7 +405,7 @@ private: /** * @brief A specialisation for the Action to issue a "configure" request on "triggered" * - * When this action is triggered, a "configure" request is issued to the PluginRoot instance + * When this action is triggered, a "configure" request is issued to the Dispatcher instance * (which is the root of the configuration hierarchy). The name and value is given by the * respective parameters passed to the constructor or set with the write accessors. */ @@ -420,21 +419,21 @@ public: /** * @brief The default constructor * - * @param pr The reference to the plugin root object which receives the configure request + * @param dispatcher The reference to the dispatcher object which receives the configure request */ - ConfigureAction (lay::PluginRoot *pr); + ConfigureAction (lay::Dispatcher *dispatcher); /** * @brief Create an configure action with the given name and value * - * @param pr The reference to the plugin root object which receives the configure request + * @param dispatcher The reference to the dispatcher object which receives the configure request * @param cname The name of the configuration parameter to set * @param cvalue The value to set "cname" to * * The value can be "?" in which case the configuration action describes * a boolean parameter which is mapped to a checkable action. */ - ConfigureAction (lay::PluginRoot *pr, const std::string &cname, const std::string &value); + ConfigureAction (lay::Dispatcher *dispatcher, const std::string &cname, const std::string &value); /** * @brief Create an configure action with the given title (icon, keyboard shortcut), name and value @@ -449,7 +448,7 @@ public: * The value can be "?" in which case the configuration action describes * a boolean parameter which is mapped to a checkable action. */ - ConfigureAction (lay::PluginRoot *pr, const std::string &title, const std::string &cname, const std::string &value); + ConfigureAction (lay::Dispatcher *dispatcher, const std::string &title, const std::string &cname, const std::string &value); /** * @brief Destructor @@ -505,63 +504,11 @@ private: ConfigureAction (const ConfigureAction &action); ConfigureAction &operator= (const ConfigureAction &action); - lay::PluginRoot *m_pr; + lay::Dispatcher *m_dispatcher; std::string m_cname, m_cvalue; type m_type; }; -/** - * @brief A menu layout entry for static initialisation - * - * These objects act as the "source" for creating the initial AbstractLayout setup. - */ -struct LAYBASIC_PUBLIC MenuLayoutEntry { - - MenuLayoutEntry (const char *_name, - const std::string &_title, - const std::pair &_kv_pair) - : name (_name), title (_title), slot (0), kv_pair (_kv_pair), submenu (0) - { } - - MenuLayoutEntry (const char *_name, - const std::string &_title, - const char *_slot, - const MenuLayoutEntry *_submenu = 0) - : name (_name), title (_title), slot (_slot), submenu (_submenu) - { } - - MenuLayoutEntry (const char *_name, - const std::string &_title, - const MenuLayoutEntry *_submenu = 0) - : name (_name), title (_title), slot (0), submenu (_submenu) - { } - - MenuLayoutEntry (const char *_name) - : name (_name), slot (0), submenu (0) - { } - - MenuLayoutEntry () - : name (0), slot (0), submenu (0) - { } - - static MenuLayoutEntry separator (const char *name) - { - return MenuLayoutEntry (name); - } - - static MenuLayoutEntry last () - { - return MenuLayoutEntry (); - } - - const char *name; - std::string title; - const char *slot; - std::pair kv_pair; - const MenuLayoutEntry *submenu; - -}; - /** * @brief One item in the abstract menu */ @@ -636,11 +583,6 @@ private: * Each item can be associated with a Action, which delivers a title, enabled/disable state etc. * The Action is either provided when new entries are inserted or created upon initialisation. * - * An abstract menu is initialised from a initialisation sequence given by a list of - * MenuLayoutEntry objects terminated with a MenuLayoutEntry::last() item. - * Each of these entries may provide a submenu. Beside for initialisation, these entries - * are not used further. - * * The abstract menu class provides methods to manipulate the menu structure (the state of the * menu items, their title and shortcut key is provided and manipulated through the Action object). * @@ -684,18 +626,13 @@ public: /** * @brief Create the abstract menu object attached to the given main window */ - AbstractMenu (AbstractMenuProvider *provider); + AbstractMenu (Dispatcher *dispatcher); /** * @brief Destroy the abstract menu object */ ~AbstractMenu (); - /** - * @brief Initialise from a sequence of MenuLayoutEntry objects - */ - void init (const MenuLayoutEntry *layout); - /** * @brief Rebuild the QMenu's and refill the QMenuBar object */ @@ -873,10 +810,9 @@ signals: private: friend class Action; - std::vector::iterator> > find_item (const std::string &path); + std::vector::iterator> > find_item (tl::Extractor &extr); const AbstractMenuItem *find_item_exact (const std::string &path) const; AbstractMenuItem *find_item_exact (const std::string &path); - void transfer (const MenuLayoutEntry *layout, AbstractMenuItem &item); void build (QMenu *menu, std::list &items); void build (QToolBar *tbar, std::list &items); void collect_group (std::vector &grp, const std::string &name, const AbstractMenuItem &item) const; @@ -890,9 +826,9 @@ private: * @param provider The abstract menu provider (the global one will be used if this instance is 0) * @return The ActionHandle object created */ - static ActionHandle *create_action (const std::string &s, lay::AbstractMenuProvider *provider); + static ActionHandle *create_action (const std::string &s, lay::Dispatcher *dispatcher); - AbstractMenuProvider *mp_provider; + Dispatcher *mp_dispatcher; AbstractMenuItem m_root; tl::stable_vector m_helper_menu_items; std::map m_action_groups; diff --git a/src/laybasic/laybasic/layAbstractMenuProvider.cc b/src/laybasic/laybasic/layAbstractMenuProvider.cc deleted file mode 100644 index 543a6f84e..000000000 --- a/src/laybasic/laybasic/layAbstractMenuProvider.cc +++ /dev/null @@ -1,51 +0,0 @@ - -/* - - KLayout Layout Viewer - Copyright (C) 2006-2020 Matthias Koefferlein - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -*/ - - -#include "layAbstractMenuProvider.h" - -namespace lay -{ - -static AbstractMenuProvider *ms_instance = 0; - -AbstractMenuProvider::AbstractMenuProvider (bool reg_inst) -{ - if (reg_inst && ! ms_instance) { - ms_instance = this; - } -} - -AbstractMenuProvider::~AbstractMenuProvider () -{ - if (ms_instance == this) { - ms_instance = 0; - } -} - -AbstractMenuProvider *AbstractMenuProvider::instance () -{ - return ms_instance; -} - -} - diff --git a/src/laybasic/laybasic/layAbstractMenuProvider.h b/src/laybasic/laybasic/layAbstractMenuProvider.h deleted file mode 100644 index 4c2d6b26e..000000000 --- a/src/laybasic/laybasic/layAbstractMenuProvider.h +++ /dev/null @@ -1,107 +0,0 @@ - -/* - - KLayout Layout Viewer - Copyright (C) 2006-2020 Matthias Koefferlein - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -*/ - - -#ifndef HDR_layAbstractMenuProvider -#define HDR_layAbstractMenuProvider - -#include "laybasicCommon.h" - -#include - -class QWidget; - -namespace lay -{ - -class AbstractMenu; -class Action; -class ConfigureAction; - -/** - * @brief An interface for the supplier of the abstract menu object - */ -class LAYBASIC_PUBLIC AbstractMenuProvider -{ -public: - /** - * @brief Constructor - * If "reg_inst" is true, this instance will become the global instance - */ - AbstractMenuProvider (bool reg_inst = true); - - /** - * @brief Destructor - */ - virtual ~AbstractMenuProvider (); - - /** - * @brief Gets the AbstractMenu object - */ - virtual AbstractMenu *menu () = 0; - - /** - * @brief Gets the parent widget - */ - virtual QWidget *menu_parent_widget () = 0; - - /** - * @brief Get the action for a slot - */ - virtual lay::Action &action_for_slot (const char *slot) = 0; - - /** - * @brief Create a configuration action with the given title, parameter name and value - * - * The action will be owned by the abstract menu provider but can be deleted to remove it from there. - */ - virtual lay::Action *create_config_action (const std::string &title, const std::string &cname, const std::string &cvalue) = 0; - - /** - * @brief Create a configuration action with the given parameter name and value - * - * The action will be owned by the abstract menu provider but can be deleted to remove it from there. - * This version is provided for applications, where the title is set later. - */ - virtual lay::Action *create_config_action (const std::string &cname, const std::string &cvalue) = 0; - - /** - * @brief Register a configuration action with the given name - */ - virtual void register_config_action (const std::string &name, lay::ConfigureAction *action) = 0; - - /** - * @brief Unregister a configuration action with the given name - */ - virtual void unregister_config_action (const std::string &name, lay::ConfigureAction *action) = 0; - - /** - * @brief Gets the singleton instance of the AbstractMenuProvider object - */ - static AbstractMenuProvider *instance (); -}; - -} - -#endif - - diff --git a/src/laybasic/laybasic/layBookmarksView.cc b/src/laybasic/laybasic/layBookmarksView.cc index 57831e651..2898a702f 100644 --- a/src/laybasic/laybasic/layBookmarksView.cc +++ b/src/laybasic/laybasic/layBookmarksView.cc @@ -134,26 +134,6 @@ BookmarksView::follow_selection (bool f) m_follow_selection = f; } -void -BookmarksView::init_menu (lay::AbstractMenu &menu) -{ - MenuLayoutEntry context_menu [] = { - MenuLayoutEntry ("follow_selection", tl::to_string (QObject::tr ("Follow Selection")), std::make_pair (cfg_bookmarks_follow_selection, "?")), - MenuLayoutEntry::separator ("ops_group"), - MenuLayoutEntry ("manage_bookmarks", tl::to_string (QObject::tr ("Manage Bookmarks")), SLOT (cm_manage_bookmarks ())), - MenuLayoutEntry ("load_bookmarks", tl::to_string (QObject::tr ("Load Bookmarks")), SLOT (cm_load_bookmarks ())), - MenuLayoutEntry ("save_bookmarks", tl::to_string (QObject::tr ("Save Bookmarks")), SLOT (cm_save_bookmarks ())), - MenuLayoutEntry::last () - }; - - MenuLayoutEntry main_menu [] = { - MenuLayoutEntry ("@bookmarks_context_menu", "", context_menu), - MenuLayoutEntry::last () - }; - - menu.init (main_menu); -} - void BookmarksView::set_background_color (QColor c) { @@ -209,5 +189,30 @@ BookmarksView::bookmark_triggered (const QModelIndex &index) } } +// ------------------------------------------------------------ +// Declaration of the "plugin" for the menu entries + +class BookmarksViewPluginDeclaration + : public lay::PluginDeclaration +{ +public: + virtual void get_menu_entries (std::vector &menu_entries) const + { + std::string at; + + at = ".end"; + menu_entries.push_back (lay::submenu ("@bookmarks_context_menu", at, std::string ())); + + at = "@bookmarks_context_menu.end"; + menu_entries.push_back (lay::config_menu_item ("follow_selection", at, tl::to_string (QObject::tr ("Follow Selection")), cfg_bookmarks_follow_selection, "?")), + menu_entries.push_back (lay::separator ("ops_group", at)); + menu_entries.push_back (lay::menu_item ("cm_manage_bookmarks", "manage_bookmarks", at, tl::to_string (QObject::tr ("Manage Bookmarks"))); + menu_entries.push_back (lay::menu_item ("cm_load_bookmarks", "load_bookmarks", at, tl::to_string (QObject::tr ("Load Bookmarks"))); + menu_entries.push_back (lay::menu_item ("cm_save_bookmarks", "save_bookmarks", at, tl::to_string (QObject::tr ("Save Bookmarks"))); + } +}; + +static tl::RegisteredClass config_decl (new BookmarksViewPluginDeclaration (), -7, "BookmarksViewPlugin"); + } diff --git a/src/laybasic/laybasic/layBookmarksView.h b/src/laybasic/laybasic/layBookmarksView.h index e8398931c..8ee811345 100644 --- a/src/laybasic/laybasic/layBookmarksView.h +++ b/src/laybasic/laybasic/layBookmarksView.h @@ -59,8 +59,6 @@ public: void refresh (); - static void init_menu (lay::AbstractMenu &menu); - public slots: void bookmark_triggered (const QModelIndex &index); void current_bookmark_changed (const QModelIndex &index); diff --git a/src/laybasic/laybasic/layDispatcher.cc b/src/laybasic/laybasic/layDispatcher.cc new file mode 100644 index 000000000..3c74de4e1 --- /dev/null +++ b/src/laybasic/laybasic/layDispatcher.cc @@ -0,0 +1,282 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2020 Matthias Koefferlein + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +*/ + + +#include "layDispatcher.h" + +#include "tlXMLParser.h" +#include "tlXMLWriter.h" + +namespace lay +{ + +// ---------------------------------------------------------------- +// Dispatcher implementation + +static Dispatcher *ms_dispatcher_instance = 0; + +Dispatcher::Dispatcher (Plugin *parent, bool standalone) + : Plugin (parent, standalone), + m_menu (this) +{ + if (! parent) { + ms_dispatcher_instance = this; + } +} + +Dispatcher::~Dispatcher () +{ + if (ms_dispatcher_instance == this) { + ms_dispatcher_instance = 0; + } +} + +lay::Action * +Dispatcher::create_config_action (const std::string &title, const std::string &cname, const std::string &cvalue) +{ + lay::ConfigureAction *ca = new lay::ConfigureAction (this, title, cname, cvalue); + m_ca_collection.push_back (ca); + return ca; +} + +lay::Action * +Dispatcher::create_config_action (const std::string &cname, const std::string &cvalue) +{ + lay::ConfigureAction *ca = new lay::ConfigureAction (this, std::string (), cname, cvalue); + m_ca_collection.push_back (ca); + return ca; +} + +void +Dispatcher::register_config_action (const std::string &name, lay::ConfigureAction *action) +{ + std::map >::iterator ca = m_configuration_actions.insert (std::make_pair (name, std::vector ())).first; + for (std::vector::iterator a = ca->second.begin (); a != ca->second.end (); ++a) { + if (*a == action) { + return; // already registered + } + } + + ca->second.push_back (action); +} + +void +Dispatcher::unregister_config_action (const std::string &name, lay::ConfigureAction *action) +{ + std::map >::iterator ca = m_configuration_actions.find (name); + if (ca != m_configuration_actions.end ()) { + for (std::vector::iterator a = ca->second.begin (); a != ca->second.end (); ++a) { + if (*a == action) { + ca->second.erase (a); + return; + } + } + } +} + +void +Dispatcher::clear_configuration_actions () +{ + m_ca_collection.clear (); + m_configuration_actions.clear (); +} + +bool +Dispatcher::configure (const std::string &name, const std::string &value) +{ + std::map >::iterator ca = m_configuration_actions.find (name); + if (ca != m_configuration_actions.end ()) { + for (std::vector::const_iterator a = ca->second.begin (); a != ca->second.end (); ++a) { + (*a)->configure (value); + } + } + + return false; +} + +// Writing and Reading of configuration + +struct ConfigGetAdaptor +{ + ConfigGetAdaptor (const std::string &name) + : mp_owner (0), m_done (false), m_name (name) + { + // .. nothing yet .. + } + + std::string operator () () const + { + std::string s; + mp_owner->config_get (m_name, s); + return s; + } + + bool at_end () const + { + return m_done; + } + + void start (const lay::Dispatcher &owner) + { + mp_owner = &owner; + m_done = false; + } + + void next () + { + m_done = true; + } + +private: + const lay::Dispatcher *mp_owner; + bool m_done; + std::string m_name; +}; + +struct ConfigGetNullAdaptor +{ + ConfigGetNullAdaptor () + { + // .. nothing yet .. + } + + std::string operator () () const + { + return std::string (); + } + + bool at_end () const + { + return true; + } + + void start (const lay::Dispatcher & /*owner*/) { } + void next () { } +}; + +struct ConfigNamedSetAdaptor +{ + ConfigNamedSetAdaptor () + { + // .. nothing yet .. + } + + void operator () (lay::Dispatcher &w, tl::XMLReaderState &reader, const std::string &name) const + { + tl::XMLObjTag tag; + w.config_set (name, *reader.back (tag)); + } +}; + +struct ConfigSetAdaptor +{ + ConfigSetAdaptor (const std::string &name) + : m_name (name) + { + // .. nothing yet .. + } + + void operator () (lay::Dispatcher &w, tl::XMLReaderState &reader) const + { + tl::XMLObjTag tag; + w.config_set (m_name, *reader.back (tag)); + } + +private: + std::string m_name; +}; + +// the configuration file's XML structure is built dynamically +static tl::XMLStruct +config_structure (const lay::Dispatcher *plugin) +{ + tl::XMLElementList body; + std::string n_with_underscores; + + std::vector names; + plugin->get_config_names (names); + + for (std::vector ::const_iterator n = names.begin (); n != names.end (); ++n) { + + body.append (tl::XMLMember > ( + ConfigGetAdaptor (*n), ConfigSetAdaptor (*n), *n)); + + // for compatibility, provide an alternative with underscores (i.e. 0.20->0.21 because of default_grids) + n_with_underscores.clear (); + for (const char *c = n->c_str (); *c; ++c) { + n_with_underscores += (*c == '-' ? '_' : *c); + } + + body.append (tl::XMLMember > ( + ConfigGetNullAdaptor (), ConfigSetAdaptor (*n), n_with_underscores)); + + } + + // add a wildcard member to read all others unspecifically into the repository + body.append (tl::XMLWildcardMember > (ConfigNamedSetAdaptor ())); + + return tl::XMLStruct ("config", body); +} + + +bool +Dispatcher::write_config (const std::string &config_file) +{ + try { + tl::OutputStream os (config_file, tl::OutputStream::OM_Plain); + config_structure (this).write (os, *this); + return true; + } catch (...) { + return false; + } +} + +bool +Dispatcher::read_config (const std::string &config_file) +{ + std::auto_ptr file; + + try { + file.reset (new tl::XMLFileSource (config_file)); + } catch (...) { + return false; + } + + try { + config_structure (this).parse (*file, *this); + } catch (tl::Exception &ex) { + std::string msg = tl::to_string (QObject::tr ("Problem reading config file ")) + config_file + ": " + ex.msg (); + throw tl::Exception (msg); + } + + config_end (); + + return true; +} + +Dispatcher * +Dispatcher::instance () +{ + return ms_dispatcher_instance; +} + +} diff --git a/src/laybasic/laybasic/layDispatcher.h b/src/laybasic/laybasic/layDispatcher.h new file mode 100644 index 000000000..63c562f1a --- /dev/null +++ b/src/laybasic/laybasic/layDispatcher.h @@ -0,0 +1,175 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2020 Matthias Koefferlein + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +*/ + + +#ifndef HDR_layDispatcher +#define HDR_layDispatcher + +#include "laybasicCommon.h" + +#include "tlTypeTraits.h" +#include "tlObject.h" +#include "layPlugin.h" + +#include +#include +#include + +namespace lay +{ + +class AbstractMenu; +class Action; +class ConfigureAction; + +/** + * @brief The central menu event and configuration dispatcher class + * + * This class acts as the top level dispatcher for plugin events and the menu configuration. + * + */ +class LAYBASIC_PUBLIC Dispatcher + : public Plugin +{ +public: + /** + * @brief The constructor + * + * @param parent Usually 0, but a dispatcher may have parents. In this case, the dispatcher is not the actual dispatcher, but the real plugin chain's root is. + * @param standalone The standalone flag passed to the plugin constructor. + */ + Dispatcher (Plugin *parent, bool standalone = false); + + /** + * @brief Destructor + */ + ~Dispatcher (); + + /** + * @brief Write configuration to a file + * + * If the configuration file cannot be written, false + * is returned but no exception is thrown. + * + * @return false, if an error occurred. + */ + bool write_config (const std::string &config_file); + + /** + * @brief Read the configuration from a file + * + * This method siletly does nothing, if the config file does not + * exist. If it does and an error occurred, the error message is printed + * on stderr. In both cases, false is returned. + * + * @return false, if an error occurred. + */ + bool read_config (const std::string &config_file); + + /** + * @brief The singleton instance of the plugin root + */ + static Dispatcher *instance (); + + /** + * @brief Notifies the plugin root that a new plugin class has been registered + * + * This method is called when a plugin is loaded dynamically during runtime. + */ + virtual void plugin_registered (lay::PluginDeclaration * /*cls*/) { } + + /** + * @brief Notifies the plugin root that a plugin class is about to be removed + */ + virtual void plugin_removed (lay::PluginDeclaration * /*cls*/) { } + + /** + * @brief Selects the given mode + * + * The implementation is supposed to select the given mode on all related plugins. + */ + virtual void select_mode (int /*mode*/) { } + + /** + * @brief Gets the parent widget + */ + virtual QWidget *menu_parent_widget () { return 0; } + + /** + * @brief Gets the AbstractMenu object + */ + AbstractMenu *menu () { return &m_menu; } + + /** + * @brief Creates a configuration action with the given title, parameter name and value + * + * The action will be owned by the abstract menu provider but can be deleted to remove it from there. + */ + lay::Action *create_config_action (const std::string &title, const std::string &cname, const std::string &cvalue); + + /** + * @brief Creates a configuration action with the given parameter name and value + * + * The action will be owned by the abstract menu provider but can be deleted to remove it from there. + * This version is provided for applications, where the title is set later. + */ + lay::Action *create_config_action (const std::string &cname, const std::string &cvalue); + + /** + * @brief Registers a configuration action with the given name + */ + void register_config_action (const std::string &name, lay::ConfigureAction *action); + + /** + * @brief Unregisters a configuration action with the given name + */ + void unregister_config_action (const std::string &name, lay::ConfigureAction *action); + +protected: + // capture the configuration events so we can change the value of the configuration actions + virtual bool configure (const std::string &name, const std::string &value); + + void clear_configuration_actions (); + +private: + Dispatcher (const Dispatcher &); + Dispatcher &operator= (const Dispatcher &); + + lay::AbstractMenu m_menu; + std::map > m_configuration_actions; + tl::shared_collection m_ca_collection; +}; + +} + +namespace tl +{ + // disable copy ctor for Dispatcher + template <> struct type_traits : public type_traits { + typedef tl::false_tag has_copy_constructor; + typedef tl::false_tag has_default_constructor; + }; +} + +#endif + + diff --git a/src/laybasic/laybasic/layGridNet.cc b/src/laybasic/laybasic/layGridNet.cc index afb3188df..9c90f2144 100644 --- a/src/laybasic/laybasic/layGridNet.cc +++ b/src/laybasic/laybasic/layGridNet.cc @@ -105,7 +105,7 @@ GridNetPluginDeclaration::config_page (QWidget *parent, std::string &title) cons } lay::Plugin * -GridNetPluginDeclaration::create_plugin (db::Manager *, lay::PluginRoot *, lay::LayoutView *view) const +GridNetPluginDeclaration::create_plugin (db::Manager *, Dispatcher *, lay::LayoutView *view) const { return new lay::GridNet (view); } diff --git a/src/laybasic/laybasic/layGridNet.h b/src/laybasic/laybasic/layGridNet.h index 4121a986f..400796dae 100644 --- a/src/laybasic/laybasic/layGridNet.h +++ b/src/laybasic/laybasic/layGridNet.h @@ -44,7 +44,7 @@ class GridNetPluginDeclaration public: virtual void get_options (std::vector < std::pair > &options) const; virtual lay::ConfigPage *config_page (QWidget *parent, std::string &title) const; - virtual lay::Plugin *create_plugin (db::Manager *, lay::PluginRoot *, lay::LayoutView *view) const; + virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *, lay::LayoutView *view) const; }; class GridNetConfigPage @@ -56,8 +56,8 @@ public: GridNetConfigPage (QWidget *parent); ~GridNetConfigPage (); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); private: Ui::GridNetConfigPage *mp_ui; diff --git a/src/laybasic/laybasic/layHierarchyControlPanel.cc b/src/laybasic/laybasic/layHierarchyControlPanel.cc index 304445681..ba95960a0 100644 --- a/src/laybasic/laybasic/layHierarchyControlPanel.cc +++ b/src/laybasic/laybasic/layHierarchyControlPanel.cc @@ -194,52 +194,6 @@ HCPCellTreeWidget::mouseReleaseEvent (QMouseEvent *event) const int max_cellviews_in_split_mode = 5; -void -HierarchyControlPanel::init_menu (lay::AbstractMenu &menu) -{ - MenuLayoutEntry sorting_menu [] = { - MenuLayoutEntry ("by_name", tl::to_string (QObject::tr ("By Name")), std::make_pair (cfg_cell_list_sorting, "?by-name")), - MenuLayoutEntry ("by_area", tl::to_string (QObject::tr ("By Area - Small To Large")), std::make_pair (cfg_cell_list_sorting, "?by-area")), - MenuLayoutEntry ("by_area", tl::to_string (QObject::tr ("By Area - Large To Small")), std::make_pair (cfg_cell_list_sorting, "?by-area-reverse")), - MenuLayoutEntry::last () - }; - - MenuLayoutEntry context_menu [] = { - MenuLayoutEntry ("flat_mode", tl::to_string (QObject::tr ("Flat Cell List")), std::make_pair (cfg_flat_cell_list, "?")), - MenuLayoutEntry ("split_mode", tl::to_string (QObject::tr ("Split Mode")), std::make_pair (cfg_split_cell_list, "?")), - MenuLayoutEntry ("sorting", tl::to_string (QObject::tr ("Sorting")), sorting_menu), - 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 ())), - MenuLayoutEntry::last () - }; - - MenuLayoutEntry main_menu [] = { - MenuLayoutEntry ("@hcp_context_menu", "", context_menu), - MenuLayoutEntry::last () - }; - - menu.init (main_menu); -} - HierarchyControlPanel::HierarchyControlPanel (lay::LayoutView *view, QWidget *parent, const char *name) : QFrame (parent), m_enable_cb (true), @@ -1204,4 +1158,57 @@ HierarchyControlPanel::paste () } } +// ------------------------------------------------------------ +// Declaration of the "plugin" for the menu entries + +class HierarchyControlPanelPluginDeclaration + : public lay::PluginDeclaration +{ +public: + virtual void get_menu_entries (std::vector &menu_entries) const + { + std::string at; + + at = ".end"; + menu_entries.push_back (lay::submenu ("@hcp_context_menu", at, std::string ())); + + at = "@hcp_context_menu.end"; + + menu_entries.push_back (lay::config_menu_item ("flat_mode", at, tl::to_string (QObject::tr ("Flat Cell List")), cfg_flat_cell_list, "?")), + menu_entries.push_back (lay::config_menu_item ("split_mode", at, tl::to_string (QObject::tr ("Split Mode")), cfg_split_cell_list, "?")), + menu_entries.push_back (lay::submenu ("sorting", at, tl::to_string (QObject::tr ("Sorting")))); + + { + std::string at = "@hcp_context_menu.sorting.end"; + menu_entries.push_back (lay::config_menu_item ("by_name", at, tl::to_string (QObject::tr ("By Name")), cfg_cell_list_sorting, "?by-name")); + menu_entries.push_back (lay::config_menu_item ("by_area", at, tl::to_string (QObject::tr ("By Area - Small To Large")), cfg_cell_list_sorting, "?by-area")); + menu_entries.push_back (lay::config_menu_item ("by_area", at, tl::to_string (QObject::tr ("By Area - Large To Small")), cfg_cell_list_sorting, "?by-area-reverse")); + } + + menu_entries.push_back (lay::separator ("operations_group", at)); + menu_entries.push_back (lay::menu_item ("cm_new_cell", "new_cell:edit:edit_mode", at, tl::to_string (QObject::tr ("New Cell"))); + menu_entries.push_back (lay::menu_item ("cm_cell_delete", "delete_cell:edit:edit_mode", at, tl::to_string (QObject::tr ("Delete Cell"))); + menu_entries.push_back (lay::menu_item ("cm_cell_rename", "rename_cell:edit:edit_mode", at, tl::to_string (QObject::tr ("Rename Cell"))); + menu_entries.push_back (lay::menu_item ("cm_cell_replace", "replace_cell:edit:edit_mode", at, tl::to_string (QObject::tr ("Replace Cell"))); + menu_entries.push_back (lay::menu_item ("cm_cell_flatten", "flatten_cell:edit:edit_mode", at, tl::to_string (QObject::tr ("Flatten Cell"))); + menu_entries.push_back (lay::menu_item ("cm_cell_user_properties", "cell_user_properties", at, tl::to_string (QObject::tr ("User Properties"))); + menu_entries.push_back (lay::separator ("clipboard_group:edit_mode", at)); + menu_entries.push_back (lay::menu_item ("cm_cell_copy", "copy:edit_mode", at, tl::to_string (QObject::tr ("Copy"))); + menu_entries.push_back (lay::menu_item ("cm_cell_cut", "cut:edit_mode", at, tl::to_string (QObject::tr ("Cut"))); + menu_entries.push_back (lay::menu_item ("cm_cell_paste", "paste:edit_mode", at, tl::to_string (QObject::tr ("Paste"))); + menu_entries.push_back (lay::separator ("select_group", at)); + menu_entries.push_back (lay::menu_item ("cm_cell_select", "show_as_top", at, tl::to_string (QObject::tr ("Show As New Top"))); + menu_entries.push_back (lay::separator ("visibility_group", at)); + menu_entries.push_back (lay::menu_item ("cm_cell_hide", "hide_cell", at, tl::to_string (QObject::tr ("Hide"))); + menu_entries.push_back (lay::menu_item ("cm_cell_show", "show_cell", at, tl::to_string (QObject::tr ("Show"))); + menu_entries.push_back (lay::menu_item ("cm_cell_show_all", "show_all", at, tl::to_string (QObject::tr ("Show All"))); + menu_entries.push_back (lay::separator ("utils_group", at)); + menu_entries.push_back (lay::menu_item ("cm_open_current_cell", "open_current", at, tl::to_string (QObject::tr ("Where Am I?"))); + menu_entries.push_back (lay::separator ("file_group", at)); + menu_entries.push_back (lay::menu_item ("cm_save_current_cell_as", "save_cell_as:hide_vo", at, tl::to_string (QObject::tr ("Save Selected Cells As"))); + } +}; + +static tl::RegisteredClass config_decl (new HierarchyControlPanelPluginDeclaration (), -8, "HierarchyControlPanelPlugin"); + } // namespace lay diff --git a/src/laybasic/laybasic/layHierarchyControlPanel.h b/src/laybasic/laybasic/layHierarchyControlPanel.h index 23af9d822..f990a6916 100644 --- a/src/laybasic/laybasic/layHierarchyControlPanel.h +++ b/src/laybasic/laybasic/layHierarchyControlPanel.h @@ -116,11 +116,6 @@ public: */ ~HierarchyControlPanel (); - /** - * @brief Perform the cell control panel's initialisations on the main menu - */ - static void init_menu (lay::AbstractMenu &menu); - /** * @brief The sizeHint implementation for Qt layout management */ diff --git a/src/laybasic/laybasic/layLayerControlPanel.cc b/src/laybasic/laybasic/layLayerControlPanel.cc index 152862370..1bd353eab 100644 --- a/src/laybasic/laybasic/layLayerControlPanel.cc +++ b/src/laybasic/laybasic/layLayerControlPanel.cc @@ -229,86 +229,6 @@ LCPTreeWidget::expand_all () // -------------------------------------------------------------------- // LayerControlPanel implementation -void -LayerControlPanel::init_menu (lay::AbstractMenu &menu) -{ - MenuLayoutEntry sort_by_menu [] = { - MenuLayoutEntry ("sort_ild", tl::to_string (QObject::tr ("Layout Index, Layer And Datatype")), SLOT (cm_lv_sort_by_ild ())), - MenuLayoutEntry ("sort_idl", tl::to_string (QObject::tr ("Layout Index, Datatype And Layer")), SLOT (cm_lv_sort_by_idl ())), - MenuLayoutEntry ("sort_ldi", tl::to_string (QObject::tr ("Layer, Datatype And Layout Index")), SLOT (cm_lv_sort_by_ldi ())), - MenuLayoutEntry ("sort_dli", tl::to_string (QObject::tr ("Datatype, Layer And Layout Index")), SLOT (cm_lv_sort_by_dli ())), - MenuLayoutEntry ("sort_name", tl::to_string (QObject::tr ("Name")), SLOT (cm_lv_sort_by_name ())), - MenuLayoutEntry::last () - }; - - MenuLayoutEntry regroup_menu [] = { - MenuLayoutEntry ("grp_i", tl::to_string (QObject::tr ("By Layout Index")), SLOT (cm_lv_regroup_by_index ())), - MenuLayoutEntry ("grp_d", tl::to_string (QObject::tr ("By Datatype")), SLOT (cm_lv_regroup_by_datatype ())), - MenuLayoutEntry ("grp_l", tl::to_string (QObject::tr ("By Layer")), SLOT (cm_lv_regroup_by_layer ())), - MenuLayoutEntry ("flatten", tl::to_string (QObject::tr ("Flatten")), SLOT (cm_lv_regroup_flatten ())), - MenuLayoutEntry::last () - }; - - MenuLayoutEntry tab_menu [] = { - MenuLayoutEntry ("new_tab", tl::to_string (QObject::tr ("New Tab")), SLOT (cm_lv_new_tab ())), - MenuLayoutEntry ("remove_tab", tl::to_string (QObject::tr ("Remove Tab")), SLOT (cm_lv_remove_tab ())), - MenuLayoutEntry ("rename_tab", tl::to_string (QObject::tr ("Rename Tab")), SLOT (cm_lv_rename_tab ())), - MenuLayoutEntry::last () - }; - - MenuLayoutEntry context_menu [] = { - MenuLayoutEntry ("select_all", tl::to_string (QObject::tr ("Select All")), SLOT (cm_lv_select_all ())), - // It is not sure, whether "expandAll" destabilizes the tree widget: - // MenuLayoutEntry ("expand_all", tl::to_string (QObject::tr ("Expand All")), SLOT (cm_lv_expand_all ())), - MenuLayoutEntry::separator ("tab_group"), - MenuLayoutEntry ("tab_menu", tl::to_string (QObject::tr ("Tabs")), tab_menu), - MenuLayoutEntry::separator ("visibility_group"), - MenuLayoutEntry ("hide", tl::to_string (QObject::tr ("Hide")), SLOT (cm_lv_hide ())), - MenuLayoutEntry ("hide_all", tl::to_string (QObject::tr ("Hide All")), SLOT (cm_lv_hide_all ())), - MenuLayoutEntry ("show", tl::to_string (QObject::tr ("Show")), SLOT (cm_lv_show ())), - MenuLayoutEntry ("show_all", tl::to_string (QObject::tr ("Show All")), SLOT (cm_lv_show_all ())), - MenuLayoutEntry ("show_only", tl::to_string (QObject::tr ("Show Only Selected")), SLOT (cm_lv_show_only ())), - MenuLayoutEntry ("valid", tl::to_string (QObject::tr ("Make Valid")), SLOT (cm_lv_make_valid ())), - MenuLayoutEntry ("invvalid", tl::to_string (QObject::tr ("Make Invalid")), SLOT (cm_lv_make_invalid ())), - MenuLayoutEntry ("rename", tl::to_string (QObject::tr ("Rename")), SLOT (cm_lv_rename ())), - MenuLayoutEntry::separator ("options_group"), - MenuLayoutEntry ("hide_empty_layers", tl::to_string (QObject::tr ("Hide Empty Layers")), std::make_pair (cfg_hide_empty_layers, "?")), - MenuLayoutEntry ("test_shapes_in_view", tl::to_string (QObject::tr ("Test For Shapes In View")), std::make_pair (cfg_test_shapes_in_view, "?")), - MenuLayoutEntry::separator ("source_group"), - MenuLayoutEntry ("select_source", tl::to_string (QObject::tr ("Select Source")), SLOT (cm_lv_source ())), - MenuLayoutEntry::separator ("sort_group"), - MenuLayoutEntry ("sort_menu", tl::to_string (QObject::tr ("Sort By")), sort_by_menu), - MenuLayoutEntry::separator ("view_group"), - MenuLayoutEntry ("del", tl::to_string (QObject::tr ("Delete Layer Entry")), SLOT (cm_lv_delete ())), - MenuLayoutEntry ("insert", tl::to_string (QObject::tr ("Insert Layer Entry")), SLOT (cm_lv_insert ())), - MenuLayoutEntry ("add_others", tl::to_string (QObject::tr ("Add Other Layer Entries")), SLOT (cm_lv_add_missing ())), - MenuLayoutEntry ("clean_up", tl::to_string (QObject::tr ("Clean Up Layer Entries")), SLOT (cm_lv_remove_unused ())), - MenuLayoutEntry::separator ("grouping_group"), - MenuLayoutEntry ("group", tl::to_string (QObject::tr ("Group")), SLOT (cm_lv_group ())), - MenuLayoutEntry ("ungroup", tl::to_string (QObject::tr ("Ungroup")), SLOT (cm_lv_ungroup ())), - MenuLayoutEntry ("regroup_menu", tl::to_string (QObject::tr ("Regroup Layer Entries")), regroup_menu), - MenuLayoutEntry::separator ("copy_paste_group"), - MenuLayoutEntry ("copy", tl::to_string (QObject::tr ("Copy")), SLOT (cm_lv_copy ())), - MenuLayoutEntry ("cut", tl::to_string (QObject::tr ("Cut")), SLOT (cm_lv_cut ())), - MenuLayoutEntry ("paste", tl::to_string (QObject::tr ("Paste")), SLOT (cm_lv_paste ())), - MenuLayoutEntry::last () - }; - - MenuLayoutEntry lcp_context_menu [] = { - MenuLayoutEntry ("@lcp_context_menu", "", context_menu), - MenuLayoutEntry::last () - }; - - menu.init (lcp_context_menu); - - MenuLayoutEntry lcp_tab_context_menu [] = { - MenuLayoutEntry ("@lcp_tabs_context_menu", "", tab_menu), - MenuLayoutEntry::last () - }; - - menu.init (lcp_tab_context_menu); -} - LayerControlPanel::LayerControlPanel (lay::LayoutView *view, db::Manager *manager, QWidget *parent, const char *name) : QFrame (parent), db::Object (manager), @@ -2399,4 +2319,96 @@ LayerControlPanel::do_move (int mode) mp_view->set_selected_layers (new_sel); } +// ------------------------------------------------------------ +// Declaration of the "plugin" for the menu entries + +class LayerControlPanelPluginDeclaration + : public lay::PluginDeclaration +{ +public: + virtual void get_menu_entries (std::vector &menu_entries) const + { + std::string at; + + at = ".end"; + menu_entries.push_back (lay::submenu ("@lcp_context_menu", at, std::string ())); + + at = "@lcp_context_menu.end"; + + menu_entries.push_back (lay::menu_item ("cm_lv_select_all", "select_all", at, tl::to_string (QObject::tr ("Select All"))); + // It is not sure, whether "expandAll" destabilizes the tree widget: + // menu_entries.push_back (lay::menu_item ("cm_lv_expand_all", "expand_all", at, tl::to_string (QObject::tr ("Expand All"))); + menu_entries.push_back (lay::separator ("tab_group", at)); + menu_entries.push_back (lay::submenu ("tab_menu", at, tl::to_string (QObject::tr ("Tabs")))); + + { + std::string at = "@lcp_context_menu.tab_menu.end"; + menu_entries.push_back (lay::menu_item ("cm_lv_new_tab", "new_tab", at, tl::to_string (QObject::tr ("New Tab"))); + menu_entries.push_back (lay::menu_item ("cm_lv_remove_tab", "remove_tab", at, tl::to_string (QObject::tr ("Remove Tab"))); + menu_entries.push_back (lay::menu_item ("cm_lv_rename_tab", "rename_tab", at, tl::to_string (QObject::tr ("Rename Tab"))); + } + + menu_entries.push_back (lay::separator ("visibility_group", at)); + menu_entries.push_back (lay::menu_item ("cm_lv_hide", "hide", at, tl::to_string (QObject::tr ("Hide"))); + menu_entries.push_back (lay::menu_item ("cm_lv_hide_all", "hide_all", at, tl::to_string (QObject::tr ("Hide All"))); + menu_entries.push_back (lay::menu_item ("cm_lv_show", "show", at, tl::to_string (QObject::tr ("Show"))); + menu_entries.push_back (lay::menu_item ("cm_lv_show_all", "show_all", at, tl::to_string (QObject::tr ("Show All"))); + menu_entries.push_back (lay::menu_item ("cm_lv_show_only", "show_only", at, tl::to_string (QObject::tr ("Show Only Selected"))); + menu_entries.push_back (lay::menu_item ("cm_lv_make_valid", "valid", at, tl::to_string (QObject::tr ("Make Valid"))); + menu_entries.push_back (lay::menu_item ("cm_lv_make_invalid", "invvalid", at, tl::to_string (QObject::tr ("Make Invalid"))); + menu_entries.push_back (lay::menu_item ("cm_lv_rename", "rename", at, tl::to_string (QObject::tr ("Rename"))); + menu_entries.push_back (lay::separator ("options_group", at)); + menu_entries.push_back (lay::config_menu_item ("hide_empty_layers", at, tl::to_string (QObject::tr ("Hide Empty Layers")), cfg_hide_empty_layers, "?")); + menu_entries.push_back (lay::config_menu_item ("test_shapes_in_view", at, tl::to_string (QObject::tr ("Test For Shapes In View")), cfg_test_shapes_in_view, "?")); + menu_entries.push_back (lay::separator ("source_group", at)); + menu_entries.push_back (lay::menu_item ("cm_lv_source", "select_source", at, tl::to_string (QObject::tr ("Select Source"))); + menu_entries.push_back (lay::separator ("sort_group", at)); + menu_entries.push_back (lay::submenu ("sort_menu", at, tl::to_string (QObject::tr ("Sort By")))); + + { + std::string at = "@lcp_context_menu.sort_menu.end"; + menu_entries.push_back (lay::menu_item ("cm_lv_sort_by_ild", "sort_ild", at, tl::to_string (QObject::tr ("Layout Index, Layer And Datatype"))); + menu_entries.push_back (lay::menu_item ("cm_lv_sort_by_idl", "sort_idl", at, tl::to_string (QObject::tr ("Layout Index, Datatype And Layer"))); + menu_entries.push_back (lay::menu_item ("cm_lv_sort_by_ldi", "sort_ldi", at, tl::to_string (QObject::tr ("Layer, Datatype And Layout Index"))); + menu_entries.push_back (lay::menu_item ("cm_lv_sort_by_dli", "sort_dli", at, tl::to_string (QObject::tr ("Datatype, Layer And Layout Index"))); + menu_entries.push_back (lay::menu_item ("cm_lv_sort_by_name", "sort_name", at, tl::to_string (QObject::tr ("Name"))); + } + + menu_entries.push_back (lay::separator ("view_group", at)); + menu_entries.push_back (lay::menu_item ("cm_lv_delete", "del", at, tl::to_string (QObject::tr ("Delete Layer Entry"))); + menu_entries.push_back (lay::menu_item ("cm_lv_insert", "insert", at, tl::to_string (QObject::tr ("Insert Layer Entry"))); + menu_entries.push_back (lay::menu_item ("cm_lv_add_missing", "add_others", at, tl::to_string (QObject::tr ("Add Other Layer Entries"))); + menu_entries.push_back (lay::menu_item ("cm_lv_remove_unused", "clean_up", at, tl::to_string (QObject::tr ("Clean Up Layer Entries"))); + menu_entries.push_back (lay::separator ("grouping_group", at)); + menu_entries.push_back (lay::menu_item ("cm_lv_group", "group", at, tl::to_string (QObject::tr ("Group"))); + menu_entries.push_back (lay::menu_item ("cm_lv_ungroup", "ungroup", at, tl::to_string (QObject::tr ("Ungroup"))); + menu_entries.push_back (lay::submenu ("regroup_menu", at, tl::to_string (QObject::tr ("Regroup Layer Entries")))); + + { + std::string at = "@lcp_context_menu.regroup_menu.end"; + menu_entries.push_back (lay::menu_item ("cm_lv_regroup_by_index", "grp_i", at, tl::to_string (QObject::tr ("By Layout Index"))); + menu_entries.push_back (lay::menu_item ("cm_lv_regroup_by_datatype", "grp_d", at, tl::to_string (QObject::tr ("By Datatype"))); + menu_entries.push_back (lay::menu_item ("cm_lv_regroup_by_layer", "grp_l", at, tl::to_string (QObject::tr ("By Layer"))); + menu_entries.push_back (lay::menu_item ("cm_lv_regroup_flatten", "flatten", at, tl::to_string (QObject::tr ("Flatten"))); + } + + menu_entries.push_back (lay::separator ("copy_paste_group", at)); + menu_entries.push_back (lay::menu_item ("cm_lv_copy", "copy", at, tl::to_string (QObject::tr ("Copy"))); + menu_entries.push_back (lay::menu_item ("cm_lv_cut", "cut", at, tl::to_string (QObject::tr ("Cut"))); + menu_entries.push_back (lay::menu_item ("cm_lv_paste", "paste", at, tl::to_string (QObject::tr ("Paste"))); + + at = ".end"; + menu_entries.push_back (lay::submenu ("@lcp_tabs_context_menu", at, std::string ())); + + { + std::string at = "@lcp_tabs_context_menu.end"; + menu_entries.push_back (lay::menu_item ("cm_lv_new_tab", "new_tab", at, tl::to_string (QObject::tr ("New Tab"))); + menu_entries.push_back (lay::menu_item ("cm_lv_remove_tab", "remove_tab", at, tl::to_string (QObject::tr ("Remove Tab"))); + menu_entries.push_back (lay::menu_item ("cm_lv_rename_tab", "rename_tab", at, tl::to_string (QObject::tr ("Rename Tab"))); + } + } +}; + +static tl::RegisteredClass config_decl (new LayerControlPanelPluginDeclaration (), -9, "LayerControlPanelPlugin"); + } // namespace lay diff --git a/src/laybasic/laybasic/layLayerControlPanel.h b/src/laybasic/laybasic/layLayerControlPanel.h index a6bbde994..d7caea7a5 100644 --- a/src/laybasic/laybasic/layLayerControlPanel.h +++ b/src/laybasic/laybasic/layLayerControlPanel.h @@ -138,11 +138,6 @@ public: */ bool has_focus () const; - /** - * @brief Perform the layer control panel's initialisations on the main menu - */ - static void init_menu (lay::AbstractMenu &menu); - /** * @brief Tell, if there is something to copy */ diff --git a/src/lay/lay/layLayoutStatistics.qrc b/src/laybasic/laybasic/layLayoutStatistics.qrc similarity index 100% rename from src/lay/lay/layLayoutStatistics.qrc rename to src/laybasic/laybasic/layLayoutStatistics.qrc diff --git a/src/lay/lay/layLayoutStatisticsForm.cc b/src/laybasic/laybasic/layLayoutStatisticsForm.cc similarity index 100% rename from src/lay/lay/layLayoutStatisticsForm.cc rename to src/laybasic/laybasic/layLayoutStatisticsForm.cc diff --git a/src/lay/lay/layLayoutStatisticsForm.h b/src/laybasic/laybasic/layLayoutStatisticsForm.h similarity index 100% rename from src/lay/lay/layLayoutStatisticsForm.h rename to src/laybasic/laybasic/layLayoutStatisticsForm.h diff --git a/src/laybasic/laybasic/layLayoutView.cc b/src/laybasic/laybasic/layLayoutView.cc index 13a29ea6f..45525bef6 100644 --- a/src/laybasic/laybasic/layLayoutView.cc +++ b/src/laybasic/laybasic/layLayoutView.cc @@ -44,7 +44,6 @@ #include "tlAssert.h" #include "tlExceptions.h" #include "layLayoutView.h" -#include "layAbstractMenuProvider.h" #include "layViewOp.h" #include "layViewObject.h" #include "layLayoutViewConfigPages.h" @@ -70,6 +69,11 @@ #include "layBookmarkManagementForm.h" #include "layNetlistBrowserDialog.h" #include "layBookmarksView.h" +#include "laySelectCellViewForm.h" +#include "layCellSelectionForm.h" +#include "layLayoutPropertiesForm.h" +#include "layLayoutStatisticsForm.h" +#include "dbClipboard.h" #include "dbLayout.h" #include "dbLayoutUtils.h" #include "dbRecursiveShapeIterator.h" @@ -255,35 +259,33 @@ static LayoutView *ms_current = 0; LayoutView::LayoutView (db::Manager *manager, bool editable, lay::Plugin *plugin_parent, QWidget *parent, const char *name, unsigned int options) : QFrame (parent), - lay::Plugin (plugin_parent), - lay::AbstractMenuProvider (false /* don't register as global instance */), - m_menu (this), + lay::Dispatcher (plugin_parent, false /*not standalone*/), m_editable (editable), m_options (options), m_annotation_shapes (manager), dm_prop_changed (this, &LayoutView::do_prop_changed) { - if (! plugin_root_maybe_null ()) { - mp_plugin_root.reset (new lay::PluginRoot (true, false)); - } + // either it's us or the parent has a dispatcher + tl_assert (dispatcher () != 0); // ensures the deferred method scheduler is present tl::DeferredMethodScheduler::instance (); setObjectName (QString::fromUtf8 (name)); - init (manager, plugin_root_maybe_null () ? plugin_root_maybe_null () : mp_plugin_root.get (), parent); + init (manager, dispatcher (), parent); } -LayoutView::LayoutView (lay::LayoutView *source, db::Manager *manager, bool editable, lay::PluginRoot *root, QWidget *parent, const char *name, unsigned int options) +LayoutView::LayoutView (lay::LayoutView *source, db::Manager *manager, bool editable, lay::Plugin *plugin_parent, QWidget *parent, const char *name, unsigned int options) : QFrame (parent), - lay::Plugin (root), - lay::AbstractMenuProvider (false /* don't register as global instance */), - m_menu (this), + lay::Dispatcher (plugin_parent, false /*not standalone*/), m_editable (editable), m_options (options), m_annotation_shapes (manager), dm_prop_changed (this, &LayoutView::do_prop_changed) { + // either it's us or the parent has a dispatcher + tl_assert (dispatcher () != 0); + // ensures the deferred method scheduler is present tl::DeferredMethodScheduler::instance (); @@ -291,7 +293,7 @@ LayoutView::LayoutView (lay::LayoutView *source, db::Manager *manager, bool edit m_annotation_shapes = source->m_annotation_shapes; - init (manager, root, parent); + init (manager, dispatcher (), parent); // set the handle reference and clear all cell related stuff m_cellviews = source->cellview_list (); @@ -353,14 +355,13 @@ LayoutView::eventFilter(QObject *obj, QEvent *event) } void -LayoutView::init (db::Manager *mgr, lay::PluginRoot *root, QWidget * /*parent*/) +LayoutView::init (db::Manager *mgr, lay::Dispatcher *dispatcher, QWidget * /*parent*/) { manager (mgr); - if (! lay::AbstractMenuProvider::instance () || ! lay::AbstractMenuProvider::instance ()->menu ()) { - init_menu (m_menu); + if (! dispatcher) { // build the context menus, nothing else so far. - m_menu.build (0, 0); + menu ()->build (0, 0); } m_annotation_shapes.manager (mgr); @@ -597,9 +598,7 @@ LayoutView::init (db::Manager *mgr, lay::PluginRoot *root, QWidget * /*parent*/) connect (mp_timer, SIGNAL (timeout ()), this, SLOT (timer ())); mp_timer->start (timer_interval); - if (root) { - create_plugins (root); - } + create_plugins (); m_new_layer_props.layer = 1; m_new_layer_props.datatype = 0; @@ -704,62 +703,6 @@ QWidget *LayoutView::menu_parent_widget () return this; } -lay::Action & -LayoutView::action_for_slot (const char *slot) -{ - std::map::iterator a = m_actions_for_slot.find (std::string (slot)); - if (a != m_actions_for_slot.end ()) { - return a->second; - } else { - Action a = Action::create_free_action (this); - gtf::action_connect (a.qaction (), SIGNAL (triggered ()), this, slot); - return m_actions_for_slot.insert (std::make_pair (std::string (slot), a)).first->second; - } -} - -lay::Action * -LayoutView::create_config_action (const std::string &title, const std::string &cname, const std::string &cvalue) -{ - lay::ConfigureAction *ca = new lay::ConfigureAction (plugin_root (), title, cname, cvalue); - m_ca_collection.push_back (ca); - return ca; -} - -lay::Action * -LayoutView::create_config_action (const std::string &cname, const std::string &cvalue) -{ - lay::ConfigureAction *ca = new lay::ConfigureAction (plugin_root (), std::string (), cname, cvalue); - m_ca_collection.push_back (ca); - return ca; -} - -void -LayoutView::register_config_action (const std::string &name, lay::ConfigureAction *action) -{ - std::map >::iterator ca = m_configuration_actions.insert (std::make_pair (name, std::vector ())).first; - for (std::vector::iterator a = ca->second.begin (); a != ca->second.end (); ++a) { - if (*a == action) { - return; // already registered - } - } - - ca->second.push_back (action); -} - -void -LayoutView::unregister_config_action (const std::string &name, lay::ConfigureAction *action) -{ - std::map >::iterator ca = m_configuration_actions.find (name); - if (ca != m_configuration_actions.end ()) { - for (std::vector::iterator a = ca->second.begin (); a != ca->second.end (); ++a) { - if (*a == action) { - ca->second.erase (a); - return; - } - } - } -} - void LayoutView::side_panel_destroyed () { if (sender () == mp_control_frame) { @@ -859,9 +802,9 @@ void LayoutView::drop_url (const std::string &path_or_url) } } -lay::Plugin *LayoutView::create_plugin (lay::PluginRoot *root, const lay::PluginDeclaration *cls) +lay::Plugin *LayoutView::create_plugin (const lay::PluginDeclaration *cls) { - lay::Plugin *p = cls->create_plugin (manager (), root, this); + lay::Plugin *p = cls->create_plugin (manager (), dispatcher (), this); if (p) { // unhook the plugin from the script side if created there (prevent GC from destroying it) @@ -881,7 +824,7 @@ lay::Plugin *LayoutView::create_plugin (lay::PluginRoot *root, const lay::Plugin return p; } -void LayoutView::create_plugins (lay::PluginRoot *root, const lay::PluginDeclaration *except_this) +void LayoutView::create_plugins (const lay::PluginDeclaration *except_this) { for (std::vector::iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) { delete *p; @@ -896,13 +839,13 @@ void LayoutView::create_plugins (lay::PluginRoot *root, const lay::PluginDeclara // TODO: clean solution. The following is a HACK: if (cls.current_name () == "ant::Plugin" || cls.current_name () == "img::Plugin") { // ant and img are created always - create_plugin (root, &*cls); + create_plugin (&*cls); } else if ((m_options & LV_NoPlugins) == 0) { // others: only create unless LV_NoPlugins is set - create_plugin (root, &*cls); + create_plugin (&*cls); } else if ((m_options & LV_NoGrid) == 0 && cls.current_name () == "GridNetPlugin") { // except grid net plugin which is created on request - create_plugin (root, &*cls); + create_plugin (&*cls); } } @@ -932,15 +875,6 @@ Plugin *LayoutView::get_plugin_by_name (const std::string &name) const return 0; } -void -LayoutView::init_menu (lay::AbstractMenu &menu) -{ - lay::LayerControlPanel::init_menu (menu); - lay::HierarchyControlPanel::init_menu (menu); - lay::LibrariesView::init_menu (menu); - lay::BookmarksView::init_menu (menu); -} - void LayoutView::update_menu (lay::LayoutView *view, lay::AbstractMenu &menu) { @@ -1045,6 +979,8 @@ LayoutView::reset_title () bool LayoutView::configure (const std::string &name, const std::string &value) { + lay::Dispatcher::configure (name, value); + if (mp_move_service && mp_move_service->configure (name, value)) { return true; } @@ -4773,7 +4709,7 @@ LayoutView::active_library_changed (int /*index*/) // commit the new active library to the other views and persist this state // TODO: could be passed through the LibraryController (like through some LibraryController::active_library) - plugin_root ()->config_set (cfg_current_lib_view, lib_name); + dispatcher ()->config_set (cfg_current_lib_view, lib_name); } void @@ -6540,25 +6476,461 @@ LayoutView::intrinsic_mouse_modes (std::vector *descriptions) AbstractMenu * LayoutView::menu () { - if (lay::AbstractMenuProvider::instance () && lay::AbstractMenuProvider::instance ()->menu ()) { - return lay::AbstractMenuProvider::instance ()->menu (); - } else { - return &m_menu; - } + // NOTE: dispatcher is either this or the real end of the chain + return dispatcher ()->menu (); } -int +int LayoutView::default_mode () { return 0; // TODO: any generic scheme? is select, should be ruler.. } -void +void +LayoutView::do_cm_duplicate (bool interactive) +{ + // Do duplicate simply by concatenating copy & paste currently. + // Save the clipboard state before in order to preserve the current content + db::Clipboard saved_clipboard; + db::Clipboard::instance ().swap (saved_clipboard); + + try { + copy (); + clear_selection (); + cancel (); + if (interactive) { + paste_interactive (); + } else { + paste (); + } + db::Clipboard::instance ().swap (saved_clipboard); + } catch (...) { + db::Clipboard::instance ().swap (saved_clipboard); + throw; + } +} + +void +LayoutView::do_cm_paste (bool interactive) +{ + if (! db::Clipboard::instance ().empty ()) { + cancel (); + clear_selection (); + if (interactive) { + paste_interactive (); + } else { + paste (); + } + } +} + +void +LayoutView::cm_new_cell () +{ + static double s_new_cell_window_size = 2.0; + static std::string s_new_cell_cell_name; + + NewCellPropertiesDialog cell_prop_dia (this); + if (cell_prop_dia.exec_dialog (& cellview (active_cellview_index ())->layout (), s_new_cell_cell_name, s_new_cell_window_size)) { + + db::cell_index_type new_ci = new_cell (active_cellview_index (), s_new_cell_cell_name.c_str ()); + select_cell (new_ci, active_cellview_index ()); + + db::DBox zb = db::DBox (-0.5 * s_new_cell_window_size, -0.5 * s_new_cell_window_size, 0.5 * s_new_cell_window_size, 0.5 * s_new_cell_window_size); + if (get_max_hier_levels () < 1 || get_min_hier_levels () > 0) { + zoom_box_and_set_hier_levels (zb, std::make_pair (0, 1)); + } else { + zoom_box (zb); + } + + } +} + +// TODO: this constant is defined in MainWindow.cc too ... +const int max_dirty_files = 15; + +void +LayoutView::cm_reload () +{ + std::vector selected; + + if (cellviews () > 1) { + + SelectCellViewForm form (0, this, tl::to_string (QObject::tr ("Select Layouts To Reload"))); + form.select_all (); + + if (form.exec () == QDialog::Accepted) { + selected = form.selected_cellviews (); + } + + } else if (cellviews () > 0) { + selected.push_back (0); + } + + if (selected.size () > 0) { + + int dirty_layouts = 0; + std::string dirty_files; + + for (std::vector ::const_iterator i = selected.begin (); i != selected.end (); ++i) { + + const lay::CellView &cv = cellview (*i); + + if (cv->layout ().is_editable () && cv->is_dirty ()) { + ++dirty_layouts; + if (dirty_layouts == max_dirty_files) { + dirty_files += "\n..."; + } else if (dirty_layouts < max_dirty_files) { + if (! dirty_files.empty ()) { + dirty_files += "\n"; + } + dirty_files += cv->name (); + } + } + + } + + bool can_reload = true; + if (dirty_layouts != 0) { + + QMessageBox mbox (this); + mbox.setText (tl::to_qstring (tl::to_string (QObject::tr ("The following layouts need saving:\n\n")) + dirty_files + "\n\nPress 'Reload Without Saving' to reload anyhow and discard changes.")); + mbox.setWindowTitle (QObject::tr ("Save Needed")); + mbox.setIcon (QMessageBox::Warning); + QAbstractButton *yes_button = mbox.addButton (QObject::tr ("Reload Without Saving"), QMessageBox::YesRole); + mbox.addButton (QMessageBox::Cancel); + + mbox.exec (); + + can_reload = (mbox.clickedButton() == yes_button); + + } + + if (can_reload) { + + // Actually reload + for (std::vector ::const_iterator i = selected.begin (); i != selected.end (); ++i) { + reload_layout (*i); + } + + } + + } +} + +std::vector +LayoutView::menu_symbols () +{ + // TODO: currently these are all symbols from all plugins + return lay::PluginDeclaration::menu_symbols (); +} + +void LayoutView::menu_activated (const std::string &symbol) { - // distribute the menu on the plugins - one should take it. - for (std::vector::iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) { - (*p)->menu_activated (symbol); + if (symbol == "cm_show_properties") { + show_properties (this); + } else if (symbol == "cm_delete") { + + del (); + // because a "delete" might involve objects currently edited, we cancel the edit after we have deleted the object + cancel (); + clear_selection (); + + } else if (symbol == "cm_unselect_all") { + select (db::DBox (), lay::Editable::Reset); + } else if (symbol == "cm_select_all") { + select (full_box (), lay::Editable::Replace); + } else if (symbol == "cm_lv_paste") { + cm_layer_paste (); + } else if (symbol == "cm_lv_cut") { + cm_layer_cut (); + } else if (symbol == "cm_lv_copy") { + cm_layer_copy (); + } else if (symbol == "cm_cell_paste") { + cm_cell_paste (); + } else if (symbol == "cm_cell_cut") { + cm_cell_cut (); + } else if (symbol == "cm_cell_copy") { + cm_cell_copy (); + } else if (symbol == "cm_duplicate") { + do_cm_duplicate (false); + } else if (symbol == "cm_duplicate_interactive") { + do_cm_duplicate (true); + } else if (symbol == "cm_copy") { + + copy (); + clear_selection (); + + } else if (symbol == "cm_paste") { + do_cm_paste (true); + } else if (symbol == "cm_paste_interactive") { + do_cm_paste (true); + } else if (symbol == "cm_cut") { + + cut (); + cancel (); // see del() for reason why cancel is after cut + clear_selection (); + + } else if (symbol == "cm_zoom_fit_sel") { + zoom_fit_sel (); + } else if (symbol == "cm_zoom_fit") { + zoom_fit (); + } else if (symbol == "cm_pan_left") { + pan_left (); + } else if (symbol == "cm_pan_right") { + pan_right (); + } else if (symbol == "cm_pan_up") { + pan_up (); + } else if (symbol == "cm_pan_down") { + pan_down (); + } else if (symbol == "cm_zoom_in") { + zoom_in (); + } else if (symbol == "cm_zoom_out") { + zoom_out (); + } else if (symbol == "cm_select_current_cell") { + + if (active_cellview_index () >= 0) { + lay::LayoutView::cell_path_type path; + int cvi = active_cellview_index (); + current_cell_path (path); + select_cell_fit (path, cvi); + } + + } else if (symbol == "cm_open_current_cell") { + + if (active_cellview_index () >= 0) { + cm_open_current_cell (); + } + + } else if (symbol == "cm_select_cell") { + + if (active_cellview_index () >= 0) { + + CellSelectionForm form (0, this, "cell_selection_form"); + + if (form.exec () == QDialog::Accepted && + form.selected_cellview_index () >= 0) { + select_cell (form.selected_cellview ().combined_unspecific_path (), form.selected_cellview_index ()); + set_current_cell_path (form.selected_cellview_index (), form.selected_cellview ().combined_unspecific_path ()); + zoom_fit (); + } + + } + + } else if (symbol == "cm_new_cell") { + cm_new_cell (); + } else if (symbol == "cm_adjust_origin") { + if (active_cellview_index () >= 0) { + cm_align_cell_origin (); + } + } else if (symbol == "cm_cell_convert_to_static") { + if (active_cellview_index () >= 0) { + cm_cell_convert_to_static (); + } + } else if (symbol == "cm_lay_convert_to_static") { + if (active_cellview_index () >= 0) { + cm_lay_convert_to_static (); + } + } else if (symbol == "cm_lay_move") { + if (active_cellview_index () >= 0) { + cm_lay_move (); + } + } else if (symbol == "cm_lay_scale") { + if (active_cellview_index () >= 0) { + cm_lay_scale (); + } + } else if (symbol == "cm_lay_free_rot") { + if (active_cellview_index () >= 0) { + cm_lay_free_rot (); + } + } else if (symbol == "cm_lay_rot_ccw") { + if (active_cellview_index () >= 0) { + cm_lay_rot_ccw (); + } + } else if (symbol == "cm_lay_rot_cw") { + if (active_cellview_index () >= 0) { + cm_lay_rot_cw (); + } + } else if (symbol == "cm_lay_flip_y") { + if (active_cellview_index () >= 0) { + cm_lay_flip_y (); + } + } else if (symbol == "cm_lay_flip_x") { + if (active_cellview_index () >= 0) { + cm_lay_flip_x (); + } + } else if (symbol == "cm_sel_move") { + if (active_cellview_index () >= 0) { + cm_sel_move (); + } + } else if (symbol == "cm_sel_move_to") { + if (active_cellview_index () >= 0) { + cm_sel_move_to (); + } + } else if (symbol == "cm_sel_move_interactive") { + if (active_cellview_index () >= 0) { + cm_sel_move_interactive (); + } + } else if (symbol == "cm_sel_scale") { + if (active_cellview_index () >= 0) { + cm_sel_scale (); + } + } else if (symbol == "cm_sel_free_rot") { + if (active_cellview_index () >= 0) { + cm_sel_free_rot (); + } + } else if (symbol == "cm_sel_rot_ccw") { + if (active_cellview_index () >= 0) { + cm_sel_rot_ccw (); + } + } else if (symbol == "cm_sel_rot_cw") { + if (active_cellview_index () >= 0) { + cm_sel_rot_cw (); + } + } else if (symbol == "cm_sel_flip_y") { + if (active_cellview_index () >= 0) { + cm_sel_flip_y (); + } + } else if (symbol == "cm_sel_flip_x") { + if (active_cellview_index () >= 0) { + cm_sel_flip_x (); + } + } else if (symbol == "cm_edit_layer") { + if (active_cellview_index () >= 0) { + cm_edit_layer (); + } + } else if (symbol == "cm_delete_layer") { + if (active_cellview_index () >= 0) { + cm_edit_layer (); + } + } else if (symbol == "cm_clear_layer") { + if (active_cellview_index () >= 0) { + cm_clear_layer (); + } + } else if (symbol == "cm_copy_layer") { + if (active_cellview_index () >= 0) { + cm_copy_layer (); + } + } else if (symbol == "cm_new_layer") { + if (active_cellview_index () >= 0) { + cm_new_layer (); + } + } else if (symbol == "cm_layout_props") { + LayoutPropertiesForm lp_form (this, this, "layout_props_form"); + lp_form.exec (); + } else if (symbol == "cm_layout_stats") { + LayoutStatisticsForm lp_form (this, this, "layout_props_form"); + lp_form.exec (); + } else if (symbol == "cm_reload") { + cm_reload (); + } else if (symbol == "cm_inc_max_hier") { + int new_to = get_max_hier_levels () + 1; + set_hier_levels (std::make_pair (get_min_hier_levels (), new_to)); + } else if (symbol == "cm_dec_max_hier") { + int new_to = get_max_hier_levels () > 0 ? get_max_hier_levels () - 1 : 0; + set_hier_levels (std::make_pair (std::min (get_min_hier_levels (), new_to), new_to)); + } else if (symbol == "cm_max_hier") { + max_hier (); + } else if (symbol == "cm_max_hier_0") { + set_hier_levels (std::make_pair (std::min (get_min_hier_levels (), 0), 0)); + } else if (symbol == "cm_max_hier_1") { + set_hier_levels (std::make_pair (std::min (get_min_hier_levels (), 0), 1)); + } else if (symbol == "cm_prev_display_state") { + if (has_prev_display_state ()) { + prev_display_state (); + } + } else if (symbol == "cm_next_display_state") { + if (has_next_display_state ()) { + next_display_state (); + } + } else if (symbol == "cm_redraw") { + redraw (); + } else if (symbol == "cm_cell_delete") { + cm_cell_delete (); + } else if (symbol == "cm_cell_replace") { + cm_cell_replace (); + } else if (symbol == "cm_cell_rename") { + cm_cell_rename (); + } else if (symbol == "cm_cell_flatten") { + cm_cell_flatten (); + } else if (symbol == "cm_cell_select") { + cm_cell_select (); + } else if (symbol == "cm_cell_hide") { + cm_cell_hide (); + } else if (symbol == "cm_cell_show") { + cm_cell_show (); + } else if (symbol == "cm_cell_show_all") { + cm_cell_show_all (); + } else if (symbol == "cm_cell_user_properties") { + if (active_cellview_index () >= 0) { + cm_cell_user_properties (); + } + } else if (symbol == "cm_lv_select_all") { + cm_select_all (); + } else if (symbol == "cm_lv_new_tab") { + cm_new_tab (); + } else if (symbol == "cm_lv_rename_tab") { + cm_rename_tab (); + } else if (symbol == "cm_lv_make_invalid") { + cm_make_invalid (); + } else if (symbol == "cm_lv_remove_tab") { + cm_remove_tab (); + } else if (symbol == "cm_lv_make_valid") { + cm_make_valid (); + } else if (symbol == "cm_lv_hide_all") { + cm_hide_all (); + } else if (symbol == "cm_lv_hide") { + cm_hide (); + } else if (symbol == "cm_lv_show_only") { + cm_show_only (); + } else if (symbol == "cm_lv_show_all") { + cm_show_all (); + } else if (symbol == "cm_lv_show") { + cm_show (); + } else if (symbol == "cm_lv_rename") { + cm_rename (); + } else if (symbol == "cm_lv_delete") { + cm_delete (); + } else if (symbol == "cm_lv_insert") { + cm_insert (); + } else if (symbol == "cm_lv_group") { + cm_group (); + } else if (symbol == "cm_lv_ungroup") { + cm_ungroup (); + } else if (symbol == "cm_lv_source") { + cm_source (); + } else if (symbol == "cm_lv_sort_by_name") { + cm_sort_by_name (); + } else if (symbol == "cm_lv_sort_by_ild") { + cm_sort_by_ild (); + } else if (symbol == "cm_lv_sort_by_idl") { + cm_sort_by_idl (); + } else if (symbol == "cm_lv_sort_by_ldi") { + cm_sort_by_ldi (); + } else if (symbol == "cm_lv_sort_by_dli") { + cm_sort_by_dli (); + } else if (symbol == "cm_lv_regroup_by_index") { + cm_regroup_by_index (); + } else if (symbol == "cm_lv_regroup_by_datatype") { + cm_regroup_by_datatype (); + } else if (symbol == "cm_lv_regroup_by_layer") { + cm_regroup_by_layer (); + } else if (symbol == "cm_lv_regroup_flatten") { + cm_regroup_flatten (); + } else if (symbol == "cm_lv_expand_all") { + cm_expand_all (); + } else if (symbol == "cm_lv_add_missing") { + cm_add_missing (); + } else if (symbol == "cm_lv_remove_unused") { + cm_remove_unused (); + } else { + + // distribute the menu on the plugins - one should take it. + for (std::vector::iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) { + (*p)->menu_activated (symbol); + } + } } @@ -7596,5 +7968,186 @@ LayoutView::sizeHint () const } } -} // namespace lay +// ------------------------------------------------------------ +// Declaration of the "plugin" for the menu entries +class LayoutViewPluginDeclaration + : public lay::PluginDeclaration +{ +public: + virtual void get_menu_entries (std::vector &menu_entries) const + { + std::string at; + + // secret menu entries + at = "@secrets.end"; + menu_entries.push_back (lay::menu_item ("cm_paste_interactive", "paste_interactive:edit", at, tl::to_string (QObject::tr ("Paste Interactive")))); + menu_entries.push_back (lay::menu_item ("cm_duplicate_interactive", "duplicate_interactive:edit", at, tl::to_string (QObject::tr ("Duplicate Interactive")))); + menu_entries.push_back (lay::menu_item ("cm_sel_move_interactive", "sel_move_interactive:edit", at, tl::to_string (QObject::tr ("Move Interactive")))); + + at = "edit_menu.end"; + menu_entries.push_back (lay::separator ("edit_select_individual_group", at)); + + menu_entries.push_back (lay::separator ("basic_group", at)); + menu_entries.push_back (lay::submenu ("layout_menu:edit:edit_mode", at, tl::to_string (QObject::tr ("Layout")))); + { + std::string at = "edit_menu.layout_menu.end"; + menu_entries.push_back (lay::menu_item ("cm_lay_flip_x", "lay_flip_x:edit_mode", at, tl::to_string (QObject::tr ("Flip Horizontally")))); + menu_entries.push_back (lay::menu_item ("cm_lay_flip_y", "lay_flip_y:edit_mode", at, tl::to_string (QObject::tr ("Flip Vertically")))); + menu_entries.push_back (lay::menu_item ("cm_lay_rot_cw", "lay_rot_cw:edit_mode", at, tl::to_string (QObject::tr ("Rotate Clockwise")))); + menu_entries.push_back (lay::menu_item ("cm_lay_rot_ccw", "lay_rot_ccw:edit_mode", at, tl::to_string (QObject::tr ("Rotate Counterclockwise")))); + menu_entries.push_back (lay::menu_item ("cm_lay_free_rot", "lay_free_rot:edit_mode", at, tl::to_string (QObject::tr ("Rotation By Angle")))); + menu_entries.push_back (lay::menu_item ("cm_lay_scale", "lay_scale:edit_mode", at, tl::to_string (QObject::tr ("Scale")))); + menu_entries.push_back (lay::menu_item ("cm_lay_move", "lay_move:edit_mode", at, tl::to_string (QObject::tr ("Move By")))); + menu_entries.push_back (lay::separator ("cellop_group", at)); + menu_entries.push_back (lay::menu_item ("cm_lay_convert_to_static", "lay_convert_to_static:edit_mode", at, tl::to_string (QObject::tr ("Convert All Cells To Static")))); + } + + menu_entries.push_back (lay::submenu ("cell_menu:edit:edit_mode", at, tl::to_string (QObject::tr ("Cell")))); + { + std::string at = "edit_menu.cell_menu.end"; + menu_entries.push_back (lay::menu_item ("cm_new_cell", "new_cell:edit:edit_mode", at, tl::to_string (QObject::tr ("New Cell")))); + menu_entries.push_back (lay::menu_item ("cm_cell_delete", "delete_cell:edit:edit_mode", at, tl::to_string (QObject::tr ("Delete Cell")))); + menu_entries.push_back (lay::menu_item ("cm_cell_rename", "rename_cell:edit:edit_mode", at, tl::to_string (QObject::tr ("Rename Cell")))); + menu_entries.push_back (lay::menu_item ("cm_cell_replace", "replace_cell:edit:edit_mode", at, tl::to_string (QObject::tr ("Replace Cell")))); + menu_entries.push_back (lay::menu_item ("cm_cell_flatten", "flatten_cell:edit:edit_mode", at, tl::to_string (QObject::tr ("Flatten Cell")))); + menu_entries.push_back (lay::separator ("ops_group", at)); + menu_entries.push_back (lay::menu_item ("cm_adjust_origin", "adjust_cell_origin:edit:edit_mode", at, tl::to_string (QObject::tr ("Adjust Origin")))); + menu_entries.push_back (lay::menu_item ("cm_cell_convert_to_static", "convert_cell_to_static:edit_mode", at, tl::to_string (QObject::tr ("Convert Cell To Static")))); + menu_entries.push_back (lay::separator ("props_group", at)); + menu_entries.push_back (lay::menu_item ("cm_cell_user_properties", "user_properties", at, tl::to_string (QObject::tr ("User Properties")))); + } + + menu_entries.push_back (lay::submenu ("layer_menu:edit:edit_mode", at, tl::to_string (QObject::tr ("Layer")))); + { + std::string at = "edit_menu.layer_menu.end"; + menu_entries.push_back (lay::menu_item ("cm_new_layer", "new_layer:edit:edit_mode", at, tl::to_string (QObject::tr ("New Layer")))); + menu_entries.push_back (lay::menu_item ("cm_clear_layer", "clear_layer:edit:edit_mode", at, tl::to_string (QObject::tr ("Clear Layer")))); + menu_entries.push_back (lay::menu_item ("cm_delete_layer", "delete_layer:edit:edit_mode", at, tl::to_string (QObject::tr ("Delete Layer")))); + menu_entries.push_back (lay::menu_item ("cm_copy_layer", "copy_layer:edit:edit_mode", at, tl::to_string (QObject::tr ("Copy Layer")))); + menu_entries.push_back (lay::menu_item ("cm_edit_layer", "edit_layer:edit:edit_mode", at, tl::to_string (QObject::tr ("Edit Layer Specification")))); + } + + menu_entries.push_back (lay::submenu ("selection_menu:edit", at, tl::to_string (QObject::tr ("Selection")))); + { + std::string at = "edit_menu.selection_menu.end"; + menu_entries.push_back (lay::menu_item ("cm_sel_flip_x", "sel_flip_x", at, tl::to_string (QObject::tr ("Flip Horizontally")))); + menu_entries.push_back (lay::menu_item ("cm_sel_flip_y", "sel_flip_y", at, tl::to_string (QObject::tr ("Flip Vertically")))); + menu_entries.push_back (lay::menu_item ("cm_sel_rot_cw", "sel_rot_cw", at, tl::to_string (QObject::tr ("Rotate Clockwise")))); + menu_entries.push_back (lay::menu_item ("cm_sel_rot_ccw", "sel_rot_ccw", at, tl::to_string (QObject::tr ("Rotate Counterclockwise")))); + menu_entries.push_back (lay::menu_item ("cm_sel_free_rot", "sel_free_rot", at, tl::to_string (QObject::tr ("Rotation By Angle")))); + menu_entries.push_back (lay::menu_item ("cm_sel_scale", "sel_scale", at, tl::to_string (QObject::tr ("Scale")))); + menu_entries.push_back (lay::menu_item ("cm_sel_move", "sel_move", at, tl::to_string (QObject::tr ("Move By")))); + menu_entries.push_back (lay::menu_item ("cm_sel_move_to", "sel_move_to", at, tl::to_string (QObject::tr ("Move To")))); + } + + menu_entries.push_back (lay::separator ("edit_select_individual_group", at)); + + menu_entries.push_back (lay::separator ("utils_group", at)); + menu_entries.push_back (lay::submenu ("utils_menu:edit:edit_mode", at, tl::to_string (QObject::tr ("Utilities")))); + + menu_entries.push_back (lay::separator ("edit_select_individual_group", at)); + + menu_entries.push_back (lay::separator ("misc_group", at)); + menu_entries.push_back (lay::menu_item ("cm_delete", "delete:edit", at, tl::to_string (QObject::tr ("Delete(Del)")))); + menu_entries.push_back (lay::menu_item ("cm_show_properties", "show_properties:edit", at, tl::to_string (QObject::tr ("Properties(Q)")))); + menu_entries.push_back (lay::separator ("edit_select_individual_group", at)); + + menu_entries.push_back (lay::separator ("cpc_group", at)); + menu_entries.push_back (lay::menu_item ("cm_copy", "copy:edit", at, tl::to_string (QObject::tr ("Copy(Ctrl+C)")))); + menu_entries.push_back (lay::menu_item ("cm_cut", "cut:edit", at, tl::to_string (QObject::tr ("Cut(Ctrl+X)")))); + menu_entries.push_back (lay::menu_item ("cm_paste", "paste:edit", at, tl::to_string (QObject::tr ("Paste(Ctrl+V)")))); + menu_entries.push_back (lay::menu_item ("cm_duplicate", "duplicate:edit", at, tl::to_string (QObject::tr ("Duplicate(Ctrl+B)")))); + + menu_entries.push_back (lay::separator ("modes_group", at)); + menu_entries.push_back (lay::submenu ("mode_menu", at, tl::to_string (QObject::tr ("Mode")))); + + menu_entries.push_back (lay::submenu ("select_menu", at, tl::to_string (QObject::tr ("Select")))); + { + std::string at = "edit_menu.select_menu.end"; + menu_entries.push_back (lay::menu_item ("cm_select_all", "select_all", at, tl::to_string (QObject::tr ("Select All")))); + menu_entries.push_back (lay::menu_item ("cm_unselect_all", "unselect_all", at, tl::to_string (QObject::tr ("Unselect All")))); + menu_entries.push_back (lay::separator ("edit_select_basic_group", at)); + menu_entries.push_back (lay::menu_item ("enable_all", "enable_all", at, tl::to_string (QObject::tr ("Enable All")))); + menu_entries.push_back (lay::menu_item ("disable_all", "disable_all", at, tl::to_string (QObject::tr ("Disable All")))); + menu_entries.push_back (lay::separator ("edit_select_individual_group", at)); + }; + + menu_entries.push_back (lay::separator ("cancel_group", at)); + menu_entries.push_back (lay::menu_item ("cm_cancel", "cancel", at, tl::to_string (QObject::tr ("Cancel(Esc)")))); + + at = "bookmark_menu.end"; + menu_entries.push_back (lay::submenu ("goto_bookmark_menu", at, tl::to_string (QObject::tr ("Goto Bookmark")))); + menu_entries.push_back (lay::menu_item ("cm_bookmark_view", "bookmark_view", at, tl::to_string (QObject::tr ("Bookmark This View")))); + + menu_entries.push_back (lay::separator ("bookmark_mgm_group", at)); + menu_entries.push_back (lay::menu_item ("cm_manage_bookmarks", "manage_bookmarks", at, tl::to_string (QObject::tr ("Manage Bookmarks")))); + menu_entries.push_back (lay::menu_item ("cm_load_bookmarks", "load_bookmarks", at, tl::to_string (QObject::tr ("Load Bookmarks")))); + menu_entries.push_back (lay::menu_item ("cm_save_bookmarks", "save_bookmarks", at, tl::to_string (QObject::tr ("Save Bookmarks")))); + + at = "zoom_menu.end"; + menu_entries.push_back (lay::submenu ("global_trans", at, tl::to_string (QObject::tr ("Global Transformation")))); + { + std::string at = "zoom_menu.global_trans.end"; + menu_entries.push_back (lay::config_menu_item ("r0", at, tl::to_string (QObject::tr ("\\(r0\\)<:/r0.png>")), cfg_global_trans, "?r0 *1 0,0")); + menu_entries.push_back (lay::config_menu_item ("r90", at, tl::to_string (QObject::tr ("\\(r90\\)<:/r90.png>")), cfg_global_trans, "?r90 *1 0,0")); + menu_entries.push_back (lay::config_menu_item ("r180", at, tl::to_string (QObject::tr ("\\(r180\\)<:/r180.png>")), cfg_global_trans, "?r180 *1 0,0")); + menu_entries.push_back (lay::config_menu_item ("r270", at, tl::to_string (QObject::tr ("\\(r270\\)<:/r270.png>")), cfg_global_trans, "?r270 *1 0,0")); + menu_entries.push_back (lay::config_menu_item ("m0", at, tl::to_string (QObject::tr ("\\(m0\\)<:/m0.png>")), cfg_global_trans, "?m0 *1 0,0")); + menu_entries.push_back (lay::config_menu_item ("m45", at, tl::to_string (QObject::tr ("\\(m45\\)<:/m45.png>")), cfg_global_trans, "?m45 *1 0,0")); + menu_entries.push_back (lay::config_menu_item ("m90", at, tl::to_string (QObject::tr ("\\(m90\\)<:/m90.png>")), cfg_global_trans, "?m90 *1 0,0")); + menu_entries.push_back (lay::config_menu_item ("m135", at, tl::to_string (QObject::tr ("\\(m135\\)<:/m135.png>")), cfg_global_trans, "?m135 *1 0,0")); + } + + menu_entries.push_back (lay::separator ("hier_group", at)); + menu_entries.push_back (lay::menu_item ("cm_max_hier", "max_hier", at, tl::to_string (QObject::tr ("Full Hierarchy(*)")))); + menu_entries.push_back (lay::menu_item ("cm_max_hier_0", "max_hier_0", at, tl::to_string (QObject::tr ("Box Only(0)")))); + menu_entries.push_back (lay::menu_item ("cm_max_hier_1", "max_hier_1", at, tl::to_string (QObject::tr ("Top Level Only(1)")))); + menu_entries.push_back (lay::menu_item ("cm_inc_max_hier", "inc_max_hier", at, tl::to_string (QObject::tr ("Increment Hierarchy(+)")))); + menu_entries.push_back (lay::menu_item ("cm_dec_max_hier", "dec_max_hier", at, tl::to_string (QObject::tr ("Decrement Hierarchy(-)")))); + + menu_entries.push_back (lay::separator ("zoom_group", at)); + menu_entries.push_back (lay::menu_item ("cm_zoom_fit", "zoom_fit", at, tl::to_string (QObject::tr ("Zoom Fit(F2)")))); + menu_entries.push_back (lay::menu_item ("cm_zoom_fit_sel", "zoom_fit_sel", at, tl::to_string (QObject::tr ("Zoom Fit Selection(Shift+F2)")))); + menu_entries.push_back (lay::menu_item ("cm_zoom_in", "zoom_in", at, tl::to_string (QObject::tr ("Zoom In(Return)")))); + menu_entries.push_back (lay::menu_item ("cm_zoom_out", "zoom_out", at, tl::to_string (QObject::tr ("Zoom Out(Shift+Return)")))); + /* disabled because that interferes with the use of the arrow keys for moving the selection + MenuLayoutEntry::separator ("pan_group"); + menu_entries.push_back (lay::menu_item ("cm_pan_up", "pan_up", at, tl::to_string (QObject::tr ("Pan Up(Up)")))); + menu_entries.push_back (lay::menu_item ("cm_pan_down", "pan_down", at, tl::to_string (QObject::tr ("Pan Down(Down)")))); + menu_entries.push_back (lay::menu_item ("cm_pan_left", "pan_left", at, tl::to_string (QObject::tr ("Pan Left(Left)")))); + menu_entries.push_back (lay::menu_item ("cm_pan_right", "pan_right", at, tl::to_string (QObject::tr ("Pan Right(Right)")))); + */ + + menu_entries.push_back (lay::separator ("redraw_group", at)); + menu_entries.push_back (lay::menu_item ("cm_redraw", "redraw", at, tl::to_string (QObject::tr ("Redraw")))); + menu_entries.push_back (lay::separator ("state_group", at)); + menu_entries.push_back (lay::menu_item ("cm_prev_display_state", "prev_display_state", at, tl::to_string (QObject::tr ("Back(Shift+Tab)<:/back.png>")))); + menu_entries.push_back (lay::menu_item ("cm_next_display_state", "next_display_state", at, tl::to_string (QObject::tr ("Forward(Tab)<:/forward.png>")))); + + menu_entries.push_back (lay::separator ("select_group", at)); + menu_entries.push_back (lay::menu_item ("cm_select_cell", "select_cell:edit", at, tl::to_string (QObject::tr ("Select Cell")))); + menu_entries.push_back (lay::menu_item ("cm_select_current_cell", "select_current_cell", at, tl::to_string (QObject::tr ("Show As New Top(Ctrl+S)")))); + menu_entries.push_back (lay::menu_item ("cm_goto_position", "goto_position", at, tl::to_string (QObject::tr ("Goto Position(Ctrl+G)")))); + + // Add a hook for inserting new items after the modes + menu_entries.push_back (lay::separator ("end_modes", "@toolbar.end")); + + } + + void implements_primary_mouse_modes (std::vector > > &modes) + { + std::vector mode_titles; + lay::LayoutView::intrinsic_mouse_modes (&mode_titles); + + int mode_id = 0; + for (std::vector ::const_iterator t = mode_titles.begin (); t != mode_titles.end (); ++t, --mode_id) { + // modes: pair(title, pair(insert_pos, id)) + modes.push_back (std::make_pair (*t, std::make_pair ("edit_menu.mode_menu.end;@toolbar.end_modes", mode_id))); + } + } +}; + +static tl::RegisteredClass config_decl (new LayoutViewPluginDeclaration (), -10, "LayoutViewPlugin"); + +} // namespace lay diff --git a/src/laybasic/laybasic/layLayoutView.h b/src/laybasic/laybasic/layLayoutView.h index f3fa53245..c8e03cc56 100644 --- a/src/laybasic/laybasic/layLayoutView.h +++ b/src/laybasic/laybasic/layLayoutView.h @@ -38,8 +38,8 @@ #include "layLayerProperties.h" #include "layAbstractMenu.h" -#include "layAbstractMenuProvider.h" #include "layAnnotationShapes.h" +#include "layDispatcher.h" #include "layLayoutCanvas.h" #include "layColorPalette.h" #include "layStipplePalette.h" @@ -81,7 +81,6 @@ class SelectionService; class MoveService; class Browser; class ColorButton; -class PluginRoot; class ConfigureAction; /** @@ -159,8 +158,7 @@ struct LAYBASIC_PUBLIC LayerDisplayProperties class LAYBASIC_PUBLIC LayoutView : public QFrame, public lay::Editables, - public lay::Plugin, - public lay::AbstractMenuProvider + public lay::Dispatcher { Q_OBJECT @@ -198,7 +196,7 @@ public: /** * @brief Constructor (clone from another view) */ - LayoutView (lay::LayoutView *source, db::Manager *mgr, bool editable, lay::PluginRoot *root, QWidget *parent = 0, const char *name = "view", unsigned int options = (unsigned int) LV_Normal); + LayoutView (lay::LayoutView *source, db::Manager *mgr, bool editable, lay::Plugin *plugin_parent, QWidget *parent = 0, const char *name = "view", unsigned int options = (unsigned int) LV_Normal); /** * @brief Destructor @@ -1667,11 +1665,6 @@ public: */ static unsigned int intrinsic_mouse_modes (std::vector *descriptions); - /** - * @brief Perform the layout view's initialisations on the main menu - */ - static void init_menu (lay::AbstractMenu &menu); - /** * @brief Updates the menu for the given view * If the view is 0, the menu shall be updated to reflect "no view active" @@ -2018,7 +2011,7 @@ public: * PD is the type of the declaration. */ template - void create_plugin (lay::PluginRoot *root) + void create_plugin () { for (std::vector::const_iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) { if (dynamic_cast ((*p)->plugin_declaration ()) != 0) { @@ -2027,7 +2020,7 @@ public: } for (tl::Registrar::iterator cls = tl::Registrar::begin (); cls != tl::Registrar::end (); ++cls) { if (dynamic_cast (&*cls) != 0) { - create_plugin (root, &*cls); + create_plugin (&*cls); break; } } @@ -2516,7 +2509,7 @@ public: * * If plugins already exist, they are deleted and created again */ - void create_plugins (lay::PluginRoot *root, const lay::PluginDeclaration *except_this = 0); + void create_plugins (const lay::PluginDeclaration *except_this = 0); public slots: /** @@ -2678,6 +2671,7 @@ public slots: void layer_order_changed (); void timer (); void menu_activated (const std::string &symbol); + static std::vector menu_symbols (); void deactivate_all_browsers (); void min_hier_changed (int i); void max_hier_changed (int i); @@ -2762,12 +2756,6 @@ protected: void activate (); private: - lay::AbstractMenu m_menu; - std::auto_ptr mp_plugin_root; - std::map m_actions_for_slot; - std::map > m_configuration_actions; - tl::shared_collection m_ca_collection; - bool m_editable; int m_disabled_edits; unsigned int m_options; @@ -2904,7 +2892,7 @@ private: bool m_active_cellview_changed_event_enabled; tl::DeferredMethod dm_prop_changed; - void init (db::Manager *mgr, lay::PluginRoot *root, QWidget *parent); + void init (db::Manager *mgr, lay::Dispatcher *dispatcher, QWidget *parent); void do_prop_changed (); void do_redraw (int layer); @@ -2937,6 +2925,11 @@ private: void init_layer_properties (LayerProperties &props, const LayerPropertiesList &lp_list) const; void merge_dither_pattern (lay::LayerPropertiesList &props); + void do_cm_duplicate (bool interactive); + void do_cm_paste (bool interactive); + void cm_new_cell (); + void cm_reload (); + // overrides Editables method to display a message void signal_selection_changed (); @@ -2944,18 +2937,13 @@ private: void showEvent (QShowEvent *); void hideEvent (QHideEvent *); - lay::Plugin *create_plugin (lay::PluginRoot *root, const lay::PluginDeclaration *cls); + lay::Plugin *create_plugin (const lay::PluginDeclaration *cls); std::list::iterator cellview_iter (int cv_index); std::list::const_iterator cellview_iter (int cv_index) const; - // implementation of AbstractMenuProvider + // implementation of Dispatcher virtual QWidget *menu_parent_widget (); - virtual lay::Action &action_for_slot (const char *slot); - virtual lay::Action *create_config_action (const std::string &title, const std::string &cname, const std::string &cvalue); - virtual lay::Action *create_config_action (const std::string &cname, const std::string &cvalue); - virtual void register_config_action (const std::string &name, lay::ConfigureAction *action); - virtual void unregister_config_action (const std::string &name, lay::ConfigureAction *action); }; } diff --git a/src/laybasic/laybasic/layLayoutViewConfigPages.h b/src/laybasic/laybasic/layLayoutViewConfigPages.h index 71b2e254f..10ffb7a23 100644 --- a/src/laybasic/laybasic/layLayoutViewConfigPages.h +++ b/src/laybasic/laybasic/layLayoutViewConfigPages.h @@ -67,8 +67,8 @@ public: LayoutViewConfigPage (QWidget *parent); ~LayoutViewConfigPage (); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); private: Ui::LayoutViewConfigPage *mp_ui; @@ -83,8 +83,8 @@ public: LayoutViewConfigPage1 (QWidget *parent); ~LayoutViewConfigPage1 (); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); private: Ui::LayoutViewConfigPage1 *mp_ui; @@ -99,8 +99,8 @@ public: LayoutViewConfigPage2a (QWidget *parent); ~LayoutViewConfigPage2a (); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); private: Ui::LayoutViewConfigPage2a *mp_ui; @@ -115,8 +115,8 @@ public: LayoutViewConfigPage2b (QWidget *parent); ~LayoutViewConfigPage2b (); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); private: Ui::LayoutViewConfigPage2b *mp_ui; @@ -131,8 +131,8 @@ public: LayoutViewConfigPage2c (QWidget *parent); ~LayoutViewConfigPage2c (); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); private: Ui::LayoutViewConfigPage2c *mp_ui; @@ -147,8 +147,8 @@ public: LayoutViewConfigPage3a (QWidget *parent); ~LayoutViewConfigPage3a (); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); private: Ui::LayoutViewConfigPage3a *mp_ui; @@ -163,8 +163,8 @@ public: LayoutViewConfigPage3b (QWidget *parent); ~LayoutViewConfigPage3b (); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); private: Ui::LayoutViewConfigPage3b *mp_ui; @@ -179,8 +179,8 @@ public: LayoutViewConfigPage3c (QWidget *parent); ~LayoutViewConfigPage3c (); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); private: Ui::LayoutViewConfigPage3c *mp_ui; @@ -195,8 +195,8 @@ public: LayoutViewConfigPage3f (QWidget *parent); ~LayoutViewConfigPage3f (); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); private: Ui::LayoutViewConfigPage3f *mp_ui; @@ -212,8 +212,8 @@ public: LayoutViewConfigPage4 (QWidget *parent); ~LayoutViewConfigPage4 (); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); virtual void undo (db::Op *op); virtual void redo (db::Op *op); @@ -244,8 +244,8 @@ public: LayoutViewConfigPage5 (QWidget *parent); ~LayoutViewConfigPage5 (); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); public slots: void browse_clicked (); @@ -264,8 +264,8 @@ public: LayoutViewConfigPage6 (QWidget *parent); ~LayoutViewConfigPage6 (); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); virtual void undo (db::Op *op); virtual void redo (db::Op *op); @@ -298,8 +298,8 @@ public: LayoutViewConfigPage6a (QWidget *parent); ~LayoutViewConfigPage6a (); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); virtual void undo (db::Op *op); virtual void redo (db::Op *op); @@ -329,8 +329,8 @@ public: LayoutViewConfigPage7 (QWidget *parent); ~LayoutViewConfigPage7 (); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); private: Ui::LayoutViewConfigPage7 *mp_ui; diff --git a/src/laybasic/laybasic/layLibrariesView.cc b/src/laybasic/laybasic/layLibrariesView.cc index ad8d84346..4ae658748 100644 --- a/src/laybasic/laybasic/layLibrariesView.cc +++ b/src/laybasic/laybasic/layLibrariesView.cc @@ -196,25 +196,6 @@ LibraryTreeWidget::mouseReleaseEvent (QMouseEvent *event) const int max_cellviews_in_split_mode = 5; -void -LibrariesView::init_menu (lay::AbstractMenu &menu) -{ - MenuLayoutEntry context_menu [] = { -#if 0 - // 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 - MenuLayoutEntry::last () - }; - - MenuLayoutEntry main_menu [] = { - MenuLayoutEntry ("@lib_context_menu", "", context_menu), - MenuLayoutEntry::last () - }; - - menu.init (main_menu); -} - LibrariesView::LibrariesView (lay::LayoutView *view, QWidget *parent, const char *name) : QFrame (parent), m_enable_cb (true), @@ -821,4 +802,28 @@ LibrariesView::has_focus () const return m_active_index >= 0 && m_active_index < int (mp_cell_lists.size ()) && mp_cell_lists [m_active_index]->hasFocus (); } +// ------------------------------------------------------------ +// Declaration of the "plugin" for the menu entries + +class LibraryViewPluginDeclaration + : public lay::PluginDeclaration +{ +public: + virtual void get_menu_entries (std::vector &menu_entries) const + { + std::string at; + + at = ".end"; + menu_entries.push_back (lay::submenu ("@lib_context_menu", at, std::string ())); + + at = "@lib_context_menu.end"; +#if 0 + // doesn't make sense for many libs + menu_entries.push_back (lay::config_menu_item ("split_mode", at, tl::to_string (QObject::tr ("Split Mode")), cfg_split_lib_views, "?")), +#endif + } +}; + +static tl::RegisteredClass config_decl (new LibraryViewPluginDeclaration (), -7, "LibraryViewPlugin"); + } // namespace lay diff --git a/src/laybasic/laybasic/layLibrariesView.h b/src/laybasic/laybasic/layLibrariesView.h index e1674e83f..841e90a75 100644 --- a/src/laybasic/laybasic/layLibrariesView.h +++ b/src/laybasic/laybasic/layLibrariesView.h @@ -114,11 +114,6 @@ public: */ ~LibrariesView (); - /** - * @brief Perform the cell control panel's initialisations on the main menu - */ - static void init_menu (lay::AbstractMenu &menu); - /** * @brief The sizeHint implementation for Qt layout management */ diff --git a/src/laybasic/laybasic/layLoadLayoutOptionsDialog.h b/src/laybasic/laybasic/layLoadLayoutOptionsDialog.h index e36ac27db..e0183ffbb 100644 --- a/src/laybasic/laybasic/layLoadLayoutOptionsDialog.h +++ b/src/laybasic/laybasic/layLoadLayoutOptionsDialog.h @@ -52,7 +52,7 @@ namespace lay { class LayoutView; -class PluginRoot; +class Dispatcher; class FileDialog; class LAYBASIC_PUBLIC LoadLayoutOptionsDialog @@ -64,7 +64,7 @@ public: LoadLayoutOptionsDialog (QWidget *parent, const std::string &title); ~LoadLayoutOptionsDialog (); - bool edit_global_options (lay::PluginRoot *config_root, db::Technologies *technologies); + bool edit_global_options (lay::Dispatcher *dispatcher, db::Technologies *technologies); bool get_options (db::LoadLayoutOptions &options); void show_always (bool sa) diff --git a/src/laybasic/laybasic/layNetlistBrowser.h b/src/laybasic/laybasic/layNetlistBrowser.h index 46324ed75..78a8adc2a 100644 --- a/src/laybasic/laybasic/layNetlistBrowser.h +++ b/src/laybasic/laybasic/layNetlistBrowser.h @@ -50,8 +50,8 @@ class NetlistBrowserConfigPage public: NetlistBrowserConfigPage (QWidget *parent); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); public slots: void window_changed (int); @@ -66,8 +66,8 @@ class NetlistBrowserConfigPage2 public: NetlistBrowserConfigPage2 (QWidget *parent); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); public slots: void color_button_clicked (); diff --git a/src/laybasic/laybasic/layPlugin.cc b/src/laybasic/laybasic/layPlugin.cc index 0743f2504..7cea2ab8b 100644 --- a/src/laybasic/laybasic/layPlugin.cc +++ b/src/laybasic/laybasic/layPlugin.cc @@ -21,7 +21,6 @@ */ -#include "layAbstractMenuProvider.h" #include "laybasicCommon.h" #include "tlException.h" @@ -30,6 +29,7 @@ #include "tlLog.h" #include "layPlugin.h" +#include "layDispatcher.h" #include "tlExceptions.h" #include "tlClassRegistry.h" @@ -56,8 +56,10 @@ PluginDeclaration::PluginDeclaration () PluginDeclaration::~PluginDeclaration () { - if (PluginRoot::instance ()) { - PluginRoot::instance ()->plugin_removed (this); + clear_menu_items (); + + if (Dispatcher::instance ()) { + Dispatcher::instance ()->plugin_removed (this); } } @@ -69,6 +71,30 @@ PluginDeclaration::toggle_editable_enabled () END_PROTECTED } +std::vector +PluginDeclaration::menu_symbols () +{ + std::vector symbols; + + for (tl::Registrar::iterator cls = tl::Registrar::begin (); cls != tl::Registrar::end (); ++cls) { + + std::vector menu_entries; + cls->get_menu_entries (menu_entries); + + for (std::vector::const_iterator m = menu_entries.begin (); m != menu_entries.end (); ++m) { + if (! m->symbol.empty ()) { + symbols.push_back (m->symbol); + } + } + + } + + std::sort (symbols.begin (), symbols.end ()); + symbols.erase (std::unique (symbols.begin (), symbols.end ()), symbols.end ()); + + return symbols; +} + void PluginDeclaration::generic_menu () { @@ -85,7 +111,7 @@ PluginDeclaration::generic_menu () } // Forward the request to the plugin root which will propagate it down to the plugins - lay::PluginRoot::instance ()->menu_activated (symbol); + lay::Dispatcher::instance ()->menu_activated (symbol); END_PROTECTED } @@ -100,8 +126,8 @@ PluginDeclaration::mode_triggered () int mode = action->data ().toInt (); - if (lay::PluginRoot::instance ()) { - lay::PluginRoot::instance ()->select_mode (mode); + if (lay::Dispatcher::instance ()) { + lay::Dispatcher::instance ()->select_mode (mode); } action->setChecked (true); @@ -111,19 +137,24 @@ PluginDeclaration::mode_triggered () END_PROTECTED } -void -PluginDeclaration::init_menu () +void +PluginDeclaration::clear_menu_items () { - if (! lay::AbstractMenuProvider::instance () || ! lay::AbstractMenuProvider::instance ()->menu ()) { - return; + while (! m_menu_actions.empty ()) { + delete m_menu_actions.back (); + m_menu_actions.pop_back (); } +} - lay::AbstractMenu &menu = *lay::AbstractMenuProvider::instance ()->menu (); +void +PluginDeclaration::init_menu (lay::Dispatcher *dispatcher) +{ + lay::AbstractMenu &menu = *dispatcher->menu (); // pre-initialize to allow multiple init_menu calls m_editable_mode_action = lay::Action (); m_mouse_mode_action = lay::Action (); - m_menu_actions.clear (); + clear_menu_items (); std::string title; @@ -158,19 +189,41 @@ PluginDeclaration::init_menu () for (std::vector::const_iterator m = menu_entries.begin (); m != menu_entries.end (); ++m) { if (m->title.empty ()) { + menu.insert_separator (m->insert_pos, m->menu_name); + } else { if (m->sub_menu) { + menu.insert_menu (m->insert_pos, m->menu_name, m->title); + } else { - Action action (m->title); - action.qaction ()->setData (QVariant (tl::to_qstring (m->symbol))); - gtf::action_connect (action.qaction (), SIGNAL (triggered ()), this, SLOT (generic_menu ())); - menu.insert_item (m->insert_pos, m->menu_name, action); + Action *action = 0; + + if (! m->cname.empty ()) { + + action = dispatcher->create_config_action (m->title, m->cname, m->cvalue); + + } else { + + action = new Action (m->title); + action->qaction ()->setData (QVariant (tl::to_qstring (m->symbol))); + gtf::action_connect (action->qaction (), SIGNAL (triggered ()), this, SLOT (generic_menu ())); + + } m_menu_actions.push_back (action); + menu.insert_item (m->insert_pos, m->menu_name, *action); + + if (! m->exclusive_group.empty ()) { + action->add_to_exclusive_group (&menu, m->exclusive_group); + } + + if (m->checkable) { + action->set_checkable (true); + } } @@ -178,13 +231,29 @@ PluginDeclaration::init_menu () } - // Fill the mode menu file items from the mouse modes + // Fill the mode menu file items from the mouse modes + + std::vector > > modes; title = std::string (); if (implements_mouse_mode (title)) { + modes.push_back (std::make_pair (title, std::make_pair ("edit_menu.mode_menu.end;@toolbar.end", id ()))); + } + + // the primary mouse modes (special for LayoutView) + implements_primary_mouse_modes (modes); + + for (std::vector >::const_iterator m = modes.begin (); m != modes.end (); ++m) { // extract first part, which is the name, separated by a tab from the title. - std::string name = tl::sprintf ("mode_%d", id ()); + std::string name; + if (m->second.second <= 0) { + name = tl::sprintf ("mode_i%d", 1 - m->second.second); + } else { + name = tl::sprintf ("mode_%d", m->second.second); + } + std::string title = m->first; + const char *tab = strchr (title.c_str (), '\t'); if (tab) { name = std::string (title, 0, tab - title.c_str ()); @@ -193,12 +262,10 @@ PluginDeclaration::init_menu () m_mouse_mode_action = Action (title); m_mouse_mode_action.add_to_exclusive_group (&menu, "mouse_mode_exclusive_group"); - m_mouse_mode_action.set_checkable (true); - m_mouse_mode_action.qaction ()->setData (QVariant (id ())); + m_mouse_mode_action.qaction ()->setData (QVariant (m->second.second)); - menu.insert_item ("edit_menu.mode_menu.end", name, m_mouse_mode_action); - menu.insert_item ("@toolbar.end_modes", name, m_mouse_mode_action); + menu.insert_item (m->second.first, name + ":mode_group", m_mouse_mode_action); gtf::action_connect (m_mouse_mode_action.qaction (), SIGNAL (triggered ()), this, SLOT (mode_triggered ())); @@ -208,15 +275,15 @@ PluginDeclaration::init_menu () void PluginDeclaration::remove_menu_items () { - if (! lay::AbstractMenuProvider::instance () || ! lay::AbstractMenuProvider::instance ()->menu ()) { + if (! lay::Dispatcher::instance () || ! lay::Dispatcher::instance ()->menu ()) { return; } - lay::AbstractMenu *menu = lay::AbstractMenuProvider::instance ()->menu (); + lay::AbstractMenu *menu = lay::Dispatcher::instance ()->menu (); menu->delete_items (m_editable_mode_action); menu->delete_items (m_mouse_mode_action); - for (std::vector ::const_iterator a = m_menu_actions.begin (); a != m_menu_actions.end (); ++a) { - menu->delete_items (*a); + for (std::vector ::const_iterator a = m_menu_actions.begin (); a != m_menu_actions.end (); ++a) { + menu->delete_items (**a); } } @@ -233,9 +300,9 @@ PluginDeclaration::set_editable_enabled (bool f) void PluginDeclaration::register_plugin () { - if (PluginRoot::instance ()) { - PluginRoot::instance ()->plugin_registered (this); - initialize (PluginRoot::instance ()); + if (Dispatcher::instance ()) { + Dispatcher::instance ()->plugin_registered (this); + initialize (Dispatcher::instance ()); } } @@ -365,26 +432,26 @@ Plugin::get_config_names (std::vector &names) const } } -PluginRoot * -Plugin::plugin_root () +Dispatcher * +Plugin::dispatcher () { Plugin *p = this; while (p->mp_parent) { p = p->mp_parent; } - return dynamic_cast (p); + return dynamic_cast (p); } -PluginRoot * -Plugin::plugin_root_maybe_null () +Dispatcher * +Plugin::dispatcher_maybe_null () { Plugin *p = this; while (p->mp_parent) { p = p->mp_parent; } - return dynamic_cast (p); + return dynamic_cast (p); } void @@ -434,190 +501,4 @@ Plugin::do_config_set (const std::string &name, const std::string &value, bool f return false; } -// ---------------------------------------------------------------- -// PluginRoot implementation - -static PluginRoot *ms_root_instance = 0; - -PluginRoot::PluginRoot (bool standalone, bool reg_inst) - : Plugin (0, standalone) -{ - if (reg_inst) { - ms_root_instance = this; - } -} - -PluginRoot::~PluginRoot () -{ - if (ms_root_instance == this) { - ms_root_instance = 0; - } -} - -// Writing and Reading of configuration - -struct ConfigGetAdaptor -{ - ConfigGetAdaptor (const std::string &name) - : mp_owner (0), m_done (false), m_name (name) - { - // .. nothing yet .. - } - - std::string operator () () const - { - std::string s; - mp_owner->config_get (m_name, s); - return s; - } - - bool at_end () const - { - return m_done; - } - - void start (const lay::PluginRoot &owner) - { - mp_owner = &owner; - m_done = false; - } - - void next () - { - m_done = true; - } - -private: - const lay::PluginRoot *mp_owner; - bool m_done; - std::string m_name; -}; - -struct ConfigGetNullAdaptor -{ - ConfigGetNullAdaptor () - { - // .. nothing yet .. - } - - std::string operator () () const - { - return std::string (); - } - - bool at_end () const - { - return true; - } - - void start (const lay::PluginRoot & /*owner*/) { } - void next () { } -}; - -struct ConfigNamedSetAdaptor -{ - ConfigNamedSetAdaptor () - { - // .. nothing yet .. - } - - void operator () (lay::PluginRoot &w, tl::XMLReaderState &reader, const std::string &name) const - { - tl::XMLObjTag tag; - w.config_set (name, *reader.back (tag)); - } -}; - -struct ConfigSetAdaptor -{ - ConfigSetAdaptor (const std::string &name) - : m_name (name) - { - // .. nothing yet .. - } - - void operator () (lay::PluginRoot &w, tl::XMLReaderState &reader) const - { - tl::XMLObjTag tag; - w.config_set (m_name, *reader.back (tag)); - } - -private: - std::string m_name; -}; - -// the configuration file's XML structure is built dynamically -static tl::XMLStruct -config_structure (const lay::PluginRoot *plugin) -{ - tl::XMLElementList body; - std::string n_with_underscores; - - std::vector names; - plugin->get_config_names (names); - - for (std::vector ::const_iterator n = names.begin (); n != names.end (); ++n) { - - body.append (tl::XMLMember > ( - ConfigGetAdaptor (*n), ConfigSetAdaptor (*n), *n)); - - // for compatibility, provide an alternative with underscores (i.e. 0.20->0.21 because of default_grids) - n_with_underscores.clear (); - for (const char *c = n->c_str (); *c; ++c) { - n_with_underscores += (*c == '-' ? '_' : *c); - } - - body.append (tl::XMLMember > ( - ConfigGetNullAdaptor (), ConfigSetAdaptor (*n), n_with_underscores)); - - } - - // add a wildcard member to read all others unspecifically into the repository - body.append (tl::XMLWildcardMember > (ConfigNamedSetAdaptor ())); - - return tl::XMLStruct ("config", body); -} - - -bool -PluginRoot::write_config (const std::string &config_file) -{ - try { - tl::OutputStream os (config_file, tl::OutputStream::OM_Plain); - config_structure (this).write (os, *this); - return true; - } catch (...) { - return false; - } -} - -bool -PluginRoot::read_config (const std::string &config_file) -{ - std::auto_ptr file; - - try { - file.reset (new tl::XMLFileSource (config_file)); - } catch (...) { - return false; - } - - try { - config_structure (this).parse (*file, *this); - } catch (tl::Exception &ex) { - std::string msg = tl::to_string (QObject::tr ("Problem reading config file ")) + config_file + ": " + ex.msg (); - throw tl::Exception (msg); - } - - config_end (); - - return true; -} - -PluginRoot * -PluginRoot::instance () -{ - return ms_root_instance; -} - } diff --git a/src/laybasic/laybasic/layPlugin.h b/src/laybasic/laybasic/layPlugin.h index 4922da7b7..0395433b6 100644 --- a/src/laybasic/laybasic/layPlugin.h +++ b/src/laybasic/laybasic/layPlugin.h @@ -47,7 +47,7 @@ namespace lay { class Plugin; -class PluginRoot; +class Dispatcher; class LayoutView; class Browser; class ViewService; @@ -77,7 +77,7 @@ public: * The implementation is supposed to fetch the configuration from the * Plugin object provided and load the widgets accordingly. */ - virtual void setup (PluginRoot * /*root*/) + virtual void setup (Dispatcher * /*root*/) { // the default implementation does nothing. } @@ -89,7 +89,7 @@ public: * throw exceptions if the configuration something is invalid) * and commit the changes through */ - virtual void commit (PluginRoot * /*root*/) + virtual void commit (Dispatcher * /*root*/) { // the default implementation does nothing. } @@ -98,42 +98,111 @@ public: /** * @brief A menu entry declaration + * See separator, menu_item, submenu and config_menu_item below. */ struct LAYBASIC_PUBLIC MenuEntry { - /** - * @brief A declaration for a separator - * - * @param menu_name The name of the menu item (see layAbstractMenu.h) - * @param insert_pos The position where to insert (see layAbstractMenu.h) - */ - MenuEntry (const std::string &menu_name_, const std::string &insert_pos_) - : menu_name (menu_name_), insert_pos (insert_pos_), sub_menu (false) - { - // .. - } - - /** - * @brief A declaration for a menu entry - * - * @param symbol The symbol to send when this menu item is selected - * @param menu_name The name of the menu item (see layAbstractMenu.h) - * @param insert_pos The position where to insert (see layAbstractMenu.h) - * @param title The title to display plus optional icon resource and keyboard shortcut. The format of the string is: ["("shortcut")"]["<"icon-resource">"][{"tool-tip"}]. - */ - MenuEntry (const std::string &symbol_, const std::string &menu_name_, const std::string &insert_pos_, const std::string &title_, bool sub_menu_ = false) - : menu_name (menu_name_), symbol (symbol_), insert_pos (insert_pos_), title (title_), sub_menu (sub_menu_) - { - // .. - } + MenuEntry () : sub_menu (false), checkable (false) { } std::string menu_name; std::string symbol; std::string insert_pos; std::string title; + std::string cname; + std::string cvalue; + std::string exclusive_group; bool sub_menu; + bool checkable; }; +/** + * @brief Creates a separator menu entry + * + * @param menu_name The name of the menu item (see layAbstractMenu.h) + * @param insert_pos The position where to insert (see layAbstractMenu.h) + */ +MenuEntry separator (const std::string &menu_name, const std::string &insert_pos) +{ + MenuEntry e; + e.menu_name = menu_name; + e.insert_pos = insert_pos; + return e; +} + +/** + * @brief Creates a normal menu entry + * + * @param symbol The symbol to send when this menu item is selected + * @param menu_name The name of the menu item (see layAbstractMenu.h) + * @param insert_pos The position where to insert (see layAbstractMenu.h) + * @param title The title to display plus optional icon resource and keyboard shortcut. The format of the string is: ["("shortcut")"]["<"icon-resource">"][{"tool-tip"}]. + */ +MenuEntry menu_item (const std::string &symbol, const std::string &menu_name, const std::string &insert_pos, const std::string &title) +{ + MenuEntry e; + e.symbol = symbol; + e.menu_name = menu_name; + e.insert_pos = insert_pos; + e.title = title; + return e; +} + +/** + * @brief Creates a submenu entry + * + * @param menu_name The name of the menu item (see layAbstractMenu.h) + * @param insert_pos The position where to insert (see layAbstractMenu.h) + * @param title The title to display plus optional icon resource and keyboard shortcut. The format of the string is: ["("shortcut")"]["<"icon-resource">"][{"tool-tip"}]. + */ +MenuEntry submenu (const std::string &menu_name, const std::string &insert_pos, const std::string &title) +{ + MenuEntry e; + e.menu_name = menu_name; + e.insert_pos = insert_pos; + e.title = title; + e.sub_menu = true; + return e; +} + +/** + * @brief Creates a submenu entry + * + * @param symbol The symbol to send when this menu item is selected + * @param menu_name The name of the menu item (see layAbstractMenu.h) + * @param insert_pos The position where to insert (see layAbstractMenu.h) + * @param title The title to display plus optional icon resource and keyboard shortcut. The format of the string is: ["("shortcut")"]["<"icon-resource">"][{"tool-tip"}]. + */ +MenuEntry submenu (const std::string &symbol, const std::string &menu_name, const std::string &insert_pos, const std::string &title) +{ + MenuEntry e; + e.symbol = symbol; + e.menu_name = menu_name; + e.insert_pos = insert_pos; + e.title = title; + e.sub_menu = true; + return e; +} + +/** + * @brief Creates a configuration entry + * + * @param menu_name The name of the menu item (see layAbstractMenu.h) + * @param insert_pos The position where to insert (see layAbstractMenu.h) + * @param title The title to display plus optional icon resource and keyboard shortcut. The format of the string is: ["("shortcut")"]["<"icon-resource">"][{"tool-tip"}]. + * @param cname The name of the configuration item + * @param cvalue The value to set for the configuration item (optional for boolean configuration items) + */ +MenuEntry config_menu_item (const std::string &menu_name, const std::string &insert_pos, const std::string &title, const std::string &cname, const std::string &cvalue = std::string ()) +{ + MenuEntry e; + e.menu_name = menu_name; + e.insert_pos = insert_pos; + e.title = title; + e.cname = cname; + e.cvalue = cvalue; + return e; +} + /** * @brief The configuration declaration * @@ -238,7 +307,7 @@ public: * Reimplementation of this method offers a chance to initialize static resources such as * dialogs etc. */ - virtual void initialize (lay::PluginRoot * /*root*/) + virtual void initialize (lay::Dispatcher * /*dispatcher*/) { // .. the default implementation does nothing .. } @@ -251,7 +320,7 @@ public: * While initialize is called before any configuration is loaded, "initialized" will be * called after the pugin system has been initially configured. */ - virtual void initialized (lay::PluginRoot * /*root*/) + virtual void initialized (lay::Dispatcher * /*dispatcher*/) { // .. the default implementation does nothing .. } @@ -259,7 +328,7 @@ public: /** * @brief Uninitialize the plugin */ - virtual void uninitialize (lay::PluginRoot * /*root*/) + virtual void uninitialize (lay::Dispatcher * /*dispatcher*/) { // .. the default implementation does nothing .. } @@ -270,7 +339,7 @@ public: * If the plugin wants to prevent the application from closing, it may return false * in this method. */ - virtual bool can_exit (lay::PluginRoot * /*root*/) const + virtual bool can_exit (lay::Dispatcher * /*dispatcher*/) const { return true; } @@ -292,7 +361,7 @@ public: * This method may return 0 for "dummy" plugins that just register menu entries * or configuration options. */ - virtual lay::Plugin *create_plugin (db::Manager * /*manager*/, lay::PluginRoot * /*plugin_root*/, lay::LayoutView * /*view*/) const + virtual lay::Plugin *create_plugin (db::Manager * /*manager*/, lay::Dispatcher * /*dispatcher*/, lay::LayoutView * /*view*/) const { return 0; } @@ -322,6 +391,17 @@ public: { return false; } + + /** + * @brief Specifies the primary mouse modes + * + * These are built-in modes from the LayoutView. This method is intended for + * the LayoutView's standard modes only. + */ + virtual void implements_primary_mouse_modes (std::vector > > & /*modes*/) + { + // .. nothing yet .. + } /** * @brief Returns the technology component provider @@ -354,9 +434,17 @@ public: * @brief Creates the menu resources for this plugin * * This method will create the menu resources for the plugin and perform the - * required connect operations. + * required connect operations. The dispatcher provides the menu and the + * event endpoints. */ - void init_menu (); + void init_menu (lay::Dispatcher *dispatcher); + + /** + * @brief Gets the available menu symbols from all plugins + * + * This does not mean all symbols will be available. + */ + static std::vector menu_symbols (); /** * @brief Removes the menu resources associated with this plugin @@ -397,7 +485,7 @@ public: } /** - * @brief Notifies that plugin root that a new plugin was registered + * @brief Notifies that dispatcher that a new plugin was registered * * This method must be called when a plugin is dynamically created. It is important * that when this method is called, the menu items and other properties are set already. @@ -416,10 +504,12 @@ private slots: private: int m_id; - std::vector m_menu_actions; + std::vector m_menu_actions; lay::Action m_editable_mode_action; lay::Action m_mouse_mode_action; bool m_editable_enabled; + + void clear_menu_items (); }; /** @@ -634,17 +724,17 @@ public: void get_config_names (std::vector &names) const; /** - * @brief Gets the plugin root (the parent plugin not having another parent) + * @brief Gets the dispatcher (the top level end of the plugin chain) * The returned pointer is guaranteed to be non-zero. */ - PluginRoot *plugin_root (); + Dispatcher *dispatcher (); /** - * @brief Gets the plugin root (the parent plugin not having another parent) + * @brief Gets the dispatcher (the top level end of the plugin chain) * This version may return null, if the plugin is instantiated without a * root. */ - PluginRoot *plugin_root_maybe_null (); + Dispatcher *dispatcher_maybe_null (); /** * @brief Menu command handler @@ -790,78 +880,6 @@ private: bool m_standalone; }; -/** - * @brief The plugin root element - * - * The first (root) object must be derived from this class. - * This class offers the full "plugin" functionality like - * configuration interface etc. but cannot have a parent. - */ - -class LAYBASIC_PUBLIC PluginRoot - : public Plugin -{ -public: - /** - * @brief The constructor - */ - PluginRoot (bool standalone = false, bool reg_inst = true); - - /** - * @brief Destructor - */ - ~PluginRoot (); - - /** - * @brief Write configuration to a file - * - * If the configuration file cannot be written, false - * is returned but no exception is thrown. - * - * @return false, if an error occurred. - */ - bool write_config (const std::string &config_file); - - /** - * @brief Read the configuration from a file - * - * This method siletly does nothing, if the config file does not - * exist. If it does and an error occurred, the error message is printed - * on stderr. In both cases, false is returned. - * - * @return false, if an error occurred. - */ - bool read_config (const std::string &config_file); - - /** - * @brief The singleton instance of the plugin root - */ - static PluginRoot *instance (); - - /** - * @brief Notifies the plugin root that a new plugin class has been registered - * - * This method is called when a plugin is loaded dynamically during runtime. - */ - virtual void plugin_registered (lay::PluginDeclaration * /*cls*/) { } - - /** - * @brief Notifies the plugin root that a plugin class is about to be removed - */ - virtual void plugin_removed (lay::PluginDeclaration * /*cls*/) { } - - /** - * @brief Selects the given mode - * - * The implementation is supposed to select the given mode on all related plugins. - */ - virtual void select_mode (int /*mode*/) { } - -private: - PluginRoot (const PluginRoot &); - PluginRoot &operator= (const PluginRoot &); -}; - /** * @brief A handy function for implementing the configure method * @@ -885,11 +903,6 @@ inline bool test_and_set (T &target, const T &source) namespace tl { - // disable copy ctor for PluginRoot - template <> struct type_traits : public type_traits { - typedef tl::false_tag has_copy_constructor; - }; - // disable copy ctor for Plugin template <> struct type_traits : public type_traits { typedef tl::false_tag has_copy_constructor; diff --git a/src/laybasic/laybasic/laySaveLayoutOptionsDialog.h b/src/laybasic/laybasic/laySaveLayoutOptionsDialog.h index 584ba94e9..c14b587b7 100644 --- a/src/laybasic/laybasic/laySaveLayoutOptionsDialog.h +++ b/src/laybasic/laybasic/laySaveLayoutOptionsDialog.h @@ -80,7 +80,7 @@ public: SaveLayoutOptionsDialog (QWidget *parent, const std::string &title); ~SaveLayoutOptionsDialog (); - bool edit_global_options (lay::PluginRoot *config_root, db::Technologies *technologies); + bool edit_global_options (lay::Dispatcher *dispatcher, db::Technologies *technologies); bool get_options (db::SaveLayoutOptions &options); public slots: diff --git a/src/lay/lay/laySelectCellViewForm.cc b/src/laybasic/laybasic/laySelectCellViewForm.cc similarity index 100% rename from src/lay/lay/laySelectCellViewForm.cc rename to src/laybasic/laybasic/laySelectCellViewForm.cc diff --git a/src/lay/lay/laySelectCellViewForm.h b/src/laybasic/laybasic/laySelectCellViewForm.h similarity index 100% rename from src/lay/lay/laySelectCellViewForm.h rename to src/laybasic/laybasic/laySelectCellViewForm.h diff --git a/src/laybasic/laybasic/laybasic.pro b/src/laybasic/laybasic/laybasic.pro index 92422593e..320831041 100644 --- a/src/laybasic/laybasic/laybasic.pro +++ b/src/laybasic/laybasic/laybasic.pro @@ -71,7 +71,9 @@ FORMS = \ NetlistBrowserConfigPage2.ui \ NetlistBrowserDialog.ui \ NetInfoDialog.ui \ - NetExportDialog.ui + NetExportDialog.ui \ + SelectCellViewForm.ui \ + LayoutStatistics.ui RESOURCES = \ laybasicResources.qrc @@ -86,7 +88,6 @@ SOURCES = \ gsiDeclLayPlugin.cc \ gsiDeclLayStream.cc \ layAbstractMenu.cc \ - layAbstractMenuProvider.cc \ layAnnotationShapes.cc \ layBitmap.cc \ layBitmapRenderer.cc \ @@ -178,12 +179,14 @@ SOURCES = \ layNetlistBrowserTreeModel.cc \ layLibrariesView.cc \ layBookmarksView.cc \ - layGenericSyntaxHighlighter.cc + layGenericSyntaxHighlighter.cc \ + layDispatcher.cc \ + laySelectCellViewForm.cc \ + layLayoutStatisticsForm.cc HEADERS = \ gtf.h \ layAbstractMenu.h \ - layAbstractMenuProvider.h \ layAnnotationShapes.h \ layBitmap.h \ layBitmapRenderer.h \ @@ -277,7 +280,10 @@ HEADERS = \ layNetlistBrowserTreeModel.h \ layLibrariesView.h \ layBookmarksView.h \ - layGenericSyntaxHighlighter.h + layGenericSyntaxHighlighter.h \ + layDispatcher.h \ + laySelectCellViewForm.h \ + layLayoutStatisticsForm.h INCLUDEPATH += $$TL_INC $$GSI_INC $$DB_INC $$RDB_INC $$LYM_INC DEPENDPATH += $$TL_INC $$GSI_INC $$DB_INC $$RDB_INC $$LYM_INC diff --git a/src/laybasic/laybasic/rdbMarkerBrowser.h b/src/laybasic/laybasic/rdbMarkerBrowser.h index 908859b4d..f4ced337c 100644 --- a/src/laybasic/laybasic/rdbMarkerBrowser.h +++ b/src/laybasic/laybasic/rdbMarkerBrowser.h @@ -47,8 +47,8 @@ class MarkerBrowserConfigPage public: MarkerBrowserConfigPage (QWidget *parent); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); public slots: void window_changed (int); @@ -63,8 +63,8 @@ class MarkerBrowserConfigPage2 public: MarkerBrowserConfigPage2 (QWidget *parent); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); }; class MarkerBrowserContextModeConverter From 674d4b45ad81635ae697ea821887ecc18f6496ec Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Fri, 7 Feb 2020 01:00:46 +0100 Subject: [PATCH 10/32] WIP: refactoring ongoing. --- src/lay/lay/gsiDeclLayMainWindow.cc | 8 +-- src/laybasic/laybasic/gsiDeclLayLayoutView.cc | 6 +- src/laybasic/laybasic/layBookmarksView.cc | 7 +- .../laybasic/layBrowseInstancesForm.cc | 10 +-- .../laybasic/layBrowseInstancesForm.h | 6 +- src/laybasic/laybasic/layBrowseShapesForm.cc | 12 ++-- src/laybasic/laybasic/layBrowseShapesForm.h | 6 +- src/laybasic/laybasic/layBrowser.cc | 4 +- src/laybasic/laybasic/layBrowser.h | 10 +-- src/laybasic/laybasic/layCellSelectionForm.cc | 12 ++-- .../laybasic/layConfigurationDialog.cc | 5 +- .../laybasic/layConfigurationDialog.h | 8 +-- src/laybasic/laybasic/layGridNet.cc | 4 +- .../laybasic/layHierarchyControlPanel.cc | 31 ++++----- src/laybasic/laybasic/layLayerControlPanel.cc | 69 +++++++++---------- .../laybasic/layLayoutViewConfigPages.cc | 57 +++++++-------- src/laybasic/laybasic/layLibrariesView.cc | 1 - .../laybasic/layLoadLayoutOptionsDialog.cc | 2 +- src/laybasic/laybasic/layNetExportDialog.cc | 3 +- src/laybasic/laybasic/layNetExportDialog.h | 4 +- src/laybasic/laybasic/layNetlistBrowser.cc | 14 ++-- .../laybasic/layNetlistBrowserDialog.cc | 10 +-- .../laybasic/layNetlistBrowserDialog.h | 2 +- .../laybasic/layNetlistBrowserPage.cc | 2 +- src/laybasic/laybasic/layNetlistBrowserPage.h | 6 +- src/laybasic/laybasic/layPlugin.cc | 55 ++++++++++++++- src/laybasic/laybasic/layPlugin.h | 50 ++------------ .../laybasic/laySaveLayoutOptionsDialog.cc | 2 +- src/laybasic/laybasic/layTipDialog.cc | 13 ++-- src/laybasic/laybasic/layWidgets.cc | 4 +- src/laybasic/laybasic/rdbMarkerBrowser.cc | 19 ++--- .../laybasic/rdbMarkerBrowserDialog.cc | 10 +-- .../laybasic/rdbMarkerBrowserDialog.h | 2 +- src/laybasic/laybasic/rdbMarkerBrowserPage.cc | 2 +- src/laybasic/laybasic/rdbMarkerBrowserPage.h | 6 +- 35 files changed, 238 insertions(+), 224 deletions(-) diff --git a/src/lay/lay/gsiDeclLayMainWindow.cc b/src/lay/lay/gsiDeclLayMainWindow.cc index 149594c69..f783c07d2 100644 --- a/src/lay/lay/gsiDeclLayMainWindow.cc +++ b/src/lay/lay/gsiDeclLayMainWindow.cc @@ -519,14 +519,14 @@ Class decl_MainWindow (QT_EXTERNAL_BASE (QMainWindow) "lay", "M ) + gsi::method ("call_menu", &lay::MainWindow::menu_activated, "@brief Calls the menu item with the provided symbol.\n" - "To obtain all symbols, use get_menu_symbols.\n" + "To obtain all symbols, use menu_symbols.\n" "\n" "This method has been introduced in version 0.27 and replaces the previous cm_... methods. " "Instead of calling a specific cm_... method, use LayoutView#call_menu with 'cm_...' as the symbol." ) + - gsi::method ("get_menu_symbols", &lay::MainWindow::menu_symbols, - "@brief Calls the menu item with the provided symbol.\n" - "To obtain all available symbols, use get_menu_symbols.\n" + gsi::method ("menu_symbols", &lay::MainWindow::menu_symbols, + "@brief Gets all available menu symbols (see \\call_menu).\n" + "NOTE: currently this method delivers a superset of all available symbols. Depending on the context, no all symbols may trigger actual functionality.\n" "\n" "This method has been introduced in version 0.27." ) + diff --git a/src/laybasic/laybasic/gsiDeclLayLayoutView.cc b/src/laybasic/laybasic/gsiDeclLayLayoutView.cc index b409a7740..b69efa3ae 100644 --- a/src/laybasic/laybasic/gsiDeclLayLayoutView.cc +++ b/src/laybasic/laybasic/gsiDeclLayLayoutView.cc @@ -539,9 +539,9 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This method has been introduced in version 0.27." ) + - gsi::method ("get_menu_symbols", &lay::LayoutView::get_menu_symbols, - "@brief Calls the menu item with the provided symbol.\n" - "To obtain all available symbols, use get_menu_symbols.\n" + gsi::method ("menu_symbols", &lay::LayoutView::menu_symbols, + "@brief Gets all available menu symbols (see \\call_menu).\n" + "NOTE: currently this method delivers a superset of all available symbols. Depending on the context, no all symbols may trigger actual functionality.\n" "\n" "This method has been introduced in version 0.27." ) + diff --git a/src/laybasic/laybasic/layBookmarksView.cc b/src/laybasic/laybasic/layBookmarksView.cc index 2898a702f..e5ce83d2a 100644 --- a/src/laybasic/laybasic/layBookmarksView.cc +++ b/src/laybasic/laybasic/layBookmarksView.cc @@ -24,7 +24,6 @@ #include "layBookmarksView.h" #include "layLayoutView.h" #include "layAbstractMenu.h" -#include "layAbstractMenuProvider.h" #include "laybasicConfig.h" @@ -206,9 +205,9 @@ public: at = "@bookmarks_context_menu.end"; menu_entries.push_back (lay::config_menu_item ("follow_selection", at, tl::to_string (QObject::tr ("Follow Selection")), cfg_bookmarks_follow_selection, "?")), menu_entries.push_back (lay::separator ("ops_group", at)); - menu_entries.push_back (lay::menu_item ("cm_manage_bookmarks", "manage_bookmarks", at, tl::to_string (QObject::tr ("Manage Bookmarks"))); - menu_entries.push_back (lay::menu_item ("cm_load_bookmarks", "load_bookmarks", at, tl::to_string (QObject::tr ("Load Bookmarks"))); - menu_entries.push_back (lay::menu_item ("cm_save_bookmarks", "save_bookmarks", at, tl::to_string (QObject::tr ("Save Bookmarks"))); + menu_entries.push_back (lay::menu_item ("cm_manage_bookmarks", "manage_bookmarks", at, tl::to_string (QObject::tr ("Manage Bookmarks")))); + menu_entries.push_back (lay::menu_item ("cm_load_bookmarks", "load_bookmarks", at, tl::to_string (QObject::tr ("Load Bookmarks")))); + menu_entries.push_back (lay::menu_item ("cm_save_bookmarks", "save_bookmarks", at, tl::to_string (QObject::tr ("Save Bookmarks")))); } }; diff --git a/src/laybasic/laybasic/layBrowseInstancesForm.cc b/src/laybasic/laybasic/layBrowseInstancesForm.cc index 90c5d82f9..a4149cf95 100644 --- a/src/laybasic/laybasic/layBrowseInstancesForm.cc +++ b/src/laybasic/laybasic/layBrowseInstancesForm.cc @@ -76,10 +76,10 @@ public: virtual void get_menu_entries (std::vector &menu_entries) const { lay::PluginDeclaration::get_menu_entries (menu_entries); - menu_entries.push_back (lay::MenuEntry ("browse_instances::show", "browse_instances", "tools_menu.end", tl::to_string (QObject::tr ("Browse Instances")))); + menu_entries.push_back (lay::menu_item ("browse_instances::show", "browse_instances", "tools_menu.end", tl::to_string (QObject::tr ("Browse Instances")))); } - virtual lay::Plugin *create_plugin (db::Manager *, lay::PluginRoot *root, lay::LayoutView *view) const + virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutView *view) const { return new BrowseInstancesForm (root, view); } @@ -175,7 +175,7 @@ BrowseInstancesConfigPage::BrowseInstancesConfigPage (QWidget *parent) } void -BrowseInstancesConfigPage::setup (lay::PluginRoot *root) +BrowseInstancesConfigPage::setup (lay::Dispatcher *root) { std::string value; @@ -221,7 +221,7 @@ BrowseInstancesConfigPage::window_changed (int m) } void -BrowseInstancesConfigPage::commit (lay::PluginRoot *root) +BrowseInstancesConfigPage::commit (lay::Dispatcher *root) { double dim = 1.0; tl::from_string (tl::to_string (le_window->text ()), dim); @@ -289,7 +289,7 @@ private: // ------------------------------------------------------------ -BrowseInstancesForm::BrowseInstancesForm (lay::PluginRoot *root, lay::LayoutView *vw) +BrowseInstancesForm::BrowseInstancesForm (lay::Dispatcher *root, lay::LayoutView *vw) : lay::Browser (root, vw), Ui::BrowseInstancesForm (), m_cv_index (0), diff --git a/src/laybasic/laybasic/layBrowseInstancesForm.h b/src/laybasic/laybasic/layBrowseInstancesForm.h index 5a2882bde..8c6ede9fd 100644 --- a/src/laybasic/laybasic/layBrowseInstancesForm.h +++ b/src/laybasic/laybasic/layBrowseInstancesForm.h @@ -46,8 +46,8 @@ class BrowseInstancesConfigPage public: BrowseInstancesConfigPage (QWidget *parent); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); public slots: void context_changed (int); @@ -64,7 +64,7 @@ public: enum mode_type { ToCellView = 0, AnyTop, Parent }; enum window_type { DontChange = 0, FitCell, FitMarker, Center, CenterSize }; - BrowseInstancesForm (lay::PluginRoot *root, lay::LayoutView *view); + BrowseInstancesForm (lay::Dispatcher *root, lay::LayoutView *view); ~BrowseInstancesForm (); bool eventFilter (QObject *watched, QEvent *event); diff --git a/src/laybasic/laybasic/layBrowseShapesForm.cc b/src/laybasic/laybasic/layBrowseShapesForm.cc index ef300456b..24c26737c 100644 --- a/src/laybasic/laybasic/layBrowseShapesForm.cc +++ b/src/laybasic/laybasic/layBrowseShapesForm.cc @@ -76,11 +76,11 @@ public: virtual void get_menu_entries (std::vector &menu_entries) const { lay::PluginDeclaration::get_menu_entries (menu_entries); - menu_entries.push_back (lay::MenuEntry ("browser_group", "tools_menu.end")); - menu_entries.push_back (lay::MenuEntry ("browse_shapes::show", "browse_shapes", "tools_menu.end", tl::to_string (QObject::tr ("Browse Shapes")))); + menu_entries.push_back (lay::separator ("browser_group", "tools_menu.end")); + menu_entries.push_back (lay::menu_item ("browse_shapes::show", "browse_shapes", "tools_menu.end", tl::to_string (QObject::tr ("Browse Shapes")))); } - virtual lay::Plugin *create_plugin (db::Manager *, lay::PluginRoot *root, lay::LayoutView *view) const + virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutView *view) const { return new BrowseShapesForm (root, view); } @@ -177,7 +177,7 @@ BrowseShapesConfigPage::BrowseShapesConfigPage (QWidget *parent) } void -BrowseShapesConfigPage::setup (lay::PluginRoot *root) +BrowseShapesConfigPage::setup (lay::Dispatcher *root) { std::string value; @@ -228,7 +228,7 @@ BrowseShapesConfigPage::window_changed (int m) } void -BrowseShapesConfigPage::commit (lay::PluginRoot *root) +BrowseShapesConfigPage::commit (lay::Dispatcher *root) { double dim = 1.0; tl::from_string (tl::to_string (le_window->text ()), dim); @@ -388,7 +388,7 @@ private: // ------------------------------------------------------------ -BrowseShapesForm::BrowseShapesForm (lay::PluginRoot *root, lay::LayoutView *vw) +BrowseShapesForm::BrowseShapesForm (lay::Dispatcher *root, lay::LayoutView *vw) : lay::Browser (root, vw), Ui::BrowseShapesForm (), m_cv_index (-1), diff --git a/src/laybasic/laybasic/layBrowseShapesForm.h b/src/laybasic/laybasic/layBrowseShapesForm.h index bd2693a27..59ffd6250 100644 --- a/src/laybasic/laybasic/layBrowseShapesForm.h +++ b/src/laybasic/laybasic/layBrowseShapesForm.h @@ -45,8 +45,8 @@ class BrowseShapesConfigPage public: BrowseShapesConfigPage (QWidget *parent); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); public slots: void context_changed (int); @@ -63,7 +63,7 @@ public: enum mode_type { ToCellView = 0, AnyTop, Local }; enum window_type { DontChange = 0, FitCell, FitMarker, Center, CenterSize }; - BrowseShapesForm (lay::PluginRoot *root, lay::LayoutView *view); + BrowseShapesForm (lay::Dispatcher *root, lay::LayoutView *view); ~BrowseShapesForm (); bool eventFilter (QObject *watched, QEvent *event); diff --git a/src/laybasic/laybasic/layBrowser.cc b/src/laybasic/laybasic/layBrowser.cc index 104ebcc17..5ca83e0a6 100644 --- a/src/laybasic/laybasic/layBrowser.cc +++ b/src/laybasic/laybasic/layBrowser.cc @@ -32,9 +32,9 @@ namespace lay { #if QT_VERSION >= 0x050000 -Browser::Browser (lay::PluginRoot *root, lay::LayoutView *view, const char *name, Qt::WindowFlags fl) +Browser::Browser (lay::Dispatcher *root, lay::LayoutView *view, const char *name, Qt::WindowFlags fl) #else -Browser::Browser (lay::PluginRoot *root, lay::LayoutView *view, const char *name, Qt::WFlags fl) +Browser::Browser (lay::Dispatcher *root, lay::LayoutView *view, const char *name, Qt::WFlags fl) #endif // TODO: clarify whether to keep the browsers as separate (potentially hidden) windows : QDialog (0 /*view*/, fl), diff --git a/src/laybasic/laybasic/layBrowser.h b/src/laybasic/laybasic/layBrowser.h index 773df5ed0..41f833399 100644 --- a/src/laybasic/laybasic/layBrowser.h +++ b/src/laybasic/laybasic/layBrowser.h @@ -36,7 +36,7 @@ namespace lay { class LayoutView; -class PluginRoot; +class Dispatcher; class LAYBASIC_PUBLIC Browser : public QDialog, @@ -47,9 +47,9 @@ public: * @brief Constructor */ #if QT_VERSION >= 0x050000 - Browser (lay::PluginRoot *root, lay::LayoutView *view, const char *name = "", Qt::WindowFlags fl = Qt::Window /*adds minimize button for example*/); + Browser (lay::Dispatcher *root, lay::LayoutView *view, const char *name = "", Qt::WindowFlags fl = Qt::Window /*adds minimize button for example*/); #else - Browser (lay::PluginRoot *root, lay::LayoutView *view, const char *name = "", Qt::WFlags fl = Qt::Window /*adds minimize button for example*/); + Browser (lay::Dispatcher *root, lay::LayoutView *view, const char *name = "", Qt::WFlags fl = Qt::Window /*adds minimize button for example*/); #endif /** @@ -101,7 +101,7 @@ public: /** * @brief Returns the pointer to the root configuration object */ - lay::PluginRoot *root () + lay::Dispatcher *root () { return mp_root; } @@ -133,7 +133,7 @@ public: private: bool m_active; lay::LayoutView *mp_view; - lay::PluginRoot *mp_root; + lay::Dispatcher *mp_root; void closeEvent (QCloseEvent *); void accept (); diff --git a/src/laybasic/laybasic/layCellSelectionForm.cc b/src/laybasic/laybasic/layCellSelectionForm.cc index 12be9d351..d9d226425 100644 --- a/src/laybasic/laybasic/layCellSelectionForm.cc +++ b/src/laybasic/laybasic/layCellSelectionForm.cc @@ -76,12 +76,12 @@ CellSelectionForm::CellSelectionForm (QWidget *parent, lay::LayoutView *view, co mp_case_sensitive->setChecked (true); mp_case_sensitive->setText (tr ("Case sensitive search")); - if (lay::PluginRoot::instance ()) { + if (lay::Dispatcher::instance ()) { bool cs = true; - lay::PluginRoot::instance ()->config_get (cfg_cell_selection_search_case_sensitive, cs); + lay::Dispatcher::instance ()->config_get (cfg_cell_selection_search_case_sensitive, cs); mp_case_sensitive->setChecked (cs); bool ue = true; - lay::PluginRoot::instance ()->config_get (cfg_cell_selection_search_use_expressions, ue); + lay::Dispatcher::instance ()->config_get (cfg_cell_selection_search_use_expressions, ue); mp_use_regular_expressions->setChecked (ue); } @@ -285,9 +285,9 @@ CellSelectionForm::reject () void CellSelectionForm::store_config () { - if (lay::PluginRoot::instance ()) { - lay::PluginRoot::instance ()->config_set (cfg_cell_selection_search_case_sensitive, mp_case_sensitive->isChecked ()); - lay::PluginRoot::instance ()->config_set (cfg_cell_selection_search_use_expressions, mp_use_regular_expressions->isChecked ()); + if (lay::Dispatcher::instance ()) { + lay::Dispatcher::instance ()->config_set (cfg_cell_selection_search_case_sensitive, mp_case_sensitive->isChecked ()); + lay::Dispatcher::instance ()->config_set (cfg_cell_selection_search_use_expressions, mp_use_regular_expressions->isChecked ()); } } diff --git a/src/laybasic/laybasic/layConfigurationDialog.cc b/src/laybasic/laybasic/layConfigurationDialog.cc index 1149bb76b..7aa64a1dc 100644 --- a/src/laybasic/laybasic/layConfigurationDialog.cc +++ b/src/laybasic/laybasic/layConfigurationDialog.cc @@ -28,6 +28,7 @@ #include "ui_ConfigurationDialog.h" #include "layConfigurationDialog.h" #include "layPlugin.h" +#include "layDispatcher.h" #include "tlLog.h" @@ -36,7 +37,7 @@ namespace lay // ------------------------------------------------------------- -ConfigurationDialog::ConfigurationDialog (QWidget *parent, lay::PluginRoot *root, const std::string &plugin_name, const char *name) +ConfigurationDialog::ConfigurationDialog (QWidget *parent, lay::Dispatcher *root, const std::string &plugin_name, const char *name) : QDialog (parent), mp_root (root) { @@ -56,7 +57,7 @@ ConfigurationDialog::ConfigurationDialog (QWidget *parent, lay::PluginRoot *root } } -ConfigurationDialog::ConfigurationDialog (QWidget *parent, lay::PluginRoot *root, lay::PluginDeclaration *decl, const char *name) +ConfigurationDialog::ConfigurationDialog (QWidget *parent, lay::Dispatcher *root, lay::PluginDeclaration *decl, const char *name) : QDialog (parent), mp_root (root) { diff --git a/src/laybasic/laybasic/layConfigurationDialog.h b/src/laybasic/laybasic/layConfigurationDialog.h index 8b40dd681..e949a522e 100644 --- a/src/laybasic/laybasic/layConfigurationDialog.h +++ b/src/laybasic/laybasic/layConfigurationDialog.h @@ -38,7 +38,7 @@ namespace Ui namespace lay { -class PluginRoot; +class Dispatcher; class ConfigPage; class PluginDeclaration; @@ -48,8 +48,8 @@ class LAYBASIC_PUBLIC ConfigurationDialog Q_OBJECT public: - ConfigurationDialog (QWidget *parent, lay::PluginRoot *root, lay::PluginDeclaration *decl, const char *name = ""); - ConfigurationDialog (QWidget *parent, lay::PluginRoot *root, const std::string &plugin_name, const char *name = ""); + ConfigurationDialog (QWidget *parent, lay::Dispatcher *root, lay::PluginDeclaration *decl, const char *name = ""); + ConfigurationDialog (QWidget *parent, lay::Dispatcher *root, const std::string &plugin_name, const char *name = ""); ~ConfigurationDialog (); void commit (); @@ -58,7 +58,7 @@ public slots: virtual void ok_clicked (); private: - lay::PluginRoot *mp_root; + lay::Dispatcher *mp_root; std::vector m_config_pages; Ui::ConfigurationDialog *mp_ui; diff --git a/src/laybasic/laybasic/layGridNet.cc b/src/laybasic/laybasic/layGridNet.cc index 9c90f2144..759089dd1 100644 --- a/src/laybasic/laybasic/layGridNet.cc +++ b/src/laybasic/laybasic/layGridNet.cc @@ -134,7 +134,7 @@ GridNetConfigPage::~GridNetConfigPage () } void -GridNetConfigPage::setup (lay::PluginRoot *root) +GridNetConfigPage::setup (lay::Dispatcher *root) { std::string value; @@ -176,7 +176,7 @@ GridNetConfigPage::setup (lay::PluginRoot *root) } void -GridNetConfigPage::commit (lay::PluginRoot *root) +GridNetConfigPage::commit (lay::Dispatcher *root) { root->config_set (cfg_grid_visible, mp_ui->grid_group->isChecked ()); root->config_set (cfg_grid_show_ruler, mp_ui->show_ruler->isChecked ()); diff --git a/src/laybasic/laybasic/layHierarchyControlPanel.cc b/src/laybasic/laybasic/layHierarchyControlPanel.cc index ba95960a0..39e324865 100644 --- a/src/laybasic/laybasic/layHierarchyControlPanel.cc +++ b/src/laybasic/laybasic/layHierarchyControlPanel.cc @@ -46,7 +46,6 @@ #include "layCellTreeModel.h" #include "layLayoutView.h" #include "layAbstractMenu.h" -#include "layAbstractMenuProvider.h" #include "layDialogs.h" #include "tlExceptions.h" #include "laybasicConfig.h" @@ -1186,26 +1185,26 @@ public: } menu_entries.push_back (lay::separator ("operations_group", at)); - menu_entries.push_back (lay::menu_item ("cm_new_cell", "new_cell:edit:edit_mode", at, tl::to_string (QObject::tr ("New Cell"))); - menu_entries.push_back (lay::menu_item ("cm_cell_delete", "delete_cell:edit:edit_mode", at, tl::to_string (QObject::tr ("Delete Cell"))); - menu_entries.push_back (lay::menu_item ("cm_cell_rename", "rename_cell:edit:edit_mode", at, tl::to_string (QObject::tr ("Rename Cell"))); - menu_entries.push_back (lay::menu_item ("cm_cell_replace", "replace_cell:edit:edit_mode", at, tl::to_string (QObject::tr ("Replace Cell"))); - menu_entries.push_back (lay::menu_item ("cm_cell_flatten", "flatten_cell:edit:edit_mode", at, tl::to_string (QObject::tr ("Flatten Cell"))); - menu_entries.push_back (lay::menu_item ("cm_cell_user_properties", "cell_user_properties", at, tl::to_string (QObject::tr ("User Properties"))); + menu_entries.push_back (lay::menu_item ("cm_new_cell", "new_cell:edit:edit_mode", at, tl::to_string (QObject::tr ("New Cell")))); + menu_entries.push_back (lay::menu_item ("cm_cell_delete", "delete_cell:edit:edit_mode", at, tl::to_string (QObject::tr ("Delete Cell")))); + menu_entries.push_back (lay::menu_item ("cm_cell_rename", "rename_cell:edit:edit_mode", at, tl::to_string (QObject::tr ("Rename Cell")))); + menu_entries.push_back (lay::menu_item ("cm_cell_replace", "replace_cell:edit:edit_mode", at, tl::to_string (QObject::tr ("Replace Cell")))); + menu_entries.push_back (lay::menu_item ("cm_cell_flatten", "flatten_cell:edit:edit_mode", at, tl::to_string (QObject::tr ("Flatten Cell")))); + menu_entries.push_back (lay::menu_item ("cm_cell_user_properties", "cell_user_properties", at, tl::to_string (QObject::tr ("User Properties")))); menu_entries.push_back (lay::separator ("clipboard_group:edit_mode", at)); - menu_entries.push_back (lay::menu_item ("cm_cell_copy", "copy:edit_mode", at, tl::to_string (QObject::tr ("Copy"))); - menu_entries.push_back (lay::menu_item ("cm_cell_cut", "cut:edit_mode", at, tl::to_string (QObject::tr ("Cut"))); - menu_entries.push_back (lay::menu_item ("cm_cell_paste", "paste:edit_mode", at, tl::to_string (QObject::tr ("Paste"))); + menu_entries.push_back (lay::menu_item ("cm_cell_copy", "copy:edit_mode", at, tl::to_string (QObject::tr ("Copy")))); + menu_entries.push_back (lay::menu_item ("cm_cell_cut", "cut:edit_mode", at, tl::to_string (QObject::tr ("Cut")))); + menu_entries.push_back (lay::menu_item ("cm_cell_paste", "paste:edit_mode", at, tl::to_string (QObject::tr ("Paste")))); menu_entries.push_back (lay::separator ("select_group", at)); - menu_entries.push_back (lay::menu_item ("cm_cell_select", "show_as_top", at, tl::to_string (QObject::tr ("Show As New Top"))); + menu_entries.push_back (lay::menu_item ("cm_cell_select", "show_as_top", at, tl::to_string (QObject::tr ("Show As New Top")))); menu_entries.push_back (lay::separator ("visibility_group", at)); - menu_entries.push_back (lay::menu_item ("cm_cell_hide", "hide_cell", at, tl::to_string (QObject::tr ("Hide"))); - menu_entries.push_back (lay::menu_item ("cm_cell_show", "show_cell", at, tl::to_string (QObject::tr ("Show"))); - menu_entries.push_back (lay::menu_item ("cm_cell_show_all", "show_all", at, tl::to_string (QObject::tr ("Show All"))); + menu_entries.push_back (lay::menu_item ("cm_cell_hide", "hide_cell", at, tl::to_string (QObject::tr ("Hide")))); + menu_entries.push_back (lay::menu_item ("cm_cell_show", "show_cell", at, tl::to_string (QObject::tr ("Show")))); + menu_entries.push_back (lay::menu_item ("cm_cell_show_all", "show_all", at, tl::to_string (QObject::tr ("Show All")))); menu_entries.push_back (lay::separator ("utils_group", at)); - menu_entries.push_back (lay::menu_item ("cm_open_current_cell", "open_current", at, tl::to_string (QObject::tr ("Where Am I?"))); + menu_entries.push_back (lay::menu_item ("cm_open_current_cell", "open_current", at, tl::to_string (QObject::tr ("Where Am I?")))); menu_entries.push_back (lay::separator ("file_group", at)); - menu_entries.push_back (lay::menu_item ("cm_save_current_cell_as", "save_cell_as:hide_vo", at, tl::to_string (QObject::tr ("Save Selected Cells As"))); + menu_entries.push_back (lay::menu_item ("cm_save_current_cell_as", "save_cell_as:hide_vo", at, tl::to_string (QObject::tr ("Save Selected Cells As")))); } }; diff --git a/src/laybasic/laybasic/layLayerControlPanel.cc b/src/laybasic/laybasic/layLayerControlPanel.cc index 1bd353eab..972ec2b19 100644 --- a/src/laybasic/laybasic/layLayerControlPanel.cc +++ b/src/laybasic/laybasic/layLayerControlPanel.cc @@ -33,7 +33,6 @@ #include "laybasicConfig.h" #include "layDialogs.h" #include "layLayoutCanvas.h" -#include "layAbstractMenuProvider.h" #include "layAbstractMenu.h" #include "tlExceptions.h" #include "tlInternational.h" @@ -2335,7 +2334,7 @@ public: at = "@lcp_context_menu.end"; - menu_entries.push_back (lay::menu_item ("cm_lv_select_all", "select_all", at, tl::to_string (QObject::tr ("Select All"))); + menu_entries.push_back (lay::menu_item ("cm_lv_select_all", "select_all", at, tl::to_string (QObject::tr ("Select All")))); // It is not sure, whether "expandAll" destabilizes the tree widget: // menu_entries.push_back (lay::menu_item ("cm_lv_expand_all", "expand_all", at, tl::to_string (QObject::tr ("Expand All"))); menu_entries.push_back (lay::separator ("tab_group", at)); @@ -2343,68 +2342,68 @@ public: { std::string at = "@lcp_context_menu.tab_menu.end"; - menu_entries.push_back (lay::menu_item ("cm_lv_new_tab", "new_tab", at, tl::to_string (QObject::tr ("New Tab"))); - menu_entries.push_back (lay::menu_item ("cm_lv_remove_tab", "remove_tab", at, tl::to_string (QObject::tr ("Remove Tab"))); - menu_entries.push_back (lay::menu_item ("cm_lv_rename_tab", "rename_tab", at, tl::to_string (QObject::tr ("Rename Tab"))); + menu_entries.push_back (lay::menu_item ("cm_lv_new_tab", "new_tab", at, tl::to_string (QObject::tr ("New Tab")))); + menu_entries.push_back (lay::menu_item ("cm_lv_remove_tab", "remove_tab", at, tl::to_string (QObject::tr ("Remove Tab")))); + menu_entries.push_back (lay::menu_item ("cm_lv_rename_tab", "rename_tab", at, tl::to_string (QObject::tr ("Rename Tab")))); } menu_entries.push_back (lay::separator ("visibility_group", at)); - menu_entries.push_back (lay::menu_item ("cm_lv_hide", "hide", at, tl::to_string (QObject::tr ("Hide"))); - menu_entries.push_back (lay::menu_item ("cm_lv_hide_all", "hide_all", at, tl::to_string (QObject::tr ("Hide All"))); - menu_entries.push_back (lay::menu_item ("cm_lv_show", "show", at, tl::to_string (QObject::tr ("Show"))); - menu_entries.push_back (lay::menu_item ("cm_lv_show_all", "show_all", at, tl::to_string (QObject::tr ("Show All"))); - menu_entries.push_back (lay::menu_item ("cm_lv_show_only", "show_only", at, tl::to_string (QObject::tr ("Show Only Selected"))); - menu_entries.push_back (lay::menu_item ("cm_lv_make_valid", "valid", at, tl::to_string (QObject::tr ("Make Valid"))); - menu_entries.push_back (lay::menu_item ("cm_lv_make_invalid", "invvalid", at, tl::to_string (QObject::tr ("Make Invalid"))); - menu_entries.push_back (lay::menu_item ("cm_lv_rename", "rename", at, tl::to_string (QObject::tr ("Rename"))); + menu_entries.push_back (lay::menu_item ("cm_lv_hide", "hide", at, tl::to_string (QObject::tr ("Hide")))); + menu_entries.push_back (lay::menu_item ("cm_lv_hide_all", "hide_all", at, tl::to_string (QObject::tr ("Hide All")))); + menu_entries.push_back (lay::menu_item ("cm_lv_show", "show", at, tl::to_string (QObject::tr ("Show")))); + menu_entries.push_back (lay::menu_item ("cm_lv_show_all", "show_all", at, tl::to_string (QObject::tr ("Show All")))); + menu_entries.push_back (lay::menu_item ("cm_lv_show_only", "show_only", at, tl::to_string (QObject::tr ("Show Only Selected")))); + menu_entries.push_back (lay::menu_item ("cm_lv_make_valid", "valid", at, tl::to_string (QObject::tr ("Make Valid")))); + menu_entries.push_back (lay::menu_item ("cm_lv_make_invalid", "invvalid", at, tl::to_string (QObject::tr ("Make Invalid")))); + menu_entries.push_back (lay::menu_item ("cm_lv_rename", "rename", at, tl::to_string (QObject::tr ("Rename")))); menu_entries.push_back (lay::separator ("options_group", at)); menu_entries.push_back (lay::config_menu_item ("hide_empty_layers", at, tl::to_string (QObject::tr ("Hide Empty Layers")), cfg_hide_empty_layers, "?")); menu_entries.push_back (lay::config_menu_item ("test_shapes_in_view", at, tl::to_string (QObject::tr ("Test For Shapes In View")), cfg_test_shapes_in_view, "?")); menu_entries.push_back (lay::separator ("source_group", at)); - menu_entries.push_back (lay::menu_item ("cm_lv_source", "select_source", at, tl::to_string (QObject::tr ("Select Source"))); + menu_entries.push_back (lay::menu_item ("cm_lv_source", "select_source", at, tl::to_string (QObject::tr ("Select Source")))); menu_entries.push_back (lay::separator ("sort_group", at)); menu_entries.push_back (lay::submenu ("sort_menu", at, tl::to_string (QObject::tr ("Sort By")))); { std::string at = "@lcp_context_menu.sort_menu.end"; - menu_entries.push_back (lay::menu_item ("cm_lv_sort_by_ild", "sort_ild", at, tl::to_string (QObject::tr ("Layout Index, Layer And Datatype"))); - menu_entries.push_back (lay::menu_item ("cm_lv_sort_by_idl", "sort_idl", at, tl::to_string (QObject::tr ("Layout Index, Datatype And Layer"))); - menu_entries.push_back (lay::menu_item ("cm_lv_sort_by_ldi", "sort_ldi", at, tl::to_string (QObject::tr ("Layer, Datatype And Layout Index"))); - menu_entries.push_back (lay::menu_item ("cm_lv_sort_by_dli", "sort_dli", at, tl::to_string (QObject::tr ("Datatype, Layer And Layout Index"))); - menu_entries.push_back (lay::menu_item ("cm_lv_sort_by_name", "sort_name", at, tl::to_string (QObject::tr ("Name"))); + menu_entries.push_back (lay::menu_item ("cm_lv_sort_by_ild", "sort_ild", at, tl::to_string (QObject::tr ("Layout Index, Layer And Datatype")))); + menu_entries.push_back (lay::menu_item ("cm_lv_sort_by_idl", "sort_idl", at, tl::to_string (QObject::tr ("Layout Index, Datatype And Layer")))); + menu_entries.push_back (lay::menu_item ("cm_lv_sort_by_ldi", "sort_ldi", at, tl::to_string (QObject::tr ("Layer, Datatype And Layout Index")))); + menu_entries.push_back (lay::menu_item ("cm_lv_sort_by_dli", "sort_dli", at, tl::to_string (QObject::tr ("Datatype, Layer And Layout Index")))); + menu_entries.push_back (lay::menu_item ("cm_lv_sort_by_name", "sort_name", at, tl::to_string (QObject::tr ("Name")))); } menu_entries.push_back (lay::separator ("view_group", at)); - menu_entries.push_back (lay::menu_item ("cm_lv_delete", "del", at, tl::to_string (QObject::tr ("Delete Layer Entry"))); - menu_entries.push_back (lay::menu_item ("cm_lv_insert", "insert", at, tl::to_string (QObject::tr ("Insert Layer Entry"))); - menu_entries.push_back (lay::menu_item ("cm_lv_add_missing", "add_others", at, tl::to_string (QObject::tr ("Add Other Layer Entries"))); - menu_entries.push_back (lay::menu_item ("cm_lv_remove_unused", "clean_up", at, tl::to_string (QObject::tr ("Clean Up Layer Entries"))); + menu_entries.push_back (lay::menu_item ("cm_lv_delete", "del", at, tl::to_string (QObject::tr ("Delete Layer Entry")))); + menu_entries.push_back (lay::menu_item ("cm_lv_insert", "insert", at, tl::to_string (QObject::tr ("Insert Layer Entry")))); + menu_entries.push_back (lay::menu_item ("cm_lv_add_missing", "add_others", at, tl::to_string (QObject::tr ("Add Other Layer Entries")))); + menu_entries.push_back (lay::menu_item ("cm_lv_remove_unused", "clean_up", at, tl::to_string (QObject::tr ("Clean Up Layer Entries")))); menu_entries.push_back (lay::separator ("grouping_group", at)); - menu_entries.push_back (lay::menu_item ("cm_lv_group", "group", at, tl::to_string (QObject::tr ("Group"))); - menu_entries.push_back (lay::menu_item ("cm_lv_ungroup", "ungroup", at, tl::to_string (QObject::tr ("Ungroup"))); + menu_entries.push_back (lay::menu_item ("cm_lv_group", "group", at, tl::to_string (QObject::tr ("Group")))); + menu_entries.push_back (lay::menu_item ("cm_lv_ungroup", "ungroup", at, tl::to_string (QObject::tr ("Ungroup")))); menu_entries.push_back (lay::submenu ("regroup_menu", at, tl::to_string (QObject::tr ("Regroup Layer Entries")))); { std::string at = "@lcp_context_menu.regroup_menu.end"; - menu_entries.push_back (lay::menu_item ("cm_lv_regroup_by_index", "grp_i", at, tl::to_string (QObject::tr ("By Layout Index"))); - menu_entries.push_back (lay::menu_item ("cm_lv_regroup_by_datatype", "grp_d", at, tl::to_string (QObject::tr ("By Datatype"))); - menu_entries.push_back (lay::menu_item ("cm_lv_regroup_by_layer", "grp_l", at, tl::to_string (QObject::tr ("By Layer"))); - menu_entries.push_back (lay::menu_item ("cm_lv_regroup_flatten", "flatten", at, tl::to_string (QObject::tr ("Flatten"))); + menu_entries.push_back (lay::menu_item ("cm_lv_regroup_by_index", "grp_i", at, tl::to_string (QObject::tr ("By Layout Index")))); + menu_entries.push_back (lay::menu_item ("cm_lv_regroup_by_datatype", "grp_d", at, tl::to_string (QObject::tr ("By Datatype")))); + menu_entries.push_back (lay::menu_item ("cm_lv_regroup_by_layer", "grp_l", at, tl::to_string (QObject::tr ("By Layer")))); + menu_entries.push_back (lay::menu_item ("cm_lv_regroup_flatten", "flatten", at, tl::to_string (QObject::tr ("Flatten")))); } menu_entries.push_back (lay::separator ("copy_paste_group", at)); - menu_entries.push_back (lay::menu_item ("cm_lv_copy", "copy", at, tl::to_string (QObject::tr ("Copy"))); - menu_entries.push_back (lay::menu_item ("cm_lv_cut", "cut", at, tl::to_string (QObject::tr ("Cut"))); - menu_entries.push_back (lay::menu_item ("cm_lv_paste", "paste", at, tl::to_string (QObject::tr ("Paste"))); + menu_entries.push_back (lay::menu_item ("cm_lv_copy", "copy", at, tl::to_string (QObject::tr ("Copy")))); + menu_entries.push_back (lay::menu_item ("cm_lv_cut", "cut", at, tl::to_string (QObject::tr ("Cut")))); + menu_entries.push_back (lay::menu_item ("cm_lv_paste", "paste", at, tl::to_string (QObject::tr ("Paste")))); at = ".end"; menu_entries.push_back (lay::submenu ("@lcp_tabs_context_menu", at, std::string ())); { std::string at = "@lcp_tabs_context_menu.end"; - menu_entries.push_back (lay::menu_item ("cm_lv_new_tab", "new_tab", at, tl::to_string (QObject::tr ("New Tab"))); - menu_entries.push_back (lay::menu_item ("cm_lv_remove_tab", "remove_tab", at, tl::to_string (QObject::tr ("Remove Tab"))); - menu_entries.push_back (lay::menu_item ("cm_lv_rename_tab", "rename_tab", at, tl::to_string (QObject::tr ("Rename Tab"))); + menu_entries.push_back (lay::menu_item ("cm_lv_new_tab", "new_tab", at, tl::to_string (QObject::tr ("New Tab")))); + menu_entries.push_back (lay::menu_item ("cm_lv_remove_tab", "remove_tab", at, tl::to_string (QObject::tr ("Remove Tab")))); + menu_entries.push_back (lay::menu_item ("cm_lv_rename_tab", "rename_tab", at, tl::to_string (QObject::tr ("Rename Tab")))); } } }; diff --git a/src/laybasic/laybasic/layLayoutViewConfigPages.cc b/src/laybasic/laybasic/layLayoutViewConfigPages.cc index 103631132..c088793d1 100644 --- a/src/laybasic/laybasic/layLayoutViewConfigPages.cc +++ b/src/laybasic/laybasic/layLayoutViewConfigPages.cc @@ -24,6 +24,7 @@ #include "layLayoutViewConfigPages.h" #include "laybasicConfig.h" #include "layConverters.h" +#include "layDispatcher.h" #include "ui_LayoutViewConfigPage.h" #include "ui_LayoutViewConfigPage1.h" @@ -74,7 +75,7 @@ LayoutViewConfigPage::~LayoutViewConfigPage () } void -LayoutViewConfigPage::setup (lay::PluginRoot *root) +LayoutViewConfigPage::setup (lay::Dispatcher *root) { lay::ColorConverter cc; QColor color; @@ -84,7 +85,7 @@ LayoutViewConfigPage::setup (lay::PluginRoot *root) } void -LayoutViewConfigPage::commit (lay::PluginRoot *root) +LayoutViewConfigPage::commit (lay::Dispatcher *root) { lay::ColorConverter cc; root->config_set (cfg_background_color, mp_ui->bkgnd_color_pb->get_color (), cc); @@ -107,7 +108,7 @@ LayoutViewConfigPage1::~LayoutViewConfigPage1 () } void -LayoutViewConfigPage1::setup (lay::PluginRoot *root) +LayoutViewConfigPage1::setup (lay::Dispatcher *root) { lay::ColorConverter cc; @@ -152,7 +153,7 @@ LayoutViewConfigPage1::setup (lay::PluginRoot *root) } void -LayoutViewConfigPage1::commit (lay::PluginRoot *root) +LayoutViewConfigPage1::commit (lay::Dispatcher *root) { lay::ColorConverter cc; @@ -192,7 +193,7 @@ LayoutViewConfigPage2a::~LayoutViewConfigPage2a () } void -LayoutViewConfigPage2a::setup (lay::PluginRoot *root) +LayoutViewConfigPage2a::setup (lay::Dispatcher *root) { QColor color; root->config_get (cfg_cell_box_color, color, ColorConverter ()); @@ -238,7 +239,7 @@ LayoutViewConfigPage2a::setup (lay::PluginRoot *root) } void -LayoutViewConfigPage2a::commit (lay::PluginRoot *root) +LayoutViewConfigPage2a::commit (lay::Dispatcher *root) { root->config_set (cfg_cell_box_text_transform, mp_ui->cell_xform_text_cbx->isChecked ()); root->config_set (cfg_cell_box_text_font, mp_ui->cell_font_cb->currentIndex ()); @@ -274,7 +275,7 @@ LayoutViewConfigPage2b::~LayoutViewConfigPage2b () } void -LayoutViewConfigPage2b::setup (lay::PluginRoot *root) +LayoutViewConfigPage2b::setup (lay::Dispatcher *root) { QColor color; root->config_get (cfg_text_color, color, ColorConverter ()); @@ -307,7 +308,7 @@ LayoutViewConfigPage2b::setup (lay::PluginRoot *root) } void -LayoutViewConfigPage2b::commit (lay::PluginRoot *root) +LayoutViewConfigPage2b::commit (lay::Dispatcher *root) { root->config_set (cfg_text_color, mp_ui->text_color_pb->get_color (), ColorConverter ()); root->config_set (cfg_apply_text_trans, mp_ui->text_apply_trans_cbx->isChecked ()); @@ -339,7 +340,7 @@ LayoutViewConfigPage2c::~LayoutViewConfigPage2c () } void -LayoutViewConfigPage2c::setup (lay::PluginRoot *root) +LayoutViewConfigPage2c::setup (lay::Dispatcher *root) { QColor color; root->config_get (cfg_sel_color, color, lay::ColorConverter ()); @@ -375,7 +376,7 @@ LayoutViewConfigPage2c::setup (lay::PluginRoot *root) } void -LayoutViewConfigPage2c::commit (lay::PluginRoot *root) +LayoutViewConfigPage2c::commit (lay::Dispatcher *root) { lay::ColorConverter cc; root->config_set (cfg_sel_color, mp_ui->color_pb->get_color (), cc); @@ -405,7 +406,7 @@ LayoutViewConfigPage3a::~LayoutViewConfigPage3a () } void -LayoutViewConfigPage3a::setup (lay::PluginRoot *root) +LayoutViewConfigPage3a::setup (lay::Dispatcher *root) { bool flag = true; @@ -418,7 +419,7 @@ LayoutViewConfigPage3a::setup (lay::PluginRoot *root) } void -LayoutViewConfigPage3a::commit (lay::PluginRoot *root) +LayoutViewConfigPage3a::commit (lay::Dispatcher *root) { root->config_set (cfg_fit_new_cell, mp_ui->fit_new_cell_cbx->isChecked ()); root->config_set (cfg_full_hier_new_cell, mp_ui->full_hier_new_cell_cbx->isChecked ()); @@ -442,7 +443,7 @@ LayoutViewConfigPage3b::~LayoutViewConfigPage3b () } void -LayoutViewConfigPage3b::setup (lay::PluginRoot *root) +LayoutViewConfigPage3b::setup (lay::Dispatcher *root) { bool flag = true; double pd = 0.0; @@ -462,7 +463,7 @@ LayoutViewConfigPage3b::setup (lay::PluginRoot *root) } void -LayoutViewConfigPage3b::commit (lay::PluginRoot *root) +LayoutViewConfigPage3b::commit (lay::Dispatcher *root) { root->config_set (cfg_mouse_wheel_mode, mp_ui->alt_mouse_wheel_mode_cbx->isChecked () ? 1 : 0); @@ -501,7 +502,7 @@ LayoutViewConfigPage3c::~LayoutViewConfigPage3c () } void -LayoutViewConfigPage3c::setup (lay::PluginRoot *root) +LayoutViewConfigPage3c::setup (lay::Dispatcher *root) { bool flag = true; @@ -512,7 +513,7 @@ LayoutViewConfigPage3c::setup (lay::PluginRoot *root) } void -LayoutViewConfigPage3c::commit (lay::PluginRoot *root) +LayoutViewConfigPage3c::commit (lay::Dispatcher *root) { root->config_set (cfg_dbu_units, mp_ui->dbu_units_cbx->isChecked ()); root->config_set (cfg_abs_units, mp_ui->abs_units_cbx->isChecked ()); @@ -535,7 +536,7 @@ LayoutViewConfigPage3f::~LayoutViewConfigPage3f () } void -LayoutViewConfigPage3f::setup (lay::PluginRoot *root) +LayoutViewConfigPage3f::setup (lay::Dispatcher *root) { int workers = 1; bool flag = true; @@ -567,7 +568,7 @@ LayoutViewConfigPage3f::setup (lay::PluginRoot *root) } void -LayoutViewConfigPage3f::commit (lay::PluginRoot *root) +LayoutViewConfigPage3f::commit (lay::Dispatcher *root) { root->config_set (cfg_drawing_workers, mp_ui->drawing_workers_spbx->value ()); @@ -654,7 +655,7 @@ LayoutViewConfigPage4::set_edit_order (bool edit_order) } void -LayoutViewConfigPage4::setup (lay::PluginRoot *root) +LayoutViewConfigPage4::setup (lay::Dispatcher *root) { m_manager.clear (); @@ -678,7 +679,7 @@ LayoutViewConfigPage4::setup (lay::PluginRoot *root) } void -LayoutViewConfigPage4::commit (lay::PluginRoot *root) +LayoutViewConfigPage4::commit (lay::Dispatcher *root) { root->config_set (cfg_color_palette, m_palette.to_string ()); } @@ -876,7 +877,7 @@ LayoutViewConfigPage5::~LayoutViewConfigPage5 () } void -LayoutViewConfigPage5::setup (lay::PluginRoot *root) +LayoutViewConfigPage5::setup (lay::Dispatcher *root) { std::string lyp_file; root->config_get (cfg_default_lyp_file, lyp_file); @@ -901,7 +902,7 @@ LayoutViewConfigPage5::setup (lay::PluginRoot *root) } void -LayoutViewConfigPage5::commit (lay::PluginRoot *root) +LayoutViewConfigPage5::commit (lay::Dispatcher *root) { if (mp_ui->lyp_file_gbx->isChecked ()) { root->config_set (cfg_default_lyp_file, tl::to_string (mp_ui->lyp_file_le->text ())); @@ -988,7 +989,7 @@ LayoutViewConfigPage6::set_edit_order (bool edit_order) } void -LayoutViewConfigPage6::setup (lay::PluginRoot *root) +LayoutViewConfigPage6::setup (lay::Dispatcher *root) { m_manager.clear (); @@ -1016,7 +1017,7 @@ LayoutViewConfigPage6::setup (lay::PluginRoot *root) } void -LayoutViewConfigPage6::commit (lay::PluginRoot *root) +LayoutViewConfigPage6::commit (lay::Dispatcher *root) { if (m_palette.stipples () == 0) { throw tl::Exception (tl::to_string (QObject::tr ("No stipples set"))); @@ -1266,7 +1267,7 @@ LayoutViewConfigPage6a::~LayoutViewConfigPage6a () } void -LayoutViewConfigPage6a::setup (lay::PluginRoot *root) +LayoutViewConfigPage6a::setup (lay::Dispatcher *root) { m_manager.clear (); @@ -1289,7 +1290,7 @@ LayoutViewConfigPage6a::setup (lay::PluginRoot *root) } void -LayoutViewConfigPage6a::commit (lay::PluginRoot *root) +LayoutViewConfigPage6a::commit (lay::Dispatcher *root) { if (m_palette.styles () == 0) { throw tl::Exception (tl::to_string (QObject::tr ("No styles set"))); @@ -1440,7 +1441,7 @@ LayoutViewConfigPage7::~LayoutViewConfigPage7 () } void -LayoutViewConfigPage7::setup (lay::PluginRoot *root) +LayoutViewConfigPage7::setup (lay::Dispatcher *root) { int oversampling = 1; root->config_get (cfg_bitmap_oversampling, oversampling); @@ -1466,7 +1467,7 @@ LayoutViewConfigPage7::setup (lay::PluginRoot *root) } void -LayoutViewConfigPage7::commit (lay::PluginRoot *root) +LayoutViewConfigPage7::commit (lay::Dispatcher *root) { root->config_set (cfg_bitmap_oversampling, mp_ui->oversampling->currentIndex () + 1); root->config_set (cfg_default_font_size, mp_ui->default_font_size->currentIndex ()); diff --git a/src/laybasic/laybasic/layLibrariesView.cc b/src/laybasic/laybasic/layLibrariesView.cc index 4ae658748..d29d735ad 100644 --- a/src/laybasic/laybasic/layLibrariesView.cc +++ b/src/laybasic/laybasic/layLibrariesView.cc @@ -48,7 +48,6 @@ #include "layCellTreeModel.h" #include "layLayoutView.h" #include "layAbstractMenu.h" -#include "layAbstractMenuProvider.h" #include "layDialogs.h" #include "tlExceptions.h" #include "laybasicConfig.h" diff --git a/src/laybasic/laybasic/layLoadLayoutOptionsDialog.cc b/src/laybasic/laybasic/layLoadLayoutOptionsDialog.cc index beb4ae96a..210654272 100644 --- a/src/laybasic/laybasic/layLoadLayoutOptionsDialog.cc +++ b/src/laybasic/laybasic/layLoadLayoutOptionsDialog.cc @@ -197,7 +197,7 @@ LoadLayoutOptionsDialog::update () } bool -LoadLayoutOptionsDialog::edit_global_options (lay::PluginRoot *config_root, db::Technologies *technologies) +LoadLayoutOptionsDialog::edit_global_options (lay::Dispatcher *config_root, db::Technologies *technologies) { m_opt_array.clear (); m_tech_array.clear (); diff --git a/src/laybasic/laybasic/layNetExportDialog.cc b/src/laybasic/laybasic/layNetExportDialog.cc index 66033b860..37ddad37f 100644 --- a/src/laybasic/laybasic/layNetExportDialog.cc +++ b/src/laybasic/laybasic/layNetExportDialog.cc @@ -22,6 +22,7 @@ #include "layNetExportDialog.h" #include "layPlugin.h" +#include "layDispatcher.h" #include "layQtTools.h" #include "tlExceptions.h" @@ -165,7 +166,7 @@ END_PROTECTED } int -NetExportDialog::exec_dialog (lay::PluginRoot *plugin_root) +NetExportDialog::exec_dialog (lay::Dispatcher *plugin_root) { std::string v; plugin_root->config_get (cfg_l2ndb_export_net_cell_prefix, v); diff --git a/src/laybasic/laybasic/layNetExportDialog.h b/src/laybasic/laybasic/layNetExportDialog.h index 475b92245..b4ff166e1 100644 --- a/src/laybasic/laybasic/layNetExportDialog.h +++ b/src/laybasic/laybasic/layNetExportDialog.h @@ -39,7 +39,7 @@ namespace Ui namespace lay { -class PluginRoot; +class Dispatcher; /** * @brief A dialog showing the details of a net @@ -74,7 +74,7 @@ public: void set_start_layer_number (int ln); int start_layer_number (); - int exec_dialog (lay::PluginRoot *mp_plugin_root); + int exec_dialog (lay::Dispatcher *mp_plugin_root); protected: void accept (); diff --git a/src/laybasic/laybasic/layNetlistBrowser.cc b/src/laybasic/laybasic/layNetlistBrowser.cc index 614bfecec..1f9bb16eb 100644 --- a/src/laybasic/laybasic/layNetlistBrowser.cc +++ b/src/laybasic/laybasic/layNetlistBrowser.cc @@ -23,8 +23,8 @@ #include "laybasicCommon.h" #include "layNetlistBrowserDialog.h" - #include "layConverters.h" +#include "layDispatcher.h" #include @@ -105,7 +105,7 @@ NetlistBrowserConfigPage::NetlistBrowserConfigPage (QWidget *parent) } void -NetlistBrowserConfigPage::setup (lay::PluginRoot *root) +NetlistBrowserConfigPage::setup (lay::Dispatcher *root) { // window mode lay::NetlistBrowserConfig::net_window_type wmode = lay::NetlistBrowserConfig::FitNet; @@ -133,7 +133,7 @@ NetlistBrowserConfigPage::window_changed (int m) } void -NetlistBrowserConfigPage::commit (lay::PluginRoot *root) +NetlistBrowserConfigPage::commit (lay::Dispatcher *root) { double dim = 1.0; tl::from_string (tl::to_string (le_window->text ()), dim); @@ -195,7 +195,7 @@ NetlistBrowserConfigPage2::color_button_clicked () } void -NetlistBrowserConfigPage2::setup (lay::PluginRoot *root) +NetlistBrowserConfigPage2::setup (lay::Dispatcher *root) { bool cycle_enabled = false; root->config_get (cfg_l2ndb_marker_cycle_colors_enabled, cycle_enabled); @@ -287,7 +287,7 @@ NetlistBrowserConfigPage2::update_colors () } void -NetlistBrowserConfigPage2::commit (lay::PluginRoot *root) +NetlistBrowserConfigPage2::commit (lay::Dispatcher *root) { root->config_set (cfg_l2ndb_marker_cycle_colors_enabled, cycle_colors_cb->isChecked ()); root->config_set (cfg_l2ndb_marker_cycle_colors, m_palette.to_string ()); @@ -373,10 +373,10 @@ public: virtual void get_menu_entries (std::vector &menu_entries) const { lay::PluginDeclaration::get_menu_entries (menu_entries); - menu_entries.push_back (lay::MenuEntry ("netlist_browser::show", "browse_netlists", "tools_menu.end", tl::to_string (QObject::tr ("Netlist Browser")))); + menu_entries.push_back (lay::menu_item ("netlist_browser::show", "browse_netlists", "tools_menu.end", tl::to_string (QObject::tr ("Netlist Browser")))); } - virtual lay::Plugin *create_plugin (db::Manager *, lay::PluginRoot *root, lay::LayoutView *view) const + virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutView *view) const { return new lay::NetlistBrowserDialog (root, view); } diff --git a/src/laybasic/laybasic/layNetlistBrowserDialog.cc b/src/laybasic/laybasic/layNetlistBrowserDialog.cc index 5b584776b..50866fa8d 100644 --- a/src/laybasic/laybasic/layNetlistBrowserDialog.cc +++ b/src/laybasic/laybasic/layNetlistBrowserDialog.cc @@ -56,7 +56,7 @@ extern const std::string cfg_l2ndb_max_shapes_highlighted; extern const std::string cfg_l2ndb_show_all; extern const std::string cfg_l2ndb_window_state; -NetlistBrowserDialog::NetlistBrowserDialog (lay::PluginRoot *root, lay::LayoutView *vw) +NetlistBrowserDialog::NetlistBrowserDialog (lay::Dispatcher *root, lay::LayoutView *vw) : lay::Browser (root, vw), lay::ViewService (vw->view_object_widget ()), Ui::NetlistBrowserDialog (), @@ -76,7 +76,7 @@ NetlistBrowserDialog::NetlistBrowserDialog (lay::PluginRoot *root, lay::LayoutVi { Ui::NetlistBrowserDialog::setupUi (this); - browser_page->set_plugin_root (root); + browser_page->set_dispatcher (root); if (view ()) { view ()->cellviews_changed_event.add (this, &NetlistBrowserDialog::cellviews_changed); @@ -132,7 +132,7 @@ NetlistBrowserDialog::configure_clicked () { release_mouse (); - lay::ConfigurationDialog config_dialog (this, lay::PluginRoot::instance (), "NetlistBrowserPlugin"); + lay::ConfigurationDialog config_dialog (this, lay::Dispatcher::instance (), "NetlistBrowserPlugin"); config_dialog.exec (); } @@ -747,8 +747,8 @@ NetlistBrowserDialog::deactivated () { release_mouse (); - if (lay::PluginRoot::instance ()) { - lay::PluginRoot::instance ()->config_set (cfg_l2ndb_window_state, lay::save_dialog_state (this, false /*don't store the section sizes*/).c_str ()); + if (lay::Dispatcher::instance ()) { + lay::Dispatcher::instance ()->config_set (cfg_l2ndb_window_state, lay::save_dialog_state (this, false /*don't store the section sizes*/).c_str ()); } browser_page->set_l2ndb (0); diff --git a/src/laybasic/laybasic/layNetlistBrowserDialog.h b/src/laybasic/laybasic/layNetlistBrowserDialog.h index 4f10e9bbe..73b0b5fe6 100644 --- a/src/laybasic/laybasic/layNetlistBrowserDialog.h +++ b/src/laybasic/laybasic/layNetlistBrowserDialog.h @@ -41,7 +41,7 @@ class NetlistBrowserDialog Q_OBJECT public: - NetlistBrowserDialog (lay::PluginRoot *root, lay::LayoutView *view); + NetlistBrowserDialog (lay::Dispatcher *root, lay::LayoutView *view); ~NetlistBrowserDialog (); void load (int lay_index, int cv_index); diff --git a/src/laybasic/laybasic/layNetlistBrowserPage.cc b/src/laybasic/laybasic/layNetlistBrowserPage.cc index f1dfc73c8..aee0bc4b1 100644 --- a/src/laybasic/laybasic/layNetlistBrowserPage.cc +++ b/src/laybasic/laybasic/layNetlistBrowserPage.cc @@ -219,7 +219,7 @@ NetlistBrowserPage::is_netlist_mode () } void -NetlistBrowserPage::set_plugin_root (lay::PluginRoot *pr) +NetlistBrowserPage::set_dispatcher (lay::Dispatcher *pr) { mp_plugin_root = pr; } diff --git a/src/laybasic/laybasic/layNetlistBrowserPage.h b/src/laybasic/laybasic/layNetlistBrowserPage.h index 59217d1ef..9a1adccd6 100644 --- a/src/laybasic/laybasic/layNetlistBrowserPage.h +++ b/src/laybasic/laybasic/layNetlistBrowserPage.h @@ -42,7 +42,7 @@ namespace lay { class LayoutView; -class PluginRoot; +class Dispatcher; class Marker; class NetInfoDialog; class LayerPropertiesConstIterator; @@ -76,7 +76,7 @@ public: /** * @brief Sets the plugin root object for this object */ - void set_plugin_root (lay::PluginRoot *pr); + void set_dispatcher (lay::Dispatcher *pr); /** * @brief Attaches the page to a view @@ -199,7 +199,7 @@ private: bool m_use_original_colors; lay::LayoutView *mp_view; unsigned int m_cv_index; - lay::PluginRoot *mp_plugin_root; + lay::Dispatcher *mp_plugin_root; tl::weak_ptr mp_database; std::vector m_history; size_t m_history_ptr; diff --git a/src/laybasic/laybasic/layPlugin.cc b/src/laybasic/laybasic/layPlugin.cc index 7cea2ab8b..16b923fb0 100644 --- a/src/laybasic/laybasic/layPlugin.cc +++ b/src/laybasic/laybasic/layPlugin.cc @@ -243,7 +243,7 @@ PluginDeclaration::init_menu (lay::Dispatcher *dispatcher) // the primary mouse modes (special for LayoutView) implements_primary_mouse_modes (modes); - for (std::vector >::const_iterator m = modes.begin (); m != modes.end (); ++m) { + for (std::vector > >::const_iterator m = modes.begin (); m != modes.end (); ++m) { // extract first part, which is the name, separated by a tab from the title. std::string name; @@ -501,4 +501,57 @@ Plugin::do_config_set (const std::string &name, const std::string &value, bool f return false; } +// --------------------------------------------------------------------------------------------------- +// Menu item generators + +MenuEntry separator (const std::string &menu_name, const std::string &insert_pos) +{ + MenuEntry e; + e.menu_name = menu_name; + e.insert_pos = insert_pos; + return e; +} + +MenuEntry menu_item (const std::string &symbol, const std::string &menu_name, const std::string &insert_pos, const std::string &title) +{ + MenuEntry e; + e.symbol = symbol; + e.menu_name = menu_name; + e.insert_pos = insert_pos; + e.title = title; + return e; +} + +MenuEntry submenu (const std::string &menu_name, const std::string &insert_pos, const std::string &title) +{ + MenuEntry e; + e.menu_name = menu_name; + e.insert_pos = insert_pos; + e.title = title; + e.sub_menu = true; + return e; +} + +MenuEntry submenu (const std::string &symbol, const std::string &menu_name, const std::string &insert_pos, const std::string &title) +{ + MenuEntry e; + e.symbol = symbol; + e.menu_name = menu_name; + e.insert_pos = insert_pos; + e.title = title; + e.sub_menu = true; + return e; +} + +MenuEntry config_menu_item (const std::string &menu_name, const std::string &insert_pos, const std::string &title, const std::string &cname, const std::string &cvalue) +{ + MenuEntry e; + e.menu_name = menu_name; + e.insert_pos = insert_pos; + e.title = title; + e.cname = cname; + e.cvalue = cvalue; + return e; +} + } diff --git a/src/laybasic/laybasic/layPlugin.h b/src/laybasic/laybasic/layPlugin.h index 0395433b6..e42a5e2fc 100644 --- a/src/laybasic/laybasic/layPlugin.h +++ b/src/laybasic/laybasic/layPlugin.h @@ -121,13 +121,7 @@ struct LAYBASIC_PUBLIC MenuEntry * @param menu_name The name of the menu item (see layAbstractMenu.h) * @param insert_pos The position where to insert (see layAbstractMenu.h) */ -MenuEntry separator (const std::string &menu_name, const std::string &insert_pos) -{ - MenuEntry e; - e.menu_name = menu_name; - e.insert_pos = insert_pos; - return e; -} +MenuEntry separator (const std::string &menu_name, const std::string &insert_pos); /** * @brief Creates a normal menu entry @@ -137,15 +131,7 @@ MenuEntry separator (const std::string &menu_name, const std::string &insert_pos * @param insert_pos The position where to insert (see layAbstractMenu.h) * @param title The title to display plus optional icon resource and keyboard shortcut. The format of the string is: ["("shortcut")"]["<"icon-resource">"][{"tool-tip"}]. */ -MenuEntry menu_item (const std::string &symbol, const std::string &menu_name, const std::string &insert_pos, const std::string &title) -{ - MenuEntry e; - e.symbol = symbol; - e.menu_name = menu_name; - e.insert_pos = insert_pos; - e.title = title; - return e; -} +MenuEntry menu_item (const std::string &symbol, const std::string &menu_name, const std::string &insert_pos, const std::string &title); /** * @brief Creates a submenu entry @@ -154,15 +140,7 @@ MenuEntry menu_item (const std::string &symbol, const std::string &menu_name, co * @param insert_pos The position where to insert (see layAbstractMenu.h) * @param title The title to display plus optional icon resource and keyboard shortcut. The format of the string is: ["("shortcut")"]["<"icon-resource">"][{"tool-tip"}]. */ -MenuEntry submenu (const std::string &menu_name, const std::string &insert_pos, const std::string &title) -{ - MenuEntry e; - e.menu_name = menu_name; - e.insert_pos = insert_pos; - e.title = title; - e.sub_menu = true; - return e; -} +MenuEntry submenu (const std::string &menu_name, const std::string &insert_pos, const std::string &title); /** * @brief Creates a submenu entry @@ -172,16 +150,7 @@ MenuEntry submenu (const std::string &menu_name, const std::string &insert_pos, * @param insert_pos The position where to insert (see layAbstractMenu.h) * @param title The title to display plus optional icon resource and keyboard shortcut. The format of the string is: ["("shortcut")"]["<"icon-resource">"][{"tool-tip"}]. */ -MenuEntry submenu (const std::string &symbol, const std::string &menu_name, const std::string &insert_pos, const std::string &title) -{ - MenuEntry e; - e.symbol = symbol; - e.menu_name = menu_name; - e.insert_pos = insert_pos; - e.title = title; - e.sub_menu = true; - return e; -} +MenuEntry submenu (const std::string &symbol, const std::string &menu_name, const std::string &insert_pos, const std::string &title); /** * @brief Creates a configuration entry @@ -192,16 +161,7 @@ MenuEntry submenu (const std::string &symbol, const std::string &menu_name, cons * @param cname The name of the configuration item * @param cvalue The value to set for the configuration item (optional for boolean configuration items) */ -MenuEntry config_menu_item (const std::string &menu_name, const std::string &insert_pos, const std::string &title, const std::string &cname, const std::string &cvalue = std::string ()) -{ - MenuEntry e; - e.menu_name = menu_name; - e.insert_pos = insert_pos; - e.title = title; - e.cname = cname; - e.cvalue = cvalue; - return e; -} +MenuEntry config_menu_item (const std::string &menu_name, const std::string &insert_pos, const std::string &title, const std::string &cname, const std::string &cvalue = std::string ()); /** * @brief The configuration declaration diff --git a/src/laybasic/laybasic/laySaveLayoutOptionsDialog.cc b/src/laybasic/laybasic/laySaveLayoutOptionsDialog.cc index f2c7b61e2..e52338aa9 100644 --- a/src/laybasic/laybasic/laySaveLayoutOptionsDialog.cc +++ b/src/laybasic/laybasic/laySaveLayoutOptionsDialog.cc @@ -230,7 +230,7 @@ SaveLayoutOptionsDialog::update () } bool -SaveLayoutOptionsDialog::edit_global_options (lay::PluginRoot *config_root, db::Technologies *technologies) +SaveLayoutOptionsDialog::edit_global_options (lay::Dispatcher *config_root, db::Technologies *technologies) { m_opt_array.clear (); m_tech_array.clear (); diff --git a/src/laybasic/laybasic/layTipDialog.cc b/src/laybasic/laybasic/layTipDialog.cc index d32738ea2..b4510d4da 100644 --- a/src/laybasic/laybasic/layTipDialog.cc +++ b/src/laybasic/laybasic/layTipDialog.cc @@ -24,6 +24,7 @@ #include "layTipDialog.h" #include "laybasicConfig.h" #include "layPlugin.h" +#include "layDispatcher.h" #include "layDialogs.h" #include "layQtTools.h" @@ -134,8 +135,8 @@ TipDialog::do_exec_dialog (button_type *button) mp_res = button; std::string th; - if (lay::PluginRoot::instance ()) { - lay::PluginRoot::instance ()->config_get (cfg_tip_window_hidden, th); + if (lay::Dispatcher::instance ()) { + lay::Dispatcher::instance ()->config_get (cfg_tip_window_hidden, th); } // test if we need to show this window @@ -172,8 +173,8 @@ TipDialog::accept () if (mp_ui->dont_show_cbx->isChecked ()) { std::string th; - if (lay::PluginRoot::instance ()) { - lay::PluginRoot::instance ()->config_get (cfg_tip_window_hidden, th); + if (lay::Dispatcher::instance ()) { + lay::Dispatcher::instance ()->config_get (cfg_tip_window_hidden, th); } if (! th.empty ()) { @@ -183,8 +184,8 @@ TipDialog::accept () th += "="; th += tl::to_string (int (*mp_res)); - if (lay::PluginRoot::instance ()) { - lay::PluginRoot::instance ()->config_set (cfg_tip_window_hidden, th); + if (lay::Dispatcher::instance ()) { + lay::Dispatcher::instance ()->config_set (cfg_tip_window_hidden, th); } } diff --git a/src/laybasic/laybasic/layWidgets.cc b/src/laybasic/laybasic/layWidgets.cc index ca9da9088..7c35f9734 100644 --- a/src/laybasic/laybasic/layWidgets.cc +++ b/src/laybasic/laybasic/layWidgets.cc @@ -197,7 +197,7 @@ DitherPatternSelectionButton::update_menu () lay::DitherPattern patterns; std::string s; - lay::PluginRoot::instance ()->config_get (cfg_stipple_palette, s); + lay::Dispatcher::instance ()->config_get (cfg_stipple_palette, s); lay::StipplePalette palette; palette.from_string (s); @@ -831,7 +831,7 @@ ColorButton::build_color_menu (QMenu *menu, QObject *receiver, const char *brows try { std::string s; - lay::PluginRoot::instance ()->config_get (cfg_color_palette, s); + lay::Dispatcher::instance ()->config_get (cfg_color_palette, s); lay::ColorPalette palette; palette.from_string (s); diff --git a/src/laybasic/laybasic/rdbMarkerBrowser.cc b/src/laybasic/laybasic/rdbMarkerBrowser.cc index a428f6f0f..1b0b5185e 100644 --- a/src/laybasic/laybasic/rdbMarkerBrowser.cc +++ b/src/laybasic/laybasic/rdbMarkerBrowser.cc @@ -26,6 +26,7 @@ #include "dbLayout.h" #include "layConverters.h" +#include "layDispatcher.h" #include @@ -133,7 +134,7 @@ MarkerBrowserConfigPage::MarkerBrowserConfigPage (QWidget *parent) } void -MarkerBrowserConfigPage::setup (lay::PluginRoot *root) +MarkerBrowserConfigPage::setup (lay::Dispatcher *root) { // context mode rdb::context_mode_type cmode = rdb::DatabaseTop; @@ -166,7 +167,7 @@ MarkerBrowserConfigPage::window_changed (int m) } void -MarkerBrowserConfigPage::commit (lay::PluginRoot *root) +MarkerBrowserConfigPage::commit (lay::Dispatcher *root) { double dim = 1.0; tl::from_string (tl::to_string (le_window->text ()), dim); @@ -190,7 +191,7 @@ MarkerBrowserConfigPage2::MarkerBrowserConfigPage2 (QWidget *parent) } void -MarkerBrowserConfigPage2::setup (lay::PluginRoot *root) +MarkerBrowserConfigPage2::setup (lay::Dispatcher *root) { // marker color QColor color; @@ -227,7 +228,7 @@ MarkerBrowserConfigPage2::setup (lay::PluginRoot *root) } void -MarkerBrowserConfigPage2::commit (lay::PluginRoot *root) +MarkerBrowserConfigPage2::commit (lay::Dispatcher *root) { QColor color (color_pb->get_color ()); root->config_set (cfg_rdb_marker_color, color, lay::ColorConverter ()); @@ -295,13 +296,13 @@ public: virtual void get_menu_entries (std::vector &menu_entries) const { lay::PluginDeclaration::get_menu_entries (menu_entries); - menu_entries.push_back (lay::MenuEntry ("marker_browser::show", "browse_markers", "tools_menu.end", tl::to_string (QObject::tr ("Marker Browser")))); - menu_entries.push_back (lay::MenuEntry ("marker_browser::show", "shapes_to_markers", "tools_menu.end", tl::to_string (QObject::tr ("Shapes To Markers")), true)); - menu_entries.push_back (lay::MenuEntry ("marker_browser::scan_layers", "scan_layers", "tools_menu.shapes_to_markers.end", tl::to_string (QObject::tr ("Hierarchical")))); - menu_entries.push_back (lay::MenuEntry ("marker_browser::scan_layers_flat", "scan_layers_flat", "tools_menu.shapes_to_markers.end", tl::to_string (QObject::tr ("Flat")))); + menu_entries.push_back (lay::menu_item ("marker_browser::show", "browse_markers", "tools_menu.end", tl::to_string (QObject::tr ("Marker Browser")))); + menu_entries.push_back (lay::submenu ("marker_browser::show", "shapes_to_markers", "tools_menu.end", tl::to_string (QObject::tr ("Shapes To Markers")))); + menu_entries.push_back (lay::menu_item ("marker_browser::scan_layers", "scan_layers", "tools_menu.shapes_to_markers.end", tl::to_string (QObject::tr ("Hierarchical")))); + menu_entries.push_back (lay::menu_item ("marker_browser::scan_layers_flat", "scan_layers_flat", "tools_menu.shapes_to_markers.end", tl::to_string (QObject::tr ("Flat")))); } - virtual lay::Plugin *create_plugin (db::Manager *, lay::PluginRoot *root, lay::LayoutView *view) const + virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutView *view) const { return new rdb::MarkerBrowserDialog (root, view); } diff --git a/src/laybasic/laybasic/rdbMarkerBrowserDialog.cc b/src/laybasic/laybasic/rdbMarkerBrowserDialog.cc index 6e15cb278..59cbea842 100644 --- a/src/laybasic/laybasic/rdbMarkerBrowserDialog.cc +++ b/src/laybasic/laybasic/rdbMarkerBrowserDialog.cc @@ -54,7 +54,7 @@ extern std::string cfg_rdb_marker_vertex_size; extern std::string cfg_rdb_marker_halo; extern std::string cfg_rdb_marker_dither_pattern; -MarkerBrowserDialog::MarkerBrowserDialog (lay::PluginRoot *root, lay::LayoutView *vw) +MarkerBrowserDialog::MarkerBrowserDialog (lay::Dispatcher *root, lay::LayoutView *vw) : lay::Browser (root, vw), Ui::MarkerBrowserDialog (), m_context (rdb::AnyCell), @@ -70,7 +70,7 @@ MarkerBrowserDialog::MarkerBrowserDialog (lay::PluginRoot *root, lay::LayoutView { Ui::MarkerBrowserDialog::setupUi (this); - browser_frame->set_plugin_root (root); + browser_frame->set_dispatcher (root); if (view ()) { view ()->cellviews_changed_event.add (this, &MarkerBrowserDialog::cellviews_changed); @@ -122,7 +122,7 @@ MarkerBrowserDialog::~MarkerBrowserDialog () void MarkerBrowserDialog::configure_clicked () { - lay::ConfigurationDialog config_dialog (this, lay::PluginRoot::instance (), "MarkerBrowserPlugin"); + lay::ConfigurationDialog config_dialog (this, lay::Dispatcher::instance (), "MarkerBrowserPlugin"); config_dialog.exec (); } @@ -703,8 +703,8 @@ MarkerBrowserDialog::update_content () void MarkerBrowserDialog::deactivated () { - if (lay::PluginRoot::instance ()) { - lay::PluginRoot::instance ()->config_set (cfg_rdb_window_state, lay::save_dialog_state (this).c_str ()); + if (lay::Dispatcher::instance ()) { + lay::Dispatcher::instance ()->config_set (cfg_rdb_window_state, lay::save_dialog_state (this).c_str ()); } browser_frame->set_rdb (0); diff --git a/src/laybasic/laybasic/rdbMarkerBrowserDialog.h b/src/laybasic/laybasic/rdbMarkerBrowserDialog.h index b42d0172b..f69c17291 100644 --- a/src/laybasic/laybasic/rdbMarkerBrowserDialog.h +++ b/src/laybasic/laybasic/rdbMarkerBrowserDialog.h @@ -38,7 +38,7 @@ class MarkerBrowserDialog Q_OBJECT public: - MarkerBrowserDialog (lay::PluginRoot *root, lay::LayoutView *view); + MarkerBrowserDialog (lay::Dispatcher *root, lay::LayoutView *view); ~MarkerBrowserDialog (); void load (int rdb_index, int cv_index); diff --git a/src/laybasic/laybasic/rdbMarkerBrowserPage.cc b/src/laybasic/laybasic/rdbMarkerBrowserPage.cc index 163dff9b7..0a0a6d69e 100644 --- a/src/laybasic/laybasic/rdbMarkerBrowserPage.cc +++ b/src/laybasic/laybasic/rdbMarkerBrowserPage.cc @@ -1603,7 +1603,7 @@ MarkerBrowserPage::~MarkerBrowserPage () } void -MarkerBrowserPage::set_plugin_root (lay::PluginRoot *pr) +MarkerBrowserPage::set_dispatcher (lay::Dispatcher *pr) { mp_plugin_root = pr; } diff --git a/src/laybasic/laybasic/rdbMarkerBrowserPage.h b/src/laybasic/laybasic/rdbMarkerBrowserPage.h index 4e69c3ef7..596685614 100644 --- a/src/laybasic/laybasic/rdbMarkerBrowserPage.h +++ b/src/laybasic/laybasic/rdbMarkerBrowserPage.h @@ -37,7 +37,7 @@ namespace lay { class LayoutView; class DMarker; - class PluginRoot; + class Dispatcher; } namespace rdb @@ -68,7 +68,7 @@ public: /** * @brief Sets the plugin root object for this object */ - void set_plugin_root (lay::PluginRoot *pr); + void set_dispatcher (lay::Dispatcher *pr); /** * @brief Attach the page to a view @@ -206,7 +206,7 @@ private: Qt::SortOrder m_marker_list_sort_order; int m_directory_tree_sorted_section; Qt::SortOrder m_directory_tree_sort_order; - lay::PluginRoot *mp_plugin_root; + lay::Dispatcher *mp_plugin_root; tl::DeferredMethod dm_rerun_macro; void release_markers (); From fa1b98c9335b167f3985889696abb49232a083cb Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Fri, 7 Feb 2020 01:11:23 +0100 Subject: [PATCH 11/32] WIP: refactoring ongoing. --- src/ant/ant/antConfigPage.cc | 17 +++--- src/ant/ant/antConfigPage.h | 16 +++--- src/ant/ant/antPlugin.cc | 24 ++++---- src/ant/ant/antPlugin.h | 6 +- src/edt/edt/edtEditorOptionsPages.cc | 4 +- src/edt/edt/edtEditorOptionsPages.h | 10 ++-- src/edt/edt/edtMainService.cc | 2 +- src/edt/edt/edtMainService.h | 6 +- src/edt/edt/edtPartialService.cc | 2 +- src/edt/edt/edtPartialService.h | 6 +- src/edt/edt/edtPlugin.cc | 83 ++++++++++++++-------------- src/edt/edt/edtPlugin.h | 4 +- src/edt/edt/edtService.cc | 4 +- src/edt/edt/edtServiceImpl.cc | 10 ++-- src/img/img/imgPlugin.cc | 2 +- src/img/img/imgPlugin.h | 2 +- src/lay/lay/layApplication.cc | 62 ++++++++++----------- src/lay/lay/layApplication.h | 12 ++-- src/lay/lay/layClipDialog.cc | 4 +- src/lay/lay/layClipDialog.h | 2 +- src/lay/lay/layFillDialog.cc | 4 +- src/lay/lay/layMacroEditorDialog.h | 4 +- 22 files changed, 143 insertions(+), 143 deletions(-) diff --git a/src/ant/ant/antConfigPage.cc b/src/ant/ant/antConfigPage.cc index ca06d1b93..64c07fcae 100644 --- a/src/ant/ant/antConfigPage.cc +++ b/src/ant/ant/antConfigPage.cc @@ -28,6 +28,7 @@ #include "ui_RulerConfigPage4.h" #include "antConfig.h" #include "layConverters.h" +#include "layDispatcher.h" #include "layQtTools.h" #include "tlExceptions.h" @@ -53,7 +54,7 @@ ConfigPage::~ConfigPage () } void -ConfigPage::setup (lay::PluginRoot *root) +ConfigPage::setup (lay::Dispatcher *root) { // Snap range int snap_range = 0; @@ -69,7 +70,7 @@ ConfigPage::setup (lay::PluginRoot *root) } void -ConfigPage::commit (lay::PluginRoot *root) +ConfigPage::commit (lay::Dispatcher *root) { root->config_set (cfg_ruler_obj_snap, mp_ui->ruler_obj_snap_cbx->isChecked ()); root->config_set (cfg_ruler_grid_snap, mp_ui->ruler_grid_snap_cbx->isChecked ()); @@ -99,7 +100,7 @@ ConfigPage2::~ConfigPage2 () } void -ConfigPage2::setup (lay::PluginRoot *root) +ConfigPage2::setup (lay::Dispatcher *root) { // Max. number of rulers int max_number_of_rulers = -1; @@ -122,7 +123,7 @@ ConfigPage2::setup (lay::PluginRoot *root) } void -ConfigPage2::commit (lay::PluginRoot *root) +ConfigPage2::commit (lay::Dispatcher *root) { int mr; try { @@ -153,7 +154,7 @@ ConfigPage3::~ConfigPage3 () } void -ConfigPage3::setup (lay::PluginRoot *root) +ConfigPage3::setup (lay::Dispatcher *root) { // snap mode lay::angle_constraint_type rm = lay::AC_Any; @@ -166,7 +167,7 @@ ConfigPage3::setup (lay::PluginRoot *root) } void -ConfigPage3::commit (lay::PluginRoot *root) +ConfigPage3::commit (lay::Dispatcher *root) { lay::angle_constraint_type rm = lay::AC_Any; if (mp_ui->ruler_any_angle_rb->isChecked ()) { @@ -215,7 +216,7 @@ ConfigPage4::~ConfigPage4 () } void -ConfigPage4::setup (lay::PluginRoot *root) +ConfigPage4::setup (lay::Dispatcher *root) { // templates root->config_get (cfg_ruler_templates, m_ruler_templates, TemplatesConverter ()); @@ -236,7 +237,7 @@ ConfigPage4::setup (lay::PluginRoot *root) } void -ConfigPage4::commit (lay::PluginRoot *root) +ConfigPage4::commit (lay::Dispatcher *root) { commit (); diff --git a/src/ant/ant/antConfigPage.h b/src/ant/ant/antConfigPage.h index 9142b4d7e..fe5853948 100644 --- a/src/ant/ant/antConfigPage.h +++ b/src/ant/ant/antConfigPage.h @@ -50,8 +50,8 @@ public: ConfigPage (QWidget *parent); ~ConfigPage (); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); private: Ui::RulerConfigPage *mp_ui; @@ -69,8 +69,8 @@ public: ConfigPage2 (QWidget *parent); ~ConfigPage2 (); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); private: Ui::RulerConfigPage2 *mp_ui; @@ -88,8 +88,8 @@ public: ConfigPage3 (QWidget *parent); ~ConfigPage3 (); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); private: Ui::RulerConfigPage3 *mp_ui; @@ -107,8 +107,8 @@ public: ConfigPage4 (QWidget *parent); ~ConfigPage4 (); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); public slots: void add_clicked (); diff --git a/src/ant/ant/antPlugin.cc b/src/ant/ant/antPlugin.cc index 5a9391fff..67de17128 100644 --- a/src/ant/ant/antPlugin.cc +++ b/src/ant/ant/antPlugin.cc @@ -23,9 +23,9 @@ #include "layPlugin.h" #include "layAbstractMenu.h" -#include "layAbstractMenuProvider.h" #include "layConverters.h" #include "layConfigurationDialog.h" +#include "layDispatcher.h" #include "antConfigPage.h" #include "antConfig.h" #include "antPlugin.h" @@ -85,13 +85,13 @@ void PluginDeclaration::get_menu_entries (std::vector &menu_entries) const { lay::PluginDeclaration::get_menu_entries (menu_entries); - menu_entries.push_back (lay::MenuEntry ("rulers_group", "edit_menu.end")); - menu_entries.push_back (lay::MenuEntry ("ant::clear_all_rulers", "clear_all_rulers:edit", "edit_menu.end", tl::to_string (QObject::tr ("Clear All Rulers And Annotations(Ctrl+K)")))); - menu_entries.push_back (lay::MenuEntry ("ant::configure", "configure_rulers", "edit_menu.end", tl::to_string (QObject::tr ("Ruler And Annotation Setup")))); + menu_entries.push_back (lay::separator ("rulers_group", "edit_menu.end")); + menu_entries.push_back (lay::menu_item ("ant::clear_all_rulers", "clear_all_rulers:edit", "edit_menu.end", tl::to_string (QObject::tr ("Clear All Rulers And Annotations(Ctrl+K)")))); + menu_entries.push_back (lay::menu_item ("ant::configure", "configure_rulers", "edit_menu.end", tl::to_string (QObject::tr ("Ruler And Annotation Setup")))); } lay::Plugin * -PluginDeclaration::create_plugin (db::Manager *manager, lay::PluginRoot *, lay::LayoutView *view) const +PluginDeclaration::create_plugin (db::Manager *manager, lay::Dispatcher *, lay::LayoutView *view) const { return new ant::Service (manager, view); } @@ -101,7 +101,7 @@ PluginDeclaration::menu_activated (const std::string &symbol) const { if (symbol == "ant::configure") { - lay::ConfigurationDialog config_dialog (QApplication::activeWindow (), lay::PluginRoot::instance (), "ant::Plugin"); + lay::ConfigurationDialog config_dialog (QApplication::activeWindow (), lay::Dispatcher::instance (), "ant::Plugin"); config_dialog.exec (); return true; @@ -165,7 +165,7 @@ PluginDeclaration::config_finalize () } void -PluginDeclaration::initialized (lay::PluginRoot *root) +PluginDeclaration::initialized (lay::Dispatcher *root) { // Check if we already have templates (initial setup) bool any_templates = false; @@ -201,7 +201,7 @@ PluginDeclaration::initialized (lay::PluginRoot *root) } void -PluginDeclaration::uninitialize (lay::PluginRoot *) +PluginDeclaration::uninitialize (lay::Dispatcher *) { for (std::vector::iterator a = m_actions.begin (); a != m_actions.end (); ++a) { delete *a; @@ -212,7 +212,7 @@ PluginDeclaration::uninitialize (lay::PluginRoot *) void PluginDeclaration::update_current_template () { - lay::AbstractMenuProvider *mp = lay::AbstractMenuProvider::instance (); + lay::Dispatcher *mp = lay::Dispatcher::instance (); if (! mp || ! mp->menu ()) { return; } @@ -238,7 +238,7 @@ PluginDeclaration::update_current_template () void PluginDeclaration::update_menu () { - lay::AbstractMenuProvider *mp = lay::AbstractMenuProvider::instance (); + lay::Dispatcher *mp = lay::Dispatcher::instance (); if (! mp || ! mp->menu ()) { return; } @@ -296,8 +296,8 @@ PluginDeclaration::register_annotation_template (const ant::Template &t) } m_templates.push_back (t); - lay::PluginRoot::instance ()->config_set (cfg_ruler_templates, ant::TemplatesConverter ().to_string (m_templates)); - lay::PluginRoot::instance ()->config_end (); + lay::Dispatcher::instance ()->config_set (cfg_ruler_templates, ant::TemplatesConverter ().to_string (m_templates)); + lay::Dispatcher::instance ()->config_end (); } static tl::RegisteredClass config_decl (new ant::PluginDeclaration (), 3000, "ant::Plugin"); diff --git a/src/ant/ant/antPlugin.h b/src/ant/ant/antPlugin.h index 01f96b0c1..4201d9e82 100644 --- a/src/ant/ant/antPlugin.h +++ b/src/ant/ant/antPlugin.h @@ -40,14 +40,14 @@ public: virtual void get_options (std::vector < std::pair > &options) const; virtual void get_menu_entries (std::vector &menu_entries) const; - virtual lay::Plugin *create_plugin (db::Manager *manager, lay::PluginRoot *, lay::LayoutView *view) const; + virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *, lay::LayoutView *view) const; virtual bool implements_editable (std::string &title) const; virtual bool implements_mouse_mode (std::string &title) const; virtual bool configure (const std::string &name, const std::string &value); virtual std::vector > config_pages (QWidget *parent) const; virtual void config_finalize (); - virtual void initialized (lay::PluginRoot *); - virtual void uninitialize (lay::PluginRoot *); + virtual void initialized (lay::Dispatcher *); + virtual void uninitialize (lay::Dispatcher *); virtual bool menu_activated (const std::string &symbol) const; void register_annotation_template (const ant::Template &t); diff --git a/src/edt/edt/edtEditorOptionsPages.cc b/src/edt/edt/edtEditorOptionsPages.cc index 47fd33bef..bd1940467 100644 --- a/src/edt/edt/edtEditorOptionsPages.cc +++ b/src/edt/edt/edtEditorOptionsPages.cc @@ -87,7 +87,7 @@ struct EOPCompareOp } }; -EditorOptionsPages::EditorOptionsPages (const std::vector &pages, lay::PluginRoot *root) +EditorOptionsPages::EditorOptionsPages (const std::vector &pages, lay::Dispatcher *root) : mp_root (root) { mp_ui = new Ui::EditorOptionsDialog (); @@ -515,7 +515,7 @@ EditorOptionsPath::setup (lay::Plugin *root) // ------------------------------------------------------------------ // EditorOptionsInst implementation -EditorOptionsInst::EditorOptionsInst (lay::PluginRoot *root) +EditorOptionsInst::EditorOptionsInst (lay::Dispatcher *root) : QWidget (), EditorOptionsPage (), mp_root (root), mp_pcell_parameters (0) { mp_ui = new Ui::EditorOptionsInst (); diff --git a/src/edt/edt/edtEditorOptionsPages.h b/src/edt/edt/edtEditorOptionsPages.h index 17ca75690..65145212f 100644 --- a/src/edt/edt/edtEditorOptionsPages.h +++ b/src/edt/edt/edtEditorOptionsPages.h @@ -44,7 +44,7 @@ namespace Ui namespace lay { class PluginDeclaration; - class PluginRoot; + class Dispatcher; class Plugin; } @@ -92,7 +92,7 @@ class EditorOptionsPages Q_OBJECT public: - EditorOptionsPages (const std::vector &pages, lay::PluginRoot *root); + EditorOptionsPages (const std::vector &pages, lay::Dispatcher *root); ~EditorOptionsPages (); void unregister_page (edt::EditorOptionsPage *page); @@ -106,7 +106,7 @@ public slots: private: std::vector m_pages; Ui::EditorOptionsDialog *mp_ui; - lay::PluginRoot *mp_root; + lay::Dispatcher *mp_root; void update (edt::EditorOptionsPage *page); void do_apply (); @@ -195,7 +195,7 @@ class EditorOptionsInst Q_OBJECT public: - EditorOptionsInst (lay::PluginRoot *root); + EditorOptionsInst (lay::Dispatcher *root); ~EditorOptionsInst (); virtual QWidget *q_frame () { return this; } @@ -214,7 +214,7 @@ public slots: private: Ui::EditorOptionsInst *mp_ui; - lay::PluginRoot *mp_root; + lay::Dispatcher *mp_root; edt::PCellParametersPage *mp_pcell_parameters; int m_cv_index; diff --git a/src/edt/edt/edtMainService.cc b/src/edt/edt/edtMainService.cc index 3c225096b..a5068438c 100644 --- a/src/edt/edt/edtMainService.cc +++ b/src/edt/edt/edtMainService.cc @@ -48,7 +48,7 @@ namespace edt // ----------------------------------------------------------------------------- // Main Service implementation -MainService::MainService (db::Manager *manager, lay::LayoutView *view, lay::PluginRoot *root) +MainService::MainService (db::Manager *manager, lay::LayoutView *view, lay::Dispatcher *root) : lay::Plugin (view), lay::Editable (view), db::Object (manager), diff --git a/src/edt/edt/edtMainService.h b/src/edt/edt/edtMainService.h index c81fa7177..743d8a9f4 100644 --- a/src/edt/edt/edtMainService.h +++ b/src/edt/edt/edtMainService.h @@ -38,7 +38,7 @@ #include namespace lay { - class PluginRoot; + class Dispatcher; class FlattenInstOptionsDialog; } @@ -63,7 +63,7 @@ public: /** * @brief The constructor */ - MainService (db::Manager *manager, lay::LayoutView *view, lay::PluginRoot *root); + MainService (db::Manager *manager, lay::LayoutView *view, lay::Dispatcher *root); /** * @brief The destructor @@ -196,7 +196,7 @@ public: private: // The layout view that this service is attached to lay::LayoutView *mp_view; - lay::PluginRoot *mp_root; + lay::Dispatcher *mp_root; bool m_needs_update; // options diff --git a/src/edt/edt/edtPartialService.cc b/src/edt/edt/edtPartialService.cc index d4feedf38..f66da5b94 100644 --- a/src/edt/edt/edtPartialService.cc +++ b/src/edt/edt/edtPartialService.cc @@ -1007,7 +1007,7 @@ PartialShapeFinder::visit_cell (const db::Cell &cell, const db::Box &search_box, // ----------------------------------------------------------------------------- // Main Service implementation -PartialService::PartialService (db::Manager *manager, lay::LayoutView *view, lay::PluginRoot *root) +PartialService::PartialService (db::Manager *manager, lay::LayoutView *view, lay::Dispatcher *root) : QObject (), lay::ViewService (view->view_object_widget ()), lay::Editable (view), diff --git a/src/edt/edt/edtPartialService.h b/src/edt/edt/edtPartialService.h index 0df2bb880..2c22ac21c 100644 --- a/src/edt/edt/edtPartialService.h +++ b/src/edt/edt/edtPartialService.h @@ -44,7 +44,7 @@ namespace db { } namespace lay { - class PluginRoot; + class Dispatcher; class Marker; class InstanceMarker; } @@ -153,7 +153,7 @@ public: /** * @brief The constructor */ - PartialService (db::Manager *manager, lay::LayoutView *view, lay::PluginRoot *root); + PartialService (db::Manager *manager, lay::LayoutView *view, lay::Dispatcher *root); /** * @brief The destructor @@ -288,7 +288,7 @@ protected: private: // The layout view that this service is attached to lay::LayoutView *mp_view; - lay::PluginRoot *mp_root; + lay::Dispatcher *mp_root; bool m_dragging; bool m_keep_selection; db::DPoint m_start, m_current; diff --git a/src/edt/edt/edtPlugin.cc b/src/edt/edt/edtPlugin.cc index 38c2c9fd4..9508c09f3 100644 --- a/src/edt/edt/edtPlugin.cc +++ b/src/edt/edt/edtPlugin.cc @@ -22,7 +22,6 @@ #include "layTipDialog.h" -#include "layAbstractMenuProvider.h" #include "edtPlugin.h" #include "edtConfig.h" #include "edtService.h" @@ -46,7 +45,7 @@ void get_text_options (std::vector < std::pair > &opti } static -void get_text_editor_options_pages (std::vector &ret, lay::PluginRoot *) +void get_text_editor_options_pages (std::vector &ret, lay::Dispatcher *) { ret.push_back (new edt::EditorOptionsText ()); } @@ -61,7 +60,7 @@ void get_path_options (std::vector < std::pair > &opti } static -void get_path_editor_options_pages (std::vector &ret, lay::PluginRoot *) +void get_path_editor_options_pages (std::vector &ret, lay::Dispatcher *) { ret.push_back (new EditorOptionsPath ()); } @@ -86,7 +85,7 @@ void get_inst_options (std::vector < std::pair > &opti } static -void get_inst_editor_options_pages (std::vector &ret, lay::PluginRoot *root) +void get_inst_editor_options_pages (std::vector &ret, lay::Dispatcher *root) { ret.push_back (new EditorOptionsInst (root)); } @@ -98,7 +97,7 @@ class PluginDeclaration public: PluginDeclaration (const std::string &title, const std::string &mouse_mode, void (*option_get_f) (std::vector < std::pair > &) = 0, - void (*pages_f) (std::vector &, lay::PluginRoot *) = 0) + void (*pages_f) (std::vector &, lay::Dispatcher *) = 0) : m_title (title), m_mouse_mode (mouse_mode), mp_option_get_f (option_get_f), mp_pages_f (pages_f) { // .. nothing yet .. @@ -121,7 +120,7 @@ public: // .. nothing yet .. } - virtual void get_editor_options_pages (std::vector &pages, lay::PluginRoot *root) const + virtual void get_editor_options_pages (std::vector &pages, lay::Dispatcher *root) const { if (mp_pages_f != 0) { size_t nstart = pages.size (); @@ -132,7 +131,7 @@ public: } } - virtual lay::Plugin *create_plugin (db::Manager *manager, lay::PluginRoot *, lay::LayoutView *view) const + virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *, lay::LayoutView *view) const { Svc *service = new Svc (manager, view); service->set_plugin_declaration (this); @@ -156,7 +155,7 @@ private: std::string m_mouse_mode; void (*mp_option_get_f) (std::vector < std::pair > &options); - void (*mp_pages_f) (std::vector &, lay::PluginRoot *); + void (*mp_pages_f) (std::vector &, lay::Dispatcher *); }; static tl::RegisteredClass config_decl1 ( @@ -215,33 +214,33 @@ public: { lay::PluginDeclaration::get_menu_entries (menu_entries); - menu_entries.push_back (lay::MenuEntry ("edt::hier_group", "zoom_menu.end")); - menu_entries.push_back (lay::MenuEntry ("edt::descend", "descend", "zoom_menu.end", tl::to_string (QObject::tr ("Descend")) + "(Ctrl+D)")); - menu_entries.push_back (lay::MenuEntry ("edt::ascend", "ascend", "zoom_menu.end", tl::to_string (QObject::tr ("Ascend")) + "(Ctrl+A)")); + menu_entries.push_back (lay::separator ("edt::hier_group", "zoom_menu.end")); + menu_entries.push_back (lay::menu_item ("edt::descend", "descend", "zoom_menu.end", tl::to_string (QObject::tr ("Descend")) + "(Ctrl+D)")); + menu_entries.push_back (lay::menu_item ("edt::ascend", "ascend", "zoom_menu.end", tl::to_string (QObject::tr ("Ascend")) + "(Ctrl+A)")); - menu_entries.push_back (lay::MenuEntry ("edit_options_group:edit_mode", "edit_menu.end")); - menu_entries.push_back (lay::MenuEntry ("edt::edit_options", "edit_options:edit_mode", "edit_menu.end", tl::to_string (QObject::tr ("Editor Options")) + "(F3)")); - menu_entries.push_back (lay::MenuEntry ("edt::sel_make_array", "make_array:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Make Array")))); - menu_entries.push_back (lay::MenuEntry ("selection_group:edit_mode", "edit_menu.selection_menu.end")); - menu_entries.push_back (lay::MenuEntry ("edt::sel_change_layer", "change_layer:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Change Layer")))); - menu_entries.push_back (lay::MenuEntry ("edt::sel_tap", "tap:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Tap")) + "(T)")); - menu_entries.push_back (lay::MenuEntry ("edt::sel_align", "align:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Align")))); - menu_entries.push_back (lay::MenuEntry ("edt::sel_round_corners", "round_corners:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Round Corners")))); - menu_entries.push_back (lay::MenuEntry ("edt::sel_size", "size:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Size Shapes")))); - menu_entries.push_back (lay::MenuEntry ("edt::sel_union", "union:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Merge Shapes")))); - menu_entries.push_back (lay::MenuEntry ("edt::sel_intersection", "intersection:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Intersection - Others With First")))); - menu_entries.push_back (lay::MenuEntry ("edt::sel_difference", "difference:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Subtraction - Others From First")))); - menu_entries.push_back (lay::MenuEntry ("edt::sel_separate", "separate:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Separate - First into Inside/Outside Others")))); - menu_entries.push_back (lay::MenuEntry ("hier_group:edit_mode", "edit_menu.selection_menu.end")); - menu_entries.push_back (lay::MenuEntry ("edt::sel_flatten_insts", "flatten_insts:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Flatten Instances")))); - menu_entries.push_back (lay::MenuEntry ("edt::sel_resolve_arefs", "resolve_arefs:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Resolve Arrays")))); - menu_entries.push_back (lay::MenuEntry ("edt::sel_move_hier_up", "move_hier_up:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Move Up In Hierarchy")))); - menu_entries.push_back (lay::MenuEntry ("edt::sel_make_cell", "make_cell:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Make Cell")))); - menu_entries.push_back (lay::MenuEntry ("edt::sel_make_cell_variants", "make_cell_variants:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Make Cell Variants")))); - menu_entries.push_back (lay::MenuEntry ("edt::sel_convert_to_pcell", "convert_to_pcell:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Convert To PCell")))); - menu_entries.push_back (lay::MenuEntry ("edt::sel_convert_to_cell", "convert_to_cell:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Convert To Static Cell")))); + menu_entries.push_back (lay::separator ("edit_options_group:edit_mode", "edit_menu.end")); + menu_entries.push_back (lay::menu_item ("edt::edit_options", "edit_options:edit_mode", "edit_menu.end", tl::to_string (QObject::tr ("Editor Options")) + "(F3)")); + menu_entries.push_back (lay::menu_item ("edt::sel_make_array", "make_array:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Make Array")))); + menu_entries.push_back (lay::separator ("selection_group:edit_mode", "edit_menu.selection_menu.end")); + menu_entries.push_back (lay::menu_item ("edt::sel_change_layer", "change_layer:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Change Layer")))); + menu_entries.push_back (lay::menu_item ("edt::sel_tap", "tap:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Tap")) + "(T)")); + menu_entries.push_back (lay::menu_item ("edt::sel_align", "align:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Align")))); + menu_entries.push_back (lay::menu_item ("edt::sel_round_corners", "round_corners:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Round Corners")))); + menu_entries.push_back (lay::menu_item ("edt::sel_size", "size:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Size Shapes")))); + menu_entries.push_back (lay::menu_item ("edt::sel_union", "union:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Merge Shapes")))); + menu_entries.push_back (lay::menu_item ("edt::sel_intersection", "intersection:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Intersection - Others With First")))); + menu_entries.push_back (lay::menu_item ("edt::sel_difference", "difference:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Subtraction - Others From First")))); + menu_entries.push_back (lay::menu_item ("edt::sel_separate", "separate:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Separate - First into Inside/Outside Others")))); + menu_entries.push_back (lay::separator ("hier_group:edit_mode", "edit_menu.selection_menu.end")); + menu_entries.push_back (lay::menu_item ("edt::sel_flatten_insts", "flatten_insts:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Flatten Instances")))); + menu_entries.push_back (lay::menu_item ("edt::sel_resolve_arefs", "resolve_arefs:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Resolve Arrays")))); + menu_entries.push_back (lay::menu_item ("edt::sel_move_hier_up", "move_hier_up:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Move Up In Hierarchy")))); + menu_entries.push_back (lay::menu_item ("edt::sel_make_cell", "make_cell:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Make Cell")))); + menu_entries.push_back (lay::menu_item ("edt::sel_make_cell_variants", "make_cell_variants:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Make Cell Variants")))); + menu_entries.push_back (lay::menu_item ("edt::sel_convert_to_pcell", "convert_to_pcell:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Convert To PCell")))); + menu_entries.push_back (lay::menu_item ("edt::sel_convert_to_cell", "convert_to_cell:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Convert To Static Cell")))); - menu_entries.push_back (lay::MenuEntry ("edt::combine_mode", "combine_mode:edit_mode", "@toolbar.end_modes", tl::to_string (QObject::tr ("Combine{Select background combination mode}")))); + menu_entries.push_back (lay::menu_item ("edt::combine_mode", "combine_mode:edit_mode", "@toolbar.end_modes", tl::to_string (QObject::tr ("Combine{Select background combination mode}")))); } bool configure (const std::string &name, const std::string &value) @@ -255,7 +254,7 @@ public: return false; } - virtual lay::Plugin *create_plugin (db::Manager *manager, lay::PluginRoot *root, lay::LayoutView *view) const + virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *root, lay::LayoutView *view) const { return new edt::MainService (manager, view, root); } @@ -270,9 +269,9 @@ public: return false; } - virtual void initialize (lay::PluginRoot *root) + virtual void initialize (lay::Dispatcher *root) { - lay::AbstractMenuProvider *mp = lay::AbstractMenuProvider::instance (); + lay::Dispatcher *mp = lay::Dispatcher::instance (); if (! mp || ! mp->menu ()) { return; } @@ -311,7 +310,7 @@ public: void update_menu (combine_mode_type cm) { - lay::AbstractMenuProvider *mp = lay::AbstractMenuProvider::instance (); + lay::Dispatcher *mp = lay::Dispatcher::instance (); if (! mp || ! mp->menu ()) { return; } @@ -336,7 +335,7 @@ public: } } - virtual void uninitialize (lay::PluginRoot *) + virtual void uninitialize (lay::Dispatcher *) { if (mp_obj_prop_dialog) { delete mp_obj_prop_dialog; @@ -372,9 +371,9 @@ public: } } - void initialized (lay::PluginRoot *root) + void initialized (lay::Dispatcher *root) { - lay::AbstractMenuProvider *mp = lay::AbstractMenuProvider::instance (); + lay::Dispatcher *mp = lay::Dispatcher::instance (); if (! mp || ! mp->menu ()) { return; } @@ -398,7 +397,7 @@ public: } private: - lay::PluginRoot *mp_root; + lay::Dispatcher *mp_root; std::string m_title; edt::EditorOptionsPages *mp_obj_prop_dialog; std::vector m_prop_dialog_pages; @@ -447,7 +446,7 @@ public: // .. nothing yet .. } - virtual lay::Plugin *create_plugin (db::Manager *manager, lay::PluginRoot *root, lay::LayoutView *view) const + virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *root, lay::LayoutView *view) const { return new edt::PartialService (manager, view, root); } diff --git a/src/edt/edt/edtPlugin.h b/src/edt/edt/edtPlugin.h index 50c46658b..f75dec8dd 100644 --- a/src/edt/edt/edtPlugin.h +++ b/src/edt/edt/edtPlugin.h @@ -30,7 +30,7 @@ namespace lay { - class PluginRoot; + class Dispatcher; } namespace edt @@ -44,7 +44,7 @@ namespace edt : public lay::PluginDeclaration { public: - virtual void get_editor_options_pages (std::vector &, lay::PluginRoot *) const = 0; + virtual void get_editor_options_pages (std::vector &, lay::Dispatcher *) const = 0; }; /** diff --git a/src/edt/edt/edtService.cc b/src/edt/edt/edtService.cc index 813f778d1..0e5986b5c 100644 --- a/src/edt/edt/edtService.cc +++ b/src/edt/edt/edtService.cc @@ -334,8 +334,8 @@ Service::copy_selected () // store the given value "forever" if (dont_ask_again) { - plugin_root ()->config_set (cfg_edit_hier_copy_mode, tl::to_string (inst_mode)); - plugin_root ()->config_end (); + dispatcher ()->config_set (cfg_edit_hier_copy_mode, tl::to_string (inst_mode)); + dispatcher ()->config_end (); } // create one ClipboardData object per cv_index because, this one assumes that there is diff --git a/src/edt/edt/edtServiceImpl.cc b/src/edt/edt/edtServiceImpl.cc index 6bdd2f8ac..691bff357 100644 --- a/src/edt/edt/edtServiceImpl.cc +++ b/src/edt/edt/edtServiceImpl.cc @@ -1282,14 +1282,14 @@ 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); + dispatcher ()->config_set (cfg_edit_inst_lib_name, m_lib_name); + dispatcher ()->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)); + dispatcher ()->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 ()); + dispatcher ()->config_set (cfg_edit_inst_pcell_parameters, std::string ()); } - plugin_root ()->config_end (); + dispatcher ()->config_end (); } void diff --git a/src/img/img/imgPlugin.cc b/src/img/img/imgPlugin.cc index 89de45ea9..48dfe7a5c 100644 --- a/src/img/img/imgPlugin.cc +++ b/src/img/img/imgPlugin.cc @@ -42,7 +42,7 @@ PluginDeclaration::get_menu_entries (std::vector &menu_entries) } lay::Plugin * -PluginDeclaration::create_plugin (db::Manager *manager, lay::PluginRoot *, lay::LayoutView *view) const +PluginDeclaration::create_plugin (db::Manager *manager, lay::Dispatcher *, lay::LayoutView *view) const { return new img::Service (manager, view); } diff --git a/src/img/img/imgPlugin.h b/src/img/img/imgPlugin.h index 95e770615..5c1dcb632 100644 --- a/src/img/img/imgPlugin.h +++ b/src/img/img/imgPlugin.h @@ -39,7 +39,7 @@ public: } virtual void get_menu_entries (std::vector &menu_entries) const; - virtual lay::Plugin *create_plugin (db::Manager *manager, lay::PluginRoot *, lay::LayoutView *view) const; + virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *, lay::LayoutView *view) const; virtual bool implements_editable (std::string &title) const; }; diff --git a/src/lay/lay/layApplication.cc b/src/lay/lay/layApplication.cc index 33f7dc0c4..f7fd82d16 100644 --- a/src/lay/lay/layApplication.cc +++ b/src/lay/lay/layApplication.cc @@ -605,7 +605,7 @@ ApplicationBase::init_app () bool editable_from_config = false; { - lay::PluginRoot cfg; + lay::Dispatcher cfg; for (std::vector ::const_iterator c = m_config_files.begin (); c != m_config_files.end (); ++c) { try { @@ -770,11 +770,11 @@ ApplicationBase::init_app () if (tl::verbosity () >= 20) { tl::info << " " << cls.current_name () << " [" << cls.current_position () << "]"; } - pd->initialize (plugin_root ()); + pd->initialize (dispatcher ()); } // establish the configuration - plugin_root ()->config_setup (); + dispatcher ()->config_setup (); // Some info output if (tl::verbosity () >= 20) { @@ -862,7 +862,7 @@ ApplicationBase::exit (int result) // uninitialize the plugins for (tl::Registrar::iterator cls = tl::Registrar::begin (); cls != tl::Registrar::end (); ++cls) { lay::PluginDeclaration *pd = const_cast (&*cls); - pd->uninitialize (plugin_root ()); + pd->uninitialize (dispatcher ()); } shutdown (); @@ -873,13 +873,13 @@ ApplicationBase::exit (int result) void ApplicationBase::finish () { - if (plugin_root () && m_write_config_file) { + if (dispatcher () && m_write_config_file) { if (! m_config_file_to_write.empty ()) { if (tl::verbosity () >= 20) { tl::info << tl::to_string (QObject::tr ("Updating configuration file ")) << m_config_file_to_write; } - plugin_root ()->write_config (m_config_file_to_write); + dispatcher ()->write_config (m_config_file_to_write); } if (! m_config_file_to_delete.empty () && m_config_file_to_delete != m_config_file_to_write) { if (tl::verbosity () >= 20) { @@ -1008,7 +1008,7 @@ ApplicationBase::run () for (std::vector ::const_iterator c = m_config_files.begin (); c != m_config_files.end (); ++c) { BEGIN_PROTECTED_CLEANUP - plugin_root ()->read_config (*c); + dispatcher ()->read_config (*c); // if the last config was read successfully no reset will happen: config_failed = false; END_PROTECTED_CLEANUP { @@ -1130,7 +1130,7 @@ ApplicationBase::run () // Give the plugins a change to do some last-minute initialisation and checks for (tl::Registrar::iterator cls = tl::Registrar::begin (); cls != tl::Registrar::end (); ++cls) { lay::PluginDeclaration *pd = const_cast (&*cls); - pd->initialized (plugin_root ()); + pd->initialized (dispatcher ()); } if (! m_no_gui && m_gtf_replay.empty () && m_gtf_record.empty ()) { @@ -1138,12 +1138,12 @@ ApplicationBase::run () mw->about_to_exec (); } - } else if (plugin_root ()) { + } else if (dispatcher ()) { // Give the plugins a change to do some last-minute initialisation and checks for (tl::Registrar::iterator cls = tl::Registrar::begin (); cls != tl::Registrar::end (); ++cls) { lay::PluginDeclaration *pd = const_cast (&*cls); - pd->initialized (plugin_root ()); + pd->initialized (dispatcher ()); } } @@ -1218,7 +1218,7 @@ ApplicationBase::process_events_impl (QEventLoop::ProcessEventsFlags /*flags*/, bool ApplicationBase::write_config (const std::string &config_file) { - return plugin_root () ? plugin_root ()->write_config (config_file) : 0; + return dispatcher () ? dispatcher ()->write_config (config_file) : 0; } void @@ -1235,38 +1235,38 @@ ApplicationBase::reset_config () void ApplicationBase::clear_config () { - if (plugin_root ()) { - plugin_root ()->clear_config (); + if (dispatcher ()) { + dispatcher ()->clear_config (); } } bool ApplicationBase::read_config (const std::string &config_file) { - return plugin_root () ? plugin_root ()->read_config (config_file) : true; + return dispatcher () ? dispatcher ()->read_config (config_file) : true; } void ApplicationBase::set_config (const std::string &name, const std::string &value) { - if (plugin_root ()) { - plugin_root ()->config_set (name, value); + if (dispatcher ()) { + dispatcher ()->config_set (name, value); } } void ApplicationBase::config_end () { - if (plugin_root ()) { - plugin_root ()->config_end (); + if (dispatcher ()) { + dispatcher ()->config_end (); } } std::string ApplicationBase::get_config (const std::string &name) const { - if (plugin_root ()) { - return plugin_root ()->config_get (name); + if (dispatcher ()) { + return dispatcher ()->config_get (name); } else { return std::string (); } @@ -1276,8 +1276,8 @@ std::vector ApplicationBase::get_config_names () const { std::vector names; - if (plugin_root ()) { - plugin_root ()->get_config_names (names); + if (dispatcher ()) { + dispatcher ()->get_config_names (names); } return names; } @@ -1313,7 +1313,7 @@ GuiApplication::~GuiApplication () // uninitialize the plugins for (tl::Registrar::iterator cls = tl::Registrar::begin (); cls != tl::Registrar::end (); ++cls) { lay::PluginDeclaration *pd = const_cast (&*cls); - pd->uninitialize (plugin_root ()); + pd->uninitialize (dispatcher ()); } shutdown (); @@ -1472,8 +1472,8 @@ GuiApplication::start_recording () } } -lay::PluginRoot * -GuiApplication::plugin_root () const +lay::Dispatcher * +GuiApplication::dispatcher () const { return mp_plugin_root; } @@ -1529,7 +1529,7 @@ NonGuiApplication::NonGuiApplication (int &argc, char **argv) : QCoreApplication (argc, argv), ApplicationBase (true), mp_pr (0), mp_pb (0), - mp_plugin_root (0) + mp_dispatcher (0) { // .. nothing yet .. } @@ -1539,7 +1539,7 @@ NonGuiApplication::~NonGuiApplication () // uninitialize the plugins for (tl::Registrar::iterator cls = tl::Registrar::begin (); cls != tl::Registrar::end (); ++cls) { lay::PluginDeclaration *pd = const_cast (&*cls); - pd->uninitialize (plugin_root ()); + pd->uninitialize (dispatcher ()); } shutdown (); @@ -1555,9 +1555,9 @@ NonGuiApplication::exec () void NonGuiApplication::shutdown () { - if (mp_plugin_root) { - delete mp_plugin_root; - mp_plugin_root = 0; + if (mp_dispatcher) { + delete mp_dispatcher; + mp_dispatcher = 0; } if (mp_pr) { @@ -1579,7 +1579,7 @@ NonGuiApplication::setup () mp_pr = new lay::ProgressReporter (); mp_pb = new TextProgress (10 /*verbosity level*/); mp_pr->set_progress_bar (mp_pb); - mp_plugin_root = new lay::PluginRoot (); + mp_dispatcher = new lay::Dispatcher (0); } } diff --git a/src/lay/lay/layApplication.h b/src/lay/lay/layApplication.h index b121138b2..31ef67256 100644 --- a/src/lay/lay/layApplication.h +++ b/src/lay/lay/layApplication.h @@ -58,7 +58,7 @@ namespace lay class MainWindow; class DispatcherToMainWindow; -class PluginRoot; +class Dispatcher; class ProgressReporter; class ProgressBar; @@ -321,7 +321,7 @@ protected: virtual void shutdown (); virtual void prepare_recording (const std::string >f_record, bool gtf_record_incremental); virtual void start_recording (); - virtual lay::PluginRoot *plugin_root () const = 0; + virtual lay::Dispatcher *dispatcher () const = 0; virtual void finish (); virtual void process_events_impl (QEventLoop::ProcessEventsFlags flags, bool silent = false); @@ -441,7 +441,7 @@ protected: virtual void start_recording (); virtual void process_events_impl (QEventLoop::ProcessEventsFlags flags, bool silent); - virtual lay::PluginRoot *plugin_root () const; + virtual lay::Dispatcher *dispatcher () const; private: MainWindow *mp_mw; @@ -493,15 +493,15 @@ protected: virtual void setup (); virtual void shutdown (); - virtual lay::PluginRoot *plugin_root () const + virtual lay::Dispatcher *dispatcher () const { - return mp_plugin_root; + return mp_dispatcher; } private: lay::ProgressReporter *mp_pr; lay::ProgressBar *mp_pb; - lay::PluginRoot *mp_plugin_root; + lay::Dispatcher *mp_dispatcher; }; } // namespace lay diff --git a/src/lay/lay/layClipDialog.cc b/src/lay/lay/layClipDialog.cc index 85e7e58a1..5a0c1da46 100644 --- a/src/lay/lay/layClipDialog.cc +++ b/src/lay/lay/layClipDialog.cc @@ -55,7 +55,7 @@ public: menu_entries.push_back (lay::MenuEntry ("clip_tool::show", "clip_tool:edit_mode", "edit_menu.utils_menu.end", tl::to_string (QObject::tr ("Clip Tool")))); } - virtual lay::Plugin *create_plugin (db::Manager *, lay::PluginRoot *root, lay::LayoutView *view) const + virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutView *view) const { return new ClipDialog (root, view); } @@ -66,7 +66,7 @@ static tl::RegisteredClass config_decl (new ClipDialogPl // ------------------------------------------------------------ -ClipDialog::ClipDialog (lay::PluginRoot *root, lay::LayoutView *vw) +ClipDialog::ClipDialog (lay::Dispatcher *root, lay::LayoutView *vw) : lay::Browser (root, vw), Ui::ClipDialog () { diff --git a/src/lay/lay/layClipDialog.h b/src/lay/lay/layClipDialog.h index 510ba8cd9..fdb50b835 100644 --- a/src/lay/lay/layClipDialog.h +++ b/src/lay/lay/layClipDialog.h @@ -40,7 +40,7 @@ class ClipDialog Q_OBJECT public: - ClipDialog (lay::PluginRoot *root, lay::LayoutView *view); + ClipDialog (lay::Dispatcher *root, lay::LayoutView *view); ~ClipDialog (); public slots: diff --git a/src/lay/lay/layFillDialog.cc b/src/lay/lay/layFillDialog.cc index 8dc072b0a..3abd11490 100644 --- a/src/lay/lay/layFillDialog.cc +++ b/src/lay/lay/layFillDialog.cc @@ -62,7 +62,7 @@ public: menu_entries.push_back (lay::MenuEntry ("fill_tool::show", "fill_tool:edit_mode", "edit_menu.utils_menu.end", tl::to_string (QObject::tr ("Fill Tool")))); } - virtual lay::Plugin *create_plugin (db::Manager *, lay::PluginRoot *root, lay::LayoutView *view) const + virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutView *view) const { return new FillDialog (root, view); } @@ -73,7 +73,7 @@ static tl::RegisteredClass config_decl (new FillDialogPl // ------------------------------------------------------------ -FillDialog::FillDialog (lay::PluginRoot *main, lay::LayoutView *view) +FillDialog::FillDialog (lay::Dispatcher *main, lay::LayoutView *view) : QDialog (view), lay::Plugin (main), Ui::FillDialog (), diff --git a/src/lay/lay/layMacroEditorDialog.h b/src/lay/lay/layMacroEditorDialog.h index 01c588ee6..f2d67320d 100644 --- a/src/lay/lay/layMacroEditorDialog.h +++ b/src/lay/lay/layMacroEditorDialog.h @@ -98,7 +98,7 @@ public: /** * @brief Constructor */ - MacroEditorDialog (lay::PluginRoot *pr, lym::MacroCollection *root); + MacroEditorDialog (lay::Dispatcher *pr, lym::MacroCollection *root); /** * @brief Destructor @@ -289,7 +289,7 @@ private: bool configure (const std::string &name, const std::string &value); void config_finalize (); - lay::PluginRoot *mp_plugin_root; + lay::Dispatcher *mp_plugin_root; lym::MacroCollection *mp_root; bool m_first_show; bool m_in_processing; From 68472e6e149cb35517dfba15e9fbab5a34c16cda Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Fri, 7 Feb 2020 01:27:24 +0100 Subject: [PATCH 12/32] WIP: refactoring ongoing. --- src/img/img/imgLandmarksDialog.cc | 2 +- src/img/img/imgNavigator.cc | 2 +- src/img/img/imgNavigator.h | 4 +- src/img/img/imgPlugin.cc | 12 ++--- src/lay/lay/gsiDeclLayApplication.cc | 24 +++++----- src/lay/lay/layApplication.cc | 2 +- src/lay/lay/layClipDialog.cc | 2 +- src/lay/lay/layFillDialog.cc | 2 +- src/lay/lay/layFillDialog.h | 2 +- src/lay/lay/layFontController.cc | 8 ++-- src/lay/lay/layFontController.h | 8 ++-- src/lay/lay/layLibraryController.cc | 8 ++-- src/lay/lay/layLibraryController.h | 8 ++-- src/lay/lay/layMacroController.cc | 6 +-- src/lay/lay/layMacroEditorDialog.cc | 6 +-- src/lay/lay/layMacroEditorSetupPage.cc | 9 ++-- src/lay/lay/layMacroEditorSetupPage.h | 4 +- src/lay/lay/layMainConfigPages.cc | 32 ++++++------- src/lay/lay/layMainWindow.cc | 2 +- src/lay/lay/laySaltController.cc | 8 ++-- src/lay/lay/laySearchReplaceConfigPage.cc | 5 +- src/lay/lay/laySearchReplaceConfigPage.h | 4 +- src/lay/lay/laySearchReplaceDialog.cc | 12 ++--- src/lay/lay/laySearchReplaceDialog.h | 2 +- src/lay/lay/laySearchReplacePlugin.cc | 8 ++-- .../lay/laySearchReplacePropertiesWidgets.cc | 48 +++++++++---------- .../lay/laySearchReplacePropertiesWidgets.h | 6 +-- src/lay/lay/laySettingsForm.cc | 8 ++-- src/lay/lay/layTechnologyController.cc | 16 +++---- src/laybasic/laybasic/gsiDeclLayPlugin.cc | 2 +- src/laybasic/laybasic/layPlugin.h | 10 ++-- .../laybasic/laySaveLayoutOptionsDialog.h | 1 - src/laybasic/laybasic/layStream.h | 2 +- .../lefdef/lay_plugin/layLEFDEFImport.cc | 6 +-- .../pcb/lay_plugin/layGerberImport.cc | 12 ++--- .../lay_plugin/layBooleanOperationsPlugin.cc | 10 ++-- .../tools/diff/lay_plugin/layDiffPlugin.cc | 8 ++-- .../diff/lay_plugin/layDiffToolDialog.cc | 4 +- .../import/lay_plugin/layStreamImport.cc | 4 +- .../import/lay_plugin/layStreamImportDialog.h | 2 +- .../lay_plugin/layNetTracerConfig.cc | 5 +- .../lay_plugin/layNetTracerConfig.h | 4 +- .../lay_plugin/layNetTracerDialog.cc | 2 +- .../lay_plugin/layNetTracerDialog.h | 2 +- .../lay_plugin/layNetTracerPlugin.cc | 14 +++--- .../tools/xor/lay_plugin/layXORPlugin.cc | 5 +- .../tools/xor/lay_plugin/layXORToolDialog.cc | 4 +- 47 files changed, 179 insertions(+), 178 deletions(-) diff --git a/src/img/img/imgLandmarksDialog.cc b/src/img/img/imgLandmarksDialog.cc index 68d20b1c3..5c56ed768 100644 --- a/src/img/img/imgLandmarksDialog.cc +++ b/src/img/img/imgLandmarksDialog.cc @@ -406,7 +406,7 @@ LandmarksDialog::LandmarksDialog (QWidget *parent, img::Object &img) setupUi (this); - mp_image = navigator->setup (lay::PluginRoot::instance (), &img); + mp_image = navigator->setup (lay::Dispatcher::instance (), &img); connect (new_pb, SIGNAL (clicked ()), this, SLOT (update_mode ())); connect (delete_pb, SIGNAL (clicked ()), this, SLOT (update_mode ())); diff --git a/src/img/img/imgNavigator.cc b/src/img/img/imgNavigator.cc index 20d30b90e..ed65e0132 100644 --- a/src/img/img/imgNavigator.cc +++ b/src/img/img/imgNavigator.cc @@ -48,7 +48,7 @@ Navigator::Navigator (QWidget *parent) } img::Object * -Navigator::setup (lay::PluginRoot *root, img::Object *img) +Navigator::setup (lay::Dispatcher *root, img::Object *img) { mp_view = new lay::LayoutView (0, false, root, this, "img_navigator_view", lay::LayoutView::LV_Naked + lay::LayoutView::LV_NoZoom + lay::LayoutView::LV_NoServices + lay::LayoutView::LV_NoGrid); mp_view->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Expanding); diff --git a/src/img/img/imgNavigator.h b/src/img/img/imgNavigator.h index b9873c7d4..7fb9c7adc 100644 --- a/src/img/img/imgNavigator.h +++ b/src/img/img/imgNavigator.h @@ -28,7 +28,7 @@ namespace lay { - class PluginRoot; + class Dispatcher; class LayoutView; class ZoomService; class ViewService; @@ -52,7 +52,7 @@ public: ~Navigator (); void background_color (QColor c); - img::Object *setup (lay::PluginRoot *root, img::Object *img); + img::Object *setup (lay::Dispatcher *root, img::Object *img); lay::LayoutView *view () { diff --git a/src/img/img/imgPlugin.cc b/src/img/img/imgPlugin.cc index 48dfe7a5c..fa88fe549 100644 --- a/src/img/img/imgPlugin.cc +++ b/src/img/img/imgPlugin.cc @@ -33,12 +33,12 @@ void PluginDeclaration::get_menu_entries (std::vector &menu_entries) const { lay::PluginDeclaration::get_menu_entries (menu_entries); - menu_entries.push_back (lay::MenuEntry ("image_group", "edit_menu.end")); - menu_entries.push_back (lay::MenuEntry ("img::add_image", "add_image:edit", "edit_menu.end", tl::to_string (QObject::tr ("Add Image")))); - menu_entries.push_back (lay::MenuEntry ("img::image_menu", "image_menu:edit", "edit_menu.end", tl::to_string (QObject::tr ("Images")), true)); - menu_entries.push_back (lay::MenuEntry ("img::bring_to_front", "bring_to_front:edit", "edit_menu.image_menu.end", tl::to_string (QObject::tr ("Image Stack: Selected Images to Front")))); - menu_entries.push_back (lay::MenuEntry ("img::bring_to_back", "bring_to_back:edit", "edit_menu.image_menu.end", tl::to_string (QObject::tr ("Image Stack: Selected Images to Back")))); - menu_entries.push_back (lay::MenuEntry ("img::clear_all_images", "clear_all_images:edit", "edit_menu.image_menu.end", tl::to_string (QObject::tr ("Clear All Images")))); + menu_entries.push_back (lay::separator ("image_group", "edit_menu.end")); + menu_entries.push_back (lay::menu_item ("img::add_image", "add_image:edit", "edit_menu.end", tl::to_string (QObject::tr ("Add Image")))); + menu_entries.push_back (lay::submenu ("img::image_menu", "image_menu:edit", "edit_menu.end", tl::to_string (QObject::tr ("Images")))); + menu_entries.push_back (lay::menu_item ("img::bring_to_front", "bring_to_front:edit", "edit_menu.image_menu.end", tl::to_string (QObject::tr ("Image Stack: Selected Images to Front")))); + menu_entries.push_back (lay::menu_item ("img::bring_to_back", "bring_to_back:edit", "edit_menu.image_menu.end", tl::to_string (QObject::tr ("Image Stack: Selected Images to Back")))); + menu_entries.push_back (lay::menu_item ("img::clear_all_images", "clear_all_images:edit", "edit_menu.image_menu.end", tl::to_string (QObject::tr ("Clear All Images")))); } lay::Plugin * diff --git a/src/lay/lay/gsiDeclLayApplication.cc b/src/lay/lay/gsiDeclLayApplication.cc index 585971789..8c325a5ed 100644 --- a/src/lay/lay/gsiDeclLayApplication.cc +++ b/src/lay/lay/gsiDeclLayApplication.cc @@ -90,8 +90,8 @@ static gsi::Methods application_methods () method ("is_editable?", &C::is_editable, "@brief Returns true if the application is in editable mode\n" ) + - // TODO: basically this method belongs to PluginRoot (aka MainWindow). - // There is separate declaration for PluginRoot which we have to synchronize + // TODO: basically this method belongs to Dispatcher (aka MainWindow). + // There is separate declaration for Dispatcher which we have to synchronize // with this method. method ("get_config", &C::get_config, "@brief Gets the value for a configuration parameter\n" @@ -109,8 +109,8 @@ static gsi::Methods application_methods () "to the configuration parameter. The values delivered by this method correspond to the values stored " "in the configuration file " ) + - // TODO: basically this method belongs to PluginRoot (aka MainWindow). - // There is separate declaration for PluginRoot which we have to synchronize + // TODO: basically this method belongs to Dispatcher (aka MainWindow). + // There is separate declaration for Dispatcher which we have to synchronize // with this method. method > ("get_config_names", &C::get_config_names, "@brief Gets the configuration parameter names\n" @@ -120,8 +120,8 @@ static gsi::Methods application_methods () "This method returns the names of all known configuration parameters. These names can be used to " "get and set configuration parameter values." ) + - // TODO: basically this method belongs to PluginRoot (aka MainWindow). - // There is separate declaration for PluginRoot which we have to synchronize + // TODO: basically this method belongs to Dispatcher (aka MainWindow). + // There is separate declaration for Dispatcher which we have to synchronize // with this method. method ("set_config", &C::set_config, "@brief Sets a configuration parameter with the given name to the given value\n" @@ -138,8 +138,8 @@ static gsi::Methods application_methods () "It is possible to write an arbitrary name/value pair into the configuration database which then is " "written to the configuration file." ) + - // TODO: basically this method belongs to PluginRoot (aka MainWindow). - // There is separate declaration for PluginRoot which we have to synchronize + // TODO: basically this method belongs to Dispatcher (aka MainWindow). + // There is separate declaration for Dispatcher which we have to synchronize // with this method. method ("commit_config", &C::config_end, "@brief Commits the configuration settings\n" @@ -150,8 +150,8 @@ static gsi::Methods application_methods () "\n" "This method has been introduced in version 0.25.\n" ) + - // TODO: basically this method belongs to PluginRoot (aka MainWindow). - // There is separate declaration for PluginRoot which we have to synchronize + // TODO: basically this method belongs to Dispatcher (aka MainWindow). + // There is separate declaration for Dispatcher which we have to synchronize // with this method. method ("write_config", &C::write_config, "@brief Writes configuration to a file\n" @@ -161,8 +161,8 @@ static gsi::Methods application_methods () "If the configuration file cannot be written, \n" "is returned but no exception is thrown.\n" ) + - // TODO: basically this method belongs to PluginRoot (aka MainWindow). - // There is separate declaration for PluginRoot which we have to synchronize + // TODO: basically this method belongs to Dispatcher (aka MainWindow). + // There is separate declaration for Dispatcher which we have to synchronize // with this method. method ("read_config", &C::read_config, "@brief Reads the configuration from a file\n" diff --git a/src/lay/lay/layApplication.cc b/src/lay/lay/layApplication.cc index f7fd82d16..8609ff904 100644 --- a/src/lay/lay/layApplication.cc +++ b/src/lay/lay/layApplication.cc @@ -605,7 +605,7 @@ ApplicationBase::init_app () bool editable_from_config = false; { - lay::Dispatcher cfg; + lay::Dispatcher cfg (0); for (std::vector ::const_iterator c = m_config_files.begin (); c != m_config_files.end (); ++c) { try { diff --git a/src/lay/lay/layClipDialog.cc b/src/lay/lay/layClipDialog.cc index 5a0c1da46..f9346b3fb 100644 --- a/src/lay/lay/layClipDialog.cc +++ b/src/lay/lay/layClipDialog.cc @@ -52,7 +52,7 @@ public: virtual void get_menu_entries (std::vector &menu_entries) const { lay::PluginDeclaration::get_menu_entries (menu_entries); - menu_entries.push_back (lay::MenuEntry ("clip_tool::show", "clip_tool:edit_mode", "edit_menu.utils_menu.end", tl::to_string (QObject::tr ("Clip Tool")))); + menu_entries.push_back (lay::menu_item ("clip_tool::show", "clip_tool:edit_mode", "edit_menu.utils_menu.end", tl::to_string (QObject::tr ("Clip Tool")))); } virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutView *view) const diff --git a/src/lay/lay/layFillDialog.cc b/src/lay/lay/layFillDialog.cc index 3abd11490..dd6e40388 100644 --- a/src/lay/lay/layFillDialog.cc +++ b/src/lay/lay/layFillDialog.cc @@ -59,7 +59,7 @@ public: virtual void get_menu_entries (std::vector &menu_entries) const { lay::PluginDeclaration::get_menu_entries (menu_entries); - menu_entries.push_back (lay::MenuEntry ("fill_tool::show", "fill_tool:edit_mode", "edit_menu.utils_menu.end", tl::to_string (QObject::tr ("Fill Tool")))); + menu_entries.push_back (lay::menu_item ("fill_tool::show", "fill_tool:edit_mode", "edit_menu.utils_menu.end", tl::to_string (QObject::tr ("Fill Tool")))); } virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutView *view) const diff --git a/src/lay/lay/layFillDialog.h b/src/lay/lay/layFillDialog.h index 520ff4907..ecd2a4639 100644 --- a/src/lay/lay/layFillDialog.h +++ b/src/lay/lay/layFillDialog.h @@ -43,7 +43,7 @@ class FillDialog Q_OBJECT public: - FillDialog (lay::PluginRoot *root, lay::LayoutView *view); + FillDialog (lay::Dispatcher *root, lay::LayoutView *view); ~FillDialog (); public slots: diff --git a/src/lay/lay/layFontController.cc b/src/lay/lay/layFontController.cc index dc4e560ae..6c2525722 100644 --- a/src/lay/lay/layFontController.cc +++ b/src/lay/lay/layFontController.cc @@ -40,7 +40,7 @@ FontController::FontController () } void -FontController::initialize (lay::PluginRoot * /*root*/) +FontController::initialize (lay::Dispatcher * /*root*/) { // NOTE: we initialize the dirs in the stage once to have them available for the autorun // macros. We'll do that later again in order to pull in the dirs from the packages. @@ -48,7 +48,7 @@ FontController::initialize (lay::PluginRoot * /*root*/) } void -FontController::initialized (lay::PluginRoot * /*root*/) +FontController::initialized (lay::Dispatcher * /*root*/) { if (lay::SaltController::instance ()) { connect (lay::SaltController::instance (), SIGNAL (salt_changed ()), this, SLOT (sync_with_external_sources ())); @@ -64,7 +64,7 @@ FontController::initialized (lay::PluginRoot * /*root*/) } void -FontController::uninitialize (lay::PluginRoot * /*root*/) +FontController::uninitialize (lay::Dispatcher * /*root*/) { if (m_file_watcher) { disconnect (m_file_watcher, SIGNAL (fileChanged (const QString &)), this, SLOT (file_watcher_triggered ())); @@ -103,7 +103,7 @@ FontController::config_finalize() } bool -FontController::can_exit (lay::PluginRoot * /*root*/) const +FontController::can_exit (lay::Dispatcher * /*root*/) const { // .. nothing yet .. return true; diff --git a/src/lay/lay/layFontController.h b/src/lay/lay/layFontController.h index 5384621eb..ed02fb1a2 100644 --- a/src/lay/lay/layFontController.h +++ b/src/lay/lay/layFontController.h @@ -65,17 +65,17 @@ public: /** * @brief Reimplementation of the PluginDeclaration interface */ - virtual void initialize (lay::PluginRoot *root); + virtual void initialize (lay::Dispatcher *root); /** * @brief Reimplementation of the PluginDeclaration interface */ - virtual void initialized (lay::PluginRoot *root); + virtual void initialized (lay::Dispatcher *root); /** * @brief Reimplementation of the PluginDeclaration interface */ - virtual void uninitialize (lay::PluginRoot *root); + virtual void uninitialize (lay::Dispatcher *root); /** * @brief Reimplementation of the PluginDeclaration interface @@ -100,7 +100,7 @@ public: /** * @brief Reimplementation of the PluginDeclaration interface */ - bool can_exit (lay::PluginRoot *root) const; + bool can_exit (lay::Dispatcher *root) const; /** * @brief Gets the singleton instance for this object diff --git a/src/lay/lay/layLibraryController.cc b/src/lay/lay/layLibraryController.cc index 2636a4ede..b9b304d37 100644 --- a/src/lay/lay/layLibraryController.cc +++ b/src/lay/lay/layLibraryController.cc @@ -45,7 +45,7 @@ LibraryController::LibraryController () } void -LibraryController::initialize (lay::PluginRoot * /*root*/) +LibraryController::initialize (lay::Dispatcher * /*root*/) { // NOTE: we initialize the libraries in the stage once to have them available for the autorun // macros. We'll do that later again in order to pull in the libraries from the packages. @@ -53,7 +53,7 @@ LibraryController::initialize (lay::PluginRoot * /*root*/) } void -LibraryController::initialized (lay::PluginRoot * /*root*/) +LibraryController::initialized (lay::Dispatcher * /*root*/) { if (lay::SaltController::instance ()) { connect (lay::SaltController::instance (), SIGNAL (salt_changed ()), this, SLOT (sync_with_external_sources ())); @@ -69,7 +69,7 @@ LibraryController::initialized (lay::PluginRoot * /*root*/) } void -LibraryController::uninitialize (lay::PluginRoot * /*root*/) +LibraryController::uninitialize (lay::Dispatcher * /*root*/) { if (m_file_watcher) { disconnect (m_file_watcher, SIGNAL (fileChanged (const QString &)), this, SLOT (file_watcher_triggered ())); @@ -108,7 +108,7 @@ LibraryController::config_finalize() } bool -LibraryController::can_exit (lay::PluginRoot * /*root*/) const +LibraryController::can_exit (lay::Dispatcher * /*root*/) const { // .. nothing yet .. return true; diff --git a/src/lay/lay/layLibraryController.h b/src/lay/lay/layLibraryController.h index 1adf75370..86c0bfdcd 100644 --- a/src/lay/lay/layLibraryController.h +++ b/src/lay/lay/layLibraryController.h @@ -65,17 +65,17 @@ public: /** * @brief Reimplementation of the PluginDeclaration interface */ - virtual void initialize (lay::PluginRoot *root); + virtual void initialize (lay::Dispatcher *root); /** * @brief Reimplementation of the PluginDeclaration interface */ - virtual void initialized (lay::PluginRoot *root); + virtual void initialized (lay::Dispatcher *root); /** * @brief Reimplementation of the PluginDeclaration interface */ - virtual void uninitialize (lay::PluginRoot *root); + virtual void uninitialize (lay::Dispatcher *root); /** * @brief Reimplementation of the PluginDeclaration interface @@ -100,7 +100,7 @@ public: /** * @brief Reimplementation of the PluginDeclaration interface */ - bool can_exit (lay::PluginRoot *root) const; + bool can_exit (lay::Dispatcher *root) const; /** * @brief Gets the singleton instance for this object diff --git a/src/lay/lay/layMacroController.cc b/src/lay/lay/layMacroController.cc index e2847f728..adda83d33 100644 --- a/src/lay/lay/layMacroController.cc +++ b/src/lay/lay/layMacroController.cc @@ -169,7 +169,7 @@ MacroController::finish () } void -MacroController::initialized (lay::PluginRoot *root) +MacroController::initialized (lay::Dispatcher *root) { connect (&m_temp_macros, SIGNAL (menu_needs_update ()), this, SLOT (macro_collection_changed ())); connect (&m_temp_macros, SIGNAL (macro_collection_changed (lym::MacroCollection *)), this, SLOT (macro_collection_changed ())); @@ -205,7 +205,7 @@ MacroController::initialized (lay::PluginRoot *root) } void -MacroController::uninitialize (lay::PluginRoot * /*root*/) +MacroController::uninitialize (lay::Dispatcher * /*root*/) { disconnect (&lym::MacroCollection::root (), SIGNAL (menu_needs_update ()), this, SLOT (macro_collection_changed ())); disconnect (&lym::MacroCollection::root (), SIGNAL (macro_collection_changed (lym::MacroCollection *)), this, SLOT (macro_collection_changed ())); @@ -247,7 +247,7 @@ MacroController::config_finalize() } bool -MacroController::can_exit (lay::PluginRoot * /*root*/) const +MacroController::can_exit (lay::Dispatcher * /*root*/) const { if (mp_macro_editor) { return mp_macro_editor->can_exit (); diff --git a/src/lay/lay/layMacroEditorDialog.cc b/src/lay/lay/layMacroEditorDialog.cc index ec51d54a5..6fb47867b 100644 --- a/src/lay/lay/layMacroEditorDialog.cc +++ b/src/lay/lay/layMacroEditorDialog.cc @@ -228,7 +228,7 @@ public: static lay::MacroEditorDialog *s_macro_editor_instance = 0; -MacroEditorDialog::MacroEditorDialog (lay::PluginRoot *pr, lym::MacroCollection *root) +MacroEditorDialog::MacroEditorDialog (lay::Dispatcher *pr, lym::MacroCollection *root) : QDialog (0 /*show as individual top widget*/, Qt::Window), lay::Plugin (pr, true), mp_plugin_root (pr), @@ -2278,7 +2278,7 @@ MacroEditorDialog::ensure_writeable_collection_selected () } static std::vector > -get_custom_paths (lay::PluginRoot *root) +get_custom_paths (lay::Dispatcher *root) { std::vector > paths; @@ -2306,7 +2306,7 @@ get_custom_paths (lay::PluginRoot *root) } static void -set_custom_paths (lay::PluginRoot *root, const std::vector > &paths) +set_custom_paths (lay::Dispatcher *root, const std::vector > &paths) { std::string mp; diff --git a/src/lay/lay/layMacroEditorSetupPage.cc b/src/lay/lay/layMacroEditorSetupPage.cc index e615536f4..98c99ee14 100644 --- a/src/lay/lay/layMacroEditorSetupPage.cc +++ b/src/lay/lay/layMacroEditorSetupPage.cc @@ -25,6 +25,7 @@ #include "layMacroEditorPage.h" #include "layMacroEditorDialog.h" #include "layGenericSyntaxHighlighter.h" +#include "layDispatcher.h" #include "lymMacro.h" @@ -56,7 +57,7 @@ struct MacroEditorSetupDialogData int font_size; std::set ignore_exceptions_list; - void setup (lay::PluginRoot *root) + void setup (lay::Dispatcher *root) { lay::MacroEditorHighlighters highlighters (this); std::string styles; @@ -91,7 +92,7 @@ struct MacroEditorSetupDialogData } } - void commit (lay::PluginRoot *root) + void commit (lay::Dispatcher *root) { lay::MacroEditorHighlighters highlighters (this); @@ -201,7 +202,7 @@ MacroEditorSetupPage::update_font () } void -MacroEditorSetupPage::setup (PluginRoot *root) +MacroEditorSetupPage::setup (Dispatcher *root) { delete mp_data; mp_data = new MacroEditorSetupDialogData (this); @@ -268,7 +269,7 @@ MacroEditorSetupPage::setup (PluginRoot *root) } void -MacroEditorSetupPage::commit (PluginRoot *root) +MacroEditorSetupPage::commit (Dispatcher *root) { if (styles_list->currentItem ()) { commit_attributes (styles_list->currentItem ()); diff --git a/src/lay/lay/layMacroEditorSetupPage.h b/src/lay/lay/layMacroEditorSetupPage.h index 6845da572..bd884fc57 100644 --- a/src/lay/lay/layMacroEditorSetupPage.h +++ b/src/lay/lay/layMacroEditorSetupPage.h @@ -44,8 +44,8 @@ public: MacroEditorSetupPage (QWidget *parent); ~MacroEditorSetupPage (); - virtual void setup (PluginRoot *root); - virtual void commit (PluginRoot *root); + virtual void setup (Dispatcher *root); + virtual void commit (Dispatcher *root); protected slots: void current_attribute_changed (QListWidgetItem *current, QListWidgetItem *previous); diff --git a/src/lay/lay/layMainConfigPages.cc b/src/lay/lay/layMainConfigPages.cc index 1c3b37ffd..c3d63e1b6 100644 --- a/src/lay/lay/layMainConfigPages.cc +++ b/src/lay/lay/layMainConfigPages.cc @@ -116,7 +116,7 @@ MainConfigPage::~MainConfigPage () } void -MainConfigPage::setup (lay::PluginRoot *root) +MainConfigPage::setup (lay::Dispatcher *root) { double grid_micron = 0.0; root->config_get (cfg_grid, grid_micron); @@ -124,7 +124,7 @@ MainConfigPage::setup (lay::PluginRoot *root) } void -MainConfigPage::commit (lay::PluginRoot *root) +MainConfigPage::commit (lay::Dispatcher *root) { try { double g; @@ -150,7 +150,7 @@ MainConfigPage6::~MainConfigPage6 () } void -MainConfigPage6::setup (lay::PluginRoot *root) +MainConfigPage6::setup (lay::Dispatcher *root) { int cp = 32; root->config_get (cfg_circle_points, cp); @@ -158,7 +158,7 @@ MainConfigPage6::setup (lay::PluginRoot *root) } void -MainConfigPage6::commit (lay::PluginRoot *root) +MainConfigPage6::commit (lay::Dispatcher *root) { try { int cp = 32; @@ -185,7 +185,7 @@ MainConfigPage7::~MainConfigPage7 () } void -MainConfigPage7::setup (lay::PluginRoot *root) +MainConfigPage7::setup (lay::Dispatcher *root) { bool en = true; root->config_get (cfg_layout_file_watcher_enabled, en); @@ -193,7 +193,7 @@ MainConfigPage7::setup (lay::PluginRoot *root) } void -MainConfigPage7::commit (lay::PluginRoot *root) +MainConfigPage7::commit (lay::Dispatcher *root) { try { root->config_set (cfg_layout_file_watcher_enabled, mp_ui->check_for_updates->isChecked ()); @@ -217,7 +217,7 @@ MainConfigPage2::~MainConfigPage2 () } void -MainConfigPage2::setup (lay::PluginRoot *root) +MainConfigPage2::setup (lay::Dispatcher *root) { bool flag = false; root->config_get (cfg_synchronized_views, flag); @@ -225,7 +225,7 @@ MainConfigPage2::setup (lay::PluginRoot *root) } void -MainConfigPage2::commit (lay::PluginRoot *root) +MainConfigPage2::commit (lay::Dispatcher *root) { root->config_set (cfg_synchronized_views, mp_ui->sync_views_cbx->isChecked ()); } @@ -247,7 +247,7 @@ MainConfigPage3::~MainConfigPage3 () } void -MainConfigPage3::setup (lay::PluginRoot *root) +MainConfigPage3::setup (lay::Dispatcher *root) { std::string default_grids; root->config_get (cfg_default_grids, default_grids); @@ -255,7 +255,7 @@ MainConfigPage3::setup (lay::PluginRoot *root) } void -MainConfigPage3::commit (lay::PluginRoot *root) +MainConfigPage3::commit (lay::Dispatcher *root) { root->config_set (cfg_default_grids, tl::to_string (mp_ui->grids_edit->text ())); } @@ -277,7 +277,7 @@ MainConfigPage4::~MainConfigPage4 () } void -MainConfigPage4::setup (lay::PluginRoot *root) +MainConfigPage4::setup (lay::Dispatcher *root) { bool flag = true; root->config_get (cfg_edit_mode, flag); @@ -285,7 +285,7 @@ MainConfigPage4::setup (lay::PluginRoot *root) } void -MainConfigPage4::commit (lay::PluginRoot *root) +MainConfigPage4::commit (lay::Dispatcher *root) { root->config_set (cfg_edit_mode, mp_ui->edit_mode_cbx->isChecked ()); } @@ -307,7 +307,7 @@ MainConfigPage5::~MainConfigPage5 () } void -MainConfigPage5::setup (lay::PluginRoot *root) +MainConfigPage5::setup (lay::Dispatcher *root) { int d; d = 5; @@ -319,7 +319,7 @@ MainConfigPage5::setup (lay::PluginRoot *root) } void -MainConfigPage5::commit (lay::PluginRoot *root) +MainConfigPage5::commit (lay::Dispatcher *root) { root->config_set (cfg_micron_digits, mp_ui->micron_digits->value ()); root->config_set (cfg_dbu_digits, mp_ui->dbu_digits->value ()); @@ -502,7 +502,7 @@ CustomizeMenuConfigPage::apply (const std::vectorconfig_get (cfg_key_bindings, packed_key_bindings); @@ -516,7 +516,7 @@ CustomizeMenuConfigPage::setup (lay::PluginRoot *root) } void -CustomizeMenuConfigPage::commit (lay::PluginRoot *root) +CustomizeMenuConfigPage::commit (lay::Dispatcher *root) { current_changed (0, mp_ui->bindings_list->currentItem ()); diff --git a/src/lay/lay/layMainWindow.cc b/src/lay/lay/layMainWindow.cc index 74560e83e..4da3a5cf2 100644 --- a/src/lay/lay/layMainWindow.cc +++ b/src/lay/lay/layMainWindow.cc @@ -4073,7 +4073,7 @@ MainWindow::plugin_removed (lay::PluginDeclaration *cls) } // ------------------------------------------------------------ -// Implementation of the PluginRootToMainWindow bride +// Implementation of the DispatcherToMainWindow bride DispatcherToMainWindow::DispatcherToMainWindow () : lay::Dispatcher (0, false), diff --git a/src/lay/lay/laySaltController.cc b/src/lay/lay/laySaltController.cc index d5205d321..a89865250 100644 --- a/src/lay/lay/laySaltController.cc +++ b/src/lay/lay/laySaltController.cc @@ -43,14 +43,14 @@ SaltController::SaltController () } void -SaltController::initialize (lay::PluginRoot *root) +SaltController::initialize (lay::Dispatcher *root) { mp_mw = lay::MainWindow::instance (); mp_plugin_root = root; } void -SaltController::initialized (lay::PluginRoot * /*root*/) +SaltController::initialized (lay::Dispatcher * /*root*/) { if (! m_file_watcher) { m_file_watcher = new tl::FileSystemWatcher (this); @@ -62,7 +62,7 @@ SaltController::initialized (lay::PluginRoot * /*root*/) } void -SaltController::uninitialize (lay::PluginRoot * /*root*/) +SaltController::uninitialize (lay::Dispatcher * /*root*/) { disconnect (&m_salt, SIGNAL (collections_changed ()), this, SIGNAL (salt_changed ())); @@ -103,7 +103,7 @@ SaltController::config_finalize() } bool -SaltController::can_exit (lay::PluginRoot * /*root*/) const +SaltController::can_exit (lay::Dispatcher * /*root*/) const { // .. nothing yet .. return true; diff --git a/src/lay/lay/laySearchReplaceConfigPage.cc b/src/lay/lay/laySearchReplaceConfigPage.cc index 55226044f..f08d6c7df 100644 --- a/src/lay/lay/laySearchReplaceConfigPage.cc +++ b/src/lay/lay/laySearchReplaceConfigPage.cc @@ -22,6 +22,7 @@ #include "laySearchReplaceConfigPage.h" +#include "layDispatcher.h" namespace lay { @@ -76,7 +77,7 @@ SearchReplaceConfigPage::SearchReplaceConfigPage (QWidget *parent) } void -SearchReplaceConfigPage::setup (lay::PluginRoot *root) +SearchReplaceConfigPage::setup (lay::Dispatcher *root) { std::string value; @@ -106,7 +107,7 @@ SearchReplaceConfigPage::window_changed (int m) } void -SearchReplaceConfigPage::commit (lay::PluginRoot *root) +SearchReplaceConfigPage::commit (lay::Dispatcher *root) { double dim = 1.0; tl::from_string (tl::to_string (le_window->text ()), dim); diff --git a/src/lay/lay/laySearchReplaceConfigPage.h b/src/lay/lay/laySearchReplaceConfigPage.h index 9d7a38e86..8e126a068 100644 --- a/src/lay/lay/laySearchReplaceConfigPage.h +++ b/src/lay/lay/laySearchReplaceConfigPage.h @@ -55,8 +55,8 @@ class SearchReplaceConfigPage public: SearchReplaceConfigPage (QWidget *parent); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); public slots: void window_changed (int); diff --git a/src/lay/lay/laySearchReplaceDialog.cc b/src/lay/lay/laySearchReplaceDialog.cc index 617d71973..be058866a 100644 --- a/src/lay/lay/laySearchReplaceDialog.cc +++ b/src/lay/lay/laySearchReplaceDialog.cc @@ -697,7 +697,7 @@ fill_ctx_cbx (QComboBox *cbx) cbx->addItem (QObject::tr ("All cells")); } -SearchReplaceDialog::SearchReplaceDialog (lay::PluginRoot *root, lay::LayoutView *view) +SearchReplaceDialog::SearchReplaceDialog (lay::Dispatcher *root, lay::LayoutView *view) : lay::Browser (root, view), Ui::SearchReplaceDialog (), mp_view (view), @@ -768,7 +768,7 @@ SearchReplaceDialog::~SearchReplaceDialog () } static void -save_states (QStackedWidget *sw, const std::string &pfx, lay::PluginRoot *config_root) +save_states (QStackedWidget *sw, const std::string &pfx, lay::Dispatcher *config_root) { for (int i = 0; i < sw->count (); ++i) { SearchReplacePropertiesWidget *pw = dynamic_cast (sw->widget (i)); @@ -779,7 +779,7 @@ save_states (QStackedWidget *sw, const std::string &pfx, lay::PluginRoot *config } static void -restore_states (QStackedWidget *sw, const std::string &pfx, lay::PluginRoot *config_root) +restore_states (QStackedWidget *sw, const std::string &pfx, lay::Dispatcher *config_root) { for (int i = 0; i < sw->count (); ++i) { SearchReplacePropertiesWidget *pw = dynamic_cast (sw->widget (i)); @@ -813,7 +813,7 @@ ctx_from_index (int index) void SearchReplaceDialog::restore_state () { - lay::PluginRoot *config_root = root (); + lay::Dispatcher *config_root = root (); restore_states (find_properties, "sr-find", config_root); restore_states (delete_properties, "sr-find", config_root); @@ -881,7 +881,7 @@ SearchReplaceDialog::restore_state () void SearchReplaceDialog::save_state () { - lay::PluginRoot *config_root = root (); + lay::Dispatcher *config_root = root (); config_root->config_set (cfg_sr_window_state, lay::save_dialog_state (this)); @@ -1877,7 +1877,7 @@ SearchReplaceDialog::tab_index_changed (int index) { cancel (); - lay::PluginRoot *config_root = root (); + lay::Dispatcher *config_root = root (); std::string v; diff --git a/src/lay/lay/laySearchReplaceDialog.h b/src/lay/lay/laySearchReplaceDialog.h index f9faf99d4..56c2ea71e 100644 --- a/src/lay/lay/laySearchReplaceDialog.h +++ b/src/lay/lay/laySearchReplaceDialog.h @@ -164,7 +164,7 @@ public: std::string text; }; - SearchReplaceDialog (lay::PluginRoot *root, lay::LayoutView *view); + SearchReplaceDialog (lay::Dispatcher *root, lay::LayoutView *view); ~SearchReplaceDialog (); private: diff --git a/src/lay/lay/laySearchReplacePlugin.cc b/src/lay/lay/laySearchReplacePlugin.cc index c6649c3cf..41c04cfd5 100644 --- a/src/lay/lay/laySearchReplacePlugin.cc +++ b/src/lay/lay/laySearchReplacePlugin.cc @@ -56,14 +56,14 @@ public: lay::PluginDeclaration::get_menu_entries (menu_entries); // separator: - menu_entries.push_back (lay::MenuEntry ("search_replace_sep", "edit_menu.utils_group+")); + menu_entries.push_back (lay::separator ("search_replace_sep", "edit_menu.utils_group+")); // two entries - one for view mode and one for edit mode: - menu_entries.push_back (lay::MenuEntry ("search_replace::show", "search_replace_editor:edit:edit_mode", "edit_menu.utils_group+", tl::to_string (QObject::tr ("Search and Replace")))); - menu_entries.push_back (lay::MenuEntry ("search_replace::show", "search_replace_viewer:edit:view_mode", "edit_menu.utils_group+", tl::to_string (QObject::tr ("Search")))); + menu_entries.push_back (lay::menu_item ("search_replace::show", "search_replace_editor:edit:edit_mode", "edit_menu.utils_group+", tl::to_string (QObject::tr ("Search and Replace")))); + menu_entries.push_back (lay::menu_item ("search_replace::show", "search_replace_viewer:edit:view_mode", "edit_menu.utils_group+", tl::to_string (QObject::tr ("Search")))); } - virtual lay::Plugin *create_plugin (db::Manager *, lay::PluginRoot *root, lay::LayoutView *view) const + virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutView *view) const { return new SearchReplaceDialog (root, view); } diff --git a/src/lay/lay/laySearchReplacePropertiesWidgets.cc b/src/lay/lay/laySearchReplacePropertiesWidgets.cc index 79c9d1c00..c135d9307 100644 --- a/src/lay/lay/laySearchReplacePropertiesWidgets.cc +++ b/src/lay/lay/laySearchReplacePropertiesWidgets.cc @@ -325,7 +325,7 @@ public: setupUi (this); } - void restore_state (const std::string &pfx, lay::PluginRoot *config_root) const + void restore_state (const std::string &pfx, lay::Dispatcher *config_root) const { std::string v; if (config_root->config_get (pfx + cfg_suffix_instance_cellname_op, v)) { @@ -336,7 +336,7 @@ public: } } - void save_state (const std::string &pfx, lay::PluginRoot *config_root) const + void save_state (const std::string &pfx, lay::Dispatcher *config_root) const { config_root->config_set (pfx + cfg_suffix_instance_cellname_op, tl::to_string (instance_cellname_op->currentText ())); config_root->config_set (pfx + cfg_suffix_instance_cellname_value, tl::to_string (instance_cellname_value->text ())); @@ -386,7 +386,7 @@ public: shape_layer->set_new_layer_enabled (false); } - void restore_state (const std::string &pfx, lay::PluginRoot *config_root) const + void restore_state (const std::string &pfx, lay::Dispatcher *config_root) const { std::string v; if (config_root->config_get (pfx + cfg_suffix_shape_layer, v)) { @@ -406,7 +406,7 @@ public: } } - void save_state (const std::string &pfx, lay::PluginRoot *config_root) const + void save_state (const std::string &pfx, lay::Dispatcher *config_root) const { config_root->config_set (pfx + cfg_suffix_shape_layer, tl::to_string (shape_layer->currentText ())); config_root->config_set (pfx + cfg_suffix_shape_area_op, tl::to_string (shape_area_op->currentText ())); @@ -454,7 +454,7 @@ public: // .. nothing yet .. } - void restore_state (const std::string &pfx, lay::PluginRoot *config_root) const + void restore_state (const std::string &pfx, lay::Dispatcher *config_root) const { std::string v; if (config_root->config_get (pfx + cfg_suffix_polygon_layer, v)) { @@ -474,7 +474,7 @@ public: } } - void save_state (const std::string &pfx, lay::PluginRoot *config_root) const + void save_state (const std::string &pfx, lay::Dispatcher *config_root) const { config_root->config_set (pfx + cfg_suffix_polygon_layer, tl::to_string (shape_layer->currentText ())); config_root->config_set (pfx + cfg_suffix_polygon_area_op, tl::to_string (shape_area_op->currentText ())); @@ -527,7 +527,7 @@ public: box_layer->set_new_layer_enabled (false); } - void restore_state (const std::string &pfx, lay::PluginRoot *config_root) const + void restore_state (const std::string &pfx, lay::Dispatcher *config_root) const { std::string v; if (config_root->config_get (pfx + cfg_suffix_box_layer, v)) { @@ -547,7 +547,7 @@ public: } } - void save_state (const std::string &pfx, lay::PluginRoot *config_root) const + void save_state (const std::string &pfx, lay::Dispatcher *config_root) const { config_root->config_set (pfx + cfg_suffix_box_layer, tl::to_string (box_layer->currentText ())); config_root->config_set (pfx + cfg_suffix_box_width_op, tl::to_string (box_width_op->currentText ())); @@ -602,7 +602,7 @@ public: path_layer->set_new_layer_enabled (false); } - void restore_state (const std::string &pfx, lay::PluginRoot *config_root) const + void restore_state (const std::string &pfx, lay::Dispatcher *config_root) const { std::string v; if (config_root->config_get (pfx + cfg_suffix_path_layer, v)) { @@ -622,7 +622,7 @@ public: } } - void save_state (const std::string &pfx, lay::PluginRoot *config_root) const + void save_state (const std::string &pfx, lay::Dispatcher *config_root) const { config_root->config_set (pfx + cfg_suffix_path_layer, tl::to_string (path_layer->currentText ())); config_root->config_set (pfx + cfg_suffix_path_width_op, tl::to_string (path_width_op->currentText ())); @@ -675,7 +675,7 @@ public: text_layer->set_new_layer_enabled (false); } - void restore_state (const std::string &pfx, lay::PluginRoot *config_root) const + void restore_state (const std::string &pfx, lay::Dispatcher *config_root) const { std::string v; if (config_root->config_get (pfx + cfg_suffix_text_layer, v)) { @@ -701,7 +701,7 @@ public: } } - void save_state (const std::string &pfx, lay::PluginRoot *config_root) const + void save_state (const std::string &pfx, lay::Dispatcher *config_root) const { config_root->config_set (pfx + cfg_suffix_text_layer, tl::to_string (text_layer->currentText ())); config_root->config_set (pfx + cfg_suffix_text_string_op, tl::to_string (text_string_op->currentText ())); @@ -753,7 +753,7 @@ public: setupUi (this); } - void restore_state (const std::string &pfx, lay::PluginRoot *config_root) const + void restore_state (const std::string &pfx, lay::Dispatcher *config_root) const { std::string v; if (config_root->config_get (pfx + cfg_suffix_instance_cellname_value, v)) { @@ -761,7 +761,7 @@ public: } } - void save_state (const std::string &pfx, lay::PluginRoot *config_root) const + void save_state (const std::string &pfx, lay::Dispatcher *config_root) const { config_root->config_set (pfx + cfg_suffix_instance_cellname_value, tl::to_string (instance_cellname->text ())); } @@ -795,7 +795,7 @@ public: shape_layer->set_no_layer_available (true); } - void restore_state (const std::string &pfx, lay::PluginRoot *config_root) const + void restore_state (const std::string &pfx, lay::Dispatcher *config_root) const { std::string v; if (config_root->config_get (pfx + cfg_suffix_shape_layer, v)) { @@ -803,7 +803,7 @@ public: } } - void save_state (const std::string &pfx, lay::PluginRoot *config_root) const + void save_state (const std::string &pfx, lay::Dispatcher *config_root) const { config_root->config_set (pfx + cfg_suffix_shape_layer, tl::to_string (shape_layer->currentText ())); } @@ -833,7 +833,7 @@ public: // .. nothing yet .. } - void restore_state (const std::string &pfx, lay::PluginRoot *config_root) const + void restore_state (const std::string &pfx, lay::Dispatcher *config_root) const { std::string v; if (config_root->config_get (pfx + cfg_suffix_polygon_layer, v)) { @@ -841,7 +841,7 @@ public: } } - void save_state (const std::string &pfx, lay::PluginRoot *config_root) const + void save_state (const std::string &pfx, lay::Dispatcher *config_root) const { config_root->config_set (pfx + cfg_suffix_polygon_layer, tl::to_string (shape_layer->currentText ())); } @@ -875,7 +875,7 @@ public: box_layer->set_no_layer_available (true); } - void restore_state (const std::string &pfx, lay::PluginRoot *config_root) const + void restore_state (const std::string &pfx, lay::Dispatcher *config_root) const { std::string v; if (config_root->config_get (pfx + cfg_suffix_box_layer, v)) { @@ -889,7 +889,7 @@ public: } } - void save_state (const std::string &pfx, lay::PluginRoot *config_root) const + void save_state (const std::string &pfx, lay::Dispatcher *config_root) const { config_root->config_set (pfx + cfg_suffix_box_layer, tl::to_string (box_layer->currentText ())); config_root->config_set (pfx + cfg_suffix_box_width_value, tl::to_string (box_width->text ())); @@ -927,7 +927,7 @@ public: path_layer->set_no_layer_available (true); } - void restore_state (const std::string &pfx, lay::PluginRoot *config_root) const + void restore_state (const std::string &pfx, lay::Dispatcher *config_root) const { std::string v; if (config_root->config_get (pfx + cfg_suffix_path_layer, v)) { @@ -938,7 +938,7 @@ public: } } - void save_state (const std::string &pfx, lay::PluginRoot *config_root) const + void save_state (const std::string &pfx, lay::Dispatcher *config_root) const { config_root->config_set (pfx + cfg_suffix_path_layer, tl::to_string (path_layer->currentText ())); config_root->config_set (pfx + cfg_suffix_path_width_value, tl::to_string (path_width->text ())); @@ -974,7 +974,7 @@ public: text_layer->set_no_layer_available (true); } - void restore_state (const std::string &pfx, lay::PluginRoot *config_root) const + void restore_state (const std::string &pfx, lay::Dispatcher *config_root) const { std::string v; if (config_root->config_get (pfx + cfg_suffix_text_layer, v)) { @@ -991,7 +991,7 @@ public: } } - void save_state (const std::string &pfx, lay::PluginRoot *config_root) const + void save_state (const std::string &pfx, lay::Dispatcher *config_root) const { config_root->config_set (pfx + cfg_suffix_text_layer, tl::to_string (text_layer->currentText ())); config_root->config_set (pfx + cfg_suffix_text_string_value, tl::to_string (text_string->text ())); diff --git a/src/lay/lay/laySearchReplacePropertiesWidgets.h b/src/lay/lay/laySearchReplacePropertiesWidgets.h index 1aecd3f51..397d25c1a 100644 --- a/src/lay/lay/laySearchReplacePropertiesWidgets.h +++ b/src/lay/lay/laySearchReplacePropertiesWidgets.h @@ -37,7 +37,7 @@ namespace db namespace lay { -class PluginRoot; +class Dispatcher; /** * @brief A base class for the search and replace properties widgets @@ -50,8 +50,8 @@ public: : QWidget (parent) { } - virtual void restore_state (const std::string &pfx, lay::PluginRoot *config_root) const = 0; - virtual void save_state (const std::string &pfx, lay::PluginRoot *config_root) const = 0; + virtual void restore_state (const std::string &pfx, lay::Dispatcher *config_root) const = 0; + virtual void save_state (const std::string &pfx, lay::Dispatcher *config_root) const = 0; }; /** diff --git a/src/lay/lay/laySettingsForm.cc b/src/lay/lay/laySettingsForm.cc index cc8fcb394..b1cde516e 100644 --- a/src/lay/lay/laySettingsForm.cc +++ b/src/lay/lay/laySettingsForm.cc @@ -42,7 +42,7 @@ namespace lay SettingsForm::SettingsForm (QWidget *parent, lay::Dispatcher *dispatcher, const char *name) : QDialog (parent), Ui::SettingsForm (), - mp_plugin_root (dispatcher), m_finalize_recursion (false) + mp_dispatcher (dispatcher), m_finalize_recursion (false) { setObjectName (QString::fromUtf8 (name)); @@ -237,7 +237,7 @@ SettingsForm::setup () // setup the custom config pages for (std::vector ::iterator cp = m_config_pages.begin (); cp != m_config_pages.end (); ++cp) { - (*cp)->setup (mp_plugin_root); + (*cp)->setup (mp_dispatcher); } } @@ -246,14 +246,14 @@ SettingsForm::commit () { // commit the custom config pages for (std::vector ::iterator cp = m_config_pages.begin (); cp != m_config_pages.end (); ++cp) { - (*cp)->commit (mp_plugin_root); + (*cp)->commit (mp_dispatcher); } m_finalize_recursion = true; try { // config_end will make the main window call setup on the settings form. // the recursion sentinel takes care of that. - mp_plugin_root->config_end (); + mp_dispatcher->config_end (); m_finalize_recursion = false; } catch (...) { m_finalize_recursion = false; diff --git a/src/lay/lay/layTechnologyController.cc b/src/lay/lay/layTechnologyController.cc index 66efa75eb..9a584f06c 100644 --- a/src/lay/lay/layTechnologyController.cc +++ b/src/lay/lay/layTechnologyController.cc @@ -70,7 +70,7 @@ TechnologyController::instance () } void -TechnologyController::initialize (lay::PluginRoot *root) +TechnologyController::initialize (lay::Dispatcher *root) { mp_plugin_root = root; mp_mw = lay::MainWindow::instance (); @@ -81,7 +81,7 @@ TechnologyController::initialize (lay::PluginRoot *root) } void -TechnologyController::initialized (lay::PluginRoot * /*root*/) +TechnologyController::initialized (lay::Dispatcher * /*root*/) { update_menu (); connect_events (); @@ -92,7 +92,7 @@ TechnologyController::initialized (lay::PluginRoot * /*root*/) } void -TechnologyController::uninitialize (lay::PluginRoot * /*root*/) +TechnologyController::uninitialize (lay::Dispatcher * /*root*/) { m_tech_actions.clear (); tl::Object::detach_from_all_events (); @@ -113,7 +113,7 @@ void TechnologyController::get_menu_entries (std::vector &menu_entries) const { lay::PluginDeclaration::get_menu_entries (menu_entries); - menu_entries.push_back (lay::MenuEntry ("technology_selector:apply_technology", "technology_selector:tech_selector_group", "@toolbar.end", tl::to_string (QObject::tr ("Technology<:techs.png>{Select technology (click to apply)}")))); + menu_entries.push_back (lay::menu_item ("technology_selector:apply_technology", "technology_selector:tech_selector_group", "@toolbar.end", tl::to_string (QObject::tr ("Technology<:techs.png>{Select technology (click to apply)}")))); } void @@ -193,7 +193,7 @@ TechnologyController::update_active_technology () #if 0 // Hint with this implementation, the current technology follows the current layout. // Although that's a nice way to display the current technology, it's pretty confusing - lay::PluginRoot *pr = mp_plugin_root; + lay::Dispatcher *pr = mp_plugin_root; if (pr) { pr->config_set (cfg_initial_technology, active_tech); } @@ -204,7 +204,7 @@ void TechnologyController::technologies_changed () { // update the configuration to reflect the persisted technologies - lay::PluginRoot *pr = mp_plugin_root; + lay::Dispatcher *pr = mp_plugin_root; if (pr) { m_configure_enabled = false; try { @@ -298,7 +298,7 @@ TechnologyController::menu_activated (const std::string &symbol) const void TechnologyController::update_current_technology () { - lay::AbstractMenuProvider *pr = lay::AbstractMenuProvider::instance (); + lay::Dispatcher *pr = lay::Dispatcher::instance (); if (! pr || ! pr->menu ()) { return; } @@ -325,7 +325,7 @@ TechnologyController::update_current_technology () void TechnologyController::update_menu () { - lay::AbstractMenuProvider *pr = lay::AbstractMenuProvider::instance (); + lay::Dispatcher *pr = lay::Dispatcher::instance (); if (! pr || ! pr->menu ()) { return; } diff --git a/src/laybasic/laybasic/gsiDeclLayPlugin.cc b/src/laybasic/laybasic/gsiDeclLayPlugin.cc index 4c81d652e..4a214ecc1 100644 --- a/src/laybasic/laybasic/gsiDeclLayPlugin.cc +++ b/src/laybasic/laybasic/gsiDeclLayPlugin.cc @@ -903,7 +903,7 @@ Class decl_Dispatcher ("lay", "Dispatcher", "@brief Clears the configuration parameters\n" ) + method ("instance", &dispatcher_instance, - "@brief Gets the singleton instance of the PluginRoot object\n" + "@brief Gets the singleton instance of the Dispatcher object\n" "\n" "@return The instance\n" ) + diff --git a/src/laybasic/laybasic/layPlugin.h b/src/laybasic/laybasic/layPlugin.h index e42a5e2fc..277777be4 100644 --- a/src/laybasic/laybasic/layPlugin.h +++ b/src/laybasic/laybasic/layPlugin.h @@ -121,7 +121,7 @@ struct LAYBASIC_PUBLIC MenuEntry * @param menu_name The name of the menu item (see layAbstractMenu.h) * @param insert_pos The position where to insert (see layAbstractMenu.h) */ -MenuEntry separator (const std::string &menu_name, const std::string &insert_pos); +LAYBASIC_PUBLIC MenuEntry separator (const std::string &menu_name, const std::string &insert_pos); /** * @brief Creates a normal menu entry @@ -131,7 +131,7 @@ MenuEntry separator (const std::string &menu_name, const std::string &insert_pos * @param insert_pos The position where to insert (see layAbstractMenu.h) * @param title The title to display plus optional icon resource and keyboard shortcut. The format of the string is: ["("shortcut")"]["<"icon-resource">"][{"tool-tip"}]. */ -MenuEntry menu_item (const std::string &symbol, const std::string &menu_name, const std::string &insert_pos, const std::string &title); +LAYBASIC_PUBLIC MenuEntry menu_item (const std::string &symbol, const std::string &menu_name, const std::string &insert_pos, const std::string &title); /** * @brief Creates a submenu entry @@ -140,7 +140,7 @@ MenuEntry menu_item (const std::string &symbol, const std::string &menu_name, co * @param insert_pos The position where to insert (see layAbstractMenu.h) * @param title The title to display plus optional icon resource and keyboard shortcut. The format of the string is: ["("shortcut")"]["<"icon-resource">"][{"tool-tip"}]. */ -MenuEntry submenu (const std::string &menu_name, const std::string &insert_pos, const std::string &title); +LAYBASIC_PUBLIC MenuEntry submenu (const std::string &menu_name, const std::string &insert_pos, const std::string &title); /** * @brief Creates a submenu entry @@ -150,7 +150,7 @@ MenuEntry submenu (const std::string &menu_name, const std::string &insert_pos, * @param insert_pos The position where to insert (see layAbstractMenu.h) * @param title The title to display plus optional icon resource and keyboard shortcut. The format of the string is: ["("shortcut")"]["<"icon-resource">"][{"tool-tip"}]. */ -MenuEntry submenu (const std::string &symbol, const std::string &menu_name, const std::string &insert_pos, const std::string &title); +LAYBASIC_PUBLIC MenuEntry submenu (const std::string &symbol, const std::string &menu_name, const std::string &insert_pos, const std::string &title); /** * @brief Creates a configuration entry @@ -161,7 +161,7 @@ MenuEntry submenu (const std::string &symbol, const std::string &menu_name, cons * @param cname The name of the configuration item * @param cvalue The value to set for the configuration item (optional for boolean configuration items) */ -MenuEntry config_menu_item (const std::string &menu_name, const std::string &insert_pos, const std::string &title, const std::string &cname, const std::string &cvalue = std::string ()); +LAYBASIC_PUBLIC MenuEntry config_menu_item (const std::string &menu_name, const std::string &insert_pos, const std::string &title, const std::string &cname, const std::string &cvalue = std::string ()); /** * @brief The configuration declaration diff --git a/src/laybasic/laybasic/laySaveLayoutOptionsDialog.h b/src/laybasic/laybasic/laySaveLayoutOptionsDialog.h index c14b587b7..cb94c8f2a 100644 --- a/src/laybasic/laybasic/laySaveLayoutOptionsDialog.h +++ b/src/laybasic/laybasic/laySaveLayoutOptionsDialog.h @@ -46,7 +46,6 @@ namespace lay { class LayoutView; -class PluginRoot; class LAYBASIC_PUBLIC SaveLayoutAsOptionsDialog : public QDialog, private Ui::SaveLayoutAsOptionsDialog diff --git a/src/laybasic/laybasic/layStream.h b/src/laybasic/laybasic/layStream.h index a3aad93f8..2058b25a5 100644 --- a/src/laybasic/laybasic/layStream.h +++ b/src/laybasic/laybasic/layStream.h @@ -44,7 +44,7 @@ namespace db namespace lay { -class PluginRoot; +class Dispatcher; class LayoutHandle; /** diff --git a/src/plugins/streamers/lefdef/lay_plugin/layLEFDEFImport.cc b/src/plugins/streamers/lefdef/lay_plugin/layLEFDEFImport.cc index 312d72c1c..3c8f051c2 100644 --- a/src/plugins/streamers/lefdef/lay_plugin/layLEFDEFImport.cc +++ b/src/plugins/streamers/lefdef/lay_plugin/layLEFDEFImport.cc @@ -69,8 +69,8 @@ public: virtual void get_menu_entries (std::vector &menu_entries) const { lay::PluginDeclaration::get_menu_entries (menu_entries); - menu_entries.push_back (lay::MenuEntry ("db::import_lef", "import_lef:edit", "file_menu.import_menu.end", tl::to_string (QObject::tr ("LEF")))); - menu_entries.push_back (lay::MenuEntry ("db::import_def", "import_def:edit", "file_menu.import_menu.end", tl::to_string (QObject::tr ("DEF/LEF")))); + menu_entries.push_back (lay::menu_item ("db::import_lef", "import_lef:edit", "file_menu.import_menu.end", tl::to_string (QObject::tr ("LEF")))); + menu_entries.push_back (lay::menu_item ("db::import_def", "import_def:edit", "file_menu.import_menu.end", tl::to_string (QObject::tr ("DEF/LEF")))); } virtual bool configure (const std::string &name, const std::string &value) @@ -115,7 +115,7 @@ public: lay::MainWindow::instance ()->cancel (); // store configuration - lay::PluginRoot *config_root = lay::PluginRoot::instance (); + lay::Dispatcher *config_root = lay::Dispatcher::instance (); if (import_lef) { config_root->config_set (cfg_lef_import_spec, data.to_string ()); } else { diff --git a/src/plugins/streamers/pcb/lay_plugin/layGerberImport.cc b/src/plugins/streamers/pcb/lay_plugin/layGerberImport.cc index 4ba5e4f99..d37683050 100644 --- a/src/plugins/streamers/pcb/lay_plugin/layGerberImport.cc +++ b/src/plugins/streamers/pcb/lay_plugin/layGerberImport.cc @@ -63,11 +63,11 @@ public: virtual void get_menu_entries (std::vector &menu_entries) const { lay::PluginDeclaration::get_menu_entries (menu_entries); - menu_entries.push_back (lay::MenuEntry ("db::import_gerber", "import_gerber_menu:edit", "file_menu.import_menu.end", tl::to_string (QObject::tr ("Gerber PCB")), true)); - menu_entries.push_back (lay::MenuEntry ("db::import_gerber_new", "import_gerber_new:edit", "file_menu.import_menu.import_gerber_menu.end", tl::to_string (QObject::tr ("New Project")))); - menu_entries.push_back (lay::MenuEntry ("db::import_gerber_new_free", "import_gerber_new_free:edit", "file_menu.import_menu.import_gerber_menu.end", tl::to_string (QObject::tr ("New Project - Free Layer Mapping")))); - menu_entries.push_back (lay::MenuEntry ("db::import_gerber_open", "import_gerber_open:edit", "file_menu.import_menu.import_gerber_menu.end", tl::to_string (QObject::tr ("Open Project")))); - menu_entries.push_back (lay::MenuEntry ("db::import_gerber_recent", "import_gerber_recent:edit", "file_menu.import_menu.import_gerber_menu.end", tl::to_string (QObject::tr ("Recent Project")))); + menu_entries.push_back (lay::submenu ("db::import_gerber", "import_gerber_menu:edit", "file_menu.import_menu.end", tl::to_string (QObject::tr ("Gerber PCB")))); + menu_entries.push_back (lay::menu_item ("db::import_gerber_new", "import_gerber_new:edit", "file_menu.import_menu.import_gerber_menu.end", tl::to_string (QObject::tr ("New Project")))); + menu_entries.push_back (lay::menu_item ("db::import_gerber_new_free", "import_gerber_new_free:edit", "file_menu.import_menu.import_gerber_menu.end", tl::to_string (QObject::tr ("New Project - Free Layer Mapping")))); + menu_entries.push_back (lay::menu_item ("db::import_gerber_open", "import_gerber_open:edit", "file_menu.import_menu.import_gerber_menu.end", tl::to_string (QObject::tr ("Open Project")))); + menu_entries.push_back (lay::menu_item ("db::import_gerber_recent", "import_gerber_recent:edit", "file_menu.import_menu.import_gerber_menu.end", tl::to_string (QObject::tr ("Recent Project")))); } virtual bool configure (const std::string &name, const std::string &value) @@ -125,7 +125,7 @@ public: } - lay::PluginRoot *config_root = lay::PluginRoot::instance (); + lay::Dispatcher *config_root = lay::Dispatcher::instance (); GerberImportDialog dialog (QApplication::activeWindow (), &data); db::GerberImporter importer; diff --git a/src/plugins/tools/bool/lay_plugin/layBooleanOperationsPlugin.cc b/src/plugins/tools/bool/lay_plugin/layBooleanOperationsPlugin.cc index aec42598b..d8623a105 100644 --- a/src/plugins/tools/bool/lay_plugin/layBooleanOperationsPlugin.cc +++ b/src/plugins/tools/bool/lay_plugin/layBooleanOperationsPlugin.cc @@ -478,10 +478,10 @@ public: virtual void get_menu_entries (std::vector &menu_entries) const { lay::PluginDeclaration::get_menu_entries (menu_entries); - menu_entries.push_back (lay::MenuEntry ("ops_group", "edit_menu.layer_menu.end")); - menu_entries.push_back (lay::MenuEntry ("lay::boolean", "boolean:edit:edit_mode", "edit_menu.layer_menu.end", tl::to_string (QObject::tr ("Boolean Operations")))); - menu_entries.push_back (lay::MenuEntry ("lay::merge", "merge:edit:edit_mode", "edit_menu.layer_menu.end", tl::to_string (QObject::tr ("Merge")))); - menu_entries.push_back (lay::MenuEntry ("lay::size", "size:edit:edit_mode", "edit_menu.layer_menu.end", tl::to_string (QObject::tr ("Size")))); + menu_entries.push_back (lay::separator ("ops_group", "edit_menu.layer_menu.end")); + menu_entries.push_back (lay::menu_item ("lay::boolean", "boolean:edit:edit_mode", "edit_menu.layer_menu.end", tl::to_string (QObject::tr ("Boolean Operations")))); + menu_entries.push_back (lay::menu_item ("lay::merge", "merge:edit:edit_mode", "edit_menu.layer_menu.end", tl::to_string (QObject::tr ("Merge")))); + menu_entries.push_back (lay::menu_item ("lay::size", "size:edit:edit_mode", "edit_menu.layer_menu.end", tl::to_string (QObject::tr ("Size")))); } virtual bool configure (const std::string & /*name*/, const std::string & /*value*/) @@ -494,7 +494,7 @@ public: // .. nothing yet .. } - lay::Plugin *create_plugin (db::Manager *, lay::PluginRoot *root, lay::LayoutView *view) const + lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutView *view) const { return new BooleanOperationsPlugin (root, view); } diff --git a/src/plugins/tools/diff/lay_plugin/layDiffPlugin.cc b/src/plugins/tools/diff/lay_plugin/layDiffPlugin.cc index 8b444b3e6..f5b62eaab 100644 --- a/src/plugins/tools/diff/lay_plugin/layDiffPlugin.cc +++ b/src/plugins/tools/diff/lay_plugin/layDiffPlugin.cc @@ -20,10 +20,8 @@ */ - - - #include "layDiffToolDialog.h" +#include "layDispatcher.h" #include "layPlugin.h" @@ -91,7 +89,7 @@ public: virtual void get_menu_entries (std::vector &menu_entries) const { lay::PluginDeclaration::get_menu_entries (menu_entries); - menu_entries.push_back (lay::MenuEntry ("lay::diff_tool", "diff_tool:edit", "tools_menu.post_verification_group", tl::to_string (QObject::tr ("Diff Tool")))); + menu_entries.push_back (lay::menu_item ("lay::diff_tool", "diff_tool:edit", "tools_menu.post_verification_group", tl::to_string (QObject::tr ("Diff Tool")))); } virtual bool configure (const std::string & /*name*/, const std::string & /*value*/) @@ -104,7 +102,7 @@ public: // .. nothing yet .. } - lay::Plugin *create_plugin (db::Manager *, lay::PluginRoot *root, lay::LayoutView *view) const + lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutView *view) const { return new DiffPlugin (root, view); } diff --git a/src/plugins/tools/diff/lay_plugin/layDiffToolDialog.cc b/src/plugins/tools/diff/lay_plugin/layDiffToolDialog.cc index a77ed0c4a..208856ef2 100644 --- a/src/plugins/tools/diff/lay_plugin/layDiffToolDialog.cc +++ b/src/plugins/tools/diff/lay_plugin/layDiffToolDialog.cc @@ -625,7 +625,7 @@ DiffToolDialog::exec_dialog (lay::LayoutView *view) mp_ui->layoutb->set_layout_view (view); } - lay::PluginRoot *config_root = lay::PluginRoot::instance (); + lay::Dispatcher *config_root = lay::Dispatcher::instance (); bool f = false; if (config_root->config_get (cfg_diff_run_xor, f)) { @@ -674,7 +674,7 @@ BEGIN_PROTECTED throw tl::Exception (tl::to_string (QObject::tr ("Trying to perform an Diff between identical layouts"))); } - lay::PluginRoot *config_root = lay::PluginRoot::instance (); + lay::Dispatcher *config_root = lay::Dispatcher::instance (); config_root->config_set (cfg_diff_run_xor, mp_ui->xor_cbx->isChecked ()); config_root->config_set (cfg_diff_detailed, mp_ui->detailed_cbx->isChecked ()); diff --git a/src/plugins/tools/import/lay_plugin/layStreamImport.cc b/src/plugins/tools/import/lay_plugin/layStreamImport.cc index 8bd0dabbd..b91304d50 100644 --- a/src/plugins/tools/import/lay_plugin/layStreamImport.cc +++ b/src/plugins/tools/import/lay_plugin/layStreamImport.cc @@ -61,7 +61,7 @@ public: virtual void get_menu_entries (std::vector &menu_entries) const { lay::PluginDeclaration::get_menu_entries (menu_entries); - menu_entries.push_back (lay::MenuEntry ("lay::import_stream", "import_stream:edit", "file_menu.import_menu.end", tl::to_string (QObject::tr ("Other Files Into Current")))); + menu_entries.push_back (lay::menu_item ("lay::import_stream", "import_stream:edit", "file_menu.import_menu.end", tl::to_string (QObject::tr ("Other Files Into Current")))); } virtual bool configure (const std::string &name, const std::string &value) @@ -95,7 +95,7 @@ public: data = StreamImportData (); } - lay::PluginRoot *config_root = lay::PluginRoot::instance (); + lay::Dispatcher *config_root = lay::Dispatcher::instance (); StreamImportDialog dialog (QApplication::activeWindow (), &data); lay::StreamImporter importer; diff --git a/src/plugins/tools/import/lay_plugin/layStreamImportDialog.h b/src/plugins/tools/import/lay_plugin/layStreamImportDialog.h index 532b2ef2c..bdeff7630 100644 --- a/src/plugins/tools/import/lay_plugin/layStreamImportDialog.h +++ b/src/plugins/tools/import/lay_plugin/layStreamImportDialog.h @@ -56,7 +56,7 @@ namespace tl namespace lay { - class PluginRoot; + class Dispatcher; } namespace lay diff --git a/src/plugins/tools/net_tracer/lay_plugin/layNetTracerConfig.cc b/src/plugins/tools/net_tracer/lay_plugin/layNetTracerConfig.cc index 64618b7cf..8de578356 100644 --- a/src/plugins/tools/net_tracer/lay_plugin/layNetTracerConfig.cc +++ b/src/plugins/tools/net_tracer/lay_plugin/layNetTracerConfig.cc @@ -23,6 +23,7 @@ #include "layNetTracerConfig.h" #include "layConverters.h" +#include "layDispatcher.h" #include #include @@ -128,7 +129,7 @@ NetTracerConfigPage::color_button_clicked () } void -NetTracerConfigPage::setup (lay::PluginRoot *root) +NetTracerConfigPage::setup (lay::Dispatcher *root) { // window mode lay::nt_window_type wmode = lay::NTFitNet; @@ -237,7 +238,7 @@ NetTracerConfigPage::window_changed (int m) } void -NetTracerConfigPage::commit (lay::PluginRoot *root) +NetTracerConfigPage::commit (lay::Dispatcher *root) { double dim = 1.0; tl::from_string (tl::to_string (le_window->text ()), dim); diff --git a/src/plugins/tools/net_tracer/lay_plugin/layNetTracerConfig.h b/src/plugins/tools/net_tracer/lay_plugin/layNetTracerConfig.h index 6990c4141..5257b1162 100644 --- a/src/plugins/tools/net_tracer/lay_plugin/layNetTracerConfig.h +++ b/src/plugins/tools/net_tracer/lay_plugin/layNetTracerConfig.h @@ -63,8 +63,8 @@ class NetTracerConfigPage public: NetTracerConfigPage (QWidget *parent); - virtual void setup (lay::PluginRoot *root); - virtual void commit (lay::PluginRoot *root); + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); public slots: void window_changed (int); diff --git a/src/plugins/tools/net_tracer/lay_plugin/layNetTracerDialog.cc b/src/plugins/tools/net_tracer/lay_plugin/layNetTracerDialog.cc index f82b4150f..04d035ea0 100644 --- a/src/plugins/tools/net_tracer/lay_plugin/layNetTracerDialog.cc +++ b/src/plugins/tools/net_tracer/lay_plugin/layNetTracerDialog.cc @@ -53,7 +53,7 @@ namespace lay // ----------------------------------------------------------------------------------- // NetTracerDialog implementation -NetTracerDialog::NetTracerDialog (lay::PluginRoot *root, lay::LayoutView *view) +NetTracerDialog::NetTracerDialog (lay::Dispatcher *root, lay::LayoutView *view) : lay::Browser (root, view, "net_tracer_dialog"), lay::ViewService (view->view_object_widget ()), m_cv_index (0), diff --git a/src/plugins/tools/net_tracer/lay_plugin/layNetTracerDialog.h b/src/plugins/tools/net_tracer/lay_plugin/layNetTracerDialog.h index 305741447..e011edb83 100644 --- a/src/plugins/tools/net_tracer/lay_plugin/layNetTracerDialog.h +++ b/src/plugins/tools/net_tracer/lay_plugin/layNetTracerDialog.h @@ -57,7 +57,7 @@ class NetTracerDialog Q_OBJECT public: - NetTracerDialog (lay::PluginRoot *root, lay::LayoutView *view); + NetTracerDialog (lay::Dispatcher *root, lay::LayoutView *view); virtual ~NetTracerDialog (); virtual bool mouse_move_event (const db::DPoint &p, unsigned int buttons, bool prio); diff --git a/src/plugins/tools/net_tracer/lay_plugin/layNetTracerPlugin.cc b/src/plugins/tools/net_tracer/lay_plugin/layNetTracerPlugin.cc index e4f8b3383..f9efb9a0c 100644 --- a/src/plugins/tools/net_tracer/lay_plugin/layNetTracerPlugin.cc +++ b/src/plugins/tools/net_tracer/lay_plugin/layNetTracerPlugin.cc @@ -67,15 +67,15 @@ public: { // TODO: where should that go? lay::PluginDeclaration::get_menu_entries (menu_entries); - menu_entries.push_back (lay::MenuEntry ("net_trace_group", "tools_menu.end")); - menu_entries.push_back (lay::MenuEntry ("lay::net_trace", "net_trace", "tools_menu.end", tl::to_string (QObject::tr ("Trace Net")))); - menu_entries.push_back (lay::MenuEntry ("", "trace_all_nets_menu", "tools_menu.end", tl::to_string (QObject::tr ("Trace All Nets")), true)); - menu_entries.push_back (lay::MenuEntry ("lay::trace_all_nets", "trace_all_nets", "tools_menu.trace_all_nets_menu.end", tl::to_string (QObject::tr ("Hierarchical")))); - menu_entries.push_back (lay::MenuEntry ("lay::trace_all_nets_flat", "trace_all_nets_flat", "tools_menu.trace_all_nets_menu.end", tl::to_string (QObject::tr ("Flat")))); - menu_entries.push_back (lay::MenuEntry ("lay::edit_layer_stack", "edit_layer_stack", "tools_menu.end", tl::to_string (QObject::tr ("Edit Layer Stack")))); + menu_entries.push_back (lay::separator ("net_trace_group", "tools_menu.end")); + menu_entries.push_back (lay::menu_item ("lay::net_trace", "net_trace", "tools_menu.end", tl::to_string (QObject::tr ("Trace Net")))); + menu_entries.push_back (lay::submenu ("", "trace_all_nets_menu", "tools_menu.end", tl::to_string (QObject::tr ("Trace All Nets")))); + menu_entries.push_back (lay::menu_item ("lay::trace_all_nets", "trace_all_nets", "tools_menu.trace_all_nets_menu.end", tl::to_string (QObject::tr ("Hierarchical")))); + menu_entries.push_back (lay::menu_item ("lay::trace_all_nets_flat", "trace_all_nets_flat", "tools_menu.trace_all_nets_menu.end", tl::to_string (QObject::tr ("Flat")))); + menu_entries.push_back (lay::menu_item ("lay::edit_layer_stack", "edit_layer_stack", "tools_menu.end", tl::to_string (QObject::tr ("Edit Layer Stack")))); } - virtual lay::Plugin *create_plugin (db::Manager * /*manager*/, lay::PluginRoot *root, lay::LayoutView *view) const + virtual lay::Plugin *create_plugin (db::Manager * /*manager*/, lay::Dispatcher *root, lay::LayoutView *view) const { return new NetTracerDialog (root, view); } diff --git a/src/plugins/tools/xor/lay_plugin/layXORPlugin.cc b/src/plugins/tools/xor/lay_plugin/layXORPlugin.cc index d8e02d7b4..f5bd4895e 100644 --- a/src/plugins/tools/xor/lay_plugin/layXORPlugin.cc +++ b/src/plugins/tools/xor/lay_plugin/layXORPlugin.cc @@ -23,6 +23,7 @@ #include "layXORToolDialog.h" +#include "layDispatcher.h" #include "layPlugin.h" @@ -96,7 +97,7 @@ public: virtual void get_menu_entries (std::vector &menu_entries) const { lay::PluginDeclaration::get_menu_entries (menu_entries); - menu_entries.push_back (lay::MenuEntry ("lay::xor_tool", "xor_tool:edit", "tools_menu.post_verification_group", tl::to_string (QObject::tr ("XOR Tool")))); + menu_entries.push_back (lay::menu_item ("lay::xor_tool", "xor_tool:edit", "tools_menu.post_verification_group", tl::to_string (QObject::tr ("XOR Tool")))); } virtual bool configure (const std::string & /*name*/, const std::string & /*value*/) @@ -109,7 +110,7 @@ public: // .. nothing yet .. } - lay::Plugin *create_plugin (db::Manager *, lay::PluginRoot *root, lay::LayoutView *view) const + lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutView *view) const { return new XORPlugin (root, view); } diff --git a/src/plugins/tools/xor/lay_plugin/layXORToolDialog.cc b/src/plugins/tools/xor/lay_plugin/layXORToolDialog.cc index ccb55afed..8a2f1f82d 100644 --- a/src/plugins/tools/xor/lay_plugin/layXORToolDialog.cc +++ b/src/plugins/tools/xor/lay_plugin/layXORToolDialog.cc @@ -207,7 +207,7 @@ XORToolDialog::exec_dialog (lay::LayoutView *view) } // take current settings from the configurations - lay::PluginRoot *config_root = lay::PluginRoot::instance (); + lay::Dispatcher *config_root = lay::Dispatcher::instance (); input_mode_t im = IMAll; if (config_root->config_get (cfg_xor_input_mode, im, InputModeConverter ())) { @@ -333,7 +333,7 @@ BEGIN_PROTECTED } } - lay::PluginRoot *config_root = lay::PluginRoot::instance (); + lay::Dispatcher *config_root = lay::Dispatcher::instance (); config_root->config_set (cfg_xor_input_mode, InputModeConverter ().to_string ((input_mode_t) mp_ui->input_layers_cbx->currentIndex ())); config_root->config_set (cfg_xor_output_mode, OutputModeConverter ().to_string ((output_mode_t) mp_ui->output_cbx->currentIndex ())); From b604624123b78dffd48740431733a1ff78105c0f Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Fri, 7 Feb 2020 01:32:05 +0100 Subject: [PATCH 13/32] WIP: refactoring ongoing. --- src/lay/lay/layMainWindow.h | 30 ------------------- src/laybasic/laybasic/laySelectCellViewForm.h | 4 ++- 2 files changed, 3 insertions(+), 31 deletions(-) diff --git a/src/lay/lay/layMainWindow.h b/src/lay/lay/layMainWindow.h index 78d133f7f..3f5c7176e 100644 --- a/src/lay/lay/layMainWindow.h +++ b/src/lay/lay/layMainWindow.h @@ -532,36 +532,6 @@ public: */ static std::vector menu_symbols (); - /** - * @brief Get the action for a slot - */ - lay::Action &action_for_slot (const char *slot); - - /** - * @brief Create a configuration action with the given title, parameter name and value - * - * The action will be owned by the main window but can be deleted to remove the action from the main window. - */ - lay::Action *create_config_action (const std::string &title, const std::string &cname, const std::string &cvalue); - - /** - * @brief Create a configuration action with the given parameter name and value - * - * The action will be owned by the main window but can be deleted to remove the action from the main window. - * This version is provided for applications, where the title is set later. - */ - lay::Action *create_config_action (const std::string &cname, const std::string &cvalue); - - /** - * @brief Register a configuration action with the given name - */ - void register_config_action (const std::string &name, lay::ConfigureAction *action); - - /** - * @brief Unregister a configuration action with the given name - */ - void unregister_config_action (const std::string &name, lay::ConfigureAction *action); - /** * @brief Open a new layout in mode 'mode' * diff --git a/src/laybasic/laybasic/laySelectCellViewForm.h b/src/laybasic/laybasic/laySelectCellViewForm.h index b03e8c651..b0f0e6f30 100644 --- a/src/laybasic/laybasic/laySelectCellViewForm.h +++ b/src/laybasic/laybasic/laySelectCellViewForm.h @@ -24,6 +24,8 @@ #ifndef HDR_SelectCellViewForm #define HDR_SelectCellViewForm +#include "laybasicCommon.h" + #include #include @@ -37,7 +39,7 @@ namespace lay class CellView; class LayoutView; -class SelectCellViewForm +class LAYBASIC_PUBLIC SelectCellViewForm : public QDialog, private Ui::SelectCellViewForm { Q_OBJECT From ce25d51763e1d6d9ba10074c25fefd44723b1694 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Fri, 7 Feb 2020 01:41:03 +0100 Subject: [PATCH 14/32] WIP: refactoring ongoing. --- src/laybasic/laybasic/layAbstractMenu.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/laybasic/laybasic/layAbstractMenu.cc b/src/laybasic/laybasic/layAbstractMenu.cc index 5c63d1d24..33b5c9e54 100644 --- a/src/laybasic/laybasic/layAbstractMenu.cc +++ b/src/laybasic/laybasic/layAbstractMenu.cc @@ -1013,7 +1013,7 @@ AbstractMenu::create_action (const std::string &s, lay::Dispatcher *dispatcher) parse_menu_title (s, title, shortcut, res, tool_tip); - ActionHandle *ah = new ActionHandle (dispatcher->menu_parent_widget ()); + ActionHandle *ah = new ActionHandle (dispatcher ? dispatcher->menu_parent_widget () : 0); ah->ptr ()->setText (tl::to_qstring (title)); if (! tool_tip.empty ()) { @@ -1613,7 +1613,11 @@ AbstractMenu::find_item (tl::Extractor &extr) std::string n; extr.read (n, ".+>("); - if (n == "begin") { + if (n.empty ()) { + + // skip (avoids infinite loops on wrong paths) + + } else if (n == "begin") { iter = parent->children.begin (); From 4210198179e5ebcafe4e22ac935b20a6d6689aad Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Fri, 7 Feb 2020 17:33:53 +0100 Subject: [PATCH 15/32] WIP: refactoring ongoing. --- src/ant/ant/antPlugin.cc | 25 +++++------ src/ant/ant/antPlugin.h | 2 +- src/laybasic/laybasic/layAbstractMenu.h | 6 +-- src/laybasic/laybasic/layDispatcher.cc | 4 +- src/laybasic/laybasic/layDispatcher.h | 4 +- src/laybasic/laybasic/layPlugin.cc | 58 ++++++++++++------------- src/laybasic/laybasic/layPlugin.h | 6 ++- 7 files changed, 52 insertions(+), 53 deletions(-) diff --git a/src/ant/ant/antPlugin.cc b/src/ant/ant/antPlugin.cc index 67de17128..b81637bc9 100644 --- a/src/ant/ant/antPlugin.cc +++ b/src/ant/ant/antPlugin.cc @@ -203,9 +203,6 @@ PluginDeclaration::initialized (lay::Dispatcher *root) void PluginDeclaration::uninitialize (lay::Dispatcher *) { - for (std::vector::iterator a = m_actions.begin (); a != m_actions.end (); ++a) { - delete *a; - } m_actions.clear (); } @@ -226,9 +223,13 @@ PluginDeclaration::update_current_template () } if (m_templates.size () > 1) { - int it = 0; - for (std::vector