WIP+Bugfix

1. Bugfix: avoid an internal error because in set_db highlight()
   was called before setup_trees(). Error was:
   Internal error: ../../../src/laybasic/laybasic/layNetlistBrowserPage.cc:387 model != 0 was not true in LayoutView::show_l2ndb

2. Provide GSI binding for lay::NetlistBrowserDialog
This commit is contained in:
Matthias Koefferlein 2020-06-14 23:31:44 +02:00
parent 880b9904cf
commit 61c9c12414
5 changed files with 218 additions and 26 deletions

View File

@ -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<lay::NetlistBrowserDialog> 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)

View File

@ -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<const db::Net *> &
NetlistBrowserDialog::selected_nets () const
{
if (browser_page) {
return browser_page->current_nets ();
} else {
static std::vector<const db::Net *> empty;
return empty;
}
}
const std::vector<const db::Device *> &
NetlistBrowserDialog::selected_devices () const
{
if (browser_page) {
return browser_page->current_devices ();
} else {
static std::vector<const db::Device *> empty;
return empty;
}
}
const std::vector<const db::SubCircuit *> &
NetlistBrowserDialog::selected_subcircuits () const
{
if (browser_page) {
return browser_page->current_subcircuits ();
} else {
static std::vector<const db::SubCircuit *> empty;
return empty;
}
}
const std::vector<const db::Circuit *> &
NetlistBrowserDialog::selected_circuits () const
{
if (browser_page) {
return browser_page->current_circuits ();
} else {
static std::vector<const db::Circuit *> 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<db::SubCircuit *> 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<db::Region *>::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

View File

@ -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<db::Net *, std::vector<db::SubCircuit *> > probe_event;
/**
* @brief Gets the current database
*/
db::LayoutToNetlist *db ();
/**
* @brief Gets the selected nets
*/
const std::vector<const db::Net *> &selected_nets () const;
/**
* @brief Gets the selected devices
*/
const std::vector<const db::Device *> &selected_devices () const;
/**
* @brief Gets the selected subcircuits
*/
const std::vector<const db::SubCircuit *> &selected_subcircuits () const;
/**
* @brief Gets the selected circuits
*/
const std::vector<const db::Circuit *> &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);

View File

@ -795,11 +795,17 @@ NetlistBrowserPage::set_db (db::LayoutToNetlist *l2ndb)
m_signals_enabled = se;
clear_markers ();
highlight (std::vector<const db::Net *> (), std::vector<const db::Device *> (), std::vector<const db::SubCircuit *> (), std::vector<const db::Circuit *> ());
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<const db::Net *> &nets, const s
update_highlights ();
}
selection_changed ();
}
}

View File

@ -33,6 +33,7 @@
#include "dbLayoutUtils.h"
#include "tlObject.h"
#include "tlEvents.h"
#include <QFrame>
@ -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<const db::Net *> &current_nets () const
{
return m_current_nets;
}
/**
* @brief Gets the selected devices
*/
const std::vector<const db::Device *> &current_devices () const
{
return m_current_devices;
}
/**
* @brief Gets the selected subcircuits
*/
const std::vector<const db::SubCircuit *> &current_subcircuits () const
{
return m_current_subcircuits;
}
/**
* @brief Gets the selected circuits
*/
const std::vector<const db::Circuit *> &current_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<NetlistBrowserPage> 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);