diff --git a/src/laybasic/laybasic/gsiDeclLayNetlistBrowserDialog.cc b/src/laybasic/laybasic/gsiDeclLayNetlistBrowserDialog.cc index 14346efe4..d35d1743c 100644 --- a/src/laybasic/laybasic/gsiDeclLayNetlistBrowserDialog.cc +++ b/src/laybasic/laybasic/gsiDeclLayNetlistBrowserDialog.cc @@ -23,6 +23,7 @@ #include "gsiDecl.h" #include "gsiDeclBasic.h" +#include "gsiSignals.h" #include "layNetlistBrowserDialog.h" #include "layLayoutView.h" @@ -42,8 +43,39 @@ namespace gsi { Class decl_NetlistBrowserDialog ("lay", "NetlistBrowserDialog", - gsi::Methods (), - "@brief ..." + gsi::event ("current_db_changed_event", &lay::NetlistBrowserDialog::current_db_changed_event, + "@brief This event is triggered when the current database is changed.\n" + "The current database can be obtained with \\db." + ) + + gsi::event ("selection_changed_event", &lay::NetlistBrowserDialog::selection_changed_event, + "@brief This event is triggered when the selection changed.\n" + "The selection can be obtained with \\selected_nets, \\selected_devices, \\selected_subcircuits and \\selected_circuits." + ) + + gsi::event ("probe_event", &lay::NetlistBrowserDialog::probe_event, gsi::arg ("net"), gsi::arg ("subcircuit_path"), + "@brief This event is triggered when a net is probed.\n" + "'subcircuit_path' will contain the subcircuit objects leading to the probed net from the netlist databases' top circuit. " + "This path may not be complete - it may contain null entries if a cell instance can't be associated with a subcircuit." + ) + + gsi::method ("db", &lay::NetlistBrowserDialog::db, + "@brief Gets the database the browser is connected to.\n" + ) + + gsi::method ("selected_nets", &lay::NetlistBrowserDialog::selected_nets, + "@brief Gets the nets currently selected in the netlist database browser.\n" + ) + + gsi::method ("selected_nets", &lay::NetlistBrowserDialog::selected_devices, + "@brief Gets the devices currently selected in the netlist database browser.\n" + ) + + gsi::method ("selected_nets", &lay::NetlistBrowserDialog::selected_subcircuits, + "@brief Gets the subcircuits currently selected in the netlist database browser.\n" + ) + + gsi::method ("selected_nets", &lay::NetlistBrowserDialog::selected_circuits, + "@brief Gets the circuits currently selected in the netlist database browser.\n" + ), + "@brief Represents the netlist browser dialog.\n" + "This dialog is a part of the \\LayoutView class and can be obtained through \\LayoutView#netlist_browser.\n" + "This interface allows to interact with the browser - mainly to get information about state changes.\n" + "\n" + "This class has been introduced in version 0.27.\n" ); static lay::NetlistBrowserDialog *netlist_browser (lay::LayoutView *lv) diff --git a/src/laybasic/laybasic/layNetlistBrowserDialog.cc b/src/laybasic/laybasic/layNetlistBrowserDialog.cc index 50866fa8d..78644cfc3 100644 --- a/src/laybasic/laybasic/layNetlistBrowserDialog.cc +++ b/src/laybasic/laybasic/layNetlistBrowserDialog.cc @@ -120,6 +120,8 @@ NetlistBrowserDialog::NetlistBrowserDialog (lay::Dispatcher *root, lay::LayoutVi connect (sticky_cbx, SIGNAL (clicked ()), this, SLOT (sticky_mode_clicked ())); cellviews_changed (); + + browser_page->selection_changed_event.add (this, &NetlistBrowserDialog::selection_changed); } NetlistBrowserDialog::~NetlistBrowserDialog () @@ -127,6 +129,56 @@ NetlistBrowserDialog::~NetlistBrowserDialog () tl::Object::detach_from_all_events (); } +db::LayoutToNetlist * +NetlistBrowserDialog::db () +{ + return browser_page->db (); +} + +const std::vector & +NetlistBrowserDialog::selected_nets () const +{ + if (browser_page) { + return browser_page->current_nets (); + } else { + static std::vector empty; + return empty; + } +} + +const std::vector & +NetlistBrowserDialog::selected_devices () const +{ + if (browser_page) { + return browser_page->current_devices (); + } else { + static std::vector empty; + return empty; + } +} + +const std::vector & +NetlistBrowserDialog::selected_subcircuits () const +{ + if (browser_page) { + return browser_page->current_subcircuits (); + } else { + static std::vector empty; + return empty; + } +} + +const std::vector & +NetlistBrowserDialog::selected_circuits () const +{ + if (browser_page) { + return browser_page->current_circuits (); + } else { + static std::vector empty; + return empty; + } +} + void NetlistBrowserDialog::configure_clicked () { @@ -254,7 +306,8 @@ NetlistBrowserDialog::probe_net (const db::DPoint &p, bool trace_path) } - const db::Net *net = 0; + db::Net *net = 0; + std::vector sc_path; db::LayoutToNetlist *l2ndb = view ()->get_l2ndb (m_l2n_index); if (l2ndb) { @@ -281,13 +334,17 @@ NetlistBrowserDialog::probe_net (const db::DPoint &p, bool trace_path) // probe the net for (std::vector::const_iterator r = regions.begin (); r != regions.end () && !net; ++r) { - net = l2ndb->probe_net (**r, start_point); + sc_path.clear (); + net = l2ndb->probe_net (**r, start_point, &sc_path); } } // select the net if one was found browser_page->select_net (net); + + // emits the probe event + probe_event (net, sc_path); } void @@ -421,9 +478,15 @@ BEGIN_PROTECTED tl::log << tl::to_string (QObject::tr ("Loading file: ")) << l2ndb->filename (); tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Loading"))); - browser_page->set_l2ndb (0); - l2ndb->load (l2ndb->filename ()); - browser_page->set_l2ndb (l2ndb); + browser_page->set_db (0); + try { + l2ndb->load (l2ndb->filename ()); + browser_page->set_db (l2ndb); + current_db_changed_event (); + } catch (...) { + current_db_changed_event (); + throw; + } } @@ -707,6 +770,8 @@ NetlistBrowserDialog::update_content () central_stack->setCurrentIndex (1); } + bool db_changed = false; + m_saveas_action->setEnabled (l2ndb != 0); m_export_action->setEnabled (l2ndb != 0); m_unload_action->setEnabled (l2ndb != 0); @@ -714,7 +779,10 @@ NetlistBrowserDialog::update_content () m_reload_action->setEnabled (l2ndb != 0); browser_page->enable_updates (false); // Avoid building the internal lists several times ... - browser_page->set_l2ndb (l2ndb); + if (browser_page->db () != l2ndb) { + db_changed = true; + browser_page->set_db (l2ndb); + } browser_page->set_max_shape_count (m_max_shape_count); browser_page->set_highlight_style (m_marker_color, m_marker_line_width, m_marker_vertex_size, m_marker_halo, m_marker_dither_pattern, m_marker_intensity, m_use_original_colors, m_auto_color_enabled ? &m_auto_colors : 0); browser_page->set_window (m_window, m_window_dim); @@ -740,6 +808,10 @@ NetlistBrowserDialog::update_content () if (l2ndb_cb->currentIndex () != m_l2n_index) { l2ndb_cb->setCurrentIndex (m_l2n_index); } + + if (db_changed) { + current_db_changed_event (); + } } void @@ -751,8 +823,16 @@ NetlistBrowserDialog::deactivated () 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); + bool db_changed = false; + if (browser_page->db () != 0) { + db_changed = true; + browser_page->set_db (0); + } browser_page->set_view (0, 0); + + if (db_changed) { + current_db_changed_event (); + } } void diff --git a/src/laybasic/laybasic/layNetlistBrowserDialog.h b/src/laybasic/laybasic/layNetlistBrowserDialog.h index 73b0b5fe6..221408999 100644 --- a/src/laybasic/laybasic/layNetlistBrowserDialog.h +++ b/src/laybasic/laybasic/layNetlistBrowserDialog.h @@ -29,6 +29,7 @@ #include "layNetlistBrowser.h" #include "layViewObject.h" #include "layColorPalette.h" +#include "tlEvents.h" namespace lay { @@ -46,6 +47,46 @@ public: void load (int lay_index, int cv_index); + /** + * @brief This event is emitted after the current database changed + */ + tl::Event current_db_changed_event; + + /** + * @brief This event is emitted when a shape is probed + */ + tl::event > probe_event; + + /** + * @brief Gets the current database + */ + db::LayoutToNetlist *db (); + + /** + * @brief Gets the selected nets + */ + const std::vector &selected_nets () const; + + /** + * @brief Gets the selected devices + */ + const std::vector &selected_devices () const; + + /** + * @brief Gets the selected subcircuits + */ + const std::vector &selected_subcircuits () const; + + /** + * @brief Gets the selected circuits + */ + const std::vector &selected_circuits () const; + + /** + * @brief An event indicating that the selection has changed + */ + tl::Event selection_changed_event; + private: // implementation of the lay::Browser interface virtual void activated (); @@ -64,6 +105,11 @@ private: void cellview_changed (int index); void l2ndbs_changed (); + void selection_changed () + { + selection_changed_event (); + } + public slots: void cv_index_changed (int); void l2ndb_index_changed (int); diff --git a/src/laybasic/laybasic/layNetlistBrowserPage.cc b/src/laybasic/laybasic/layNetlistBrowserPage.cc index 3c0882ad0..f3c6f799d 100644 --- a/src/laybasic/laybasic/layNetlistBrowserPage.cc +++ b/src/laybasic/laybasic/layNetlistBrowserPage.cc @@ -795,11 +795,17 @@ NetlistBrowserPage::set_db (db::LayoutToNetlist *l2ndb) m_signals_enabled = se; clear_markers (); - highlight (std::vector (), std::vector (), std::vector (), std::vector ()); + + m_current_nets.clear (); + m_current_devices.clear (); + m_current_subcircuits.clear (); + m_current_circuits.clear (); m_cell_context_cache = db::ContextCache (mp_database.get () ? mp_database->internal_layout () : 0); setup_trees (); + + selection_changed_event (); } void @@ -902,6 +908,8 @@ NetlistBrowserPage::highlight (const std::vector &nets, const s update_highlights (); } + selection_changed (); + } } diff --git a/src/laybasic/laybasic/layNetlistBrowserPage.h b/src/laybasic/laybasic/layNetlistBrowserPage.h index 9a1adccd6..4aef9bae8 100644 --- a/src/laybasic/laybasic/layNetlistBrowserPage.h +++ b/src/laybasic/laybasic/layNetlistBrowserPage.h @@ -33,6 +33,7 @@ #include "dbLayoutUtils.h" #include "tlObject.h" +#include "tlEvents.h" #include @@ -90,25 +91,14 @@ public: /** * @brief Attaches the page to a L2N DB */ - void set_l2ndb (db::LayoutToNetlist *database) - { - set_db (database); - } + void set_db (db::LayoutToNetlist *database); /** - * @brief Attaches the page to a LVS DB + * @brief Gets the database the page is connected to */ - void set_lvsdb (db::LayoutVsSchematic *database) + db::LayoutToNetlist *db () { - set_db (database); - } - - /** - * @brief Detaches the page from any DB - */ - void reset_db () - { - set_db (0); + return mp_database.get (); } /** @@ -162,6 +152,43 @@ public: */ void update_highlights (); + /** + * @brief Gets the selected nets + */ + const std::vector ¤t_nets () const + { + return m_current_nets; + } + + /** + * @brief Gets the selected devices + */ + const std::vector ¤t_devices () const + { + return m_current_devices; + } + + /** + * @brief Gets the selected subcircuits + */ + const std::vector ¤t_subcircuits () const + { + return m_current_subcircuits; + } + + /** + * @brief Gets the selected circuits + */ + const std::vector ¤t_circuits () const + { + return m_current_circuits; + } + + /** + * @brief An event indicating that the selection has changed + */ + tl::Event selection_changed_event; + public slots: void export_all (); void export_selected (); @@ -216,7 +243,6 @@ private: tl::DeferredMethod dm_rerun_macro; db::ContextCache m_cell_context_cache; - void set_db (db::LayoutToNetlist *l2ndb); void setup_trees (); void add_to_history (void *id, bool fwd); void navigate_to (void *id, bool forward = true);