WIP: net export feature, first part

This commit is contained in:
Matthias Koefferlein 2019-05-02 23:30:44 +02:00
parent 18bbc24484
commit 062b74aad7
8 changed files with 524 additions and 4 deletions

View File

@ -0,0 +1,234 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>NetExportDialog</class>
<widget class="QDialog" name="NetExportDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>531</width>
<height>321</height>
</rect>
</property>
<property name="windowTitle">
<string>Export Net Options</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="7" column="2">
<widget class="QLineEdit" name="device_cell_prefix"/>
</item>
<item row="6" column="0" colspan="3">
<widget class="QCheckBox" name="produce_device_cells_cb">
<property name="text">
<string>Produce cells for devices</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="3">
<widget class="QCheckBox" name="produce_circuit_cells_cb">
<property name="text">
<string>Produce cells for circuits</string>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QLineEdit" name="circuit_cell_prefix"/>
</item>
<item row="3" column="0">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>10</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="7" column="0">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>10</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Net cell name prefix</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLineEdit" name="net_cell_prefix"/>
</item>
<item row="8" column="1" colspan="2">
<widget class="QLabel" name="label_4">
<property name="text">
<string>If this options is selected, each device will be represented by one cell made from the device name and the given prefix. Otherwise, device parts are exported as shapes inside the net.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="10" column="0" colspan="3">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
<item row="9" column="0" colspan="3">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>10</width>
<height>29</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="1">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Cell name prefix</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Cell name prefix</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="3">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>10</height>
</size>
</property>
</spacer>
</item>
<item row="4" column="1" colspan="2">
<widget class="QLabel" name="label">
<property name="text">
<string>If this option is selected, the subcircuits on a net are represented by individual cells. Otherwise the net is exported as a whole into a single cell (flattened).</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="5" column="0" colspan="3">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>10</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>produce_circuit_cells_cb</sender>
<signal>clicked(bool)</signal>
<receiver>circuit_cell_prefix</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>91</x>
<y>72</y>
</hint>
<hint type="destinationlabel">
<x>266</x>
<y>100</y>
</hint>
</hints>
</connection>
<connection>
<sender>produce_device_cells_cb</sender>
<signal>clicked(bool)</signal>
<receiver>device_cell_prefix</receiver>
<slot>setEnabled(bool)</slot>
<hints>
<hint type="sourcelabel">
<x>98</x>
<y>176</y>
</hint>
<hint type="destinationlabel">
<x>317</x>
<y>204</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>NetExportDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>381</x>
<y>284</y>
</hint>
<hint type="destinationlabel">
<x>368</x>
<y>299</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>NetExportDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>461</x>
<y>285</y>
</hint>
<hint type="destinationlabel">
<x>442</x>
<y>298</y>
</hint>
</hints>
</connection>
</connections>
</ui>

View File

@ -236,7 +236,7 @@
<bool>true</bool>
</property>
<attribute name="headerVisible">
<bool>true</bool>
<bool>false</bool>
</attribute>
</widget>
</item>
@ -302,6 +302,16 @@
<string>Case Sensitive</string>
</property>
</action>
<action name="actionExportAll">
<property name="text">
<string>Export All</string>
</property>
</action>
<action name="actionExportSelected">
<property name="text">
<string>Export Selected Nets</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>

View File

@ -0,0 +1,152 @@
/*
KLayout Layout Viewer
Copyright (C) 2006-2019 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 "layNetExportDialog.h"
#include "layPlugin.h"
#include "ui_NetExportDialog.h"
#include <sstream>
namespace lay
{
extern std::string cfg_l2ndb_net_cell_prefix;
extern std::string cfg_l2ndb_circuit_cell_prefix;
extern std::string cfg_l2ndb_produce_circuit_cells;
extern std::string cfg_l2ndb_device_cell_prefix;
extern std::string cfg_l2ndb_produce_device_cells;
NetExportDialog::NetExportDialog (QWidget *parent)
: QDialog (parent)
{
ui = new Ui::NetExportDialog ();
ui->setupUi (this);
}
NetExportDialog::~NetExportDialog ()
{
delete ui;
ui = 0;
}
void
NetExportDialog::set_net_prefix (const std::string &net_prefix)
{
ui->net_cell_prefix->setText (tl::to_qstring (net_prefix));
}
std::string
NetExportDialog::net_prefix ()
{
return tl::to_string (ui->net_cell_prefix->text ());
}
void
NetExportDialog::set_produce_circuit_cells (bool f)
{
ui->circuit_cell_prefix->setEnabled (f);
ui->produce_circuit_cells_cb->setChecked (f);
}
bool
NetExportDialog::produce_circuit_cells ()
{
return ui->produce_circuit_cells_cb->isChecked ();
}
void
NetExportDialog::set_circuit_cell_prefix (const std::string &cell_prefix)
{
ui->circuit_cell_prefix->setText (tl::to_qstring (cell_prefix));
}
std::string
NetExportDialog::circuit_cell_prefix ()
{
return tl::to_string (ui->circuit_cell_prefix->text ());
}
void
NetExportDialog::set_produce_device_cells (bool f)
{
ui->device_cell_prefix->setEnabled (f);
ui->produce_device_cells_cb->setChecked (f);
}
bool
NetExportDialog::produce_device_cells ()
{
return ui->produce_device_cells_cb->isChecked ();
}
void
NetExportDialog::set_device_cell_prefix (const std::string &cell_prefix)
{
ui->device_cell_prefix->setText (tl::to_qstring (cell_prefix));
}
std::string
NetExportDialog::device_cell_prefix ()
{
return tl::to_string (ui->device_cell_prefix->text ());
}
int
NetExportDialog::exec (lay::PluginRoot *plugin_root)
{
std::string v;
plugin_root->config_get (cfg_l2ndb_net_cell_prefix, v);
set_net_prefix (v);
bool f = false;
plugin_root->config_get (cfg_l2ndb_produce_circuit_cells, f);
set_produce_circuit_cells (f);
v.clear ();
plugin_root->config_get (cfg_l2ndb_circuit_cell_prefix, v);
set_circuit_cell_prefix (v);
f = false;
plugin_root->config_get (cfg_l2ndb_produce_device_cells, f);
set_produce_device_cells (f);
v.clear ();
plugin_root->config_get (cfg_l2ndb_device_cell_prefix, v);
set_device_cell_prefix (v);
int ret = QDialog::exec ();
if (ret) {
plugin_root->config_set (cfg_l2ndb_net_cell_prefix, net_prefix ());
plugin_root->config_set (cfg_l2ndb_produce_circuit_cells, tl::to_string (produce_circuit_cells ()));
plugin_root->config_set (cfg_l2ndb_circuit_cell_prefix, circuit_cell_prefix ());
plugin_root->config_set (cfg_l2ndb_produce_device_cells, tl::to_string (produce_device_cells ()));
plugin_root->config_set (cfg_l2ndb_device_cell_prefix, device_cell_prefix ());
}
return ret;
}
}

View File

@ -0,0 +1,80 @@
/*
KLayout Layout Viewer
Copyright (C) 2006-2019 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_layNetExportDialog
#define HDR_layNetExportDialog
#include "ui_NetExportDialog.h"
#include "dbLayoutToNetlist.h"
#include "tlObjectCollection.h"
#include <QDialog>
namespace Ui
{
class NetExportDialog;
}
namespace lay
{
class PluginRoot;
/**
* @brief A dialog showing the details of a net
*/
class NetExportDialog
: public QDialog
{
Q_OBJECT
public:
NetExportDialog (QWidget *parent);
~NetExportDialog ();
void set_net_prefix (const std::string &net_prefix);
std::string net_prefix ();
void set_produce_circuit_cells (bool f);
bool produce_circuit_cells ();
void set_circuit_cell_prefix (const std::string &net_prefix);
std::string circuit_cell_prefix ();
void set_produce_device_cells (bool f);
bool produce_device_cells ();
void set_device_cell_prefix (const std::string &net_prefix);
std::string device_cell_prefix ();
int exec (lay::PluginRoot *mp_plugin_root);
private:
Ui::NetExportDialog *ui;
};
}
#endif

View File

@ -50,6 +50,11 @@ extern const std::string cfg_l2ndb_window_dim ("l2ndb-window-dim");
extern const std::string cfg_l2ndb_max_shapes_highlighted ("l2ndb-max-shapes-highlighted");
extern const std::string cfg_l2ndb_show_all ("l2ndb-show-all");
extern const std::string cfg_l2ndb_window_state ("l2ndb-window-state");
extern const std::string cfg_l2ndb_net_cell_prefix ("l2ndb-net-cell-prefix");
extern const std::string cfg_l2ndb_circuit_cell_prefix ("l2ndb-circuit-cell-prefix");
extern const std::string cfg_l2ndb_produce_circuit_cells ("l2ndb-produce-circuit-cells");
extern const std::string cfg_l2ndb_device_cell_prefix ("l2ndb-device-cell-prefix");
extern const std::string cfg_l2ndb_produce_device_cells ("l2ndb-produce-device-cells");
// ------------------------------------------------------------
@ -335,6 +340,11 @@ public:
options.push_back (std::pair<std::string, std::string> (cfg_l2ndb_marker_intensity, "50"));
options.push_back (std::pair<std::string, std::string> (cfg_l2ndb_show_all, "true"));
options.push_back (std::pair<std::string, std::string> (cfg_l2ndb_window_state, ""));
options.push_back (std::pair<std::string, std::string> (cfg_l2ndb_net_cell_prefix, "NET_"));
options.push_back (std::pair<std::string, std::string> (cfg_l2ndb_produce_circuit_cells, "false"));
options.push_back (std::pair<std::string, std::string> (cfg_l2ndb_circuit_cell_prefix, "CIRCUIT_"));
options.push_back (std::pair<std::string, std::string> (cfg_l2ndb_produce_device_cells, "false"));
options.push_back (std::pair<std::string, std::string> (cfg_l2ndb_device_cell_prefix, "DEVICE_"));
}
virtual std::vector<std::pair <std::string, lay::ConfigPage *> > config_pages (QWidget *parent) const

View File

@ -27,6 +27,7 @@
#include "layLayoutView.h"
#include "layMarker.h"
#include "layNetInfoDialog.h"
#include "layNetExportDialog.h"
#include "tlProgress.h"
#include "dbLayoutToNetlist.h"
#include "dbNetlistDeviceClasses.h"
@ -1766,6 +1767,11 @@ NetlistBrowserPage::NetlistBrowserPage (QWidget * /*parent*/)
sep->setSeparator (true);
directory_tree->addAction (sep);
directory_tree->addAction (color_action);
sep = new QAction (directory_tree);
sep->setSeparator (true);
directory_tree->addAction (sep);
directory_tree->addAction (actionExportSelected);
directory_tree->addAction (actionExportAll);
lay::HTMLItemDelegate *delegate;
@ -1798,6 +1804,9 @@ NetlistBrowserPage::NetlistBrowserPage (QWidget * /*parent*/)
connect (forward, SIGNAL (clicked ()), this, SLOT (navigate_forward ()));
connect (backward, SIGNAL (clicked ()), this, SLOT (navigate_back ()));
connect (actionExportAll, SIGNAL (triggered ()), this, SLOT (export_all ()));
connect (actionExportSelected, SIGNAL (triggered ()), this, SLOT (export_selected ()));
forward->setEnabled (false);
backward->setEnabled (false);
}
@ -2481,5 +2490,23 @@ NetlistBrowserPage::clear_markers ()
mp_markers.clear ();
}
void
NetlistBrowserPage::export_all ()
{
std::auto_ptr<lay::NetExportDialog> dialog (new lay::NetExportDialog (this));
if (dialog->exec (mp_plugin_root)) {
// @@@
}
}
void
NetlistBrowserPage::export_selected ()
{
std::auto_ptr<lay::NetExportDialog> dialog (new lay::NetExportDialog (this));
if (dialog->exec (mp_plugin_root)) {
// @@@
}
}
}

View File

@ -307,6 +307,10 @@ public:
*/
void update_highlights ();
public slots:
void export_all ();
void export_selected ();
private slots:
void show_all_clicked ();
void info_button_pressed ();

View File

@ -70,7 +70,8 @@ FORMS = \
NetlistBrowserConfigPage.ui \
NetlistBrowserConfigPage2.ui \
NetlistBrowserDialog.ui \
NetInfoDialog.ui
NetInfoDialog.ui \
NetExportDialog.ui
RESOURCES = \
laybasicResources.qrc
@ -169,7 +170,8 @@ SOURCES = \
layNetlistBrowserDialog.cc \
layNetlistBrowserPage.cc \
layItemDelegates.cc \
layNetInfoDialog.cc
layNetInfoDialog.cc \
layNetExportDialog.cc
HEADERS = \
gtf.h \
@ -260,7 +262,8 @@ HEADERS = \
layNetlistBrowserDialog.h \
layNetlistBrowserPage.h \
layItemDelegates.h \
layNetInfoDialog.h
layNetInfoDialog.h \
layNetExportDialog.h
INCLUDEPATH += $$TL_INC $$GSI_INC $$DB_INC $$RDB_INC
DEPENDPATH += $$TL_INC $$GSI_INC $$DB_INC $$RDB_INC