mirror of
https://github.com/KLayout/klayout.git
synced 2026-08-30 09:49:21 +02:00
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:
@@ -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
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user