mirror of https://github.com/KLayout/klayout.git
WIP: integration of LVSDB into LayoutView (GSI)
This commit is contained in:
parent
58b9cfa3c5
commit
14bc72039e
|
|
@ -28,6 +28,9 @@
|
|||
#include "dbCellMapping.h"
|
||||
#include "dbLayoutToNetlistWriter.h"
|
||||
#include "dbLayoutToNetlistReader.h"
|
||||
#include "dbLayoutVsSchematic.h"
|
||||
#include "dbLayoutToNetlistFormatDefs.h"
|
||||
#include "dbLayoutVsSchematicFormatDefs.h"
|
||||
|
||||
namespace db
|
||||
{
|
||||
|
|
@ -1066,4 +1069,28 @@ void db::LayoutToNetlist::load (const std::string &path)
|
|||
reader.read (this);
|
||||
}
|
||||
|
||||
db::LayoutToNetlist *db::LayoutToNetlist::create_from_file (const std::string &path)
|
||||
{
|
||||
std::auto_ptr<db::LayoutToNetlist> db;
|
||||
|
||||
// TODO: generic concept to detect format
|
||||
std::string first_line;
|
||||
{
|
||||
tl::InputStream stream (path);
|
||||
tl::TextInputStream text_stream (stream);
|
||||
first_line = text_stream.get_line ();
|
||||
}
|
||||
|
||||
if (first_line.find (db::lvs_std_format::keys<false>::lvs_magic_string) == 0) {
|
||||
db::LayoutVsSchematic *lvs_db = new db::LayoutVsSchematic ();
|
||||
db.reset (lvs_db);
|
||||
lvs_db->load (path);
|
||||
} else {
|
||||
db.reset (new db::LayoutToNetlist ());
|
||||
db->load (path);
|
||||
}
|
||||
|
||||
return db.release ();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -666,6 +666,16 @@ public:
|
|||
*/
|
||||
void load (const std::string &path);
|
||||
|
||||
/**
|
||||
* @brief Creates a LayoutToNetlist object from a file
|
||||
*
|
||||
* This method analyses the file and will create a LayoutToNetlist object
|
||||
* or one of a derived class (specifically LayoutVsSchematic).
|
||||
*
|
||||
* The returned object is new'd one and must be deleted by the caller.
|
||||
*/
|
||||
static db::LayoutToNetlist *create_from_file (const std::string &path);
|
||||
|
||||
private:
|
||||
// no copying
|
||||
LayoutToNetlist (const db::LayoutToNetlist &other);
|
||||
|
|
|
|||
|
|
@ -1095,9 +1095,7 @@ ApplicationBase::run ()
|
|||
}
|
||||
|
||||
if (mw->current_view () != 0) {
|
||||
std::auto_ptr <db::LayoutToNetlist> db (new db::LayoutToNetlist ());
|
||||
db->load (f->second.first);
|
||||
int l2ndb_index = mw->current_view ()->add_l2ndb (db.release ());
|
||||
int l2ndb_index = mw->current_view ()->add_l2ndb (db::LayoutToNetlist::create_from_file (f->second.first));
|
||||
mw->current_view ()->open_l2ndb_browser (l2ndb_index, mw->current_view ()->active_cellview_index ());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
#include "layLineStyles.h"
|
||||
#include "dbSaveLayoutOptions.h"
|
||||
#include "dbLayoutToNetlist.h"
|
||||
#include "dbLayoutVsSchematic.h"
|
||||
#include "tlStream.h"
|
||||
|
||||
#if defined(HAVE_QTBINDINGS)
|
||||
|
|
@ -204,6 +205,24 @@ static unsigned int create_l2ndb (lay::LayoutView *view, const std::string &name
|
|||
return view->add_l2ndb (db);
|
||||
}
|
||||
|
||||
static unsigned int create_lvsdb (lay::LayoutView *view, const std::string &name)
|
||||
{
|
||||
db::LayoutVsSchematic *db = new db::LayoutVsSchematic ();
|
||||
db->set_name (name);
|
||||
return view->add_l2ndb (db);
|
||||
}
|
||||
|
||||
static db::LayoutVsSchematic *get_lvsdb (lay::LayoutView *view, unsigned int index)
|
||||
{
|
||||
db::LayoutToNetlist *db = view->get_l2ndb (index);
|
||||
return dynamic_cast<db::LayoutVsSchematic *> (db);
|
||||
}
|
||||
|
||||
static void add_lvsdb (lay::LayoutView *view, db::LayoutVsSchematic *lvsdb)
|
||||
{
|
||||
view->add_l2ndb (lvsdb);
|
||||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
|
|
@ -1497,6 +1516,39 @@ Class<lay::LayoutView> decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou
|
|||
"\n"
|
||||
"This method has been added in version 0.26."
|
||||
) +
|
||||
gsi::method_ext ("lvsdb", &get_lvsdb, gsi::arg ("index"),
|
||||
"@brief Gets the netlist database with the given index\n"
|
||||
"@return The \\LayoutVsSchematic object or nil if the index is not valid"
|
||||
"\n"
|
||||
"This method has been added in version 0.26."
|
||||
) +
|
||||
gsi::method_ext ("add_lvsdb", &add_lvsdb, gsi::arg ("db"),
|
||||
"@brief Adds the given database to the view\n"
|
||||
"\n"
|
||||
"This method will add an existing database to the view. It will then appear in the netlist database browser.\n"
|
||||
"A similar method is \\create_lvsdb which will create a new database within the view.\n"
|
||||
"\n"
|
||||
"@return The index of the database within the view (see \\lvsdb)\n"
|
||||
"\n"
|
||||
"This method has been added in version 0.26."
|
||||
) +
|
||||
gsi::method_ext ("create_lvsdb", &create_lvsdb, 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 \\lvsdb 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_lvsdb", &lay::LayoutView::open_l2ndb_browser, gsi::arg ("lvsdb_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 \"lvsdb_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.
|
||||
|
|
|
|||
|
|
@ -32,8 +32,6 @@
|
|||
#include "layConfigurationDialog.h"
|
||||
#include "dbLayoutToNetlist.h"
|
||||
#include "dbRecursiveShapeIterator.h"
|
||||
#include "dbLayoutToNetlistFormatDefs.h"
|
||||
#include "dbLayoutVsSchematicFormatDefs.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
#include <QInputDialog>
|
||||
|
|
@ -458,26 +456,7 @@ BEGIN_PROTECTED
|
|||
lay::FileDialog open_dialog (this, tl::to_string (QObject::tr ("Netlist/LVS Database File")), fmts);
|
||||
if (open_dialog.get_open (m_open_filename)) {
|
||||
|
||||
std::auto_ptr <db::LayoutToNetlist> db;
|
||||
|
||||
// TODO: generic concept to detect format
|
||||
std::string first_line;
|
||||
{
|
||||
tl::InputStream stream (m_open_filename);
|
||||
tl::TextInputStream text_stream (stream);
|
||||
first_line = text_stream.get_line ();
|
||||
}
|
||||
|
||||
if (first_line.find (db::lvs_std_format::keys<false>::lvs_magic_string) == 0) {
|
||||
db::LayoutVsSchematic *lvs_db = new db::LayoutVsSchematic ();
|
||||
db.reset (lvs_db);
|
||||
lvs_db->load (m_open_filename);
|
||||
} else {
|
||||
db.reset (new db::LayoutToNetlist ());
|
||||
db->load (m_open_filename);
|
||||
}
|
||||
|
||||
int l2n_index = view ()->add_l2ndb (db.release ());
|
||||
int l2n_index = view ()->add_l2ndb (db::LayoutToNetlist::create_from_file (m_open_filename));
|
||||
l2ndb_cb->setCurrentIndex (l2n_index);
|
||||
// it looks like the setCurrentIndex does not issue this signal:
|
||||
l2ndb_index_changed (l2n_index);
|
||||
|
|
|
|||
Loading…
Reference in New Issue