Naming of layers isn't required anymore for connect et al: names are given automatically now.

This commit is contained in:
Matthias Koefferlein
2019-04-20 20:30:12 +02:00
parent 767f6a7c48
commit 20b984cc50
13 changed files with 592 additions and 236 deletions
@@ -28,6 +28,7 @@
#include "layDitherPattern.h"
#include "layLineStyles.h"
#include "dbSaveLayoutOptions.h"
#include "dbLayoutToNetlist.h"
#include "tlStream.h"
#if defined(HAVE_QTBINDINGS)
@@ -196,6 +197,13 @@ static unsigned int create_rdb (lay::LayoutView *view, const std::string &name)
return view->add_rdb (db);
}
static unsigned int create_l2ndb (lay::LayoutView *view, const std::string &name)
{
db::LayoutToNetlist *db = new db::LayoutToNetlist ();
db->set_name (name);
return view->add_l2ndb (db);
}
// this binding returns a const pointer which is not converted into a copy by RBA
static lay::LayerPropertiesNodeRef insert_layer1 (lay::LayoutView *view, const lay::LayerPropertiesConstIterator &iter, const lay::LayerProperties &props)
{
@@ -1427,6 +1435,48 @@ Class<lay::LayoutView> decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou
"The marker browser is opened showing the report database with the index given by \"rdb_index\".\n"
"It will be attached (i.e. navigate to) the layout with the given cellview index in \"cv_index\".\n"
) +
gsi::event ("on_l2ndb_list_changed", &lay::LayoutView::l2ndb_list_changed_event,
"@brief An event that is triggered the list of netlist databases is changed\n"
"\n"
"If a netlist database is added or removed, this event is triggered.\n"
"\n"
"This method has been added in version 0.26."
) +
gsi::method ("num_l2ndbs", &lay::LayoutView::num_l2ndbs,
"@brief Gets the number of netlist databases loaded into this view\n"
"@return The number of \\LayoutToNetlist objects present in this view\n"
"\n"
"This method has been added in version 0.26."
) +
gsi::method ("remove_l2ndb", &lay::LayoutView::remove_l2ndb, gsi::arg ("index"),
"@brief Removes a netlist database with the given index\n"
"@param The index of the netlist database to remove from this view"
"\n"
"This method has been added in version 0.26."
) +
gsi::method ("l2ndb", (db::LayoutToNetlist *(lay::LayoutView::*) (int index)) &lay::LayoutView::get_l2ndb, gsi::arg ("index"),
"@brief Gets the netlist database with the given index\n"
"@return The \\LayoutToNetlist object or nil if the index is not valid"
"\n"
"This method has been added in version 0.26."
) +
gsi::method_ext ("create_l2ndb", &create_l2ndb, gsi::arg ("name"),
"@brief Creates a new netlist database and returns the index of the new database\n"
"@param name The name of the new netlist database\n"
"@return The index of the new database\n"
"This method returns an index of the new netlist database. Use \\l2ndb to get the actual object. "
"If a netlist database with the given name already exists, a unique name will be created.\n"
"The name will be replaced by the file name when a file is loaded into the netlist database.\n"
"\n"
"This method has been added in version 0.26."
) +
gsi::method ("show_l2ndb", &lay::LayoutView::open_l2ndb_browser, gsi::arg ("l2ndb_index"), gsi::arg ("cv_index"),
"@brief Shows a netlist database in the marker browser on a certain layout\n"
"The netlist browser is opened showing the netlist database with the index given by \"l2ndb_index\".\n"
"It will be attached (i.e. navigate to) the layout with the given cellview index in \"cv_index\".\n"
"\n"
"This method has been added in version 0.26."
) +
// HINT: the cast is important to direct GSI to the LayoutView method rather than the
// Plugin method (in which case we get a segmentation violation ..)
// TODO: this method belongs to the Plugin interface and should be located there.
+73 -12
View File
@@ -66,6 +66,7 @@
#include "layRedrawThreadWorker.h"
#include "layParsedLayerSource.h"
#include "layBookmarkManagementForm.h"
#include "layNetlistBrowserDialog.h"
#include "dbLayout.h"
#include "dbLayoutUtils.h"
#include "dbRecursiveShapeIterator.h"
@@ -73,6 +74,7 @@
#include "dbEdgeProcessor.h"
#include "rdb.h"
#include "rdbMarkerBrowserDialog.h"
#include "dbLayoutToNetlist.h"
#include "tlXMLParser.h"
#include "gsi.h"
#include "gtf.h"
@@ -568,6 +570,7 @@ LayoutView::~LayoutView ()
cellviews_changed_event.clear ();
cellview_changed_event.clear ();
rdb_list_changed_event.clear ();
l2ndb_list_changed_event.clear ();
file_open_event.clear ();
hier_changed_event.clear ();
geom_changed_event.clear ();
@@ -581,6 +584,11 @@ LayoutView::~LayoutView ()
remove_rdb (0);
}
// remove all L2N DB's
while (num_l2ndbs () > 0) {
remove_l2ndb (0);
}
// delete layer lists
std::vector<LayerPropertiesList *> layer_properties_lists;
layer_properties_lists.swap (m_layer_properties_lists);
@@ -7074,19 +7082,17 @@ LayoutView::cm_clear_layer ()
}
}
unsigned int
LayoutView::add_rdb (rdb::Database *rdb)
template <class T, class Iter>
static void make_unique_name (T *object, Iter from, Iter to)
{
// make the name unique
std::string n (rdb->name ());
std::string n (object->name ());
int nn = 0;
do {
bool found = false;
for (unsigned int i = 0; i < num_rdbs () && !found; ++i) {
if (get_rdb (i)->name () == n) {
for (Iter i = from; i != to && !found; ++i) {
if ((*i)->name () == n) {
found = true;
}
}
@@ -7095,12 +7101,67 @@ LayoutView::add_rdb (rdb::Database *rdb)
break;
}
n = rdb->name () + tl::sprintf ("[%d]", ++nn);
n = object->name () + tl::sprintf ("[%d]", ++nn);
} while (1);
rdb->set_name (n);
object->set_name (n);
}
unsigned int
LayoutView::add_l2ndb (db::LayoutToNetlist *l2ndb)
{
make_unique_name (l2ndb, m_l2ndbs.begin (), m_l2ndbs.end ());
m_l2ndbs.push_back (l2ndb);
l2ndb_list_changed_event ();
return (unsigned int)(m_l2ndbs.size () - 1);
}
db::LayoutToNetlist *
LayoutView::get_l2ndb (int index)
{
if (index >= 0 && index < int (m_l2ndbs.size ())) {
return m_l2ndbs [index];
} else {
return 0;
}
}
void
LayoutView::open_l2ndb_browser (int l2ndb_index, int cv_index)
{
lay::NetlistBrowserDialog *l2ndb_browser = get_plugin <lay::NetlistBrowserDialog> ();
if (l2ndb_browser) {
l2ndb_browser->load (l2ndb_index, cv_index);
}
}
const db::LayoutToNetlist *
LayoutView::get_l2ndb (int index) const
{
if (index >= 0 && index < int (m_l2ndbs.size ())) {
return m_l2ndbs [index];
} else {
return 0;
}
}
void
LayoutView::remove_l2ndb (unsigned int index)
{
if (index < (unsigned int) (m_l2ndbs.size ())) {
delete m_l2ndbs [index];
m_l2ndbs.erase (m_l2ndbs.begin () + index);
l2ndb_list_changed_event ();
}
}
unsigned int
LayoutView::add_rdb (rdb::Database *rdb)
{
make_unique_name (rdb, m_l2ndbs.begin (), m_l2ndbs.end ());
m_rdbs.push_back (rdb);
rdb_list_changed_event ();
@@ -7118,7 +7179,7 @@ LayoutView::get_rdb (int index)
}
}
void
void
LayoutView::open_rdb_browser (int rdb_index, int cv_index)
{
rdb::MarkerBrowserDialog *rdb_browser = get_plugin <rdb::MarkerBrowserDialog> ();
@@ -7137,7 +7198,7 @@ LayoutView::get_rdb (int index) const
}
}
void
void
LayoutView::remove_rdb (unsigned int index)
{
if (index < (unsigned int) (m_rdbs.size ())) {
@@ -7147,7 +7208,7 @@ LayoutView::remove_rdb (unsigned int index)
}
}
QSize
QSize
LayoutView::sizeHint () const
{
if ((m_options & LV_Naked) != 0) {
+58 -1
View File
@@ -62,6 +62,7 @@ namespace db {
class Layout;
class Manager;
class SaveLayoutOptions;
class LayoutToNetlist;
}
namespace lay {
@@ -2293,7 +2294,7 @@ public:
void remove_rdb (unsigned int index);
/**
* @brief Get the number of databases
* @brief Get the number of marker databases
*/
unsigned int num_rdbs () const
{
@@ -2307,6 +2308,61 @@ public:
*/
tl::Event rdb_list_changed_event;
/**
* @brief Add a Netlist database
*
* The layout view will become owner of the database.
*
* @param l2ndb The database to add
* @return The index of the database
*/
unsigned int add_l2ndb (db::LayoutToNetlist *l2ndb);
/**
* @brief Get the netlist database by index
*
* @param index The index of the database
* @return A pointer to the database or 0 if the index was not valid.
*/
db::LayoutToNetlist *get_l2ndb (int index);
/**
* @brief Get the netlist database by index (const version)
*
* @param index The index of the database
* @return A pointer to the database or 0 if the index was not valid.
*/
const db::LayoutToNetlist *get_l2ndb (int index) const;
/**
* @brief Open the L2NDB browser for a given database and associated cv index
*/
void open_l2ndb_browser (int l2ndb_index, int cv_index);
/**
* @brief Remove the netlist database with the given index
*
* This will release the netlist database at the given index. The list
* will be reduced by that element. This means, that the following elements
* will have different indicies.
*/
void remove_l2ndb (unsigned int index);
/**
* @brief Get the number of netlist databases
*/
unsigned int num_l2ndbs () const
{
return (unsigned int) m_l2ndbs.size ();
}
/**
* @brief An event signalling a change in the netlist database list
*
* If netlist databases are added or removed, this event is triggered.
*/
tl::Event l2ndb_list_changed_event;
/**
* @brief Deliver a size hint (reimplementation of QWidget)
*/
@@ -2635,6 +2691,7 @@ private:
std::vector <std::set <cell_index_type> > m_hidden_cells;
std::string m_title;
tl::vector <rdb::Database *> m_rdbs;
tl::vector <db::LayoutToNetlist *> m_l2ndbs;
std::string m_def_lyp_file;
bool m_add_other_layers;
bool m_always_show_source;
+43 -43
View File
@@ -34,17 +34,17 @@ namespace lay
// ------------------------------------------------------------
// Declaration of the configuration options
std::string cfg_l2n_context_mode ("l2n-context-mode");
std::string cfg_l2n_show_all ("l2n-show-all");
std::string cfg_l2n_window_state ("l2n-window-state");
std::string cfg_l2n_window_mode ("l2n-window-mode");
std::string cfg_l2n_window_dim ("l2n-window-dim");
std::string cfg_l2n_max_marker_count ("l2n-max-marker-count");
std::string cfg_l2n_highlight_color ("l2n-highlight-color");
std::string cfg_l2n_highlight_line_width ("l2n-highlight-line-width");
std::string cfg_l2n_highlight_vertex_size ("l2n-highlight-vertex-size");
std::string cfg_l2n_highlight_halo ("l2n-highlight-halo");
std::string cfg_l2n_highlight_dither_pattern ("l2n-highlight-dither-pattern");
std::string cfg_l2ndb_context_mode ("l2n-context-mode");
std::string cfg_l2ndb_show_all ("l2n-show-all");
std::string cfg_l2ndb_window_state ("l2n-window-state");
std::string cfg_l2ndb_window_mode ("l2n-window-mode");
std::string cfg_l2ndb_window_dim ("l2n-window-dim");
std::string cfg_l2ndb_max_marker_count ("l2n-max-marker-count");
std::string cfg_l2ndb_highlight_color ("l2n-highlight-color");
std::string cfg_l2ndb_highlight_line_width ("l2n-highlight-line-width");
std::string cfg_l2ndb_highlight_vertex_size ("l2n-highlight-vertex-size");
std::string cfg_l2ndb_highlight_halo ("l2n-highlight-halo");
std::string cfg_l2ndb_highlight_dither_pattern ("l2n-highlight-dither-pattern");
// ------------------------------------------------------------
@@ -136,22 +136,22 @@ NetlistBrowserConfigPage::setup (lay::PluginRoot *root)
{
// context mode
lay::NetlistBrowserConfig::net_context_mode_type cmode = lay::NetlistBrowserConfig::NetlistTop;
root->config_get (cfg_l2n_context_mode, cmode, NetlistBrowserContextModeConverter ());
root->config_get (cfg_l2ndb_context_mode, cmode, NetlistBrowserContextModeConverter ());
cbx_context->setCurrentIndex (int (cmode));
// window mode
lay::NetlistBrowserConfig::net_window_type wmode = lay::NetlistBrowserConfig::FitNet;
root->config_get (cfg_l2n_window_mode, wmode, NetlistBrowserWindowModeConverter ());
root->config_get (cfg_l2ndb_window_mode, wmode, NetlistBrowserWindowModeConverter ());
cbx_window->setCurrentIndex (int (wmode));
// window dimension
double wdim = 1.0;
root->config_get (cfg_l2n_window_dim, wdim);
root->config_get (cfg_l2ndb_window_dim, wdim);
le_window->setText (tl::to_qstring (tl::to_string (wdim)));
// max. marker count
unsigned int max_marker_count = 1000;
root->config_get (cfg_l2n_max_marker_count, max_marker_count);
root->config_get (cfg_l2ndb_max_marker_count, max_marker_count);
le_max_markers->setText (tl::to_qstring (tl::to_string (max_marker_count)));
// enable controls
@@ -173,10 +173,10 @@ NetlistBrowserConfigPage::commit (lay::PluginRoot *root)
unsigned int max_markers_count = 1000;
tl::from_string (tl::to_string (le_max_markers->text ()), max_markers_count);
root->config_set (cfg_l2n_context_mode, lay::NetlistBrowserConfig::net_context_mode_type (cbx_context->currentIndex ()), NetlistBrowserContextModeConverter ());
root->config_set (cfg_l2n_window_mode, lay::NetlistBrowserConfig::net_window_type (cbx_window->currentIndex ()), NetlistBrowserWindowModeConverter ());
root->config_set (cfg_l2n_window_dim, dim);
root->config_set (cfg_l2n_max_marker_count, max_markers_count);
root->config_set (cfg_l2ndb_context_mode, lay::NetlistBrowserConfig::net_context_mode_type (cbx_context->currentIndex ()), NetlistBrowserContextModeConverter ());
root->config_set (cfg_l2ndb_window_mode, lay::NetlistBrowserConfig::net_window_type (cbx_window->currentIndex ()), NetlistBrowserWindowModeConverter ());
root->config_set (cfg_l2ndb_window_dim, dim);
root->config_set (cfg_l2ndb_max_marker_count, max_markers_count);
}
// ------------------------------------------------------------
@@ -193,12 +193,12 @@ NetlistBrowserConfigPage2::setup (lay::PluginRoot *root)
{
// marker color
QColor color;
root->config_get (cfg_l2n_highlight_color, color, lay::ColorConverter ());
root->config_get (cfg_l2ndb_highlight_color, color, lay::ColorConverter ());
color_pb->set_color (color);
// marker line width
int lw = 0;
root->config_get (cfg_l2n_highlight_line_width, lw);
root->config_get (cfg_l2ndb_highlight_line_width, lw);
if (lw < 0) {
lw_le->setText (QString ());
} else {
@@ -207,7 +207,7 @@ NetlistBrowserConfigPage2::setup (lay::PluginRoot *root)
// marker vertex size
int vs = 0;
root->config_get (cfg_l2n_highlight_vertex_size, vs);
root->config_get (cfg_l2ndb_highlight_vertex_size, vs);
if (vs < 0) {
vs_le->setText (QString ());
} else {
@@ -216,12 +216,12 @@ NetlistBrowserConfigPage2::setup (lay::PluginRoot *root)
// stipple pattern
int dp = 0;
root->config_get (cfg_l2n_highlight_dither_pattern, dp);
root->config_get (cfg_l2ndb_highlight_dither_pattern, dp);
stipple_pb->set_dither_pattern (dp);
// halo
int halo = 0;
root->config_get (cfg_l2n_highlight_halo, halo);
root->config_get (cfg_l2ndb_highlight_halo, halo);
halo_cb->setCheckState (halo < 0 ? Qt::PartiallyChecked : (halo ? Qt::Checked : Qt::Unchecked));
}
@@ -229,36 +229,36 @@ void
NetlistBrowserConfigPage2::commit (lay::PluginRoot *root)
{
QColor color (color_pb->get_color ());
root->config_set (cfg_l2n_highlight_color, color, lay::ColorConverter ());
root->config_set (cfg_l2ndb_highlight_color, color, lay::ColorConverter ());
if (lw_le->text ().isEmpty ()) {
root->config_set (cfg_l2n_highlight_line_width, -1);
root->config_set (cfg_l2ndb_highlight_line_width, -1);
} else {
try {
int s;
tl::from_string (tl::to_string (lw_le->text ()), s);
root->config_set (cfg_l2n_highlight_line_width, s);
root->config_set (cfg_l2ndb_highlight_line_width, s);
} catch (...) { }
}
if (vs_le->text ().isEmpty ()) {
root->config_set (cfg_l2n_highlight_vertex_size, -1);
root->config_set (cfg_l2ndb_highlight_vertex_size, -1);
} else {
try {
int s;
tl::from_string (tl::to_string (vs_le->text ()), s);
root->config_set (cfg_l2n_highlight_vertex_size, s);
root->config_set (cfg_l2ndb_highlight_vertex_size, s);
} catch (...) { }
}
root->config_set (cfg_l2n_highlight_dither_pattern, stipple_pb->dither_pattern ());
root->config_set (cfg_l2ndb_highlight_dither_pattern, stipple_pb->dither_pattern ());
if (halo_cb->checkState () == Qt::PartiallyChecked) {
root->config_set (cfg_l2n_highlight_halo, -1);
root->config_set (cfg_l2ndb_highlight_halo, -1);
} else if (halo_cb->checkState () == Qt::Unchecked) {
root->config_set (cfg_l2n_highlight_halo, 0);
root->config_set (cfg_l2ndb_highlight_halo, 0);
} else if (halo_cb->checkState () == Qt::Checked) {
root->config_set (cfg_l2n_highlight_halo, 1);
root->config_set (cfg_l2ndb_highlight_halo, 1);
}
}
@@ -271,16 +271,16 @@ class NetlistBrowserPluginDeclaration
public:
virtual void get_options (std::vector < std::pair<std::string, std::string> > &options) const
{
options.push_back (std::pair<std::string, std::string> (cfg_l2n_context_mode, "netlist-top"));
options.push_back (std::pair<std::string, std::string> (cfg_l2n_window_mode, "fit-net"));
options.push_back (std::pair<std::string, std::string> (cfg_l2n_window_state, ""));
options.push_back (std::pair<std::string, std::string> (cfg_l2n_window_dim, "1.0"));
options.push_back (std::pair<std::string, std::string> (cfg_l2n_max_marker_count, "1000"));
options.push_back (std::pair<std::string, std::string> (cfg_l2n_highlight_color, lay::ColorConverter ().to_string (QColor ())));
options.push_back (std::pair<std::string, std::string> (cfg_l2n_highlight_line_width, "-1"));
options.push_back (std::pair<std::string, std::string> (cfg_l2n_highlight_vertex_size, "-1"));
options.push_back (std::pair<std::string, std::string> (cfg_l2n_highlight_halo, "-1"));
options.push_back (std::pair<std::string, std::string> (cfg_l2n_highlight_dither_pattern, "-1"));
options.push_back (std::pair<std::string, std::string> (cfg_l2ndb_context_mode, "netlist-top"));
options.push_back (std::pair<std::string, std::string> (cfg_l2ndb_window_mode, "fit-net"));
options.push_back (std::pair<std::string, std::string> (cfg_l2ndb_window_state, ""));
options.push_back (std::pair<std::string, std::string> (cfg_l2ndb_window_dim, "1.0"));
options.push_back (std::pair<std::string, std::string> (cfg_l2ndb_max_marker_count, "1000"));
options.push_back (std::pair<std::string, std::string> (cfg_l2ndb_highlight_color, lay::ColorConverter ().to_string (QColor ())));
options.push_back (std::pair<std::string, std::string> (cfg_l2ndb_highlight_line_width, "-1"));
options.push_back (std::pair<std::string, std::string> (cfg_l2ndb_highlight_vertex_size, "-1"));
options.push_back (std::pair<std::string, std::string> (cfg_l2ndb_highlight_halo, "-1"));
options.push_back (std::pair<std::string, std::string> (cfg_l2ndb_highlight_dither_pattern, "-1"));
}
virtual std::vector<std::pair <std::string, lay::ConfigPage *> > config_pages (QWidget *parent) const
+80 -134
View File
@@ -29,7 +29,7 @@
#include "layConverters.h"
#include "layQtTools.h"
#include "layConfigurationDialog.h"
#include "dbLayoutUtils.h"
#include "dbLayoutToNetlist.h"
#include "dbRecursiveShapeIterator.h"
#include <QMessageBox>
@@ -40,17 +40,17 @@
namespace lay
{
extern std::string cfg_l2n_context_mode;
extern std::string cfg_l2n_show_all;
extern std::string cfg_l2n_window_state;
extern std::string cfg_l2n_window_mode;
extern std::string cfg_l2n_window_dim;
extern std::string cfg_l2n_max_marker_count;
extern std::string cfg_l2n_highlight_color;
extern std::string cfg_l2n_highlight_line_width;
extern std::string cfg_l2n_highlight_vertex_size;
extern std::string cfg_l2n_highlight_halo;
extern std::string cfg_l2n_highlight_dither_pattern;
extern std::string cfg_l2ndb_context_mode;
extern std::string cfg_l2ndb_show_all;
extern std::string cfg_l2ndb_window_state;
extern std::string cfg_l2ndb_window_mode;
extern std::string cfg_l2ndb_window_dim;
extern std::string cfg_l2ndb_max_marker_count;
extern std::string cfg_l2ndb_highlight_color;
extern std::string cfg_l2ndb_highlight_line_width;
extern std::string cfg_l2ndb_highlight_vertex_size;
extern std::string cfg_l2ndb_highlight_halo;
extern std::string cfg_l2ndb_highlight_dither_pattern;
NetlistBrowserDialog::NetlistBrowserDialog (lay::PluginRoot *root, lay::LayoutView *vw)
: lay::Browser (root, vw),
@@ -73,7 +73,7 @@ NetlistBrowserDialog::NetlistBrowserDialog (lay::PluginRoot *root, lay::LayoutVi
if (view ()) {
view ()->cellviews_changed_event.add (this, &NetlistBrowserDialog::cellviews_changed);
view ()->cellview_changed_event.add (this, &NetlistBrowserDialog::cellview_changed);
// @@@view ()->l2n_list_changed_event.add (this, &NetlistBrowserDialog::l2ndbs_changed);
view ()->l2ndb_list_changed_event.add (this, &NetlistBrowserDialog::l2ndbs_changed);
}
m_open_action = new QAction (QObject::tr ("Open"), file_menu);
@@ -129,37 +129,11 @@ NetlistBrowserDialog::unload_all_clicked ()
{
BEGIN_PROTECTED
#if 0 // @@@
bool modified = false;
for (int i = 0; i < int (view ()->num_rdbs ()); ++i) {
rdb::Database *rdb = view ()->get_rdb (i);
if (rdb && rdb->is_modified ()) {
modified = true;
break;
}
}
if (modified) {
QMessageBox msgbox (QMessageBox::Question, QObject::tr ("Unload Without Saving"),
QObject::tr ("At least one database was not saved.\nPress 'Continue' to continue anyway or 'Cancel' for not unloading the database."));
QPushButton *ok = msgbox.addButton (QObject::tr ("Continue"), QMessageBox::AcceptRole);
msgbox.setDefaultButton (msgbox.addButton (QMessageBox::Cancel));
msgbox.exec ();
if (msgbox.clickedButton () != ok) {
return;
}
}
while (view ()->num_rdbs () > 0) {
view ()->remove_rdb (0);
while (view ()->num_l2ndbs () > 0) {
view ()->remove_l2ndb (0);
}
l2ndb_index_changed (-1);
#endif
END_PROTECTED
}
@@ -169,39 +143,21 @@ NetlistBrowserDialog::unload_clicked ()
{
BEGIN_PROTECTED
#if 0 // @@@
if (m_l2n_index < int (view ()->num_rdbs ()) && m_l2n_index >= 0) {
rdb::Database *rdb = view ()->get_rdb (m_l2n_index);
if (rdb && rdb->is_modified ()) {
QMessageBox msgbox (QMessageBox::Question, QObject::tr ("Unload Without Saving"),
QObject::tr ("The database was not saved.\nPress 'Continue' to continue anyway or 'Cancel' for not unloading the database."));
QPushButton *ok = msgbox.addButton (QObject::tr ("Continue"), QMessageBox::AcceptRole);
msgbox.setDefaultButton (msgbox.addButton (QMessageBox::Cancel));
msgbox.exec ();
if (msgbox.clickedButton () != ok) {
return;
}
}
if (m_l2n_index < int (view ()->num_l2ndbs ()) && m_l2n_index >= 0) {
int new_l2n_index = m_l2n_index;
view ()->remove_rdb (m_l2n_index);
view ()->remove_l2ndb (m_l2n_index);
// try to use another rbd ...
if (new_l2n_index >= int (view ()->num_rdbs ())) {
if (new_l2n_index >= int (view ()->num_l2ndbs ())) {
--new_l2n_index;
}
if (new_l2n_index < int (view ()->num_rdbs ()) && new_l2n_index >= 0) {
if (new_l2n_index < int (view ()->num_l2ndbs ()) && new_l2n_index >= 0) {
l2ndb_index_changed (new_l2n_index);
}
}
#endif
END_PROTECTED
}
@@ -250,26 +206,23 @@ NetlistBrowserDialog::saveas_clicked ()
{
BEGIN_PROTECTED
#if 0 // @@@
if (m_l2n_index < int (view ()->num_rdbs ()) && m_l2n_index >= 0) {
if (m_l2n_index < int (view ()->num_l2ndbs ()) && m_l2n_index >= 0) {
rdb::Database *rdb = view ()->get_rdb (m_l2n_index);
if (rdb) {
db::LayoutToNetlist *l2ndb = view ()->get_l2ndb (m_l2n_index);
if (l2ndb) {
// prepare and open the file dialog
lay::FileDialog save_dialog (this, tl::to_string (QObject::tr ("Save Net Database")), "KLayout RDB files (*.lyrdb)");
std::string fn (rdb->filename ());
lay::FileDialog save_dialog (this, tl::to_string (QObject::tr ("Save Netlist Database")), "KLayout L2N DB files (*.l2n)");
std::string fn (l2ndb->filename ());
if (save_dialog.get_save (fn)) {
rdb->save (fn);
rdb->reset_modified ();
l2ndb->save (fn, true);
}
}
}
#endif
END_PROTECTED
}
@@ -279,20 +232,18 @@ NetlistBrowserDialog::reload_clicked ()
{
BEGIN_PROTECTED
#if 0 // @@@
if (m_l2n_index < int (view ()->num_rdbs ()) && m_l2n_index >= 0) {
if (m_l2n_index < int (view ()->num_l2ndbs ()) && m_l2n_index >= 0) {
rdb::Database *rdb = view ()->get_rdb (m_l2n_index);
if (rdb && ! rdb->filename ().empty ()) {
db::LayoutToNetlist *l2ndb = view ()->get_l2ndb (m_l2n_index);
if (l2ndb && ! l2ndb->filename ().empty ()) {
browser_frame->set_rdb (0);
rdb->load (rdb->filename ());
browser_frame->set_rdb (rdb);
browser_frame->set_l2ndb (0);
l2ndb->load (l2ndb->filename ());
browser_frame->set_l2ndb (l2ndb);
}
}
#endif
END_PROTECTED
}
@@ -302,27 +253,30 @@ NetlistBrowserDialog::open_clicked ()
{
BEGIN_PROTECTED
#if 0 // @@@
// collect the formats available ...
std::string fmts = tl::to_string (QObject::tr ("All files (*)"));
#if 0 // @@@ would be good to have this:
// collect the formats available ...
for (tl::Registrar<rdb::FormatDeclaration>::iterator rdr = tl::Registrar<rdb::FormatDeclaration>::begin (); rdr != tl::Registrar<rdb::FormatDeclaration>::end (); ++rdr) {
fmts += ";;" + rdr->file_format ();
}
#else
fmts += ";;L2N DB files (*.l2n)";
// @@@ TODO: add plain spice
#endif
// prepare and open the file dialog
lay::FileDialog open_dialog (this, tl::to_string (QObject::tr ("Marker Database File")), fmts);
lay::FileDialog open_dialog (this, tl::to_string (QObject::tr ("Netlist Database File")), fmts);
if (open_dialog.get_open (m_open_filename)) {
std::auto_ptr <rdb::Database> db (new rdb::Database ());
std::auto_ptr <db::LayoutToNetlist> db (new db::LayoutToNetlist ());
db->load (m_open_filename);
int l2n_index = view ()->add_rdb (db.release ());
l2n_cb->setCurrentIndex (l2n_index);
int l2n_index = view ()->add_l2ndb (db.release ());
l2ndb_cb->setCurrentIndex (l2n_index);
// it looks like the setCurrentIndex does not issue this signal:
l2ndb_index_changed (l2n_index);
}
#endif
END_PROTECTED
}
@@ -334,23 +288,23 @@ NetlistBrowserDialog::configure (const std::string &name, const std::string &val
bool taken = true;
bool show_all = browser_frame->show_all ();
if (name == cfg_l2n_context_mode) {
if (name == cfg_l2ndb_context_mode) {
NetlistBrowserConfig::net_context_mode_type context = m_context;
NetlistBrowserContextModeConverter ().from_string (value, context);
need_update = lay::test_and_set (m_context, context);
} else if (name == cfg_l2n_show_all) {
} else if (name == cfg_l2ndb_show_all) {
tl::from_string (value, show_all);
} else if (name == cfg_l2n_window_mode) {
} else if (name == cfg_l2ndb_window_mode) {
NetlistBrowserConfig::net_window_type window = m_window;
NetlistBrowserWindowModeConverter ().from_string (value, window);
need_update = lay::test_and_set (m_window, window);
} else if (name == cfg_l2n_window_dim) {
} else if (name == cfg_l2ndb_window_dim) {
double wdim = m_window_dim;
tl::from_string (value, wdim);
@@ -359,13 +313,13 @@ NetlistBrowserDialog::configure (const std::string &name, const std::string &val
need_update = true;
}
} else if (name == cfg_l2n_max_marker_count) {
} else if (name == cfg_l2ndb_max_marker_count) {
unsigned int mc = 0;
tl::from_string (value, mc);
need_update = lay::test_and_set (m_max_shape_count, mc);
} else if (name == cfg_l2n_highlight_color) {
} else if (name == cfg_l2ndb_highlight_color) {
QColor color;
if (! value.empty ()) {
@@ -377,7 +331,7 @@ NetlistBrowserDialog::configure (const std::string &name, const std::string &val
need_update = true;
}
} else if (name == cfg_l2n_highlight_line_width) {
} else if (name == cfg_l2ndb_highlight_line_width) {
int lw = 0;
tl::from_string (value, lw);
@@ -387,7 +341,7 @@ NetlistBrowserDialog::configure (const std::string &name, const std::string &val
need_update = true;
}
} else if (name == cfg_l2n_highlight_vertex_size) {
} else if (name == cfg_l2ndb_highlight_vertex_size) {
int vs = 0;
tl::from_string (value, vs);
@@ -397,7 +351,7 @@ NetlistBrowserDialog::configure (const std::string &name, const std::string &val
need_update = true;
}
} else if (name == cfg_l2n_highlight_halo) {
} else if (name == cfg_l2ndb_highlight_halo) {
int halo = 0;
tl::from_string (value, halo);
@@ -407,7 +361,7 @@ NetlistBrowserDialog::configure (const std::string &name, const std::string &val
need_update = true;
}
} else if (name == cfg_l2n_highlight_dither_pattern) {
} else if (name == cfg_l2ndb_highlight_dither_pattern) {
int dp = 0;
tl::from_string (value, dp);
@@ -433,10 +387,9 @@ NetlistBrowserDialog::configure (const std::string &name, const std::string &val
}
void
NetlistBrowserDialog::load (int l2n_index, int cv_index)
NetlistBrowserDialog::load (int l2ndb_index, int cv_index)
{
#if 0 // @@@ TODO: implement
if (! view ()->get_rdb (l2n_index)) {
if (! view ()->get_l2ndb (l2ndb_index)) {
return;
}
@@ -447,39 +400,36 @@ NetlistBrowserDialog::load (int l2n_index, int cv_index)
}
// set the new references (by name)
m_l2n_name = view ()->get_rdb (l2n_index)->name ();
m_l2ndb_name = view ()->get_l2ndb (l2ndb_index)->name ();
// force an update
rdbs_changed ();
l2ndbs_changed ();
cellviews_changed ();
activate ();
#endif
}
void
NetlistBrowserDialog::l2ndbs_changed ()
{
#if 0 // @@@ TODO: implement
int l2n_index = -1;
l2n_cb->clear ();
l2ndb_cb->clear ();
for (unsigned int i = 0; i < view ()->num_rdbs (); ++i) {
const rdb::Database *rdb = view ()->get_rdb (i);
l2n_cb->addItem (tl::to_qstring (rdb->name ()));
if (rdb->name () == m_l2n_name) {
for (unsigned int i = 0; i < view ()->num_l2ndbs (); ++i) {
const db::LayoutToNetlist *l2ndb = view ()->get_l2ndb (i);
l2ndb_cb->addItem (tl::to_qstring (l2ndb->name ()));
if (l2ndb->name () == m_l2ndb_name) {
l2n_index = i;
}
}
// force an update
m_l2n_index = l2n_index;
l2n_cb->setCurrentIndex (l2n_index);
l2ndb_cb->setCurrentIndex (l2n_index);
if (active ()) {
update_content ();
}
#endif
}
void
@@ -532,10 +482,9 @@ NetlistBrowserDialog::cv_index_changed (int index)
void
NetlistBrowserDialog::activated ()
{
#if 0 // @@@ TODO: implement
std::string state;
if (lay::PluginRoot::instance ()) {
lay::PluginRoot::instance ()->config_get (cfg_l2n_window_state, state);
lay::PluginRoot::instance ()->config_get (cfg_l2ndb_window_state, state);
}
lay::restore_dialog_state (this, state);
@@ -545,42 +494,40 @@ NetlistBrowserDialog::activated ()
m_cv_index = view ()->active_cellview_index ();
}
if (m_l2n_index < 0 && view ()->get_rdb (0) != 0) {
if (m_l2n_index < 0 && view ()->get_l2ndb (0) != 0) {
m_l2n_name = view ()->get_rdb (0)->name ();
rdbs_changed ();
m_l2ndb_name = view ()->get_l2ndb (0)->name ();
l2ndbs_changed ();
} else {
update_content ();
}
#endif
}
void
NetlistBrowserDialog::update_content ()
{
#if 0 // @@@ TODO: implement
rdb::Database *rdb = view ()->get_rdb (m_l2n_index);
db::LayoutToNetlist *l2ndb = view ()->get_l2ndb (m_l2n_index);
if (!rdb ) {
if (! l2ndb) {
central_stack->setCurrentIndex (1);
}
m_saveas_action->setEnabled (rdb != 0);
m_export_action->setEnabled (rdb != 0);
m_unload_action->setEnabled (rdb != 0);
m_unload_all_action->setEnabled (rdb != 0);
m_reload_action->setEnabled (rdb != 0);
m_saveas_action->setEnabled (l2ndb != 0);
m_export_action->setEnabled (l2ndb != 0);
m_unload_action->setEnabled (l2ndb != 0);
m_unload_all_action->setEnabled (l2ndb != 0);
m_reload_action->setEnabled (l2ndb != 0);
browser_frame->enable_updates (false); // Avoid building the internal lists several times ...
browser_frame->set_rdb (rdb);
browser_frame->set_max_marker_count (m_max_marker_count);
browser_frame->set_marker_style (m_marker_color, m_marker_line_width, m_marker_vertex_size, m_marker_halo, m_marker_dither_pattern);
browser_frame->set_l2ndb (l2ndb);
browser_frame->set_max_shape_count (m_max_shape_count);
browser_frame->set_highlight_style (m_marker_color, m_marker_line_width, m_marker_vertex_size, m_marker_halo, m_marker_dither_pattern);
browser_frame->set_window (m_window, m_window_dim, m_context);
browser_frame->set_view (view (), m_cv_index);
browser_frame->enable_updates (true);
if (rdb) {
if (l2ndb) {
// Note: it appears to be required to show the browser page after it has been configured.
// Otherwise the header gets messed up and the configuration is reset.
central_stack->setCurrentIndex (0);
@@ -596,20 +543,19 @@ NetlistBrowserDialog::update_content ()
layout_cb->setCurrentIndex (m_cv_index);
}
if (l2n_cb->currentIndex () != m_l2n_index) {
l2n_cb->setCurrentIndex (m_l2n_index);
if (l2ndb_cb->currentIndex () != m_l2n_index) {
l2ndb_cb->setCurrentIndex (m_l2n_index);
}
#endif
}
void
NetlistBrowserDialog::deactivated ()
{
if (lay::PluginRoot::instance ()) {
lay::PluginRoot::instance ()->config_set (cfg_l2n_window_state, lay::save_dialog_state (this).c_str ());
lay::PluginRoot::instance ()->config_set (cfg_l2ndb_window_state, lay::save_dialog_state (this).c_str ());
}
// @@@ browser_frame->set_rdb (0);
browser_frame->set_l2ndb (0);
browser_frame->set_view (0, 0);
}
@@ -80,7 +80,7 @@ private:
int m_marker_dither_pattern;
std::string m_layout_name;
int m_cv_index;
std::string m_lay_name;
std::string m_l2ndb_name;
int m_l2n_index;
std::string m_open_filename;
QAction *m_open_action;
+65 -2
View File
@@ -26,7 +26,7 @@
namespace lay
{
extern std::string cfg_l2n_show_all;
extern std::string cfg_l2ndb_show_all;
// ----------------------------------------------------------------------------------
// NetlistBrowserPage implementation
@@ -122,7 +122,7 @@ void
NetlistBrowserPage::show_all_clicked ()
{
if (mp_plugin_root) {
mp_plugin_root->config_set (cfg_l2n_show_all, tl::to_string (m_show_all_action->isChecked ()));
mp_plugin_root->config_set (cfg_l2ndb_show_all, tl::to_string (m_show_all_action->isChecked ()));
}
}
@@ -168,5 +168,68 @@ NetlistBrowserPage::update_highlights ()
#endif
}
void
NetlistBrowserPage::set_l2ndb (db::LayoutToNetlist *database)
{
#if 0 // @@@
if (database != mp_database) {
release_markers ();
mp_database = database;
QAbstractItemModel *tree_model = directory_tree->model ();
MarkerBrowserTreeViewModel *new_model = new MarkerBrowserTreeViewModel ();
new_model->set_show_empty_ones (true);
new_model->set_database (database);
directory_tree->setModel (new_model);
connect (directory_tree->selectionModel (), SIGNAL (selectionChanged (const QItemSelection &, const QItemSelection &)), this, SLOT (directory_selection_changed (const QItemSelection &, const QItemSelection &)));
directory_tree->header ()->setSortIndicatorShown (true);
cat_filter->setText (QString ());
cell_filter->setText (QString ());
set_hidden_rec (new_model, directory_tree, QModelIndex (), m_show_all, QString (), QString ());
if (tree_model) {
delete tree_model;
}
QAbstractItemModel *list_model = markers_list->model ();
MarkerBrowserListViewModel *new_list_model = new MarkerBrowserListViewModel ();
new_list_model->set_database (database);
markers_list->setModel (new_list_model);
connect (markers_list->selectionModel (), SIGNAL (selectionChanged (const QItemSelection &, const QItemSelection &)), this, SLOT (markers_selection_changed (const QItemSelection &, const QItemSelection &)));
connect (markers_list->selectionModel (), SIGNAL (currentChanged (const QModelIndex &, const QModelIndex &)), this, SLOT (markers_current_changed (const QModelIndex &, const QModelIndex &)));
if (list_model) {
delete list_model;
}
}
#endif
}
void
NetlistBrowserPage::enable_updates (bool f)
{
#if 0 // @@@
if (f != m_enable_updates) {
m_enable_updates = f;
if (f && m_update_needed) {
update_markers ();
update_info_text ();
}
m_update_needed = false;
}
#endif
}
}
+17 -5
View File
@@ -32,17 +32,16 @@
class QAction;
namespace lay
namespace db
{
class LayoutView;
class DMarker;
class PluginRoot;
class LayoutToNetlist;
}
namespace lay
{
class Database;
class LayoutView;
class PluginRoot;
/**
* @brief A marker browser page
@@ -78,6 +77,14 @@ public:
*/
void set_view (lay::LayoutView *view, unsigned int cv_index);
/**
* @brief Attach the page to a L2N DB
*
* To detach the page from any L2N DB, pass 0 for the pointer.
*/
void set_l2ndb (db::LayoutToNetlist *database);
/**
* @brief Set the window type and window dimensions
*/
@@ -122,6 +129,11 @@ public:
*/
void show_all (bool f);
/**
* @brief Enable or disable updates
*/
void enable_updates (bool f);
private slots:
void show_all_clicked ();
void filter_changed ();