mirror of https://github.com/KLayout/klayout.git
Bringing 'save all' on the same level than 'same'
- Taking the technology's settings for save options - Deploying "libname", e.g. for GDS2
This commit is contained in:
parent
dacb3230d5
commit
bbaaa14b2c
|
|
@ -2277,6 +2277,29 @@ MainWindow::cm_save_as ()
|
|||
do_save (true);
|
||||
}
|
||||
|
||||
static db::SaveLayoutOptions
|
||||
get_save_options_from_cv (const lay::CellView &cv)
|
||||
{
|
||||
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 ());
|
||||
}
|
||||
|
||||
// preconfigure options with current values
|
||||
|
||||
options.set_dbu (cv->layout ().dbu ());
|
||||
|
||||
if (cv->layout ().has_meta_info ("libname")) {
|
||||
tl::Variant libname = cv->layout ().meta_info ("libname").value;
|
||||
if (libname.is_a_string ()) {
|
||||
options.set_libname (libname.to_stdstring ());
|
||||
}
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
void
|
||||
MainWindow::do_save (bool as)
|
||||
{
|
||||
|
|
@ -2309,22 +2332,7 @@ MainWindow::do_save (bool as)
|
|||
// - if the layout's save options are valid we take the options from there, otherwise we take the options from the technology
|
||||
// - on "save as" we let the user edit the options
|
||||
|
||||
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 ());
|
||||
}
|
||||
|
||||
// preconfigure options with current values
|
||||
|
||||
options.set_dbu (cv->layout ().dbu ());
|
||||
|
||||
if (cv->layout ().has_meta_info ("libname")) {
|
||||
tl::Variant libname = cv->layout ().meta_info ("libname").value;
|
||||
if (libname.is_a_string ()) {
|
||||
options.set_libname (libname.to_stdstring ());
|
||||
}
|
||||
}
|
||||
db::SaveLayoutOptions options = get_save_options_from_cv (cv);
|
||||
|
||||
if (as || options.format ().empty ()) {
|
||||
options.set_format_from_filename (fn);
|
||||
|
|
@ -2362,8 +2370,7 @@ MainWindow::cm_save_all ()
|
|||
|
||||
if (! fn.empty () || mp_layout_fdia->get_save (fn, tl::to_string (tr ("Save Layout '%1'").arg (tl::to_qstring (cv->name ()))))) {
|
||||
|
||||
db::SaveLayoutOptions options (cv->save_options ());
|
||||
options.set_dbu (cv->layout ().dbu ());
|
||||
db::SaveLayoutOptions options = get_save_options_from_cv (cv);
|
||||
|
||||
if (options.format ().empty ()) {
|
||||
options.set_format_from_filename (fn);
|
||||
|
|
|
|||
|
|
@ -300,32 +300,6 @@ LayoutHandle::set_save_options (const db::SaveLayoutOptions &options, bool valid
|
|||
m_save_options_valid = valid;
|
||||
}
|
||||
|
||||
void
|
||||
LayoutHandle::update_save_options (db::SaveLayoutOptions &options)
|
||||
{
|
||||
#if defined(HAVE_QT)
|
||||
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 || decl->options_alias ()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
std::unique_ptr<db::FormatSpecificWriterOptions> specific_options;
|
||||
if (options.get_options (decl->format_name ())) {
|
||||
specific_options.reset (options.get_options (decl->format_name ())->clone ());
|
||||
} else {
|
||||
specific_options.reset (decl->create_specific_options ());
|
||||
}
|
||||
|
||||
if (specific_options.get ()) {
|
||||
options.set_options (specific_options.release ());
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
LayoutHandle::save_as (const std::string &fn, tl::OutputStream::OutputStreamMode om, const db::SaveLayoutOptions &options, bool update, int keep_backups)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -242,15 +242,6 @@ public:
|
|||
return m_save_options;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Updates the given save options with attributes from this cell view
|
||||
*
|
||||
* Some formats will initialize attributes from the cell view and the layout's
|
||||
* metadata (example: libname of GDS2). This method will update the options
|
||||
* if the layout provides attributes for initializing the latter.
|
||||
*/
|
||||
void update_save_options (db::SaveLayoutOptions &options);
|
||||
|
||||
/**
|
||||
* @brief Gets a flag indicating whether the save options are valid
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue