mirror of https://github.com/KLayout/klayout.git
Issue 1071 (GDS2Text format options issues) (#1085)
* Fixed first issue (UI problem with GDS2Text options) * Fixed problem with 'save' when the file extension does not indicate one of the known formats In this case, and when plain 'save' is used, the original format is delivered. The session files also store the original format now. The statistics page will now indicate the format of the file that was loaded.
This commit is contained in:
parent
0398beffae
commit
b84ec19da1
|
|
@ -51,6 +51,7 @@ tl::XMLElementList load_options_xml_element_list ()
|
|||
tl::XMLElementList save_options_xml_element_list ()
|
||||
{
|
||||
tl::XMLElementList elements;
|
||||
elements.append (tl::make_member (&db::SaveLayoutOptions::format, &db::SaveLayoutOptions::set_format, "format"));
|
||||
|
||||
for (tl::Registrar<db::StreamFormatDeclaration>::iterator cls = tl::Registrar<db::StreamFormatDeclaration>::begin (); cls != tl::Registrar<db::StreamFormatDeclaration>::end (); ++cls) {
|
||||
const StreamFormatDeclaration *decl = dynamic_cast <const StreamFormatDeclaration *> (&*cls);
|
||||
|
|
|
|||
|
|
@ -2298,12 +2298,14 @@ MainWindow::do_save (bool as)
|
|||
db::SaveLayoutOptions options = cv->save_options ();
|
||||
if (!cv->save_options_valid () && cv->technology ()) {
|
||||
options = cv->technology ()->save_layout_options ();
|
||||
options.set_format (cv->save_options ().format ());
|
||||
}
|
||||
|
||||
options.set_dbu (cv->layout ().dbu ());
|
||||
options.set_format_from_filename (fn);
|
||||
|
||||
cv->update_save_options (options);
|
||||
if (as || options.format ().empty ()) {
|
||||
options.set_format_from_filename (fn);
|
||||
}
|
||||
|
||||
tl::OutputStream::OutputStreamMode om = tl::OutputStream::OM_Auto;
|
||||
|
||||
|
|
@ -2340,7 +2342,9 @@ MainWindow::cm_save_all ()
|
|||
db::SaveLayoutOptions options (cv->save_options ());
|
||||
options.set_dbu (cv->layout ().dbu ());
|
||||
|
||||
options.set_format_from_filename (fn);
|
||||
if (options.format ().empty ()) {
|
||||
options.set_format_from_filename (fn);
|
||||
}
|
||||
|
||||
tl::OutputStream::OutputStreamMode om = tl::OutputStream::OM_Auto;
|
||||
|
||||
|
|
|
|||
|
|
@ -277,7 +277,7 @@ LayoutHandle::update_save_options (db::SaveLayoutOptions &options)
|
|||
for (tl::Registrar<lay::PluginDeclaration>::iterator cls = tl::Registrar<lay::PluginDeclaration>::begin (); cls != tl::Registrar<lay::PluginDeclaration>::end (); ++cls) {
|
||||
|
||||
const lay::StreamWriterPluginDeclaration *decl = dynamic_cast <const lay::StreamWriterPluginDeclaration *> (&*cls);
|
||||
if (! decl) {
|
||||
if (! decl || decl->options_alias ()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -350,6 +350,8 @@ db::LayerMap
|
|||
LayoutHandle::load (const db::LoadLayoutOptions &options, const std::string &technology)
|
||||
{
|
||||
m_load_options = options;
|
||||
m_save_options = db::SaveLayoutOptions ();
|
||||
m_save_options_valid = false;
|
||||
|
||||
set_tech_name (technology);
|
||||
|
||||
|
|
@ -369,6 +371,7 @@ LayoutHandle::load (const db::LoadLayoutOptions &options, const std::string &tec
|
|||
file_watcher ().remove_file (filename ());
|
||||
file_watcher ().add_file (filename ());
|
||||
|
||||
m_save_options.set_format (reader.format ());
|
||||
m_dirty = false;
|
||||
return new_lmap;
|
||||
}
|
||||
|
|
@ -377,6 +380,8 @@ db::LayerMap
|
|||
LayoutHandle::load ()
|
||||
{
|
||||
m_load_options = db::LoadLayoutOptions ();
|
||||
m_save_options = db::SaveLayoutOptions ();
|
||||
m_save_options_valid = false;
|
||||
|
||||
set_tech_name (std::string ());
|
||||
|
||||
|
|
@ -394,6 +399,7 @@ LayoutHandle::load ()
|
|||
file_watcher ().remove_file (filename ());
|
||||
file_watcher ().add_file (filename ());
|
||||
|
||||
m_save_options.set_format (reader.format ());
|
||||
m_dirty = false;
|
||||
return new_lmap;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -682,8 +682,13 @@ StatisticsSource::get (const std::string &url)
|
|||
<< "<table>" << std::endl
|
||||
<< "<tr>"
|
||||
<< "<td>" << tl::to_string (QObject::tr ("Path")) << ": </td><td>" << m_h->filename () << "</td>"
|
||||
<< "</tr>" << std::endl
|
||||
<< "<tr>"
|
||||
<< "</tr>" << std::endl;
|
||||
if (! m_h->save_options ().format ().empty ()) {
|
||||
os << "<tr>"
|
||||
<< "<td>" << tl::to_string (QObject::tr ("Format")) << ": </td><td>" << m_h->save_options ().format () << "</td>"
|
||||
<< "</tr>" << std::endl;
|
||||
}
|
||||
os << "<tr>"
|
||||
<< "<td>" << tl::to_string (QObject::tr ("Technology")) << ": </td><td>" << m_h->technology ()->description () << format_tech_name (m_h->tech_name ()) << "</td>"
|
||||
<< "</tr>" << std::endl
|
||||
<< "<tr>"
|
||||
|
|
|
|||
|
|
@ -338,16 +338,47 @@ SaveLayoutAsOptionsDialog::SaveLayoutAsOptionsDialog (QWidget *parent, const std
|
|||
|
||||
fmt_cbx->addItem (tl::to_qstring (fmt->format_title ()));
|
||||
|
||||
StreamWriterOptionsPage *page = 0;
|
||||
|
||||
// obtain the config page from the plugin which we identify by format name
|
||||
const StreamWriterPluginDeclaration *decl = plugin_for_format (fmt->format_name ());
|
||||
if (decl) {
|
||||
page = decl->format_specific_options_page (options_stack);
|
||||
}
|
||||
|
||||
m_pages.push_back (std::make_pair (page, fmt->format_name ()));
|
||||
m_tab_positions.push_back (page ? options_stack->addWidget (page) : empty_widget_index);
|
||||
if (decl) {
|
||||
|
||||
const char *alias = decl->options_alias ();
|
||||
if (alias) {
|
||||
|
||||
// alias needs to come before
|
||||
int index = -1;
|
||||
int n = 0;
|
||||
for (tl::Registrar<db::StreamFormatDeclaration>::iterator i = tl::Registrar<db::StreamFormatDeclaration>::begin (); i != tl::Registrar<db::StreamFormatDeclaration>::end (); ++i) {
|
||||
if (i->format_name () == alias) {
|
||||
index = n;
|
||||
}
|
||||
++n;
|
||||
}
|
||||
|
||||
if (index >= 0 && index < int (m_tab_positions.size ())) {
|
||||
m_pages.push_back (std::make_pair (m_pages [index].first, fmt->format_name ()));
|
||||
m_tab_positions.push_back (m_tab_positions[index]);
|
||||
} else {
|
||||
m_pages.push_back (std::make_pair ((StreamWriterOptionsPage *) 0, fmt->format_name ()));
|
||||
m_tab_positions.push_back (empty_widget_index);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
StreamWriterOptionsPage *page = decl->format_specific_options_page (options_stack);
|
||||
|
||||
m_pages.push_back (std::make_pair (page, fmt->format_name ()));
|
||||
m_tab_positions.push_back (page ? options_stack->addWidget (page) : empty_widget_index);
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
m_pages.push_back (std::make_pair ((StreamWriterOptionsPage *) 0, fmt->format_name ()));
|
||||
m_tab_positions.push_back (empty_widget_index);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -440,7 +471,7 @@ SaveLayoutAsOptionsDialog::get_options (lay::LayoutView *view, unsigned int cv_i
|
|||
for (std::vector< std::pair<StreamWriterOptionsPage *, std::string> >::iterator page = m_pages.begin (); page != m_pages.end (); ++page) {
|
||||
|
||||
const StreamWriterPluginDeclaration *decl = plugin_for_format (page->second);
|
||||
if (decl) {
|
||||
if (decl && ! decl->options_alias ()) {
|
||||
|
||||
std::unique_ptr<db::FormatSpecificWriterOptions> specific_options;
|
||||
if (options.get_options (page->second)) {
|
||||
|
|
|
|||
|
|
@ -229,6 +229,14 @@ public:
|
|||
*/
|
||||
static const StreamWriterPluginDeclaration *plugin_for_format (const std::string &format_name);
|
||||
|
||||
/**
|
||||
* @brief If the options are shared with another declaration, returns this name of this declaration here
|
||||
*/
|
||||
virtual const char *options_alias () const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Create a format specific options page
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -118,12 +118,14 @@ GDS2WriterOptionPage::multi_xy_clicked ()
|
|||
// ---------------------------------------------------------------
|
||||
// GDS2WriterPluginDeclaration definition and implementation
|
||||
|
||||
class GDS2WriterPluginDeclaration
|
||||
namespace {
|
||||
|
||||
class GDS2WriterPluginDeclarationBase
|
||||
: public StreamWriterPluginDeclaration
|
||||
{
|
||||
public:
|
||||
GDS2WriterPluginDeclaration ()
|
||||
: StreamWriterPluginDeclaration (db::GDS2WriterOptions ().format_name ())
|
||||
GDS2WriterPluginDeclarationBase (const std::string &name)
|
||||
: StreamWriterPluginDeclaration (name)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
|
@ -152,21 +154,47 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief A dummy plugin for GDS2Text
|
||||
* @brief A plugin for GDS2
|
||||
*/
|
||||
class GDS2WriterPluginDeclaration
|
||||
: public GDS2WriterPluginDeclarationBase
|
||||
{
|
||||
public:
|
||||
GDS2WriterPluginDeclaration ()
|
||||
: GDS2WriterPluginDeclarationBase (db::GDS2WriterOptions ().format_name ())
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief A plugin for GDS2Text
|
||||
*
|
||||
* GDS2Text shares the options with GDS2, although some limitations do not exist.
|
||||
* There is not specific option set for GDS2Text. The writer will take the options from GDS2.
|
||||
*/
|
||||
class GDS2TextWriterPluginDeclaration
|
||||
: public StreamWriterPluginDeclaration
|
||||
: public GDS2WriterPluginDeclarationBase
|
||||
{
|
||||
public:
|
||||
GDS2TextWriterPluginDeclaration ()
|
||||
: StreamWriterPluginDeclaration ("GDS2Text")
|
||||
: GDS2WriterPluginDeclarationBase ("GDS2Text")
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
virtual const char *options_alias () const
|
||||
{
|
||||
return db::GDS2WriterOptions ().format_name ().c_str ();
|
||||
}
|
||||
|
||||
StreamWriterOptionsPage *format_specific_options_page (QWidget *) const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
static tl::RegisteredClass<lay::PluginDeclaration> plugin_decl1 (new lay::GDS2WriterPluginDeclaration (), 10000, "GDS2Writer");
|
||||
|
|
|
|||
Loading…
Reference in New Issue