mirror of
https://github.com/KLayout/klayout.git
synced 2026-09-01 10:27:53 +02:00
WIP: first steps for making technology a db component.
This commit is contained in:
@@ -1,159 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CommonReaderOptionPage</class>
|
||||
<widget class="QWidget" name="CommonReaderOptionPage">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>629</width>
|
||||
<height>519</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Feature Subset</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="_2">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="enable_text_cbx">
|
||||
<property name="text">
|
||||
<string>Enable text objects</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="enable_properties_cbx">
|
||||
<property name="text">
|
||||
<string>Enable properties</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="layer_subset_grp">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>1</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Layer Subset And Layer Mapping</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<layout class="QGridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="2" column="0" rowspan="10" colspan="2">
|
||||
<widget class="lay::LayerMappingWidget" name="layer_map">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="read_all_cbx">
|
||||
<property name="text">
|
||||
<string>Read all layers (additionally to the ones in the mapping table)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>lay::LayerMappingWidget</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>layLayerMappingWidget.h</header>
|
||||
<container>1</container>
|
||||
<slots>
|
||||
<signal>enable_all_layers(bool)</signal>
|
||||
</slots>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>layer_map</sender>
|
||||
<signal>enable_all_layers(bool)</signal>
|
||||
<receiver>read_all_cbx</receiver>
|
||||
<slot>setChecked(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>131</x>
|
||||
<y>180</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>107</x>
|
||||
<y>139</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
@@ -29,7 +29,7 @@ namespace gsi
|
||||
|
||||
static db::LoadLayoutOptions get_options_from_technology (const std::string &technology)
|
||||
{
|
||||
return lay::Technologies::instance ()->technology_by_name (technology)->load_layout_options ();
|
||||
return db::Technologies::instance ()->technology_by_name (technology)->load_layout_options ();
|
||||
}
|
||||
|
||||
// Extend "LoadLayoutOptions" by contributions from lay
|
||||
|
||||
@@ -1,318 +0,0 @@
|
||||
/*
|
||||
|
||||
KLayout Layout Viewer
|
||||
Copyright (C) 2006-2018 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 "gsiDecl.h"
|
||||
#include "layTechnology.h"
|
||||
#include "tlXMLWriter.h"
|
||||
#include "tlXMLParser.h"
|
||||
|
||||
namespace gsi
|
||||
{
|
||||
|
||||
static std::vector<std::string> technology_names ()
|
||||
{
|
||||
std::vector<std::string> names;
|
||||
for (lay::Technologies::const_iterator t = lay::Technologies::instance ()->begin (); t != lay::Technologies::instance ()->end (); ++t) {
|
||||
names.push_back (t->name ());
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
static lay::Technology *technology_by_name (const std::string &name)
|
||||
{
|
||||
return lay::Technologies::instance ()->technology_by_name (name);
|
||||
}
|
||||
|
||||
static lay::Technology *create_technology (const std::string &name)
|
||||
{
|
||||
lay::Technology *tech = new lay::Technology ();
|
||||
tech->set_name (name);
|
||||
lay::Technologies::instance ()->add_new (tech);
|
||||
return tech;
|
||||
}
|
||||
|
||||
static void remove_technology (const std::string &name)
|
||||
{
|
||||
lay::Technologies::instance ()->remove (name);
|
||||
}
|
||||
|
||||
static bool has_technology (const std::string &name)
|
||||
{
|
||||
return lay::Technologies::instance ()->has_technology (name);
|
||||
}
|
||||
|
||||
static std::string technologies_to_xml ()
|
||||
{
|
||||
return lay::Technologies::instance ()->to_xml ();
|
||||
}
|
||||
|
||||
static void technologies_from_xml (const std::string &s)
|
||||
{
|
||||
lay::Technologies::instance ()->load_from_xml (s);
|
||||
}
|
||||
|
||||
static lay::Technology technology_from_xml (const std::string &s)
|
||||
{
|
||||
lay::Technology tech;
|
||||
tl::XMLStringSource source (s);
|
||||
tl::XMLStruct<lay::Technology> xml_struct ("technology", lay::Technology::xml_elements ());
|
||||
xml_struct.parse (source, tech);
|
||||
return tech;
|
||||
}
|
||||
|
||||
static std::string technology_to_xml (const lay::Technology *tech)
|
||||
{
|
||||
if (! tech) {
|
||||
return std::string ();
|
||||
} else {
|
||||
tl::OutputStringStream os;
|
||||
tl::XMLStruct<lay::Technology> xml_struct ("technology", lay::Technology::xml_elements ());
|
||||
tl::OutputStream oss (os);
|
||||
xml_struct.write (oss, *tech);
|
||||
return os.string ();
|
||||
}
|
||||
}
|
||||
|
||||
static lay::TechnologyComponent *get_component (lay::Technology *tech, const std::string &name)
|
||||
{
|
||||
return tech->component_by_name (name);
|
||||
}
|
||||
|
||||
static std::vector<std::string> get_component_names (const lay::Technology *tech)
|
||||
{
|
||||
return tech->component_names ();
|
||||
}
|
||||
|
||||
gsi::Class<lay::TechnologyComponent> technology_component_decl ("lay", "TechnologyComponent",
|
||||
gsi::method ("name", &lay::TechnologyComponent::name,
|
||||
"@brief Gets the formal name of the technology component\n"
|
||||
"This is the name by which the component can be obtained from a technology using "
|
||||
"\\Technology#component."
|
||||
) +
|
||||
gsi::method ("description", &lay::TechnologyComponent::description,
|
||||
"@brief Gets the human-readable description string of the technology component\n"
|
||||
),
|
||||
"@brief A part of a technology definition\n"
|
||||
"Technology components extend technology definitions (class \\Technology) by "
|
||||
"specialized subfeature definitions. For example, the net tracer supplies "
|
||||
"it's technology-dependent specification through a technology component called "
|
||||
"\\NetTracerTechnology.\n"
|
||||
"\n"
|
||||
"Components are managed within technologies and can be accessed from a technology "
|
||||
"using \\Technology#component.\n"
|
||||
"\n"
|
||||
"This class has been introduced in version 0.25."
|
||||
);
|
||||
|
||||
LAYBASIC_PUBLIC gsi::Class<lay::TechnologyComponent> &decl_layTechnologyComponent () { return technology_component_decl; }
|
||||
|
||||
gsi::Class<lay::Technology> technology_decl ("lay", "Technology",
|
||||
gsi::method ("name", &lay::Technology::name,
|
||||
"@brief Gets the name of the technology"
|
||||
) +
|
||||
gsi::method ("name=", &lay::Technology::set_name, gsi::arg ("name"),
|
||||
"@brief Sets the name of the technology"
|
||||
) +
|
||||
gsi::method ("base_path", &lay::Technology::base_path,
|
||||
"@brief Gets the base path of the technology\n"
|
||||
"\n"
|
||||
"The base path is the effective path where files are read from if their "
|
||||
"file path is a relative one. If the explicit path is set (see \\explicit_base_path=), it is\n"
|
||||
"used. If not, the default path is used. The default path is the one from which\n"
|
||||
"a technology file was imported. The explicit one is the one that is specified\n"
|
||||
"explicitly with \\explicit_base_path=.\n"
|
||||
) +
|
||||
gsi::method ("default_base_path", &lay::Technology::default_base_path,
|
||||
"@brief Gets the default base path\n"
|
||||
"\n"
|
||||
"See \\base_path for details about the default base path.\n"
|
||||
) +
|
||||
gsi::method ("default_base_path=", &lay::Technology::set_default_base_path, gsi::arg ("path"),
|
||||
"@hide\n" // only for testing
|
||||
) +
|
||||
gsi::method ("correct_path", &lay::Technology::correct_path, gsi::arg ("path"),
|
||||
"@brief Makes a file path relative to the base path if one is specified\n"
|
||||
"\n"
|
||||
"This method turns an absolute path into one relative to the base path. "
|
||||
"Only files below the base path will be made relative. Files above or beside "
|
||||
"won't be made relative.\n"
|
||||
"\n"
|
||||
"See \\base_path for details about the default base path.\n"
|
||||
) +
|
||||
gsi::method ("eff_path", &lay::Technology::build_effective_path, gsi::arg ("path"),
|
||||
"@brief Makes a file path relative to the base path if one is specified\n"
|
||||
"\n"
|
||||
"This method will return the actual path for a file from the file's path. "
|
||||
"If the input path is a relative one, it will be made absolute by using the "
|
||||
"base path.\n"
|
||||
"\n"
|
||||
"See \\base_path for details about the default base path.\n"
|
||||
) +
|
||||
gsi::method ("explicit_base_path", &lay::Technology::explicit_base_path,
|
||||
"@brief Gets the explicit base path\n"
|
||||
"\n"
|
||||
"See \\base_path for details about the explicit base path.\n"
|
||||
) +
|
||||
gsi::method ("explicit_base_path=", &lay::Technology::set_explicit_base_path, gsi::arg ("path"),
|
||||
"@brief Sets the explicit base path\n"
|
||||
"\n"
|
||||
"See \\base_path for details about the explicit base path.\n"
|
||||
) +
|
||||
gsi::method ("description", &lay::Technology::description,
|
||||
"@brief Gets the description\n"
|
||||
"\n"
|
||||
"The technology description is shown to the user in technology selection dialogs and for "
|
||||
"display purposes."
|
||||
) +
|
||||
gsi::method ("description=", &lay::Technology::set_description, gsi::arg ("description"),
|
||||
"@brief Sets the description\n"
|
||||
) +
|
||||
gsi::method ("dbu", &lay::Technology::dbu,
|
||||
"@brief Gets the default database unit\n"
|
||||
"\n"
|
||||
"The default database unit is the one used when creating a layout for example."
|
||||
) +
|
||||
gsi::method ("dbu=", &lay::Technology::set_dbu, gsi::arg ("dbu"),
|
||||
"@brief Sets the default database unit\n"
|
||||
) +
|
||||
gsi::method ("layer_properties_file", &lay::Technology::layer_properties_file,
|
||||
"@brief Gets the path of the layer properties file\n"
|
||||
"\n"
|
||||
"If empty, no layer properties file is associated with the technology. "
|
||||
"If non-empty, this path will be corrected by the base path (see \\correct_path) and "
|
||||
"this layer properties file will be loaded for layouts with this technology."
|
||||
) +
|
||||
gsi::method ("layer_properties_file=", &lay::Technology::set_layer_properties_file, gsi::arg ("file"),
|
||||
"@brief Sets the path of the layer properties file\n"
|
||||
"\n"
|
||||
"See \\layer_properties_file for details about this property."
|
||||
) +
|
||||
gsi::method ("eff_layer_properties_file", &lay::Technology::eff_layer_properties_file,
|
||||
"@brief Gets the effective path of the layer properties file\n"
|
||||
) +
|
||||
gsi::method ("add_other_layers?", &lay::Technology::add_other_layers,
|
||||
"@brief Gets the flag indicating whether to add other layers to the layer properties\n"
|
||||
) +
|
||||
gsi::method ("add_other_layers=", &lay::Technology::set_add_other_layers, gsi::arg ("add"),
|
||||
"@brief Sets the flag indicating whether to add other layers to the layer properties\n"
|
||||
) +
|
||||
gsi::method ("load_layout_options", &lay::Technology::load_layout_options,
|
||||
"@brief Gets the layout reader options\n"
|
||||
"\n"
|
||||
"This method returns the layout reader options that are used when reading layouts "
|
||||
"with this technology.\n"
|
||||
"\n"
|
||||
"Change the reader options by modifying the object and using the setter to change it:\n"
|
||||
"\n"
|
||||
"@code\n"
|
||||
"opt = tech.load_layout_options\n"
|
||||
"opt.dxf_dbu = 2.5\n"
|
||||
"tech.load_layout_options = opt\n"
|
||||
"@/code\n"
|
||||
) +
|
||||
gsi::method ("load_layout_options=", &lay::Technology::set_load_layout_options, gsi::arg ("options"),
|
||||
"@brief Sets the layout reader options\n"
|
||||
"\n"
|
||||
"See \\load_layout_options for a description of this property.\n"
|
||||
) +
|
||||
gsi::method ("save_layout_options", &lay::Technology::save_layout_options,
|
||||
"@brief Gets the layout writer options\n"
|
||||
"\n"
|
||||
"This method returns the layout writer options that are used when writing layouts "
|
||||
"with this technology.\n"
|
||||
"\n"
|
||||
"Change the reader options by modifying the object and using the setter to change it:\n"
|
||||
"\n"
|
||||
"@code\n"
|
||||
"opt = tech.save_layout_options\n"
|
||||
"opt.dbu = 0.01\n"
|
||||
"tech.save_layout_options = opt\n"
|
||||
"@/code\n"
|
||||
) +
|
||||
gsi::method ("save_layout_options=", &lay::Technology::set_save_layout_options, gsi::arg ("options"),
|
||||
"@brief Sets the layout writer options\n"
|
||||
"\n"
|
||||
"See \\save_layout_options for a description of this property.\n"
|
||||
) +
|
||||
gsi::method ("load", &lay::Technology::load, gsi::arg ("file"),
|
||||
"@brief Loads the technology definition from a file\n"
|
||||
) +
|
||||
gsi::method ("load", &lay::Technology::save, gsi::arg ("file"),
|
||||
"@brief Saves the technology definition to a file\n"
|
||||
) +
|
||||
gsi::method ("technology_names", &technology_names,
|
||||
"@brief Gets a list of technology names defined in the system\n"
|
||||
) +
|
||||
gsi::method ("technology_by_name", &technology_by_name, gsi::arg ("name"),
|
||||
"@brief Gets the technology object for a given name\n"
|
||||
) +
|
||||
gsi::method ("has_technology?", &has_technology, gsi::arg ("name"),
|
||||
"@brief Returns a value indicating whether there is a technology with this name\n"
|
||||
) +
|
||||
gsi::method ("create_technology", &create_technology, gsi::arg ("name"),
|
||||
"@brief Creates a new (empty) technology with the given name\n"
|
||||
"\n"
|
||||
"This method returns a reference to the new technology."
|
||||
) +
|
||||
gsi::method ("remove_technology", &remove_technology, gsi::arg ("name"),
|
||||
"@brief Removes the technology with the given name\n"
|
||||
) +
|
||||
gsi::method ("technologies_to_xml", &technologies_to_xml,
|
||||
"@brief Returns a XML representation of all technologies registered in the system\n"
|
||||
"\n"
|
||||
"\\technologies_from_xml can be used to restore the technology definitions. "
|
||||
"This method is provided mainly as a substitute for the pre-0.25 way of accessing "
|
||||
"technology data through the 'technology-data' configuration parameter. This method "
|
||||
"will return the equivalent string."
|
||||
) +
|
||||
gsi::method_ext ("to_xml", &technology_to_xml,
|
||||
"@brief Returns a XML representation of this technolog\n"
|
||||
"\n"
|
||||
"\\technology_from_xml can be used to restore the technology definition."
|
||||
) +
|
||||
gsi::method ("technologies_from_xml", &technologies_from_xml, gsi::arg ("xml"),
|
||||
"@brief Loads the technologies from a XML representation\n"
|
||||
"\n"
|
||||
"See \\technologies_to_xml for details. This method is the corresponding setter."
|
||||
) +
|
||||
gsi::method ("technology_from_xml", &technology_from_xml, gsi::arg ("xml"),
|
||||
"@brief Loads the technology from a XML representation\n"
|
||||
"\n"
|
||||
"See \\technology_to_xml for details."
|
||||
) +
|
||||
gsi::method_ext ("component_names", &get_component_names,
|
||||
"@brief Gets the names of all components available for \\component"
|
||||
) +
|
||||
gsi::method_ext ("component", &get_component, gsi::arg ("name"),
|
||||
"@brief Gets the technology component with the given name\n"
|
||||
"The names are unique system identifiers. For all names, use \\component_names."
|
||||
),
|
||||
"@brief Represents a technology\n"
|
||||
"\n"
|
||||
"This class represents one technology from a set of technologies. The set of technologies "
|
||||
"available in the system can be obtained with \\technology_names. Individual technology "
|
||||
"definitions are returned with \\technology_by_name. Use \\create_technology to register "
|
||||
"new technologies and \\remove_technology to delete technologies.\n"
|
||||
"\n"
|
||||
"The Technology class has been introduced in version 0.25.\n"
|
||||
);
|
||||
|
||||
}
|
||||
@@ -203,10 +203,10 @@ LayoutHandle::remove_ref ()
|
||||
}
|
||||
}
|
||||
|
||||
const lay::Technology *
|
||||
const db::Technology *
|
||||
LayoutHandle::technology () const
|
||||
{
|
||||
return lay::Technologies::instance ()->technology_by_name (m_tech_name);
|
||||
return db::Technologies::instance ()->technology_by_name (m_tech_name);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -221,7 +221,7 @@ void
|
||||
LayoutHandle::set_tech_name (const std::string &tn)
|
||||
{
|
||||
if (tn != m_tech_name) {
|
||||
if (lay::Technologies::instance ()->has_technology (tn)) {
|
||||
if (db::Technologies::instance ()->has_technology (tn)) {
|
||||
m_tech_name = tn;
|
||||
} else {
|
||||
m_tech_name = std::string ();
|
||||
|
||||
@@ -108,7 +108,7 @@ public:
|
||||
/**
|
||||
* @brief Gets the technology attached to this layout
|
||||
*/
|
||||
const lay::Technology *technology () const;
|
||||
const db::Technology *technology () const;
|
||||
|
||||
/**
|
||||
* @brief Gets the technology name for this layout
|
||||
|
||||
@@ -1,238 +0,0 @@
|
||||
|
||||
/*
|
||||
|
||||
KLayout Layout Viewer
|
||||
Copyright (C) 2006-2018 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 "dbCommonReader.h"
|
||||
#include "dbLoadLayoutOptions.h"
|
||||
#include "layCommonReaderPlugin.h"
|
||||
#include "ui_CommonReaderOptionsPage.h"
|
||||
#include "gsiDecl.h"
|
||||
|
||||
#include <QFrame>
|
||||
|
||||
namespace lay
|
||||
{
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// CommonReaderOptionPage definition and implementation
|
||||
|
||||
CommonReaderOptionPage::CommonReaderOptionPage (QWidget *parent)
|
||||
: StreamReaderOptionsPage (parent)
|
||||
{
|
||||
mp_ui = new Ui::CommonReaderOptionPage ();
|
||||
mp_ui->setupUi (this);
|
||||
}
|
||||
|
||||
CommonReaderOptionPage::~CommonReaderOptionPage ()
|
||||
{
|
||||
delete mp_ui;
|
||||
mp_ui = 0;
|
||||
}
|
||||
|
||||
void
|
||||
CommonReaderOptionPage::setup (const db::FormatSpecificReaderOptions *o, const lay::Technology * /*tech*/)
|
||||
{
|
||||
static const db::CommonReaderOptions default_options;
|
||||
const db::CommonReaderOptions *options = dynamic_cast<const db::CommonReaderOptions *> (o);
|
||||
if (!options) {
|
||||
options = &default_options;
|
||||
}
|
||||
|
||||
mp_ui->enable_text_cbx->setChecked (options->enable_text_objects);
|
||||
mp_ui->enable_properties_cbx->setChecked (options->enable_properties);
|
||||
mp_ui->layer_map->set_layer_map (options->layer_map);
|
||||
mp_ui->read_all_cbx->setChecked (options->create_other_layers);
|
||||
}
|
||||
|
||||
void
|
||||
CommonReaderOptionPage::commit (db::FormatSpecificReaderOptions *o, const lay::Technology * /*tech*/)
|
||||
{
|
||||
db::CommonReaderOptions *options = dynamic_cast<db::CommonReaderOptions *> (o);
|
||||
if (options) {
|
||||
|
||||
options->enable_text_objects = mp_ui->enable_text_cbx->isChecked ();
|
||||
options->enable_properties = mp_ui->enable_properties_cbx->isChecked ();
|
||||
options->layer_map = mp_ui->layer_map->get_layer_map ();
|
||||
options->create_other_layers = mp_ui->read_all_cbx->isChecked ();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// CommonReaderPluginDeclaration definition and implementation
|
||||
|
||||
class CommonReaderPluginDeclaration
|
||||
: public StreamReaderPluginDeclaration
|
||||
{
|
||||
public:
|
||||
CommonReaderPluginDeclaration ()
|
||||
: StreamReaderPluginDeclaration (db::CommonReaderOptions ().format_name ())
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
StreamReaderOptionsPage *format_specific_options_page (QWidget *parent) const
|
||||
{
|
||||
return new CommonReaderOptionPage (parent);
|
||||
}
|
||||
|
||||
db::FormatSpecificReaderOptions *create_specific_options () const
|
||||
{
|
||||
return new db::CommonReaderOptions ();
|
||||
}
|
||||
|
||||
virtual tl::XMLElementBase *xml_element () const
|
||||
{
|
||||
return new lay::ReaderOptionsXMLElement<db::CommonReaderOptions> ("common",
|
||||
tl::make_member (&db::CommonReaderOptions::create_other_layers, "create-other-layers") +
|
||||
tl::make_member (&db::CommonReaderOptions::layer_map, "layer-map") +
|
||||
tl::make_member (&db::CommonReaderOptions::enable_properties, "enable-properties") +
|
||||
tl::make_member (&db::CommonReaderOptions::enable_text_objects, "enable-text-objects")
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
static tl::RegisteredClass<lay::PluginDeclaration> plugin_decl (new lay::CommonReaderPluginDeclaration (), 10000, "CommonReader");
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// gsi Implementation of specific methods
|
||||
|
||||
static void set_layer_map (db::LoadLayoutOptions *options, const db::LayerMap &lm, bool f)
|
||||
{
|
||||
options->get_options<db::CommonReaderOptions> ().layer_map = lm;
|
||||
options->get_options<db::CommonReaderOptions> ().create_other_layers = f;
|
||||
}
|
||||
|
||||
static db::LayerMap &get_layer_map (db::LoadLayoutOptions *options)
|
||||
{
|
||||
return options->get_options<db::CommonReaderOptions> ().layer_map;
|
||||
}
|
||||
|
||||
static void select_all_layers (db::LoadLayoutOptions *options)
|
||||
{
|
||||
options->get_options<db::CommonReaderOptions> ().layer_map = db::LayerMap ();
|
||||
options->get_options<db::CommonReaderOptions> ().create_other_layers = true;
|
||||
}
|
||||
|
||||
static bool create_other_layers (const db::LoadLayoutOptions *options)
|
||||
{
|
||||
return options->get_options<db::CommonReaderOptions> ().create_other_layers;
|
||||
}
|
||||
|
||||
static void set_create_other_layers (db::LoadLayoutOptions *options, bool l)
|
||||
{
|
||||
options->get_options<db::CommonReaderOptions> ().create_other_layers = l;
|
||||
}
|
||||
|
||||
static bool get_text_enabled (const db::LoadLayoutOptions *options)
|
||||
{
|
||||
return options->get_options<db::CommonReaderOptions> ().enable_text_objects;
|
||||
}
|
||||
|
||||
static void set_text_enabled (db::LoadLayoutOptions *options, bool l)
|
||||
{
|
||||
options->get_options<db::CommonReaderOptions> ().enable_text_objects = l;
|
||||
}
|
||||
|
||||
static bool get_properties_enabled (const db::LoadLayoutOptions *options)
|
||||
{
|
||||
return options->get_options<db::CommonReaderOptions> ().enable_properties;
|
||||
}
|
||||
|
||||
static void set_properties_enabled (db::LoadLayoutOptions *options, bool l)
|
||||
{
|
||||
options->get_options<db::CommonReaderOptions> ().enable_properties = l;
|
||||
}
|
||||
|
||||
// extend lay::LoadLayoutOptions with the Common options
|
||||
static
|
||||
gsi::ClassExt<db::LoadLayoutOptions> common_reader_options (
|
||||
gsi::method_ext ("set_layer_map", &set_layer_map, gsi::arg ("map"), gsi::arg ("create_other_layers"),
|
||||
"@brief Sets the layer map\n"
|
||||
"This sets a layer mapping for the reader. The \"create_other_layers\" specifies whether to create layers that are not "
|
||||
"in the mapping and automatically assign layers to them.\n"
|
||||
"@param map The layer map to set."
|
||||
"@param create_other_layers The flag telling whether other layer should be created also. Set to false if just the layers in the mapping table should be read.\n"
|
||||
"\n"
|
||||
"Starting with version 0.25 this option only applies to GDS2 and OASIS format. Other formats provide their own configuration."
|
||||
) +
|
||||
gsi::method_ext ("select_all_layers", &select_all_layers,
|
||||
"@brief Selects all layers and disables the layer map\n"
|
||||
"\n"
|
||||
"This disables any layer map and enables reading of all layers.\n"
|
||||
"New layers will be created when required.\n"
|
||||
"\n"
|
||||
"Starting with version 0.25 this method only applies to GDS2 and OASIS format. Other formats provide their own configuration."
|
||||
) +
|
||||
gsi::method_ext ("layer_map", &get_layer_map,
|
||||
"@brief Gets the layer map\n"
|
||||
"@return A reference to the layer map\n"
|
||||
"\n"
|
||||
"Starting with version 0.25 this option only applies to GDS2 and OASIS format. Other formats provide their own configuration."
|
||||
) +
|
||||
gsi::method_ext ("create_other_layers?", &create_other_layers,
|
||||
"@brief Gets a value indicating whether other layers shall be created\n"
|
||||
"@return True, if other layers should be created.\n"
|
||||
"\n"
|
||||
"Starting with version 0.25 this option only applies to GDS2 and OASIS format. Other formats provide their own configuration."
|
||||
) +
|
||||
gsi::method_ext ("create_other_layers=", &set_create_other_layers, gsi::arg ("create"),
|
||||
"@brief Specifies whether other layers shall be created\n"
|
||||
"@param create True, if other layers should be created.\n"
|
||||
"\n"
|
||||
"Starting with version 0.25 this option only applies to GDS2 and OASIS format. Other formats provide their own configuration."
|
||||
) +
|
||||
gsi::method_ext ("text_enabled?|#is_text_enabled?", &get_text_enabled,
|
||||
"@brief Gets a value indicating whether text objects shall be read\n"
|
||||
"@return True, if text objects should be read."
|
||||
"\n"
|
||||
"Starting with version 0.25 this option only applies to GDS2 and OASIS format. Other formats provide their own configuration."
|
||||
) +
|
||||
gsi::method_ext ("text_enabled=", &set_text_enabled, gsi::arg ("enabled"),
|
||||
"@brief Specifies whether text objects shall be read\n"
|
||||
"@param enabled True, if text objects should be read."
|
||||
"\n"
|
||||
"Starting with version 0.25 this option only applies to GDS2 and OASIS format. Other formats provide their own configuration."
|
||||
) +
|
||||
gsi::method_ext ("properties_enabled?|#is_properties_enabled?", &get_properties_enabled,
|
||||
"@brief Gets a value indicating whether properties shall be read\n"
|
||||
"@return True, if properties should be read."
|
||||
"\n"
|
||||
"Starting with version 0.25 this option only applies to GDS2 and OASIS format. Other formats provide their own configuration."
|
||||
) +
|
||||
gsi::method_ext ("properties_enabled=", &set_properties_enabled, gsi::arg ("enabled"),
|
||||
"@brief Specifies whether properties should be read\n"
|
||||
"@args enabled\n"
|
||||
"@param enabled True, if properties should be read."
|
||||
"\n"
|
||||
"Starting with version 0.25 this option only applies to GDS2 and OASIS format. Other formats provide their own configuration."
|
||||
),
|
||||
""
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -45,8 +45,8 @@ public:
|
||||
CommonReaderOptionPage (QWidget *parent);
|
||||
~CommonReaderOptionPage ();
|
||||
|
||||
void setup (const db::FormatSpecificReaderOptions *options, const lay::Technology *tech);
|
||||
void commit (db::FormatSpecificReaderOptions *options, const lay::Technology *tech);
|
||||
void setup (const db::FormatSpecificReaderOptions *options, const db::Technology *tech);
|
||||
void commit (db::FormatSpecificReaderOptions *options, const db::Technology *tech);
|
||||
|
||||
private:
|
||||
Ui::CommonReaderOptionPage *mp_ui;
|
||||
|
||||
@@ -115,8 +115,8 @@ NewLayoutPropertiesDialog::tech_changed ()
|
||||
{
|
||||
double dbu = 0.001;
|
||||
int technology_index = mp_ui->tech_cbx->currentIndex ();
|
||||
if (technology_index >= 0 && technology_index < (int) lay::Technologies::instance ()->technologies ()) {
|
||||
dbu = lay::Technologies::instance ()->begin () [technology_index].dbu ();
|
||||
if (technology_index >= 0 && technology_index < (int) db::Technologies::instance ()->technologies ()) {
|
||||
dbu = db::Technologies::instance ()->begin () [technology_index].dbu ();
|
||||
}
|
||||
|
||||
#if QT_VERSION >= 0x40700
|
||||
@@ -129,7 +129,7 @@ NewLayoutPropertiesDialog::exec_dialog (std::string &technology, std::string &ce
|
||||
{
|
||||
mp_ui->tech_cbx->clear ();
|
||||
unsigned int technology_index = 0;
|
||||
for (lay::Technologies::const_iterator t = lay::Technologies::instance ()->begin (); t != lay::Technologies::instance ()->end (); ++t, ++technology_index) {
|
||||
for (db::Technologies::const_iterator t = db::Technologies::instance ()->begin (); t != db::Technologies::instance ()->end (); ++t, ++technology_index) {
|
||||
|
||||
std::string d = t->name ();
|
||||
if (! d.empty () && ! t->description ().empty ()) {
|
||||
@@ -157,8 +157,8 @@ NewLayoutPropertiesDialog::exec_dialog (std::string &technology, std::string &ce
|
||||
|
||||
// get the selected technology name
|
||||
int technology_index = mp_ui->tech_cbx->currentIndex ();
|
||||
if (technology_index >= 0 && technology_index < (int) lay::Technologies::instance ()->technologies ()) {
|
||||
technology = lay::Technologies::instance ()->begin () [technology_index].name ();
|
||||
if (technology_index >= 0 && technology_index < (int) db::Technologies::instance ()->technologies ()) {
|
||||
technology = db::Technologies::instance ()->begin () [technology_index].name ();
|
||||
} else {
|
||||
technology = std::string ();
|
||||
}
|
||||
|
||||
@@ -110,9 +110,9 @@ LayoutPropertiesForm::commit ()
|
||||
// get the selected technology name
|
||||
std::string technology;
|
||||
int technology_index = tech_cbx->currentIndex ();
|
||||
const lay::Technology *tech = 0;
|
||||
if (technology_index >= 0 && technology_index < (int) lay::Technologies::instance ()->technologies ()) {
|
||||
tech = &(lay::Technologies::instance ()->begin () [technology_index]);
|
||||
const db::Technology *tech = 0;
|
||||
if (technology_index >= 0 && technology_index < (int) db::Technologies::instance ()->technologies ()) {
|
||||
tech = &(db::Technologies::instance ()->begin () [technology_index]);
|
||||
technology = tech->name ();
|
||||
}
|
||||
|
||||
@@ -190,7 +190,7 @@ BEGIN_PROTECTED
|
||||
|
||||
tech_cbx->clear ();
|
||||
unsigned int technology_index = 0;
|
||||
for (lay::Technologies::const_iterator t = lay::Technologies::instance ()->begin (); t != lay::Technologies::instance ()->end (); ++t, ++technology_index) {
|
||||
for (db::Technologies::const_iterator t = db::Technologies::instance ()->begin (); t != db::Technologies::instance ()->end (); ++t, ++technology_index) {
|
||||
|
||||
std::string d = t->name ();
|
||||
if (! d.empty () && ! t->description ().empty ()) {
|
||||
|
||||
@@ -2442,7 +2442,7 @@ LayoutView::signal_apply_technology (lay::LayoutHandle *layout_handle)
|
||||
if (cellview (i).handle () == layout_handle) {
|
||||
|
||||
std::string lyp_file;
|
||||
const lay::Technology *tech = lay::Technologies::instance ()->technology_by_name (cellview (i)->tech_name ());
|
||||
const db::Technology *tech = db::Technologies::instance ()->technology_by_name (cellview (i)->tech_name ());
|
||||
if (tech && ! tech->eff_layer_properties_file ().empty ()) {
|
||||
lyp_file = tech->eff_layer_properties_file ();
|
||||
}
|
||||
@@ -3005,7 +3005,7 @@ LayoutView::add_layout (lay::LayoutHandle *layout_handle, bool add_cellview, boo
|
||||
// Use the "layer-properties-file" meta info from the handle to get the layer properties file.
|
||||
// If no such file is present, use the default file or the technology specific file.
|
||||
std::string lyp_file = m_def_lyp_file;
|
||||
const lay::Technology *tech = lay::Technologies::instance ()->technology_by_name (layout_handle->tech_name ());
|
||||
const db::Technology *tech = db::Technologies::instance ()->technology_by_name (layout_handle->tech_name ());
|
||||
if (tech && ! tech->eff_layer_properties_file ().empty ()) {
|
||||
lyp_file = tech->eff_layer_properties_file ();
|
||||
add_other_layers = tech->add_other_layers ();
|
||||
@@ -3072,7 +3072,7 @@ LayoutView::add_layout (lay::LayoutHandle *layout_handle, bool add_cellview, boo
|
||||
unsigned int
|
||||
LayoutView::create_layout (const std::string &technology, bool add_cellview, bool initialize_layers)
|
||||
{
|
||||
const lay::Technology *tech = lay::Technologies::instance ()->technology_by_name (technology);
|
||||
const db::Technology *tech = db::Technologies::instance ()->technology_by_name (technology);
|
||||
|
||||
db::Layout *layout = new db::Layout (manager ());
|
||||
if (tech) {
|
||||
@@ -3097,7 +3097,7 @@ LayoutView::load_layout (const std::string &filename, const db::LoadLayoutOption
|
||||
|
||||
bool set_max_hier = (m_full_hier_new_cell || has_max_hier ());
|
||||
|
||||
const lay::Technology *tech = lay::Technologies::instance ()->technology_by_name (technology);
|
||||
const db::Technology *tech = db::Technologies::instance ()->technology_by_name (technology);
|
||||
|
||||
// create a new layout handle
|
||||
lay::CellView cv;
|
||||
|
||||
@@ -186,7 +186,7 @@ LoadLayoutOptionsDialog::update ()
|
||||
return;
|
||||
}
|
||||
|
||||
const lay::Technology *tech = m_tech_array [m_technology_index];
|
||||
const db::Technology *tech = m_tech_array [m_technology_index];
|
||||
mp_ui->options_tab->setEnabled (tech && tech->is_persisted ());
|
||||
|
||||
for (std::vector< std::pair<StreamReaderOptionsPage *, std::string> >::iterator page = m_pages.begin (); page != m_pages.end (); ++page) {
|
||||
@@ -197,7 +197,7 @@ LoadLayoutOptionsDialog::update ()
|
||||
}
|
||||
|
||||
bool
|
||||
LoadLayoutOptionsDialog::edit_global_options (lay::PluginRoot *config_root, lay::Technologies *technologies)
|
||||
LoadLayoutOptionsDialog::edit_global_options (lay::PluginRoot *config_root, db::Technologies *technologies)
|
||||
{
|
||||
m_opt_array.clear ();
|
||||
m_tech_array.clear ();
|
||||
@@ -219,7 +219,7 @@ LoadLayoutOptionsDialog::edit_global_options (lay::PluginRoot *config_root, lay:
|
||||
unsigned int i = 0;
|
||||
m_technology_index = -1;
|
||||
|
||||
for (lay::Technologies::const_iterator t = technologies->begin (); t != technologies->end (); ++t, ++i) {
|
||||
for (db::Technologies::const_iterator t = technologies->begin (); t != technologies->end (); ++t, ++i) {
|
||||
|
||||
std::string d = t->name ();
|
||||
if (! d.empty () && ! t->description ().empty ()) {
|
||||
@@ -256,7 +256,7 @@ LoadLayoutOptionsDialog::edit_global_options (lay::PluginRoot *config_root, lay:
|
||||
|
||||
i = 0;
|
||||
technologies->begin_updates ();
|
||||
for (lay::Technologies::iterator t = technologies->begin (); t != technologies->end () && i < m_opt_array.size (); ++t, ++i) {
|
||||
for (db::Technologies::iterator t = technologies->begin (); t != technologies->end () && i < m_opt_array.size (); ++t, ++i) {
|
||||
technologies->begin ()[i].set_load_layout_options (m_opt_array [i]);
|
||||
}
|
||||
technologies->end_updates ();
|
||||
|
||||
@@ -39,6 +39,7 @@ class QAbstractButton;
|
||||
namespace db
|
||||
{
|
||||
class LoadLayoutOptions;
|
||||
class Technologies;
|
||||
}
|
||||
|
||||
namespace Ui
|
||||
@@ -53,7 +54,6 @@ namespace lay
|
||||
class LayoutView;
|
||||
class PluginRoot;
|
||||
class FileDialog;
|
||||
class Technologies;
|
||||
|
||||
class LAYBASIC_PUBLIC LoadLayoutOptionsDialog
|
||||
: public QDialog
|
||||
@@ -64,7 +64,7 @@ public:
|
||||
LoadLayoutOptionsDialog (QWidget *parent, const std::string &title);
|
||||
~LoadLayoutOptionsDialog ();
|
||||
|
||||
bool edit_global_options (lay::PluginRoot *config_root, lay::Technologies *technologies);
|
||||
bool edit_global_options (lay::PluginRoot *config_root, db::Technologies *technologies);
|
||||
bool get_options (db::LoadLayoutOptions &options);
|
||||
|
||||
void show_always (bool sa)
|
||||
@@ -89,7 +89,7 @@ private:
|
||||
bool m_show_always;
|
||||
int m_technology_index;
|
||||
std::vector<db::LoadLayoutOptions> m_opt_array;
|
||||
std::vector<const lay::Technology *> m_tech_array;
|
||||
std::vector<const db::Technology *> m_tech_array;
|
||||
|
||||
void commit ();
|
||||
void update ();
|
||||
|
||||
@@ -230,7 +230,7 @@ SaveLayoutOptionsDialog::update ()
|
||||
}
|
||||
|
||||
bool
|
||||
SaveLayoutOptionsDialog::edit_global_options (lay::PluginRoot *config_root, lay::Technologies *technologies)
|
||||
SaveLayoutOptionsDialog::edit_global_options (lay::PluginRoot *config_root, db::Technologies *technologies)
|
||||
{
|
||||
m_opt_array.clear ();
|
||||
m_tech_array.clear ();
|
||||
@@ -244,7 +244,7 @@ SaveLayoutOptionsDialog::edit_global_options (lay::PluginRoot *config_root, lay:
|
||||
unsigned int i = 0;
|
||||
m_technology_index = -1;
|
||||
|
||||
for (lay::Technologies::const_iterator t = technologies->begin (); t != technologies->end (); ++t, ++i) {
|
||||
for (db::Technologies::const_iterator t = technologies->begin (); t != technologies->end (); ++t, ++i) {
|
||||
|
||||
std::string d = t->name ();
|
||||
if (! d.empty () && ! t->description ().empty ()) {
|
||||
@@ -270,7 +270,7 @@ SaveLayoutOptionsDialog::edit_global_options (lay::PluginRoot *config_root, lay:
|
||||
|
||||
// get the selected technology name and store in the config
|
||||
unsigned int i = 0;
|
||||
for (lay::Technologies::iterator t = technologies->begin (); t != technologies->end () && i < m_opt_array.size (); ++t, ++i) {
|
||||
for (db::Technologies::iterator t = technologies->begin (); t != technologies->end () && i < m_opt_array.size (); ++t, ++i) {
|
||||
technologies->begin ()[i].set_save_layout_options (m_opt_array [i]);
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ class QWidget;
|
||||
namespace db
|
||||
{
|
||||
class SaveLayoutOptions;
|
||||
class Technologies;
|
||||
}
|
||||
|
||||
namespace lay
|
||||
@@ -46,7 +47,6 @@ namespace lay
|
||||
|
||||
class LayoutView;
|
||||
class PluginRoot;
|
||||
class Technologies;
|
||||
|
||||
class LAYBASIC_PUBLIC SaveLayoutAsOptionsDialog
|
||||
: public QDialog, private Ui::SaveLayoutAsOptionsDialog
|
||||
@@ -68,7 +68,7 @@ private:
|
||||
std::vector<int> m_tab_positions;
|
||||
std::string m_filename;
|
||||
db::SaveLayoutOptions m_options;
|
||||
const lay::Technology *mp_tech;
|
||||
const db::Technology *mp_tech;
|
||||
};
|
||||
|
||||
class LAYBASIC_PUBLIC SaveLayoutOptionsDialog
|
||||
@@ -80,7 +80,7 @@ public:
|
||||
SaveLayoutOptionsDialog (QWidget *parent, const std::string &title);
|
||||
~SaveLayoutOptionsDialog ();
|
||||
|
||||
bool edit_global_options (lay::PluginRoot *config_root, lay::Technologies *technologies);
|
||||
bool edit_global_options (lay::PluginRoot *config_root, db::Technologies *technologies);
|
||||
bool get_options (db::SaveLayoutOptions &options);
|
||||
|
||||
public slots:
|
||||
@@ -93,7 +93,7 @@ private:
|
||||
std::vector< std::pair<StreamWriterOptionsPage *, std::string> > m_pages;
|
||||
int m_technology_index;
|
||||
std::vector<db::SaveLayoutOptions> m_opt_array;
|
||||
std::vector<const lay::Technology *> m_tech_array;
|
||||
std::vector<const db::Technology *> m_tech_array;
|
||||
|
||||
void commit ();
|
||||
void update ();
|
||||
|
||||
@@ -82,42 +82,5 @@ const StreamWriterPluginDeclaration *StreamWriterPluginDeclaration::plugin_for_f
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Implementation of load_options_xml_element_list
|
||||
|
||||
tl::XMLElementList load_options_xml_element_list ()
|
||||
{
|
||||
tl::XMLElementList elements;
|
||||
|
||||
for (tl::Registrar<lay::PluginDeclaration>::iterator cls = tl::Registrar<lay::PluginDeclaration>::begin (); cls != tl::Registrar<lay::PluginDeclaration>::end (); ++cls) {
|
||||
const StreamReaderPluginDeclaration *decl = dynamic_cast <const StreamReaderPluginDeclaration *> (&*cls);
|
||||
if (decl) {
|
||||
elements.append (decl->xml_element ());
|
||||
}
|
||||
}
|
||||
|
||||
// ignore all unknown elements
|
||||
elements.append (tl::make_member<db::LoadLayoutOptions> ("*"));
|
||||
|
||||
return elements;
|
||||
}
|
||||
|
||||
tl::XMLElementList save_options_xml_element_list ()
|
||||
{
|
||||
tl::XMLElementList elements;
|
||||
|
||||
for (tl::Registrar<lay::PluginDeclaration>::iterator cls = tl::Registrar<lay::PluginDeclaration>::begin (); cls != tl::Registrar<lay::PluginDeclaration>::end (); ++cls) {
|
||||
const StreamWriterPluginDeclaration *decl = dynamic_cast <const StreamWriterPluginDeclaration *> (&*cls);
|
||||
if (decl) {
|
||||
elements.append (decl->xml_element ());
|
||||
}
|
||||
}
|
||||
|
||||
// ignore all unknown elements
|
||||
elements.append (tl::make_member<db::FormatSpecificWriterOptions> ("*"));
|
||||
|
||||
return elements;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ namespace db
|
||||
class FormatSpecificReaderOptions;
|
||||
class LoadLayoutOptions;
|
||||
class SaveLayoutOptions;
|
||||
class Technology;
|
||||
}
|
||||
|
||||
namespace lay
|
||||
@@ -45,7 +46,6 @@ namespace lay
|
||||
|
||||
class PluginRoot;
|
||||
class LayoutHandle;
|
||||
class Technology;
|
||||
|
||||
/**
|
||||
* @brief The base class for writer configuration pages
|
||||
@@ -70,7 +70,7 @@ public:
|
||||
* Plugin object provided and load the widgets accordingly.
|
||||
* The options object can be cast to the specific format object.
|
||||
*/
|
||||
virtual void setup (const db::FormatSpecificWriterOptions * /*options*/, const lay::Technology * /*tech*/)
|
||||
virtual void setup (const db::FormatSpecificWriterOptions * /*options*/, const db::Technology * /*tech*/)
|
||||
{
|
||||
// the default implementation does nothing.
|
||||
}
|
||||
@@ -83,7 +83,7 @@ public:
|
||||
* and commit the changes through
|
||||
* The options object can be cast to the specific format object.
|
||||
*/
|
||||
virtual void commit (db::FormatSpecificWriterOptions * /*options*/, const lay::Technology * /*tech*/, bool /*gzip*/)
|
||||
virtual void commit (db::FormatSpecificWriterOptions * /*options*/, const db::Technology * /*tech*/, bool /*gzip*/)
|
||||
{
|
||||
// the default implementation does nothing.
|
||||
}
|
||||
@@ -112,7 +112,7 @@ public:
|
||||
* Plugin object provided and load the widgets accordingly.
|
||||
* The options object can be cast to the specific format object.
|
||||
*/
|
||||
virtual void setup (const db::FormatSpecificReaderOptions * /*options*/, const lay::Technology * /*tech*/)
|
||||
virtual void setup (const db::FormatSpecificReaderOptions * /*options*/, const db::Technology * /*tech*/)
|
||||
{
|
||||
// the default implementation does nothing.
|
||||
}
|
||||
@@ -125,7 +125,7 @@ public:
|
||||
* and commit the changes through
|
||||
* The options object can be cast to the specific format object.
|
||||
*/
|
||||
virtual void commit (db::FormatSpecificReaderOptions * /*options*/, const lay::Technology * /*tech*/)
|
||||
virtual void commit (db::FormatSpecificReaderOptions * /*options*/, const db::Technology * /*tech*/)
|
||||
{
|
||||
// the default implementation does nothing.
|
||||
}
|
||||
@@ -209,32 +209,8 @@ public:
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Delivers the XMLElement object that represents this component within a technology XML tree
|
||||
*
|
||||
* This method is supposed to return an instance ReaderOptionsXMLElement<RO> where RO is the
|
||||
* specific reader options type. The return value can be 0 to indicate there is no specific reader
|
||||
* option.
|
||||
*
|
||||
* The returned XMLElement is destroyed by the caller and needs to be a new object.
|
||||
*/
|
||||
virtual tl::XMLElementBase *xml_element () const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Returns the XMLElement list that can represent a db::LoadLayoutOptions object
|
||||
*/
|
||||
LAYBASIC_PUBLIC tl::XMLElementList load_options_xml_element_list ();
|
||||
|
||||
/**
|
||||
* @brief Returns the XMLElement list that can represent a db::SaveLayoutOptions object
|
||||
*/
|
||||
LAYBASIC_PUBLIC tl::XMLElementList save_options_xml_element_list ();
|
||||
|
||||
/**
|
||||
* @brief A specialisation of Plugin declaration for stream reader plugins
|
||||
*/
|
||||
@@ -283,171 +259,6 @@ public:
|
||||
{
|
||||
// the default implementation does nothing.
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Delivers the XMLElement object that represents this component within a technology XML tree
|
||||
*
|
||||
* This method is supposed to return an instance WriterOptionsXMLElement<WO> where WO is the
|
||||
* specific writer options type. The return value can be 0 to indicate there is no specific writer
|
||||
* option.
|
||||
*
|
||||
* The returned XMLElement is destroyed by the caller and needs to be a new object.
|
||||
*/
|
||||
virtual tl::XMLElementBase *xml_element () const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief A helper class for the XML serialization of the stream options (custom read adaptor)
|
||||
*
|
||||
* OPT is a reader or writer options class and HOST is the host class. For example, OPT
|
||||
* can be db::GDS2ReaderOptions and HOST then is db::LoadLayoutOptions.
|
||||
*/
|
||||
template <class OPT, class HOST>
|
||||
class StreamOptionsReadAdaptor
|
||||
{
|
||||
public:
|
||||
typedef tl::pass_by_ref_tag tag;
|
||||
|
||||
StreamOptionsReadAdaptor ()
|
||||
: mp_options (0), m_done (false)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
const OPT &operator () () const
|
||||
{
|
||||
return mp_options->template get_options<OPT> ();
|
||||
}
|
||||
|
||||
bool at_end () const
|
||||
{
|
||||
return m_done;
|
||||
}
|
||||
|
||||
void start (const HOST &options)
|
||||
{
|
||||
mp_options = &options;
|
||||
m_done = false;
|
||||
}
|
||||
|
||||
void next ()
|
||||
{
|
||||
mp_options = 0;
|
||||
m_done = true;
|
||||
}
|
||||
|
||||
private:
|
||||
const HOST *mp_options;
|
||||
bool m_done;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief A helper class for the XML serialization of the stream option (custom write adaptor)
|
||||
*
|
||||
* See StreamOptionsReadAdaptor for details.
|
||||
*/
|
||||
template <class OPT, class HOST>
|
||||
class StreamOptionsWriteAdaptor
|
||||
{
|
||||
public:
|
||||
StreamOptionsWriteAdaptor ()
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
void operator () (HOST &options, tl::XMLReaderState &reader) const
|
||||
{
|
||||
std::auto_ptr<OPT> opt (new OPT ());
|
||||
|
||||
tl::XMLObjTag<OPT> tag;
|
||||
*opt = *reader.back (tag);
|
||||
|
||||
options.set_options (opt.release ());
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief A XMLElement specialization for stream options
|
||||
*/
|
||||
template <class OPT, class HOST>
|
||||
class StreamOptionsXMLElement
|
||||
: public tl::XMLElement<OPT, HOST, StreamOptionsReadAdaptor<OPT, HOST>, StreamOptionsWriteAdaptor<OPT, HOST> >
|
||||
{
|
||||
public:
|
||||
StreamOptionsXMLElement (const std::string &element_name, const tl::XMLElementList &children)
|
||||
: tl::XMLElement<OPT, HOST, StreamOptionsReadAdaptor<OPT, HOST>, StreamOptionsWriteAdaptor<OPT, HOST> > (StreamOptionsReadAdaptor<OPT, HOST> (), StreamOptionsWriteAdaptor<OPT, HOST> (), element_name, children)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
StreamOptionsXMLElement (const StreamOptionsXMLElement &d)
|
||||
: tl::XMLElement<OPT, HOST, StreamOptionsReadAdaptor<OPT, HOST>, StreamOptionsWriteAdaptor<OPT, HOST> > (d)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief A custom XMLElement for the serialization of reader options
|
||||
*
|
||||
* StreamReaderPluginDeclaration::xml_element can return such an element to
|
||||
* insert a custom XML element into the XML tree which represents the
|
||||
* reader options.
|
||||
*/
|
||||
template <class OPT>
|
||||
class ReaderOptionsXMLElement
|
||||
: public StreamOptionsXMLElement<OPT, db::LoadLayoutOptions>
|
||||
{
|
||||
public:
|
||||
ReaderOptionsXMLElement (const std::string &element_name, const tl::XMLElementList &children)
|
||||
: StreamOptionsXMLElement<OPT, db::LoadLayoutOptions> (element_name, children)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
ReaderOptionsXMLElement (const ReaderOptionsXMLElement &d)
|
||||
: StreamOptionsXMLElement<OPT, db::LoadLayoutOptions> (d)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
virtual tl::XMLElementBase *clone () const
|
||||
{
|
||||
return new ReaderOptionsXMLElement (*this);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief A custom XMLElement for the serialization of writer options
|
||||
*
|
||||
* StreamWriterPluginDeclaration::xml_element can return such an element to
|
||||
* insert a custom XML element into the XML tree which represents the
|
||||
* writer options.
|
||||
*/
|
||||
template <class OPT>
|
||||
class WriterOptionsXMLElement
|
||||
: public StreamOptionsXMLElement<OPT, db::SaveLayoutOptions>
|
||||
{
|
||||
public:
|
||||
WriterOptionsXMLElement (const std::string &element_name, const tl::XMLElementList &children)
|
||||
: StreamOptionsXMLElement<OPT, db::SaveLayoutOptions> (element_name, children)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
WriterOptionsXMLElement (const WriterOptionsXMLElement &d)
|
||||
: StreamOptionsXMLElement<OPT, db::SaveLayoutOptions> (d)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
virtual tl::XMLElementBase *clone () const
|
||||
{
|
||||
return new WriterOptionsXMLElement (*this);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -33,440 +33,7 @@
|
||||
namespace lay
|
||||
{
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
Technologies::Technologies ()
|
||||
{
|
||||
m_technologies.push_back (new Technology (std::string (""), "(Default)"));
|
||||
m_changed = false;
|
||||
m_in_update = false;
|
||||
}
|
||||
|
||||
Technologies::Technologies (const Technologies &other)
|
||||
: tl::Object ()
|
||||
{
|
||||
m_changed = false;
|
||||
m_in_update = false;
|
||||
operator= (other);
|
||||
}
|
||||
|
||||
Technologies::~Technologies ()
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
Technologies &
|
||||
Technologies::operator= (const Technologies &other)
|
||||
{
|
||||
if (&other != this) {
|
||||
m_technologies = other.m_technologies;
|
||||
for (iterator i = begin (); i != end (); ++i) {
|
||||
i->technology_changed_with_sender_event.add (this, &Technologies::technology_changed);
|
||||
}
|
||||
technologies_changed ();
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
static std::auto_ptr<lay::Technologies> sp_technologies;
|
||||
|
||||
lay::Technologies *
|
||||
Technologies::instance ()
|
||||
{
|
||||
if (! sp_technologies.get ()) {
|
||||
sp_technologies.reset (new lay::Technologies ());
|
||||
}
|
||||
return sp_technologies.get ();
|
||||
}
|
||||
|
||||
static tl::XMLElementList xml_elements ()
|
||||
{
|
||||
return make_element ((Technologies::const_iterator (Technologies::*) () const) &Technologies::begin, (Technologies::const_iterator (Technologies::*) () const) &Technologies::end, &Technologies::add, "technology",
|
||||
Technology::xml_elements ()
|
||||
);
|
||||
}
|
||||
|
||||
std::string
|
||||
Technologies::to_xml () const
|
||||
{
|
||||
// create a copy to filter out the ones which are not persisted
|
||||
lay::Technologies copy;
|
||||
for (const_iterator t = begin (); t != end (); ++t) {
|
||||
if (t->is_persisted ()) {
|
||||
copy.add (new Technology (*t));
|
||||
}
|
||||
}
|
||||
|
||||
tl::OutputStringStream os;
|
||||
tl::XMLStruct<lay::Technologies> xml_struct ("technologies", xml_elements ());
|
||||
tl::OutputStream oss (os);
|
||||
xml_struct.write (oss, copy);
|
||||
return os.string ();
|
||||
}
|
||||
|
||||
void
|
||||
Technologies::load_from_xml (const std::string &s)
|
||||
{
|
||||
// create a copy to filter out the ones which are not persisted and remain
|
||||
lay::Technologies copy;
|
||||
for (const_iterator t = begin (); t != end (); ++t) {
|
||||
if (! t->is_persisted ()) {
|
||||
copy.add (new Technology (*t));
|
||||
}
|
||||
}
|
||||
|
||||
tl::XMLStringSource source (s);
|
||||
tl::XMLStruct<lay::Technologies> xml_struct ("technologies", xml_elements ());
|
||||
xml_struct.parse (source, copy);
|
||||
|
||||
*this = copy;
|
||||
}
|
||||
|
||||
void
|
||||
Technologies::add_tech (Technology *tech, bool replace_same)
|
||||
{
|
||||
if (! tech) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::auto_ptr<Technology> tech_ptr (tech);
|
||||
|
||||
Technology *t = 0;
|
||||
for (tl::stable_vector<Technology>::iterator i = m_technologies.begin (); !t && i != m_technologies.end (); ++i) {
|
||||
if (i->name () == tech->name ()) {
|
||||
t = i.operator-> ();
|
||||
}
|
||||
}
|
||||
|
||||
if (t) {
|
||||
if (replace_same) {
|
||||
*t = *tech;
|
||||
} else {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("A technology with this name already exists: %1").arg (tl::to_qstring (tech->name ()))));
|
||||
}
|
||||
} else {
|
||||
m_technologies.push_back (tech_ptr.release ());
|
||||
tech->technology_changed_with_sender_event.add (this, &Technologies::technology_changed);
|
||||
}
|
||||
|
||||
technologies_changed ();
|
||||
}
|
||||
|
||||
void
|
||||
Technologies::remove (const std::string &name)
|
||||
{
|
||||
for (tl::stable_vector<Technology>::iterator t = m_technologies.begin (); t != m_technologies.end (); ++t) {
|
||||
if (t->name () == name) {
|
||||
m_technologies.erase (t);
|
||||
technologies_changed ();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Technologies::clear ()
|
||||
{
|
||||
if (! m_technologies.empty ()) {
|
||||
m_technologies.clear ();
|
||||
technologies_changed ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Technologies::technology_changed (Technology *t)
|
||||
{
|
||||
if (m_in_update) {
|
||||
m_changed = true;
|
||||
} else {
|
||||
technology_changed_event (t);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Technologies::technologies_changed ()
|
||||
{
|
||||
if (m_in_update) {
|
||||
m_changed = true;
|
||||
} else {
|
||||
technologies_changed_event ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Technologies::begin_updates ()
|
||||
{
|
||||
tl_assert (! m_in_update);
|
||||
m_in_update = true;
|
||||
m_changed = false;
|
||||
}
|
||||
|
||||
void
|
||||
Technologies::end_updates ()
|
||||
{
|
||||
if (m_in_update) {
|
||||
m_in_update = false;
|
||||
if (m_changed) {
|
||||
m_changed = false;
|
||||
technologies_changed ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Technologies::notify_technologies_changed ()
|
||||
{
|
||||
technologies_changed ();
|
||||
}
|
||||
|
||||
void
|
||||
Technologies::end_updates_no_event ()
|
||||
{
|
||||
m_in_update = false;
|
||||
m_changed = false;
|
||||
}
|
||||
|
||||
bool
|
||||
Technologies::has_technology (const std::string &name) const
|
||||
{
|
||||
for (tl::stable_vector<Technology>::const_iterator t = m_technologies.begin (); t != m_technologies.end (); ++t) {
|
||||
if (t->name () == name) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Technology *
|
||||
Technologies::technology_by_name (const std::string &name)
|
||||
{
|
||||
for (tl::stable_vector<Technology>::iterator t = m_technologies.begin (); t != m_technologies.end (); ++t) {
|
||||
if (t->name () == name) {
|
||||
return &*t;
|
||||
}
|
||||
}
|
||||
|
||||
tl_assert (! m_technologies.empty ());
|
||||
return &*m_technologies.begin ();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Technology implementation
|
||||
|
||||
Technology::Technology ()
|
||||
: m_name (), m_description (), m_dbu (0.001), m_persisted (true), m_readonly (false)
|
||||
{
|
||||
init ();
|
||||
}
|
||||
|
||||
Technology::Technology (const std::string &name, const std::string &description)
|
||||
: m_name (name), m_description (description), m_dbu (0.001), m_persisted (true), m_readonly (false)
|
||||
{
|
||||
init ();
|
||||
}
|
||||
|
||||
void
|
||||
Technology::init ()
|
||||
{
|
||||
m_add_other_layers = true;
|
||||
|
||||
for (tl::Registrar<lay::PluginDeclaration>::iterator cls = tl::Registrar<lay::PluginDeclaration>::begin (); cls != tl::Registrar<lay::PluginDeclaration>::end (); ++cls) {
|
||||
if (cls->technology_component_provider () != 0) {
|
||||
m_components.push_back (cls->technology_component_provider ()->create_component ());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Technology::~Technology ()
|
||||
{
|
||||
for (std::vector <TechnologyComponent *>::const_iterator c = m_components.begin (); c != m_components.end (); ++c) {
|
||||
delete *c;
|
||||
}
|
||||
m_components.clear ();
|
||||
}
|
||||
|
||||
Technology::Technology (const Technology &d)
|
||||
: tl::Object (),
|
||||
m_name (d.m_name), m_description (d.m_description), m_grain_name (d.m_grain_name), m_dbu (d.m_dbu),
|
||||
m_explicit_base_path (d.m_explicit_base_path), m_default_base_path (d.m_default_base_path),
|
||||
m_load_layout_options (d.m_load_layout_options),
|
||||
m_save_layout_options (d.m_save_layout_options),
|
||||
m_lyp_path (d.m_lyp_path), m_add_other_layers (d.m_add_other_layers), m_persisted (d.m_persisted),
|
||||
m_readonly (d.m_readonly), m_lyt_file (d.m_lyt_file)
|
||||
{
|
||||
for (std::vector <TechnologyComponent *>::const_iterator c = d.m_components.begin (); c != d.m_components.end (); ++c) {
|
||||
m_components.push_back ((*c)->clone ());
|
||||
}
|
||||
}
|
||||
|
||||
Technology &Technology::operator= (const Technology &d)
|
||||
{
|
||||
if (this != &d) {
|
||||
|
||||
m_name = d.m_name;
|
||||
m_description = d.m_description;
|
||||
m_grain_name = d.m_grain_name;
|
||||
m_dbu = d.m_dbu;
|
||||
m_default_base_path = d.m_default_base_path;
|
||||
m_explicit_base_path = d.m_explicit_base_path;
|
||||
m_load_layout_options = d.m_load_layout_options;
|
||||
m_save_layout_options = d.m_save_layout_options;
|
||||
m_lyp_path = d.m_lyp_path;
|
||||
m_add_other_layers = d.m_add_other_layers;
|
||||
m_persisted = d.m_persisted;
|
||||
m_readonly = d.m_readonly;
|
||||
m_lyt_file = d.m_lyt_file;
|
||||
|
||||
for (std::vector <TechnologyComponent *>::const_iterator c = m_components.begin (); c != m_components.end (); ++c) {
|
||||
delete *c;
|
||||
}
|
||||
m_components.clear ();
|
||||
|
||||
for (std::vector <TechnologyComponent *>::const_iterator c = d.m_components.begin (); c != d.m_components.end (); ++c) {
|
||||
m_components.push_back ((*c)->clone ());
|
||||
}
|
||||
|
||||
technology_changed ();
|
||||
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
tl::XMLElementList
|
||||
Technology::xml_elements ()
|
||||
{
|
||||
tl::XMLElementList elements =
|
||||
tl::make_member (&Technology::name, &Technology::set_name, "name") +
|
||||
tl::make_member (&Technology::description, &Technology::set_description, "description") +
|
||||
tl::make_member (&Technology::dbu, &Technology::set_dbu, "dbu") +
|
||||
tl::make_member (&Technology::explicit_base_path, &Technology::set_explicit_base_path, "base-path") +
|
||||
tl::make_member (&Technology::default_base_path, &Technology::set_default_base_path, "original-base-path") +
|
||||
tl::make_member (&Technology::layer_properties_file, &Technology::set_layer_properties_file, "layer-properties_file") +
|
||||
tl::make_member (&Technology::add_other_layers, &Technology::set_add_other_layers, "add-other-layers") +
|
||||
tl::make_element (&Technology::load_layout_options, &Technology::set_load_layout_options, "reader-options",
|
||||
lay::load_options_xml_element_list ()
|
||||
) +
|
||||
tl::make_element (&Technology::save_layout_options, &Technology::set_save_layout_options, "writer-options",
|
||||
lay::save_options_xml_element_list ()
|
||||
);
|
||||
|
||||
for (tl::Registrar<lay::PluginDeclaration>::iterator cls = tl::Registrar<lay::PluginDeclaration>::begin (); cls != tl::Registrar<lay::PluginDeclaration>::end (); ++cls) {
|
||||
if (cls->technology_component_provider () != 0) {
|
||||
elements.append (cls->technology_component_provider ()->xml_element ());
|
||||
}
|
||||
}
|
||||
|
||||
// ignore all unknown elements
|
||||
elements.append (tl::make_member<Technology> ("*"));
|
||||
|
||||
return elements;
|
||||
}
|
||||
|
||||
const TechnologyComponent *
|
||||
Technology::component_by_name (const std::string &component_name) const
|
||||
{
|
||||
for (std::vector <TechnologyComponent *>::const_iterator c = m_components.begin (); c != m_components.end (); ++c) {
|
||||
if ((*c)->name () == component_name) {
|
||||
return *c;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
TechnologyComponent *
|
||||
Technology::component_by_name (const std::string &component_name)
|
||||
{
|
||||
for (std::vector <TechnologyComponent *>::const_iterator c = m_components.begin (); c != m_components.end (); ++c) {
|
||||
if ((*c)->name () == component_name) {
|
||||
return *c;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::vector <std::string>
|
||||
Technology::component_names () const
|
||||
{
|
||||
std::vector <std::string> names;
|
||||
for (std::vector <TechnologyComponent *>::const_iterator c = m_components.begin (); c != m_components.end (); ++c) {
|
||||
names.push_back ((*c)->name ());
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
void
|
||||
Technology::set_component (TechnologyComponent *component)
|
||||
{
|
||||
for (std::vector <TechnologyComponent *>::iterator c = m_components.begin (); c != m_components.end (); ++c) {
|
||||
if ((*c)->name () == component->name ()) {
|
||||
if (*c != component) {
|
||||
delete *c;
|
||||
*c = component;
|
||||
technology_changed_event ();
|
||||
technology_changed_with_sender_event (this);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::string
|
||||
Technology::correct_path (const std::string &fp) const
|
||||
{
|
||||
if (base_path ().empty ()) {
|
||||
return fp;
|
||||
}
|
||||
|
||||
QString rfp = QDir (tl::to_qstring (base_path ())).relativeFilePath (tl::to_qstring (fp));
|
||||
if (rfp.startsWith (QString::fromUtf8 (".."))) {
|
||||
// upwards or beside - don't correct:
|
||||
return fp;
|
||||
} else {
|
||||
return tl::to_string (rfp);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Technology::load (const std::string &fn)
|
||||
{
|
||||
tl::XMLFileSource source (fn);
|
||||
tl::XMLStruct<lay::Technology> xml_struct ("technology", xml_elements ());
|
||||
xml_struct.parse (source, *this);
|
||||
|
||||
// use the tech file's path as the default base path
|
||||
std::string lyt_file = tl::to_string (QFileInfo (tl::to_qstring (fn)).absoluteDir ().path ());
|
||||
set_default_base_path (lyt_file);
|
||||
|
||||
set_tech_file_path (fn);
|
||||
}
|
||||
|
||||
void
|
||||
Technology::save (const std::string &fn) const
|
||||
{
|
||||
tl::XMLStruct<lay::Technology> xml_struct ("technology", xml_elements ());
|
||||
tl::OutputStream os (fn, tl::OutputStream::OM_Plain);
|
||||
xml_struct.write (os, *this);
|
||||
}
|
||||
|
||||
std::string
|
||||
Technology::build_effective_path (const std::string &p) const
|
||||
{
|
||||
if (p.empty () || base_path ().empty ()) {
|
||||
return p;
|
||||
}
|
||||
|
||||
QFileInfo f (tl::to_qstring (p));
|
||||
if (f.isAbsolute ()) {
|
||||
return p;
|
||||
} else {
|
||||
return tl::to_string (QDir (tl::to_qstring (base_path ())).filePath (tl::to_qstring (p)));
|
||||
}
|
||||
}
|
||||
// .. nothing yet ..
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -26,689 +26,13 @@
|
||||
|
||||
#include "laybasicCommon.h"
|
||||
|
||||
#include "tlStableVector.h"
|
||||
#include "tlString.h"
|
||||
#include "tlEvents.h"
|
||||
#include "tlXMLParser.h"
|
||||
#include "tlTypeTraits.h"
|
||||
#include "dbStreamLayers.h"
|
||||
#include "dbLoadLayoutOptions.h"
|
||||
#include "dbSaveLayoutOptions.h"
|
||||
#include "dbTechnology.h"
|
||||
|
||||
#include <QFrame>
|
||||
|
||||
namespace lay
|
||||
{
|
||||
|
||||
class Technology;
|
||||
class TechnologyComponent;
|
||||
class TechnologyComponentEditor;
|
||||
|
||||
/**
|
||||
* @brief A container for the technology settings
|
||||
*
|
||||
* The container associates a technology with a name and provides an
|
||||
* iterator for the technologies.
|
||||
* The container features at least one technology (the default) which is
|
||||
* present in any case. If a technology with an unknown name is requested,
|
||||
* this default technology is returned.
|
||||
*/
|
||||
class LAYBASIC_PUBLIC Technologies
|
||||
: public tl::Object
|
||||
{
|
||||
public:
|
||||
typedef tl::stable_vector<Technology>::const_iterator const_iterator;
|
||||
typedef tl::stable_vector<Technology>::iterator iterator;
|
||||
|
||||
/**
|
||||
* @brief The constructor
|
||||
*/
|
||||
Technologies ();
|
||||
|
||||
/**
|
||||
* @brief The destructor
|
||||
*/
|
||||
~Technologies ();
|
||||
|
||||
/**
|
||||
* @brief Copy ctor
|
||||
*/
|
||||
Technologies (const Technologies &other);
|
||||
|
||||
/**
|
||||
* @brief Assignment operator
|
||||
*/
|
||||
Technologies &operator= (const Technologies &other);
|
||||
|
||||
/**
|
||||
* @brief Const iterator - begin
|
||||
*/
|
||||
const_iterator begin () const
|
||||
{
|
||||
return m_technologies.begin ();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Const iterator - end
|
||||
*/
|
||||
const_iterator end () const
|
||||
{
|
||||
return m_technologies.end ();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief iterator - begin
|
||||
*/
|
||||
iterator begin ()
|
||||
{
|
||||
return m_technologies.begin ();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Const iterator - end
|
||||
*/
|
||||
iterator end ()
|
||||
{
|
||||
return m_technologies.end ();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief The number of technologies
|
||||
*/
|
||||
size_t technologies () const
|
||||
{
|
||||
return m_technologies.size ();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Adds a technology to the setup
|
||||
*
|
||||
* The container becomes owner of the technology object.
|
||||
* Replaces a technology with the name of the given technology.
|
||||
*/
|
||||
void add (Technology *technology)
|
||||
{
|
||||
add_tech (technology, true /*replace*/);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Adds a technology with a new name
|
||||
*
|
||||
* Like \add, but throws an exception if a technology with this name
|
||||
* already exists. Takes over ownership over the technology object.
|
||||
* The technology object is discarded if an exception is thrown.
|
||||
*/
|
||||
void add_new (Technology *technology)
|
||||
{
|
||||
add_tech (technology, false /*throws exception on same name*/);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Remove a technology with the given name from the setup
|
||||
*/
|
||||
void remove (const std::string &name);
|
||||
|
||||
/**
|
||||
* @brief Clears the list of technologies
|
||||
*/
|
||||
void clear ();
|
||||
|
||||
/**
|
||||
* @brief Begins a bulk operation
|
||||
* This method will disable "technologies_changed" events until (later) end_updates () is called.
|
||||
*/
|
||||
void begin_updates ();
|
||||
|
||||
/**
|
||||
* @brief Ends a bulk operation
|
||||
*/
|
||||
void end_updates ();
|
||||
|
||||
/**
|
||||
* @brief Ends a bulk operation
|
||||
* This version does not send an technologies_changed event but just cancels the bulk
|
||||
* operation. begin_updates/end_updates_no_event is essentially equivalent to blocking
|
||||
* signals.
|
||||
*/
|
||||
void end_updates_no_event ();
|
||||
|
||||
/**
|
||||
* @brief Notifies the system of changes in technologies
|
||||
* For performance reasons, changes inside a technology are not propagated to
|
||||
* the system directly. Only bulk changes (such as adding or removing technologies
|
||||
* are). To inform the system of individual technology updates, call this method
|
||||
* after a technology or multiple technologies have been changed.
|
||||
*/
|
||||
void notify_technologies_changed ();
|
||||
|
||||
/**
|
||||
* @brief Checks, if a technology with the given name exists
|
||||
*/
|
||||
bool has_technology (const std::string &name) const;
|
||||
|
||||
/**
|
||||
* @brief Returns the technology with the given name
|
||||
*
|
||||
* If no technology with that name exists, the default technology is returned.
|
||||
*/
|
||||
Technology *technology_by_name (const std::string &name);
|
||||
|
||||
/**
|
||||
* @brief Returns the technology with the given name (const version)
|
||||
*
|
||||
* If no technology with that name exists, the default technology is returned.
|
||||
*/
|
||||
const Technology *technology_by_name (const std::string &name) const
|
||||
{
|
||||
return const_cast<Technologies *> (this)->technology_by_name (name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Converts the list into an XML string
|
||||
*/
|
||||
std::string to_xml () const;
|
||||
|
||||
/**
|
||||
* @brief Reads the list from an XML string
|
||||
*/
|
||||
void load_from_xml (const std::string &s);
|
||||
|
||||
/**
|
||||
* @brief Returns the singleton instance
|
||||
*/
|
||||
static lay::Technologies *instance ();
|
||||
|
||||
/**
|
||||
* @brief An event indicating that the list of technologies has changed
|
||||
* If a technology is added or removed, this event is triggered.
|
||||
*/
|
||||
tl::Event technologies_changed_event;
|
||||
|
||||
/**
|
||||
* @brief An event indicating that one technology in the list has changed
|
||||
* If a technology is modified, this event is triggered with that technology as argument of the event.
|
||||
*/
|
||||
tl::event<Technology *> technology_changed_event;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @brief Forward the event from the individual technologies
|
||||
*/
|
||||
void technology_changed (Technology *t);
|
||||
|
||||
/**
|
||||
* @brief Sends the technologies_changed event
|
||||
*/
|
||||
void technologies_changed ();
|
||||
|
||||
private:
|
||||
tl::stable_vector<Technology> m_technologies;
|
||||
bool m_changed;
|
||||
bool m_in_update;
|
||||
|
||||
void add_tech (Technology *technology, bool replace_same);
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief A technology
|
||||
*
|
||||
* This class represents one technology.
|
||||
* A technology has a name and a description.
|
||||
*/
|
||||
class LAYBASIC_PUBLIC Technology
|
||||
: public tl::Object
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief The default constructor
|
||||
*/
|
||||
Technology ();
|
||||
|
||||
/**
|
||||
* @brief The constructor
|
||||
*/
|
||||
Technology (const std::string &name, const std::string &description);
|
||||
|
||||
/**
|
||||
* @brief The copy constructor
|
||||
*/
|
||||
Technology (const Technology &tech);
|
||||
|
||||
/**
|
||||
* @brief The destructor
|
||||
*/
|
||||
~Technology ();
|
||||
|
||||
/**
|
||||
* @brief Assignment
|
||||
*/
|
||||
Technology &operator= (const Technology &tech);
|
||||
|
||||
/**
|
||||
* @brief Gets the name
|
||||
*/
|
||||
const std::string &name () const
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Sets the name
|
||||
*/
|
||||
void set_name (const std::string &n)
|
||||
{
|
||||
if (n != m_name) {
|
||||
m_name = n;
|
||||
technology_changed ();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Sets the package source
|
||||
*
|
||||
* This attribute indicates that this technology was contributed by a package
|
||||
*/
|
||||
void set_grain_name (const std::string &g)
|
||||
{
|
||||
m_grain_name = g;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets the package source
|
||||
*/
|
||||
const std::string &grain_name () const
|
||||
{
|
||||
return m_grain_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets the base path
|
||||
*
|
||||
* The base path is an effective path - if the explicit path is set, it is
|
||||
* used. If not, the default path is used. The default path is the one from which
|
||||
* a technology file was imported. The explicit one is the one that is specified
|
||||
* explicitly.
|
||||
*/
|
||||
const std::string &base_path () const
|
||||
{
|
||||
return m_explicit_base_path.empty () ? m_default_base_path : m_explicit_base_path;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Makes a file path relative to the base path if one is specified.
|
||||
*
|
||||
* Only files below the base path will be made relative. Files above or beside
|
||||
* won't be made relative.
|
||||
*/
|
||||
std::string correct_path (const std::string &fp) const;
|
||||
|
||||
/**
|
||||
* @brief Gets the default base path
|
||||
*/
|
||||
const std::string &default_base_path () const
|
||||
{
|
||||
return m_default_base_path;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Sets the default base path
|
||||
*/
|
||||
void set_default_base_path (const std::string &p)
|
||||
{
|
||||
if (m_default_base_path != p) {
|
||||
m_default_base_path = p;
|
||||
technology_changed ();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets the explicit base path
|
||||
*/
|
||||
const std::string &explicit_base_path () const
|
||||
{
|
||||
return m_explicit_base_path;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Sets the explicit base path
|
||||
*/
|
||||
void set_explicit_base_path (const std::string &p)
|
||||
{
|
||||
if (m_explicit_base_path != p) {
|
||||
m_explicit_base_path = p;
|
||||
technology_changed ();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets the path of the tech file if the technology was loaded from a tech file
|
||||
*/
|
||||
const std::string &tech_file_path () const
|
||||
{
|
||||
return m_lyt_file;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Sets the path of the tech file
|
||||
* This method is intended for internal use only.
|
||||
*/
|
||||
void set_tech_file_path (const std::string &lyt_file)
|
||||
{
|
||||
m_lyt_file = lyt_file;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets the description
|
||||
*/
|
||||
const std::string &description () const
|
||||
{
|
||||
return m_description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Sets the description
|
||||
*/
|
||||
void set_description (const std::string &d)
|
||||
{
|
||||
if (m_description != d) {
|
||||
m_description = d;
|
||||
technology_changed ();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets the default database unit
|
||||
*/
|
||||
double dbu () const
|
||||
{
|
||||
return m_dbu;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Sets the default database unit
|
||||
*/
|
||||
void set_dbu (double d)
|
||||
{
|
||||
if (fabs (m_dbu - d) > 1e-10) {
|
||||
m_dbu = d;
|
||||
technology_changed ();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets the layer properties file path (empty if none is specified)
|
||||
*/
|
||||
const std::string &layer_properties_file () const
|
||||
{
|
||||
return m_lyp_path;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets the effective layer properties file path (empty if none is specified)
|
||||
*
|
||||
* The effective path is the one extended by the base path if relative.
|
||||
*/
|
||||
std::string eff_layer_properties_file () const
|
||||
{
|
||||
return build_effective_path (m_lyp_path);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Sets the layer properties file path (set to empty string to remove layer properties file)
|
||||
*/
|
||||
void set_layer_properties_file (const std::string &lyp)
|
||||
{
|
||||
if (m_lyp_path != lyp) {
|
||||
m_lyp_path = lyp;
|
||||
technology_changed ();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets the flag indicating whether to add other layers to the layer properties
|
||||
*/
|
||||
bool add_other_layers () const
|
||||
{
|
||||
return m_add_other_layers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Sets the flag indicating whether to add other layers to the layer properties
|
||||
*
|
||||
* If "add_other_layers" is true, the layers in the layout but not specified in the
|
||||
* layer properties file will be added automatically.
|
||||
*/
|
||||
void set_add_other_layers (bool add_other_layers)
|
||||
{
|
||||
if (m_add_other_layers != add_other_layers) {
|
||||
m_add_other_layers = add_other_layers;
|
||||
technology_changed ();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief gets the layout reader options
|
||||
*/
|
||||
const db::LoadLayoutOptions &load_layout_options () const
|
||||
{
|
||||
return m_load_layout_options;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Sets the layout reader options
|
||||
*/
|
||||
void set_load_layout_options (const db::LoadLayoutOptions &options)
|
||||
{
|
||||
m_load_layout_options = options;
|
||||
technology_changed ();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief gets the layout writer options
|
||||
*/
|
||||
const db::SaveLayoutOptions &save_layout_options () const
|
||||
{
|
||||
return m_save_layout_options;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Sets the layout writer options
|
||||
*/
|
||||
void set_save_layout_options (const db::SaveLayoutOptions &options)
|
||||
{
|
||||
m_save_layout_options = options;
|
||||
technology_changed ();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Load from file (import)
|
||||
*/
|
||||
void load (const std::string &fn);
|
||||
|
||||
/**
|
||||
* @brief Save to file (export)
|
||||
*/
|
||||
void save (const std::string &fn) const;
|
||||
|
||||
/**
|
||||
* @brief Delivers the XMLElementList that specifies the technology's XML representation
|
||||
*/
|
||||
static tl::XMLElementList xml_elements ();
|
||||
|
||||
/**
|
||||
* @brief Sets the technology component by the component name
|
||||
*
|
||||
* This replaces the technology component with the given name.
|
||||
* The Technology object will become owner of the component.
|
||||
*/
|
||||
void set_component (TechnologyComponent *component);
|
||||
|
||||
/**
|
||||
* @brief Gets the technology component by the component name
|
||||
*
|
||||
* If no component with that name exists, 0 is returned.
|
||||
*/
|
||||
const TechnologyComponent *component_by_name (const std::string &component_name) const;
|
||||
|
||||
/**
|
||||
* @brief Gets the technology component by the component name (non-const version)
|
||||
*
|
||||
* If no component with that name exists, 0 is returned.
|
||||
*/
|
||||
TechnologyComponent *component_by_name (const std::string &component_name);
|
||||
|
||||
/**
|
||||
* @brief Gets the component names
|
||||
*/
|
||||
std::vector <std::string> component_names () const;
|
||||
|
||||
/**
|
||||
* @brief Builds the effective path from a relative or absolute one using the base path if necessary
|
||||
*/
|
||||
std::string build_effective_path (const std::string &p) const;
|
||||
|
||||
/**
|
||||
* @brief Returns a flag indicating whether the technology is persisted or not
|
||||
*
|
||||
* If the flag is false, this technology is not included into the XML string
|
||||
* of the technologies.
|
||||
*/
|
||||
bool is_persisted () const
|
||||
{
|
||||
return m_persisted;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Sets a flag indicating whether the technology is persisted
|
||||
*/
|
||||
void set_persisted (bool f)
|
||||
{
|
||||
m_persisted = f;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns a flag indicating whether the technology is readonly
|
||||
*
|
||||
* If the flag is false, the technology can be edited. Otherwise it's locked for editing.
|
||||
*/
|
||||
bool is_readonly () const
|
||||
{
|
||||
return m_readonly;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Sets a flag indicating whether the technology is readonly
|
||||
*/
|
||||
void set_readonly (bool f)
|
||||
{
|
||||
m_readonly = f;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief An event indicating that the technology has changed
|
||||
*/
|
||||
tl::Event technology_changed_event;
|
||||
|
||||
/**
|
||||
* @brief An event indicating that the technology has changed (with a sender argument)
|
||||
*/
|
||||
tl::event<Technology *> technology_changed_with_sender_event;
|
||||
|
||||
private:
|
||||
std::string m_name, m_description;
|
||||
std::string m_grain_name;
|
||||
double m_dbu;
|
||||
std::string m_explicit_base_path, m_default_base_path;
|
||||
db::LoadLayoutOptions m_load_layout_options;
|
||||
db::SaveLayoutOptions m_save_layout_options;
|
||||
std::string m_lyp_path;
|
||||
std::string m_lyt_path;
|
||||
bool m_add_other_layers;
|
||||
std::vector <TechnologyComponent *> m_components;
|
||||
bool m_persisted;
|
||||
bool m_readonly;
|
||||
std::string m_lyt_file;
|
||||
|
||||
void init ();
|
||||
|
||||
void technology_changed ()
|
||||
{
|
||||
technology_changed_with_sender_event (this);
|
||||
technology_changed_event ();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief A technology component
|
||||
*
|
||||
* A technology component is a part of the data for one technology.
|
||||
* Plugins may register technology components in every technology and
|
||||
* use those components to store their specific data.
|
||||
* A technology component has a name and a description. The name is used
|
||||
* to identify a component within a technology. The description is shown
|
||||
* in the setup dialogs.
|
||||
* This class is the base class for all technology components.
|
||||
*/
|
||||
class LAYBASIC_PUBLIC TechnologyComponent
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief The constructor
|
||||
*
|
||||
* @param name The name of the technology component
|
||||
* @param descriptor The description of the technology component
|
||||
*/
|
||||
TechnologyComponent (const std::string &name, const std::string &description)
|
||||
: m_name (name), m_description (description)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief The destructor
|
||||
*/
|
||||
virtual ~TechnologyComponent ()
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets the name
|
||||
*/
|
||||
const std::string &name () const
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets the description
|
||||
*/
|
||||
const std::string &description () const
|
||||
{
|
||||
return m_description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Creates the editor
|
||||
*
|
||||
* The implementation of this method is supposed to create an editor for
|
||||
* the given component. It is guaranteed that the component that is given
|
||||
* to the editor is one that has been delivered by create_component ().
|
||||
*/
|
||||
virtual TechnologyComponentEditor *create_editor (QWidget * /*parent*/)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Clone this instance
|
||||
*/
|
||||
virtual TechnologyComponent *clone () const = 0;
|
||||
|
||||
private:
|
||||
std::string m_name, m_description;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief A base class for an editor for a technology component
|
||||
*
|
||||
@@ -740,7 +64,7 @@ public:
|
||||
/**
|
||||
* @brief Set the technology and component for the editor
|
||||
*/
|
||||
void set_technology (Technology *tech, TechnologyComponent *tech_component)
|
||||
void set_technology (db::Technology *tech, db::TechnologyComponent *tech_component)
|
||||
{
|
||||
mp_tech = tech;
|
||||
mp_tech_component = tech_component;
|
||||
@@ -763,31 +87,31 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
Technology *tech ()
|
||||
db::Technology *tech ()
|
||||
{
|
||||
return mp_tech;
|
||||
}
|
||||
|
||||
TechnologyComponent *tech_component ()
|
||||
db::TechnologyComponent *tech_component ()
|
||||
{
|
||||
return mp_tech_component;
|
||||
}
|
||||
|
||||
private:
|
||||
Technology *mp_tech;
|
||||
TechnologyComponent *mp_tech_component;
|
||||
db::Technology *mp_tech;
|
||||
db::TechnologyComponent *mp_tech_component;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief A base class for a technology component provider
|
||||
*/
|
||||
class LAYBASIC_PUBLIC TechnologyComponentProvider
|
||||
class LAYBASIC_PUBLIC TechnologyEditorProvider
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief The constructor
|
||||
*/
|
||||
TechnologyComponentProvider ()
|
||||
TechnologyEditorProvider ()
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
@@ -795,7 +119,7 @@ public:
|
||||
/**
|
||||
* @brief The destructor
|
||||
*/
|
||||
virtual ~TechnologyComponentProvider ()
|
||||
virtual ~TechnologyEditorProvider ()
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
@@ -803,146 +127,13 @@ public:
|
||||
/**
|
||||
* @brief Creates the technology component
|
||||
*/
|
||||
virtual TechnologyComponent *create_component () const = 0;
|
||||
|
||||
/**
|
||||
* @brief Delivers the XMLElement object that represents this component within a technology XML tree
|
||||
*
|
||||
* The object returned is destroyed by the caller.
|
||||
*/
|
||||
virtual tl::XMLElementBase *xml_element () const = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief A helper class for the XML serialization of the technology component (custom read adaptor)
|
||||
*/
|
||||
|
||||
template <class TC>
|
||||
class TechnologyComponentReadAdaptor
|
||||
{
|
||||
public:
|
||||
typedef tl::pass_by_ref_tag tag;
|
||||
|
||||
TechnologyComponentReadAdaptor (const std::string &name)
|
||||
: m_name (name), mp_t (0), m_done (false)
|
||||
virtual TechnologyComponentEditor *create_editor (QWidget * /*parent*/) const
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
const TC &operator () () const
|
||||
{
|
||||
const TC *tc = dynamic_cast<const TC *> ((const_cast <lay::Technology *> (mp_t))->component_by_name (m_name));
|
||||
if (! tc) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Unknown technology component: ")) + m_name);
|
||||
}
|
||||
|
||||
return *tc;
|
||||
}
|
||||
|
||||
bool at_end () const
|
||||
{
|
||||
return m_done;
|
||||
}
|
||||
|
||||
void start (const lay::Technology &t)
|
||||
{
|
||||
mp_t = &t;
|
||||
m_done = false;
|
||||
}
|
||||
|
||||
void next ()
|
||||
{
|
||||
m_done = true;
|
||||
}
|
||||
|
||||
private:
|
||||
std::string m_name;
|
||||
const lay::Technology *mp_t;
|
||||
bool m_done;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief A helper class for the XML serialization of the technology component (custom write adaptor)
|
||||
*/
|
||||
|
||||
template <class TC>
|
||||
class TechnologyComponentWriteAdaptor
|
||||
{
|
||||
public:
|
||||
TechnologyComponentWriteAdaptor (const std::string &name)
|
||||
: m_name (name)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
void operator () (lay::Technology &t, tl::XMLReaderState &reader) const
|
||||
{
|
||||
const TechnologyComponent *tc_basic = t.component_by_name (m_name);
|
||||
TC *tc = 0;
|
||||
if (! tc_basic) {
|
||||
tc = new TC ();
|
||||
} else {
|
||||
tc = dynamic_cast<TC *> (tc_basic->clone ());
|
||||
if (! tc) {
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("Invalid technology component: ")) + m_name);
|
||||
}
|
||||
}
|
||||
|
||||
tl::XMLObjTag<TC> tag;
|
||||
*tc = *reader.back (tag);
|
||||
|
||||
t.set_component (tc);
|
||||
}
|
||||
|
||||
private:
|
||||
std::string m_name;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief A custom XMLElement for the serialization of technology components
|
||||
*
|
||||
* TechnologyComponentProvider::xml_element can return such an element to
|
||||
* insert a custom XML element into the XML tree which represents the
|
||||
* technology component.
|
||||
*
|
||||
* The name of the element will be the name of the technology component.
|
||||
*/
|
||||
|
||||
template <class TC>
|
||||
class TechnologyComponentXMLElement
|
||||
: public tl::XMLElement<TC, lay::Technology, TechnologyComponentReadAdaptor<TC>, TechnologyComponentWriteAdaptor<TC> >
|
||||
{
|
||||
public:
|
||||
TechnologyComponentXMLElement (const std::string &name, const tl::XMLElementList &children)
|
||||
: tl::XMLElement<TC, lay::Technology, TechnologyComponentReadAdaptor<TC>, TechnologyComponentWriteAdaptor<TC> > (TechnologyComponentReadAdaptor<TC> (name), TechnologyComponentWriteAdaptor<TC> (name), name, children)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
TechnologyComponentXMLElement (const TechnologyComponentXMLElement &d)
|
||||
: tl::XMLElement<TC, lay::Technology, TechnologyComponentReadAdaptor<TC>, TechnologyComponentWriteAdaptor<TC> > (d)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
virtual tl::XMLElementBase *clone () const
|
||||
{
|
||||
return new TechnologyComponentXMLElement (*this);
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace tl
|
||||
{
|
||||
/**
|
||||
* @brief Type traits
|
||||
*/
|
||||
template <> struct type_traits <lay::TechnologyComponent> : public type_traits<void> {
|
||||
typedef tl::false_tag has_default_constructor;
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -63,7 +63,6 @@ FORMS = \
|
||||
UserPropertiesForm.ui \
|
||||
UserPropertiesEditForm.ui \
|
||||
SpecificLoadLayoutOptionsDialog.ui \
|
||||
CommonReaderOptionsPage.ui \
|
||||
SelectLineStyleForm.ui \
|
||||
LayoutViewConfigPage6a.ui \
|
||||
EditLineStylesForm.ui
|
||||
@@ -154,14 +153,12 @@ SOURCES = \
|
||||
rdbMarkerBrowser.cc \
|
||||
rdbMarkerBrowserDialog.cc \
|
||||
rdbMarkerBrowserPage.cc \
|
||||
layCommonReaderPlugin.cc \
|
||||
layLineStyles.cc \
|
||||
laySelectLineStyleForm.cc \
|
||||
layLineStylePalette.cc \
|
||||
layEditLineStylesForm.cc \
|
||||
layEditLineStyleWidget.cc \
|
||||
layBackgroundAwareTreeStyle.cc \
|
||||
gsiDeclLayTechnologies.cc
|
||||
|
||||
HEADERS = \
|
||||
gtf.h \
|
||||
|
||||
Reference in New Issue
Block a user