From 753e170a68381449aece47d041adc167d75312a2 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Fri, 31 Aug 2018 23:25:19 +0200 Subject: [PATCH] Fixed #162 (GDS2 libname not maintained) --- Changelog | 5 +++++ src/lay/lay/layMainWindow.cc | 2 ++ src/laybasic/laybasic/layCellView.cc | 25 +++++++++++++++++++++++++ src/laybasic/laybasic/layCellView.h | 9 +++++++++ 4 files changed, 41 insertions(+) diff --git a/Changelog b/Changelog index e3c628f40..4c08a6981 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,8 @@ +0.25.5 (xxxx-xx-xx): + +* Bugfix: https://github.com/klayoutmatthias/klayout/issues/162 + GDS2 LIBNAME was not maintained on "File/Save". + 0.25.4 (2018-08-25): * Bugfix: https://github.com/klayoutmatthias/klayout/issues/121 Issue with multiple reads of GDS2 layouts including PCells diff --git a/src/lay/lay/layMainWindow.cc b/src/lay/lay/layMainWindow.cc index 9f50edaa5..22644d368 100644 --- a/src/lay/lay/layMainWindow.cc +++ b/src/lay/lay/layMainWindow.cc @@ -3170,6 +3170,8 @@ MainWindow::do_save (bool as) options.set_dbu (cv->layout ().dbu ()); options.set_format_from_filename (fn); + cv->update_save_options (options); + tl::OutputStream::OutputStreamMode om = tl::OutputStream::OM_Auto; if (as && ! mp_layout_save_as_options->get_options (current_view (), cv_index, fn, om, options)) { diff --git a/src/laybasic/laybasic/layCellView.cc b/src/laybasic/laybasic/layCellView.cc index 065b8a345..e48d4c8fe 100644 --- a/src/laybasic/laybasic/layCellView.cc +++ b/src/laybasic/laybasic/layCellView.cc @@ -258,6 +258,31 @@ LayoutHandle::set_save_options (const db::SaveLayoutOptions &options, bool valid m_save_options_valid = valid; } +void +LayoutHandle::update_save_options (db::SaveLayoutOptions &options) +{ + for (tl::Registrar::iterator cls = tl::Registrar::begin (); cls != tl::Registrar::end (); ++cls) { + + const lay::StreamWriterPluginDeclaration *decl = dynamic_cast (&*cls); + if (! decl) { + continue; + } + + std::auto_ptr 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 ()) { + decl->initialize_options_from_layout_handle (specific_options.get (), *this); + options.set_options (specific_options.release ()); + } + + } +} + void LayoutHandle::save_as (const std::string &fn, tl::OutputStream::OutputStreamMode om, const db::SaveLayoutOptions &options, bool update) { diff --git a/src/laybasic/laybasic/layCellView.h b/src/laybasic/laybasic/layCellView.h index 4a5b3f170..1104ac91f 100644 --- a/src/laybasic/laybasic/layCellView.h +++ b/src/laybasic/laybasic/layCellView.h @@ -234,6 +234,15 @@ 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 *