From 1b129758d84e1c49e3234fc5ebf4bb51836f8ade Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 24 Apr 2022 23:27:33 +0200 Subject: [PATCH 01/88] More range for NoQt option - covers lym (without MacroCollection), drc, lvs and buddies now --- src/buddies/src/bd/strmxor.cc | 4 +- src/klayout.pro | 24 +- src/lay/lay/layMacroController.h | 2 +- src/lay/lay/layMacroEditorTree.cc | 2 +- src/laybasic/laybasic/layLayoutCanvas.h | 3 +- src/laybasic/laybasic/layLayoutView.h | 1 + src/lym/lym/gsiDeclLymMacro.cc | 7 +- src/lym/lym/lym.pro | 2 + src/lym/lym/lymMacro.cc | 972 +---------------- src/lym/lym/lymMacro.h | 529 +--------- src/lym/lym/lymMacroCollection.cc | 987 ++++++++++++++++++ src/lym/lym/lymMacroCollection.h | 594 +++++++++++ src/lym/lym/lymMacroInterpreter.cc | 6 +- src/plugins/tools/view_25d/view_25d.pro | 14 +- src/tl/unit_tests/tlFileSystemWatcherTests.cc | 2 + 15 files changed, 1657 insertions(+), 1492 deletions(-) create mode 100644 src/lym/lym/lymMacroCollection.cc create mode 100644 src/lym/lym/lymMacroCollection.h diff --git a/src/buddies/src/bd/strmxor.cc b/src/buddies/src/bd/strmxor.cc index 03de6cf80..1e5cf7722 100644 --- a/src/buddies/src/bd/strmxor.cc +++ b/src/buddies/src/bd/strmxor.cc @@ -408,7 +408,7 @@ BD_PUBLIC int strmxor (int argc, char *argv[]) db::Layout layout_b; { - tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Loading file (A): ")) + infile_a); + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Loading file (A): ")) + infile_a); db::LoadLayoutOptions load_options; generic_reader_options_a.configure (load_options); @@ -416,7 +416,7 @@ BD_PUBLIC int strmxor (int argc, char *argv[]) } { - tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Loading file (B): ")) + infile_b); + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Loading file (B): ")) + infile_b); db::LoadLayoutOptions load_options; generic_reader_options_b.configure (load_options); diff --git a/src/klayout.pro b/src/klayout.pro index 1cea2a7a7..9d584c003 100644 --- a/src/klayout.pro +++ b/src/klayout.pro @@ -11,6 +11,8 @@ SUBDIRS = \ lib \ plugins \ unit_tests \ + buddies \ + lym \ !equals(HAVE_QT, "0") { @@ -20,8 +22,6 @@ SUBDIRS = \ laybasic \ lay \ ant \ - buddies \ - lym \ img \ edt \ fontgen \ @@ -60,21 +60,22 @@ lib.depends += db plugins.depends += lib rdb db -!equals(HAVE_QT, "0") { +buddies.depends += plugins lym $$LANG_DEPENDS +lym.depends += gsi $$LANG_DEPENDS - buddies.depends += plugins lym $$LANG_DEPENDS +equals(HAVE_RUBY, "1") { + SUBDIRS += drc lvs + MAIN_DEPENDS += drc lvs + drc.depends += rdb lym + lvs.depends += drc +} + +!equals(HAVE_QT, "0") { equals(HAVE_PYTHON, "1") { pymod.depends += lay } - equals(HAVE_RUBY, "1") { - SUBDIRS += drc lvs - MAIN_DEPENDS += drc lvs - drc.depends += rdb lym - lvs.depends += drc - } - equals(HAVE_QTBINDINGS, "1") { SUBDIRS += gsiqt @@ -89,7 +90,6 @@ plugins.depends += lib rdb db plugins.depends += lay ant - lym.depends += gsi $$LANG_DEPENDS laybasic.depends += rdb lym ant.depends += laybasic img.depends += laybasic diff --git a/src/lay/lay/layMacroController.h b/src/lay/lay/layMacroController.h index cae8e979b..707cc44e9 100644 --- a/src/lay/lay/layMacroController.h +++ b/src/lay/lay/layMacroController.h @@ -26,7 +26,7 @@ #include "layCommon.h" #include "layPlugin.h" -#include "lymMacro.h" +#include "lymMacroCollection.h" #include "tlObject.h" #include "tlDeferredExecution.h" #include "tlFileSystemWatcher.h" diff --git a/src/lay/lay/layMacroEditorTree.cc b/src/lay/lay/layMacroEditorTree.cc index 544930dd0..a6035d641 100644 --- a/src/lay/lay/layMacroEditorTree.cc +++ b/src/lay/lay/layMacroEditorTree.cc @@ -23,7 +23,7 @@ #include "layMacroEditorTree.h" #include "layMacroEditorDialog.h" -#include "lymMacro.h" +#include "lymMacroCollection.h" #include "tlExceptions.h" #include "tlInternational.h" #include "tlException.h" diff --git a/src/laybasic/laybasic/layLayoutCanvas.h b/src/laybasic/laybasic/layLayoutCanvas.h index 34660f835..bbdbfcfcd 100644 --- a/src/laybasic/laybasic/layLayoutCanvas.h +++ b/src/laybasic/laybasic/layLayoutCanvas.h @@ -171,8 +171,6 @@ public: void update_image (); - virtual void paintEvent (QPaintEvent *); - /** * @brief Specifies the global transformation which is always applied first */ @@ -386,6 +384,7 @@ private: QMutex m_mutex; + virtual void paintEvent (QPaintEvent *); virtual void resizeEvent (QResizeEvent *); virtual bool event (QEvent *e); virtual void key_event (unsigned int key, unsigned int buttons); diff --git a/src/laybasic/laybasic/layLayoutView.h b/src/laybasic/laybasic/layLayoutView.h index 0ad398392..9fd1519b9 100644 --- a/src/laybasic/laybasic/layLayoutView.h +++ b/src/laybasic/laybasic/layLayoutView.h @@ -2673,6 +2673,7 @@ public slots: void min_hier_changed (int i); void max_hier_changed (int i); +private: // event handlers used to connect to the layout object's events void signal_hier_changed (); void signal_bboxes_from_layer_changed (unsigned int cv_index, unsigned int layer_index); diff --git a/src/lym/lym/gsiDeclLymMacro.cc b/src/lym/lym/gsiDeclLymMacro.cc index 7d22afa72..3bce22d44 100644 --- a/src/lym/lym/gsiDeclLymMacro.cc +++ b/src/lym/lym/gsiDeclLymMacro.cc @@ -27,6 +27,7 @@ #include "gsiEnums.h" #include "lymMacroInterpreter.h" #include "lymMacro.h" +#include "lymMacroCollection.h" #include "rba.h" #include "tlClassRegistry.h" @@ -204,7 +205,7 @@ public: lym::Macro *create_template (const std::string &url) { if (! mp_registration) { - throw std::runtime_error (tl::to_string (QObject::tr ("MacroInterpreter::create_template must be called after register"))); + throw std::runtime_error (tl::to_string (tr ("MacroInterpreter::create_template must be called after register"))); } lym::Macro *m = new lym::Macro (); @@ -472,7 +473,11 @@ gsi::ClassExt inject_Format_in_parent (decl_FormatEnum.def static lym::Macro *macro_by_path (const std::string &path) { +#if defined(HAVE_QT) return lym::MacroCollection::root ().find_macro (path); +#else + return 0; +#endif } static std::string real_path (const std::string &path, int line) diff --git a/src/lym/lym/lym.pro b/src/lym/lym/lym.pro index 18dff3666..9a87d4c8b 100644 --- a/src/lym/lym/lym.pro +++ b/src/lym/lym/lym.pro @@ -9,12 +9,14 @@ DEFINES += MAKE_LYM_LIBRARY SOURCES = \ gsiDeclLymMacro.cc \ lymMacroInterpreter.cc \ + lymMacroCollection.cc \ lymMacro.cc \ HEADERS = \ lymCommon.h \ lymInclude.h \ lymMacroInterpreter.h \ + lymMacroCollection.h \ lymMacro.h \ INCLUDEPATH += $$TL_INC $$GSI_INC diff --git a/src/lym/lym/lymMacro.cc b/src/lym/lym/lymMacro.cc index 429a4fbf2..26fbd4708 100644 --- a/src/lym/lym/lymMacro.cc +++ b/src/lym/lym/lymMacro.cc @@ -22,6 +22,7 @@ #include "lymMacro.h" +#include "lymMacroCollection.h" #include "lymMacroInterpreter.h" #include "tlExceptions.h" #include "gsiDecl.h" @@ -39,39 +40,42 @@ #include "rba.h" #include "pya.h" -#include -#include -#include -#include +#include "tlFileUtils.h" +#include "tlUri.h" #include #include #include #include + namespace lym { // ---------------------------------------------------------------------- Macro::Macro () - : m_modified (true), m_readonly (false), m_autorun (false), m_autorun_default (false), m_autorun_early (false), m_priority (0), m_show_in_menu (false), m_is_file (false), mp_parent (0), m_interpreter (None), m_format (Macro::NoFormat) + : m_modified (true), m_readonly (false), m_autorun (false), m_autorun_default (false), m_autorun_early (false), m_priority (0), m_show_in_menu (false), m_is_file (false), m_interpreter (None), m_format (Macro::NoFormat) { - // .. nothing yet .. + mp_parent = 0; } void Macro::on_menu_needs_update () { +#if defined(HAVE_QT) // forward the signal to the root collection - the main window will attach to this MacroCollection::root ().on_menu_needs_update (); +#endif } void Macro::on_changed () { +#if defined(HAVE_QT) emit changed (); if (mp_parent) { mp_parent->on_macro_changed (this); } +#endif } void Macro::assign (const lym::Macro &other) @@ -133,8 +137,7 @@ bool Macro::del () if (tl::verbosity () >= 20) { tl::log << "Deleting macro " << path (); } - QFile f (tl::to_qstring (path ())); - return f.remove (); + return tl::rm_file (path ()); } else { return true; } @@ -254,7 +257,7 @@ void Macro::load_from (const std::string &fn) } } else { - throw tl::Exception (tl::to_string (QObject::tr ("Unable to determine format for file from suffix or format spec ")) + fn); + throw tl::Exception (tl::to_string (tr ("Unable to determine format for file from suffix or format spec ")) + fn); } m_modified = true; @@ -270,7 +273,7 @@ void Macro::load_from_string (const std::string &text, const std::string &url) tl::log << "Loading macro from " << url; } - if (format_from_suffix (tl::to_string (QUrl (tl::to_qstring (url)).path ()), m_interpreter, m_dsl_interpreter, m_autorun_default, m_format)) { + if (format_from_suffix (tl::URI (url).path (), m_interpreter, m_dsl_interpreter, m_autorun_default, m_format)) { m_autorun = m_autorun_default; @@ -291,7 +294,7 @@ void Macro::load_from_string (const std::string &text, const std::string &url) } } else { - throw tl::Exception (tl::to_string (QObject::tr ("Unable to determine format for file from suffix ")) + url); + throw tl::Exception (tl::to_string (tr ("Unable to determine format for file from suffix ")) + url); } m_modified = true; @@ -306,8 +309,7 @@ void Macro::load () bool Macro::format_from_suffix (const std::string &fn, Macro::Interpreter &interpreter, std::string &dsl_name, bool &autorun_pref, Macro::Format &format) { - std::string suffix = tl::to_string (QFileInfo (tl::to_qstring (fn)).suffix ()); - return format_from_suffix_string (suffix, interpreter, dsl_name, autorun_pref, format); + return format_from_suffix_string (tl::extension (fn), interpreter, dsl_name, autorun_pref, format); } std::pair @@ -425,10 +427,9 @@ std::string Macro::path () const std::string suffix = suffix_for_format (m_interpreter, m_dsl_interpreter, m_format); if (mp_parent) { - return tl::to_string (QFileInfo (QDir (tl::to_qstring (mp_parent->path ())), tl::to_qstring (m_name + suffix)).filePath ()); - } else { - return m_name + suffix; + return tl::combine_path (mp_parent->path (), m_name + suffix); } + return m_name + suffix; } void Macro::set_file_path (const std::string &fp) @@ -459,8 +460,7 @@ bool Macro::rename (const std::string &n) if (tl::verbosity () >= 20) { tl::log << "Renaming macro " << path () << " to " << n; } - QFile f (tl::to_qstring (path ())); - if (! f.rename (QFileInfo (QDir (tl::to_qstring (parent ()->path ())), tl::to_qstring (n + suffix)).filePath ())) { + if (! tl::rename_file (path (), tl::combine_path (parent ()->path (), n + suffix))) { return false; } } @@ -478,9 +478,8 @@ std::string Macro::dir () const { if (mp_parent) { return mp_parent->path (); - } else { - return std::string (); } + return tl::dirname (path ()); } std::string Macro::display_string () const @@ -948,7 +947,7 @@ void Macro::install_doc () const --i; if (cls) { - tl::error << tl::to_string (QObject::tr ("Reading class doc from ")) << path () << ": " << tl::to_string (QObject::tr ("Duplicate @class")); + tl::error << tl::to_string (tr ("Reading class doc from ")) << path () << ": " << tl::to_string (tr ("Duplicate @class")); return; } @@ -970,7 +969,7 @@ void Macro::install_doc () const } } if (! super_cls) { - tl::error << tl::to_string (QObject::tr ("Reading class doc from ")) << path () << ": " << tl::to_string (QObject::tr ("Cannot find super class: ")) << super_cls_name; + tl::error << tl::to_string (tr ("Reading class doc from ")) << path () << ": " << tl::to_string (tr ("Cannot find super class: ")) << super_cls_name; return; } } @@ -986,7 +985,7 @@ void Macro::install_doc () const } else if (ex.test ("@method") || (st = ex.test ("@static_method")) == true) { if (cls == 0) { - tl::error << tl::to_string (QObject::tr ("Reading class doc from ")) << path () << ": " << tl::to_string (QObject::tr ("@method without preceding @class")); + tl::error << tl::to_string (tr ("Reading class doc from ")) << path () << ": " << tl::to_string (tr ("@method without preceding @class")); } else { std::string n; @@ -1082,932 +1081,5 @@ int Macro::run () const return 0; } -// ---------------------------------------------------------------------- - -static MacroCollection ms_root; - -MacroCollection::MacroCollection () - : mp_parent (0), m_virtual_mode (ProjectFolder), m_readonly (false) -{ - // .. nothing yet .. -} - -MacroCollection::~MacroCollection () -{ - do_clear (); -} - -void MacroCollection::do_clear () -{ - for (iterator m = begin (); m != end (); ++m) { - delete m->second; - } - m_macros.clear (); - - for (child_iterator mm = begin_children (); mm != end_children (); ++mm) { - delete mm->second; - } - m_folders.clear (); -} - -void MacroCollection::begin_changes () -{ - // Note: it is very important that each on_changed occurs after exactly one begin_changes. - // (See #459 for example) - if (mp_parent) { - mp_parent->begin_changes (); - } else { - emit about_to_change (); - } -} - -void MacroCollection::on_menu_needs_update () -{ - emit menu_needs_update (); -} - -void MacroCollection::on_changed () -{ - // Note: it is very important that each on_changed occurs after exactly one begin_changes. - // (See #459 for example) - emit changed (); - on_macro_collection_changed (this); -} - -void MacroCollection::on_macro_collection_changed (MacroCollection *mc) -{ - if (mp_parent) { - mp_parent->on_macro_collection_changed (mc); - } else { - emit macro_collection_changed (mc); - } -} - -void MacroCollection::on_child_deleted (MacroCollection *mc) -{ - emit child_deleted (mc); - on_macro_collection_deleted (mc); -} - -void MacroCollection::on_macro_collection_deleted (MacroCollection *mc) -{ - if (mp_parent) { - mp_parent->on_macro_collection_deleted (mc); - } else { - emit macro_collection_deleted (mc); - } -} - -void MacroCollection::on_macro_deleted_here (Macro *macro) -{ - emit macro_deleted_here (macro); - on_macro_deleted (macro); -} - -void MacroCollection::on_macro_deleted (Macro *macro) -{ - if (mp_parent) { - mp_parent->on_macro_deleted (macro); - } else { - emit macro_deleted (macro); - } -} - -void MacroCollection::on_macro_changed (Macro *macro) -{ - if (mp_parent) { - mp_parent->on_macro_changed (macro); - } else { - emit macro_changed (macro); - } -} - -void MacroCollection::collect_used_nodes (std::set ¯os, std::set ¯o_collections) -{ - for (MacroCollection::child_iterator c = begin_children (); c != end_children (); ++c) { - macro_collections.insert (c->second); - c->second->collect_used_nodes (macros, macro_collections); - } - for (MacroCollection::iterator c = begin (); c != end (); ++c) { - macros.insert (c->second); - } -} - -Macro *MacroCollection::macro_by_name (const std::string &name, Macro::Format format) -{ - std::multimap ::iterator i = m_macros.find (name); - while (i != m_macros.end () && i->first == name) { - if (format == Macro::NoFormat || i->second->format () == format) { - return i->second; - } - ++i; - } - return 0; -} - -const Macro *MacroCollection::macro_by_name (const std::string &name, Macro::Format format) const -{ - std::multimap ::const_iterator i = m_macros.find (name); - while (i != m_macros.end () && i->first == name) { - if (format == Macro::NoFormat || i->second->format () == format) { - return i->second; - } - ++i; - } - return 0; -} - -MacroCollection *MacroCollection::folder_by_name (const std::string &name) -{ - std::map ::iterator i = m_folders.find (name); - if (i != m_folders.end ()) { - return i->second; - } else { - return 0; - } -} - -const MacroCollection *MacroCollection::folder_by_name (const std::string &name) const -{ - std::map ::const_iterator i = m_folders.find (name); - if (i != m_folders.end ()) { - return i->second; - } else { - return 0; - } -} - -std::string MacroCollection::path () const -{ - if (m_virtual_mode) { - return m_path; - } else if (mp_parent) { - return tl::to_string (QFileInfo (QDir (tl::to_qstring (mp_parent->path ())), tl::to_qstring (m_path)).filePath ()); - } else { - return m_path; - } -} - -std::string MacroCollection::display_string () const -{ - if (m_virtual_mode) { - return "[" + m_description + "]"; - } else { - std::string r = name (); - if (! m_description.empty ()) { - r += " - " + m_description; - } - return r; - } -} - -void -MacroCollection::make_readonly (bool f) -{ - if (m_readonly != f) { - begin_changes (); - m_readonly = f; - on_changed (); - } -} - -MacroCollection * -MacroCollection::add_folder (const std::string &description, const std::string &path, const std::string &cat, bool readonly, bool force_create) -{ - if (! path.empty () && path[0] == ':') { - readonly = true; - } else { - - QFileInfo file_info (tl::to_qstring (path)); - - if (! file_info.exists ()) { - - // Try to create the folder since it does not exist yet or skip that one - if (! force_create) { - - if (tl::verbosity () >= 20) { - tl::log << "Folder does not exist - skipping: " << path; - } - return 0; - - } else { - - if (tl::verbosity () >= 20) { - tl::log << "Folder does not exist yet - trying to create it: " << path; - } - if (! QDir::root ().mkpath (file_info.absoluteFilePath ())) { - if (tl::verbosity () >= 10) { - tl::error << "Unable to create folder path: " << path; - } - return 0; - } - } - - file_info.refresh (); - - } - - if (! file_info.isDir ()) { - if (tl::verbosity () >= 10) { - tl::error << "Folder is not a directory: " << path; - } - return 0; - } - - QString cp = file_info.canonicalFilePath (); - if (cp.isEmpty ()) { - return 0; - } - - for (child_iterator f = m_folders.begin (); f != m_folders.end (); ++f) { - // skip, if that folder is in the collection already - if (QFileInfo (tl::to_qstring (f->first)).canonicalFilePath () == cp) { - return 0; - } - } - - if (! readonly && ! file_info.isWritable ()) { - readonly = true; - if (tl::verbosity () >= 20) { - tl::log << "Folder is read-only: " << path; - } - } - - } - - begin_changes (); - - MacroCollection *mc = m_folders.insert (std::make_pair (path, new MacroCollection ())).first->second; - mc->set_name (path); - mc->set_description (description); - mc->set_category (cat); - mc->set_readonly (readonly); - mc->scan (path); - mc->set_parent (this); - - on_changed (); - on_macro_changed (0); - - return mc; -} - -void MacroCollection::rescan () -{ - for (std::map ::const_iterator m = m_folders.begin (); m != m_folders.end (); ++m) { - m->second->scan (m->first); - } -} - -namespace { - - /** - * @brief A QResource variant that allows access to the children - */ - class ResourceWithChildren - : public QResource - { - public: - ResourceWithChildren (const QString &path) : QResource (path) { } - using QResource::children; - }; - -} - -void MacroCollection::scan (const std::string &path) -{ - if (tl::verbosity () >= 20) { - tl::info << "Scanning macro path " << path << " (readonly=" << m_readonly << ")"; - } - - if (! path.empty () && path[0] == ':') { - - ResourceWithChildren res (tl::to_qstring (path)); - QStringList children = res.children (); - children.sort (); - - for (QStringList::const_iterator c = children.begin (); c != children.end (); ++c) { - - std::string url = path + "/" + tl::to_string (*c); - QResource res (tl::to_qstring (url)); - if (res.size () > 0) { - - QByteArray data; -#if QT_VERSION >= 0x60000 - if (res.compressionAlgorithm () == QResource::ZlibCompression) { -#else - if (res.isCompressed ()) { -#endif - data = qUncompress ((const unsigned char *)res.data (), (int)res.size ()); - } else { - data = QByteArray ((const char *)res.data (), (int)res.size ()); - } - - try { - - Macro::Format format = Macro::NoFormat; - Macro::Interpreter interpreter = Macro::None; - std::string dsl_name; - bool autorun = false; - - if (Macro::format_from_suffix (tl::to_string (*c), interpreter, dsl_name, autorun, format)) { - - std::string n = tl::to_string (QFileInfo (*c).baseName ()); - - iterator mm = m_macros.find (n); - bool found = false; - while (mm != m_macros.end () && mm->first == n && ! found) { - if ((interpreter == Macro::None || mm->second->interpreter () == interpreter) && - (dsl_name.empty () || mm->second->dsl_interpreter () == dsl_name) && - mm->second->format () == format) { - found = true; - } - ++mm; - } - if (! found) { - Macro *m = m_macros.insert (std::make_pair (n, new Macro ()))->second; - m->set_interpreter (interpreter); - m->set_autorun_default (autorun); - m->set_autorun (autorun); - m->set_dsl_interpreter (dsl_name); - m->set_format (format); - m->set_name (n); - m->load_from_string (std::string (data.constData (), data.size ()), url); - m->set_readonly (m_readonly); - m->reset_modified (); - m->set_is_file (); - m->set_parent (this); - } - - } - - } catch (tl::Exception &ex) { - tl::error << "Reading " << url << ": " << ex.msg (); - } - - } - - } - - } else { - - QDir dir (tl::to_qstring (path)); - QStringList filters; - filters << QString::fromUtf8 ("*.lym"); - filters << QString::fromUtf8 ("*.txt"); - // TODO: should be either *.rb or *.python, depending on the category. - // Right now we rely on the folders not containing foreign files. - filters << QString::fromUtf8 ("*.rb"); - filters << QString::fromUtf8 ("*.py"); - - // add the suffixes in the DSL interpreter declarations - for (tl::Registrar::iterator cls = tl::Registrar::begin (); cls != tl::Registrar::end (); ++cls) { - if (! cls->suffix ().empty ()) { - filters << tl::to_qstring ("*." + cls->suffix ()); - } - } - - QStringList files = dir.entryList (filters, QDir::Files); - for (QStringList::ConstIterator f = files.begin (); f != files.end (); ++f) { - - std::unique_ptr new_macro; - - try { - - std::string n = tl::to_string (QFileInfo (*f).completeBaseName ()); - std::string mp = tl::to_string (dir.absoluteFilePath (*f)); - - Macro::Format format = Macro::NoFormat; - Macro::Interpreter interpreter = Macro::None; - std::string dsl_name; - bool autorun = false; - - if (Macro::format_from_suffix (tl::to_string (*f), interpreter, dsl_name, autorun, format)) { - - iterator mm = m_macros.find (n); - bool found = false; - while (mm != m_macros.end () && mm->first == n && ! found) { - if ((interpreter == Macro::None || mm->second->interpreter () == interpreter) && - (dsl_name.empty () || mm->second->dsl_interpreter () == dsl_name) && - mm->second->format () == format) { - found = true; - } - ++mm; - } - if (! found) { - Macro *m = new Macro (); - new_macro.reset (m); - m->set_format (format); - m->set_autorun_default (autorun); - m->set_autorun (autorun); - m->set_interpreter (interpreter); - m->set_dsl_interpreter (dsl_name); - m->set_name (n); - m->load_from (mp); - m->reset_modified (); - m->set_readonly (m_readonly); - m->set_parent (this); - } - - } - - if (new_macro.get ()) { - m_macros.insert (std::make_pair (n, new_macro.release ())); - } - - } catch (tl::Exception &ex) { - tl::error << "Reading " << tl::to_string (*f) << " in " << path << ": " << ex.msg (); - } - - } - - QStringList folders = dir.entryList (QDir::Dirs | QDir::NoDotAndDotDot); - for (QStringList::ConstIterator f = folders.begin (); f != folders.end (); ++f) { - - try { - - std::string n = tl::to_string (*f); - MacroCollection *&mc = m_folders.insert (std::make_pair (n, (MacroCollection *) 0)).first->second; - if (! mc) { - mc = new MacroCollection (); - mc->set_name (n); - mc->set_virtual_mode (NotVirtual); - bool ro = (m_readonly || ! QFileInfo (dir.filePath (*f)).isWritable ()); - mc->set_readonly (ro); - mc->scan (tl::to_string (dir.filePath (*f))); - mc->set_parent (this); - } - - } catch (tl::Exception &ex) { - tl::error << ex.msg (); - } - - } - - } -} - -void MacroCollection::clear () -{ - begin_changes (); - do_clear (); - on_changed (); -} - -void MacroCollection::erase (lym::Macro *mp) -{ - for (iterator m = m_macros.begin (); m != m_macros.end (); ++m) { - if (m->second == mp) { - begin_changes (); - on_macro_deleted_here (mp); - m_macros.erase (m); - delete mp; - on_changed (); - return; - } - } -} - -void MacroCollection::erase (lym::MacroCollection *mp) -{ - for (child_iterator f = m_folders.begin (); f != m_folders.end (); ++f) { - if (f->second == mp) { - begin_changes (); - on_child_deleted (mp); - m_folders.erase (f); - delete mp; - on_changed (); - return; - } - } -} - -void MacroCollection::erase (iterator i) -{ - begin_changes (); - on_macro_deleted_here (i->second); - delete i->second; - m_macros.erase (i); - on_changed (); -} - -void MacroCollection::erase (child_iterator i) -{ - begin_changes (); - on_child_deleted (i->second); - delete i->second; - m_folders.erase (i); - on_changed (); -} - -void MacroCollection::save () -{ - for (child_iterator f = m_folders.begin (); f != m_folders.end (); ++f) { - f->second->save (); - } - - for (iterator m = m_macros.begin (); m != m_macros.end (); ++m) { - if (m->second->is_modified () && ! m->second->is_readonly () && ! m->second->path ().empty ()) { - try { - m->second->save (); - } catch (tl::Exception &ex) { - tl::error << ex.msg (); - } - } - } -} - -bool MacroCollection::rename (const std::string &n) -{ - if (tl::verbosity () >= 20) { - tl::info << "Renaming macro folder " << path () << " to " << n; - } - QFile f (tl::to_qstring (path ())); - begin_changes (); - if (! f.rename (QFileInfo (QDir (tl::to_qstring (mp_parent->path ())), tl::to_qstring (n)).filePath ())) { - on_changed (); - return false; - } else { - m_path = n; - on_changed (); - return true; - } -} - -lym::MacroCollection *MacroCollection::create_folder (const char *prefix, bool mkdir) -{ - std::string name; - int n = 0; - do { - name = (prefix ? prefix : "new_folder"); - if (n > 0) { - name += "_" + tl::to_string (n); - } - if (m_folders.find (name) == m_folders.end ()) { - break; - } - ++n; - } while (true); - - if (mkdir && ! QDir (tl::to_qstring (path ())).mkdir (tl::to_qstring (name))) { - return 0; - } - - begin_changes (); - - lym::MacroCollection *m = m_folders.insert (std::make_pair (name, new lym::MacroCollection ())).first->second; - m->set_virtual_mode (NotVirtual); - m->set_name (name); - m->set_parent (this); - - on_changed (); - - return m; -} - -lym::Macro *MacroCollection::create (const char *prefix, Macro::Format format) -{ - std::string name; - int n = 0; - do { - name = (prefix ? prefix : "new_macro"); - if (n > 0) { - name += "_" + tl::to_string (n); - } - if (! macro_by_name (name, format)) { - break; - } - ++n; - } while (true); - - begin_changes (); - - lym::Macro *m = m_macros.insert (std::make_pair (name, new lym::Macro ()))->second; - m->set_name (name); - m->set_parent (this); - - on_changed (); - - return m; -} - -void MacroCollection::add_unspecific (lym::Macro *m) -{ - begin_changes (); - m_macros.insert (std::make_pair (m->name (), m)); - m->set_parent (this); - on_changed (); -} - -bool MacroCollection::add (lym::Macro *m) -{ - QDir d (tl::to_qstring (path ())); - QDir dd = QFileInfo (tl::to_qstring (m->path ())).dir (); - - if (d == dd) { - - begin_changes (); - m_macros.insert (std::make_pair (m->name (), m)); - m->set_parent (this); - on_changed (); - return true; - - } else { - - for (child_iterator c = begin_children (); c != end_children (); ++c) { - if (c->second->add (m)) { - return true; - } - } - - // try to detect new child folders. If that is the case, create that folder and add - // the macro there. - QDir dm (tl::to_qstring (m->dir ())); - while (true) { - - std::string folder_name = tl::to_string (dm.dirName ()); - if (! dm.cdUp ()) { - break; - } - - if (dm == d) { - begin_changes (); - lym::MacroCollection *mc = m_folders.insert (std::make_pair (folder_name, new MacroCollection ())).first->second; - mc->set_virtual_mode (NotVirtual); - mc->set_parent (this); - on_changed (); - return mc->add (m); - } - - } - - } - - return false; -} - -bool MacroCollection::del () -{ - if (tl::verbosity () >= 20) { - tl::info << "Deleting macro folder " << path (); - } - return QDir ().rmdir (tl::to_qstring (path ())); -} - -void MacroCollection::rename_macro (Macro *macro, const std::string &new_name) -{ - iterator m = m_macros.find (macro->name ()); - while (m != m_macros.end () && m->first == macro->name ()) { - if (m->second == macro) { - m_macros.erase (m); - m_macros.insert (std::make_pair (new_name, macro)); - return; - } - ++m; - } -} - -lym::Macro *MacroCollection::find_macro (const std::string &path) -{ - for (iterator m = begin (); m != end (); ++m) { - if (m->second->path () == path) { - return m->second; - } - } - - for (child_iterator mc = begin_children (); mc != end_children (); ++mc) { - lym::Macro *macro = mc->second->find_macro (path); - if (macro) { - return macro; - } - } - - return 0; -} - -MacroCollection &MacroCollection::root () -{ - return ms_root; -} - -static bool sync_macros (lym::MacroCollection *current, lym::MacroCollection *actual, bool safe) -{ - bool ret = false; - - if (actual) { - current->make_readonly (actual->is_readonly ()); - } - - std::vector folders_to_delete; - - for (lym::MacroCollection::child_iterator m = current->begin_children (); m != current->end_children (); ++m) { - lym::MacroCollection *cm = actual ? actual->folder_by_name (m->first) : 0; - if (! cm) { - folders_to_delete.push_back (m->second); - } - } - - if (actual) { - for (lym::MacroCollection::child_iterator m = actual->begin_children (); m != actual->end_children (); ++m) { - lym::MacroCollection *cm = current->folder_by_name (m->first); - if (! cm) { - cm = current->create_folder (m->first.c_str (), false); - ret = true; - } - if (sync_macros(cm, m->second, safe)) { - ret = true; - } - } - } - - // delete folders which do no longer exist - for (std::vector::iterator m = folders_to_delete.begin (); m != folders_to_delete.end (); ++m) { - ret = true; - sync_macros (*m, 0, safe); - current->erase (*m); - } - - std::vector macros_to_delete; - - for (lym::MacroCollection::iterator m = current->begin (); m != current->end (); ++m) { - lym::Macro *cm = actual ? actual->macro_by_name (m->first, m->second->format ()) : 0; - if (! cm) { - macros_to_delete.push_back (m->second); - } - } - - if (actual) { - for (lym::MacroCollection::iterator m = actual->begin (); m != actual->end (); ++m) { - lym::Macro *cm = current->macro_by_name (m->first, m->second->format ()); - if (cm) { - if (*cm != *m->second && (! safe || ! cm->is_modified ())) { - cm->assign (*m->second); - } - cm->set_readonly (m->second->is_readonly ()); - } else { - cm = current->create (m->first.c_str (), m->second->format ()); - cm->assign (*m->second); - cm->set_readonly (m->second->is_readonly ()); - ret = true; - } - } - } - - // erase macros from collection which are no longer used - for (std::vector::const_iterator m = macros_to_delete.begin (); m != macros_to_delete.end (); ++m) { - current->erase (*m); - ret = true; - } - - return ret; -} - -void MacroCollection::reload (bool safe) -{ - // create a new collection and synchronize - - lym::MacroCollection new_collection; - for (lym::MacroCollection::child_iterator c = begin_children (); c != end_children (); ++c) { - new_collection.add_folder (c->second->description (), c->second->path (), c->second->category (), c->second->is_readonly (), false /* don't force to create */); - } - - // and synchronize current with the actual one - sync_macros (this, &new_collection, safe); -} - -static bool has_autorun_for (const lym::MacroCollection &collection, bool early) -{ - for (lym::MacroCollection::const_child_iterator c = collection.begin_children (); c != collection.end_children (); ++c) { - if (has_autorun_for (*c->second, early)) { - return true; - } - } - - for (lym::MacroCollection::const_iterator c = collection.begin (); c != collection.end (); ++c) { - if ((early && c->second->is_autorun_early ()) || (!early && c->second->is_autorun () && !c->second->is_autorun_early ())) { - return true; - } - } - - return false; -} - -bool MacroCollection::has_autorun () const -{ - return has_autorun_for (*this, false); -} - -bool MacroCollection::has_autorun_early () const -{ - return has_autorun_for (*this, true); -} - -static int collect_priority (lym::MacroCollection &collection, bool early, int from_prio) -{ - int p = -1; - - for (lym::MacroCollection::child_iterator c = collection.begin_children (); c != collection.end_children (); ++c) { - int pp = collect_priority (*c->second, early, from_prio); - if (pp >= from_prio && (p < 0 || pp < p)) { - p = pp; - } - } - - for (lym::MacroCollection::iterator c = collection.begin (); c != collection.end (); ++c) { - if (c->second->can_run () && ((early && c->second->is_autorun_early ()) || (!early && c->second->is_autorun () && !c->second->is_autorun_early ()))) { - int pp = c->second->priority (); - if (pp >= from_prio && (p < 0 || pp < p)) { - p = pp; - } - } - } - - return p; -} - -static void autorun_for_prio (lym::MacroCollection &collection, bool early, std::set *executed_already, int prio) -{ - for (lym::MacroCollection::child_iterator c = collection.begin_children (); c != collection.end_children (); ++c) { - autorun_for_prio (*c->second, early, executed_already, prio); - } - - for (lym::MacroCollection::iterator c = collection.begin (); c != collection.end (); ++c) { - - if (c->second->priority () == prio && c->second->can_run () && ((early && c->second->is_autorun_early ()) || (!early && c->second->is_autorun () && !c->second->is_autorun_early ()))) { - - if (!executed_already || executed_already->find (c->second->path ()) == executed_already->end ()) { - - BEGIN_PROTECTED_SILENT - c->second->run (); - c->second->install_doc (); - END_PROTECTED_SILENT - - if (executed_already) { - executed_already->insert (c->second->path ()); - } - - } - - } - - } -} - -static void autorun_for (lym::MacroCollection &collection, bool early, std::set *executed_already) -{ - int prio = 0; - while (true) { - int p = collect_priority (collection, early, prio); - if (p < prio) { - break; - } - autorun_for_prio (collection, early, executed_already, p); - prio = p + 1; - } -} - -void MacroCollection::autorun (std::set *already_executed) -{ - autorun_for (*this, false, already_executed); -} - -void MacroCollection::autorun_early (std::set *already_executed) -{ - autorun_for (*this, true, already_executed); -} - -void MacroCollection::dump (int l) -{ - for (int i = 0; i < l; ++i) { printf (" "); } - printf ("----\n"); - for (int i = 0; i < l; ++i) { printf (" "); } - printf ("Collection: %s\n", name ().c_str ()); - for (int i = 0; i < l; ++i) { printf (" "); } - printf ("Collection-path: %s\n", path ().c_str ()); - for (int i = 0; i < l; ++i) { printf (" "); } - printf ("Collection-description: %s\n", description ().c_str ()); - for (int i = 0; i < l; ++i) { printf (" "); } - printf("Collection-readonly: %d\n", is_readonly ()); - printf ("\n"); - - for (iterator m = begin (); m != end (); ++m) { - for (int i = 0; i < l; ++i) { printf (" "); } - printf("Name: %s%s\n", m->second->name ().c_str (), m->second->is_modified() ? "*" : ""); - for (int i = 0; i < l; ++i) { printf (" "); } - printf(" Path: %s\n", m->second->path ().c_str ()); - for (int i = 0; i < l; ++i) { printf (" "); } - printf(" Readonly: %d\n", m->second->is_readonly ()); - for (int i = 0; i < l; ++i) { printf (" "); } - printf(" Autorun: %d\n", m->second->is_autorun ()); - for (int i = 0; i < l; ++i) { printf (" "); } - printf(" Autorun-early: %d\n", m->second->is_autorun_early ()); - for (int i = 0; i < l; ++i) { printf (" "); } - printf(" Description: %s\n", m->second->description ().c_str ()); - } - - for (child_iterator m = begin_children (); m != end_children (); ++m) { - m->second->dump (l + 1); - } -} - } diff --git a/src/lym/lym/lymMacro.h b/src/lym/lym/lymMacro.h index 619be68a6..29ce328ea 100644 --- a/src/lym/lym/lymMacro.h +++ b/src/lym/lym/lymMacro.h @@ -31,7 +31,9 @@ #include #include -#include +#if defined(HAVE_QT) +# include +#endif namespace lym { @@ -55,11 +57,15 @@ class MacroCollection; * a macro can be bound to an arbitrary interpreter and decides * by itself which interpreter to use. */ -class LYM_PUBLIC Macro - : public QObject, +class LYM_PUBLIC Macro : +#if defined(HAVE_QT) + public QObject, +#endif public tl::Object { -Q_OBJECT +#if defined(HAVE_QT) +Q_OBJECT +#endif public: /** @@ -587,12 +593,14 @@ public: return !(*this == other); } +#if defined(HAVE_QT) signals: /** * @brief This signal is sent when the macro changes */ void changed (); - +#endif + private: friend class MacroCollection; @@ -646,517 +654,6 @@ private: Macro &operator= (const Macro &d); }; -/** - * @brief Represents a collection of macros - * - * A collection is representing a set of macros, usually associated with - * a folder containing *.lym, *.rb or other script files. - */ -class LYM_PUBLIC MacroCollection - : public QObject -{ -Q_OBJECT - -public: - typedef std::multimap ::iterator iterator; - typedef std::multimap ::const_iterator const_iterator; - typedef std::map ::iterator child_iterator; - typedef std::map ::const_iterator const_child_iterator; - - /** - * @brief Some constants for virtual_mode - */ - enum FolderType { - NotVirtual = 0, - ProjectFolder = 1, - TechFolder = 2, - SaltFolder = 3 - }; - - /** - * @brief Constructor - * - * The default constructor create - */ - MacroCollection (); - - /** - * @brief Destructor - */ - ~MacroCollection (); - - /** - * @brief Add a folder (will also scan the folder) - * - * @return A pointer to the new collection if successful - * - * If force_create is true (the default), the folder will be created if it does not - * exist yet. On error, 0 is returned. - */ - MacroCollection *add_folder (const std::string &description, const std::string &path, const std::string &category, bool readonly, bool force_create = true); - - /** - * @brief Gets the category tag of the collection - * - * A category tag can be used to categorize the collections. For example, DRC categories are handled differently - * from the other categories. - */ - const std::string &category () const - { - return m_category; - } - - /** - * @brief Sets the category tags - */ - void set_category (const std::string &d) - { - m_category = d; - } - - /** - * @brief Collect all Macro and MacroCollection objects inside a tree starting from this collection - */ - void collect_used_nodes(std::set ¯os, std::set ¯o_collections); - - /** - * @brief Saves all macros in the collection - * - * Saves only those macros that have is_modified and whose path is set. - */ - void save (); - - /** - * @brief Delete the original folder (the directory behind the macro) - * - * Returns true if the folder was deleted successfully. - * The folder cannot be deleted if it contains any files, also some that are not listed because - * they don't end with .lym, .rb or similar. - */ - bool del (); - - /** - * @brief Gets the name of the collection - * - * For virtual collections this is the path. - */ - std::string name () const - { - return m_path; - } - - /** - * @brief Gets the path of the folder representing that collection - */ - std::string path () const; - - /** - * @brief Returns the parent of the macro collection - * - * Returns 0, if there is no parent of this collection (this is the root) - */ - lym::MacroCollection *parent () - { - return mp_parent; - } - - /** - * @brief Returns the parent of the macro collection (const version) - * - * Returns 0, if there is no parent of this collection (this is the root) - */ - const lym::MacroCollection *parent () const - { - return mp_parent; - } - - /** - * @brief Returns != 0, if the macro collection is a virtual node - * - * A virtual node does not correspond to a location in the file system. - * A virtual node cannot have macros but only children. - * The return value indicates the kind of virtual use. - */ - int virtual_mode () const - { - return m_virtual_mode; - } - - /** - * @brief Sets the virtual mode - * - * See virtual_mode for details about the virtual mode. - */ - void set_virtual_mode (int m) - { - m_virtual_mode = m; - } - - /** - * @brief Gets a value indicating whether the macro collection is readonly - */ - bool is_readonly () const - { - return m_readonly; - } - - /** - * @brief Sets a value indicating whether the macro is readonly - * In contrast to the private \set_readonly method, this version delivers a "changed" signal when - * the flag changed. - */ - void make_readonly (bool f); - - /** - * @brief Gets the macro collection's description text - */ - const std::string &description () const - { - return m_description; - } - - /** - * @brief Sets the description - */ - void set_description (const std::string &d) - { - m_description = d; - } - - /** - * @brief Gets the display string - */ - std::string display_string () const; - - /** - * @brief Rename a Macro - * - * Renames the macro. If the macro is a file, the file will be renamed as well. - * This method will return true, if the rename was successful. - */ - bool rename (const std::string &n); - - /** - * @brief Adds a macro to the collection - * - * If a macro with the name of the new macro already exists, it is replaced - * (like in the file system). This method will traverse the tree to find - * the location of the macro using the path information of the macro and insert - * the macro there. - * - * The collection becomes the owner of the object passed to this method - * - * @return true, if the macro could be added successfully. - */ - bool add (lym::Macro *m); - - /** - * @brief Adds a macro in an unspecific way - * - * "unspecific" means that the path is not looked up - the macro is - * added irregardless whether the path matches or not. - * This is a way to build macro collections without connection - * to some file system point. - */ - void add_unspecific (lym::Macro *m); - - /** - * @brief Empties the collection - * Note: only the unspecific on_changed event is generated. - */ - void clear (); - - /** - * @brief Erases the given macro from the list - * - * This does not remove the file but just remove the macro object. - * This will also delete the macro object. - */ - void erase (lym::Macro *m); - - /** - * @brief Erases the entry with the given iterator - */ - void erase (iterator i); - - /** - * @brief Erases the given macro collection from the list of child collections - * - * This does not remove the directory but just removes the macro collection object. - * This will also delete the macro collection object. - */ - void erase (lym::MacroCollection *m); - - /** - * @brief Erases the folder with the given iterator - */ - void erase (child_iterator i); - - /** - * @brief Creates a new macro in that collection (with a new name) - * - * If a name is given, it is used as a prefix to create a unique name for a macro with that format. - */ - lym::Macro *create (const char *name = 0, Macro::Format format = Macro::NoFormat); - - /** - * @brief Creates a new macro collection in that collection (with a new name) - * - * If a name is given, it is used as a prefix to create a unique name. - * This method will also create the directory for this folder. - * If not successful, it will return 0. - */ - lym::MacroCollection *create_folder (const char *name = 0, bool mkdir = true); - - /** - * @brief Gets the begin iterator of the macros - */ - iterator begin () - { - return m_macros.begin (); - } - - /** - * @brief Gets the end iterator of the macros - */ - iterator end () - { - return m_macros.end (); - } - - /** - * @brief Gets the begin iterator of the macros (const version) - */ - const_iterator begin () const - { - return m_macros.begin (); - } - - /** - * @brief Gets the end iterator of the macros (const version) - */ - const_iterator end () const - { - return m_macros.end (); - } - - /** - * @brief Gets the begin iterator of the folders - */ - child_iterator begin_children () - { - return m_folders.begin (); - } - - /** - * @brief Gets the end iterator of the folders - */ - child_iterator end_children () - { - return m_folders.end (); - } - - /** - * @brief Gets the begin iterator of the folders (const version) - */ - const_child_iterator begin_children () const - { - return m_folders.begin (); - } - - /** - * @brief Gets the end iterator of the folders (const version) - */ - const_child_iterator end_children () const - { - return m_folders.end (); - } - - /** - * @brief Gets a macro by name - * - * If no macro with that name exists, this method will return 0. - */ - Macro *macro_by_name (const std::string &name, Macro::Format format); - - /** - * @brief Gets a macro by name - * - * If no macro with that name exists, this method will return 0. - */ - const Macro *macro_by_name (const std::string &name, Macro::Format format) const; - - /** - * @brief Gets a folder by name - * - * If no folder with that name exists, this method will return 0. - */ - MacroCollection *folder_by_name (const std::string &name); - - /** - * @brief Gets a folder by name - * - * If no folder with that name exists, this method will return 0. - */ - const MacroCollection *folder_by_name (const std::string &name) const; - - /** - * @brief Finds a macro by path - * - * This method is called from the root collection and delivers the macro which - * matches the given path or 0. - */ - lym::Macro *find_macro (const std::string &path); - - /** - * @brief Returns true, if the collection has an autorun macro - */ - bool has_autorun () const; - - /** - * @brief Runs all macros marked with auto-run - */ - void autorun (std::set *already_executed = 0); - - /** - * @brief Returns true, if the collection has an early autorun macro - */ - bool has_autorun_early () const; - - /** - * @brief Runs all macros marked with early auto-run - */ - void autorun_early (std::set *already_executed = 0); - - /** - * @brief Redo the scan (will add new files or folders) - * - * This method must be called on root. - */ - void rescan (); - - /** - * @brief Reloads the macro collection - * - * This method is similar to rescan, but it will also remove folders and macros. - * In safe mode (safe = true), modified macros won't be overwritten. - */ - void reload (bool safe); - - /** - * @brief Gets the root of the macro hierarchy corresponding to the configuration space - */ - static MacroCollection &root (); - - /** - * @brief Dump the macro tree (for debugging) - */ - void dump (int l = 0); - -signals: - /** - * @brief This signal is sent when the collection changes - */ - void changed (); - - /** - * @brief This signal is sent by collection when a child collection is deleted in this collection - */ - void child_deleted (lym::MacroCollection *); - - /** - * @brief This signal is sent by the root object when a macro collection is deleted - */ - void macro_collection_deleted (lym::MacroCollection *); - - /** - * @brief This signal is sent by collection when a macro is deleted in this collection - */ - void macro_deleted_here (lym::Macro *); - - /** - * @brief This signal is sent by the root object when a macro is deleted - */ - void macro_deleted (lym::Macro *); - - /** - * @brief This signal is sent by the root object when a macro changes - * - * This signal is only emitted by the root, but it may originate from a - * macro inside the tree. - */ - void macro_changed (lym::Macro *); - - /** - * @brief This signal is sent by the root object when a macro collection changes - * - * This signal is only emitted by the root, but it may originate from a - * macro collection inside the tree. - */ - void macro_collection_changed (lym::MacroCollection *); - - /** - * @brief This signal is sent by the root object befor the macro collection changes - */ - void about_to_change (); - - /** - * @brief This signal is emitted from the collection root if the menu needs to be updated - */ - void menu_needs_update (); - -private: - friend class Macro; - - std::string m_path; - std::string m_description; - std::string m_category; - std::multimap m_macros; - std::map m_folders; - lym::MacroCollection *mp_parent; - int m_virtual_mode; - bool m_readonly; - - void on_child_deleted (MacroCollection *mc); - void on_macro_collection_deleted (MacroCollection *mc); - void on_macro_deleted_here (Macro *macro); - void on_macro_deleted (Macro *macro); - void on_macro_changed (Macro *macro); - void on_macro_collection_changed (MacroCollection *mc); - void on_changed (); - void on_menu_needs_update (); - - /** - * @brief Scans a folder creating the macro collection - */ - void scan (const std::string &path); - - void rename_macro (Macro *macro, const std::string &new_name); - - void begin_changes (); - - void set_name (const std::string &n) - { - m_path = n; - } - - void set_parent (lym::MacroCollection *parent) - { - mp_parent = parent; - } - - void set_readonly (bool f) - { - m_readonly = f; - } - - void do_clear (); - - // no copying - MacroCollection (const MacroCollection &d); - MacroCollection &operator= (const MacroCollection &d); -}; - } #endif diff --git a/src/lym/lym/lymMacroCollection.cc b/src/lym/lym/lymMacroCollection.cc new file mode 100644 index 000000000..5ea264937 --- /dev/null +++ b/src/lym/lym/lymMacroCollection.cc @@ -0,0 +1,987 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 "lymMacroCollection.h" + +#if defined(HAVE_QT) + +#include "lymMacroInterpreter.h" +#include "tlExceptions.h" +#include "gsiDecl.h" +#include "gsiInterpreter.h" + +#include "tlString.h" +#include "tlStableVector.h" +#include "tlClassRegistry.h" +#include "tlLog.h" +#include "tlXMLParser.h" +#include "tlGlobPattern.h" +#include "tlInclude.h" +#include "tlProgress.h" + +#include "rba.h" +#include "pya.h" + +#include +#include +#include +#include + +#include +#include +#include +#include + +namespace lym +{ + +// ---------------------------------------------------------------------- + +static MacroCollection ms_root; + +MacroCollection::MacroCollection () + : mp_parent (0), m_virtual_mode (ProjectFolder), m_readonly (false) +{ + // .. nothing yet .. +} + +MacroCollection::~MacroCollection () +{ + do_clear (); +} + +void MacroCollection::do_clear () +{ + for (iterator m = begin (); m != end (); ++m) { + delete m->second; + } + m_macros.clear (); + + for (child_iterator mm = begin_children (); mm != end_children (); ++mm) { + delete mm->second; + } + m_folders.clear (); +} + +void MacroCollection::begin_changes () +{ + // Note: it is very important that each on_changed occurs after exactly one begin_changes. + // (See #459 for example) + if (mp_parent) { + mp_parent->begin_changes (); + } else { + emit about_to_change (); + } +} + +void MacroCollection::on_menu_needs_update () +{ + emit menu_needs_update (); +} + +void MacroCollection::on_changed () +{ + // Note: it is very important that each on_changed occurs after exactly one begin_changes. + // (See #459 for example) + emit changed (); + on_macro_collection_changed (this); +} + +void MacroCollection::on_macro_collection_changed (MacroCollection *mc) +{ + if (mp_parent) { + mp_parent->on_macro_collection_changed (mc); + } else { + emit macro_collection_changed (mc); + } +} + +void MacroCollection::on_child_deleted (MacroCollection *mc) +{ + emit child_deleted (mc); + on_macro_collection_deleted (mc); +} + +void MacroCollection::on_macro_collection_deleted (MacroCollection *mc) +{ + if (mp_parent) { + mp_parent->on_macro_collection_deleted (mc); + } else { + emit macro_collection_deleted (mc); + } +} + +void MacroCollection::on_macro_deleted_here (Macro *macro) +{ + emit macro_deleted_here (macro); + on_macro_deleted (macro); +} + +void MacroCollection::on_macro_deleted (Macro *macro) +{ + if (mp_parent) { + mp_parent->on_macro_deleted (macro); + } else { + emit macro_deleted (macro); + } +} + +void MacroCollection::on_macro_changed (Macro *macro) +{ + if (mp_parent) { + mp_parent->on_macro_changed (macro); + } else { + emit macro_changed (macro); + } +} + +void MacroCollection::collect_used_nodes (std::set ¯os, std::set ¯o_collections) +{ + for (MacroCollection::child_iterator c = begin_children (); c != end_children (); ++c) { + macro_collections.insert (c->second); + c->second->collect_used_nodes (macros, macro_collections); + } + for (MacroCollection::iterator c = begin (); c != end (); ++c) { + macros.insert (c->second); + } +} + +Macro *MacroCollection::macro_by_name (const std::string &name, Macro::Format format) +{ + std::multimap ::iterator i = m_macros.find (name); + while (i != m_macros.end () && i->first == name) { + if (format == Macro::NoFormat || i->second->format () == format) { + return i->second; + } + ++i; + } + return 0; +} + +const Macro *MacroCollection::macro_by_name (const std::string &name, Macro::Format format) const +{ + std::multimap ::const_iterator i = m_macros.find (name); + while (i != m_macros.end () && i->first == name) { + if (format == Macro::NoFormat || i->second->format () == format) { + return i->second; + } + ++i; + } + return 0; +} + +MacroCollection *MacroCollection::folder_by_name (const std::string &name) +{ + std::map ::iterator i = m_folders.find (name); + if (i != m_folders.end ()) { + return i->second; + } else { + return 0; + } +} + +const MacroCollection *MacroCollection::folder_by_name (const std::string &name) const +{ + std::map ::const_iterator i = m_folders.find (name); + if (i != m_folders.end ()) { + return i->second; + } else { + return 0; + } +} + +std::string MacroCollection::path () const +{ + if (m_virtual_mode) { + return m_path; + } else if (mp_parent) { + return tl::to_string (QFileInfo (QDir (tl::to_qstring (mp_parent->path ())), tl::to_qstring (m_path)).filePath ()); + } else { + return m_path; + } +} + +std::string MacroCollection::display_string () const +{ + if (m_virtual_mode) { + return "[" + m_description + "]"; + } else { + std::string r = name (); + if (! m_description.empty ()) { + r += " - " + m_description; + } + return r; + } +} + +void +MacroCollection::make_readonly (bool f) +{ + if (m_readonly != f) { + begin_changes (); + m_readonly = f; + on_changed (); + } +} + +MacroCollection * +MacroCollection::add_folder (const std::string &description, const std::string &path, const std::string &cat, bool readonly, bool force_create) +{ + if (! path.empty () && path[0] == ':') { + readonly = true; + } else { + + QFileInfo file_info (tl::to_qstring (path)); + + if (! file_info.exists ()) { + + // Try to create the folder since it does not exist yet or skip that one + if (! force_create) { + + if (tl::verbosity () >= 20) { + tl::log << "Folder does not exist - skipping: " << path; + } + return 0; + + } else { + + if (tl::verbosity () >= 20) { + tl::log << "Folder does not exist yet - trying to create it: " << path; + } + if (! QDir::root ().mkpath (file_info.absoluteFilePath ())) { + if (tl::verbosity () >= 10) { + tl::error << "Unable to create folder path: " << path; + } + return 0; + } + } + + file_info.refresh (); + + } + + if (! file_info.isDir ()) { + if (tl::verbosity () >= 10) { + tl::error << "Folder is not a directory: " << path; + } + return 0; + } + + QString cp = file_info.canonicalFilePath (); + if (cp.isEmpty ()) { + return 0; + } + + for (child_iterator f = m_folders.begin (); f != m_folders.end (); ++f) { + // skip, if that folder is in the collection already + if (QFileInfo (tl::to_qstring (f->first)).canonicalFilePath () == cp) { + return 0; + } + } + + if (! readonly && ! file_info.isWritable ()) { + readonly = true; + if (tl::verbosity () >= 20) { + tl::log << "Folder is read-only: " << path; + } + } + + } + + begin_changes (); + + MacroCollection *mc = m_folders.insert (std::make_pair (path, new MacroCollection ())).first->second; + mc->set_name (path); + mc->set_description (description); + mc->set_category (cat); + mc->set_readonly (readonly); + mc->scan (path); + mc->set_parent (this); + + on_changed (); + on_macro_changed (0); + + return mc; +} + +void MacroCollection::rescan () +{ + for (std::map ::const_iterator m = m_folders.begin (); m != m_folders.end (); ++m) { + m->second->scan (m->first); + } +} + +namespace { + + /** + * @brief A QResource variant that allows access to the children + */ + class ResourceWithChildren + : public QResource + { + public: + ResourceWithChildren (const QString &path) : QResource (path) { } + using QResource::children; + }; + +} + +void MacroCollection::scan (const std::string &path) +{ + if (tl::verbosity () >= 20) { + tl::info << "Scanning macro path " << path << " (readonly=" << m_readonly << ")"; + } + + if (! path.empty () && path[0] == ':') { + + ResourceWithChildren res (tl::to_qstring (path)); + QStringList children = res.children (); + children.sort (); + + for (QStringList::const_iterator c = children.begin (); c != children.end (); ++c) { + + std::string url = path + "/" + tl::to_string (*c); + QResource res (tl::to_qstring (url)); + if (res.size () > 0) { + + QByteArray data; +#if QT_VERSION >= 0x60000 + if (res.compressionAlgorithm () == QResource::ZlibCompression) { +#else + if (res.isCompressed ()) { +#endif + data = qUncompress ((const unsigned char *)res.data (), (int)res.size ()); + } else { + data = QByteArray ((const char *)res.data (), (int)res.size ()); + } + + try { + + Macro::Format format = Macro::NoFormat; + Macro::Interpreter interpreter = Macro::None; + std::string dsl_name; + bool autorun = false; + + if (Macro::format_from_suffix (tl::to_string (*c), interpreter, dsl_name, autorun, format)) { + + std::string n = tl::to_string (QFileInfo (*c).baseName ()); + + iterator mm = m_macros.find (n); + bool found = false; + while (mm != m_macros.end () && mm->first == n && ! found) { + if ((interpreter == Macro::None || mm->second->interpreter () == interpreter) && + (dsl_name.empty () || mm->second->dsl_interpreter () == dsl_name) && + mm->second->format () == format) { + found = true; + } + ++mm; + } + if (! found) { + Macro *m = m_macros.insert (std::make_pair (n, new Macro ()))->second; + m->set_interpreter (interpreter); + m->set_autorun_default (autorun); + m->set_autorun (autorun); + m->set_dsl_interpreter (dsl_name); + m->set_format (format); + m->set_name (n); + m->load_from_string (std::string (data.constData (), data.size ()), url); + m->set_readonly (m_readonly); + m->reset_modified (); + m->set_is_file (); + m->set_parent (this); + } + + } + + } catch (tl::Exception &ex) { + tl::error << "Reading " << url << ": " << ex.msg (); + } + + } + + } + + } else { + + QDir dir (tl::to_qstring (path)); + QStringList filters; + filters << QString::fromUtf8 ("*.lym"); + filters << QString::fromUtf8 ("*.txt"); + // TODO: should be either *.rb or *.python, depending on the category. + // Right now we rely on the folders not containing foreign files. + filters << QString::fromUtf8 ("*.rb"); + filters << QString::fromUtf8 ("*.py"); + + // add the suffixes in the DSL interpreter declarations + for (tl::Registrar::iterator cls = tl::Registrar::begin (); cls != tl::Registrar::end (); ++cls) { + if (! cls->suffix ().empty ()) { + filters << tl::to_qstring ("*." + cls->suffix ()); + } + } + + QStringList files = dir.entryList (filters, QDir::Files); + for (QStringList::ConstIterator f = files.begin (); f != files.end (); ++f) { + + std::unique_ptr new_macro; + + try { + + std::string n = tl::to_string (QFileInfo (*f).completeBaseName ()); + std::string mp = tl::to_string (dir.absoluteFilePath (*f)); + + Macro::Format format = Macro::NoFormat; + Macro::Interpreter interpreter = Macro::None; + std::string dsl_name; + bool autorun = false; + + if (Macro::format_from_suffix (tl::to_string (*f), interpreter, dsl_name, autorun, format)) { + + iterator mm = m_macros.find (n); + bool found = false; + while (mm != m_macros.end () && mm->first == n && ! found) { + if ((interpreter == Macro::None || mm->second->interpreter () == interpreter) && + (dsl_name.empty () || mm->second->dsl_interpreter () == dsl_name) && + mm->second->format () == format) { + found = true; + } + ++mm; + } + if (! found) { + Macro *m = new Macro (); + new_macro.reset (m); + m->set_format (format); + m->set_autorun_default (autorun); + m->set_autorun (autorun); + m->set_interpreter (interpreter); + m->set_dsl_interpreter (dsl_name); + m->set_name (n); + m->load_from (mp); + m->reset_modified (); + m->set_readonly (m_readonly); + m->set_parent (this); + } + + } + + if (new_macro.get ()) { + m_macros.insert (std::make_pair (n, new_macro.release ())); + } + + } catch (tl::Exception &ex) { + tl::error << "Reading " << tl::to_string (*f) << " in " << path << ": " << ex.msg (); + } + + } + + QStringList folders = dir.entryList (QDir::Dirs | QDir::NoDotAndDotDot); + for (QStringList::ConstIterator f = folders.begin (); f != folders.end (); ++f) { + + try { + + std::string n = tl::to_string (*f); + MacroCollection *&mc = m_folders.insert (std::make_pair (n, (MacroCollection *) 0)).first->second; + if (! mc) { + mc = new MacroCollection (); + mc->set_name (n); + mc->set_virtual_mode (NotVirtual); + bool ro = (m_readonly || ! QFileInfo (dir.filePath (*f)).isWritable ()); + mc->set_readonly (ro); + mc->scan (tl::to_string (dir.filePath (*f))); + mc->set_parent (this); + } + + } catch (tl::Exception &ex) { + tl::error << ex.msg (); + } + + } + + } +} + +void MacroCollection::clear () +{ + begin_changes (); + do_clear (); + on_changed (); +} + +void MacroCollection::erase (lym::Macro *mp) +{ + for (iterator m = m_macros.begin (); m != m_macros.end (); ++m) { + if (m->second == mp) { + begin_changes (); + on_macro_deleted_here (mp); + m_macros.erase (m); + delete mp; + on_changed (); + return; + } + } +} + +void MacroCollection::erase (lym::MacroCollection *mp) +{ + for (child_iterator f = m_folders.begin (); f != m_folders.end (); ++f) { + if (f->second == mp) { + begin_changes (); + on_child_deleted (mp); + m_folders.erase (f); + delete mp; + on_changed (); + return; + } + } +} + +void MacroCollection::erase (iterator i) +{ + begin_changes (); + on_macro_deleted_here (i->second); + delete i->second; + m_macros.erase (i); + on_changed (); +} + +void MacroCollection::erase (child_iterator i) +{ + begin_changes (); + on_child_deleted (i->second); + delete i->second; + m_folders.erase (i); + on_changed (); +} + +void MacroCollection::save () +{ + for (child_iterator f = m_folders.begin (); f != m_folders.end (); ++f) { + f->second->save (); + } + + for (iterator m = m_macros.begin (); m != m_macros.end (); ++m) { + if (m->second->is_modified () && ! m->second->is_readonly () && ! m->second->path ().empty ()) { + try { + m->second->save (); + } catch (tl::Exception &ex) { + tl::error << ex.msg (); + } + } + } +} + +bool MacroCollection::rename (const std::string &n) +{ + if (tl::verbosity () >= 20) { + tl::info << "Renaming macro folder " << path () << " to " << n; + } + QFile f (tl::to_qstring (path ())); + begin_changes (); + if (! f.rename (QFileInfo (QDir (tl::to_qstring (mp_parent->path ())), tl::to_qstring (n)).filePath ())) { + on_changed (); + return false; + } else { + m_path = n; + on_changed (); + return true; + } +} + +lym::MacroCollection *MacroCollection::create_folder (const char *prefix, bool mkdir) +{ + std::string name; + int n = 0; + do { + name = (prefix ? prefix : "new_folder"); + if (n > 0) { + name += "_" + tl::to_string (n); + } + if (m_folders.find (name) == m_folders.end ()) { + break; + } + ++n; + } while (true); + + if (mkdir && ! QDir (tl::to_qstring (path ())).mkdir (tl::to_qstring (name))) { + return 0; + } + + begin_changes (); + + lym::MacroCollection *m = m_folders.insert (std::make_pair (name, new lym::MacroCollection ())).first->second; + m->set_virtual_mode (NotVirtual); + m->set_name (name); + m->set_parent (this); + + on_changed (); + + return m; +} + +lym::Macro *MacroCollection::create (const char *prefix, Macro::Format format) +{ + std::string name; + int n = 0; + do { + name = (prefix ? prefix : "new_macro"); + if (n > 0) { + name += "_" + tl::to_string (n); + } + if (! macro_by_name (name, format)) { + break; + } + ++n; + } while (true); + + begin_changes (); + + lym::Macro *m = m_macros.insert (std::make_pair (name, new lym::Macro ()))->second; + m->set_name (name); + m->set_parent (this); + + on_changed (); + + return m; +} + +void MacroCollection::add_unspecific (lym::Macro *m) +{ + begin_changes (); + m_macros.insert (std::make_pair (m->name (), m)); + m->set_parent (this); + on_changed (); +} + +bool MacroCollection::add (lym::Macro *m) +{ + QDir d (tl::to_qstring (path ())); + QDir dd = QFileInfo (tl::to_qstring (m->path ())).dir (); + + if (d == dd) { + + begin_changes (); + m_macros.insert (std::make_pair (m->name (), m)); + m->set_parent (this); + on_changed (); + return true; + + } else { + + for (child_iterator c = begin_children (); c != end_children (); ++c) { + if (c->second->add (m)) { + return true; + } + } + + // try to detect new child folders. If that is the case, create that folder and add + // the macro there. + QDir dm (tl::to_qstring (m->dir ())); + while (true) { + + std::string folder_name = tl::to_string (dm.dirName ()); + if (! dm.cdUp ()) { + break; + } + + if (dm == d) { + begin_changes (); + lym::MacroCollection *mc = m_folders.insert (std::make_pair (folder_name, new MacroCollection ())).first->second; + mc->set_virtual_mode (NotVirtual); + mc->set_parent (this); + on_changed (); + return mc->add (m); + } + + } + + } + + return false; +} + +bool MacroCollection::del () +{ + if (tl::verbosity () >= 20) { + tl::info << "Deleting macro folder " << path (); + } + return QDir ().rmdir (tl::to_qstring (path ())); +} + +void MacroCollection::rename_macro (Macro *macro, const std::string &new_name) +{ + iterator m = m_macros.find (macro->name ()); + while (m != m_macros.end () && m->first == macro->name ()) { + if (m->second == macro) { + m_macros.erase (m); + m_macros.insert (std::make_pair (new_name, macro)); + return; + } + ++m; + } +} + +lym::Macro *MacroCollection::find_macro (const std::string &path) +{ + for (iterator m = begin (); m != end (); ++m) { + if (m->second->path () == path) { + return m->second; + } + } + + for (child_iterator mc = begin_children (); mc != end_children (); ++mc) { + lym::Macro *macro = mc->second->find_macro (path); + if (macro) { + return macro; + } + } + + return 0; +} + +MacroCollection &MacroCollection::root () +{ + return ms_root; +} + +static bool sync_macros (lym::MacroCollection *current, lym::MacroCollection *actual, bool safe) +{ + bool ret = false; + + if (actual) { + current->make_readonly (actual->is_readonly ()); + } + + std::vector folders_to_delete; + + for (lym::MacroCollection::child_iterator m = current->begin_children (); m != current->end_children (); ++m) { + lym::MacroCollection *cm = actual ? actual->folder_by_name (m->first) : 0; + if (! cm) { + folders_to_delete.push_back (m->second); + } + } + + if (actual) { + for (lym::MacroCollection::child_iterator m = actual->begin_children (); m != actual->end_children (); ++m) { + lym::MacroCollection *cm = current->folder_by_name (m->first); + if (! cm) { + cm = current->create_folder (m->first.c_str (), false); + ret = true; + } + if (sync_macros(cm, m->second, safe)) { + ret = true; + } + } + } + + // delete folders which do no longer exist + for (std::vector::iterator m = folders_to_delete.begin (); m != folders_to_delete.end (); ++m) { + ret = true; + sync_macros (*m, 0, safe); + current->erase (*m); + } + + std::vector macros_to_delete; + + for (lym::MacroCollection::iterator m = current->begin (); m != current->end (); ++m) { + lym::Macro *cm = actual ? actual->macro_by_name (m->first, m->second->format ()) : 0; + if (! cm) { + macros_to_delete.push_back (m->second); + } + } + + if (actual) { + for (lym::MacroCollection::iterator m = actual->begin (); m != actual->end (); ++m) { + lym::Macro *cm = current->macro_by_name (m->first, m->second->format ()); + if (cm) { + if (*cm != *m->second && (! safe || ! cm->is_modified ())) { + cm->assign (*m->second); + } + cm->set_readonly (m->second->is_readonly ()); + } else { + cm = current->create (m->first.c_str (), m->second->format ()); + cm->assign (*m->second); + cm->set_readonly (m->second->is_readonly ()); + ret = true; + } + } + } + + // erase macros from collection which are no longer used + for (std::vector::const_iterator m = macros_to_delete.begin (); m != macros_to_delete.end (); ++m) { + current->erase (*m); + ret = true; + } + + return ret; +} + +void MacroCollection::reload (bool safe) +{ + // create a new collection and synchronize + + lym::MacroCollection new_collection; + for (lym::MacroCollection::child_iterator c = begin_children (); c != end_children (); ++c) { + new_collection.add_folder (c->second->description (), c->second->path (), c->second->category (), c->second->is_readonly (), false /* don't force to create */); + } + + // and synchronize current with the actual one + sync_macros (this, &new_collection, safe); +} + +static bool has_autorun_for (const lym::MacroCollection &collection, bool early) +{ + for (lym::MacroCollection::const_child_iterator c = collection.begin_children (); c != collection.end_children (); ++c) { + if (has_autorun_for (*c->second, early)) { + return true; + } + } + + for (lym::MacroCollection::const_iterator c = collection.begin (); c != collection.end (); ++c) { + if ((early && c->second->is_autorun_early ()) || (!early && c->second->is_autorun () && !c->second->is_autorun_early ())) { + return true; + } + } + + return false; +} + +bool MacroCollection::has_autorun () const +{ + return has_autorun_for (*this, false); +} + +bool MacroCollection::has_autorun_early () const +{ + return has_autorun_for (*this, true); +} + +static int collect_priority (lym::MacroCollection &collection, bool early, int from_prio) +{ + int p = -1; + + for (lym::MacroCollection::child_iterator c = collection.begin_children (); c != collection.end_children (); ++c) { + int pp = collect_priority (*c->second, early, from_prio); + if (pp >= from_prio && (p < 0 || pp < p)) { + p = pp; + } + } + + for (lym::MacroCollection::iterator c = collection.begin (); c != collection.end (); ++c) { + if (c->second->can_run () && ((early && c->second->is_autorun_early ()) || (!early && c->second->is_autorun () && !c->second->is_autorun_early ()))) { + int pp = c->second->priority (); + if (pp >= from_prio && (p < 0 || pp < p)) { + p = pp; + } + } + } + + return p; +} + +static void autorun_for_prio (lym::MacroCollection &collection, bool early, std::set *executed_already, int prio) +{ + for (lym::MacroCollection::child_iterator c = collection.begin_children (); c != collection.end_children (); ++c) { + autorun_for_prio (*c->second, early, executed_already, prio); + } + + for (lym::MacroCollection::iterator c = collection.begin (); c != collection.end (); ++c) { + + if (c->second->priority () == prio && c->second->can_run () && ((early && c->second->is_autorun_early ()) || (!early && c->second->is_autorun () && !c->second->is_autorun_early ()))) { + + if (!executed_already || executed_already->find (c->second->path ()) == executed_already->end ()) { + + BEGIN_PROTECTED_SILENT + c->second->run (); + c->second->install_doc (); + END_PROTECTED_SILENT + + if (executed_already) { + executed_already->insert (c->second->path ()); + } + + } + + } + + } +} + +static void autorun_for (lym::MacroCollection &collection, bool early, std::set *executed_already) +{ + int prio = 0; + while (true) { + int p = collect_priority (collection, early, prio); + if (p < prio) { + break; + } + autorun_for_prio (collection, early, executed_already, p); + prio = p + 1; + } +} + +void MacroCollection::autorun (std::set *already_executed) +{ + autorun_for (*this, false, already_executed); +} + +void MacroCollection::autorun_early (std::set *already_executed) +{ + autorun_for (*this, true, already_executed); +} + +void MacroCollection::dump (int l) +{ + for (int i = 0; i < l; ++i) { printf (" "); } + printf ("----\n"); + for (int i = 0; i < l; ++i) { printf (" "); } + printf ("Collection: %s\n", name ().c_str ()); + for (int i = 0; i < l; ++i) { printf (" "); } + printf ("Collection-path: %s\n", path ().c_str ()); + for (int i = 0; i < l; ++i) { printf (" "); } + printf ("Collection-description: %s\n", description ().c_str ()); + for (int i = 0; i < l; ++i) { printf (" "); } + printf("Collection-readonly: %d\n", is_readonly ()); + printf ("\n"); + + for (iterator m = begin (); m != end (); ++m) { + for (int i = 0; i < l; ++i) { printf (" "); } + printf("Name: %s%s\n", m->second->name ().c_str (), m->second->is_modified() ? "*" : ""); + for (int i = 0; i < l; ++i) { printf (" "); } + printf(" Path: %s\n", m->second->path ().c_str ()); + for (int i = 0; i < l; ++i) { printf (" "); } + printf(" Readonly: %d\n", m->second->is_readonly ()); + for (int i = 0; i < l; ++i) { printf (" "); } + printf(" Autorun: %d\n", m->second->is_autorun ()); + for (int i = 0; i < l; ++i) { printf (" "); } + printf(" Autorun-early: %d\n", m->second->is_autorun_early ()); + for (int i = 0; i < l; ++i) { printf (" "); } + printf(" Description: %s\n", m->second->description ().c_str ()); + } + + for (child_iterator m = begin_children (); m != end_children (); ++m) { + m->second->dump (l + 1); + } +} + +} + +#endif diff --git a/src/lym/lym/lymMacroCollection.h b/src/lym/lym/lymMacroCollection.h new file mode 100644 index 000000000..9df9f3d87 --- /dev/null +++ b/src/lym/lym/lymMacroCollection.h @@ -0,0 +1,594 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 + +*/ + + +#ifndef HDR_lymMacroCollection +#define HDR_lymMacroCollection + +#include "lymCommon.h" +#include "lymMacro.h" + +#if defined(HAVE_QT) + +#include +#include +#include + +#include + +namespace lym +{ + +/** + * @brief Represents a collection of macros + * + * A collection is representing a set of macros, usually associated with + * a folder containing *.lym, *.rb or other script files. + */ +class LYM_PUBLIC MacroCollection + : public QObject +{ +Q_OBJECT + +public: + typedef std::multimap ::iterator iterator; + typedef std::multimap ::const_iterator const_iterator; + typedef std::map ::iterator child_iterator; + typedef std::map ::const_iterator const_child_iterator; + + /** + * @brief Some constants for virtual_mode + */ + enum FolderType { + NotVirtual = 0, + ProjectFolder = 1, + TechFolder = 2, + SaltFolder = 3 + }; + + /** + * @brief Constructor + * + * The default constructor create + */ + MacroCollection (); + + /** + * @brief Destructor + */ + ~MacroCollection (); + + /** + * @brief Add a folder (will also scan the folder) + * + * @return A pointer to the new collection if successful + * + * If force_create is true (the default), the folder will be created if it does not + * exist yet. On error, 0 is returned. + */ + MacroCollection *add_folder (const std::string &description, const std::string &path, const std::string &category, bool readonly, bool force_create = true); + + /** + * @brief Gets the category tag of the collection + * + * A category tag can be used to categorize the collections. For example, DRC categories are handled differently + * from the other categories. + */ + const std::string &category () const + { + return m_category; + } + + /** + * @brief Sets the category tags + */ + void set_category (const std::string &d) + { + m_category = d; + } + + /** + * @brief Collect all Macro and MacroCollection objects inside a tree starting from this collection + */ + void collect_used_nodes(std::set ¯os, std::set ¯o_collections); + + /** + * @brief Saves all macros in the collection + * + * Saves only those macros that have is_modified and whose path is set. + */ + void save (); + + /** + * @brief Delete the original folder (the directory behind the macro) + * + * Returns true if the folder was deleted successfully. + * The folder cannot be deleted if it contains any files, also some that are not listed because + * they don't end with .lym, .rb or similar. + */ + bool del (); + + /** + * @brief Gets the name of the collection + * + * For virtual collections this is the path. + */ + std::string name () const + { + return m_path; + } + + /** + * @brief Gets the path of the folder representing that collection + */ + std::string path () const; + + /** + * @brief Returns the parent of the macro collection + * + * Returns 0, if there is no parent of this collection (this is the root) + */ + lym::MacroCollection *parent () + { + return mp_parent; + } + + /** + * @brief Returns the parent of the macro collection (const version) + * + * Returns 0, if there is no parent of this collection (this is the root) + */ + const lym::MacroCollection *parent () const + { + return mp_parent; + } + + /** + * @brief Returns != 0, if the macro collection is a virtual node + * + * A virtual node does not correspond to a location in the file system. + * A virtual node cannot have macros but only children. + * The return value indicates the kind of virtual use. + */ + int virtual_mode () const + { + return m_virtual_mode; + } + + /** + * @brief Sets the virtual mode + * + * See virtual_mode for details about the virtual mode. + */ + void set_virtual_mode (int m) + { + m_virtual_mode = m; + } + + /** + * @brief Gets a value indicating whether the macro collection is readonly + */ + bool is_readonly () const + { + return m_readonly; + } + + /** + * @brief Sets a value indicating whether the macro is readonly + * In contrast to the private \set_readonly method, this version delivers a "changed" signal when + * the flag changed. + */ + void make_readonly (bool f); + + /** + * @brief Gets the macro collection's description text + */ + const std::string &description () const + { + return m_description; + } + + /** + * @brief Sets the description + */ + void set_description (const std::string &d) + { + m_description = d; + } + + /** + * @brief Gets the display string + */ + std::string display_string () const; + + /** + * @brief Rename a Macro + * + * Renames the macro. If the macro is a file, the file will be renamed as well. + * This method will return true, if the rename was successful. + */ + bool rename (const std::string &n); + + /** + * @brief Adds a macro to the collection + * + * If a macro with the name of the new macro already exists, it is replaced + * (like in the file system). This method will traverse the tree to find + * the location of the macro using the path information of the macro and insert + * the macro there. + * + * The collection becomes the owner of the object passed to this method + * + * @return true, if the macro could be added successfully. + */ + bool add (lym::Macro *m); + + /** + * @brief Adds a macro in an unspecific way + * + * "unspecific" means that the path is not looked up - the macro is + * added irregardless whether the path matches or not. + * This is a way to build macro collections without connection + * to some file system point. + */ + void add_unspecific (lym::Macro *m); + + /** + * @brief Empties the collection + * Note: only the unspecific on_changed event is generated. + */ + void clear (); + + /** + * @brief Erases the given macro from the list + * + * This does not remove the file but just remove the macro object. + * This will also delete the macro object. + */ + void erase (lym::Macro *m); + + /** + * @brief Erases the entry with the given iterator + */ + void erase (iterator i); + + /** + * @brief Erases the given macro collection from the list of child collections + * + * This does not remove the directory but just removes the macro collection object. + * This will also delete the macro collection object. + */ + void erase (lym::MacroCollection *m); + + /** + * @brief Erases the folder with the given iterator + */ + void erase (child_iterator i); + + /** + * @brief Creates a new macro in that collection (with a new name) + * + * If a name is given, it is used as a prefix to create a unique name for a macro with that format. + */ + lym::Macro *create (const char *name = 0, Macro::Format format = Macro::NoFormat); + + /** + * @brief Creates a new macro collection in that collection (with a new name) + * + * If a name is given, it is used as a prefix to create a unique name. + * This method will also create the directory for this folder. + * If not successful, it will return 0. + */ + lym::MacroCollection *create_folder (const char *name = 0, bool mkdir = true); + + /** + * @brief Gets the begin iterator of the macros + */ + iterator begin () + { + return m_macros.begin (); + } + + /** + * @brief Gets the end iterator of the macros + */ + iterator end () + { + return m_macros.end (); + } + + /** + * @brief Gets the begin iterator of the macros (const version) + */ + const_iterator begin () const + { + return m_macros.begin (); + } + + /** + * @brief Gets the end iterator of the macros (const version) + */ + const_iterator end () const + { + return m_macros.end (); + } + + /** + * @brief Gets the begin iterator of the folders + */ + child_iterator begin_children () + { + return m_folders.begin (); + } + + /** + * @brief Gets the end iterator of the folders + */ + child_iterator end_children () + { + return m_folders.end (); + } + + /** + * @brief Gets the begin iterator of the folders (const version) + */ + const_child_iterator begin_children () const + { + return m_folders.begin (); + } + + /** + * @brief Gets the end iterator of the folders (const version) + */ + const_child_iterator end_children () const + { + return m_folders.end (); + } + + /** + * @brief Gets a macro by name + * + * If no macro with that name exists, this method will return 0. + */ + Macro *macro_by_name (const std::string &name, Macro::Format format); + + /** + * @brief Gets a macro by name + * + * If no macro with that name exists, this method will return 0. + */ + const Macro *macro_by_name (const std::string &name, Macro::Format format) const; + + /** + * @brief Gets a folder by name + * + * If no folder with that name exists, this method will return 0. + */ + MacroCollection *folder_by_name (const std::string &name); + + /** + * @brief Gets a folder by name + * + * If no folder with that name exists, this method will return 0. + */ + const MacroCollection *folder_by_name (const std::string &name) const; + + /** + * @brief Finds a macro by path + * + * This method is called from the root collection and delivers the macro which + * matches the given path or 0. + */ + lym::Macro *find_macro (const std::string &path); + + /** + * @brief Returns true, if the collection has an autorun macro + */ + bool has_autorun () const; + + /** + * @brief Runs all macros marked with auto-run + */ + void autorun (std::set *already_executed = 0); + + /** + * @brief Returns true, if the collection has an early autorun macro + */ + bool has_autorun_early () const; + + /** + * @brief Runs all macros marked with early auto-run + */ + void autorun_early (std::set *already_executed = 0); + + /** + * @brief Redo the scan (will add new files or folders) + * + * This method must be called on root. + */ + void rescan (); + + /** + * @brief Reloads the macro collection + * + * This method is similar to rescan, but it will also remove folders and macros. + * In safe mode (safe = true), modified macros won't be overwritten. + */ + void reload (bool safe); + + /** + * @brief Gets the root of the macro hierarchy corresponding to the configuration space + */ + static MacroCollection &root (); + + /** + * @brief Dump the macro tree (for debugging) + */ + void dump (int l = 0); + +signals: + /** + * @brief This signal is sent when the collection changes + */ + void changed (); + + /** + * @brief This signal is sent by collection when a child collection is deleted in this collection + */ + void child_deleted (lym::MacroCollection *); + + /** + * @brief This signal is sent by the root object when a macro collection is deleted + */ + void macro_collection_deleted (lym::MacroCollection *); + + /** + * @brief This signal is sent by collection when a macro is deleted in this collection + */ + void macro_deleted_here (lym::Macro *); + + /** + * @brief This signal is sent by the root object when a macro is deleted + */ + void macro_deleted (lym::Macro *); + + /** + * @brief This signal is sent by the root object when a macro changes + * + * This signal is only emitted by the root, but it may originate from a + * macro inside the tree. + */ + void macro_changed (lym::Macro *); + + /** + * @brief This signal is sent by the root object when a macro collection changes + * + * This signal is only emitted by the root, but it may originate from a + * macro collection inside the tree. + */ + void macro_collection_changed (lym::MacroCollection *); + + /** + * @brief This signal is sent by the root object befor the macro collection changes + */ + void about_to_change (); + + /** + * @brief This signal is emitted from the collection root if the menu needs to be updated + */ + void menu_needs_update (); + +private: + friend class Macro; + + std::string m_path; + std::string m_description; + std::string m_category; + std::multimap m_macros; + std::map m_folders; + lym::MacroCollection *mp_parent; + int m_virtual_mode; + bool m_readonly; + + void on_child_deleted (MacroCollection *mc); + void on_macro_collection_deleted (MacroCollection *mc); + void on_macro_deleted_here (Macro *macro); + void on_macro_deleted (Macro *macro); + void on_macro_changed (Macro *macro); + void on_macro_collection_changed (MacroCollection *mc); + void on_changed (); + void on_menu_needs_update (); + + /** + * @brief Scans a folder creating the macro collection + */ + void scan (const std::string &path); + + void rename_macro (Macro *macro, const std::string &new_name); + + void begin_changes (); + + void set_name (const std::string &n) + { + m_path = n; + } + + void set_parent (lym::MacroCollection *parent) + { + mp_parent = parent; + } + + void set_readonly (bool f) + { + m_readonly = f; + } + + void do_clear (); + + // no copying + MacroCollection (const MacroCollection &d); + MacroCollection &operator= (const MacroCollection &d); +}; + +} + +#else // without QT: + +#include + +namespace lym +{ + +/** + * @brief Dummy implementation for Qt-less builds. + * + * This dummy implementation does not provide any services but acts as a dummy anchor + * for lym::Macro. + * + * Without Qt, the MacroCollection does not make much sense as there is no + * application specific file system without an Application object. + */ +class LYM_PUBLIC MacroCollection +{ +public: + MacroCollection () + { + // .. nothing yet .. + } + + std::string path () const + { + return std::string (); + } + + void rename_macro (lym::Macro *, const std::string &) + { + // .. nothing yet .. + } +}; + +} + +#endif + +#endif + diff --git a/src/lym/lym/lymMacroInterpreter.cc b/src/lym/lym/lymMacroInterpreter.cc index 77f437345..532bff93d 100644 --- a/src/lym/lym/lymMacroInterpreter.cc +++ b/src/lym/lym/lymMacroInterpreter.cc @@ -29,13 +29,15 @@ #include "tlClassRegistry.h" #include "tlInclude.h" +#include + namespace lym { tl::Executable * MacroInterpreter::executable (const lym::Macro *) const { - throw tl::Exception (tl::to_string (QObject::tr ("executable() implementation missing for DSL interpreter"))); + throw tl::Exception (tl::to_string (tr ("executable() implementation missing for DSL interpreter"))); } bool @@ -131,7 +133,7 @@ MacroInterpreter::execute_macro (const lym::Macro *macro) } } - throw tl::Exception (tl::to_string (QObject::tr ("No interpreter registered for DSL type '")) + macro->dsl_interpreter () + "'"); + throw tl::Exception (tl::to_string (tr ("No interpreter registered for DSL type '")) + macro->dsl_interpreter () + "'"); } std::string diff --git a/src/plugins/tools/view_25d/view_25d.pro b/src/plugins/tools/view_25d/view_25d.pro index 138f0890d..3fa284d8a 100644 --- a/src/plugins/tools/view_25d/view_25d.pro +++ b/src/plugins/tools/view_25d/view_25d.pro @@ -1,12 +1,16 @@ TEMPLATE = subdirs -contains(QT_CONFIG, opengl) { +!equals(HAVE_QT, "0") { + + contains(QT_CONFIG, opengl) { + + greaterThan(QT_MAJOR_VERSION, 4) { + SUBDIRS = lay_plugin unit_tests + } + + unit_tests.depends += lay_plugin - greaterThan(QT_MAJOR_VERSION, 4) { - SUBDIRS = lay_plugin unit_tests } - unit_tests.depends += lay_plugin - } diff --git a/src/tl/unit_tests/tlFileSystemWatcherTests.cc b/src/tl/unit_tests/tlFileSystemWatcherTests.cc index fda2a0157..da732dd60 100644 --- a/src/tl/unit_tests/tlFileSystemWatcherTests.cc +++ b/src/tl/unit_tests/tlFileSystemWatcherTests.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "tlFileSystemWatcher.h" #include "tlString.h" @@ -218,3 +219,4 @@ TEST(3) EXPECT_EQ (changed_spy.count (), 0); } +#endif From 177290f68069bb30d23b7c828d027e748624a467 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 24 Apr 2022 23:33:42 +0200 Subject: [PATCH 02/88] Some cleanup --- src/klayout.pro | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/klayout.pro b/src/klayout.pro index 9d584c003..e65f610a0 100644 --- a/src/klayout.pro +++ b/src/klayout.pro @@ -14,6 +14,10 @@ SUBDIRS = \ buddies \ lym \ +equals(HAVE_RUBY, "1") { + SUBDIRS += drc lvs +} + !equals(HAVE_QT, "0") { # TODO: make buddies able to build without Qt @@ -64,10 +68,10 @@ buddies.depends += plugins lym $$LANG_DEPENDS lym.depends += gsi $$LANG_DEPENDS equals(HAVE_RUBY, "1") { - SUBDIRS += drc lvs MAIN_DEPENDS += drc lvs drc.depends += rdb lym lvs.depends += drc + buddies.depends += drc lvs } !equals(HAVE_QT, "0") { @@ -102,8 +106,3 @@ equals(HAVE_RUBY, "1") { } unit_tests.depends += plugins $$MAIN_DEPENDS $$LANG_DEPENDS - -RESOURCES += \ - plugins/tools/import/lay_plugin/layResources.qrc \ - laybasic/laybasic/layResources.qrc - From 51e7c0a038b82944d543c9850910597bfc4e343c Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Mon, 25 Apr 2022 23:09:57 +0200 Subject: [PATCH 03/88] WIP --- src/ant/ant/antConfigPage.h | 1 + src/klayout.pro | 4 +- src/lay/lay/layMacroEditorSetupPage.h | 1 + src/lay/lay/layMainConfigPages.h | 1 + src/lay/lay/laySearchReplaceConfigPage.h | 1 + src/lay/lay/laySettingsForm.cc | 1 + src/laybasic/laybasic/gsiDeclLayLayers.cc | 1 + src/laybasic/laybasic/layAbstractMenu.cc | 1 + .../laybasic/layBrowseInstancesForm.h | 1 + src/laybasic/laybasic/layBrowseShapesForm.h | 1 + src/laybasic/laybasic/layCellView.h | 11 +- src/laybasic/laybasic/layColor.cc | 119 ++++ src/laybasic/laybasic/layColor.h | 95 +++ src/laybasic/laybasic/layColorPalette.cc | 6 +- .../laybasic/layConfigurationDialog.cc | 1 + src/laybasic/laybasic/layDispatcher.cc | 12 +- src/laybasic/laybasic/layDispatcher.h | 19 + src/laybasic/laybasic/layDisplayState.cc | 6 +- src/laybasic/laybasic/layDitherPattern.cc | 23 +- src/laybasic/laybasic/layDitherPattern.h | 25 +- src/laybasic/laybasic/layDrawing.h | 2 - src/laybasic/laybasic/layEditable.cc | 26 +- src/laybasic/laybasic/layEditable.h | 10 + src/laybasic/laybasic/layGridNet.h | 1 + .../laybasic/layLayoutViewConfigPages.h | 1 + src/laybasic/laybasic/layLineStyles.h | 21 +- src/laybasic/laybasic/layNetlistBrowser.h | 1 + src/laybasic/laybasic/layPlugin.h | 74 +-- src/laybasic/laybasic/layPluginConfigPage.cc | 33 ++ src/laybasic/laybasic/layPluginConfigPage.h | 82 +++ src/laybasic/laybasic/laySnap.h | 4 + src/laybasic/laybasic/layStream.h | 2 + src/laybasic/laybasic/layViewOp.h | 3 +- src/laybasic/laybasic/laybasic.pro | 558 +++++++++--------- src/laybasic/laybasic/rdbMarkerBrowser.h | 1 + src/laybasic/unit_tests/layColorTests.cc | 114 ++++ src/laybasic/unit_tests/unit_tests.pro | 1 + .../lay_plugin/layNetTracerConfig.h | 1 + 38 files changed, 906 insertions(+), 359 deletions(-) create mode 100644 src/laybasic/laybasic/layColor.cc create mode 100644 src/laybasic/laybasic/layColor.h create mode 100644 src/laybasic/laybasic/layPluginConfigPage.cc create mode 100644 src/laybasic/laybasic/layPluginConfigPage.h create mode 100644 src/laybasic/unit_tests/layColorTests.cc diff --git a/src/ant/ant/antConfigPage.h b/src/ant/ant/antConfigPage.h index a99d37b34..b032c254a 100644 --- a/src/ant/ant/antConfigPage.h +++ b/src/ant/ant/antConfigPage.h @@ -26,6 +26,7 @@ #define HDR_antConfigPage #include "layPlugin.h" +#include "layPluginConfigPage.h" #include "antTemplate.h" class QListWidgetItem; diff --git a/src/klayout.pro b/src/klayout.pro index e65f610a0..11e00817d 100644 --- a/src/klayout.pro +++ b/src/klayout.pro @@ -13,6 +13,7 @@ SUBDIRS = \ unit_tests \ buddies \ lym \ + laybasic \ equals(HAVE_RUBY, "1") { SUBDIRS += drc lvs @@ -23,7 +24,6 @@ equals(HAVE_RUBY, "1") { # TODO: make buddies able to build without Qt SUBDIRS += \ klayout_main \ - laybasic \ lay \ ant \ img \ @@ -66,6 +66,7 @@ plugins.depends += lib rdb db buddies.depends += plugins lym $$LANG_DEPENDS lym.depends += gsi $$LANG_DEPENDS +laybasic.depends += rdb lym equals(HAVE_RUBY, "1") { MAIN_DEPENDS += drc lvs @@ -94,7 +95,6 @@ equals(HAVE_RUBY, "1") { plugins.depends += lay ant - laybasic.depends += rdb lym ant.depends += laybasic img.depends += laybasic edt.depends += laybasic diff --git a/src/lay/lay/layMacroEditorSetupPage.h b/src/lay/lay/layMacroEditorSetupPage.h index b8a693d7b..b6de86b0d 100644 --- a/src/lay/lay/layMacroEditorSetupPage.h +++ b/src/lay/lay/layMacroEditorSetupPage.h @@ -25,6 +25,7 @@ #define HDR_layMacroEditorSetupPage #include "layPlugin.h" +#include "layPluginConfigPage.h" #include "ui_MacroEditorSetupPage.h" namespace lay diff --git a/src/lay/lay/layMainConfigPages.h b/src/lay/lay/layMainConfigPages.h index 7b15fc78f..92d6fe97a 100644 --- a/src/lay/lay/layMainConfigPages.h +++ b/src/lay/lay/layMainConfigPages.h @@ -28,6 +28,7 @@ #include #include "layPlugin.h" +#include "layPluginConfigPage.h" #include diff --git a/src/lay/lay/laySearchReplaceConfigPage.h b/src/lay/lay/laySearchReplaceConfigPage.h index acf2e3d67..9a7889ae4 100644 --- a/src/lay/lay/laySearchReplaceConfigPage.h +++ b/src/lay/lay/laySearchReplaceConfigPage.h @@ -25,6 +25,7 @@ #define HDR_laySearchReplaceConfigPage #include "layPlugin.h" +#include "layPluginConfigPage.h" #include "laySearchReplaceDialog.h" #include "ui_SearchReplaceConfigPage.h" diff --git a/src/lay/lay/laySettingsForm.cc b/src/lay/lay/laySettingsForm.cc index 0b8f64e02..74bf43bc5 100644 --- a/src/lay/lay/laySettingsForm.cc +++ b/src/lay/lay/laySettingsForm.cc @@ -31,6 +31,7 @@ #include "layMainWindow.h" #include "layApplication.h" +#include "layPluginConfigPage.h" #include "tlExceptions.h" #include "tlLog.h" #include "dbHershey.h" diff --git a/src/laybasic/laybasic/gsiDeclLayLayers.cc b/src/laybasic/laybasic/gsiDeclLayLayers.cc index 8fc610bee..df088a76a 100644 --- a/src/laybasic/laybasic/gsiDeclLayLayers.cc +++ b/src/laybasic/laybasic/gsiDeclLayLayers.cc @@ -22,6 +22,7 @@ #include "gsiDecl.h" +#include "layLayerProperties.h" #include "layLayoutView.h" namespace gsi diff --git a/src/laybasic/laybasic/layAbstractMenu.cc b/src/laybasic/laybasic/layAbstractMenu.cc index 248e43bb5..61a91e89d 100644 --- a/src/laybasic/laybasic/layAbstractMenu.cc +++ b/src/laybasic/laybasic/layAbstractMenu.cc @@ -39,6 +39,7 @@ #include #include #include +#include #include diff --git a/src/laybasic/laybasic/layBrowseInstancesForm.h b/src/laybasic/laybasic/layBrowseInstancesForm.h index 7e7937dfc..ae4d5e2b0 100644 --- a/src/laybasic/laybasic/layBrowseInstancesForm.h +++ b/src/laybasic/laybasic/layBrowseInstancesForm.h @@ -28,6 +28,7 @@ #include "ui_BrowseInstancesConfigPage.h" #include "layLayoutView.h" +#include "layPluginConfigPage.h" #include "layBrowser.h" #include "layMarker.h" diff --git a/src/laybasic/laybasic/layBrowseShapesForm.h b/src/laybasic/laybasic/layBrowseShapesForm.h index d933f0520..d4c74afff 100644 --- a/src/laybasic/laybasic/layBrowseShapesForm.h +++ b/src/laybasic/laybasic/layBrowseShapesForm.h @@ -28,6 +28,7 @@ #include "ui_BrowseShapesConfigPage.h" #include "layLayoutView.h" +#include "layPluginConfigPage.h" #include "layBrowser.h" #include "layMarker.h" diff --git a/src/laybasic/laybasic/layCellView.h b/src/laybasic/laybasic/layCellView.h index 758decfaf..99c6c18d3 100644 --- a/src/laybasic/laybasic/layCellView.h +++ b/src/laybasic/laybasic/layCellView.h @@ -30,8 +30,6 @@ #include #include "tlObject.h" -#include "tlFileSystemWatcher.h" -#include "layTechnology.h" #include "dbLayout.h" #include "dbMetaInfo.h" #include "dbReader.h" @@ -40,6 +38,11 @@ #include "dbInstElement.h" #include "gsi.h" +#if defined(HAVE_QT) +# include "layTechnology.h" +# include "tlFileSystemWatcher.h" +#endif + namespace lay { @@ -287,10 +290,12 @@ public: */ void layout_changed (); +#if defined(HAVE_QT) /** * @brief Gets the file system watcher that delivers events when one of the layouts gets updated */ static tl::FileSystemWatcher &file_watcher (); +#endif private: db::Layout *mp_layout; @@ -305,7 +310,9 @@ private: void on_technology_changed (); static std::map ms_dict; +#if defined(HAVE_QT) static tl::FileSystemWatcher *mp_file_watcher; +#endif }; /** diff --git a/src/laybasic/laybasic/layColor.cc b/src/laybasic/laybasic/layColor.cc new file mode 100644 index 000000000..67e0c700e --- /dev/null +++ b/src/laybasic/laybasic/layColor.cc @@ -0,0 +1,119 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 "layColor.h" +#include "tlString.h" + +#include + +namespace lay +{ + +Color::Color () + : m_color (0) +{ + // .. nothing yet .. +} + +Color::Color (color_t color) + : m_color (color | 0xff000000) +{ + // .. nothing yet .. +} + +Color::Color (unsigned int r, unsigned int g, unsigned int b, unsigned int alpha) + : m_color ((b & 0xff) | ((g & 0xff) << 8) | ((r & 0xff) << 16) | ((alpha & 0xff) << 24)) +{ + // .. nothing yet .. +} + +Color::Color (const std::string &name) +{ + m_color = 0; + + tl::Extractor ex (name.c_str ()); + + unsigned int n = 0; + + ex.test ("#"); + while (! ex.at_end ()) { + char c = tolower (*ex.get ()); + if (c >= '0' && c <= '9') { + m_color <<= 4; + m_color |= (c - '0'); + ++n; + } else if (c >= 'a' && c <= 'f') { + m_color <<= 4; + m_color |= (c - 'a') + 10; + ++n; + } + ++ex; + } + + if (n == 0) { + m_color = 0; + } else if (n <= 3) { + m_color = ((m_color & 0xf) * 0x11) | ((m_color & 0xf0) * 0x110) | ((m_color & 0xf00) * 0x1100) | 0xff000000; + } else if (n <= 4) { + m_color = ((m_color & 0xf) * 0x11) | ((m_color & 0xf0) * 0x110) | ((m_color & 0xf00) * 0x1100) | ((m_color & 0xf000) * 0x11000); + } else if (n <= 6) { + m_color |= 0xff000000; + } +} + +std::string +Color::to_string () const +{ + if (! is_valid ()) { + + return std::string (); + + } else { + + unsigned int n = 8; + if ((m_color & 0xff000000) == 0xff000000) { + n = 6; + } + + uint32_t c = m_color; + char s [10]; + s[n + 1] = 0; + s[0] = '#'; + while (n > 0) { + s [n] = "0123456789abcdef" [c & 0xf]; + c >>= 4; + --n; + } + + return std::string (s); + + } +} + +bool +Color::is_valid () const +{ + return (m_color & 0xff000000) != 0; +} + +} diff --git a/src/laybasic/laybasic/layColor.h b/src/laybasic/laybasic/layColor.h new file mode 100644 index 000000000..836252fff --- /dev/null +++ b/src/laybasic/laybasic/layColor.h @@ -0,0 +1,95 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 + +*/ + + +#ifndef HDR_layColor +#define HDR_layColor + +#include "laybasicCommon.h" + +#include +#include + +namespace lay +{ + +/** + * @brief The basic color type for a RGB triplet + */ +typedef uint32_t color_t; + +/** + * @brief A wrapper for a color value + * + * This class is a replacement for QColor. It offers invalid color values and + * string conversion. + */ +class LAYBASIC_PUBLIC Color +{ +public: + /** + * @brief Default constructor - creates an invalid color + */ + Color (); + + /** + * @brief Creates a color from a RGB triplet + */ + Color (color_t color); + + /** + * @brief Creates a color from a RGB triplet and alpha value + * + * An alpha value of 0 generates an invalid color. + */ + Color (unsigned int r, unsigned int g, unsigned int b, unsigned int alpha = 0xff); + + /** + * @brief Creates a color value from a string + */ + Color (const std::string &name); + + /** + * @brief Gets the string value from a color + */ + std::string to_string () const; + + /** + * @brief Gets a value indicating whether the color is valid + */ + bool is_valid () const; + + /** + * @brief Gets the RGB triplet + */ + color_t rgb () const + { + return m_color; + } + +private: + color_t m_color; +}; + +} + +#endif diff --git a/src/laybasic/laybasic/layColorPalette.cc b/src/laybasic/laybasic/layColorPalette.cc index 7c5ad2bcd..e24cb73c9 100644 --- a/src/laybasic/laybasic/layColorPalette.cc +++ b/src/laybasic/laybasic/layColorPalette.cc @@ -232,16 +232,16 @@ ColorPalette::from_string (const std::string &s, bool simple) } if (! x.at_end ()) { - throw tl::Exception (tl::sprintf (tl::to_string (QObject::tr ("unexpected characters: %s")), x.skip ())); + throw tl::Exception (tl::sprintf (tl::to_string (tr ("unexpected characters: %s")), x.skip ())); } if (! simple && (colors () == 0 || luminous_colors () == 0)) { - throw tl::Exception (tl::to_string (QObject::tr ("invalid palette - no colors and/or default colors"))); + throw tl::Exception (tl::to_string (tr ("invalid palette - no colors and/or default colors"))); } } catch (std::exception &ex) { // reformat error message - throw tl::Exception (tl::sprintf (tl::to_string (QObject::tr ("Color palette string format error: %s")), ex.what ())); + throw tl::Exception (tl::sprintf (tl::to_string (tr ("Color palette string format error: %s")), ex.what ())); } } diff --git a/src/laybasic/laybasic/layConfigurationDialog.cc b/src/laybasic/laybasic/layConfigurationDialog.cc index 63d9edeb5..6a10774ac 100644 --- a/src/laybasic/laybasic/layConfigurationDialog.cc +++ b/src/laybasic/laybasic/layConfigurationDialog.cc @@ -28,6 +28,7 @@ #include "ui_ConfigurationDialog.h" #include "layConfigurationDialog.h" #include "layPlugin.h" +#include "layPluginConfigPage.h" #include "layDispatcher.h" #include "tlLog.h" diff --git a/src/laybasic/laybasic/layDispatcher.cc b/src/laybasic/laybasic/layDispatcher.cc index 8f1280b08..dce1ec93b 100644 --- a/src/laybasic/laybasic/layDispatcher.cc +++ b/src/laybasic/laybasic/layDispatcher.cc @@ -36,7 +36,9 @@ static Dispatcher *ms_dispatcher_instance = 0; Dispatcher::Dispatcher (Plugin *parent, bool standalone) : Plugin (parent, standalone), +#if defined(HAVE_QT) mp_menu_parent_widget (0), +#endif mp_delegate (0) { if (! parent && ! ms_dispatcher_instance) { @@ -44,6 +46,7 @@ Dispatcher::Dispatcher (Plugin *parent, bool standalone) } } +#if defined(HAVE_QT) Dispatcher::Dispatcher (QWidget *menu_parent_widget, Plugin *parent, bool standalone) : Plugin (parent, standalone), mp_menu_parent_widget (menu_parent_widget), @@ -56,10 +59,13 @@ Dispatcher::Dispatcher (QWidget *menu_parent_widget, Plugin *parent, bool standa ms_dispatcher_instance = this; } } +#endif Dispatcher::Dispatcher (DispatcherDelegate *delegate, Plugin *parent, bool standalone) : Plugin (parent, standalone), +#if defined(HAVE_QT) mp_menu_parent_widget (0), +#endif mp_delegate (delegate) { if (! parent && ! ms_dispatcher_instance) { @@ -67,6 +73,7 @@ Dispatcher::Dispatcher (DispatcherDelegate *delegate, Plugin *parent, bool stand } } +#if defined(HAVE_QT) Dispatcher::Dispatcher (QWidget *menu_parent_widget, DispatcherDelegate *delegate, Plugin *parent, bool standalone) : Plugin (parent, standalone), mp_menu_parent_widget (menu_parent_widget), @@ -79,6 +86,7 @@ Dispatcher::Dispatcher (QWidget *menu_parent_widget, DispatcherDelegate *delegat ms_dispatcher_instance = this; } } +#endif Dispatcher::~Dispatcher () { @@ -90,12 +98,14 @@ Dispatcher::~Dispatcher () bool Dispatcher::configure (const std::string &name, const std::string &value) { +#if defined(HAVE_QT) if (mp_menu) { std::vector ca = mp_menu->configure_actions (name); for (std::vector::const_iterator a = ca.begin (); a != ca.end (); ++a) { (*a)->configure (value); } } +#endif if (mp_delegate) { return mp_delegate->configure (name, value); @@ -264,7 +274,7 @@ Dispatcher::read_config (const std::string &config_file) try { config_structure (this).parse (*file, *this); } catch (tl::Exception &ex) { - std::string msg = tl::to_string (QObject::tr ("Problem reading config file ")) + config_file + ": " + ex.msg (); + std::string msg = tl::to_string (tr ("Problem reading config file ")) + config_file + ": " + ex.msg (); throw tl::Exception (msg); } diff --git a/src/laybasic/laybasic/layDispatcher.h b/src/laybasic/laybasic/layDispatcher.h index 777092aad..703b4eec0 100644 --- a/src/laybasic/laybasic/layDispatcher.h +++ b/src/laybasic/laybasic/layDispatcher.h @@ -34,6 +34,10 @@ #include #include +#if defined(HAVE_QT) +class QWidget; +#endif + namespace lay { @@ -117,6 +121,7 @@ public: */ Dispatcher (Plugin *parent = 0, bool standalone = false); +#if defined(HAVE_QT) /** * @brief The constructor * @@ -125,6 +130,7 @@ public: * @param standalone The standalone flag passed to the plugin constructor. */ Dispatcher (QWidget *menu_parent_widget, Plugin *parent = 0, bool standalone = false); +#endif /** * @brief The root constructor @@ -133,6 +139,7 @@ public: */ Dispatcher (DispatcherDelegate *delegate, Plugin *parent = 0, bool standalone = false); +#if defined(HAVE_QT) /** * @brief The root constructor * @@ -140,6 +147,7 @@ public: * @param delegate The notification receiver for dispatcher events */ Dispatcher (QWidget *menu_parent_widget, DispatcherDelegate *delegate, Plugin *parent = 0, bool standalone = false); +#endif /** * @brief Destructor @@ -216,6 +224,7 @@ public: } } +#if defined(HAVE_QT) /** * @brief Gets the parent widget */ @@ -238,6 +247,14 @@ public: { return (dispatcher () == this) ? mp_menu.get () : dispatcher ()->menu (); } +#else + + /** + * @brief Returns true, if the dispatcher supplies a user interface + */ + bool has_ui () { return false; } + +#endif protected: // capture the configuration events so we can change the value of the configuration actions @@ -248,8 +265,10 @@ private: Dispatcher (const Dispatcher &); Dispatcher &operator= (const Dispatcher &); +#if defined(HAVE_QT) std::unique_ptr mp_menu; QWidget *mp_menu_parent_widget; +#endif DispatcherDelegate *mp_delegate; }; diff --git a/src/laybasic/laybasic/layDisplayState.cc b/src/laybasic/laybasic/layDisplayState.cc index 2a06334cd..11faee3e7 100644 --- a/src/laybasic/laybasic/layDisplayState.cc +++ b/src/laybasic/laybasic/layDisplayState.cc @@ -190,7 +190,7 @@ DisplayState::cellview (unsigned int index, lay::LayoutHandle *layout_h) const cell_path.push_back (pci.second); valid_path = true; } else { - tl::warn << tl::to_string (QObject::tr ("Cellname cannot be reconstructed: ")) << *cn; + tl::warn << tl::to_string (tr ("Cellname cannot be reconstructed: ")) << *cn; valid_path = false; break; } @@ -215,8 +215,8 @@ DisplayState::cellview (unsigned int index, lay::LayoutHandle *layout_h) const pc = &layout_h->layout ().cell (ie.second.inst_ptr.cell_index ()); valid_path = true; } else { - tl::warn << tl::to_string (QObject::tr ("Specific instance cannot be reconstructed: instantiated cell is ")) << ci->cell_name - << tl::to_string (QObject::tr (", parent cell is ")) << layout_h->layout ().cell_name (pc->cell_index ()); + tl::warn << tl::to_string (tr ("Specific instance cannot be reconstructed: instantiated cell is ")) << ci->cell_name + << tl::to_string (tr (", parent cell is ")) << layout_h->layout ().cell_name (pc->cell_index ()); valid_path = false; } } diff --git a/src/laybasic/laybasic/layDitherPattern.cc b/src/laybasic/laybasic/layDitherPattern.cc index 0e24576bc..243f8a5e0 100644 --- a/src/laybasic/laybasic/layDitherPattern.cc +++ b/src/laybasic/laybasic/layDitherPattern.cc @@ -26,6 +26,7 @@ #include "tlAssert.h" #include +#include #include namespace lay @@ -555,6 +556,8 @@ DitherPatternInfo::operator< (const DitherPatternInfo &d) const return m_order_index < d.m_order_index; } +#if defined(HAVE_QT) + // TODO including a scaling algorithm in this formula, or give more resolution to the dither QBitmap DitherPatternInfo::get_bitmap (int width, int height) const @@ -593,6 +596,8 @@ DitherPatternInfo::get_bitmap (int width, int height) const return bitmap; } +#endif + void DitherPatternInfo::set_pattern (const uint32_t *pt, unsigned int w, unsigned int h) { @@ -771,8 +776,11 @@ struct ReplaceDitherPatternOp DitherPatternInfo m_old, m_new; }; -DitherPattern::DitherPattern () - : QObject (), db::Object (0) +DitherPattern::DitherPattern () : +#if defined(HAVE_QT) + QObject (), +#endif + db::Object (0) { for (unsigned int d = 0; d < sizeof (dither_strings) / sizeof (dither_strings [0]); d += 2) { m_pattern.push_back (DitherPatternInfo ()); @@ -786,8 +794,11 @@ DitherPattern::~DitherPattern () // .. nothing yet .. } -DitherPattern::DitherPattern (const DitherPattern &p) - : QObject (), db::Object (0) +DitherPattern::DitherPattern (const DitherPattern &p) : +#if defined(HAVE_QT) + QObject (), +#endif + db::Object (0) { m_pattern = p.m_pattern; } @@ -807,6 +818,7 @@ DitherPattern::operator= (const DitherPattern &p) return *this; } +#if defined(HAVE_QT) QBitmap DitherPattern::get_bitmap (unsigned int i, int width, int height) const { @@ -816,6 +828,7 @@ DitherPattern::get_bitmap (unsigned int i, int width, int height) const return m_pattern [1].get_bitmap (width, height); } } +#endif const DitherPatternInfo & DitherPattern::pattern (unsigned int i) const @@ -848,7 +861,9 @@ DitherPattern::replace_pattern (unsigned int i, const DitherPatternInfo &p) // if something has changed emit the signal if (chg) { +#if defined(HAVE_QT) emit changed (); +#endif } } diff --git a/src/laybasic/laybasic/layDitherPattern.h b/src/laybasic/laybasic/layDitherPattern.h index 5373c72d0..de1e88ca8 100644 --- a/src/laybasic/laybasic/layDitherPattern.h +++ b/src/laybasic/laybasic/layDitherPattern.h @@ -27,8 +27,10 @@ #include "laybasicCommon.h" -#include -#include +#if defined(HAVE_QT) +# include +# include +#endif #include "dbObject.h" @@ -126,6 +128,7 @@ public: m_order_index = oi; } +#if defined(HAVE_QT) /** * @brief Get a monochrome bitmap object for this pattern * @@ -133,6 +136,7 @@ public: * @param height The desired height (-1 for default) */ QBitmap get_bitmap (int width = -1, int height = -1) const; +#endif /** * @brief Gets the the dither pattern @@ -225,10 +229,15 @@ private: * replaced with a new pattern, except for the first pattern which * cannot be changed. */ -class LAYBASIC_PUBLIC DitherPattern - : public QObject, public db::Object +class LAYBASIC_PUBLIC DitherPattern : +#if defined(HAVE_QT) + public QObject, +#endif + public db::Object { +#if defined(HAVE_QT) Q_OBJECT +#endif public: typedef std::vector pattern_vector; @@ -272,8 +281,9 @@ public: return m_pattern != p.m_pattern; } +#if defined(HAVE_QT) /** - * @brief Get a monochrome bitmap object for this pattern + * @brief Gets a monochrome bitmap object for this pattern * * If the index is not valid, an empty bitmap is returned. * @@ -282,6 +292,7 @@ public: * @param height The desired height (-1 for default) */ QBitmap get_bitmap (unsigned int i, int width = -1, int height = -1) const; +#endif /** * @brief Deliver the pattern with the given index @@ -373,12 +384,14 @@ public: */ static const DitherPattern &default_pattern (); +#if defined(HAVE_QT) signals: /** * @brief This signal is emitted if a pattern is changed */ void changed (); - +#endif + private: std::vector m_pattern; }; diff --git a/src/laybasic/laybasic/layDrawing.h b/src/laybasic/laybasic/layDrawing.h index a52c71da1..6545ed3db 100644 --- a/src/laybasic/laybasic/layDrawing.h +++ b/src/laybasic/laybasic/layDrawing.h @@ -34,8 +34,6 @@ #include "layViewOp.h" #include "dbTrans.h" -#include - namespace lay { diff --git a/src/laybasic/laybasic/layEditable.cc b/src/laybasic/laybasic/layEditable.cc index a391c6845..c90cc7663 100644 --- a/src/laybasic/laybasic/layEditable.cc +++ b/src/laybasic/laybasic/layEditable.cc @@ -25,7 +25,9 @@ #include "dbClipboard.h" #include "tlAssert.h" -#include "layPropertiesDialog.h" +#if defined(HAVE_QT) +# include "layPropertiesDialog.h" +#endif #include #include @@ -72,25 +74,29 @@ Editable::~Editable () // Editables implementation Editables::Editables (db::Manager *manager) - : db::Object (manager), mp_properties_dialog (0), m_move_selection (false), m_any_move_operation (false) + : db::Object (manager), m_move_selection (false), m_any_move_operation (false) { - // .. nothing yet .. +#if defined(HAVE_QT) + mp_properties_dialog = 0; +#endif } Editables::~Editables () { cancel_edits (); +#if defined(HAVE_QT) if (mp_properties_dialog) { delete mp_properties_dialog; mp_properties_dialog = 0; } +#endif } void Editables::del (db::Transaction *transaction) { - std::unique_ptr trans_holder (transaction ? transaction : new db::Transaction (manager (), tl::to_string (QObject::tr ("Delete")))); + std::unique_ptr trans_holder (transaction ? transaction : new db::Transaction (manager (), tl::to_string (tr ("Delete")))); if (has_selection ()) { @@ -169,9 +175,9 @@ Editables::selection_catch_bbox () } void -Editables::transform (const db::DCplxTrans &tr, db::Transaction *transaction) +Editables::transform (const db::DCplxTrans &t, db::Transaction *transaction) { - std::unique_ptr trans_holder (transaction ? transaction : new db::Transaction (manager (), tl::to_string (QObject::tr ("Transform")))); + std::unique_ptr trans_holder (transaction ? transaction : new db::Transaction (manager (), tl::to_string (tr ("Transform")))); if (has_selection ()) { @@ -183,7 +189,7 @@ Editables::transform (const db::DCplxTrans &tr, db::Transaction *transaction) manager ()->queue (this, new db::Op ()); for (iterator e = begin (); e != end (); ++e) { - e->transform (tr); + e->transform (t); } } catch (...) { @@ -597,7 +603,7 @@ Editables::move_transform (const db::DPoint &p, db::DFTrans t, lay::angle_constr void Editables::end_move (const db::DPoint &p, lay::angle_constraint_type ac, db::Transaction *transaction) { - std::unique_ptr trans_holder (transaction ? transaction : new db::Transaction (manager (), tl::to_string (QObject::tr ("Move")))); + std::unique_ptr trans_holder (transaction ? transaction : new db::Transaction (manager (), tl::to_string (tr ("Move")))); if (m_any_move_operation) { @@ -660,10 +666,12 @@ Editables::edit_cancel () void Editables::cancel_edits () { +#if defined(HAVE_QT) // close the property dialog if (mp_properties_dialog) { mp_properties_dialog->hide (); } +#endif // cancel any edit operations for (iterator e = begin (); e != end (); ++e) { @@ -671,6 +679,7 @@ Editables::cancel_edits () } } +#if defined(HAVE_QT) void Editables::show_properties (QWidget *parent) { @@ -686,6 +695,7 @@ Editables::show_properties (QWidget *parent) mp_properties_dialog = new lay::PropertiesDialog (parent, manager (), this); mp_properties_dialog->show (); } +#endif } diff --git a/src/laybasic/laybasic/layEditable.h b/src/laybasic/laybasic/layEditable.h index f1f54f164..40721d5a0 100644 --- a/src/laybasic/laybasic/layEditable.h +++ b/src/laybasic/laybasic/layEditable.h @@ -37,14 +37,18 @@ #include #include +#if defined(HAVE_QT) class QWidget; +#endif namespace lay { class Editables; +#if defined(HAVE_QT) class PropertiesPage; class PropertiesDialog; +#endif /** * @brief The "editable" interface @@ -353,6 +357,7 @@ public: return false; } +#if defined(HAVE_QT) /** * @brief Create a "properties page" object * @@ -368,6 +373,7 @@ public: { return 0; } +#endif /** * @brief Destruction callback by the properties page @@ -584,10 +590,12 @@ public: return m_editables.end (); } +#if defined(HAVE_QT) /** * @brief The "show properties" operation */ void show_properties (QWidget *parent); +#endif /** * @brief An event triggered if the selection changed @@ -643,7 +651,9 @@ private: tl::shared_collection m_editables; std::set m_enabled; +#if defined(HAVE_QT) lay::PropertiesDialog *mp_properties_dialog; +#endif bool m_move_selection; bool m_any_move_operation; db::DBox m_last_selected_point; diff --git a/src/laybasic/laybasic/layGridNet.h b/src/laybasic/laybasic/layGridNet.h index 728eadf65..98063d9bd 100644 --- a/src/laybasic/laybasic/layGridNet.h +++ b/src/laybasic/laybasic/layGridNet.h @@ -26,6 +26,7 @@ #include "layViewObject.h" #include "layPlugin.h" +#include "layPluginConfigPage.h" #include "dbTypes.h" #include "dbBox.h" diff --git a/src/laybasic/laybasic/layLayoutViewConfigPages.h b/src/laybasic/laybasic/layLayoutViewConfigPages.h index 176e0e633..04eb8ec4c 100644 --- a/src/laybasic/laybasic/layLayoutViewConfigPages.h +++ b/src/laybasic/laybasic/layLayoutViewConfigPages.h @@ -25,6 +25,7 @@ #define HDR_layLayoutViewConfigPages #include "layPlugin.h" +#include "layPluginConfigPage.h" #include "layColorPalette.h" #include "layStipplePalette.h" #include "layLineStylePalette.h" diff --git a/src/laybasic/laybasic/layLineStyles.h b/src/laybasic/laybasic/layLineStyles.h index 5e506dfa5..2ffa00824 100644 --- a/src/laybasic/laybasic/layLineStyles.h +++ b/src/laybasic/laybasic/layLineStyles.h @@ -27,8 +27,10 @@ #include "laybasicCommon.h" -#include -#include +#if defined(HAVE_QT) +# include +# include +#endif #include "dbObject.h" @@ -141,6 +143,7 @@ public: return m_pattern; } +#if defined(HAVE_QT) /** * @brief Get a monochrome bitmap object for this pattern * @@ -148,6 +151,7 @@ public: * @param height The desired height (-1 for default) */ QBitmap get_bitmap (int width = -1, int height = -1) const; +#endif /** * @brief Replaces the pattern string @@ -215,10 +219,15 @@ private: * replaced with a new pattern, except for the first styles which * cannot be changed. */ -class LAYBASIC_PUBLIC LineStyles - : public QObject, public db::Object +class LAYBASIC_PUBLIC LineStyles : +#if defined(HAVE_QT) + public QObject, +#endif + public db::Object { +#if defined(HAVE_QT) Q_OBJECT +#endif public: typedef std::vector pattern_vector; @@ -352,12 +361,14 @@ public: */ static const LineStyles &default_style (); +#if defined(HAVE_QT) signals: /** * @brief This signal is emitted if a style is changed */ void changed (); - +#endif + private: std::vector m_styles; }; diff --git a/src/laybasic/laybasic/layNetlistBrowser.h b/src/laybasic/laybasic/layNetlistBrowser.h index 96b55874d..96f333ce7 100644 --- a/src/laybasic/laybasic/layNetlistBrowser.h +++ b/src/laybasic/laybasic/layNetlistBrowser.h @@ -25,6 +25,7 @@ #define HDR_layNetlistBrowser #include "layPlugin.h" +#include "layPluginConfigPage.h" #include "layColorPalette.h" #include "ui_NetlistBrowserConfigPage.h" #include "ui_NetlistBrowserConfigPage2.h" diff --git a/src/laybasic/laybasic/layPlugin.h b/src/laybasic/laybasic/layPlugin.h index 59b356d2f..8f634c0a9 100644 --- a/src/laybasic/laybasic/layPlugin.h +++ b/src/laybasic/laybasic/layPlugin.h @@ -26,13 +26,13 @@ #include "laybasicCommon.h" -#include - #include "tlString.h" #include "tlClassRegistry.h" #include "tlDeferredExecution.h" #include "gsiObject.h" -#include "layAbstractMenu.h" +#if defined(HAVE_QT) +# include "layAbstractMenu.h" +#endif #include #include @@ -49,53 +49,15 @@ namespace lay class Plugin; class Dispatcher; class LayoutView; -class Browser; class ViewService; class Editable; class Drawing; class TechnologyComponentProvider; +#if defined(HAVE_QT) +class Browser; class EditorOptionsPage; - -/** - * @brief The base class for configuration pages - * - * This interface defines some services the configuration page - * must provide (i.e. setup, commit) - */ -class LAYBASIC_PUBLIC ConfigPage - : public QFrame -{ -public: - ConfigPage (QWidget *parent) - : QFrame (parent) - { - // .. nothing else .. - } - - /** - * @brief Load the page - * - * The implementation is supposed to fetch the configuration from the - * Plugin object provided and load the widgets accordingly. - */ - virtual void setup (Dispatcher * /*root*/) - { - // the default implementation does nothing. - } - - /** - * @brief Commit the page - * - * The implementation is supposed to read the configuration (and - * throw exceptions if the configuration something is invalid) - * and commit the changes through - */ - virtual void commit (Dispatcher * /*root*/) - { - // the default implementation does nothing. - } - -}; +class ConfigPage; +#endif /** * @brief A menu entry declaration @@ -184,11 +146,15 @@ LAYBASIC_PUBLIC MenuEntry config_menu_item (const std::string &menu_name, const * mechanism (instantiate a tl::Registrar::Class * object). */ -class LAYBASIC_PUBLIC PluginDeclaration - : public QObject, +class LAYBASIC_PUBLIC PluginDeclaration : +#if defined(HAVE_QT) + public QObject, +#endif public gsi::ObjectBase { -Q_OBJECT +#if defined(HAVE_QT) +Q_OBJECT +#endif public: /** @@ -211,6 +177,7 @@ public: // the default implementation does not add any options } +#if defined(HAVE_QT) /** * @brief Fetch the configuration page for the configuration dialog * @@ -222,7 +189,7 @@ public: { return 0; } - + /** * @brief Fetch the configuration pages for the configuration dialog * @@ -235,6 +202,7 @@ public: { return std::vector > (); } +#endif /** * @brief The global configuration @@ -352,6 +320,7 @@ public: return false; } +#if defined(HAVE_QT) /** * @brief Gets the editor options pages * @@ -364,6 +333,7 @@ public: { // .. no pages in the default implementation .. } +#endif /** * @brief Tells if the plugin implements a "lay::ViewService" active mouse mode @@ -483,14 +453,18 @@ public: */ tl::Event editable_enabled_changed_event; +#if defined(HAVE_QT) private slots: void toggle_editable_enabled (); +#endif private: int m_id; +#if defined(HAVE_QT) tl::weak_ptr mp_editable_mode_action; tl::weak_ptr mp_mouse_mode_action; tl::weak_collection m_menu_actions; +#endif bool m_editable_enabled; }; @@ -730,6 +704,7 @@ public: // .. this implementation does nothing .. } +#if defined(HAVE_QT) /** * @brief Return the lay::Browser interface if this object has one * @@ -740,6 +715,7 @@ public: { return 0; } +#endif /** * @brief Return the lay::ViewService interface if this object has one diff --git a/src/laybasic/laybasic/layPluginConfigPage.cc b/src/laybasic/laybasic/layPluginConfigPage.cc new file mode 100644 index 000000000..680e76f01 --- /dev/null +++ b/src/laybasic/laybasic/layPluginConfigPage.cc @@ -0,0 +1,33 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 "laybasicCommon.h" + +#include "layPluginConfigPage.h" + +namespace lay +{ + +// .. nothing yet .. + +} diff --git a/src/laybasic/laybasic/layPluginConfigPage.h b/src/laybasic/laybasic/layPluginConfigPage.h new file mode 100644 index 000000000..e190ac15a --- /dev/null +++ b/src/laybasic/laybasic/layPluginConfigPage.h @@ -0,0 +1,82 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 + +*/ + + +#ifndef HDR_layPluginConfigPage +#define HDR_layPluginConfigPage + +#include "laybasicCommon.h" + +#include + +namespace lay +{ + +class Dispatcher; +class EditorOptionsPage; + +/** + * @brief The base class for configuration pages + * + * This interface defines some services the configuration page + * must provide (i.e. setup, commit) + */ +class LAYBASIC_PUBLIC ConfigPage + : public QFrame +{ +public: + ConfigPage (QWidget *parent) + : QFrame (parent) + { + // .. nothing else .. + } + + /** + * @brief Load the page + * + * The implementation is supposed to fetch the configuration from the + * Plugin object provided and load the widgets accordingly. + */ + virtual void setup (Dispatcher * /*root*/) + { + // the default implementation does nothing. + } + + /** + * @brief Commit the page + * + * The implementation is supposed to read the configuration (and + * throw exceptions if the configuration something is invalid) + * and commit the changes through + */ + virtual void commit (Dispatcher * /*root*/) + { + // the default implementation does nothing. + } + +}; + +} + +#endif + + diff --git a/src/laybasic/laybasic/laySnap.h b/src/laybasic/laybasic/laySnap.h index 506f19e60..c05eabda3 100644 --- a/src/laybasic/laybasic/laySnap.h +++ b/src/laybasic/laybasic/laySnap.h @@ -27,7 +27,9 @@ #include "laybasicCommon.h" +#if defined(HAVE_QT) #include +#endif #include #include @@ -244,6 +246,7 @@ namespace lay */ LAYBASIC_PUBLIC int draw_round (double x); +#if defined(HAVE_QT) /** * @brief rounding (and height-transformation) of a double point */ @@ -253,6 +256,7 @@ namespace lay * @brief rounding (and height-transformation) of a two-point vector */ LAYBASIC_PUBLIC std::pair draw_round (const db::DPoint &p1, const db::DPoint &p2, int h); +#endif /** * @brief rounding (and height-transformation) of a two-point vector diff --git a/src/laybasic/laybasic/layStream.h b/src/laybasic/laybasic/layStream.h index 333e86331..55d4fde00 100644 --- a/src/laybasic/laybasic/layStream.h +++ b/src/laybasic/laybasic/layStream.h @@ -31,6 +31,8 @@ #include "tlXMLWriter.h" #include "dbLoadLayoutOptions.h" +#include + namespace db { class StreamFormatDeclaration; diff --git a/src/laybasic/laybasic/layViewOp.h b/src/laybasic/laybasic/layViewOp.h index f9cf704c6..5527288c5 100644 --- a/src/laybasic/laybasic/layViewOp.h +++ b/src/laybasic/laybasic/layViewOp.h @@ -26,14 +26,13 @@ #define HDR_layViewOp #include "laybasicCommon.h" +#include "layColor.h" #include namespace lay { -typedef unsigned int color_t; - const unsigned int wordlen = 32; const unsigned int wordbits = 5; const unsigned int wordones = 0xffffffff; diff --git a/src/laybasic/laybasic/laybasic.pro b/src/laybasic/laybasic/laybasic.pro index ed2625d9d..5c370f207 100644 --- a/src/laybasic/laybasic/laybasic.pro +++ b/src/laybasic/laybasic/laybasic.pro @@ -6,67 +6,69 @@ include($$PWD/../../lib.pri) DEFINES += MAKE_LAYBASIC_LIBRARY -FORMS = \ - AlignCellOptionsDialog.ui \ - BookmarkManagementForm.ui \ - BrowseInstancesConfigPage.ui \ - BrowseInstancesForm.ui \ - BrowserDialog.ui \ - BrowserPanel.ui \ - BrowseShapesConfigPage.ui \ - BrowseShapesForm.ui \ - CellSelectionForm.ui \ - ClearLayerModeDialog.ui \ - ConfigurationDialog.ui \ - CopyCellModeDialog.ui \ - DeleteCellModeDialog.ui \ - DuplicateLayerDialog.ui \ - EditStipplesForm.ui \ - FlattenInstOptionsDialog.ui \ - GridNetConfigPage.ui \ - LayerMappingWidget.ui \ - LayerSourceDialog.ui \ - LayoutProperties.ui \ - LayoutViewConfigPage1.ui \ - LayoutViewConfigPage2a.ui \ - LayoutViewConfigPage2b.ui \ - LayoutViewConfigPage2c.ui \ - LayoutViewConfigPage2d.ui \ - LayoutViewConfigPage3a.ui \ - LayoutViewConfigPage3b.ui \ - LayoutViewConfigPage3c.ui \ - LayoutViewConfigPage3f.ui \ - LayoutViewConfigPage4.ui \ - LayoutViewConfigPage5.ui \ - LayoutViewConfigPage6.ui \ - LayoutViewConfigPage7.ui \ - LayoutViewConfigPage.ui \ - LibraryCellSelectionForm.ui \ - LoadLayoutOptionsDialog.ui \ - MarkerBrowserConfigPage2.ui \ - MarkerBrowserConfigPage.ui \ - MarkerBrowserDialog.ui \ - MarkerBrowserPage.ui \ - MarkerBrowserSnapshotView.ui \ - MoveOptionsDialog.ui \ - MoveToOptionsDialog.ui \ - NewCellPropertiesDialog.ui \ - NewLayerPropertiesDialog.ui \ - NewLayoutPropertiesDialog.ui \ - OpenLayoutModeDialog.ui \ - PropertiesDialog.ui \ - RenameCellDialog.ui \ - ReplaceCellOptionsDialog.ui \ - SaveLayoutOptionsDialog.ui \ - SaveLayoutAsOptionsDialog.ui \ - SelectStippleForm.ui \ - TipDialog.ui \ - UserPropertiesForm.ui \ - UserPropertiesEditForm.ui \ - SpecificLoadLayoutOptionsDialog.ui \ - SelectLineStyleForm.ui \ - LayoutViewConfigPage6a.ui \ - EditLineStylesForm.ui \ +!equals(HAVE_QT, "0") { + + FORMS = \ + AlignCellOptionsDialog.ui \ + BookmarkManagementForm.ui \ + BrowseInstancesConfigPage.ui \ + BrowseInstancesForm.ui \ + BrowserDialog.ui \ + BrowserPanel.ui \ + BrowseShapesConfigPage.ui \ + BrowseShapesForm.ui \ + CellSelectionForm.ui \ + ClearLayerModeDialog.ui \ + ConfigurationDialog.ui \ + CopyCellModeDialog.ui \ + DeleteCellModeDialog.ui \ + DuplicateLayerDialog.ui \ + EditStipplesForm.ui \ + FlattenInstOptionsDialog.ui \ + GridNetConfigPage.ui \ + LayerMappingWidget.ui \ + LayerSourceDialog.ui \ + LayoutProperties.ui \ + LayoutViewConfigPage1.ui \ + LayoutViewConfigPage2a.ui \ + LayoutViewConfigPage2b.ui \ + LayoutViewConfigPage2c.ui \ + LayoutViewConfigPage2d.ui \ + LayoutViewConfigPage3a.ui \ + LayoutViewConfigPage3b.ui \ + LayoutViewConfigPage3c.ui \ + LayoutViewConfigPage3f.ui \ + LayoutViewConfigPage4.ui \ + LayoutViewConfigPage5.ui \ + LayoutViewConfigPage6.ui \ + LayoutViewConfigPage7.ui \ + LayoutViewConfigPage.ui \ + LibraryCellSelectionForm.ui \ + LoadLayoutOptionsDialog.ui \ + MarkerBrowserConfigPage2.ui \ + MarkerBrowserConfigPage.ui \ + MarkerBrowserDialog.ui \ + MarkerBrowserPage.ui \ + MarkerBrowserSnapshotView.ui \ + MoveOptionsDialog.ui \ + MoveToOptionsDialog.ui \ + NewCellPropertiesDialog.ui \ + NewLayerPropertiesDialog.ui \ + NewLayoutPropertiesDialog.ui \ + OpenLayoutModeDialog.ui \ + PropertiesDialog.ui \ + RenameCellDialog.ui \ + ReplaceCellOptionsDialog.ui \ + SaveLayoutOptionsDialog.ui \ + SaveLayoutAsOptionsDialog.ui \ + SelectStippleForm.ui \ + TipDialog.ui \ + UserPropertiesForm.ui \ + UserPropertiesEditForm.ui \ + SpecificLoadLayoutOptionsDialog.ui \ + SelectLineStyleForm.ui \ + LayoutViewConfigPage6a.ui \ + EditLineStylesForm.ui \ NetlistBrowserPage.ui \ NetlistBrowserConfigPage.ui \ NetlistBrowserConfigPage2.ui \ @@ -74,231 +76,243 @@ FORMS = \ NetInfoDialog.ui \ NetExportDialog.ui \ SelectCellViewForm.ui \ - LayoutStatistics.ui + LayoutStatistics.ui \ -RESOURCES = \ + RESOURCES = \ laybasicResources.qrc \ - layLayoutStatistics.qrc + layLayoutStatistics.qrc \ -SOURCES = \ - gtf.cc \ - gsiDeclLayDialogs.cc \ - gsiDeclLayLayers.cc \ - gsiDeclLayLayoutView.cc \ - gsiDeclLayMarker.cc \ - gsiDeclLayMenu.cc \ - gsiDeclLayPlugin.cc \ - gsiDeclLayStream.cc \ - layAbstractMenu.cc \ - layAnnotationShapes.cc \ - layBitmap.cc \ - layBitmapRenderer.cc \ - layBitmapsToImage.cc \ - layBookmarkList.cc \ - layBookmarkManagementForm.cc \ - layBrowseInstancesForm.cc \ - layBrowser.cc \ - layBrowserDialog.cc \ - layBrowserPanel.cc \ - layBrowseShapesForm.cc \ - layBusy.cc \ - layCanvasPlane.cc \ - layCellSelectionForm.cc \ - layCellTreeModel.cc \ - layCellView.cc \ - layColorPalette.cc \ - layConfigurationDialog.cc \ - layConverters.cc \ - layCursor.cc \ - layDialogs.cc \ - layDisplayState.cc \ - layDitherPattern.cc \ - layDrawing.cc \ - layEditable.cc \ - layEditStipplesForm.cc \ - layEditStippleWidget.cc \ - layEditorOptionsFrame.cc \ - layEditorOptionsPage.cc \ - layEditorOptionsPages.cc \ - layEditorServiceBase.cc \ - layFileDialog.cc \ - layFinder.cc \ - layFixedFont.cc \ - layGridNet.cc \ - layHierarchyControlPanel.cc \ - layLayerControlPanel.cc \ - layLayerMappingWidget.cc \ - layLayerProperties.cc \ - layLayerToolbox.cc \ - layLayerTreeModel.cc \ - layLayoutCanvas.cc \ - layLayoutPropertiesForm.cc \ - layLayoutView.cc \ - layLayoutViewConfigPages.cc \ - layLoadLayoutOptionsDialog.cc \ - layMarker.cc \ - layMouseTracker.cc \ - layMove.cc \ - layObjectInstPath.cc \ - layParsedLayerSource.cc \ - layPlugin.cc \ - layProperties.cc \ - layPropertiesDialog.cc \ - layQtTools.cc \ - layRedrawLayerInfo.cc \ - layRedrawThreadCanvas.cc \ - layRedrawThread.cc \ - layRedrawThreadWorker.cc \ - layRenderer.cc \ - layRubberBox.cc \ - laySaveLayoutOptionsDialog.cc \ - laySelector.cc \ - laySelectStippleForm.cc \ - laySnap.cc \ - layStipplePalette.cc \ - layStream.cc \ - layTechnology.cc \ - layTipDialog.cc \ - layViewObject.cc \ - layViewOp.cc \ - layViewport.cc \ - layWidgets.cc \ - layZoomBox.cc \ - rdbInfoWidget.cc \ - rdbMarkerBrowser.cc \ - rdbMarkerBrowserDialog.cc \ - rdbMarkerBrowserPage.cc \ - layLineStyles.cc \ - laySelectLineStyleForm.cc \ - layLineStylePalette.cc \ - layEditLineStylesForm.cc \ - layEditLineStyleWidget.cc \ - layBackgroundAwareTreeStyle.cc \ + SOURCES = \ + gsiDeclLayDialogs.cc \ + gsiDeclLayLayoutView.cc \ + gsiDeclLayMarker.cc \ + gsiDeclLayMenu.cc \ + gsiDeclLayNetlistBrowserDialog.cc \ + gsiDeclLayPlugin.cc \ + gsiDeclLayStream.cc \ + gtf.cc \ + layAbstractMenu.cc \ + layBackgroundAwareTreeStyle.cc \ + layBitmapRenderer.cc \ + layBitmapsToImage.cc \ + layBookmarkList.cc \ + layBookmarkManagementForm.cc \ + layBookmarksView.cc \ + layBrowseInstancesForm.cc \ + layBrowseShapesForm.cc \ + layBrowser.cc \ + layBrowserDialog.cc \ + layBrowserPanel.cc \ + layBusy.cc \ + layCellSelectionForm.cc \ + layCellTreeModel.cc \ + layCellView.cc \ + layConfigurationDialog.cc \ + layConverters.cc \ + layCursor.cc \ + layDialogs.cc \ + layEditLineStyleWidget.cc \ + layEditLineStylesForm.cc \ + layEditStippleWidget.cc \ + layEditStipplesForm.cc \ + layEditorOptionsFrame.cc \ + layEditorOptionsPage.cc \ + layEditorOptionsPages.cc \ + layEditorServiceBase.cc \ + layFileDialog.cc \ + layGenericSyntaxHighlighter.cc \ + layGridNet.cc \ + layHierarchyControlPanel.cc \ + layIndexedNetlistModel.cc \ + layItemDelegates.cc \ + layLayerControlPanel.cc \ + layLayerMappingWidget.cc \ + layLayerToolbox.cc \ + layLayerTreeModel.cc \ + layLayoutCanvas.cc \ + layLayoutPropertiesForm.cc \ + layLayoutStatisticsForm.cc \ + layLayoutView.cc \ + layLayoutViewConfigPages.cc \ + layLayoutViewFunctions.cc \ + layLibrariesView.cc \ + layLoadLayoutOptionsDialog.cc \ + layNetExportDialog.cc \ + layNetInfoDialog.cc \ layNetlistBrowser.cc \ layNetlistBrowserDialog.cc \ - layNetlistBrowserPage.cc \ - layItemDelegates.cc \ - layNetInfoDialog.cc \ - layNetExportDialog.cc \ layNetlistBrowserModel.cc \ - layIndexedNetlistModel.cc \ - layNetlistCrossReferenceModel.cc \ + layNetlistBrowserPage.cc \ layNetlistBrowserTreeModel.cc \ - layLibrariesView.cc \ - layBookmarksView.cc \ - layGenericSyntaxHighlighter.cc \ - layDispatcher.cc \ + layNetlistCrossReferenceModel.cc \ + layPluginConfigPage.cc \ + layProperties.cc \ + layPropertiesDialog.cc \ + layQtTools.cc \ + laySaveLayoutOptionsDialog.cc \ laySelectCellViewForm.cc \ - layLayoutStatisticsForm.cc \ - gsiDeclLayNetlistBrowserDialog.cc \ - layLayoutViewFunctions.cc + laySelectLineStyleForm.cc \ + laySelectStippleForm.cc \ + laySelector.cc \ + layTechnology.cc \ + layTipDialog.cc \ + layWidgets.cc \ + layZoomBox.cc \ + rdbInfoWidget.cc \ + rdbMarkerBrowser.cc \ + rdbMarkerBrowserDialog.cc \ + rdbMarkerBrowserPage.cc \ -HEADERS = \ - gtf.h \ - layAbstractMenu.h \ - layAnnotationShapes.h \ - layBitmap.h \ - layBitmapRenderer.h \ - layBitmapsToImage.h \ - layBookmarkList.h \ - layBookmarkManagementForm.h \ - layBrowseInstancesForm.h \ - layBrowserDialog.h \ - layBrowser.h \ - layBrowserPanel.h \ - layBrowseShapesForm.h \ - layBusy.h \ - layCanvasPlane.h \ - layCellSelectionForm.h \ - layCellTreeModel.h \ - layCellView.h \ - layColorPalette.h \ - layConfigurationDialog.h \ - layConverters.h \ - layCursor.h \ - layDialogs.h \ - layDisplayState.h \ - layDitherPattern.h \ - layDrawing.h \ - layEditable.h \ - layEditStipplesForm.h \ - layEditStippleWidget.h \ - layEditorOptionsFrame.h \ - layEditorOptionsPage.h \ - layEditorOptionsPages.h \ - layEditorServiceBase.h \ - layFileDialog.h \ - layFinder.h \ - layFixedFont.h \ - layGridNet.h \ - layHierarchyControlPanel.h \ - layLayerControlPanel.h \ - layLayerMappingWidget.h \ - layLayerProperties.h \ - layLayerToolbox.h \ - layLayerTreeModel.h \ - layLayoutCanvas.h \ - layLayoutPropertiesForm.h \ - layLayoutViewConfigPages.h \ - layLayoutView.h \ - layLoadLayoutOptionsDialog.h \ - layMarker.h \ - layMouseTracker.h \ - layMove.h \ - layObjectInstPath.h \ - layParsedLayerSource.h \ - layPlugin.h \ - layPropertiesDialog.h \ - layProperties.h \ - layQtTools.h \ - layRedrawLayerInfo.h \ - layRedrawThreadCanvas.h \ - layRedrawThread.h \ - layRedrawThreadWorker.h \ - layRenderer.h \ - layRubberBox.h \ - laySaveLayoutOptionsDialog.h \ - laySelector.h \ - laySelectStippleForm.h \ - laySnap.h \ - layStipplePalette.h \ - layStream.h \ - layTechnology.h \ - layTipDialog.h \ - layViewObject.h \ - layViewOp.h \ - layViewport.h \ - layWidgets.h \ - layZoomBox.h \ - rdbInfoWidget.h \ - rdbMarkerBrowserDialog.h \ - rdbMarkerBrowser.h \ - rdbMarkerBrowserPage.h \ - layLineStyles.h \ - laySelectLineStyleForm.h \ - layLineStylePalette.h \ - layEditLineStylesForm.h \ - layEditLineStyleWidget.h \ - laybasicCommon.h \ - laybasicConfig.h \ - layBackgroundAwareTreeStyle.h \ + HEADERS = \ + gtf.h \ + layAbstractMenu.h \ + layBackgroundAwareTreeStyle.h \ + layBitmap.h \ + layBitmapRenderer.h \ + layBitmapsToImage.h \ + layBookmarkList.h \ + layBookmarkManagementForm.h \ + layBookmarksView.h \ + layBrowseInstancesForm.h \ + layBrowseShapesForm.h \ + layBrowser.h \ + layBrowserDialog.h \ + layBrowserPanel.h \ + layBusy.h \ + layCellSelectionForm.h \ + layCellTreeModel.h \ + layCellView.h \ + layConfigurationDialog.h \ + layConverters.h \ + layColor.h \ + layCursor.h \ + layDialogs.h \ + layEditLineStyleWidget.h \ + layEditLineStylesForm.h \ + layEditStippleWidget.h \ + layEditStipplesForm.h \ + layEditorOptionsFrame.h \ + layEditorOptionsPage.h \ + layEditorOptionsPages.h \ + layEditorServiceBase.h \ + layFileDialog.h \ + layGenericSyntaxHighlighter.h \ + layGridNet.h \ + layHierarchyControlPanel.h \ + layIndexedNetlistModel.h \ + layItemDelegates.h \ + layLayerControlPanel.h \ + layLayerMappingWidget.h \ + layLayerToolbox.h \ + layLayerTreeModel.h \ + layLayoutCanvas.h \ + layLayoutPropertiesForm.h \ + layLayoutStatisticsForm.h \ + layLayoutView.h \ + layLayoutViewConfigPages.h \ + layLayoutViewFunctions.h \ + layLibrariesView.h \ + layLoadLayoutOptionsDialog.h \ + layNetExportDialog.h \ + layNetInfoDialog.h \ layNetlistBrowser.h \ layNetlistBrowserDialog.h \ - layNetlistBrowserPage.h \ - layItemDelegates.h \ - layNetInfoDialog.h \ - layNetExportDialog.h \ layNetlistBrowserModel.h \ - layIndexedNetlistModel.h \ - layNetlistCrossReferenceModel.h \ + layNetlistBrowserPage.h \ layNetlistBrowserTreeModel.h \ - layLibrariesView.h \ - layBookmarksView.h \ - layGenericSyntaxHighlighter.h \ - layDispatcher.h \ + layNetlistCrossReferenceModel.h \ + layPluginConfigPage.h \ + layProperties.h \ + layPropertiesDialog.h \ + layQtTools.h \ + laySaveLayoutOptionsDialog.h \ laySelectCellViewForm.h \ - layLayoutStatisticsForm.h \ - layLayoutViewFunctions.h + laySelectLineStyleForm.h \ + laySelectStippleForm.h \ + laySelector.h \ + layTechnology.h \ + layTipDialog.h \ + layWidgets.h \ + layZoomBox.h \ + laybasicConfig.h \ + rdbInfoWidget.h \ + rdbMarkerBrowser.h \ + rdbMarkerBrowserDialog.h \ + rdbMarkerBrowserPage.h \ + +} + +SOURCES += \ + gsiDeclLayLayers.cc \ + layAnnotationShapes.cc \ + layBitmap.cc \ + layColor.cc \ + layColorPalette.cc \ + layDispatcher.cc \ + layDisplayState.cc \ + layDitherPattern.cc \ + layDrawing.cc \ + layEditable.cc \ + layFinder.cc \ + layFixedFont.cc \ + layLineStylePalette.cc \ + layLineStyles.cc \ + layMarker.cc \ + layMouseTracker.cc \ + layMove.cc \ + layObjectInstPath.cc \ + layParsedLayerSource.cc \ + layPlugin.cc \ + layRedrawLayerInfo.cc \ + layRedrawThread.cc \ + layRedrawThreadCanvas.cc \ + layRedrawThreadWorker.cc \ + layRenderer.cc \ + layRubberBox.cc \ + laySnap.cc \ + layStipplePalette.cc \ + layStream.cc \ + layCanvasPlane.cc \ + layLayerProperties.cc \ + layViewObject.cc \ + layViewOp.cc \ + layViewport.cc \ + +HEADERS += \ + layAnnotationShapes.h \ + layBitmap.h \ + layColorPalette.h \ + layDispatcher.h \ + layDisplayState.h \ + layDitherPattern.h \ + layDrawing.h \ + layEditable.h \ + layFinder.h \ + layFixedFont.h \ + layLineStylePalette.h \ + layLineStyles.h \ + layMarker.h \ + layMouseTracker.h \ + layMove.h \ + layObjectInstPath.h \ + layParsedLayerSource.h \ + layPlugin.h \ + layRedrawLayerInfo.h \ + layRedrawThread.h \ + layRedrawThreadCanvas.h \ + layRedrawThreadWorker.h \ + layRenderer.h \ + layRubberBox.h \ + laySnap.h \ + layStipplePalette.h \ + layStream.h \ + layLayerProperties.h \ + layCanvasPlane.h \ + layViewObject.h \ + layViewOp.h \ + layViewport.h \ + laybasicCommon.h \ + INCLUDEPATH += $$TL_INC $$GSI_INC $$DB_INC $$RDB_INC $$LYM_INC DEPENDPATH += $$TL_INC $$GSI_INC $$DB_INC $$RDB_INC $$LYM_INC diff --git a/src/laybasic/laybasic/rdbMarkerBrowser.h b/src/laybasic/laybasic/rdbMarkerBrowser.h index 8c9feb344..b2a14a25b 100644 --- a/src/laybasic/laybasic/rdbMarkerBrowser.h +++ b/src/laybasic/laybasic/rdbMarkerBrowser.h @@ -25,6 +25,7 @@ #define HDR_rdbMarkerBrowser #include "layPlugin.h" +#include "layPluginConfigPage.h" #include "ui_MarkerBrowserConfigPage.h" #include "ui_MarkerBrowserConfigPage2.h" diff --git a/src/laybasic/unit_tests/layColorTests.cc b/src/laybasic/unit_tests/layColorTests.cc new file mode 100644 index 000000000..c90b0d722 --- /dev/null +++ b/src/laybasic/unit_tests/layColorTests.cc @@ -0,0 +1,114 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 "layColor.h" + +#include "tlUnitTest.h" + +#if defined(HAVE_QT) +#include +#endif + +TEST(1) +{ + EXPECT_EQ (lay::Color ().is_valid (), false); + EXPECT_EQ (lay::Color ().to_string (), ""); + EXPECT_EQ (lay::Color ().rgb (), 0x00000000); + +#if defined(HAVE_QT) + EXPECT_EQ (QColor ().isValid (), false); + EXPECT_EQ (tl::to_string (QColor ().name ()), "#000000"); // why? + EXPECT_EQ (QColor ().rgb (), 0xff000000); +#endif +} + +TEST(2) +{ + EXPECT_EQ (lay::Color (0x102030).is_valid (), true); + EXPECT_EQ (lay::Color (0x102030).to_string (), "#102030"); + EXPECT_EQ (lay::Color (0x102030).rgb (), 0xff102030); + +#if defined(HAVE_QT) + EXPECT_EQ (QColor (0x102030).isValid (), true); + EXPECT_EQ (tl::to_string (QColor (0x102030).name ()), "#102030"); + EXPECT_EQ (QColor (0x102030).rgb (), 0xff102030); +#endif +} + +TEST(3) +{ + EXPECT_EQ (lay::Color (std::string ()).is_valid (), false); + EXPECT_EQ (lay::Color ("#102030").is_valid (), true); + EXPECT_EQ (lay::Color ("#102030").to_string (), "#102030"); + EXPECT_EQ (lay::Color ("#102030").rgb (), 0xff102030); + EXPECT_EQ (lay::Color ("102030").is_valid (), true); + EXPECT_EQ (lay::Color ("102030").to_string (), "#102030"); + EXPECT_EQ (lay::Color ("102030").rgb (), 0xff102030); + +#if defined(HAVE_QT) + EXPECT_EQ (QColor (tl::to_qstring ("#102030")).isValid (), true); + EXPECT_EQ (tl::to_string (QColor (tl::to_qstring ("#102030")).name ()), "#102030"); + EXPECT_EQ (QColor (tl::to_qstring ("#102030")).rgb (), 0xff102030); +#endif +} + +TEST(4) +{ + EXPECT_EQ (lay::Color ("#123").is_valid (), true); + EXPECT_EQ (lay::Color ("#123").to_string (), "#112233"); + EXPECT_EQ (lay::Color ("#123").rgb (), 0xff112233); +} + +TEST(5) +{ + EXPECT_EQ (lay::Color ("#80102030").is_valid (), true); + EXPECT_EQ (lay::Color ("#80102030").to_string (), "#80102030"); + EXPECT_EQ (lay::Color ("#80102030").rgb (), 0x80102030); + +#if defined(HAVE_QT) + // no alpha support in Qt + EXPECT_EQ (QColor (tl::to_qstring ("#80102030")).isValid (), true); + EXPECT_EQ (tl::to_string (QColor (tl::to_qstring ("#80102030")).name ()), "#102030"); + EXPECT_EQ (QColor (tl::to_qstring ("#80102030")).rgb (), 0xff102030); +#endif +} + +TEST(6) +{ + EXPECT_EQ (lay::Color ("#8123").is_valid (), true); + EXPECT_EQ (lay::Color ("#8123").to_string (), "#88112233"); + EXPECT_EQ (lay::Color ("#8123").rgb (), 0x88112233); +} + +TEST(7) +{ + EXPECT_EQ (lay::Color (16, 32, 48, 128).is_valid (), true); + EXPECT_EQ (lay::Color (16, 32, 48, 128).to_string (), "#80102030"); + EXPECT_EQ (lay::Color (16, 32, 48, 128).rgb (), 0x80102030); + +#if defined(HAVE_QT) + // no alpha support in Qt + EXPECT_EQ (QColor (16, 32, 48, 128).isValid (), true); + EXPECT_EQ (tl::to_string (QColor (16, 32, 48, 128).name ()), "#102030"); + EXPECT_EQ (QColor (16, 32, 48, 128).rgb (), 0xff102030); +#endif +} diff --git a/src/laybasic/unit_tests/unit_tests.pro b/src/laybasic/unit_tests/unit_tests.pro index d948a1d87..0da4329f9 100644 --- a/src/laybasic/unit_tests/unit_tests.pro +++ b/src/laybasic/unit_tests/unit_tests.pro @@ -10,6 +10,7 @@ SOURCES = \ layAnnotationShapes.cc \ layBitmap.cc \ layBitmapsToImage.cc \ + layColorTests.cc \ layLayerProperties.cc \ layParsedLayerSource.cc \ layRenderer.cc \ diff --git a/src/plugins/tools/net_tracer/lay_plugin/layNetTracerConfig.h b/src/plugins/tools/net_tracer/lay_plugin/layNetTracerConfig.h index 91c02f9ce..395a87d20 100644 --- a/src/plugins/tools/net_tracer/lay_plugin/layNetTracerConfig.h +++ b/src/plugins/tools/net_tracer/lay_plugin/layNetTracerConfig.h @@ -28,6 +28,7 @@ #include "ui_NetTracerConfigPage.h" #include "layPlugin.h" +#include "layPluginConfigPage.h" #include "layColorPalette.h" namespace lay From c3f3fd00ce51df4d93e61f2619c59b222879fa2a Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Tue, 26 Apr 2022 00:09:39 +0200 Subject: [PATCH 04/88] WIP --- src/ant/ant/antService.cc | 12 +-- src/ant/ant/antService.h | 6 +- src/edt/edt/edtPartialService.cc | 2 +- src/edt/edt/edtPartialService.h | 2 +- src/img/img/imgLandmarksDialog.cc | 2 +- src/lay/lay/layNavigator.cc | 14 ++-- src/laybasic/laybasic/gsiDeclLayLayoutView.cc | 4 +- src/laybasic/laybasic/gsiDeclLayMarker.cc | 12 +-- src/laybasic/laybasic/layBookmarksView.cc | 8 +- src/laybasic/laybasic/layBookmarksView.h | 5 +- src/laybasic/laybasic/layColor.h | 56 +++++++++++++ src/laybasic/laybasic/layConverters.cc | 23 +++++- src/laybasic/laybasic/layConverters.h | 3 + src/laybasic/laybasic/layDrawing.h | 2 +- src/laybasic/laybasic/layEditorServiceBase.cc | 6 +- src/laybasic/laybasic/layEditorServiceBase.h | 4 +- .../laybasic/layHierarchyControlPanel.cc | 16 ++-- .../laybasic/layHierarchyControlPanel.h | 8 +- src/laybasic/laybasic/layLayerControlPanel.cc | 12 +-- src/laybasic/laybasic/layLayerControlPanel.h | 4 +- src/laybasic/laybasic/layLayoutCanvas.cc | 28 +++---- src/laybasic/laybasic/layLayoutCanvas.h | 16 ++-- src/laybasic/laybasic/layLayoutView.cc | 80 +++++++++---------- src/laybasic/laybasic/layLayoutView.h | 54 ++++++------- src/laybasic/laybasic/layLibrariesView.cc | 16 ++-- src/laybasic/laybasic/layLibrariesView.h | 8 +- src/laybasic/laybasic/layMarker.cc | 14 ++-- src/laybasic/laybasic/layMarker.h | 14 ++-- .../laybasic/layNetlistBrowserDialog.cc | 2 +- .../laybasic/layNetlistBrowserDialog.h | 2 +- .../laybasic/layNetlistBrowserModel.cc | 24 +++--- .../laybasic/layNetlistBrowserModel.h | 14 ++-- .../laybasic/layNetlistBrowserPage.cc | 28 +++---- src/laybasic/laybasic/layNetlistBrowserPage.h | 6 +- .../laybasic/layRedrawThreadCanvas.cc | 2 +- src/laybasic/laybasic/layRedrawThreadCanvas.h | 2 +- src/laybasic/laybasic/laySelector.cc | 2 +- src/laybasic/laybasic/laySelector.h | 2 +- src/laybasic/laybasic/layViewObject.h | 8 +- src/laybasic/laybasic/layZoomBox.cc | 2 +- src/laybasic/laybasic/layZoomBox.h | 2 +- .../laybasic/rdbMarkerBrowserDialog.cc | 2 +- .../laybasic/rdbMarkerBrowserDialog.h | 2 +- src/laybasic/laybasic/rdbMarkerBrowserPage.cc | 2 +- src/laybasic/laybasic/rdbMarkerBrowserPage.h | 5 +- src/laybasic/unit_tests/layColorTests.cc | 4 + .../net_tracer/db_plugin/dbNetTracerIO.cc | 4 +- .../net_tracer/db_plugin/dbNetTracerIO.h | 10 +-- .../lay_plugin/layNetTracerDialog.cc | 14 ++-- .../lay_plugin/layNetTracerDialog.h | 2 +- .../view_25d/lay_plugin/layD25ViewWidget.cc | 2 +- 51 files changed, 327 insertions(+), 247 deletions(-) diff --git a/src/ant/ant/antService.cc b/src/ant/ant/antService.cc index 7fe8733ce..5c6db1ec2 100644 --- a/src/ant/ant/antService.cc +++ b/src/ant/ant/antService.cc @@ -759,9 +759,9 @@ View::render (const lay::Viewport &vp, lay::ViewObjectCanvas &canvas) int basic_width = int(0.5 + 1.0 / canvas.resolution ()); - QColor c (mp_rulers->color ()); - if (! c.isValid ()) { - c = QColor (canvas.foreground_color ().rgb ()); + lay::Color c (mp_rulers->color ()); + if (! c.is_valid ()) { + c = canvas.foreground_color (); } // obtain bitmap to render on @@ -819,7 +819,7 @@ Service::configure (const std::string &name, const std::string &value) if (name == cfg_ruler_color) { - QColor color; + lay::Color color; lay::ColorConverter ().from_string (value, color); // make the color available for the dynamic view objects too. @@ -910,7 +910,7 @@ Service::annotations_changed () } std::vector -Service::get_view_ops (lay::RedrawThreadCanvas &canvas, QColor background, QColor foreground, QColor /*active*/) const +Service::get_view_ops (lay::RedrawThreadCanvas &canvas, lay::Color background, lay::Color foreground, lay::Color /*active*/) const { int basic_width = int(0.5 + 1.0 / canvas.resolution ()); @@ -920,7 +920,7 @@ Service::get_view_ops (lay::RedrawThreadCanvas &canvas, QColor background, QColo if (m_halo) { view_ops.push_back (lay::ViewOp (background.rgb (), lay::ViewOp::Copy, 0, 0, 0, lay::ViewOp::Rect, 3 * basic_width, 0)); } - if (m_color.isValid ()) { + if (m_color.is_valid ()) { view_ops.push_back (lay::ViewOp (m_color.rgb (), lay::ViewOp::Copy, 0, 0, 0, lay::ViewOp::Rect, basic_width, 0)); } else { view_ops.push_back (lay::ViewOp (foreground.rgb (), lay::ViewOp::Copy, 0, 0, 0, lay::ViewOp::Rect, basic_width, 0)); diff --git a/src/ant/ant/antService.h b/src/ant/ant/antService.h index 2856ba067..9b53cbe03 100644 --- a/src/ant/ant/antService.h +++ b/src/ant/ant/antService.h @@ -387,7 +387,7 @@ public: /** * @brief Color accessor */ - QColor color () const + lay::Color color () const { return m_color; } @@ -498,7 +498,7 @@ public: private: // Ruler display and snapping configuration - QColor m_color; + lay::Color m_color; bool m_halo; lay::angle_constraint_type m_snap_mode; double m_grid; @@ -599,7 +599,7 @@ private: /** * @brief implementation of the "Drawing" interface: configuration */ - std::vector get_view_ops (lay::RedrawThreadCanvas &canvas, QColor background, QColor foreground, QColor active) const; + std::vector get_view_ops (lay::RedrawThreadCanvas &canvas, lay::Color background, lay::Color foreground, lay::Color active) const; /** * @brief Update m_rulers to reflect the selection diff --git a/src/edt/edt/edtPartialService.cc b/src/edt/edt/edtPartialService.cc index fe5bf02df..a22882651 100644 --- a/src/edt/edt/edtPartialService.cc +++ b/src/edt/edt/edtPartialService.cc @@ -1220,7 +1220,7 @@ PartialService::clear_partial_transient_selection () } void -PartialService::set_colors (QColor /*background*/, QColor color) +PartialService::set_colors (lay::Color /*background*/, lay::Color color) { m_color = color.rgb (); if (mp_box) { diff --git a/src/edt/edt/edtPartialService.h b/src/edt/edt/edtPartialService.h index 03d09da96..0781dcf81 100644 --- a/src/edt/edt/edtPartialService.h +++ b/src/edt/edt/edtPartialService.h @@ -282,7 +282,7 @@ public: /** * @brief Reimplementation of the ViewService interface: set the colors */ - virtual void set_colors (QColor background, QColor text); + virtual void set_colors (lay::Color background, lay::Color text); /** * @brief Cancel any edit operations (in this case, unselect all & cancel any drag operation) diff --git a/src/img/img/imgLandmarksDialog.cc b/src/img/img/imgLandmarksDialog.cc index 1a8d3d152..16d9142cf 100644 --- a/src/img/img/imgLandmarksDialog.cc +++ b/src/img/img/imgLandmarksDialog.cc @@ -345,7 +345,7 @@ public: widget ()->ungrab_mouse (this); } - void set_colors (QColor /*background*/, QColor /*color*/) + void set_colors (lay::Color /*background*/, lay::Color /*color*/) { // ... } diff --git a/src/lay/lay/layNavigator.cc b/src/lay/lay/layNavigator.cc index 20f828626..5855b403d 100644 --- a/src/lay/lay/layNavigator.cc +++ b/src/lay/lay/layNavigator.cc @@ -72,18 +72,18 @@ public: void background_color_changed () { - QColor c = mp_view->background_color (); + lay::Color c = mp_view->background_color (); // replace by "real" background color if required - if (! c.isValid ()) { - c = mp_view->palette ().color (QPalette::Normal, QPalette::Base); + if (! c.is_valid ()) { + c = lay::Color (mp_view->palette ().color (QPalette::Normal, QPalette::Base).rgb ()); } - QColor contrast; + lay::Color contrast; if (c.green () > 128) { - contrast = QColor (0, 0, 0); + contrast = lay::Color (0, 0, 0); } else { - contrast = QColor (255, 255, 255); + contrast = lay::Color (255, 255, 255); } set_colors (c, contrast); @@ -388,7 +388,7 @@ public: widget ()->ungrab_mouse (this); } - void set_colors (QColor /*background*/, QColor color) + void set_colors (lay::Color /*background*/, lay::Color color) { // set zoom box color m_color = color.rgb (); diff --git a/src/laybasic/laybasic/gsiDeclLayLayoutView.cc b/src/laybasic/laybasic/gsiDeclLayLayoutView.cc index e5bf11472..1cf36d029 100644 --- a/src/laybasic/laybasic/gsiDeclLayLayoutView.cc +++ b/src/laybasic/laybasic/gsiDeclLayLayoutView.cc @@ -330,13 +330,13 @@ static void save_as2 (lay::LayoutView *view, unsigned int index, const std::stri #if defined(HAVE_QTBINDINGS) static QImage get_image_with_options (lay::LayoutView *view, unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, const db::DBox &target_box, bool monochrome) { - return view->get_image_with_options (width, height, linewidth, oversampling, resolution, QColor (), QColor (), QColor (), target_box, monochrome); + return view->get_image_with_options (width, height, linewidth, oversampling, resolution, lay::Color (), lay::Color (), lay::Color (), target_box, monochrome); } #endif static void save_image_with_options (lay::LayoutView *view, const std::string &fn, unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, const db::DBox &target_box, bool monochrome) { - view->save_image_with_options (fn, width, height, linewidth, oversampling, resolution, QColor (), QColor (), QColor (), target_box, monochrome); + view->save_image_with_options (fn, width, height, linewidth, oversampling, resolution, lay::Color (), lay::Color (), lay::Color (), target_box, monochrome); } static std::vector diff --git a/src/laybasic/laybasic/gsiDeclLayMarker.cc b/src/laybasic/laybasic/gsiDeclLayMarker.cc index ff048605e..5e23b71aa 100644 --- a/src/laybasic/laybasic/gsiDeclLayMarker.cc +++ b/src/laybasic/laybasic/gsiDeclLayMarker.cc @@ -37,13 +37,13 @@ lay::DMarker *create_marker (lay::LayoutView *view) static void reset_frame_color (lay::DMarker *marker) { - marker->set_frame_color (QColor ()); + marker->set_frame_color (lay::Color ()); } static void set_frame_color (lay::DMarker *marker, unsigned int color) { - marker->set_frame_color (QColor (color)); + marker->set_frame_color (lay::Color (color)); } static @@ -55,19 +55,19 @@ unsigned int get_frame_color (const lay::DMarker *marker) static bool has_frame_color (const lay::DMarker *marker) { - return marker->get_frame_color ().isValid (); + return marker->get_frame_color ().is_valid (); } static void reset_color (lay::DMarker *marker) { - marker->set_color (QColor ()); + marker->set_color (lay::Color ()); } static void set_color (lay::DMarker *marker, unsigned int color) { - marker->set_color (QColor (color)); + marker->set_color (lay::Color (color)); } static @@ -79,7 +79,7 @@ unsigned int get_color (const lay::DMarker *marker) static bool has_color (const lay::DMarker *marker) { - return marker->get_color ().isValid (); + return marker->get_color ().is_valid (); } Class decl_Marker ("lay", "Marker", diff --git a/src/laybasic/laybasic/layBookmarksView.cc b/src/laybasic/laybasic/layBookmarksView.cc index 39df8be5e..4c104316c 100644 --- a/src/laybasic/laybasic/layBookmarksView.cc +++ b/src/laybasic/laybasic/layBookmarksView.cc @@ -134,18 +134,18 @@ BookmarksView::follow_selection (bool f) } void -BookmarksView::set_background_color (QColor c) +BookmarksView::set_background_color (lay::Color c) { QPalette pl (mp_bookmarks->palette ()); - pl.setColor (QPalette::Base, c); + pl.setColor (QPalette::Base, QColor (c.rgb ())); mp_bookmarks->setPalette (pl); } void -BookmarksView::set_text_color (QColor c) +BookmarksView::set_text_color (lay::Color c) { QPalette pl (mp_bookmarks->palette ()); - pl.setColor (QPalette::Text, c); + pl.setColor (QPalette::Text, QColor (c.rgb ())); mp_bookmarks->setPalette (pl); } diff --git a/src/laybasic/laybasic/layBookmarksView.h b/src/laybasic/laybasic/layBookmarksView.h index 54bc6214d..70c6958a6 100644 --- a/src/laybasic/laybasic/layBookmarksView.h +++ b/src/laybasic/laybasic/layBookmarksView.h @@ -27,6 +27,7 @@ #include "laybasicCommon.h" #include "layBookmarkList.h" +#include "layColor.h" #include #include @@ -51,8 +52,8 @@ public: BookmarksView (LayoutView *view, QWidget *parent, const char *name); ~BookmarksView (); - void set_background_color (QColor c); - void set_text_color (QColor c); + void set_background_color (lay::Color c); + void set_text_color (lay::Color c); void follow_selection (bool f); std::set selected_bookmarks (); diff --git a/src/laybasic/laybasic/layColor.h b/src/laybasic/laybasic/layColor.h index 836252fff..77cccebc8 100644 --- a/src/laybasic/laybasic/layColor.h +++ b/src/laybasic/laybasic/layColor.h @@ -68,6 +68,30 @@ public: */ Color (const std::string &name); + /** + * @brief Comparison: equal + */ + bool operator== (const Color &color) const + { + return m_color == color.m_color; + } + + /** + * @brief Comparison: not equal + */ + bool operator!= (const Color &color) const + { + return m_color != color.m_color; + } + + /** + * @brief Comparison: less + */ + bool operator< (const Color &color) const + { + return m_color < color.m_color; + } + /** * @brief Gets the string value from a color */ @@ -86,6 +110,38 @@ public: return m_color; } + /** + * @brief Gets the alpha component + */ + unsigned int alpha () const + { + return (m_color & 0xff000000) >> 24; + } + + /** + * @brief Gets the red component + */ + unsigned int red () const + { + return (m_color & 0xff0000) >> 16; + } + + /** + * @brief Gets the green component + */ + unsigned int green () const + { + return (m_color & 0xff00) >> 8; + } + + /** + * @brief Gets the blue component + */ + unsigned int blue () const + { + return (m_color & 0xff); + } + private: color_t m_color; }; diff --git a/src/laybasic/laybasic/layConverters.cc b/src/laybasic/laybasic/layConverters.cc index 98c56cbe3..3a5f0497a 100644 --- a/src/laybasic/laybasic/layConverters.cc +++ b/src/laybasic/laybasic/layConverters.cc @@ -41,7 +41,17 @@ ColorConverter::to_string (const QColor &c) const } } -void +std::string +ColorConverter::to_string (const lay::Color &c) const +{ + if (! c.is_valid ()) { + return "auto"; + } else { + return c.to_string (); + } +} + +void ColorConverter::from_string (const std::string &s, QColor &c) const { std::string t (tl::trim (s)); @@ -52,5 +62,16 @@ ColorConverter::from_string (const std::string &s, QColor &c) const } } +void +ColorConverter::from_string (const std::string &s, lay::Color &c) const +{ + std::string t (tl::trim (s)); + if (t == "auto") { + c = lay::Color (); + } else { + c = lay::Color (t); + } +} + } diff --git a/src/laybasic/laybasic/layConverters.h b/src/laybasic/laybasic/layConverters.h index ed3c2b6aa..8965fc369 100644 --- a/src/laybasic/laybasic/layConverters.h +++ b/src/laybasic/laybasic/layConverters.h @@ -25,6 +25,7 @@ #define HDR_layConverters #include "laybasicCommon.h" +#include "layColor.h" #include @@ -37,7 +38,9 @@ namespace lay struct LAYBASIC_PUBLIC ColorConverter { std::string to_string (const QColor &c) const; + std::string to_string (const lay::Color &c) const; void from_string (const std::string &s, QColor &c) const; + void from_string (const std::string &s, lay::Color &c) const; }; } diff --git a/src/laybasic/laybasic/layDrawing.h b/src/laybasic/laybasic/layDrawing.h index 6545ed3db..20791ca70 100644 --- a/src/laybasic/laybasic/layDrawing.h +++ b/src/laybasic/laybasic/layDrawing.h @@ -121,7 +121,7 @@ public: /** * @brief Get the current appearance */ - virtual std::vector get_view_ops (lay::RedrawThreadCanvas &canvas, QColor background, QColor foreground, QColor active) const = 0; + virtual std::vector get_view_ops (lay::RedrawThreadCanvas &canvas, lay::Color background, lay::Color foreground, lay::Color active) const = 0; private: unsigned int m_num_planes; diff --git a/src/laybasic/laybasic/layEditorServiceBase.cc b/src/laybasic/laybasic/layEditorServiceBase.cc index 388bd4487..7dbc0fad1 100644 --- a/src/laybasic/laybasic/layEditorServiceBase.cc +++ b/src/laybasic/laybasic/layEditorServiceBase.cc @@ -59,11 +59,11 @@ public: uint32_t cursor_color (lay::ViewObjectCanvas &canvas) const { - QColor color; + lay::Color color; if (mp_service) { color = mp_service->tracking_cursor_color (); } - if (! color.isValid ()) { + if (! color.is_valid ()) { color = canvas.foreground_color (); } return color.rgb (); @@ -263,7 +263,7 @@ EditorServiceBase::configure (const std::string &name, const std::string &value) if (name == cfg_tracking_cursor_color) { - QColor color; + lay::Color color; lay::ColorConverter ().from_string (value, color); if (color != m_cursor_color) { diff --git a/src/laybasic/laybasic/layEditorServiceBase.h b/src/laybasic/laybasic/layEditorServiceBase.h index d088c22fe..276f1a66a 100644 --- a/src/laybasic/laybasic/layEditorServiceBase.h +++ b/src/laybasic/laybasic/layEditorServiceBase.h @@ -92,7 +92,7 @@ public: /** * @brief Gets the tracking cursor color */ - QColor tracking_cursor_color () const + lay::Color tracking_cursor_color () const { return m_cursor_color; } @@ -128,7 +128,7 @@ protected: private: // The marker representing the mouse cursor std::vector m_mouse_cursor_markers; - QColor m_cursor_color; + lay::Color m_cursor_color; bool m_cursor_enabled; bool m_has_tracking_position; db::DPoint m_tracking_position; diff --git a/src/laybasic/laybasic/layHierarchyControlPanel.cc b/src/laybasic/laybasic/layHierarchyControlPanel.cc index 1f21ae24c..947b2f3c7 100644 --- a/src/laybasic/laybasic/layHierarchyControlPanel.cc +++ b/src/laybasic/laybasic/layHierarchyControlPanel.cc @@ -655,23 +655,23 @@ HierarchyControlPanel::current_cell (int cv_index, HierarchyControlPanel::cell_p } void -HierarchyControlPanel::set_background_color (QColor c) +HierarchyControlPanel::set_background_color (lay::Color c) { m_background_color = c; for (std::vector ::const_iterator f = mp_cell_lists.begin (); f != mp_cell_lists.end (); ++f) { QPalette pl ((*f)->palette ()); - pl.setColor (QPalette::Base, c); + pl.setColor (QPalette::Base, QColor (c.rgb ())); (*f)->setPalette (pl); } } void -HierarchyControlPanel::set_text_color (QColor c) +HierarchyControlPanel::set_text_color (lay::Color c) { m_text_color = c; for (std::vector ::const_iterator f = mp_cell_lists.begin (); f != mp_cell_lists.end (); ++f) { QPalette pl ((*f)->palette ()); - pl.setColor (QPalette::Text, c); + pl.setColor (QPalette::Text, QColor (c.rgb ())); (*f)->setPalette (pl); } } @@ -895,11 +895,11 @@ HierarchyControlPanel::do_update_content (int cv_index) cell_list->setUniformRowHeights (true); pl = cell_list->palette (); - if (m_text_color.isValid ()) { - pl.setColor (QPalette::Text, m_text_color); + if (m_text_color.is_valid ()) { + pl.setColor (QPalette::Text, QColor (m_text_color.rgb ())); } - if (m_background_color.isValid ()) { - pl.setColor (QPalette::Base, m_background_color); + if (m_background_color.is_valid ()) { + pl.setColor (QPalette::Base, QColor (m_background_color.rgb ())); } cell_list->setPalette (pl); diff --git a/src/laybasic/laybasic/layHierarchyControlPanel.h b/src/laybasic/laybasic/layHierarchyControlPanel.h index 516ec1d46..be6c29db8 100644 --- a/src/laybasic/laybasic/layHierarchyControlPanel.h +++ b/src/laybasic/laybasic/layHierarchyControlPanel.h @@ -125,12 +125,12 @@ public: /** * @brief Changing of the background color */ - void set_background_color (QColor c); + void set_background_color (lay::Color c); /** * @brief Changing of the text color */ - void set_text_color (QColor c); + void set_text_color (lay::Color c); /** * @brief Select the active cellview @@ -304,8 +304,8 @@ private: QFrame *mp_search_frame; QCheckBox *mp_search_close_cb; QSplitter *mp_splitter; - QColor m_background_color; - QColor m_text_color; + lay::Color m_background_color; + lay::Color m_text_color; tl::DeferredMethod m_do_update_content_dm; tl::DeferredMethod m_do_full_update_content_dm; std::unique_ptr mp_tree_style; diff --git a/src/laybasic/laybasic/layLayerControlPanel.cc b/src/laybasic/laybasic/layLayerControlPanel.cc index bdb0a3004..931f5fd1c 100644 --- a/src/laybasic/laybasic/layLayerControlPanel.cc +++ b/src/laybasic/laybasic/layLayerControlPanel.cc @@ -1640,21 +1640,21 @@ LayerControlPanel::set_no_stipples (bool ns) } void -LayerControlPanel::set_background_color (QColor c) +LayerControlPanel::set_background_color (lay::Color c) { QPalette pl (mp_layer_list->palette ()); - pl.setColor (QPalette::Base, c); + pl.setColor (QPalette::Base, QColor (c.rgb ())); mp_layer_list->setPalette (pl); - mp_model->set_background_color (c); + mp_model->set_background_color (QColor (c.rgb ())); } void -LayerControlPanel::set_text_color (QColor c) +LayerControlPanel::set_text_color (lay::Color c) { QPalette pl (mp_layer_list->palette ()); - pl.setColor (QPalette::Text, c); + pl.setColor (QPalette::Text, QColor (c.rgb ())); mp_layer_list->setPalette (pl); - mp_model->set_text_color (c); + mp_model->set_text_color (QColor (c.rgb ())); } void diff --git a/src/laybasic/laybasic/layLayerControlPanel.h b/src/laybasic/laybasic/layLayerControlPanel.h index 1db2ee13c..d3b322c88 100644 --- a/src/laybasic/laybasic/layLayerControlPanel.h +++ b/src/laybasic/laybasic/layLayerControlPanel.h @@ -166,12 +166,12 @@ public: /** * @brief Changing of the background color */ - void set_background_color (QColor c); + void set_background_color (lay::Color c); /** * @brief Changing of the text color */ - void set_text_color (QColor c); + void set_text_color (lay::Color c); /** * @brief Set the "hide empty layers" flag diff --git a/src/laybasic/laybasic/layLayoutCanvas.cc b/src/laybasic/laybasic/layLayoutCanvas.cc index 152644176..99a6200dd 100644 --- a/src/laybasic/laybasic/layLayoutCanvas.cc +++ b/src/laybasic/laybasic/layLayoutCanvas.cc @@ -303,9 +303,9 @@ LayoutCanvas::LayoutCanvas (QWidget *parent, lay::LayoutView *view, const char * mp_redraw_thread = new lay::RedrawThread (this, view); setBackgroundRole (QPalette::NoRole); - set_colors (palette ().color (QPalette::Normal, QPalette::Window), - palette ().color (QPalette::Normal, QPalette::Text), - palette ().color (QPalette::Normal, QPalette::Mid)); + set_colors (lay::Color (palette ().color (QPalette::Normal, QPalette::Window).rgb ()), + lay::Color (palette ().color (QPalette::Normal, QPalette::Text).rgb ()), + lay::Color (palette ().color (QPalette::Normal, QPalette::Mid).rgb ())); setAttribute (Qt::WA_NoSystemBackground); } @@ -378,7 +378,7 @@ LayoutCanvas::set_oversampling (unsigned int os) } void -LayoutCanvas::set_colors (QColor background, QColor foreground, QColor active) +LayoutCanvas::set_colors (lay::Color background, lay::Color foreground, lay::Color active) { m_background = background.rgb (); m_foreground = foreground.rgb (); @@ -697,7 +697,7 @@ class DetachedViewObjectCanvas : public BitmapViewObjectCanvas { public: - DetachedViewObjectCanvas (QColor bg, QColor fg, QColor ac, unsigned int width_l, unsigned int height_l, double resolution, QImage *img) + DetachedViewObjectCanvas (lay::Color bg, lay::Color fg, lay::Color ac, unsigned int width_l, unsigned int height_l, double resolution, QImage *img) : BitmapViewObjectCanvas (width_l, height_l, resolution), m_bg (bg), m_fg (fg), m_ac (ac), mp_image (img) { @@ -722,17 +722,17 @@ public: } } - QColor background_color () const + lay::Color background_color () const { return m_bg; } - QColor foreground_color () const + lay::Color foreground_color () const { return m_fg; } - QColor active_color () const + lay::Color active_color () const { return m_ac; } @@ -764,7 +764,7 @@ public: } private: - QColor m_bg, m_fg, m_ac; + lay::Color m_bg, m_fg, m_ac; QImage *mp_image; QImage *mp_image_l; double m_gamma; @@ -773,11 +773,11 @@ private: QImage LayoutCanvas::image (unsigned int width, unsigned int height) { - return image_with_options (width, height, -1, -1, -1.0, QColor (), QColor (), QColor (), db::DBox (), false); + return image_with_options (width, height, -1, -1, -1.0, lay::Color (), lay::Color (), lay::Color (), db::DBox (), false); } QImage -LayoutCanvas::image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, QColor background, QColor foreground, QColor active, const db::DBox &target_box, bool is_mono) +LayoutCanvas::image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, lay::Color background, lay::Color foreground, lay::Color active, const db::DBox &target_box, bool is_mono) { if (oversampling <= 0) { oversampling = m_oversampling; @@ -788,13 +788,13 @@ LayoutCanvas::image_with_options (unsigned int width, unsigned int height, int l if (resolution <= 0.0) { resolution = 1.0 / oversampling; } - if (background == QColor ()) { + if (! background.is_valid ()) { background = background_color (); } - if (foreground == QColor ()) { + if (! foreground.is_valid ()) { foreground = foreground_color (); } - if (active == QColor ()) { + if (! active.is_valid ()) { active = active_color (); } diff --git a/src/laybasic/laybasic/layLayoutCanvas.h b/src/laybasic/laybasic/layLayoutCanvas.h index bbdbfcfcd..aa4d9e624 100644 --- a/src/laybasic/laybasic/layLayoutCanvas.h +++ b/src/laybasic/laybasic/layLayoutCanvas.h @@ -144,7 +144,7 @@ public: LayoutCanvas (QWidget *parent, lay::LayoutView *view, const char *name = "canvas"); ~LayoutCanvas (); - void set_colors (QColor background, QColor foreground, QColor active); + void set_colors (lay::Color background, lay::Color foreground, lay::Color active); /** * @brief Set the view ops for the layers @@ -167,7 +167,7 @@ public: QImage screenshot (); QImage image (unsigned int width, unsigned int height); - QImage image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, QColor background, QColor foreground, QColor active_color, const db::DBox &target_box, bool monochrome); + QImage image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, lay::Color background, lay::Color foreground, lay::Color active_color, const db::DBox &target_box, bool monochrome); void update_image (); @@ -288,25 +288,25 @@ public: /** * @brief Reimplementation of ViewObjectCanvas: Background color */ - QColor background_color () const + lay::Color background_color () const { - return QColor (m_background); + return lay::Color (m_background); } /** * @brief Reimplementation of ViewObjectCanvas: Foreground color */ - QColor foreground_color () const + lay::Color foreground_color () const { - return QColor (m_foreground); + return lay::Color (m_foreground); } /** * @brief Reimplementation of ViewObjectCanvas: Active color */ - QColor active_color () const + lay::Color active_color () const { - return QColor (m_active); + return lay::Color (m_active); } /** diff --git a/src/laybasic/laybasic/layLayoutView.cc b/src/laybasic/laybasic/layLayoutView.cc index d780fd482..9fd12f057 100644 --- a/src/laybasic/laybasic/layLayoutView.cc +++ b/src/laybasic/laybasic/layLayoutView.cc @@ -404,7 +404,7 @@ LayoutView::init (db::Manager *mgr, QWidget * /*parent*/) m_paste_display_mode = 2; m_guiding_shape_visible = true; m_guiding_shape_line_width = 1; - m_guiding_shape_color = QColor (); + m_guiding_shape_color = lay::Color (); m_guiding_shape_vertex_size = 5; m_to_level = 0; m_ctx_dimming = 50; @@ -1151,7 +1151,7 @@ LayoutView::configure (const std::string &name, const std::string &value) } else if (name == cfg_background_color) { - QColor color; + lay::Color color; ColorConverter ().from_string (value, color); background_color (color); // do not take - let others receive the background color events as well @@ -1196,7 +1196,7 @@ LayoutView::configure (const std::string &name, const std::string &value) } else if (name == cfg_ctx_color) { - QColor color; + lay::Color color; ColorConverter ().from_string (value, color); ctx_color (color); return true; @@ -1217,7 +1217,7 @@ LayoutView::configure (const std::string &name, const std::string &value) } else if (name == cfg_child_ctx_color) { - QColor color; + lay::Color color; ColorConverter ().from_string (value, color); child_ctx_color (color); return true; @@ -1301,14 +1301,14 @@ LayoutView::configure (const std::string &name, const std::string &value) } else if (name == cfg_cell_box_color) { - QColor color; + lay::Color color; ColorConverter ().from_string (value, color); cell_box_color (color); return true; } else if (name == cfg_text_color) { - QColor color; + lay::Color color; ColorConverter ().from_string (value, color); text_color (color); return true; @@ -1427,14 +1427,14 @@ LayoutView::configure (const std::string &name, const std::string &value) } else if (name == cfg_guiding_shape_color) { - QColor color; + lay::Color color; ColorConverter ().from_string (value, color); guiding_shapes_color (color); return true; } else if (name == cfg_guiding_shape_color) { - QColor color; + lay::Color color; ColorConverter ().from_string (value, color); guiding_shapes_color (color); return true; @@ -1589,7 +1589,7 @@ LayoutView::configure (const std::string &name, const std::string &value) } else if (name == cfg_sel_color) { - QColor color; + lay::Color color; lay::ColorConverter ().from_string (value, color); // Change the color @@ -2991,7 +2991,7 @@ LayoutView::get_image (unsigned int width, unsigned int height) QImage LayoutView::get_image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, - QColor background, QColor foreground, QColor active, const db::DBox &target_box, bool monochrome) + lay::Color background, lay::Color foreground, lay::Color active, const db::DBox &target_box, bool monochrome) { tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Save image"))); @@ -3034,7 +3034,7 @@ LayoutView::save_image (const std::string &fn, unsigned int width, unsigned int void LayoutView::save_image_with_options (const std::string &fn, unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, - QColor background, QColor foreground, QColor active, const db::DBox &target_box, bool monochrome) + lay::Color background, lay::Color foreground, lay::Color active, const db::DBox &target_box, bool monochrome) { tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Save image"))); @@ -4128,11 +4128,11 @@ LayoutView::set_view_ops () std::vector view_ops; view_ops.reserve (nlayers * planes_per_layer + special_planes_before + special_planes_after); - lay::color_t box_color; - if (! m_box_color.isValid ()) { - box_color = mp_canvas->foreground_color ().rgb (); + lay::Color box_color; + if (! m_box_color.is_valid ()) { + box_color = mp_canvas->foreground_color (); } else { - box_color = m_box_color.rgb (); + box_color = m_box_color; } // cell boxes @@ -4141,10 +4141,10 @@ LayoutView::set_view_ops () lay::ViewOp vop; // context level - if (m_ctx_color.isValid ()) { + if (m_ctx_color.is_valid ()) { vop = lay::ViewOp (m_ctx_color.rgb (), lay::ViewOp::Copy, 0, 0, 0); } else { - vop = lay::ViewOp (lay::LayerProperties::brighter (box_color, brightness_for_context), lay::ViewOp::Copy, 0, 0, 0); + vop = lay::ViewOp (lay::LayerProperties::brighter (box_color.rgb (), brightness_for_context), lay::ViewOp::Copy, 0, 0, 0); } // fill, frame, text, vertex @@ -4154,10 +4154,10 @@ LayoutView::set_view_ops () view_ops.push_back (lay::ViewOp (0, lay::ViewOp::Or, 0, 0, 0)); // child level - if (m_child_ctx_color.isValid ()) { + if (m_child_ctx_color.is_valid ()) { vop = lay::ViewOp (m_child_ctx_color.rgb (), lay::ViewOp::Copy, 0, 0, 0); } else { - vop = lay::ViewOp (lay::LayerProperties::brighter (box_color, brightness_for_context), lay::ViewOp::Copy, 0, 0, 0); + vop = lay::ViewOp (lay::LayerProperties::brighter (box_color.rgb (), brightness_for_context), lay::ViewOp::Copy, 0, 0, 0); } // fill, frame, text, vertex @@ -4167,7 +4167,7 @@ LayoutView::set_view_ops () view_ops.push_back (lay::ViewOp (0, lay::ViewOp::Or, 0, 0, 0)); // current level - vop = lay::ViewOp (box_color, lay::ViewOp::Copy, 0, 0, 0); + vop = lay::ViewOp (box_color.rgb (), lay::ViewOp::Copy, 0, 0, 0); // fill, frame, text, vertex view_ops.push_back (lay::ViewOp (0, lay::ViewOp::Or, 0, 0, 0)); @@ -4187,8 +4187,8 @@ LayoutView::set_view_ops () // produce the ViewOps for the guiding shapes - color_t gs_color = box_color; - if (m_guiding_shape_color.isValid ()) { + color_t gs_color = box_color.rgb (); + if (m_guiding_shape_color.is_valid ()) { gs_color = m_guiding_shape_color.rgb (); } @@ -4202,7 +4202,7 @@ LayoutView::set_view_ops () if (ctx == 0) { // context planes - if (m_ctx_color.isValid ()) { + if (m_ctx_color.is_valid ()) { frame_color = text_color = fill_color = m_ctx_color.rgb (); } else { frame_color = text_color = fill_color = lay::LayerProperties::brighter (gs_color, brightness_for_context); @@ -4215,7 +4215,7 @@ LayoutView::set_view_ops () } else if (ctx == 1) { // child level planes (if used) - if (m_child_ctx_color.isValid ()) { + if (m_child_ctx_color.is_valid ()) { frame_color = text_color = fill_color = m_child_ctx_color.rgb (); } else { frame_color = text_color = fill_color = lay::LayerProperties::brighter (gs_color, brightness_for_child_context); @@ -4318,12 +4318,12 @@ LayoutView::set_view_ops () if (ctx == 0) { // context planes - if (m_ctx_color.isValid ()) { + if (m_ctx_color.is_valid ()) { frame_color = text_color = fill_color = m_ctx_color.rgb (); } else { fill_color = l->eff_fill_color_brighter (true /*real*/, brightness_for_context); frame_color = l->eff_frame_color_brighter (true /*real*/, brightness_for_context); - if (m_text_color.isValid ()) { + if (m_text_color.is_valid ()) { text_color = lay::LayerProperties::brighter (m_text_color.rgb (), brightness_for_context); } else { text_color = frame_color; @@ -4337,12 +4337,12 @@ LayoutView::set_view_ops () } else if (ctx == 1) { // child level planes (if used) - if (m_child_ctx_color.isValid ()) { + if (m_child_ctx_color.is_valid ()) { frame_color = text_color = fill_color = m_child_ctx_color.rgb (); } else { fill_color = l->eff_fill_color_brighter (true /*real*/, brightness_for_child_context); frame_color = l->eff_frame_color_brighter (true /*real*/, brightness_for_child_context); - if (m_text_color.isValid ()) { + if (m_text_color.is_valid ()) { text_color = lay::LayerProperties::brighter (m_text_color.rgb (), brightness_for_child_context); } else { text_color = frame_color; @@ -4358,7 +4358,7 @@ LayoutView::set_view_ops () // current level planes fill_color = l->eff_fill_color (true /*real*/); frame_color = l->eff_frame_color (true /*real*/); - if (m_text_color.isValid ()) { + if (m_text_color.is_valid ()) { text_color = m_text_color.rgb (); } else { text_color = frame_color; @@ -4414,7 +4414,7 @@ LayoutView::guiding_shapes_visible (bool v) } void -LayoutView::guiding_shapes_color (QColor c) +LayoutView::guiding_shapes_color (lay::Color c) { if (c != m_guiding_shape_color) { m_guiding_shape_color = c; @@ -4477,7 +4477,7 @@ LayoutView::drop_small_cells_cond (drop_small_cells_cond_type t) } void -LayoutView::cell_box_color (QColor c) +LayoutView::cell_box_color (lay::Color c) { if (c != m_box_color) { m_box_color = c; @@ -4627,7 +4627,7 @@ LayoutView::set_palette (const lay::LineStylePalette &p) } void -LayoutView::ctx_color (QColor c) +LayoutView::ctx_color (lay::Color c) { if (c != m_ctx_color) { m_ctx_color = c; @@ -4654,7 +4654,7 @@ LayoutView::ctx_hollow (bool h) } void -LayoutView::child_ctx_color (QColor c) +LayoutView::child_ctx_color (lay::Color c) { if (c != m_child_ctx_color) { m_child_ctx_color = c; @@ -4711,22 +4711,22 @@ LayoutView::abstract_mode_enabled (bool e) } void -LayoutView::background_color (QColor c) +LayoutView::background_color (lay::Color c) { if (c == mp_canvas->background_color ()) { return; } // replace by "real" background color if required - if (! c.isValid ()) { - c = palette ().color (QPalette::Normal, QPalette::Base); + if (! c.is_valid ()) { + c = lay::Color (palette ().color (QPalette::Normal, QPalette::Base).rgb ()); } - QColor contrast; + lay::Color contrast; if (c.green () > 128) { - contrast = QColor (0, 0, 0); + contrast = lay::Color (0, 0, 0); } else { - contrast = QColor (255, 255, 255); + contrast = lay::Color (255, 255, 255); } if (mp_control_panel) { @@ -5267,7 +5267,7 @@ LayoutView::show_markers (bool f) } void -LayoutView::text_color (QColor c) +LayoutView::text_color (lay::Color c) { if (m_text_color != c) { m_text_color = c; diff --git a/src/laybasic/laybasic/layLayoutView.h b/src/laybasic/laybasic/layLayoutView.h index 9fd1519b9..17e4d20b5 100644 --- a/src/laybasic/laybasic/layLayoutView.h +++ b/src/laybasic/laybasic/layLayoutView.h @@ -918,13 +918,13 @@ public: * @param linewidth The width of a line in pixels (usually 1) or 0 for default * @param oversampling The oversampling factor (1..3) or 0 for default * @param resolution The resolution (pixel size compared to a screen pixel size, i.e 1/oversampling) or 0 for default - * @param background The background color or QColor() for default - * @param foreground The foreground color or QColor() for default - * @param active The active color or QColor() for default + * @param background The background color or lay::Color() for default + * @param foreground The foreground color or lay::Color() for default + * @param active The active color or lay::Color() for default * @param target_box The box to draw or db::DBox() for default * @param monochrome If true, monochrome images will be produced */ - void save_image_with_options (const std::string &fn, unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, QColor background, QColor foreground, QColor active_color, const db::DBox &target_box, bool monochrome); + void save_image_with_options (const std::string &fn, unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, Color background, Color foreground, Color active_color, const db::DBox &target_box, bool monochrome); /** * @brief Get the screen content as a QImage object with the given width and height @@ -939,13 +939,13 @@ public: * @param linewidth The width of a line in pixels (usually 1) or 0 for default * @param oversampling The oversampling factor (1..3) or 0 for default * @param resolution The resolution (pixel size compared to a screen pixel size, i.e 1/oversampling) or 0 for default - * @param background The background color or QColor() for default - * @param foreground The foreground color or QColor() for default - * @param active The active color or QColor() for default + * @param background The background color or lay::Color() for default + * @param foreground The foreground color or lay::Color() for default + * @param active The active color or lay::Color() for default * @param target_box The box to draw or db::DBox() for default * @param monochrome If true, monochrome images will be produced */ - QImage get_image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, QColor background, QColor foreground, QColor active_color, const db::DBox &target_box, bool monochrome); + QImage get_image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, lay::Color background, lay::Color foreground, lay::Color active_color, const db::DBox &target_box, bool monochrome); /** * @brief Hierarchy level selection setter @@ -1002,12 +1002,12 @@ public: /** * @brief Cell box/label color setter */ - void cell_box_color (QColor c); + void cell_box_color (lay::Color c); /** * @brief Cell box/label getter */ - QColor cell_box_color () const + lay::Color cell_box_color () const { return m_box_color; } @@ -1200,12 +1200,12 @@ public: /** * @brief Text object color */ - void text_color (QColor c); + void text_color (lay::Color c); /** * @brief Text object color */ - QColor text_color () const + lay::Color text_color () const { return m_text_color; } @@ -1811,7 +1811,7 @@ public: /** * @brief Background color property */ - QColor background_color () const + lay::Color background_color () const { return mp_canvas->background_color (); } @@ -1819,7 +1819,7 @@ public: /** * @brief Foreground color property */ - QColor foreground_color () const + lay::Color foreground_color () const { return mp_canvas->foreground_color (); } @@ -1827,7 +1827,7 @@ public: /** * @brief Active color property */ - QColor active_color () const + lay::Color active_color () const { return mp_canvas->active_color (); } @@ -1887,7 +1887,7 @@ public: /** * @brief Gets the guiding shapes color */ - QColor guiding_shapes_color () const + lay::Color guiding_shapes_color () const { return m_guiding_shape_color; } @@ -1895,7 +1895,7 @@ public: /** * @brief Sets the guiding shapes color */ - void guiding_shapes_color (QColor c); + void guiding_shapes_color (lay::Color c); /** * @brief Gets the guiding shapes line width @@ -2231,7 +2231,7 @@ public: /** * @brief Get the default color for markers */ - QColor default_marker_color () const + lay::Color default_marker_color () const { return m_marker_color; } @@ -2791,15 +2791,15 @@ private: int m_paste_display_mode; int m_wheel_mode; bool m_guiding_shape_visible; - QColor m_guiding_shape_color; + lay::Color m_guiding_shape_color; int m_guiding_shape_line_width; int m_guiding_shape_vertex_size; - QColor m_ctx_color; + lay::Color m_ctx_color; int m_ctx_dimming; bool m_ctx_hollow; - QColor m_child_ctx_color; + lay::Color m_child_ctx_color; int m_child_ctx_dimming; bool m_child_ctx_hollow; bool m_child_ctx_enabled; @@ -2807,13 +2807,13 @@ private: double m_abstract_mode_width; bool m_abstract_mode_enabled; - QColor m_box_color; + lay::Color m_box_color; bool m_box_text_transform; unsigned int m_box_font; int m_min_size_for_label; bool m_cell_box_visible; - QColor m_marker_color; + lay::Color m_marker_color; int m_marker_line_width; int m_marker_vertex_size; int m_marker_dither_pattern; @@ -2831,7 +2831,7 @@ private: bool m_text_lazy_rendering; bool m_bitmap_caching; bool m_show_properties; - QColor m_text_color; + lay::Color m_text_color; bool m_apply_text_trans; double m_default_text_size; unsigned int m_text_font; @@ -2892,11 +2892,11 @@ private: void do_redraw (int layer); void do_redraw (); - void background_color (QColor c); - void ctx_color (QColor c); + void background_color (lay::Color c); + void ctx_color (lay::Color c); void ctx_dimming (int percent); void ctx_hollow (bool h); - void child_ctx_color (QColor c); + void child_ctx_color (lay::Color c); void child_ctx_dimming (int percent); void child_ctx_hollow (bool h); void child_ctx_enabled (bool e); diff --git a/src/laybasic/laybasic/layLibrariesView.cc b/src/laybasic/laybasic/layLibrariesView.cc index 4b1246666..0849a306b 100644 --- a/src/laybasic/laybasic/layLibrariesView.cc +++ b/src/laybasic/laybasic/layLibrariesView.cc @@ -489,23 +489,23 @@ LibrariesView::double_clicked (const QModelIndex & /*index*/) } void -LibrariesView::set_background_color (QColor c) +LibrariesView::set_background_color (lay::Color c) { m_background_color = c; for (std::vector ::const_iterator f = mp_cell_lists.begin (); f != mp_cell_lists.end (); ++f) { QPalette pl ((*f)->palette ()); - pl.setColor (QPalette::Base, c); + pl.setColor (QPalette::Base, QColor (c.rgb ())); (*f)->setPalette (pl); } } void -LibrariesView::set_text_color (QColor c) +LibrariesView::set_text_color (lay::Color c) { m_text_color = c; for (std::vector ::const_iterator f = mp_cell_lists.begin (); f != mp_cell_lists.end (); ++f) { QPalette pl ((*f)->palette ()); - pl.setColor (QPalette::Text, c); + pl.setColor (QPalette::Text, QColor (c.rgb ())); (*f)->setPalette (pl); } } @@ -637,11 +637,11 @@ LibrariesView::do_update_content (int lib_index) cell_list->setUniformRowHeights (true); pl = cell_list->palette (); - if (m_text_color.isValid ()) { - pl.setColor (QPalette::Text, m_text_color); + if (m_text_color.is_valid ()) { + pl.setColor (QPalette::Text, QColor (m_text_color.rgb ())); } - if (m_background_color.isValid ()) { - pl.setColor (QPalette::Base, m_background_color); + if (m_background_color.is_valid ()) { + pl.setColor (QPalette::Base, QColor (m_background_color.rgb ())); } cell_list->setPalette (pl); diff --git a/src/laybasic/laybasic/layLibrariesView.h b/src/laybasic/laybasic/layLibrariesView.h index 3b12f3a20..48b650583 100644 --- a/src/laybasic/laybasic/layLibrariesView.h +++ b/src/laybasic/laybasic/layLibrariesView.h @@ -122,12 +122,12 @@ public: /** * @brief Changing of the background color */ - void set_background_color (QColor c); + void set_background_color (lay::Color c); /** * @brief Changing of the text color */ - void set_text_color (QColor c); + void set_text_color (lay::Color c); /** * @brief Sets the active library by name @@ -247,8 +247,8 @@ private: QFrame *mp_search_frame; QCheckBox *mp_search_close_cb; QSplitter *mp_splitter; - QColor m_background_color; - QColor m_text_color; + lay::Color m_background_color; + lay::Color m_text_color; tl::DeferredMethod m_do_update_content_dm; tl::DeferredMethod m_do_full_update_content_dm; std::unique_ptr mp_tree_style; diff --git a/src/laybasic/laybasic/layMarker.cc b/src/laybasic/laybasic/layMarker.cc index ac08e6d95..8e1f7ab7d 100644 --- a/src/laybasic/laybasic/layMarker.cc +++ b/src/laybasic/laybasic/layMarker.cc @@ -196,7 +196,7 @@ MarkerBase::MarkerBase (lay::LayoutView *view) } void -MarkerBase::set_frame_color (QColor color) +MarkerBase::set_frame_color (lay::Color color) { if (color != m_frame_color) { m_frame_color = color; @@ -205,7 +205,7 @@ MarkerBase::set_frame_color (QColor color) } void -MarkerBase::set_color (QColor color) +MarkerBase::set_color (lay::Color color) { if (color != m_color) { m_color = color; @@ -292,16 +292,16 @@ MarkerBase::get_bitmaps (const Viewport & /*vp*/, ViewObjectCanvas &canvas, lay: int basic_width = int(0.5 + 1.0 / resolution); // obtain bitmaps - QColor color = m_color; - if (! color.isValid ()) { + lay::Color color = m_color; + if (! color.is_valid ()) { color = mp_view->default_marker_color (); } - if (! color.isValid ()) { + if (! color.is_valid ()) { color = canvas.foreground_color (); } - QColor frame_color = m_frame_color; - if (! frame_color.isValid ()) { + lay::Color frame_color = m_frame_color; + if (! frame_color.is_valid ()) { frame_color = color; } diff --git a/src/laybasic/laybasic/layMarker.h b/src/laybasic/laybasic/layMarker.h index c3a140a87..7b18deab6 100644 --- a/src/laybasic/laybasic/layMarker.h +++ b/src/laybasic/laybasic/layMarker.h @@ -41,8 +41,6 @@ #include "dbArray.h" #include "gsi.h" -#include - namespace lay { @@ -68,7 +66,7 @@ public: * * If the color is invalid, the marker is drawn with the canvases foreground color. */ - QColor get_color () const + lay::Color get_color () const { return m_color; } @@ -78,14 +76,14 @@ public: * * If the color is invalid, the marker is drawn with the canvases foreground color. */ - void set_color (QColor color); + void set_color (lay::Color color); /** * @brief Get the color by which the marker's frame is drawn * * If the color is invalid, the marker's frame is drawn with the fill color. */ - QColor get_frame_color () const + lay::Color get_frame_color () const { return m_frame_color; } @@ -95,7 +93,7 @@ public: * * If the color is invalid, the marker's frame is drawn with the fill color. */ - void set_frame_color (QColor color); + void set_frame_color (lay::Color color); /** * @brief Get the line width with which the marker is drawn @@ -228,8 +226,8 @@ public: protected: void get_bitmaps (const Viewport &vp, ViewObjectCanvas &canvas, lay::CanvasPlane *&fill, lay::CanvasPlane *&frame, lay::CanvasPlane *&vertex, lay::CanvasPlane *&text); - QColor m_color; - QColor m_frame_color; + lay::Color m_color; + lay::Color m_frame_color; char m_line_width, m_vertex_size, m_halo; bool m_text_enabled; lay::ViewOp::Shape m_vertex_shape; diff --git a/src/laybasic/laybasic/layNetlistBrowserDialog.cc b/src/laybasic/laybasic/layNetlistBrowserDialog.cc index 4ecf301b4..820ebdf32 100644 --- a/src/laybasic/laybasic/layNetlistBrowserDialog.cc +++ b/src/laybasic/laybasic/layNetlistBrowserDialog.cc @@ -555,7 +555,7 @@ NetlistBrowserDialog::configure (const std::string &name, const std::string &val } else if (name == cfg_l2ndb_marker_color) { - QColor color; + lay::Color color; if (! value.empty ()) { lay::ColorConverter ().from_string (value, color); } diff --git a/src/laybasic/laybasic/layNetlistBrowserDialog.h b/src/laybasic/laybasic/layNetlistBrowserDialog.h index b8e929cfa..ebebe1c14 100644 --- a/src/laybasic/laybasic/layNetlistBrowserDialog.h +++ b/src/laybasic/laybasic/layNetlistBrowserDialog.h @@ -119,7 +119,7 @@ private: lay::NetlistBrowserConfig::net_window_type m_window; double m_window_dim; unsigned int m_max_shape_count; - QColor m_marker_color; + lay::Color m_marker_color; lay::ColorPalette m_auto_colors; bool m_auto_color_enabled; int m_marker_line_width; diff --git a/src/laybasic/laybasic/layNetlistBrowserModel.cc b/src/laybasic/laybasic/layNetlistBrowserModel.cc index 61126be03..82e5f05a4 100644 --- a/src/laybasic/laybasic/layNetlistBrowserModel.cc +++ b/src/laybasic/laybasic/layNetlistBrowserModel.cc @@ -111,7 +111,7 @@ NetColorizer::NetColorizer () } void -NetColorizer::configure (const QColor &marker_color, const lay::ColorPalette *auto_colors) +NetColorizer::configure (const lay::Color &marker_color, const lay::ColorPalette *auto_colors) { m_marker_color = marker_color; if (auto_colors) { @@ -131,7 +131,7 @@ NetColorizer::has_color_for_net (const db::Net *net) } void -NetColorizer::set_color_of_net (const db::Net *net, const QColor &color) +NetColorizer::set_color_of_net (const db::Net *net, const lay::Color &color) { m_custom_color[net] = color; emit_colors_changed (); @@ -183,14 +183,14 @@ NetColorizer::emit_colors_changed () } } -QColor +lay::Color NetColorizer::color_of_net (const db::Net *net) const { if (! net) { - return QColor (); + return lay::Color (); } - std::map::const_iterator c = m_custom_color.find (net); + std::map::const_iterator c = m_custom_color.find (net); if (c != m_custom_color.end ()) { return c->second; } @@ -219,7 +219,7 @@ NetColorizer::color_of_net (const db::Net *net) const return m_auto_colors.color_by_index ((unsigned int) index); } else { - return QColor (); + return lay::Color (); } } @@ -823,9 +823,9 @@ static QIcon icon_for_subcircuit () return icon; } -static QIcon colored_icon (const QColor &color, const QIcon &original_icon) +static QIcon colored_icon (const lay::Color &color, const QIcon &original_icon) { - if (! color.isValid ()) { + if (! color.is_valid ()) { return icon_for_net (); } @@ -857,12 +857,12 @@ static QIcon colored_icon (const QColor &color, const QIcon &original_icon) return colored_icon; } -static QIcon net_icon_with_color (const QColor &color) +static QIcon net_icon_with_color (const lay::Color &color) { return colored_icon (color, light_icon_for_net ()); } -static QIcon connection_icon_with_color (const QColor &color) +static QIcon connection_icon_with_color (const lay::Color &color) { return colored_icon (color, light_icon_for_connection ()); } @@ -2869,7 +2869,7 @@ NetlistBrowserModel::icon_for_nets (const std::pairhas_color_for_net (net)) { - QColor color = mp_colorizer->color_of_net (net); + lay::Color color = mp_colorizer->color_of_net (net); lay::color_t rgb = lay::color_t (color.rgb ()); std::map::const_iterator c = m_net_icon_per_color.find (rgb); @@ -2891,7 +2891,7 @@ NetlistBrowserModel::icon_for_connection (const std::pairhas_color_for_net (net)) { - QColor color = mp_colorizer->color_of_net (net); + lay::Color color = mp_colorizer->color_of_net (net); lay::color_t rgb = lay::color_t (color.rgb ()); std::map::const_iterator c = m_connection_icon_per_color.find (rgb); diff --git a/src/laybasic/laybasic/layNetlistBrowserModel.h b/src/laybasic/laybasic/layNetlistBrowserModel.h index 005664a6f..b18c4bbe7 100644 --- a/src/laybasic/laybasic/layNetlistBrowserModel.h +++ b/src/laybasic/laybasic/layNetlistBrowserModel.h @@ -25,6 +25,7 @@ #define HDR_layNetlistBrowserModel #include "layColorPalette.h" +#include "layColor.h" #include "laybasicCommon.h" #include "dbLayoutToNetlist.h" @@ -34,7 +35,6 @@ #include "tlTypeTraits.h" #include -#include #include #include @@ -57,15 +57,15 @@ Q_OBJECT public: NetColorizer (); - void configure (const QColor &marker_color, const lay::ColorPalette *auto_colors); + void configure (const lay::Color &marker_color, const lay::ColorPalette *auto_colors); bool has_color_for_net (const db::Net *net); - void set_color_of_net (const db::Net *net, const QColor &color); + void set_color_of_net (const db::Net *net, const Color &color); void reset_color_of_net (const db::Net *net); void clear (); - QColor color_of_net (const db::Net *net) const; + lay::Color color_of_net (const db::Net *net) const; - const QColor &marker_color () const + const lay::Color &marker_color () const { return m_marker_color; } @@ -77,10 +77,10 @@ signals: void colors_changed (); private: - QColor m_marker_color; + lay::Color m_marker_color; lay::ColorPalette m_auto_colors; bool m_auto_colors_enabled; - std::map m_custom_color; + std::map m_custom_color; bool m_update_needed; bool m_signals_enabled; mutable std::map m_net_index_by_object; diff --git a/src/laybasic/laybasic/layNetlistBrowserPage.cc b/src/laybasic/laybasic/layNetlistBrowserPage.cc index f69b537d7..ef1fdc4f0 100644 --- a/src/laybasic/laybasic/layNetlistBrowserPage.cc +++ b/src/laybasic/laybasic/layNetlistBrowserPage.cc @@ -229,7 +229,7 @@ NetlistBrowserPage::set_dispatcher (lay::Dispatcher *pr) } void -NetlistBrowserPage::set_highlight_style (QColor color, int line_width, int vertex_size, int halo, int dither_pattern, int marker_intensity, bool use_original_colors, const lay::ColorPalette *auto_colors) +NetlistBrowserPage::set_highlight_style (lay::Color color, int line_width, int vertex_size, int halo, int dither_pattern, int marker_intensity, bool use_original_colors, const lay::ColorPalette *auto_colors) { m_colorizer.configure (color, auto_colors); m_marker_line_width = line_width; @@ -492,13 +492,13 @@ NetlistBrowserPage::selection_changed () } void -NetlistBrowserPage::set_color_for_selected_nets (const QColor &color) +NetlistBrowserPage::set_color_for_selected_nets (const lay::Color &color) { std::vector nets = selected_nets (); m_colorizer.begin_changes (); for (std::vector::const_iterator n = nets.begin (); n != nets.end (); ++n) { - if (color.isValid ()) { + if (color.is_valid ()) { m_colorizer.set_color_of_net (*n, color); } else { m_colorizer.reset_color_of_net (*n); @@ -514,7 +514,7 @@ NetlistBrowserPage::browse_color_for_net () { QColor c = QColorDialog::getColor (QColor (), this); if (c.isValid ()) { - set_color_for_selected_nets (c); + set_color_for_selected_nets (lay::Color (c.rgb ())); } } @@ -523,7 +523,7 @@ NetlistBrowserPage::select_color_for_net () { QAction *action = dynamic_cast (sender ()); if (action) { - set_color_for_selected_nets (action->data ().value ()); + set_color_for_selected_nets (lay::Color (action->data ().value ().rgb ())); } } @@ -1095,11 +1095,11 @@ NetlistBrowserPage::adjust_view () } } -QColor -NetlistBrowserPage::make_valid_color (const QColor &color) +lay::Color +NetlistBrowserPage::make_valid_color (const lay::Color &color) { - if (! color.isValid () && mp_view) { - return mp_view->background_color ().green () < 128 ? QColor (Qt::white) : QColor (Qt::black); + if (! color.is_valid () && mp_view) { + return mp_view->background_color ().green () < 128 ? lay::Color (255, 255, 255) : lay::Color (0, 0, 0); } else { return color; } @@ -1110,7 +1110,7 @@ NetlistBrowserPage::produce_highlights_for_device (const db::Device *device, siz { const db::Layout *layout = mp_database->internal_layout (); - QColor color = make_valid_color (m_colorizer.marker_color ()); + lay::Color color = make_valid_color (m_colorizer.marker_color ()); db::Box device_bbox = bbox_for_device_abstract (layout, device->device_abstract (), device->trans ()); if (! device_bbox.empty ()) { @@ -1159,7 +1159,7 @@ NetlistBrowserPage::produce_highlights_for_circuit (const db::Circuit *circuit, { const db::Layout *layout = mp_database->internal_layout (); - QColor color = make_valid_color (m_colorizer.marker_color ()); + lay::Color color = make_valid_color (m_colorizer.marker_color ()); db::Box circuit_bbox = bbox_for_circuit (layout, circuit); if (circuit_bbox.empty ()) { return false; @@ -1188,8 +1188,8 @@ NetlistBrowserPage::produce_highlights_for_net (const db::Net *net, size_t &n_ma db::cell_index_type cell_index = net->circuit ()->cell_index (); size_t cluster_id = net->cluster_id (); - QColor net_color = m_colorizer.color_of_net (net); - QColor fallback_color = make_valid_color (m_colorizer.marker_color ()); + lay::Color net_color = m_colorizer.color_of_net (net); + lay::Color fallback_color = make_valid_color (m_colorizer.marker_color ()); const db::Connectivity &conn = mp_database->connectivity (); for (db::Connectivity::layer_iterator layer = conn.begin_layers (); layer != conn.end_layers (); ++layer) { @@ -1212,7 +1212,7 @@ NetlistBrowserPage::produce_highlights_for_net (const db::Net *net, size_t &n_ma mp_markers.push_back (new lay::Marker (mp_view, m_cv_index)); mp_markers.back ()->set (shapes->polygon_ref (), shapes.trans (), tv); - if (net_color.isValid ()) { + if (net_color.is_valid ()) { mp_markers.back ()->set_color (net_color); mp_markers.back ()->set_frame_color (net_color); diff --git a/src/laybasic/laybasic/layNetlistBrowserPage.h b/src/laybasic/laybasic/layNetlistBrowserPage.h index 77cf489e7..d11f126e9 100644 --- a/src/laybasic/laybasic/layNetlistBrowserPage.h +++ b/src/laybasic/laybasic/layNetlistBrowserPage.h @@ -141,7 +141,7 @@ public: * @param halo The halo flag or -1 for default * @param dither_pattern The dither pattern index of -1 to take the default */ - void set_highlight_style (QColor color, int line_width, int vertex_size, int halo, int dither_pattern, int marker_intensity, bool use_original_colors, const lay::ColorPalette *auto_colors); + void set_highlight_style (lay::Color color, int line_width, int vertex_size, int halo, int dither_pattern, int marker_intensity, bool use_original_colors, const lay::ColorPalette *auto_colors); /** * @brief Gets a value indicating whether all items in the netlist tree are shown (specifically for cross-reference DBs) @@ -253,9 +253,9 @@ private: std::vector selected_devices (); std::vector selected_subcircuits (); std::vector selected_circuits (); - void set_color_for_selected_nets (const QColor &color); + void set_color_for_selected_nets (const lay::Color &color); void layer_list_changed (int); - QColor make_valid_color (const QColor &color); + lay::Color make_valid_color (const lay::Color &color); bool produce_highlights_for_net(const db::Net *net, size_t &n_markers, const std::map &display_by_lp, const std::vector &tv); bool produce_highlights_for_device (const db::Device *device, size_t &n_markers, const std::vector &tv); bool produce_highlights_for_circuit (const db::Circuit *circuit, size_t &n_markers, const std::vector &tv); diff --git a/src/laybasic/laybasic/layRedrawThreadCanvas.cc b/src/laybasic/laybasic/layRedrawThreadCanvas.cc index 94125b20a..b6d2964f4 100644 --- a/src/laybasic/laybasic/layRedrawThreadCanvas.cc +++ b/src/laybasic/laybasic/layRedrawThreadCanvas.cc @@ -394,7 +394,7 @@ BitmapRedrawThreadCanvas::initialize_plane (lay::CanvasPlane *plane, unsigned in } void -BitmapRedrawThreadCanvas::to_image (const std::vector &view_ops, const lay::DitherPattern &dp, const lay::LineStyles &ls, QColor background, QColor foreground, QColor active, const lay::Drawings *drawings, QImage &img, unsigned int width, unsigned int height) +BitmapRedrawThreadCanvas::to_image (const std::vector &view_ops, const lay::DitherPattern &dp, const lay::LineStyles &ls, lay::Color background, lay::Color foreground, lay::Color active, const lay::Drawings *drawings, QImage &img, unsigned int width, unsigned int height) { if (width > m_width) { width = m_width; diff --git a/src/laybasic/laybasic/layRedrawThreadCanvas.h b/src/laybasic/laybasic/layRedrawThreadCanvas.h index b765b3fcd..abaf8085b 100644 --- a/src/laybasic/laybasic/layRedrawThreadCanvas.h +++ b/src/laybasic/laybasic/layRedrawThreadCanvas.h @@ -322,7 +322,7 @@ public: /** * @brief Transfer the content to an QImage */ - void to_image (const std::vector &view_ops, const lay::DitherPattern &dp, const lay::LineStyles &ls, QColor background, QColor foreground, QColor active, const lay::Drawings *drawings, QImage &img, unsigned int width, unsigned int height); + void to_image (const std::vector &view_ops, const lay::DitherPattern &dp, const lay::LineStyles &ls, lay::Color background, lay::Color foreground, lay::Color active, const lay::Drawings *drawings, QImage &img, unsigned int width, unsigned int height); /** * @brief Gets the current bitmap data as a BitmapCanvasData object diff --git a/src/laybasic/laybasic/laySelector.cc b/src/laybasic/laybasic/laySelector.cc index 1c85416c1..e1dea2f3b 100644 --- a/src/laybasic/laybasic/laySelector.cc +++ b/src/laybasic/laybasic/laySelector.cc @@ -62,7 +62,7 @@ SelectionService::~SelectionService () } void -SelectionService::set_colors (QColor /*background*/, QColor color) +SelectionService::set_colors (lay::Color /*background*/, lay::Color color) { m_color = color.rgb (); if (mp_box) { diff --git a/src/laybasic/laybasic/laySelector.h b/src/laybasic/laybasic/laySelector.h index 85ba64d76..b7f5f5e22 100644 --- a/src/laybasic/laybasic/laySelector.h +++ b/src/laybasic/laybasic/laySelector.h @@ -49,7 +49,7 @@ public: SelectionService (lay::LayoutView *view); ~SelectionService (); - void set_colors (QColor background, QColor color); + void set_colors (lay::Color background, lay::Color color); void begin (const db::DPoint &pos); bool dragging () const { return mp_box != 0; } diff --git a/src/laybasic/laybasic/layViewObject.h b/src/laybasic/laybasic/layViewObject.h index 3e10c0b0d..f69ad4efc 100644 --- a/src/laybasic/laybasic/layViewObject.h +++ b/src/laybasic/laybasic/layViewObject.h @@ -373,7 +373,7 @@ public: /** * @brief This method is called to set the background and text (foreground) color */ - virtual void set_colors (QColor /*background*/, QColor /*text*/) { } + virtual void set_colors (lay::Color /*background*/, lay::Color /*text*/) { } /** * @brief This method is called when a drag operation should be cancelled @@ -1152,17 +1152,17 @@ public: /** * @brief Background color property: background color of the canvas */ - virtual QColor background_color () const = 0; + virtual lay::Color background_color () const = 0; /** * @brief Foreground color property: foreground color of the canvas (some "contrast" color to background) */ - virtual QColor foreground_color () const = 0; + virtual lay::Color foreground_color () const = 0; /** * @brief Active color property: color of active elements on the canvas (some "contrast" color to background and different from foreground) */ - virtual QColor active_color () const = 0; + virtual lay::Color active_color () const = 0; /** * @brief Get the resolution diff --git a/src/laybasic/laybasic/layZoomBox.cc b/src/laybasic/laybasic/layZoomBox.cc index 50af13b8a..bef7e40f2 100644 --- a/src/laybasic/laybasic/layZoomBox.cc +++ b/src/laybasic/laybasic/layZoomBox.cc @@ -54,7 +54,7 @@ ZoomService::drag_cancel () } void -ZoomService::set_colors (QColor /*background*/, QColor color) +ZoomService::set_colors (lay::Color /*background*/, lay::Color color) { m_color = color.rgb (); if (mp_box) { diff --git a/src/laybasic/laybasic/layZoomBox.h b/src/laybasic/laybasic/layZoomBox.h index 27fb82ff8..a0a497a83 100644 --- a/src/laybasic/laybasic/layZoomBox.h +++ b/src/laybasic/laybasic/layZoomBox.h @@ -41,7 +41,7 @@ public: ZoomService (lay::LayoutView *view); ~ZoomService (); - void set_colors (QColor background, QColor text); + void set_colors (lay::Color background, lay::Color text); void begin (const db::DPoint &pos); void begin_pan (const db::DPoint &pos); diff --git a/src/laybasic/laybasic/rdbMarkerBrowserDialog.cc b/src/laybasic/laybasic/rdbMarkerBrowserDialog.cc index 76baf7e1d..c85b40024 100644 --- a/src/laybasic/laybasic/rdbMarkerBrowserDialog.cc +++ b/src/laybasic/laybasic/rdbMarkerBrowserDialog.cc @@ -474,7 +474,7 @@ MarkerBrowserDialog::configure (const std::string &name, const std::string &valu } else if (name == cfg_rdb_marker_color) { - QColor color; + lay::Color color; if (! value.empty ()) { lay::ColorConverter ().from_string (value, color); } diff --git a/src/laybasic/laybasic/rdbMarkerBrowserDialog.h b/src/laybasic/laybasic/rdbMarkerBrowserDialog.h index b15dd5369..5e0bd782e 100644 --- a/src/laybasic/laybasic/rdbMarkerBrowserDialog.h +++ b/src/laybasic/laybasic/rdbMarkerBrowserDialog.h @@ -73,7 +73,7 @@ private: window_type m_window; double m_window_dim; unsigned int m_max_marker_count; - QColor m_marker_color; + lay::Color m_marker_color; int m_marker_line_width; int m_marker_vertex_size; int m_marker_halo; diff --git a/src/laybasic/laybasic/rdbMarkerBrowserPage.cc b/src/laybasic/laybasic/rdbMarkerBrowserPage.cc index 1342fa14b..df28158db 100644 --- a/src/laybasic/laybasic/rdbMarkerBrowserPage.cc +++ b/src/laybasic/laybasic/rdbMarkerBrowserPage.cc @@ -1609,7 +1609,7 @@ MarkerBrowserPage::set_dispatcher (lay::Dispatcher *pr) } void -MarkerBrowserPage::set_marker_style (QColor color, int line_width, int vertex_size, int halo, int dither_pattern) +MarkerBrowserPage::set_marker_style (lay::Color color, int line_width, int vertex_size, int halo, int dither_pattern) { m_marker_color = color; m_marker_line_width = line_width; diff --git a/src/laybasic/laybasic/rdbMarkerBrowserPage.h b/src/laybasic/laybasic/rdbMarkerBrowserPage.h index a4d82da0c..f879884a6 100644 --- a/src/laybasic/laybasic/rdbMarkerBrowserPage.h +++ b/src/laybasic/laybasic/rdbMarkerBrowserPage.h @@ -27,6 +27,7 @@ #include "ui_MarkerBrowserPage.h" #include "rdbMarkerBrowser.h" #include "tlDeferredExecution.h" +#include "layColor.h" #include "dbBox.h" #include @@ -136,7 +137,7 @@ public: * @param halo The halo flag or -1 for default * @param dither_pattern The dither pattern index of -1 to take the default */ - void set_marker_style (QColor color, int line_width, int vertex_size, int halo, int dither_pattern); + void set_marker_style (lay::Color color, int line_width, int vertex_size, int halo, int dither_pattern); /** * @brief Enable or disable updates @@ -195,7 +196,7 @@ private: rdb::window_type m_window; double m_window_dim; size_t m_max_marker_count; - QColor m_marker_color; + lay::Color m_marker_color; int m_marker_line_width; int m_marker_vertex_size; int m_marker_halo; diff --git a/src/laybasic/unit_tests/layColorTests.cc b/src/laybasic/unit_tests/layColorTests.cc index c90b0d722..c1d44c744 100644 --- a/src/laybasic/unit_tests/layColorTests.cc +++ b/src/laybasic/unit_tests/layColorTests.cc @@ -81,6 +81,10 @@ TEST(4) TEST(5) { EXPECT_EQ (lay::Color ("#80102030").is_valid (), true); + EXPECT_EQ (lay::Color ("#80102030").alpha (), 128); + EXPECT_EQ (lay::Color ("#80102030").red (), 16); + EXPECT_EQ (lay::Color ("#80102030").green (), 32); + EXPECT_EQ (lay::Color ("#80102030").blue (), 48); EXPECT_EQ (lay::Color ("#80102030").to_string (), "#80102030"); EXPECT_EQ (lay::Color ("#80102030").rgb (), 0x80102030); diff --git a/src/plugins/tools/net_tracer/db_plugin/dbNetTracerIO.cc b/src/plugins/tools/net_tracer/db_plugin/dbNetTracerIO.cc index f175b1c82..f77581b7b 100644 --- a/src/plugins/tools/net_tracer/db_plugin/dbNetTracerIO.cc +++ b/src/plugins/tools/net_tracer/db_plugin/dbNetTracerIO.cc @@ -339,13 +339,13 @@ NetTracerSymbolInfo::parse (tl::Extractor &ex) // Net implementation NetTracerNet::NetTracerNet () - : m_dbu (0.001), m_incomplete (true), m_trace_path (false) + : m_dbu (0.001), m_incomplete (true), m_color (0), m_trace_path (false) { // .. nothing yet .. } NetTracerNet::NetTracerNet (const NetTracer &tracer, const db::ICplxTrans &trans, const db::Layout &layout, db::cell_index_type cell_index, const std::string &layout_filename, const std::string &layout_name, const NetTracerData &data) - : m_name (tracer.name ()), m_incomplete (tracer.incomplete ()), m_trace_path (false) + : m_name (tracer.name ()), m_incomplete (tracer.incomplete ()), m_color (0), m_trace_path (false) { m_dbu = layout.dbu (); m_top_cell_name = layout.cell_name (cell_index); diff --git a/src/plugins/tools/net_tracer/db_plugin/dbNetTracerIO.h b/src/plugins/tools/net_tracer/db_plugin/dbNetTracerIO.h index 2262bcf7e..ec98182e2 100644 --- a/src/plugins/tools/net_tracer/db_plugin/dbNetTracerIO.h +++ b/src/plugins/tools/net_tracer/db_plugin/dbNetTracerIO.h @@ -196,11 +196,10 @@ public: return m_net_shapes.size (); } -#if defined(HAVE_QT) /** * @brief Gets the color in which the net is drawn */ - QColor color () const + uint32_t color () const { return m_color; } @@ -208,11 +207,10 @@ public: /** * @brief Sets the color in which the net is drawn */ - void set_color (QColor c) + void set_color (uint32_t c) { m_color = c; } -#endif /** * @brief Get a name for the net @@ -355,9 +353,7 @@ private: db::Shapes m_shapes; std::map > m_layers; std::map m_cell_names; -#if defined(HAVE_QT) - QColor m_color; -#endif + uint32_t m_color; db::DBox m_start_search_box, m_stop_search_box; bool m_trace_path; diff --git a/src/plugins/tools/net_tracer/lay_plugin/layNetTracerDialog.cc b/src/plugins/tools/net_tracer/lay_plugin/layNetTracerDialog.cc index cf543dfa2..132d46a4a 100644 --- a/src/plugins/tools/net_tracer/lay_plugin/layNetTracerDialog.cc +++ b/src/plugins/tools/net_tracer/lay_plugin/layNetTracerDialog.cc @@ -187,7 +187,7 @@ NetTracerDialog::mouse_click_event (const db::DPoint &p, unsigned int buttons, b // do auto coloring if (m_auto_color_enabled) { if (m_auto_color_index < int (m_auto_colors.colors ())) { - mp_nets.back ()->set_color (QColor (m_auto_colors.color_by_index (m_auto_color_index))); + mp_nets.back ()->set_color (m_auto_colors.color_by_index (m_auto_color_index)); } ++m_auto_color_index; if (m_auto_color_index >= int (m_auto_colors.colors ())) { @@ -476,7 +476,7 @@ NetTracerDialog::configure (const std::string &name, const std::string &value) } else if (name == cfg_nt_marker_color) { - QColor color; + lay::Color color; if (! value.empty ()) { lay::ColorConverter ().from_string (value, color); } @@ -594,7 +594,7 @@ NetTracerDialog::net_color_changed (QColor color) int item_index = net_list->row (*item); if (item_index >= 0 && item_index < int (mp_nets.size ())) { if (color != mp_nets [item_index]->color ()) { - mp_nets [item_index]->set_color (color); + mp_nets [item_index]->set_color (color.rgb ()); changed = true; } } @@ -1092,7 +1092,7 @@ NetTracerDialog::update_list () item->setData (Qt::DisplayRole, tl::to_qstring (mp_nets [i]->name ())); - if (mp_nets [i]->color ().isValid ()) { + if (lay::Color (mp_nets [i]->color ()).is_valid ()) { QPixmap pxmp (icon_size); QPainter pxpainter (&pxmp); @@ -1595,7 +1595,7 @@ NetTracerDialog::update_highlights () std::map llmap; - QColor net_color = mp_nets [item_index]->color (); + lay::Color net_color = mp_nets [item_index]->color (); // Create markers for the shapes for (db::NetTracerNet::iterator net_shape = mp_nets [item_index]->begin (); net_shape != mp_nets [item_index]->end () && n_marker < m_max_marker_count; ++net_shape) { @@ -1648,10 +1648,10 @@ NetTracerDialog::update_highlights () } } - if (net_color.isValid ()) { + if (net_color.is_valid ()) { mp_markers.back ()->set_color (net_color); mp_markers.back ()->set_frame_color (net_color); - } else if (m_marker_color.isValid ()) { + } else if (m_marker_color.is_valid ()) { mp_markers.back ()->set_color (m_marker_color); mp_markers.back ()->set_frame_color (m_marker_color); } diff --git a/src/plugins/tools/net_tracer/lay_plugin/layNetTracerDialog.h b/src/plugins/tools/net_tracer/lay_plugin/layNetTracerDialog.h index 6acf2cf93..4bff2255f 100644 --- a/src/plugins/tools/net_tracer/lay_plugin/layNetTracerDialog.h +++ b/src/plugins/tools/net_tracer/lay_plugin/layNetTracerDialog.h @@ -92,7 +92,7 @@ private: nt_window_type m_window; double m_window_dim; unsigned int m_max_marker_count; - QColor m_marker_color; + lay::Color m_marker_color; int m_marker_line_width; int m_marker_vertex_size; int m_marker_halo; diff --git a/src/plugins/tools/view_25d/lay_plugin/layD25ViewWidget.cc b/src/plugins/tools/view_25d/lay_plugin/layD25ViewWidget.cc index 94e7f2705..9fa1f77d6 100644 --- a/src/plugins/tools/view_25d/lay_plugin/layD25ViewWidget.cc +++ b/src/plugins/tools/view_25d/lay_plugin/layD25ViewWidget.cc @@ -1089,7 +1089,7 @@ D25ViewWidget::paintGL () const qreal retina_scale = devicePixelRatio (); glViewport (0, 0, width () * retina_scale, height () * retina_scale); - QColor c = mp_view->background_color (); + lay::Color c = mp_view->background_color (); float foreground_rgb = (c.green () > 128 ? 0.0f : 1.0f); float ambient = (c.green () > 128 ? 0.8f : 0.25f); float mist_factor = (c.green () > 128 ? 0.2f : 0.4f); From a6f2528aff0f6171dfa883c98fabc5fe8e0f39a8 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Tue, 26 Apr 2022 00:31:10 +0200 Subject: [PATCH 05/88] WIP --- src/edt/edt/edtService.h | 1 - src/laybasic/laybasic/layRedrawThreadCanvas.h | 1 - 2 files changed, 2 deletions(-) diff --git a/src/edt/edt/edtService.h b/src/edt/edt/edtService.h index f084f7a01..2dc67d46a 100644 --- a/src/edt/edt/edtService.h +++ b/src/edt/edt/edtService.h @@ -41,7 +41,6 @@ #include #include -#include namespace lay { class LayerPropertiesConstIterator; diff --git a/src/laybasic/laybasic/layRedrawThreadCanvas.h b/src/laybasic/laybasic/layRedrawThreadCanvas.h index abaf8085b..eb22d4717 100644 --- a/src/laybasic/laybasic/layRedrawThreadCanvas.h +++ b/src/laybasic/laybasic/layRedrawThreadCanvas.h @@ -33,7 +33,6 @@ #include #include -#include class QImage; From 7048dde7b39dd5e518fdec62f6132291345d1f7e Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Wed, 27 Apr 2022 23:03:17 +0200 Subject: [PATCH 06/88] WIP: HSV support in lay::Color --- src/img/img/gsiDeclImg.cc | 4 +- src/img/img/imgObject.cc | 73 +++++++++++++--- src/img/img/imgObject.h | 11 ++- src/img/img/imgPropertiesPage.cc | 26 +++--- src/img/img/imgStream.cc | 6 +- src/img/img/imgWidgets.cc | 97 ++++++++-------------- src/img/img/imgWidgets.h | 15 ++-- src/img/unit_tests/imgFile.cc | 6 +- src/img/unit_tests/imgObject.cc | 6 +- src/laybasic/laybasic/layColor.cc | 79 ++++++++++++++++++ src/laybasic/laybasic/layColor.h | 13 +++ src/laybasic/unit_tests/layColorTests.cc | 101 +++++++++++++++++++++++ 12 files changed, 324 insertions(+), 113 deletions(-) diff --git a/src/img/img/gsiDeclImg.cc b/src/img/img/gsiDeclImg.cc index 27e13f72c..096375845 100644 --- a/src/img/img/gsiDeclImg.cc +++ b/src/img/img/gsiDeclImg.cc @@ -45,12 +45,12 @@ static void clear_colormap (img::DataMapping *dm) static void add_colormap (img::DataMapping *dm, double value, lay::color_t color) { - dm->false_color_nodes.push_back (std::make_pair (value, std::make_pair (QColor (color), QColor (color)))); + dm->false_color_nodes.push_back (std::make_pair (value, std::make_pair (lay::Color (color), lay::Color (color)))); } static void add_colormap2 (img::DataMapping *dm, double value, lay::color_t lcolor, lay::color_t rcolor) { - dm->false_color_nodes.push_back (std::make_pair (value, std::make_pair (QColor (lcolor), QColor (rcolor)))); + dm->false_color_nodes.push_back (std::make_pair (value, std::make_pair (lay::Color (lcolor), lay::Color (rcolor)))); } static size_t num_colormap_entries (const img::DataMapping *dm) diff --git a/src/img/img/imgObject.cc b/src/img/img/imgObject.cc index f8758b9d3..7f265252c 100644 --- a/src/img/img/imgObject.cc +++ b/src/img/img/imgObject.cc @@ -31,6 +31,7 @@ #include "dbPolygonTools.h" #include "tlFileUtils.h" #include "tlUri.h" +#include "tlThreads.h" #include #include @@ -40,7 +41,6 @@ #include #include -#include namespace img { @@ -51,8 +51,8 @@ namespace img DataMapping::DataMapping () : brightness (0.0), contrast (0.0), gamma (1.0), red_gain (1.0), green_gain (1.0), blue_gain (1.0) { - false_color_nodes.push_back (std::make_pair (0.0, std::make_pair (QColor (0, 0, 0), QColor (0, 0, 0)))); - false_color_nodes.push_back (std::make_pair (1.0, std::make_pair (QColor (255, 255, 255), QColor (255, 255, 255)))); + false_color_nodes.push_back (std::make_pair (0.0, std::make_pair (lay::Color (0, 0, 0), lay::Color (0, 0, 0)))); + false_color_nodes.push_back (std::make_pair (1.0, std::make_pair (lay::Color (255, 255, 255), lay::Color (255, 255, 255)))); } bool @@ -192,11 +192,11 @@ DataMapping::create_data_mapping (bool monochrome, double xmin, double xmax, uns for (unsigned int i = 1; i < false_color_nodes.size (); ++i) { - int h1, s1, v1; - false_color_nodes [i - 1].second.second.getHsv (&h1, &s1, &v1); + unsigned int h1, s1, v1; + false_color_nodes [i - 1].second.second.get_hsv (h1, s1, v1); - int h2, s2, v2; - false_color_nodes [i].second.first.getHsv (&h2, &s2, &v2); + unsigned int h2, s2, v2; + false_color_nodes [i].second.first.get_hsv (h2, s2, v2); // The number of steps is chosen such that the full HSV band divides into approximately 200 steps double nsteps = 0.5 * sqrt (double (h1 - h2) * double (h1 - h2) + double (s1 - s2) * double (s1 - s2) + double (v1 - v2) * double (v1 - v2)); @@ -206,7 +206,7 @@ DataMapping::create_data_mapping (bool monochrome, double xmin, double xmax, uns for (int j = 0; j < n; ++j) { - QColor c = interpolated_color (false_color_nodes, x); + lay::Color c = interpolated_color (false_color_nodes, x); double y = 0.0; if (channel == 0) { @@ -260,6 +260,57 @@ DataMapping::create_data_mapping (bool monochrome, double xmin, double xmax, uns return dm; } +// -------------------------------------------------------------------------------------- + +namespace +{ + +struct compare_first_of_node +{ + bool operator() (const std::pair > &a, const std::pair > &b) const + { + return a.first < b.first; + } +}; + +} + +lay::Color +interpolated_color (const DataMapping::false_color_nodes_type &nodes, double x) +{ + if (nodes.size () < 1) { + return lay::Color (); + } else if (nodes.size () < 2) { + return x < nodes[0].first ? nodes[0].second.first : nodes[0].second.second; + } else { + + std::vector > >::const_iterator p = std::lower_bound (nodes.begin (), nodes.end (), std::make_pair (x, std::make_pair (lay::Color (), lay::Color ())), compare_first_of_node ()); + if (p == nodes.end ()) { + return nodes.back ().second.second; + } else if (p == nodes.begin ()) { + return nodes.front ().second.first; + } else { + + double x1 = p[-1].first; + double x2 = p->first; + + unsigned int h1 = 0, s1 = 0, v1 = 0; + p[-1].second.second.get_hsv (h1, s1, v1); + + unsigned int h2 = 0, s2 = 0, v2 = 0; + p->second.first.get_hsv (h2, s2, v2); + + int h = int (0.5 + h1 + double(x - x1) * double (h2 - h1) / double(x2 - x1)); + int s = int (0.5 + s1 + double(x - x1) * double (s2 - s1) / double(x2 - x1)); + int v = int (0.5 + v1 + double(x - x1) * double (v2 - v1) / double(x2 - x1)); + + return lay::Color::from_hsv ((unsigned int) h, (unsigned int) s, (unsigned int) v); + + } + + } +} + // -------------------------------------------------------------------------------------- // img::DataHeader definition and implementation @@ -690,7 +741,7 @@ private: static size_t make_id () { - static QMutex id_lock; + static tl::Mutex id_lock; static size_t s_id_counter = 1; // Get a new Id for the object. Id == 0 is reserved. @@ -1283,7 +1334,7 @@ Object::from_string (const char *str, const char *base_dir) double x = 0.0; lay::ColorConverter cc; - QColor cl, cr; + lay::Color cl, cr; std::string s; m_data_mapping.false_color_nodes.clear (); @@ -1654,7 +1705,7 @@ Object::to_string () const for (unsigned int i = 0; i < data_mapping ().false_color_nodes.size (); ++i) { os << data_mapping ().false_color_nodes[i].first; os << ","; - const std::pair &clr = data_mapping ().false_color_nodes[i].second; + const std::pair &clr = data_mapping ().false_color_nodes[i].second; os << tl::to_word_or_quoted_string (cc.to_string (clr.first)); if (clr.first != clr.second) { os << ","; diff --git a/src/img/img/imgObject.h b/src/img/img/imgObject.h index c5dcdb467..1d3f734e1 100644 --- a/src/img/img/imgObject.h +++ b/src/img/img/imgObject.h @@ -33,13 +33,11 @@ #include "dbMatrix.h" #include "dbPolygon.h" #include "tlDataMapping.h" -#include "layViewOp.h" +#include "layColor.h" #include #include -#include - namespace img { class DataHeader; @@ -52,7 +50,7 @@ class DataHeader; struct IMG_PUBLIC DataMapping { public: - typedef std::vector< std::pair > > false_color_nodes_type; + typedef std::vector< std::pair > > false_color_nodes_type; /** * @brief The constructor @@ -139,6 +137,11 @@ public: tl::DataMappingBase *create_data_mapping (bool monochrome, double xmin, double xmax, unsigned int channel) const; }; +/** + * @brief A helper function to interpolate a color in the color bar at a given x + */ +lay::Color interpolated_color (const DataMapping::false_color_nodes_type &nodes, double x); + /** * @brief A image object * diff --git a/src/img/img/imgPropertiesPage.cc b/src/img/img/imgPropertiesPage.cc index fef5a1fa8..aec31b1b0 100644 --- a/src/img/img/imgPropertiesPage.cc +++ b/src/img/img/imgPropertiesPage.cc @@ -735,9 +735,9 @@ PropertiesPage::blue_spinbox_changed (double value) void PropertiesPage::black_to_white () { - std::vector > > nodes; - nodes.push_back (std::make_pair (0.0, std::make_pair (QColor (0, 0, 0), QColor (0, 0, 0)))); - nodes.push_back (std::make_pair (1.0, std::make_pair (QColor (255, 255, 255), QColor (255, 255, 255)))); + std::vector > > nodes; + nodes.push_back (std::make_pair (0.0, std::make_pair (lay::Color (0, 0, 0), lay::Color (0, 0, 0)))); + nodes.push_back (std::make_pair (1.0, std::make_pair (lay::Color (255, 255, 255), lay::Color (255, 255, 255)))); false_color_control->set_nodes (nodes); emit edited (); } @@ -745,9 +745,9 @@ PropertiesPage::black_to_white () void PropertiesPage::white_to_black () { - std::vector > > nodes; - nodes.push_back (std::make_pair (0.0, std::make_pair (QColor (255, 255, 255), QColor (255, 255, 255)))); - nodes.push_back (std::make_pair (1.0, std::make_pair (QColor (0, 0, 0), QColor (0, 0, 0)))); + std::vector > > nodes; + nodes.push_back (std::make_pair (0.0, std::make_pair (lay::Color (255, 255, 255), lay::Color (255, 255, 255)))); + nodes.push_back (std::make_pair (1.0, std::make_pair (lay::Color (0, 0, 0), lay::Color (0, 0, 0)))); false_color_control->set_nodes (nodes); emit edited (); } @@ -755,9 +755,9 @@ PropertiesPage::white_to_black () void PropertiesPage::red_to_blue () { - std::vector > > nodes; - nodes.push_back (std::make_pair (0.0, std::make_pair (QColor (255, 0, 0), QColor (255, 0, 0)))); - nodes.push_back (std::make_pair (1.0, std::make_pair (QColor (0, 0, 255), QColor (0, 0, 255)))); + std::vector > > nodes; + nodes.push_back (std::make_pair (0.0, std::make_pair (lay::Color (255, 0, 0), lay::Color (255, 0, 0)))); + nodes.push_back (std::make_pair (1.0, std::make_pair (lay::Color (0, 0, 255), lay::Color (0, 0, 255)))); false_color_control->set_nodes (nodes); emit edited (); } @@ -765,9 +765,9 @@ PropertiesPage::red_to_blue () void PropertiesPage::blue_to_red () { - std::vector > > nodes; - nodes.push_back (std::make_pair (0.0, std::make_pair (QColor (0, 0, 255), QColor (0, 0, 255)))); - nodes.push_back (std::make_pair (1.0, std::make_pair (QColor (255, 0, 0), QColor (255, 0, 0)))); + std::vector > > nodes; + nodes.push_back (std::make_pair (0.0, std::make_pair (lay::Color (0, 0, 255), lay::Color (0, 0, 255)))); + nodes.push_back (std::make_pair (1.0, std::make_pair (lay::Color (255, 0, 0), lay::Color (255, 0, 0)))); false_color_control->set_nodes (nodes); emit edited (); } @@ -775,7 +775,7 @@ PropertiesPage::blue_to_red () void PropertiesPage::reverse_color_order () { - std::vector > > nodes (false_color_control->nodes ()); + std::vector > > nodes (false_color_control->nodes ()); for (size_t i = 0; i < nodes.size () / 2; ++i) { std::swap (nodes [i].second.second, nodes [nodes.size () - 1 - i].second.first); std::swap (nodes [i].second.first, nodes [nodes.size () - 1 - i].second.second); diff --git a/src/img/img/imgStream.cc b/src/img/img/imgStream.cc index 72dcb9c21..cb84b63b6 100644 --- a/src/img/img/imgStream.cc +++ b/src/img/img/imgStream.cc @@ -373,7 +373,7 @@ namespace { struct ColorMapConverter { - std::string to_string (const std::pair > &cm) const + std::string to_string (const std::pair > &cm) const { std::string s; s = tl::to_string (cm.first); @@ -389,7 +389,7 @@ namespace { return s; } - void from_string (const std::string &s, std::pair > &cm) const + void from_string (const std::string &s, std::pair > &cm) const { tl::Extractor ex (s.c_str ()); @@ -427,7 +427,7 @@ tl::XMLStruct s_img_structure ("image-data", tl::make_member (&ImageProxy::max_value, &ImageProxy::set_max_value, "max-value") + tl::make_element (&ImageProxy::data_mapping, &ImageProxy::set_data_mapping, "data-mapping", tl::make_element (&img::DataMapping::false_color_nodes, "color-map", - tl::make_member >, img::DataMapping::false_color_nodes_type::const_iterator, img::DataMapping::false_color_nodes_type, ColorMapConverter> (&img::DataMapping::false_color_nodes_type::begin, &img::DataMapping::false_color_nodes_type::end, &img::DataMapping::false_color_nodes_type::push_back, "color-map-entry", ColorMapConverter ()) + tl::make_member >, img::DataMapping::false_color_nodes_type::const_iterator, img::DataMapping::false_color_nodes_type, ColorMapConverter> (&img::DataMapping::false_color_nodes_type::begin, &img::DataMapping::false_color_nodes_type::end, &img::DataMapping::false_color_nodes_type::push_back, "color-map-entry", ColorMapConverter ()) ) + tl::make_member (&img::DataMapping::brightness, "brightness") + tl::make_member (&img::DataMapping::contrast, "contrast") + diff --git a/src/img/img/imgWidgets.cc b/src/img/img/imgWidgets.cc index 587e77322..92952dac5 100644 --- a/src/img/img/imgWidgets.cc +++ b/src/img/img/imgWidgets.cc @@ -44,52 +44,6 @@ const int min_bar_height = 4; const double min_value_interval = 1e-3; const double epsilon = 1e-6; -struct compare_first_of_node -{ - bool operator() (const std::pair > &a, const std::pair > &b) const - { - return a.first < b.first; - } -}; - -QColor -interpolated_color (const std::vector > > &nodes, double x) -{ - if (nodes.size () < 1) { - return QColor (); - } else if (nodes.size () < 2) { - return x < nodes[0].first ? nodes[0].second.first : nodes[0].second.second; - } else { - - std::vector > >::const_iterator p = std::lower_bound (nodes.begin (), nodes.end (), std::make_pair (x, std::make_pair (QColor (), QColor ())), compare_first_of_node ()); - if (p == nodes.end ()) { - return nodes.back ().second.second; - } else if (p == nodes.begin ()) { - return nodes.front ().second.first; - } else { - - double x1 = p[-1].first; - double x2 = p->first; - - int h1 = 0, s1 = 0, v1 = 0; - p[-1].second.second.getHsv (&h1, &s1, &v1); - - int h2 = 0, s2 = 0, v2 = 0; - p->second.first.getHsv (&h2, &s2, &v2); - - int h = int (0.5 + h1 + double(x - x1) * double (h2 - h1) / double(x2 - x1)); - int s = int (0.5 + s1 + double(x - x1) * double (s2 - s1) / double(x2 - x1)); - int v = int (0.5 + v1 + double(x - x1) * double (v2 - v1) / double(x2 - x1)); - - QColor r; - r.setHsv (h, s, v); - return r; - - } - - } -} - // -------------------------------------------------------------------------------------------------------------------- TwoColorWidget::TwoColorWidget (QWidget *parent) @@ -173,8 +127,8 @@ TwoColorWidget::lock_changed (bool checked) ColorBar::ColorBar (QWidget *parent) : QWidget (parent), m_dragging (false), m_selected (-1) { - m_nodes.push_back (std::make_pair (0.0, std::make_pair (QColor (0, 0, 0), QColor (0, 0, 0)))); - m_nodes.push_back (std::make_pair (1.0, std::make_pair (QColor (255, 255, 255), QColor (255, 255, 255)))); + m_nodes.push_back (std::make_pair (0.0, std::make_pair (lay::Color (0, 0, 0), lay::Color (0, 0, 0)))); + m_nodes.push_back (std::make_pair (1.0, std::make_pair (lay::Color (255, 255, 255), lay::Color (255, 255, 255)))); } ColorBar::~ColorBar () @@ -206,7 +160,7 @@ void ColorBar::set_current_color (std::pair c) { if (has_selection ()) { - m_nodes [m_selected].second = c; + m_nodes [m_selected].second = std::make_pair (lay::Color (c.first.rgb ()), lay::Color (c.second.rgb ())); emit color_mapping_changed (); update (); } @@ -260,22 +214,35 @@ ColorBar::keyPressEvent (QKeyEvent *event) } } +namespace +{ + +struct compare_first_of_node +{ + bool operator() (const std::pair > &a, const std::pair > &b) const + { + return a.first < b.first; + } +}; + +} + void -ColorBar::set_nodes (const std::vector > > &nodes) +ColorBar::set_nodes (const std::vector > > &nodes) { m_nodes = nodes; std::sort (m_nodes.begin (), m_nodes.end (), compare_first_of_node ()); if (m_nodes.size () == 0 || fabs (m_nodes[0].first) > epsilon) { - m_nodes.insert (m_nodes.begin (), std::make_pair (0.0, std::make_pair (QColor (0, 0, 0), QColor (0, 0, 0)))); + m_nodes.insert (m_nodes.begin (), std::make_pair (0.0, std::make_pair (lay::Color (0, 0, 0), lay::Color (0, 0, 0)))); } else { m_nodes[0].first = 0.0; } - std::vector > >::iterator w = m_nodes.begin (); - std::vector > >::const_iterator nn = m_nodes.begin (); - for (std::vector > >::const_iterator n = m_nodes.begin () + 1; n != m_nodes.end (); ++n) { + std::vector > >::iterator w = m_nodes.begin (); + std::vector > >::const_iterator nn = m_nodes.begin (); + for (std::vector > >::const_iterator n = m_nodes.begin () + 1; n != m_nodes.end (); ++n) { if (fabs (nn->first - n->first) > min_value_interval) { *w++ = *nn; nn = n; @@ -288,7 +255,7 @@ ColorBar::set_nodes (const std::vector 1.0 - min_value_interval) { m_nodes.back ().first = 1.0; } else { - m_nodes.push_back (std::make_pair (1.0, std::make_pair (QColor (255, 255, 255), QColor (255, 255, 255)))); + m_nodes.push_back (std::make_pair (1.0, std::make_pair (lay::Color (255, 255, 255), lay::Color (255, 255, 255)))); } m_selected = -1; @@ -313,8 +280,8 @@ ColorBar::mousePressEvent (QMouseEvent *event) double xx = double (event->x () - xl) / double (xr - xl); double dmin = 100.0; - std::vector > >::const_iterator pmin = m_nodes.end (); - for (std::vector > >::const_iterator p = m_nodes.begin (); p != m_nodes.end (); ++p) { + std::vector > >::const_iterator pmin = m_nodes.end (); + for (std::vector > >::const_iterator p = m_nodes.begin (); p != m_nodes.end (); ++p) { double d = fabs (p->first - xx); if (d < 0.05 && d < dmin) { dmin = d; @@ -323,9 +290,10 @@ ColorBar::mousePressEvent (QMouseEvent *event) } if (pmin != m_nodes.end ()) { - m_selected = int (std::distance (std::vector > >::const_iterator (m_nodes.begin ()), pmin)); + m_selected = int (std::distance (std::vector > >::const_iterator (m_nodes.begin ()), pmin)); emit selection_changed (); - emit selection_changed (m_nodes [m_selected].second); + std::pair cp = m_nodes [m_selected].second; + emit selection_changed (std::make_pair (QColor (cp.first.rgb ()), QColor (cp.second.rgb ()))); m_dragging = true; update (); } else { @@ -359,13 +327,14 @@ ColorBar::mouseDoubleClickEvent (QMouseEvent *event) double xx = double (event->x () - xl) / double (xr - xl); - std::vector > >::iterator p = std::lower_bound (m_nodes.begin (), m_nodes.end (), std::make_pair (xx, std::make_pair (QColor (), QColor ())), compare_first_of_node ()); + std::vector > >::iterator p = std::lower_bound (m_nodes.begin (), m_nodes.end (), std::make_pair (xx, std::make_pair (lay::Color (), lay::Color ())), compare_first_of_node ()); if (p != m_nodes.begin () && p != m_nodes.end ()) { m_selected = int (std::distance (m_nodes.begin (), p)); - QColor ci = interpolated_color (m_nodes, xx); + lay::Color ci = interpolated_color (m_nodes, xx); m_nodes.insert (p, std::make_pair (xx, std::make_pair (ci, ci))); emit selection_changed (); - emit selection_changed (m_nodes [m_selected].second); + std::pair cp = m_nodes [m_selected].second; + emit selection_changed (std::make_pair (QColor (cp.first.rgb ()), QColor (cp.second.rgb ()))); emit color_mapping_changed (); update (); } @@ -440,9 +409,9 @@ ColorBar::paintEvent (QPaintEvent *) if (xr != xl) { xx = double (x - xl) / double (xr - xl); } - QColor c = interpolated_color (m_nodes, xx); + lay::Color c = interpolated_color (m_nodes, xx); - painter.fillRect (x, yb - hbar, 1, hbar + 1, QBrush (c)); + painter.fillRect (x, yb - hbar, 1, hbar + 1, QBrush (QColor (c.rgb ()))); } diff --git a/src/img/img/imgWidgets.h b/src/img/img/imgWidgets.h index d0ce8ed63..06cef78ef 100644 --- a/src/img/img/imgWidgets.h +++ b/src/img/img/imgWidgets.h @@ -24,6 +24,8 @@ #define HDR_imgWidgets #include "layWidgets.h" +#include "layColor.h" +#include "imgObject.h" #include #include @@ -38,13 +40,6 @@ class QPaintEvent; namespace img { -/** - * @brief A helper function to interpolate a color in the color bar at a given x - * - * TODO: move this somewhere else. - */ -QColor interpolated_color (const std::vector > > &nodes, double x); - /** * @brief A two-color widget * @@ -114,9 +109,9 @@ public: return m_selected >= 0; } - void set_nodes (const std::vector > > &nodes); + void set_nodes (const std::vector > > &nodes); - const std::vector > > &nodes () const + const std::vector > > &nodes () const { return m_nodes; } @@ -135,7 +130,7 @@ signals: private: bool m_dragging; int m_selected; - std::vector > > m_nodes; + std::vector > > m_nodes; std::vector m_histogram; }; diff --git a/src/img/unit_tests/imgFile.cc b/src/img/unit_tests/imgFile.cc index 49719aa02..5daf917f2 100644 --- a/src/img/unit_tests/imgFile.cc +++ b/src/img/unit_tests/imgFile.cc @@ -45,9 +45,9 @@ TEST(1_FloatMono) dm.gamma = 1.5; dm.brightness = 1.25; dm.false_color_nodes.clear (); - dm.false_color_nodes.push_back (std::make_pair (0.0, std::make_pair (QColor (0, 0, 0), QColor (0, 0, 0)))); - dm.false_color_nodes.push_back (std::make_pair (0.5, std::make_pair (QColor (255, 0, 0), QColor (0, 255, 0)))); - dm.false_color_nodes.push_back (std::make_pair (1.0, std::make_pair (QColor (255, 255, 255), QColor (255, 255, 255)))); + dm.false_color_nodes.push_back (std::make_pair (0.0, std::make_pair (lay::Color (0, 0, 0), lay::Color (0, 0, 0)))); + dm.false_color_nodes.push_back (std::make_pair (0.5, std::make_pair (lay::Color (255, 0, 0), lay::Color (0, 255, 0)))); + dm.false_color_nodes.push_back (std::make_pair (1.0, std::make_pair (lay::Color (255, 255, 255), lay::Color (255, 255, 255)))); image.set_data_mapping (dm); image.set_pixel (0, 0, 0.25); diff --git a/src/img/unit_tests/imgObject.cc b/src/img/unit_tests/imgObject.cc index 7eaa24198..1dfabda0c 100644 --- a/src/img/unit_tests/imgObject.cc +++ b/src/img/unit_tests/imgObject.cc @@ -101,8 +101,8 @@ TEST(1) dm.red_gain = 1.25; dm.green_gain = 0.75; dm.blue_gain = 2.5; - QColor c (128, 255, 64); - QColor c2 (64, 32, 192); + lay::Color c (128, 255, 64); + lay::Color c2 (64, 32, 192); dm.false_color_nodes.insert (dm.false_color_nodes.begin () + 1, std::make_pair (0.5, std::make_pair (c, c))); image.set_data_mapping (dm); EXPECT_EQ (copy1.equals (&image), false); @@ -226,7 +226,7 @@ TEST(2) dm.red_gain = 1.25; dm.green_gain = 0.75; dm.blue_gain = 2.5; - QColor c (128, 255, 64); + lay::Color c (128, 255, 64); dm.false_color_nodes.insert (dm.false_color_nodes.begin () + 1, std::make_pair (0.5, std::make_pair (c, c))); image.set_data_mapping (dm); EXPECT_EQ (copy1.equals (&image), false); diff --git a/src/laybasic/laybasic/layColor.cc b/src/laybasic/laybasic/layColor.cc index 67e0c700e..ac486cdbb 100644 --- a/src/laybasic/laybasic/layColor.cc +++ b/src/laybasic/laybasic/layColor.cc @@ -23,6 +23,7 @@ #include "layColor.h" #include "tlString.h" +#include "tlMath.h" #include @@ -116,4 +117,82 @@ Color::is_valid () const return (m_color & 0xff000000) != 0; } +void +Color::get_hsv (unsigned int &hue, unsigned int &saturation, unsigned int &value) const +{ + double r = double (red ()) / 255.0; + double g = double (green ()) / 255.0; + double b = double (blue ()) / 255.0; + + double max = std::max (r, std::max (g, b)); + double min = std::min (r, std::min (g, b)); + double delta = max - min; + + value = (unsigned int) tl::round (255.0 * max, 1); + hue = 0; + saturation = 0; + + if (! tl::equal (delta, 0.0)) { + + saturation = (unsigned int) tl::round (255.0 * delta / max, 1); + double h = 0.0; + if (tl::equal (r, max)) { + h = (g - b) / delta; + } else if (tl::equal (g, max)) { + h = 2.0f + (b - r) / delta; + } else if (tl::equal (b, max)) { + h = 4.0f + (r - g) / delta; + } + h *= 60.0; + if (tl::less (h, 0.0)) { + h += 360.0; + } + + hue = (unsigned int) tl::round (h, 1); + + } +} + +static lay::Color color_d (double r, double g, double b) +{ + return lay::Color (tl::round (r * 255.0, 1), tl::round (g * 255.0, 1), tl::round (b * 255.0, 1)); +} + +lay::Color +Color::from_hsv (unsigned int hue, unsigned int saturation, unsigned int value) +{ + if (saturation == 0) { + return lay::Color (value, value, value); + } + + hue = (hue + 360) % 360; + + double h = double (hue) / 60.0; + double s = double (saturation) / 255.0; + double v = double (value) / 255.0; + + int i = int (tl::round_down (h, 1)); + double f = (i & 1) != 0 ? h - i : 1.0 - h + i; + double p = v * (1.0 - s); + double q = v * (1.0 - s * f); + + switch (i) { + case 0: + return color_d (v, q, p); + case 1: + return color_d (q, v, p); + case 2: + return color_d (p, v, q); + case 3: + return color_d (p, q, v); + case 4: + return color_d (q, p, v); + case 5: + return color_d (v, p, q); + default: + return lay::Color (); + } + +} + } diff --git a/src/laybasic/laybasic/layColor.h b/src/laybasic/laybasic/layColor.h index 77cccebc8..79725ecfb 100644 --- a/src/laybasic/laybasic/layColor.h +++ b/src/laybasic/laybasic/layColor.h @@ -142,6 +142,19 @@ public: return (m_color & 0xff); } + /** + * @brief Gets the HSV color components + * hue: 0..359 + * saturation: 0..255 + * value: 0..255 + */ + void get_hsv (unsigned int &hue, unsigned int &saturation, unsigned int &value) const; + + /** + * @brief Creates the color from a HSV color + */ + static lay::Color from_hsv (unsigned int hue, unsigned int saturation, unsigned int value); + private: color_t m_color; }; diff --git a/src/laybasic/unit_tests/layColorTests.cc b/src/laybasic/unit_tests/layColorTests.cc index c1d44c744..8da8e208b 100644 --- a/src/laybasic/unit_tests/layColorTests.cc +++ b/src/laybasic/unit_tests/layColorTests.cc @@ -116,3 +116,104 @@ TEST(7) EXPECT_EQ (QColor (16, 32, 48, 128).rgb (), 0xff102030); #endif } + +TEST(8) +{ + unsigned int h, s, v; + int ih, is, iv; + lay::Color c = lay::Color (16, 32, 48); + c.get_hsv (h, s, v); + EXPECT_EQ (h, 210); + EXPECT_EQ (s, 170); + EXPECT_EQ (v, 48); + + EXPECT_EQ (lay::Color::from_hsv (h, s, v).to_string (), "#102030"); + +#if defined(HAVE_QT) + QColor qc = QColor (16, 32, 48); + qc.getHsv (&ih, &is, &iv); + EXPECT_EQ (ih, 210); + EXPECT_EQ (is, 170); + EXPECT_EQ (iv, 48); +#endif + + c = lay::Color (32, 16, 48); + c.get_hsv (h, s, v); + EXPECT_EQ (h, 270); + EXPECT_EQ (s, 170); + EXPECT_EQ (v, 48); + + EXPECT_EQ (lay::Color::from_hsv (h, s, v).to_string (), "#201030"); + +#if defined(HAVE_QT) + qc = QColor (32, 16, 48); + qc.getHsv (&ih, &is, &iv); + EXPECT_EQ (ih, 270); + EXPECT_EQ (is, 170); + EXPECT_EQ (iv, 48); +#endif + + c = lay::Color (32, 48, 16); + c.get_hsv (h, s, v); + EXPECT_EQ (h, 90); + EXPECT_EQ (s, 170); + EXPECT_EQ (v, 48); + + EXPECT_EQ (lay::Color::from_hsv (h, s, v).to_string (), "#203010"); + +#if defined(HAVE_QT) + qc = QColor (32, 48, 16); + qc.getHsv (&ih, &is, &iv); + EXPECT_EQ (ih, 90); + EXPECT_EQ (is, 170); + EXPECT_EQ (iv, 48); +#endif + + c = lay::Color (48, 32, 16); + c.get_hsv (h, s, v); + EXPECT_EQ (h, 30); + EXPECT_EQ (s, 170); + EXPECT_EQ (v, 48); + + EXPECT_EQ (lay::Color::from_hsv (h, s, v).to_string (), "#302010"); + +#if defined(HAVE_QT) + qc = QColor (48, 32, 16); + qc.getHsv (&ih, &is, &iv); + EXPECT_EQ (ih, 30); + EXPECT_EQ (is, 170); + EXPECT_EQ (iv, 48); +#endif + + c = lay::Color (48, 16, 32); + c.get_hsv (h, s, v); + EXPECT_EQ (h, 330); + EXPECT_EQ (s, 170); + EXPECT_EQ (v, 48); + + EXPECT_EQ (lay::Color::from_hsv (h, s, v).to_string (), "#301020"); + +#if defined(HAVE_QT) + qc = QColor (48, 16, 32); + qc.getHsv (&ih, &is, &iv); + EXPECT_EQ (ih, 330); + EXPECT_EQ (is, 170); + EXPECT_EQ (iv, 48); +#endif + + c = lay::Color (16, 48, 32); + c.get_hsv (h, s, v); + EXPECT_EQ (h, 150); + EXPECT_EQ (s, 170); + EXPECT_EQ (v, 48); + + EXPECT_EQ (lay::Color::from_hsv (h, s, v).to_string (), "#103020"); + +#if defined(HAVE_QT) + qc = QColor (16, 48, 32); + qc.getHsv (&ih, &is, &iv); + EXPECT_EQ (ih, 150); + EXPECT_EQ (is, 170); + EXPECT_EQ (iv, 48); +#endif +} From 2298a9a5c8322f0ba153e567d8d05748e49d074d Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Fri, 29 Apr 2022 23:40:07 +0200 Subject: [PATCH 07/88] WIP --- src/laybasic/laybasic/layCellView.h | 10 +- src/laybasic/laybasic/layDispatcher.cc | 27 +- src/laybasic/laybasic/layDispatcher.h | 26 +- src/laybasic/laybasic/layLayerProperties.cc | 30 +- src/laybasic/laybasic/layLayerProperties.h | 22 +- src/laybasic/laybasic/layLayoutCanvas.h | 30 +- src/laybasic/laybasic/layLayoutView.h | 2935 ++------- src/laybasic/laybasic/layLayoutViewBase.cc | 5487 +++++++++++++++++ src/laybasic/laybasic/layLayoutViewBase.h | 2566 ++++++++ src/laybasic/laybasic/layMouseTracker.h | 6 +- src/laybasic/laybasic/layMove.h | 16 +- src/laybasic/laybasic/layParsedLayerSource.cc | 4 +- src/laybasic/laybasic/layParsedLayerSource.h | 4 +- src/laybasic/laybasic/layPlugin.h | 10 +- src/laybasic/laybasic/laySelector.h | 24 +- src/laybasic/laybasic/layZoomBox.h | 6 +- src/laybasic/laybasic/laybasic.pro | 2 + 17 files changed, 8501 insertions(+), 2704 deletions(-) create mode 100644 src/laybasic/laybasic/layLayoutViewBase.cc create mode 100644 src/laybasic/laybasic/layLayoutViewBase.h diff --git a/src/laybasic/laybasic/layCellView.h b/src/laybasic/laybasic/layCellView.h index 99c6c18d3..4fc1e98b4 100644 --- a/src/laybasic/laybasic/layCellView.h +++ b/src/laybasic/laybasic/layCellView.h @@ -46,7 +46,7 @@ namespace lay { -class LayoutView; +class LayoutViewBase; /** * @brief A layout handle @@ -581,7 +581,7 @@ public: * @param cv The reference to the target cellview * @param view The reference to the layout view */ - CellViewRef (lay::CellView *cv, lay::LayoutView *view); + CellViewRef (lay::CellView *cv, lay::LayoutViewBase *view); /** * @brief Gets the cellview index of this reference @@ -590,9 +590,9 @@ public: int index () const; /** - * @brief Gets the LayoutView the reference is pointing to + * @brief Gets the LayoutViewBase the reference is pointing to */ - lay::LayoutView *view (); + lay::LayoutViewBase *view (); /** * @brief Equality: Gives true, if the cellviews are identical @@ -749,7 +749,7 @@ public: private: tl::weak_ptr mp_cv; - tl::weak_ptr mp_view; + tl::weak_ptr mp_view; }; } diff --git a/src/laybasic/laybasic/layDispatcher.cc b/src/laybasic/laybasic/layDispatcher.cc index dce1ec93b..809d25a56 100644 --- a/src/laybasic/laybasic/layDispatcher.cc +++ b/src/laybasic/laybasic/layDispatcher.cc @@ -73,21 +73,6 @@ Dispatcher::Dispatcher (DispatcherDelegate *delegate, Plugin *parent, bool stand } } -#if defined(HAVE_QT) -Dispatcher::Dispatcher (QWidget *menu_parent_widget, DispatcherDelegate *delegate, Plugin *parent, bool standalone) - : Plugin (parent, standalone), - mp_menu_parent_widget (menu_parent_widget), - mp_delegate (delegate) -{ - if (mp_menu_parent_widget) { - mp_menu.reset (new lay::AbstractMenu (this)); - } - if (! parent && ! ms_dispatcher_instance) { - ms_dispatcher_instance = this; - } -} -#endif - Dispatcher::~Dispatcher () { if (ms_dispatcher_instance == this) { @@ -95,6 +80,18 @@ Dispatcher::~Dispatcher () } } +#if defined(HAVE_QT) +void Dispatcher::set_menu_parent_widget (QWidget *menu_parent_widget) +{ + mp_menu_parent_widget = menu_parent_widget; + if (mp_menu_parent_widget) { + mp_menu.reset (new lay::AbstractMenu (this)); + } else { + mp_menu.reset (0); + } +} +#endif + bool Dispatcher::configure (const std::string &name, const std::string &value) { diff --git a/src/laybasic/laybasic/layDispatcher.h b/src/laybasic/laybasic/layDispatcher.h index 703b4eec0..05acda580 100644 --- a/src/laybasic/laybasic/layDispatcher.h +++ b/src/laybasic/laybasic/layDispatcher.h @@ -121,17 +121,6 @@ public: */ Dispatcher (Plugin *parent = 0, bool standalone = false); -#if defined(HAVE_QT) - /** - * @brief The constructor - * - * @param menu_parent_widget If not 0, indicates that this is a GUI mode dispatcher providing an abstract menu - * @param parent Usually 0, but a dispatcher may have parents. In this case, the dispatcher is not the actual dispatcher, but the real plugin chain's root is. - * @param standalone The standalone flag passed to the plugin constructor. - */ - Dispatcher (QWidget *menu_parent_widget, Plugin *parent = 0, bool standalone = false); -#endif - /** * @brief The root constructor * @@ -139,16 +128,6 @@ public: */ Dispatcher (DispatcherDelegate *delegate, Plugin *parent = 0, bool standalone = false); -#if defined(HAVE_QT) - /** - * @brief The root constructor - * - * @param menu_parent_widget If not 0, indicates that this is a GUI mode dispatcher providing an abstract menu - * @param delegate The notification receiver for dispatcher events - */ - Dispatcher (QWidget *menu_parent_widget, DispatcherDelegate *delegate, Plugin *parent = 0, bool standalone = false); -#endif - /** * @brief Destructor */ @@ -233,6 +212,11 @@ public: return mp_menu_parent_widget; } + /** + * @brief Sets the parent widget + */ + void set_menu_parent_widget (QWidget *pw); + /** * @brief Returns true, if the dispatcher supplies a user interface */ diff --git a/src/laybasic/laybasic/layLayerProperties.cc b/src/laybasic/laybasic/layLayerProperties.cc index d24c08a62..a6cdd3726 100644 --- a/src/laybasic/laybasic/layLayerProperties.cc +++ b/src/laybasic/laybasic/layLayerProperties.cc @@ -22,7 +22,7 @@ #include "layLayerProperties.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "layConverters.h" #include "tlXMLParser.h" #include "tlException.h" @@ -404,7 +404,7 @@ class LayerSourceEval : public tl::Eval { public: - LayerSourceEval (const lay::LayerProperties &lp, const lay::LayoutView *view, bool real) + LayerSourceEval (const lay::LayerProperties &lp, const lay::LayoutViewBase *view, bool real) : m_lp (lp), mp_view (view), m_real (real) { // .. nothing yet .. @@ -415,14 +415,14 @@ public: return m_lp.source (m_real); } - const lay::LayoutView *view () const + const lay::LayoutViewBase *view () const { return mp_view; } private: const lay::LayerProperties &m_lp; - const lay::LayoutView *mp_view; + const lay::LayoutViewBase *mp_view; bool m_real; }; @@ -480,7 +480,7 @@ private: }; std::string -LayerProperties::display_string (const lay::LayoutView *view, bool real, bool always_show_source) const +LayerProperties::display_string (const lay::LayoutViewBase *view, bool real, bool always_show_source) const { refresh (); @@ -592,7 +592,7 @@ LayerProperties::need_realize (unsigned int flags, bool /*force*/) } void -LayerProperties::do_realize (const LayoutView *view) const +LayerProperties::do_realize (const LayoutViewBase *view) const { m_layer_index = -1; m_cellview_index = -1; @@ -712,10 +712,10 @@ LayerPropertiesNode::operator== (const LayerPropertiesNode &d) const return m_children == d.m_children; } -LayoutView * +LayoutViewBase * LayerPropertiesNode::view () const { - return const_cast (mp_view.get ()); + return const_cast (mp_view.get ()); } unsigned int @@ -804,7 +804,7 @@ LayerPropertiesNode::bbox () const } void -LayerPropertiesNode::attach_view (LayoutView *view, unsigned int list_index) +LayerPropertiesNode::attach_view (LayoutViewBase *view, unsigned int list_index) { mp_view.reset (view); m_list_index = list_index; @@ -1335,7 +1335,7 @@ static LayerPropertiesNode expand_wildcard_layout (const LayerPropertiesNode &so } static std::vector -expand_wildcard_layers (const LayerPropertiesNode &lp, const LayerPropertiesList ¤t_props, lay::LayoutView *view, unsigned int list_index) +expand_wildcard_layers (const LayerPropertiesNode &lp, const LayerPropertiesList ¤t_props, lay::LayoutViewBase *view, unsigned int list_index) { std::vector new_props; @@ -1651,7 +1651,7 @@ struct UIntColorConverter if (c == 0) { return ""; } else { - return ColorConverter::to_string (QColor (c & 0xffffff)); + return ColorConverter::to_string (lay::Color (c | 0xff000000)); } } @@ -1660,7 +1660,7 @@ struct UIntColorConverter if (s.empty ()) { c = 0; } else { - QColor qc; + lay::Color qc; ColorConverter::from_string (s, qc); c = qc.rgb () | 0xff000000; } @@ -1858,7 +1858,7 @@ LayerPropertiesList::save (tl::OutputStream &os, const std::vector (mp_view.get ()); + return const_cast (mp_view.get ()); } unsigned int diff --git a/src/laybasic/laybasic/layLayerProperties.h b/src/laybasic/laybasic/layLayerProperties.h index 6f9c6d760..3df52ade7 100644 --- a/src/laybasic/laybasic/layLayerProperties.h +++ b/src/laybasic/laybasic/layLayerProperties.h @@ -48,7 +48,7 @@ namespace tl { namespace lay { -class LayoutView; +class LayoutViewBase; class LayerPropertiesList; class LayerPropertiesNode; @@ -700,7 +700,7 @@ public: * If it is set to false, the view's always_show_source attribute with determine whether the source is * shown. */ - std::string display_string (const lay::LayoutView *view, bool real, bool always_with_source = false) const; + std::string display_string (const lay::LayoutViewBase *view, bool real, bool always_with_source = false) const; /** * @brief The source specification @@ -717,7 +717,7 @@ public: * * This method may throw an exception if the specification * is not valid. In order to make the layer usable, the properties - * object must be "realized" with respect to a LayoutView object. + * object must be "realized" with respect to a LayoutViewBase object. */ void set_source (const std::string &s); @@ -725,7 +725,7 @@ public: * @brief Load the source specification * * In order to make the layer usable, the properties - * object must be "realized" with respect to a LayoutView object. + * object must be "realized" with respect to a LayoutViewBase object. */ void set_source (const lay::ParsedLayerSource &s); @@ -887,7 +887,7 @@ protected: * * @param view The view the properties refer to or 0 if there is no view. */ - void do_realize (const LayoutView *view) const; + void do_realize (const LayoutViewBase *view) const; /** * @brief Tell, if a realize of the visual properties is needed @@ -1172,12 +1172,12 @@ public: * compute the actual property selection set. * This method is supposed to be */ - void attach_view (LayoutView *view, unsigned int list_index); + void attach_view (LayoutViewBase *view, unsigned int list_index); /** * @brief Gets the layout view the node lives in */ - LayoutView *view () const; + LayoutViewBase *view () const; /** * @brief Gets the index of the layer properties list that node lives in @@ -1214,7 +1214,7 @@ protected: private: // A reference to the view - tl::weak_ptr mp_view; + tl::weak_ptr mp_view; unsigned int m_list_index; // the parent node tl::weak_ptr mp_parent; @@ -1912,12 +1912,12 @@ public: * "load" automatically attaches the view. * This method has the side effect of recomputing the layer source parameters. */ - void attach_view (lay::LayoutView *view, unsigned int list_index); + void attach_view (lay::LayoutViewBase *view, unsigned int list_index); /** * @brief Gets the layout view this list is attached to */ - lay::LayoutView *view () const; + lay::LayoutViewBase *view () const; /** * @brief Gets the layout list @@ -1925,7 +1925,7 @@ public: unsigned int list_index () const; private: - tl::weak_ptr mp_view; + tl::weak_ptr mp_view; unsigned int m_list_index; layer_list m_layer_properties; lay::DitherPattern m_dither_pattern; diff --git a/src/laybasic/laybasic/layLayoutCanvas.h b/src/laybasic/laybasic/layLayoutCanvas.h index aa4d9e624..de403bc88 100644 --- a/src/laybasic/laybasic/layLayoutCanvas.h +++ b/src/laybasic/laybasic/layLayoutCanvas.h @@ -47,7 +47,7 @@ namespace lay { -class LayoutView; +class LayoutViewBase; class RedrawThread; /** @@ -138,10 +138,16 @@ class LayoutCanvas public lay::BitmapRedrawThreadCanvas, public lay::Drawings { +#if defined(HAVE_QT) Q_OBJECT +#endif public: - LayoutCanvas (QWidget *parent, lay::LayoutView *view, const char *name = "canvas"); +#if defined(HAVE_QT) + LayoutCanvas (QWidget *parent, lay::LayoutViewBase *view, const char *name = "canvas"); +#else + LayoutCanvas (lay::LayoutViewBase *view, const char *name = "canvas"); +#endif ~LayoutCanvas (); void set_colors (lay::Color background, lay::Color foreground, lay::Color active); @@ -341,18 +347,18 @@ public: */ tl::Event viewport_changed_event; -signals: - void left_arrow_key_pressed (); - void up_arrow_key_pressed (); - void right_arrow_key_pressed (); - void down_arrow_key_pressed (); - void left_arrow_key_pressed_with_shift (); - void up_arrow_key_pressed_with_shift (); - void right_arrow_key_pressed_with_shift (); - void down_arrow_key_pressed_with_shift (); + // key events + tl::Event left_arrow_key_pressed; + tl::Event up_arrow_key_pressed; + tl::Event right_arrow_key_pressed; + tl::Event down_arrow_key_pressed; + tl::Event left_arrow_key_pressed_with_shift; + tl::Event up_arrow_key_pressed_with_shift; + tl::Event right_arrow_key_pressed_with_shift; + tl::Event down_arrow_key_pressed_with_shift; private: - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; QImage *mp_image; QImage *mp_image_bg; QPixmap *mp_pixmap; diff --git a/src/laybasic/laybasic/layLayoutView.h b/src/laybasic/laybasic/layLayoutView.h index 17e4d20b5..a8ad43acf 100644 --- a/src/laybasic/laybasic/layLayoutView.h +++ b/src/laybasic/laybasic/layLayoutView.h @@ -36,6 +36,7 @@ #include #include +#include "layLayoutViewBase.h" #include "layLayerProperties.h" #include "layAbstractMenu.h" #include "layAnnotationShapes.h" @@ -85,71 +86,6 @@ class ColorButton; class ConfigureAction; class EditorOptionsPages; -/** - * @brief Stores a layer reference to create layers which have been added by some action - * - * This object is delivered by LayoutView::layer_snapshot and can be used in add_missing_layers - * to create new layer views for layers which have been created between layer_snapshot and - * add_missing_layers. - */ -struct LayerState -{ - /** - * @brief Constructor - */ - LayerState () { } - - std::set present; -}; - -/** - * @brief A layer display properties structure - * - * The layer properties encapsulate the settings relevant for - * the display of a layer. - * - * "brightness" is a index that indicates how much to make the - * color brighter to darker rendering the effective color - * (eff_frame_color (), eff_fill_color ()). It's value is roughly between - * -255 and 255. - */ -struct LAYBASIC_PUBLIC LayerDisplayProperties -{ - LayerDisplayProperties (); - - bool operator== (const LayerDisplayProperties &d); - bool operator!= (const LayerDisplayProperties &d); - - /** - * @brief render the effective frame color - * - * The effective frame color is computed from the frame color brightness and the - * frame color. - */ - color_t eff_frame_color () const; - - /** - * @brief render the effective frame color - * - * The effective frame color is computed from the frame color brightness and the - * frame color. - */ - color_t eff_fill_color () const; - - // display styles - color_t frame_color; - color_t fill_color; - int frame_brightness; - int fill_brightness; - unsigned int dither_pattern; - bool visible; - bool transparent; - int width; - bool marked; - int animation; - std::string name; -}; - /** * @brief The layout view object * @@ -158,39 +94,11 @@ struct LAYBASIC_PUBLIC LayerDisplayProperties * It manages the layer display list, bookmark list etc. */ class LAYBASIC_PUBLIC LayoutView - : public QFrame, - public lay::Editables, - public lay::Dispatcher + : public LayoutViewBase { Q_OBJECT public: - typedef lay::CellView::unspecific_cell_path_type cell_path_type; - typedef lay::CellView::cell_index_type cell_index_type; - typedef std::pair bookmark_type; - - /** - * @brief Define some options for the view - */ - enum options_type { - LV_Normal = 0, - LV_NoLayers = 1, - LV_NoHierarchyPanel = 2, - LV_NoLibrariesView = 4, - LV_NoEditorOptionsPanel = 8, - LV_NoBookmarksView = 16, - LV_Naked = 32, - LV_NoZoom = 64, - LV_NoGrid = 128, - LV_NoMove = 256, - LV_NoTracker = 512, - LV_NoSelection = 1024, - LV_NoPlugins = 2048, - LV_NoServices = LV_NoMove + LV_NoTracker + LV_NoSelection + LV_NoPlugins - }; - - enum drop_small_cells_cond_type { DSC_Max = 0, DSC_Min = 1, DSC_Sum = 2 }; - /** * @brief Constructor */ @@ -201,11 +109,6 @@ public: */ LayoutView (lay::LayoutView *source, db::Manager *mgr, bool editable, lay::Plugin *plugin_parent, QWidget *parent = 0, const char *name = "view", unsigned int options = (unsigned int) LV_Normal); - /** - * @brief Destructor - */ - ~LayoutView (); - /** * @brief Makes this view the current one */ @@ -216,20 +119,188 @@ public: * * The argument can be 0 which means there is no current view. */ - static void set_current (LayoutView *); + static void set_current (LayoutViewBase *); /** * @brief Gets the current view */ - static LayoutView *current (); + static LayoutViewBase *current (); /** - * @brief Determine if there is something to copy - * - * This reimplementation of the lay::Editables interface additionally - * looks for content providers in the tree views for example. + * @brief Gets the window title of the view */ - bool has_selection (); + std::string title () const; + + /** + * @brief Sets the window title to an explicit string + */ + void set_title (const std::string &t); + + /** + * @brief Resets the explicit title and enable the automatic naming + */ + void reset_title (); + + /** + * @brief Sets the currently active layer by layer properties and cell view index + * + * If the layer does not exist, the user will be asked whether to create the layer. + * Returns false if the layer is not a valid one and the user defined to create the layer. + */ + bool set_or_request_current_layer (unsigned int cv_index, const db::LayerProperties &properties); + + /** + * @brief Sets the currently active layer by layer properties and cell view index + * + * This method will look up that layer in the layer view tree and select that layer. + * This method will also select this layer. + * + * Returns false if the layer is not a valid one. + */ + bool set_current_layer (unsigned int cv_index, const db::LayerProperties &properties); + + /** + * @brief Sets the currently active layer + * + * The active layer is the one that is active in the layer + * browser panel. This method will also select this layer. + */ + void set_current_layer (const lay::LayerPropertiesConstIterator &l); + + /** + * @brief Retrieve the index of the currently active layer + * + * The active layer is the one that is active in the layer + * browser panel. + * This method returns a null iterator, if no layer is active. + */ + lay::LayerPropertiesConstIterator current_layer () const; + + /** + * @brief Return the layers that are selected in the layer browser + * + * Returns an empty list if no layer is selected. + */ + std::vector selected_layers () const; + + /** + * @brief Sets the layers that are selected in the layer browser + */ + void set_selected_layers (const std::vector &sel); + + /** + * @brief Get the index of the active cellview (shown in hierarchy browser) + */ + int active_cellview_index () const; + + /** + * @brief Get the index of the active cellview (shown in hierarchy browser) + */ + const lay::CellView &active_cellview () const; + + /** + * @brief Gets a cellview reference to the active cellview + */ + lay::CellViewRef active_cellview_ref (); + + /** + * @brief Select a certain cellview for the active one + */ + void set_active_cellview_index (int index); + + /** + * @brief Cell paths of the selected cells + * + * The current cell is the one highlighted in the browser with the focus rectangle. The + * current path is returned for the cellview given by cv_index. + */ + void selected_cells_paths (int cv_index, std::vector &paths) const; + + /** + * @brief Cell path of the current cell + * + * The current cell is the one highlighted in the browser with the focus rectangle. The + * current path is returned for the cellview given by cv_index. + */ + void current_cell_path (int cv_index, cell_path_type &path) const; + + /** + * @brief Cell path of the current cell + * + * This method version is provided for automation purposes mainly. + */ + cell_path_type get_current_cell_path (int cv_index) const + { + cell_path_type r; + current_cell_path (cv_index, r); + return r; + } + + /** + * @brief Cell path of the current cell in the active cellview + * + * This is a convenience function returning the path for the active cellview. + */ + void current_cell_path (cell_path_type &path) const + { + current_cell_path (active_cellview_index (), path); + } + + /** + * @brief Set the path to the current cell + * + * The current cell is the one highlighted in the browser with the focus rectangle. The + * cell given by the path is highlighted and scrolled into view. + */ + void set_current_cell_path (int cv_index, const cell_path_type &path); + + /** + * @brief Set the path to the current cell is the current cellview + * + * This is a convenience function setting the path for the active cellview. + */ + void set_current_cell_path (const cell_path_type &path) + { + set_current_cell_path (active_cellview_index (), path); + } + + /** + * @brief Bookmark the current view under the given name + */ + void bookmark_view (const std::string &name); + + /** + * @brief Asks for a bookmark name and bookmark the current view under this name + */ + void bookmark_current_view (); + + /** + * @brief Show the bookmark management form + */ + void manage_bookmarks (); + + /** + * @brief Obtain the bookmarks list + */ + const BookmarkList &bookmarks () const + { + return m_bookmarks; + } + + /** + * @brief Set the bookmarks list + */ + void bookmarks (const BookmarkList &b); + + /** + * @brief Open the RDB browser for a given database and associated cv index + */ + void open_rdb_browser (int rdb_index, int cv_index); + + /** + * @brief Open the L2NDB browser for a given database and associated cv index + */ + void open_l2ndb_browser (int l2ndb_index, int cv_index); /** * @brief Gets the container with the layer control panel @@ -288,407 +359,9 @@ public: } /** - * @brief Gets the editor options pages widget + * @brief Deliver a size hint (reimplementation of QWidget) */ - lay::EditorOptionsPages *editor_options_pages (); - - /** - * @brief Pastes from clipboard - * - * This reimplementation of the lay::Editables interface additionally - * looks for paste receivers in the tree views for example. - */ - void paste (); - - /** - * @brief Pastes from clipboard and initiates a move - */ - void paste_interactive (); - - /** - * @brief Copies to clipboard - * - * This reimplementation of the lay::Editables interface additionally - * looks for copy providers in the tree views for example. - */ - void copy (); - - /** - * @brief Cuts to clipboard - * - * This reimplementation of the lay::Editables interface additionally - * looks for cut & copy providers in the tree views for example. - */ - void cut (); - - /** - * @brief Gets the explicit title string of the view - * - * This is the one explicitly set, not the one displayed. The displayed text is composed of internal information - * if no title string is set. - */ - const std::string &title_string () const - { - return m_title; - } - - /** - * @brief Gets the window title of the view - */ - std::string title () const; - - /** - * @brief Sets the window title to an explicit string - */ - void set_title (const std::string &t); - - /** - * @brief Resets the explicit title and enable the automatic naming - */ - void reset_title (); - - /** - * @brief The "dirty" flag indicates that one of the layout has been modified - * - * A signal is provided on a change of this flag (dirty_changed). - */ - bool is_dirty () const; - - /** - * @brief Fill the layer properties for a new layer - * - * The layer's source must be set already to allow computing of the initial color. - * It is assumed that the layer is appended at the end of the layer list. This - * is important to set the dither pattern index accordingly. - */ - void init_layer_properties (LayerProperties &props) const; - - /** - * @brief Create a set of new layers for the given layers of the given cellview - */ - void add_new_layers (const std::vector &layer_ids, int cv_index); - - /** - * @brief Set the layer properties of a layer with the given position (by iterator) for the current layer list - * - * @param iter Points to the layer to be replaced - * @param props The properties to replace the current properties - */ - void set_properties (const LayerPropertiesConstIterator &iter, const LayerProperties &props) - { - set_properties (current_layer_list (), iter, props); - } - - /** - * @brief Set the layer properties of a layer with the given position (by iterator) for the layer list with the given index - * - * @param index The layer list's index - * @param iter Points to the layer to be replaced - * @param props The properties to replace the current properties - */ - void set_properties (unsigned int index, const LayerPropertiesConstIterator &iter, const LayerProperties &props); - - /** - * @brief Expand the layer properties of all tabs - * - * This method will replace the wildcard specifications in the layer properties of all - * tabs. All unspecific cv index specifications will be expanded to all cellviews, all - * layer and datatype specs will be expanded into all available (remaining) specs. - */ - void expand_properties (); - - /** - * @brief Expand the layer properties for the given tab - * - * @param index The index of the tab to which to apply the expansion to. - */ - void expand_properties (unsigned int index); - - /** - * @brief Expand the layer properties of all tabs with some options - * - * @param map_cv_index Maps a specified cv index to the one to use. Use -1 for the first entry to map any present cv index. Map to -1 to specify expansion to all available cv indices. - * @param add_default Set this parameter to true to implicitly add an entry for all "missing" layers. - */ - void expand_properties (const std::map &map_cv_index, bool add_default); - - /** - * @brief Expand the layer properties of the specified tab with some options - * - * @param index The index of the tab to which to apply the expansion to. - * @param map_cv_index Maps a specified cv index to the one to use. Use -1 for the first entry to map any present cv index. Map to -1 to specify expansion to all available cv indices. - * @param add_default Set this parameter to true to implicitly add an entry for all "missing" layers. - */ - void expand_properties (unsigned int index, const std::map &map_cv_index, bool add_default); - - /** - * @brief Replace the layer node with a new one for the current layer list - */ - void replace_layer_node (const LayerPropertiesConstIterator &iter, const LayerPropertiesNode &props) - { - replace_layer_node (current_layer_list (), iter, props); - } - - /** - * @brief Replace the layer node with a new one for the layer list with the given index - */ - void replace_layer_node (unsigned int index, const LayerPropertiesConstIterator &iter, const LayerPropertiesNode &props); - - /** - * @brief Insert the given layer properties node into the list for the current layer list - * - * This method returns a reference to the element created. - */ - const LayerPropertiesNode &insert_layer (const LayerPropertiesConstIterator &iter, const LayerPropertiesNode &props) - { - return insert_layer (current_layer_list (), iter, props); - } - - /** - * @brief Insert the given layer properties node into the list before the given index - * - * This method returns a reference to the element created. - */ - const LayerPropertiesNode &insert_layer (unsigned int index, const LayerPropertiesConstIterator &iter, const LayerPropertiesNode &props); - - /** - * @brief Delete the layer properties node for the current layer list - * - * This method deletes the object that the iterator points to and invalidates - * the iterator since the object that the iterator points to is no longer valid. - */ - void delete_layer (LayerPropertiesConstIterator &iter) - { - delete_layer (current_layer_list (), iter); - } - - /** - * @brief Delete the layer properties node for the layer list with the given index - * - * This method deletes the object that the iterator points to and invalidates - * the iterator since the object that the iterator points to is no longer valid. - */ - void delete_layer (unsigned int index, LayerPropertiesConstIterator &iter); - - /** - * @brief Begin iterator for the layers - * - * This iterator delivers recursively the layers of this view - */ - LayerPropertiesConstIterator begin_layers () const - { - return get_properties ().begin_const_recursive (); - } - - /** - * @brief End iterator for the layers - */ - LayerPropertiesConstIterator end_layers () const - { - return get_properties ().end_const_recursive (); - } - - /** - * @brief Begin iterator for the layers for a given list - * - * This iterator delivers recursively the layers of this view - */ - LayerPropertiesConstIterator begin_layers (unsigned int index) const - { - return get_properties (index).begin_const_recursive (); - } - - /** - * @brief End iterator for the layers for a given list - */ - LayerPropertiesConstIterator end_layers (unsigned int index) const - { - return get_properties (index).end_const_recursive (); - } - - /** - * @brief Replace the current layer properties list - */ - void set_properties (const LayerPropertiesList &list) - { - set_properties (current_layer_list (), list); - } - - /** - * @brief Rename a layer properties list - */ - void rename_properties (unsigned int index, const std::string &new_name); - - /** - * @brief Replace the specified layer properties list - */ - void set_properties (unsigned int index, const LayerPropertiesList &list); - - /** - * @brief Clear the given layer view list - */ - void clear_layers (unsigned int index) - { - set_properties (index, LayerPropertiesList ()); - } - - /** - * @brief Clear the current layer view list - */ - void clear_layers () - { - set_properties (LayerPropertiesList ()); - } - - /** - * @brief Access the current layer properties list - */ - const LayerPropertiesList &get_properties () const - { - return get_properties (current_layer_list ()); - } - - /** - * @brief Access the specified layer properties list - */ - const LayerPropertiesList &get_properties (unsigned int index) const; - - /** - * @brief Get the number of lists present in this view - */ - unsigned int layer_lists () const - { - return (unsigned int) m_layer_properties_lists.size (); - } - - /** - * @brief Get the index of the current properties list - */ - unsigned int current_layer_list () const - { - return m_current_layer_list; - } - - /** - * @brief Set the index of the current properties list - */ - void set_current_layer_list (unsigned int index); - - /** - * @brief Delete the specified layer properties list - */ - void delete_layer_list (unsigned int index); - - /** - * @brief Insert the layer properties list at the given index and make it the current list. - */ - void insert_layer_list (unsigned int index, const LayerPropertiesList &props); - - /** - * @brief Insert the layer properties list at the given index and make it the current list. - */ - void insert_layer_list (unsigned int index) - { - insert_layer_list (index, LayerPropertiesList ()); - } - - /** - * @brief Set the custom dither pattern - */ - void set_dither_pattern (const DitherPattern &pattern); - - /** - * @brief Obtain the custom dither pattern - */ - const DitherPattern &dither_pattern () const - { - return mp_canvas->dither_pattern (); - } - - /** - * @brief Set the custom line styles - */ - void set_line_styles (const LineStyles &styles); - - /** - * @brief Obtain the custom line styles - */ - const LineStyles &line_styles () const - { - return mp_canvas->line_styles (); - } - - /** - * @brief An event signalling the change in the number of hierarchy levels shown - */ - tl::Event hier_levels_changed_event; - - /** - * @brief An event signalling a change in the annotations shape list - * - * If annotation shapes are added or removed, this event is triggered. - */ - tl::Event annotations_changed_event; - - /** - * @brief An event signalling a change in the hierarchy of the layouts - * - * If the hierarchy of a layout is changed, this event is triggered. - * This may happen due to the removal or insertion of cells or instances. - */ - tl::Event hier_changed_event; - - /** - * @brief An event signalling a change in the geometries of the layouts - * - * If something on the geometries of a cell in one the layouts changes, this - * event is triggered. This may happed due to the removal or insertion of shapes or cell instances. - * In general, this indicates the need for redrawing of the layout for example. - */ - tl::Event geom_changed_event; - - /** - * @brief An event triggered before something on a cellview is changed - * - * This event is triggered before something on the cellview (i.e. the current cell of - * of set of the cellview) is changed. The argument is the index of the cell view to be - * changed. - * This event is followed by a corresponding cellview_changed event after the cellview - * has changed. - */ - tl::event cellview_about_to_change_event; - - /** - * @brief An event triggered before something on the cellviews is changed - * - * This event is triggered before something on the cellviews is changed, i.e. a cellview is deleted or inserted. - * Each of these events is followed by a cellviews_changed event after the change has been made. - */ - tl::Event cellviews_about_to_change_event; - - /** - * @brief An event signalling that the cell views have changed. - * - * When a cellview is added or removed, this event is triggered after the change has been made. - * The corresponding event that is triggered before the change is made is cellviews_about_to_change_event. - */ - tl::Event cellviews_changed_event; - - /** - * @brief An event signalling a change in a cellview. - * - * If a cellview is changed (i.e. the cell is changed) this event is triggered. - * The integer argument will receive the index of the cellview that has changed. - * The corresponding event that is triggered before the change is made is cellview_about_to_change_event. - */ - tl::event cellview_changed_event; - - /** - * @brief An event signalling that a file has been loaded. - * - * If a new file is loaded, this event is triggered. - */ - tl::Event file_open_event; + QSize sizeHint () const; /** * @brief An event signalling that the view is going to close @@ -705,1932 +378,86 @@ public: */ tl::Event hide_event; - /** - * @brief An event signalling that the viewport has changed. - * - * If the viewport (the rectangle that is shown) changes, this event - * is triggered. - */ - tl::Event viewport_changed_event; - - /** - * @brief This event is triggered if the background color changed - */ - tl::Event background_color_changed_event; - - /** - * @brief An event signalling that the layer list has changed. - * - * If the layer list changes, this event is triggered with an integer argument. - * The arguments's bit 0 is set, if the properties have changed. If the arguments bit 1 is - * set, the hierarchy has changed. If the name of layer properties is changed, bit 2 is - * set. - */ - tl::event layer_list_changed_event; - - /** - * @brief An event signalling that a layer list was deleted. - * - * If a layer list is deleted from the layer list set, the event is triggered with - * the index of the deleted list as an integer parameter. - */ - tl::event layer_list_deleted_event; - - /** - * @brief An event signalling that a layer list was inserted. - * - * If a layer list is inserted into the layer list set, the event is triggered with - * the index of the new list as an integer parameter. - */ - tl::event layer_list_inserted_event; - - /** - * @brief An event signalling that the current layer list has changed. - * - * If the current layer list is changed, this event is triggered. - */ - tl::event current_layer_list_changed_event; - - /** - * @brief An event signalling that the current layer has changed - */ - tl::event current_layer_changed_event; - - - /** - * @brief An event signalling that the visibility of some cells has changed - */ - tl::Event cell_visibility_changed_event; - - /** - * @brief An event triggered if the active cellview changes - * This event is triggered after the active cellview changed. - */ - tl::Event active_cellview_changed_event; - - /** - * @brief An event triggered if the active cellview changes - * This event is triggered after the active cellview changed. The integer parameter is the index of the - * new cellview. - */ - tl::event active_cellview_changed_with_index_event; - - /** - * @brief Sets the currently active layer by layer properties and cell view index - * - * This method will look up that layer in the layer view tree and select that layer. - * This method will also select this layer. - * - * Returns false if the layer is not a valid one. - */ - bool set_current_layer (unsigned int cv_index, const db::LayerProperties &properties); - - /** - * @brief Sets the currently active layer by layer properties and cell view index - * - * If the layer does not exist, the user will be asked whether to create the layer. - * Returns false if the layer is not a valid one and the user defined to create the layer. - */ - bool set_or_request_current_layer (unsigned int cv_index, const db::LayerProperties &properties); - - /** - * @brief Sets the currently active layer - * - * The active layer is the one that is active in the layer - * browser panel. This method will also select this layer. - */ - void set_current_layer (const lay::LayerPropertiesConstIterator &l); - - /** - * @brief Retrieve the index of the currently active layer - * - * The active layer is the one that is active in the layer - * browser panel. - * This method returns a null iterator, if no layer is active. - */ - lay::LayerPropertiesConstIterator current_layer () const; - - /** - * @brief Return the layers that are selected in the layer browser - * - * Returns an empty list if no layer is selected. - */ - std::vector selected_layers () const; - - /** - * @brief Sets the layers that are selected in the layer browser - */ - void set_selected_layers (const std::vector &sel); - - /** - * @brief Save the given cellview into the given file (with options) - * If "update" is true, the cell view's properties will be updated (options, filename etc.). - */ - void save_as (unsigned int index, const std::string &filename, tl::OutputStream::OutputStreamMode om, const db::SaveLayoutOptions &options, bool update, int keep_backups); - - /** - * @brief Implementation of the undo operations - */ - virtual void undo (db::Op *op); - - /** - * @brief Implementation of the redo operations - */ - virtual void redo (db::Op *op); - - /** - * @brief Set the cellview at the given index - * - * If cvindex is used as the cellview index to associate the - * layout with. As a side effect, this method will emit a - * title_changed signal, which means that the cellview passed - * should be correctly named before to reflect the correct - * title if no explicit title is set. - */ - void set_layout (const lay::CellView &cv, unsigned int cvindex); - - /** - * @brief clear the cellviews - */ - void clear_cellviews (); - - /** - * @brief erase one cellview with the given index - */ - void erase_cellview (unsigned int index); - - /** - * @brief Save the layer properties - */ - void save_layer_props (const std::string &fn); - - /** - * @brief Load the layer properties - * - * @param fn The file to load. - */ - void load_layer_props (const std::string &fn); - - /** - * @brief Load the layer properties - * - * @param fn The file to load - * - * This version allows one to specify whether defaults should be used for all other layers by - * setting add_default to true - */ - void load_layer_props (const std::string &fn, bool add_default); - - /** - * @brief Load the layer properties - * - * @param fn The file to load - * - * This version allows one to specify whether defaults should be used for all other layers by - * setting add_default to true. In addition, this version will apply the .lyp definitions - * to a specific cellview after removing all definitions for this one. If cv_index is set - * to -1, the .lyp file will be applied to each cellview. In any case, the cv index specs - * in the .lyp file will be overridden. - */ - void load_layer_props (const std::string &fn, int cv_index, bool add_default); - - /** - * @brief Save the screen content to a file - */ - void save_screenshot (const std::string &fn); - - /** - * @brief Get the screen content as a QImage object - */ - QImage get_screenshot (); - - /** - * @brief Save an image file with the given width and height - */ - void save_image (const std::string &fn, unsigned int width, unsigned int height); - - /** - * @brief Save an image file with some options - * - * @param fn The path of the file to write - * @param width The width of the image in pixels - * @param height The height of the image - * @param linewidth The width of a line in pixels (usually 1) or 0 for default - * @param oversampling The oversampling factor (1..3) or 0 for default - * @param resolution The resolution (pixel size compared to a screen pixel size, i.e 1/oversampling) or 0 for default - * @param background The background color or lay::Color() for default - * @param foreground The foreground color or lay::Color() for default - * @param active The active color or lay::Color() for default - * @param target_box The box to draw or db::DBox() for default - * @param monochrome If true, monochrome images will be produced - */ - void save_image_with_options (const std::string &fn, unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, Color background, Color foreground, Color active_color, const db::DBox &target_box, bool monochrome); - - /** - * @brief Get the screen content as a QImage object with the given width and height - */ - QImage get_image (unsigned int width, unsigned int height); - - /** - * @brief Get the screen content as a QImage object with the given width and height - * - * @param width The width of the image in pixels - * @param height The height of the image - * @param linewidth The width of a line in pixels (usually 1) or 0 for default - * @param oversampling The oversampling factor (1..3) or 0 for default - * @param resolution The resolution (pixel size compared to a screen pixel size, i.e 1/oversampling) or 0 for default - * @param background The background color or lay::Color() for default - * @param foreground The foreground color or lay::Color() for default - * @param active The active color or lay::Color() for default - * @param target_box The box to draw or db::DBox() for default - * @param monochrome If true, monochrome images will be produced - */ - QImage get_image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, lay::Color background, lay::Color foreground, lay::Color active_color, const db::DBox &target_box, bool monochrome); - - /** - * @brief Hierarchy level selection setter - */ - void set_hier_levels (std::pair l); - - /** - * @brief Hierarchy level selection setter - */ - void set_min_hier_levels (int l) - { - set_hier_levels (std::pair (l, get_max_hier_levels ())); - } - - /** - * @brief Hierarchy level selection setter - */ - void set_max_hier_levels (int l) - { - set_hier_levels (std::pair (get_min_hier_levels (), l)); - } - - /** - * @brief Hierarchy level selection getter - */ - std::pair get_hier_levels () const; - - /** - * @brief Hierarchy level selection getter - */ - int get_min_hier_levels () const - { - return get_hier_levels ().first; - } - - /** - * @brief Hierarchy level selection getter - */ - int get_max_hier_levels () const - { - return get_hier_levels ().second; - } - - /** - * @brief Return true, if there is a "last" display state - */ - bool has_prev_display_state (); - - /** - * @brief Return true, if there is a "next" display state - */ - bool has_next_display_state (); - - /** - * @brief Cell box/label color setter - */ - void cell_box_color (lay::Color c); - - /** - * @brief Cell box/label getter - */ - lay::Color cell_box_color () const - { - return m_box_color; - } - - /** - * @brief Transform label flag setter - */ - void cell_box_text_transform (bool xform); - - /** - * @brief Transform label flag getter - */ - bool cell_box_text_transform () const - { - return m_box_text_transform; - } - - /** - * @brief Label font setter - */ - void cell_box_text_font (unsigned int f); - - /** - * @brief Label font setter - */ - unsigned int cell_box_text_font () const - { - return m_box_font; - } - - /** - * @brief Visibility of cell boxes - */ - void cell_box_visible (bool vis); - - /** - * @brief Visibility of cell boxes - */ - bool cell_box_visible () const - { - return m_cell_box_visible; - } - - /** - * @brief Min instance label size setter - */ - void min_inst_label_size (int px); - - /** - * @brief Min instance label size getter - */ - int min_inst_label_size () const - { - return m_min_size_for_label; - } - - /** - * @brief Visibility of text objects - */ - void text_visible (bool vis); - - /** - * @brief Visibility of text objects - */ - bool text_visible () const - { - return m_text_visible; - } - - /** - * @brief Show properties - */ - void show_properties_as_text (bool sp); - - /** - * @brief Show properties - */ - bool show_properties_as_text () - { - return m_show_properties; - } - - /** - * @brief Enable or disable bitmap caching - * - * Bitmap caching is used to optimize drawing by storing bitmaps - * in a cache for each cell. Repeated cells will be drawn faster then. - */ - void bitmap_caching (bool en); - - /** - * @brief Lazy rendering of text objects - */ - bool bitmap_caching () - { - return m_bitmap_caching; - } - - /** - * @brief Lazy rendering of text objects - */ - void text_lazy_rendering (bool lzy); - - /** - * @brief Lazy rendering of text objects - */ - bool text_lazy_rendering () - { - return m_text_lazy_rendering; - } - - /** - * @brief Text object font setter - */ - void text_font (unsigned int f); - - /** - * @brief Text object font getter - */ - unsigned int text_font () const - { - return m_text_font; - } - - /** - * @brief The default text size property - */ - void default_text_size (double fs); - - /** - * @brief The default text size property - */ - double default_text_size () const - { - return m_default_text_size; - } - - /** - * @brief Show or hide markers - */ - void show_markers (bool f); - - /** - * @brief "show_markers" property getter - */ - bool show_markers () const - { - return m_show_markers; - } - - /** - * @brief Don't show stipples - */ - void no_stipples (bool f); - - /** - * @brief "Don't show stipples" property getter - */ - bool no_stipples () const - { - return m_no_stipples; - } - - /** - * @brief Offset stipples property - */ - void offset_stipples (bool f); - - /** - * @brief Offset stipples property getter - */ - bool offset_stipples () const - { - return m_stipple_offset; - } - - /** - * @brief Apply text transformation property - */ - void apply_text_trans (bool f); - - /** - * @brief Apply text transformation property - */ - bool apply_text_trans () const - { - return m_apply_text_trans; - } - - /** - * @brief Text object color - */ - void text_color (lay::Color c); - - /** - * @brief Text object color - */ - lay::Color text_color () const - { - return m_text_color; - } - - /** - * @brief Clear all rulers if a new cell is selected (setter) - * - * If this property is set to true, all rulers are cleared - * if the cell is changed. - */ - void clear_ruler_new_cell (bool f); - - /** - * @brief Clear all rulers if a new cell is selected (getter) - * - * If this property is set to true, all rulers are cleared - * if the cell is changed. - */ - bool clear_ruler_new_cell () const - { - return m_clear_ruler_new_cell; - } - - /** - * @brief Switch new cell to full hierarchy property - * - * If this property is set to true, all hierarchy levels are selected - * if the cell is changed. - */ - void full_hier_new_cell (bool f); - - /** - * @brief Switch new cell to full hierarchy property - * - * If this property is set to true, all hierarchy levels are selected - * if the cell is changed. - */ - bool full_hier_new_cell () const - { - return m_full_hier_new_cell; - } - - /** - * @brief Fit new cell property - * - * If this property is set to false, the coordinate window is not - * changed if the cell is changed. - */ - void fit_new_cell (bool f); - - /** - * @brief Fit new cell - * - * If this property is set to false, the coordinate window is not - * changed if the cell is changed. - */ - bool fit_new_cell () const - { - return m_fit_new_cell; - } - - /** - * @brief The pan distance - * - * The pan distance is given relative to the current width and height. - */ - void pan_distance (double d); - - /** - * @brief Gets the pan distance - */ - double pan_distance () const; - - /** - * @brief Get the mouse wheel mode - * - * The mouse wheel mode determines how the wheel behaves. Mode 0 is the - * default mode, mode 1 is the alternative mode (default is up/down, - * shift is left/right, ctrl is zoom). - */ - int mouse_wheel_mode () const - { - return m_wheel_mode; - } - - /** - * @brief Set the mouse wheel mode - * - * The mouse wheel mode determines how the wheel behaves. Mode 0 is the - * default mode, mode 1 is the alternative mode (default is up/down, - * shift is left/right, ctrl is zoom). - */ - void mouse_wheel_mode (int m) - { - m_wheel_mode = m; - } - - /** - * @brief Sets the color palette - * - * The color palette is used for coloring new layers and is shown in the - * layer toolbox. - */ - void set_palette (const lay::ColorPalette &); - - /** - * @brief Gets the color palette - */ - const lay::ColorPalette &get_palette () const - { - return m_palette; - } - - /** - * @brief Sets the stipple palette - * - * The stipple palette is used for selecting stipples for new layers and is shown in the - * layer toolbox. - */ - void set_palette (const lay::StipplePalette &); - - /** - * @brief Gets the stipple palette - */ - const lay::StipplePalette &get_stipple_palette () const - { - return m_stipple_palette; - } - - /** - * @brief Sets the line style palette - * - * The line style palette is used for selecting line styles and is shown in the - * layer toolbox. - */ - void set_palette (const lay::LineStylePalette &); - - /** - * @brief Gets the line style palette - */ - const lay::LineStylePalette &get_line_style_palette () const - { - return m_line_style_palette; - } - - /** - * @brief Reloads the given cellview into the current view - * - * The cellview is given by index in the current view's cellview list. - */ - void reload_layout (unsigned int cv_index); - - /** - * @brief Load a (new) file into the layout - * - * The add_cellview param controls whether to create a new cellview - * or clear all cellviews before. - * - * The new layout will use the default technology. - * - * @return The index of the cellview loaded. - */ - unsigned int load_layout (const std::string &filename, bool add_cellview) - { - return load_layout (filename, std::string (), add_cellview); - } - - /** - * @brief Load a (new) file into the layout associating it with the given technology - * - * The add_cellview param controls whether to create a new cellview - * or clear all cellviews before. - * - * @return The index of the cellview loaded. - */ - unsigned int load_layout (const std::string &filename, const std::string &technology, bool add_cellview); - - /** - * @brief Load a (new) file into the layout with the options - * - * The add_cellview param controls whether to create a new cellview - * or clear all cellviews before. - * - * The new layout will use the default technology. - * - * @param options The options to use when loading. - * @param add_cellview_param See above. - * @return The index of the cellview loaded. - */ - unsigned int load_layout (const std::string &filename, const db::LoadLayoutOptions &options, bool add_cellview) - { - return load_layout (filename, options, std::string (), add_cellview); - } - - /** - * @brief Load a (new) file into the layout with the options and using the specified technology - * - * The add_cellview param controls whether to create a new cellview - * or clear all cellviews before. - * - * @param options The options to use when loading. - * @param add_cellview_param See above. - * @return The index of the cellview loaded. - */ - unsigned int load_layout (const std::string &filename, const db::LoadLayoutOptions &options, const std::string &technology, bool add_cellview); - - /** - * @brief Create a new, empty layout - * - * The add_cellview param controls whether to create a new cellview - * or clear all cellviews before. - * - * The new layout will use the default technology. - * - * @return The index of the cellview loaded. - */ - unsigned int create_layout (bool add_cellview) - { - return create_layout (std::string (), add_cellview, true); - } - - /** - * @brief Create a new, empty layout using the specified technology - * - * The add_cellview param controls whether to create a new cellview - * or clear all cellviews before. - * - * @return The index of the cellview created. - */ - unsigned int create_layout (const std::string &technology, bool add_cellview) - { - return create_layout (technology, add_cellview, true); - } - - /** - * @brief Create a new, empty layout using the specified technology - * - * The add_cellview param controls whether to create a new cellview - * or clear all cellviews before. This version allows one to specify whether layer properties shall be created. - * - * @return The index of the cellview created. - */ - unsigned int create_layout (const std::string &technology, bool add_cellview, bool initialize_layers); - - /** - * @brief Add an existing layout or replace the current cellview by the given layout - * - * The add_cellview param controls whether to add the layout as a new cellview - * or clear all cellviews before. - * - * The "initialize_layers" parameter allows one to specify whether the layer properties shall be initialized. - * - * @return The index of the cellview loaded. - */ - unsigned int add_layout (lay::LayoutHandle *layout_handle, bool add_cellview, bool initialize_layers = true); - - /** - * @brief Pass the current position from the mouse tracker to the status bar - */ - void current_pos (double x, double y); - - /** - * @brief Get the index of the active cellview (shown in hierarchy browser) - */ - int active_cellview_index () const; - - /** - * @brief Get the index of the active cellview (shown in hierarchy browser) - */ - const lay::CellView &active_cellview () const; - - /** - * @brief Gets a cellview reference to the active cellview - */ - lay::CellViewRef active_cellview_ref (); - - /** - * @brief Select a certain cellview for the active one - */ - void set_active_cellview_index (int index); - - /** - * @brief Cell paths of the selected cells - * - * The current cell is the one highlighted in the browser with the focus rectangle. The - * current path is returned for the cellview given by cv_index. - */ - void selected_cells_paths (int cv_index, std::vector &paths) const; - - /** - * @brief Cell path of the current cell - * - * The current cell is the one highlighted in the browser with the focus rectangle. The - * current path is returned for the cellview given by cv_index. - */ - void current_cell_path (int cv_index, cell_path_type &path) const; - - /** - * @brief Cell path of the current cell - * - * This method version is provided for automation purposes mainly. - */ - cell_path_type get_current_cell_path (int cv_index) const - { - cell_path_type r; - current_cell_path (cv_index, r); - return r; - } - - /** - * @brief Cell path of the current cell in the active cellview - * - * This is a convenience function returning the path for the active cellview. - */ - void current_cell_path (cell_path_type &path) const - { - current_cell_path (active_cellview_index (), path); - } - - /** - * @brief Set the path to the current cell - * - * The current cell is the one highlighted in the browser with the focus rectangle. The - * cell given by the path is highlighted and scrolled into view. - */ - void set_current_cell_path (int cv_index, const cell_path_type &path); - - /** - * @brief Set the path to the current cell is the current cellview - * - * This is a convenience function setting the path for the active cellview. - */ - void set_current_cell_path (const cell_path_type &path) - { - set_current_cell_path (active_cellview_index (), path); - } - - /** - * @brief Obtain the number of cellviews - */ - unsigned int cellviews () const - { - return (unsigned int) m_cellviews.size (); - } - - /** - * @brief Obtain the cellviews as a vector - */ - const std::list &cellview_list () const - { - return m_cellviews; - } - - /** - * @brief Obtain the cell view reference for an index - * - * If the index is invalid, an empty cell view reference is returned - */ - const CellView &cellview (unsigned int index) const; - - /** - * @brief Gets a cellview reference to the active cellview - */ - lay::CellViewRef cellview_ref (unsigned int index); - - /** - * @brief Gets the index of the given cellview - * Based on the pointer passed to the function, the index of the respective cellview - * will be returned. If a null pointer is given or the pointer is not a valid cellview, - * -1 will be returned. - */ - int index_of_cellview (const lay::CellView *cv) const; - - /** - * @brief Obtain the list of annotation shapes - */ - const lay::AnnotationShapes &annotation_shapes () const - { - return m_annotation_shapes; - } - - /** - * @brief Obtain the list of annotation shapes (non-const version) - */ - lay::AnnotationShapes &annotation_shapes () - { - return m_annotation_shapes; - } - - /** - * @brief Select the list of cellviews for this window and fit cell - * - * Warning: use with care! - */ - void select_cellviews_fit (const std::list &cvs); - - /** - * @brief Select the list of cellviews for this window - * - * Warning: use with care! - */ - void select_cellviews (const std::list &cvs); - - /** - * @brief Configures the cellview with the given index - * @param index Index of the cellview to configure - * @param cv The cellview that provides the new configuration - */ - void select_cellview (int index, const CellView &cv); - - /** - * @brief Shift and scale the window - */ - void shift_window (double f, double dx, double dy); - - /** - * @brief Goto window - * - * Position the window to the new position x and y with a size of s (approximately). - * If s is negative or zero, the windows is just shifted. - */ - void goto_window (const db::DPoint &p, double s = -1.0); - - /** - * @brief Return the displayed window - */ - db::DBox box () const; - - /** - * @brief Display a status message - */ - void message (const std::string &s = "", int timeout = 10); - - /** - * @brief Create a new cell with the given in the given cellview - * - * @param cv_index The index of the cellview where to create the cell - * @param cell_name The name of the cell (an exception is thrown if a cell of that name already exists) - * @return The index of the new cell - */ - db::cell_index_type new_cell (int cv_index, const std::string &cell_name); - - /** - * @brief Bookmark the current view under the given name - */ - void bookmark_view (const std::string &name); - - /** - * @brief Asks for a bookmark name and bookmark the current view under this name - */ - void bookmark_current_view (); - - /** - * @brief Show the bookmark management form - */ - void manage_bookmarks (); - - /** - * @brief Obtain the bookmarks list - */ - const BookmarkList &bookmarks () const - { - return m_bookmarks; - } - - /** - * @brief Set the bookmarks list - */ - void bookmarks (const BookmarkList &b); - - std::pair redo_available (); - std::pair undo_available (); - - /** - * @brief Select a certain mode (by index) - */ - void mode (int m); - - /** - * @brief Switches the application's mode - * - * Switches the mode on application level. Use this method to initiate - * a mode switch from the view. - */ - void switch_mode (int m); - - /** - * @brief Test, if the view is currently in move mode. - */ - bool is_move_mode () const; - - /** - * @brief Test, if the view is currently in selection mode. - */ - bool is_selection_mode () const; - - /** - * @brief Query the intrinsic mouse modes available - */ - static unsigned int intrinsic_mouse_modes (std::vector *descriptions); - - /** - * @brief Updates the menu for the given view - * If the view is 0, the menu shall be updated to reflect "no view active" - */ - static void update_menu (lay::LayoutView *view, lay::AbstractMenu &menu); - - /** - * @brief Query the default mode - */ - static int default_mode (); - - /** - * @brief Get a list of cellview index and transform variants - */ - std::set< std::pair > cv_transform_variants () const; - - /** - * @brief Get the global transform variants for a given cellview index - */ - std::vector cv_transform_variants (int cv_index) const; - - /** - * @brief Get the global transform variants for a given cellview index and layer - */ - std::vector cv_transform_variants (int cv_index, unsigned int layer) const; - - /** - * @brief Get the transformation variants for a given cellview index ordered by layer - */ - std::map > cv_transform_variants_by_layer (int cv_index) const; - - /** - * @brief Access to the hidden cell list - */ - const std::vector > &hidden_cells () const - { - return m_hidden_cells; - } - - /** - * @brief Get the "dbu_coordinates" flag - * - * If this flag is true, the property dialogs and other display functions should use - * database units to display coordinates etc. - */ - bool dbu_coordinates () const - { - return m_dbu_coordinates; - } - - /** - * @brief Set the "dbu_coordinates" flag - * - * If this flag is true, the property dialogs and other display functions should use - * database units to display coordinates etc. - */ - void dbu_coordinates (bool f); - - /** - * @brief Get the "absolute_coordinates" flag - * - * If this flag is true, the property dialogs and other display functions should use - * absolute (on top level) coordinates for points etc. - * "absolute" may as well refer to orientation, not only to coordinates, - * if transformations are considered. - */ - bool absolute_coordinates () const - { - return m_absolute_coordinates; - } - - /** - * @brief Set the "absolute_coordinates" flag - * - * If this flag is true, the property dialogs and other display functions should use - * absolute (on top level) coordinates for points etc. - * "absolute" may as well refer to orientation, not only to coordinates, - * if transformations are considered. - */ - void absolute_coordinates (bool f); - - /** - * @brief Get the view object widget - * - * This method intentionally delivers the ViewObjectWidget, not the - * LayoutCanvas to emphasize that the LayoutCanvas object shall not - * be modified. - */ - lay::ViewObjectWidget *view_object_widget () - { - return mp_canvas; - } - - /** - * @brief Get the current viewport - */ - const lay::Viewport &viewport () const - { - return mp_canvas->viewport (); - } - - /** - * @brief Background color property - */ - lay::Color background_color () const - { - return mp_canvas->background_color (); - } - - /** - * @brief Foreground color property - */ - lay::Color foreground_color () const - { - return mp_canvas->foreground_color (); - } - - /** - * @brief Active color property - */ - lay::Color active_color () const - { - return mp_canvas->active_color (); - } - - /** - * @brief Write accessor to the "drop small cells" flag - */ - void drop_small_cells (bool m); - - /** - * @brief Read accessor to the "drop small cells" flag - */ - bool drop_small_cells () const - { - return m_drop_small_cells; - } - - /** - * @brief Write accessor to the "drop small cells" value - */ - void drop_small_cells_value (unsigned int s); - - /** - * @brief Read accessor to the "drop small cells" value - */ - unsigned int drop_small_cells_value () const - { - return m_drop_small_cells_value; - } - - /** - * @brief Write accessor to the "drop small cells" condition - */ - void drop_small_cells_cond (drop_small_cells_cond_type t); - - /** - * @brief Read accessor to the "drop small cells" condition - */ - drop_small_cells_cond_type drop_small_cells_cond () const - { - return m_drop_small_cells_cond; - } - - /** - * @brief Gets a value indicating whether guiding shapes are visible - */ - bool guiding_shapes_visible () const - { - return m_guiding_shape_visible; - } - - /** - * @brief Sets a value indicating whether guiding shapes are visible - */ - void guiding_shapes_visible (bool v); - - /** - * @brief Gets the guiding shapes color - */ - lay::Color guiding_shapes_color () const - { - return m_guiding_shape_color; - } - - /** - * @brief Sets the guiding shapes color - */ - void guiding_shapes_color (lay::Color c); - - /** - * @brief Gets the guiding shapes line width - */ - int guiding_shapes_line_width () const - { - return m_guiding_shape_line_width; - } - - /** - * @brief Sets the guiding shapes line width - */ - void guiding_shapes_line_width (int lw); - - /** - * @brief Gets the guiding shapes vertex size - */ - int guiding_shapes_vertex_size () const - { - return m_guiding_shape_vertex_size; - } - - /** - * @brief Sets the guiding shapes vertex size - */ - void guiding_shapes_vertex_size (int lw); - - /** - * @brief Read accessor to the "abstract mode width" property. - * - * The abstract mode width enables abstract mode (for values > 0) and - * specifies the border to search for touching shapes. - */ - double abstract_mode_width () const - { - return m_abstract_mode_enabled ? m_abstract_mode_width : 0.0; - } - - /** - * @brief Read accessor to the "child context enabled" property. - * - * If child context is enabled, a third set of bit planes must be created by the redraw thread - * containing the shapes for the below-top-level objects. - */ - bool child_context_enabled () const - { - return m_child_ctx_enabled; - } - - /** - * @brief Write accessor to the "draw array border instances" flag - */ - void draw_array_border_instances (bool m); - - /** - * @brief Read accessor to the "draw array border instances" flag - */ - bool draw_array_border_instances () const - { - return m_draw_array_border_instances; - } - - /** - * @brief Get the Drawings interface - * - * Although the Drawings interface is implemented by LayoutCanvas, - * it is a different interface from ViewObjectWidget. - */ - lay::Drawings *drawings () - { - return mp_canvas; - } - - /** - * @brief Select synchronous mode or deselect it - */ - void set_synchronous (bool sync_mode); - - /** - * @brief Tell the state of synchronous mode - */ - bool synchronous () const - { - return m_synchronous; - } - - /** - * @brief Set the number of drawing workers (if not synchronous) - */ - void set_drawing_workers (int workers); - - /** - * @brief Get the number of drawing workers - */ - int drawing_workers () const - { - return m_drawing_workers; - } - - /** - * @brief Gets a value indicating whether the view will accept a dropped file with the given URL or path - */ - virtual bool accepts_drop (const std::string &path_or_url) const; - - /** - * @brief Gets called when a file or URL is dropped on the view - */ - virtual void drop_url (const std::string &path_or_url); - - /** - * @brief Gets a list of all plugins - */ - const std::vector &plugins () - { - return mp_plugins; - } - - /** - * @brief Localize a plugin by name - * - * This method will return 0, if no such plugin is registered - */ - Plugin *get_plugin_by_name (const std::string &name) const; - - /** - * @brief Localize the plugin of the given Type - * - * This method will return 0, if no such plugin is registered - */ - template - PI *get_plugin () const - { - PI *pi = 0; - for (std::vector::const_iterator p = mp_plugins.begin (); p != mp_plugins.end () && !pi; ++p) { - pi = dynamic_cast (*p); - } - return pi; - } - - /** - * @brief Localize the plugins of the given Type - * - * This method will return 0, if no such plugin is registered - */ - template - std::vector get_plugins () const - { - std::vector pi; - for (std::vector::const_iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) { - if (dynamic_cast (*p) != 0) { - pi.push_back (dynamic_cast (*p)); - } - } - return pi; - } - - /** - * @brief Create a plugin of the given type - * - * This method can be used to selectively create plugins when the NoPlugin option - * is used. If no such plugin is registered, no plugin is created. - * If a plugin with that name is already registered, it is not created again. - * PD is the type of the declaration. - */ - template - void create_plugin () - { - for (std::vector::const_iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) { - if (dynamic_cast ((*p)->plugin_declaration ()) != 0) { - return; - } - } - for (tl::Registrar::iterator cls = tl::Registrar::begin (); cls != tl::Registrar::end (); ++cls) { - if (dynamic_cast (&*cls) != 0) { - create_plugin (&*cls); - break; - } - } - } - - - /** - * @brief Enable or disable the actions for edit functions - * - * This method is used by non-modal dialogs that want to suppress any editing - * activities (like browsers) while they are open. - * - * This method can be called multiple times and will count the enable/disable - * transitions. Each disable will cancel on enable call. - */ - void enable_edits (bool enable); - - /** - * @brief Gets a value indicating whether edits are enabled or not - * - * "enable_edits" will change this value. - */ - bool edits_enabled () const - { - return m_disabled_edits <= 0; - } - - /** - * @brief Rename the given cellview to the given name - * - * The name of the cell view is shown in the title - */ - void rename_cellview (const std::string &name, int cellview_index); - - /** - * @brief Descend into the hierarchy along the given specific path for the given cellview - */ - void descend (const std::vector &path, int cellview_index); - - /** - * @brief Ascend one level in the hierarchy for the given cellview - * - * @return The instance element removed by ascending the path - */ - db::InstElement ascend (int cellview_index); - - /** - * @brief Select a cell by path for a certain cell view and fit cell - */ - void select_cell_fit (const cell_path_type &path, int cellview_index); - - /** - * @brief Select a cell by index for a certain cell view and fit cell - */ - void select_cell_fit (cell_index_type index, int cellview_index); - - /** - * @brief Select a cell by path for a certain cell view - */ - void select_cell (const cell_path_type &path, int cellview_index); - - /** - * @brief Select a cell by index for a certain cell view - */ - void select_cell (cell_index_type index, int cellview_index); - - /** - * @brief Check if a cell is hidden - */ - bool is_cell_hidden (cell_index_type ci, int cellview_index) const; - - /** - * @brief Get the hidden cells for a certain cellview - */ - const std::set &hidden_cells (int cellview_index) const; - - /** - * @brief Add a cell to the hidden cell list - */ - void hide_cell (cell_index_type ci, int cellview_index); - - /** - * @brief Remove a cell from the hidden cell list - */ - void show_cell (cell_index_type ci, int cellview_index); - - /** - * @brief Clears the hidden cell list - */ - void show_all_cells (); - - /** - * @brief Clears the hidden cell list for the given cellview - */ - void show_all_cells (int cv_index); - - /** - * @brief Update the layout view to the current state - * - * This method must be called in order to trigger the update of - * the contents. It will be known, what needs to be updated. - */ - void update_content (); - - /** - * @brief Force an unconditional update - * - * This method is supposed to be used to ensure everything is updated. - * TODO: this method should become obsolete once there is a consistent - * signalling of states implemented. - */ - void force_update_content (); - - /** - * @brief Create a set of initial layer properties for the given cellview - * - * @param cv_index The cellview for which to produce a set of layer properties - * @param lyp_file The layer properties file to load or empty if no file should be loaded - * @param add_missing True, if missing layers should be added (ignored if lyp_file is empty) - */ - void create_initial_layer_props (int cv_index, const std::string &lyp_file, bool add_missing); - - /** - * @brief Merges the given properties into the cell properties of this view - */ - void merge_layer_props (const std::vector &props); - - /** - * @brief Internal method: check, if the layer tree is and an consistent state. - * - * This method is used by the layer tree model to check, if the tree has been brought into - * a consistent state. - * HINT: for the layout this is solved more consistently with the "under construction" attribute - * of the layout. There is no equivalent object for the layer tree currently. - */ - bool layer_model_updated (); - - /** - * @brief Get the "select inside PCells" selection mode - * - * @return true, objects inside PCells can be selected - */ - bool select_inside_pcells_mode () const - { - return m_sel_inside_pcells; - } - - /** - * @brief Get the transient selection mode - * - * @return true, if transient (hover) selection mode is enabled - */ - bool transient_selection_mode () const - { - return m_transient_selection_mode; - } - - /** - * @brief Get the default color for markers - */ - lay::Color default_marker_color () const - { - return m_marker_color; - } - - /** - * @brief Get the default line width for markers - */ - int default_marker_line_width () const - { - return m_marker_line_width; - } - - /** - * @brief Get the default marker dither pattern index - */ - int default_dither_pattern () const - { - return m_marker_dither_pattern; - } - - /** - * @brief Get the default marker line style index - */ - int default_line_style () const - { - return m_marker_line_style; - } - - /** - * @brief Get the default vertex size for markers - */ - int default_marker_vertex_size () const - { - return m_marker_vertex_size; - } - - /** - * @brief Get the default halo flag for markers - */ - int default_marker_halo () const - { - return m_marker_halo; - } - - /** - * @brief Gets the "search range" in pixels (for single click) - * The search range applies whenever some object is looked up in the vicinity of the - * mouse cursor. This value gives the search range in pixels. - */ - unsigned int search_range (); - - /** - * @brief Sets the "search range" in pixels (for single click) - */ - void set_search_range (unsigned int sr); - - /** - * @brief Gets the "search range" in pixels (for box) - * The search range applies whenever some object is looked up in the vicinity of the - * mouse cursor. This value gives the search range in pixels. - */ - unsigned int search_range_box (); - - /** - * @brief Sets the "search range" in pixels (for box) - */ - void set_search_range_box (unsigned int sr); - - /** - * @brief Return true, if any cellview is editable - */ - bool is_editable () const; - - /** - * @brief Get the view_op's for rendering the layers - */ - const std::vector &get_view_ops () const - { - return mp_canvas->get_view_ops (); - } - - /** - * @brief Get the redraw layer info vector - */ - const std::vector &get_redraw_layers () const - { - return mp_canvas->get_redraw_layers (); - } - - /** - * @brief Add missing layers - */ - void add_missing_layers (); - - /** - * @brief Add layers which are not part of the LayerState - */ - void add_new_layers (const LayerState &snapshot); - - /** - * @brief Gets a snapshot of the current layers (can be used for add_missing_layers later) - */ - LayerState layer_snapshot () const; - - /** - * @brief Remove unused layers - */ - void remove_unused_layers (); - - /** - * @brief Returns true, if the layer source shall be shown always in the layer properties tree - */ - bool always_show_source () const - { - return m_always_show_source; - } - - /** - * @brief Returns true, if the layer/datatype shall be shown always in the layer properties tree - */ - bool always_show_ld () const - { - return m_always_show_ld; - } - - /** - * @brief Returns true, if the layout index shall be shown always in the layer properties tree - */ - bool always_show_layout_index () const - { - return m_always_show_layout_index; - } - - /** - * @brief Add a marker database - * - * The layout view will become owner of the database. - * - * @param rdb The database to add - * @return The index of the database - */ - unsigned int add_rdb (rdb::Database *rdb); - - /** - * @brief Replaces a marker database - * - * The layout view will become owner of the database. - * If the index is not valid, the database will be added and the new index will be returned. - * - * @param db_index The index of the database to replace - * @param rdb The database to add - */ - unsigned int replace_rdb (unsigned int db_index, rdb::Database *rdb); - - /** - * @brief Get the marker database by index - * - * @param index The index of the database - * @return A pointer to the database or 0 if the index was not valid. - */ - rdb::Database *get_rdb (int index); - - /** - * @brief Get the marker database by index (const version) - * - * @param index The index of the database - * @return A pointer to the database or 0 if the index was not valid. - */ - const rdb::Database *get_rdb (int index) const; - - /** - * @brief Open the RDB browser for a given database and associated cv index - */ - void open_rdb_browser (int rdb_index, int cv_index); - - /** - * @brief Remove the marker database with the given index - * - * This will release the marker database at the given index. The list - * will be reduced by that element. This means, that the following elements - * will have different indicies. - */ - void remove_rdb (unsigned int index); - - /** - * @brief Get the number of marker databases - */ - unsigned int num_rdbs () const - { - return (unsigned int) m_rdbs.size (); - } - - /** - * @brief An event signalling a change in the marker database list - * - * If marker databases are added or removed, this event is triggered. - */ - tl::Event rdb_list_changed_event; - - /** - * @brief Add a Netlist database - * - * The layout view will become owner of the database. - * - * @param l2ndb The database to add - * @return The index of the database - */ - unsigned int add_l2ndb (db::LayoutToNetlist *l2ndb); - - /** - * @brief Replaces a Netlist database - * - * The layout view will become owner of the database. - * If the index is not valid, the database will be added and the new index will be returned. - * - * @param db_index The index of the database to replace - * @param l2ndb The database to add - */ - unsigned int replace_l2ndb (unsigned int db_index, db::LayoutToNetlist *l2ndb); - - /** - * @brief Get the netlist database by index - * - * @param index The index of the database - * @return A pointer to the database or 0 if the index was not valid. - */ - db::LayoutToNetlist *get_l2ndb (int index); - - /** - * @brief Get the netlist database by index (const version) - * - * @param index The index of the database - * @return A pointer to the database or 0 if the index was not valid. - */ - const db::LayoutToNetlist *get_l2ndb (int index) const; - - /** - * @brief Open the L2NDB browser for a given database and associated cv index - */ - void open_l2ndb_browser (int l2ndb_index, int cv_index); - - /** - * @brief Remove the netlist database with the given index - * - * This will release the netlist database at the given index. The list - * will be reduced by that element. This means, that the following elements - * will have different indicies. - */ - void remove_l2ndb (unsigned int index); - - /** - * @brief Get the number of netlist databases - */ - unsigned int num_l2ndbs () const - { - return (unsigned int) m_l2ndbs.size (); - } - - /** - * @brief An event signalling a change in the netlist database list - * - * If netlist databases are added or removed, this event is triggered. - */ - tl::Event l2ndb_list_changed_event; - - /** - * @brief Deliver a size hint (reimplementation of QWidget) - */ - QSize sizeHint () const; - - /** - * @brief Ensure the given box is visible - */ - void ensure_visible (const db::DBox &b); - - /** - * @brief Specify the global transformation - */ - void set_global_trans (const db::DCplxTrans &b); - - /** - * @brief Gets the global transformation - */ - const db::DCplxTrans &global_trans () const - { - return mp_canvas->global_trans (); - } - - /** - * @brief Removes the previous state from the stack - */ - void pop_state (); - - /** - * @brief Clears the state stack - */ - void clear_states (); - - /** - * @brief Zoom the given box into view - */ - void zoom_box (const db::DBox &b); - - /** - * @brief Zoom the given box into view and select hierarchy levels - */ - void zoom_box_and_set_hier_levels (const db::DBox &b, const std::pair &levels); - - /** - * @brief Specify the transformation explicitly - */ - void zoom_trans (const db::DCplxTrans &b); - - /** - * @brief Move the viewport such that the given point is at the center of the viewport - */ - void pan_center (const db::DPoint &p); - - /** - * @brief Goto a position/cell view that was saved with save_view - */ - void goto_view (const DisplayState &state); - - /** - * @brief Save a position/cell view that can be used for "goto_view" - */ - void save_view (DisplayState &state) const; - - // access to the basic services - lay::MouseTracker *mouse_tracker () const { return mp_tracker; } - lay::ZoomService *zoom_service () const { return mp_zoom_service; } - lay::SelectionService *selection_service () const { return mp_selection_service; } - lay::MoveService *move_service () const { return mp_move_service; } - - /** - * @brief Create all plugins - * - * If plugins already exist, they are deleted and created again - */ - void create_plugins (const lay::PluginDeclaration *except_this = 0); - - /** - * @brief Gets the full field box - * - * This is the box to which the view will zoom on zoom_fit(). - * This box is supposed to cover everything inside the view. - */ - db::DBox full_box () const; - public slots: /** * @brief Store the current state on the "previous states" stack */ - void store_state (); + void store_state () + { + LayoutViewBase::store_state (); + } /** * @brief Cancels all edit operations, clears the selection and resets the mode to "Select" */ - void cancel_esc (); + void cancel_esc () + { + LayoutViewBase::cancel_esc (); + } /** * @brief Cancels all edit operations and clears the selection */ - void cancel (); + void cancel () + { + LayoutViewBase::cancel (); + } /** * @brief Cancels all edit operations but maintains selection */ - void cancel_edits (); + void cancel_edits () + { + LayoutViewBase::cancel_edits (); + } /** * @brief Select all levels of hierarchy available */ - void max_hier (); + void max_hier () + { + LayoutViewBase::max_hier (); + } /** * @brief Stop activities like shape browser and redrawing thread */ - void stop (); + void stop () + { + LayoutViewBase::stop (); + } /** * @brief Stop redrawing thread */ - void stop_redraw (); + void stop_redraw () + { + LayoutViewBase::stop_redraw (); + } /** * @brief Select last display state */ - void prev_display_state (); + void prev_display_state () + { + LayoutViewBase::prev_display_state (); + } /** * @brief Select next display state */ - void next_display_state (); + void next_display_state () + { + LayoutViewBase::next_display_state (); + } /** * @brief Ensure the selection is visible */ - void ensure_selection_visible (); + void ensure_selection_visible () + { + LayoutViewBase::ensure_selection_visible (); + } /** * @brief Select a cell by index for a certain cell view @@ -2638,40 +465,127 @@ public slots: * This will be forwarded to select_cell or select_cell_fit depending * on the m_fit_new_cell flag. */ - void select_cell_dispatch (const cell_path_type &path, int cellview_index); + void select_cell_dispatch (const cell_path_type &path, int cellview_index) + { + LayoutViewBase::select_cell_dispatch (path, cellview_index); + } /** * @brief Called when the current layer changed */ - void current_layer_changed_slot (const lay::LayerPropertiesConstIterator &iter); + void current_layer_changed_slot (const lay::LayerPropertiesConstIterator &iter) + { + LayoutViewBase::current_layer_changed_slot (iter); + } // zoom slots - void zoom_fit (); - void zoom_fit_sel (); - void zoom_in (); - void zoom_out (); - void pan_left (); - void pan_up (); - void pan_right (); - void pan_down (); - void pan_left_fast (); - void pan_up_fast (); - void pan_right_fast (); - void pan_down_fast (); + void zoom_fit () + { + LayoutViewBase::zoom_fit (); + } + + void zoom_fit_sel () + { + LayoutViewBase::zoom_fit_sel (); + } + + void zoom_in () + { + LayoutViewBase::zoom_in (); + } + + void zoom_out () + { + LayoutViewBase::zoom_out (); + } + + void pan_left () + { + LayoutViewBase::pan_left (); + } + + void pan_up () + { + LayoutViewBase::pan_up (); + } + + void pan_right () + { + LayoutViewBase::pan_right (); + } + + void pan_down () + { + LayoutViewBase::pan_down (); + } + + void pan_left_fast () + { + LayoutViewBase::pan_left_fast (); + } + + void pan_up_fast () + { + LayoutViewBase::pan_up_fast (); + } + + void pan_right_fast () + { + LayoutViewBase::pan_right_fast (); + } + + void pan_down_fast () + { + LayoutViewBase::pan_down_fast (); + } // called by children and owner - void redraw (); - void redraw_layer (unsigned int index); - void redraw_deco_layer (); - void redraw_cell_boxes (); - void layer_tab_changed (); - void layer_order_changed (); - void timer (); - void menu_activated (const std::string &symbol); - static std::vector menu_symbols (); + void redraw () + { + LayoutViewBase::redraw (); + } + + void redraw_layer (unsigned int index) + { + LayoutViewBase::redraw_layer (index); + } + + void redraw_deco_layer () + { + LayoutViewBase::redraw_deco_layer (); + } + + void redraw_cell_boxes () + { + LayoutViewBase::redraw_cell_boxes (); + } + + void layer_tab_changed () + { + LayoutViewBase::layer_tab_changed (); + } + + void layer_order_changed () + { + LayoutViewBase::layer_order_changed (); + } + + void timer () + { + LayoutViewBase::timer (); + } + + void min_hier_changed (int i) + { + LayoutViewBase::min_hier_changed (i); + } + + void max_hier_changed (int i) + { + LayoutViewBase::max_hier_changed (i); + } + void deactivate_all_browsers (); - void min_hier_changed (int i); - void max_hier_changed (int i); private: // event handlers used to connect to the layout object's events @@ -2686,8 +600,16 @@ private: void signal_apply_technology (lay::LayoutHandle *layout_handle); private slots: - void active_cellview_changed (int index); - void active_library_changed (int index); + void active_cellview_changed (int index) + { + LayoutViewBase::active_cellview_changed (index); + } + + void active_library_changed (int index) + { + LayoutViewBase::active_library_changed (index); + } + void side_panel_destroyed (); signals: @@ -2736,33 +658,8 @@ signals: */ void current_layer_changed (const lay::LayerPropertiesConstIterator &l); -protected: - /** - * @brief Establish the view operations - */ - void set_view_ops (); - - /** - * @brief Deactivate the view - * - * A view gets "deactivated" if it is no longer the current one. - * This is the opposite operation than activation. - */ - void deactivate (); - - /** - * @brief Activate the view - * - * This method gets called when the view becomes the current one. - */ - void activate (); - private: - bool m_editable; - int m_disabled_edits; - unsigned int m_options; QTimer *mp_timer; - lay::LayoutCanvas *mp_canvas; QFrame *mp_left_frame; lay::LayerControlPanel *mp_control_panel; lay::HierarchyControlPanel *mp_hierarchy_panel; @@ -2772,165 +669,21 @@ private: lay::EditorOptionsFrame *mp_editor_options_frame; QSpinBox *mp_min_hier_spbx; QSpinBox *mp_max_hier_spbx; - std::list m_cellviews; - lay::AnnotationShapes m_annotation_shapes; - std::vector > m_hidden_cells; - std::string m_title; - tl::vector m_rdbs; - tl::vector m_l2ndbs; - std::string m_def_lyp_file; - bool m_add_other_layers; - bool m_always_show_source; - bool m_always_show_ld; - bool m_always_show_layout_index; - bool m_synchronous; - int m_drawing_workers; - - int m_from_level, m_to_level; - double m_pan_distance; - int m_paste_display_mode; - int m_wheel_mode; - bool m_guiding_shape_visible; - lay::Color m_guiding_shape_color; - int m_guiding_shape_line_width; - int m_guiding_shape_vertex_size; - - lay::Color m_ctx_color; - int m_ctx_dimming; - bool m_ctx_hollow; - - lay::Color m_child_ctx_color; - int m_child_ctx_dimming; - bool m_child_ctx_hollow; - bool m_child_ctx_enabled; - - double m_abstract_mode_width; - bool m_abstract_mode_enabled; - - lay::Color m_box_color; - bool m_box_text_transform; - unsigned int m_box_font; - int m_min_size_for_label; - bool m_cell_box_visible; - - lay::Color m_marker_color; - int m_marker_line_width; - int m_marker_vertex_size; - int m_marker_dither_pattern; - int m_marker_line_style; - bool m_marker_halo; - - unsigned int m_search_range; - unsigned int m_search_range_box; - - bool m_transient_selection_mode; - bool m_sel_inside_pcells; - - int m_default_font_size; - bool m_text_visible; - bool m_text_lazy_rendering; - bool m_bitmap_caching; - bool m_show_properties; - lay::Color m_text_color; - bool m_apply_text_trans; - double m_default_text_size; - unsigned int m_text_font; - bool m_show_markers; - bool m_no_stipples; - bool m_stipple_offset; - - bool m_drop_small_cells; - unsigned int m_drop_small_cells_value; - drop_small_cells_cond_type m_drop_small_cells_cond; - - bool m_draw_array_border_instances; - - bool m_fit_new_cell; - bool m_full_hier_new_cell; - bool m_clear_ruler_new_cell; - bool m_dbu_coordinates; - bool m_absolute_coordinates; - - bool m_dirty; - bool m_activated; - bool m_animated; - unsigned int m_phase; - - lay::ColorPalette m_palette; - lay::StipplePalette m_stipple_palette; - lay::LineStylePalette m_line_style_palette; - - std::vector m_display_states; - unsigned int m_display_state_ptr; - - std::vector m_layer_properties_lists; - unsigned int m_current_layer_list; - BookmarkList m_bookmarks; - - // service and editable management - int m_mode; - - // services & editables - lay::MouseTracker *mp_tracker; - lay::ZoomService *mp_zoom_service; - lay::SelectionService *mp_selection_service; - lay::MoveService *mp_move_service; - - std::vector mp_plugins; - - bool m_visibility_changed; bool m_active_cellview_changed_event_enabled; - tl::DeferredMethod dm_prop_changed; + tl::DeferredMethod dm_prop_changed; tl::DeferredMethod dm_setup_editor_option_pages; void init (db::Manager *mgr, QWidget *parent); void init_menu (); - - void do_prop_changed (); - void do_redraw (int layer); - void do_redraw (); - - void background_color (lay::Color c); - void ctx_color (lay::Color c); - void ctx_dimming (int percent); - void ctx_hollow (bool h); - void child_ctx_color (lay::Color c); - void child_ctx_dimming (int percent); - void child_ctx_hollow (bool h); - void child_ctx_enabled (bool e); - void abstract_mode_width (double w); - void abstract_mode_enabled (bool e); - bool has_max_hier () const; - int max_hier_level () const; - bool set_hier_levels_basic (std::pair l); - void do_setup_editor_options_pages (); - - void update_event_handlers (); - void viewport_changed (); - void cellview_changed (unsigned int index); - - bool configure (const std::string &name, const std::string &value); - void config_finalize (); - - void do_load_layer_props (const std::string &fn, bool map_cv, int cv_index, bool add_default); - void finish_cellviews_changed (); - void init_layer_properties (LayerProperties &props, const LayerPropertiesList &lp_list) const; - void merge_dither_pattern (lay::LayerPropertiesList &props); - - // overrides Editables method to display a message - void signal_selection_changed (); + void activate (); + void deactivate (); bool eventFilter(QObject *obj, QEvent *ev); void showEvent (QShowEvent *); void hideEvent (QHideEvent *); - - lay::Plugin *create_plugin (const lay::PluginDeclaration *cls); - - std::list::iterator cellview_iter (int cv_index); - std::list::const_iterator cellview_iter (int cv_index) const; }; } diff --git a/src/laybasic/laybasic/layLayoutViewBase.cc b/src/laybasic/laybasic/layLayoutViewBase.cc new file mode 100644 index 000000000..f5713323a --- /dev/null +++ b/src/laybasic/laybasic/layLayoutViewBase.cc @@ -0,0 +1,5487 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 +#include +#include + +#include "tlInternational.h" +#include "tlExpression.h" +#include "tlTimer.h" +#include "tlString.h" +#include "tlLog.h" +#include "tlAssert.h" +#include "tlExceptions.h" +#include "layLayoutViewBase.h" +#include "layViewOp.h" +#include "layViewObject.h" +#include "laybasicConfig.h" +#include "layConverters.h" +#include "layGridNet.h" +#include "layMove.h" +#include "layZoomBox.h" +#include "layMouseTracker.h" +#include "layEditable.h" +#include "layFixedFont.h" +#include "laySelector.h" +#include "layLayoutCanvas.h" +#include "layLayerControlPanel.h" +#include "layHierarchyControlPanel.h" +#include "layLibrariesView.h" +#include "layBrowser.h" +#include "layRedrawThread.h" +#include "layRedrawThreadWorker.h" +#include "layParsedLayerSource.h" +#include "layBookmarkManagementForm.h" +#include "layNetlistBrowserDialog.h" +#include "layBookmarksView.h" +#include "layEditorOptionsFrame.h" +#include "layEditorOptionsPages.h" +#include "dbClipboard.h" +#include "dbLayout.h" +#include "dbLayoutUtils.h" +#include "dbManager.h" +#include "dbLibrary.h" +#include "rdb.h" +#include "rdbMarkerBrowserDialog.h" +#include "dbLayoutToNetlist.h" +#include "dbTechnology.h" +#include "tlXMLParser.h" +#include "gsi.h" +#include "gtf.h" + +#include + +namespace lay +{ + +// factor for "zoom in & out" +const double zoom_factor = 0.7; + +// factor by which panning is faster in "fast" (+Shift) mode +const double fast_factor = 3.0; + +// ------------------------------------------------------------- + +struct OpHideShowCell + : public db::Op +{ + OpHideShowCell (lay::CellView::cell_index_type ci, int cv_index, bool show) + : m_cell_index (ci), m_cellview_index (cv_index), m_show (show) + { } + + lay::CellView::cell_index_type m_cell_index; + int m_cellview_index; + bool m_show; +}; + +struct OpSetDitherPattern + : public db::Op +{ + OpSetDitherPattern (const lay::DitherPattern &o, const lay::DitherPattern &n) + : db::Op (), m_old (o), m_new (n) + { + // nothing yet. + } + + lay::DitherPattern m_old, m_new; +}; + +struct OpSetLineStyles + : public db::Op +{ + OpSetLineStyles (const lay::LineStyles &o, const lay::LineStyles &n) + : db::Op (), m_old (o), m_new (n) + { + // nothing yet. + } + + lay::LineStyles m_old, m_new; +}; + +struct OpSetLayerProps + : public db::Op +{ + OpSetLayerProps (unsigned int li, unsigned int i, const lay::LayerProperties &o, const lay::LayerProperties &n) + : m_list_index (li), m_index (i), m_old (o), m_new (n) + { + // .. nothing yet .. + } + + unsigned int m_list_index; + size_t m_index; + lay::LayerProperties m_old, m_new; +}; + +struct OpSetLayerPropsNode + : public db::Op +{ + OpSetLayerPropsNode (unsigned int li, unsigned int i, const lay::LayerPropertiesNode &o, const lay::LayerPropertiesNode &n) + : m_list_index (li), m_index (i), m_old (o), m_new (n) + { + // .. nothing yet .. + } + + unsigned int m_list_index; + size_t m_index; + lay::LayerPropertiesNode m_old, m_new; +}; + +struct OpDeleteLayerList + : public db::Op +{ + OpDeleteLayerList (unsigned int li, const lay::LayerPropertiesList &o) + : m_list_index (li), m_old (o) + { + // .. nothing yet .. + } + + unsigned int m_list_index; + lay::LayerPropertiesList m_old; +}; + +struct OpInsertLayerList + : public db::Op +{ + OpInsertLayerList (unsigned int li, const lay::LayerPropertiesList &n) + : m_list_index (li), m_new (n) + { + // .. nothing yet .. + } + + unsigned int m_list_index; + lay::LayerPropertiesList m_new; +}; + +struct OpRenameProps + : public db::Op +{ + OpRenameProps (unsigned int li, const std::string &old_name, const std::string &new_name) + : m_list_index (li), m_old (old_name), m_new (new_name) + { + // .. nothing yet .. + } + + unsigned int m_list_index; + std::string m_old, m_new; +}; + +struct OpSetAllProps + : public db::Op +{ + OpSetAllProps (unsigned int li, const lay::LayerPropertiesList &o, const lay::LayerPropertiesList &n) + : m_list_index (li), m_old (o), m_new (n) + { + // .. nothing yet .. + } + + unsigned int m_list_index; + lay::LayerPropertiesList m_old, m_new; +}; + +struct OpLayerList + : public db::Op +{ + enum Mode { Delete, Insert }; + + OpLayerList (unsigned int li, unsigned int i, const lay::LayerPropertiesNode &n, Mode m) + : m_list_index (li), m_index (i), m_mode (m), m_node (n) + { } + + unsigned int m_list_index; + size_t m_index; + Mode m_mode; + lay::LayerPropertiesNode m_node; +}; + +struct OpInsertLayerProps + : public OpLayerList +{ + OpInsertLayerProps (unsigned int li, unsigned int i, const lay::LayerPropertiesNode &n) + : OpLayerList (li, i, n, Insert) + { + // .. nothing yet .. + } +}; + +struct OpDeleteLayerProps + : public OpLayerList +{ + OpDeleteLayerProps (unsigned int li, unsigned int i, const lay::LayerPropertiesNode &n) + : OpLayerList (li, i, n, Delete) + { + // .. nothing yet .. + } +}; + +// ------------------------------------------------------------- + +const int timer_interval = 500; + +static LayoutViewBase *ms_current = 0; + +LayoutViewBase::LayoutViewBase (db::Manager *manager, bool editable, lay::Plugin *plugin_parent, unsigned int options) + : lay::Dispatcher (plugin_parent, false /*not standalone*/), + m_editable (editable), + m_options (options), + m_annotation_shapes (manager), + dm_prop_changed (this, &LayoutViewBase::do_prop_changed) +{ + // either it's us or the parent has a dispatcher + tl_assert (dispatcher () != 0); + + // ensures the deferred method scheduler is present + tl::DeferredMethodScheduler::instance (); + + init (manager); +} + +LayoutViewBase::LayoutViewBase (lay::LayoutViewBase *source, db::Manager *manager, bool editable, lay::Plugin *plugin_parent, unsigned int options) + : lay::Dispatcher (plugin_parent, false /*not standalone*/), + m_editable (editable), + m_options (options), + m_annotation_shapes (manager), + dm_prop_changed (this, &LayoutViewBase::do_prop_changed) +{ + // either it's us or the parent has a dispatcher + tl_assert (dispatcher () != 0); + + // ensures the deferred method scheduler is present + tl::DeferredMethodScheduler::instance (); + + m_annotation_shapes = source->m_annotation_shapes; + + init (manager); + + // set the handle reference and clear all cell related stuff + m_cellviews = source->cellview_list (); + m_hidden_cells = source->m_hidden_cells; + + // clear the history, store path and zoom box + m_display_states.clear (); + m_display_state_ptr = 0; + m_synchronous = source->synchronous (); + m_drawing_workers = source->drawing_workers (); + + // duplicate the layer properties + for (size_t i = 0; i < source->m_layer_properties_lists.size (); ++i) { + if (i >= m_layer_properties_lists.size ()) { + m_layer_properties_lists.push_back (new lay::LayerPropertiesList (*source->m_layer_properties_lists [i])); + } else { + *m_layer_properties_lists [i] = *source->m_layer_properties_lists [i]; + } + m_layer_properties_lists [i]->attach_view (this, (unsigned int) i); + } + + if (! m_layer_properties_lists.empty ()) { + mp_canvas->set_dither_pattern (m_layer_properties_lists [0]->dither_pattern ()); + } + + bookmarks (source->bookmarks ()); + + set_active_cellview_index (source->active_cellview_index ()); + + // copy the title + m_title = source->m_title; + + layer_list_changed_event (3); + + finish_cellviews_changed (); +} + +void +LayoutViewBase::init (db::Manager *mgr) +{ + manager (mgr); + + m_annotation_shapes.manager (mgr); + + m_visibility_changed = false; + m_disabled_edits = 0; + m_synchronous = false; + m_drawing_workers = 1; + m_from_level = 0; + m_pan_distance = 0.15; + m_wheel_mode = 0; + m_paste_display_mode = 2; + m_guiding_shape_visible = true; + m_guiding_shape_line_width = 1; + m_guiding_shape_color = lay::Color (); + m_guiding_shape_vertex_size = 5; + m_to_level = 0; + m_ctx_dimming = 50; + m_ctx_hollow = false; + m_child_ctx_dimming = 50; + m_child_ctx_hollow = false; + m_child_ctx_enabled = false; + m_abstract_mode_width = 10.0; + m_abstract_mode_enabled = false; + m_box_text_transform = true; + m_box_font = 0; + m_min_size_for_label = 16; + m_cell_box_visible = true; + m_text_visible = true; + m_default_font_size = lay::FixedFont::default_font_size (); + m_text_lazy_rendering = true; + m_bitmap_caching = true; + m_show_properties = false; + m_apply_text_trans = true; + m_default_text_size = 0.1; + m_text_font = 0; + m_show_markers = true; + m_no_stipples = false; + m_stipple_offset = true; + m_fit_new_cell = true; + m_full_hier_new_cell = true; + m_clear_ruler_new_cell = false; + m_dbu_coordinates = false; + m_absolute_coordinates = false; + m_drop_small_cells = false; + m_drop_small_cells_value = 10; + m_drop_small_cells_cond = DSC_Max; + m_draw_array_border_instances = false; + m_dirty = false; + m_activated = true; + m_animated = false; + m_phase = 0; + m_palette = lay::ColorPalette::default_palette (); + m_stipple_palette = lay::StipplePalette::default_palette (); + m_display_state_ptr = 0; + m_mode = std::numeric_limits::min (); // nothing selected yet. + mp_tracker = 0; + mp_zoom_service = 0; + mp_selection_service = 0; + mp_move_service = 0; + m_marker_line_width = 0; + m_marker_vertex_size = 0; + m_marker_dither_pattern = 1; + m_marker_line_style = 0; + m_marker_halo = true; + m_transient_selection_mode = true; + m_sel_inside_pcells = false; + m_add_other_layers = false; + m_always_show_source = false; + m_always_show_ld = true; + m_always_show_layout_index = false; + m_search_range = 5; + m_search_range_box = 0; + + m_layer_properties_lists.push_back (new LayerPropertiesList ()); + m_layer_properties_lists.back ()->attach_view (this, (unsigned int) (m_layer_properties_lists.size () - 1)); + m_current_layer_list = 0; + + mp_canvas = new lay::LayoutCanvas (this); // @@@ Widget parent??? + + mp_canvas->left_arrow_key_pressed.add (this, &LayoutViewBase::pan_left); + mp_canvas->up_arrow_key_pressed.add (this, &LayoutViewBase::pan_up); + mp_canvas->right_arrow_key_pressed.add (this, &LayoutViewBase::pan_right); + mp_canvas->down_arrow_key_pressed.add (this, &LayoutViewBase::pan_down); + mp_canvas->left_arrow_key_pressed_with_shift.add (this, &LayoutViewBase::pan_left_fast); + mp_canvas->up_arrow_key_pressed_with_shift.add (this, &LayoutViewBase::pan_up_fast); + mp_canvas->right_arrow_key_pressed_with_shift.add (this, &LayoutViewBase::pan_right_fast); + mp_canvas->down_arrow_key_pressed_with_shift.add (this, &LayoutViewBase::pan_down_fast); + + // occupy services and editables: + // these services get deleted by the canvas destructor automatically: + if ((m_options & LV_NoTracker) == 0) { + mp_tracker = new lay::MouseTracker (this); + } + if ((m_options & LV_NoZoom) == 0) { + mp_zoom_service = new lay::ZoomService (this); + } + if ((m_options & LV_NoSelection) == 0) { + mp_selection_service = new lay::SelectionService (this); + } + if ((m_options & LV_NoMove) == 0) { + mp_move_service = new lay::MoveService (this); + } + + create_plugins (); + + config_setup (); +} + +LayoutViewBase::~LayoutViewBase () +{ + if (ms_current == this) { + ms_current = 0; + } + + // detach all observers + // This is to prevent signals to partially destroyed observers that own a LayoutViewBase + layer_list_changed_event.clear (); + layer_list_deleted_event.clear (); + layer_list_inserted_event.clear (); + current_layer_list_changed_event.clear (); + cell_visibility_changed_event.clear (); + cellviews_about_to_change_event.clear (); + cellview_about_to_change_event.clear (); + cellviews_changed_event.clear (); + cellview_changed_event.clear (); + rdb_list_changed_event.clear (); + l2ndb_list_changed_event.clear (); + file_open_event.clear (); + hier_changed_event.clear (); + geom_changed_event.clear (); + annotations_changed_event.clear (); + + // detach ourselves from any observed objects to prevent signals while destroying + tl::Object::detach_from_all_events (); + + // remove all rdb's + while (num_rdbs () > 0) { + remove_rdb (0); + } + + // remove all L2N DB's + while (num_l2ndbs () > 0) { + remove_l2ndb (0); + } + + // delete layer lists + std::vector layer_properties_lists; + layer_properties_lists.swap (m_layer_properties_lists); + for (std::vector::iterator l = layer_properties_lists.begin (); l != layer_properties_lists.end (); ++l) { + if (*l) { + delete *l; + } + } + + // delete all plugins + std::vector plugins; + plugins.swap (mp_plugins); + for (std::vector::iterator p = plugins.begin (); p != plugins.end (); ++p) { + delete *p; + } + + // detach from the manager, so we can safely delete the manager + manager (0); + + stop (); + + // because LayoutViewBase and LayoutCanvas both control lifetimes of + // ruler objects for example, it is safer to explicitly delete the + // LayoutCanvas object here: + delete mp_canvas; + mp_canvas = 0; +} + +void LayoutViewBase::update_event_handlers () +{ + tl::Object::detach_from_all_events (); + + for (std::vector::iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) { + // TODO: get rid of the const_cast hack + const_cast ((*p)->plugin_declaration ())->editable_enabled_changed_event.add (this, &LayoutViewBase::signal_plugin_enabled_changed); + } + + for (unsigned int i = 0; i < cellviews (); ++i) { + cellview (i)->layout ().hier_changed_event.add (this, &LayoutViewBase::signal_hier_changed); + cellview (i)->layout ().bboxes_changed_event.add (this, &LayoutViewBase::signal_bboxes_from_layer_changed, i); + cellview (i)->layout ().dbu_changed_event.add (this, &LayoutViewBase::signal_bboxes_changed); + cellview (i)->layout ().prop_ids_changed_event.add (this, &LayoutViewBase::signal_prop_ids_changed); + cellview (i)->layout ().layer_properties_changed_event.add (this, &LayoutViewBase::signal_layer_properties_changed); + cellview (i)->layout ().cell_name_changed_event.add (this, &LayoutViewBase::signal_cell_name_changed); + cellview (i)->apply_technology_with_sender_event.add (this, &LayoutViewBase::signal_apply_technology); + } + + annotation_shapes ().bboxes_changed_any_event.add (this, &LayoutViewBase::signal_annotations_changed); + + mp_canvas->viewport_changed_event.add (this, &LayoutViewBase::viewport_changed); +} + +void LayoutViewBase::viewport_changed () +{ + viewport_changed_event (); +} + +bool LayoutViewBase::accepts_drop (const std::string &path_or_url) const +{ + for (std::vector::const_iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) { + if ((*p)->accepts_drop (path_or_url)) { + return true; + } + } + return false; +} + +void LayoutViewBase::drop_url (const std::string &path_or_url) +{ + for (std::vector::const_iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) { + if ((*p)->accepts_drop (path_or_url)) { + (*p)->drop_url (path_or_url); + break; + } + } +} + +lay::Plugin *LayoutViewBase::create_plugin (const lay::PluginDeclaration *cls) +{ + lay::Plugin *p = cls->create_plugin (manager (), dispatcher (), this); + if (p) { + + // unhook the plugin from the script side if created there (prevent GC from destroying it) + p->gsi::ObjectBase::keep (); + + mp_plugins.push_back (p); + p->set_plugin_declaration (cls); + + // enable editable functionality + if (p->editable_interface ()) { + enable (p->editable_interface (), cls->editable_enabled ()); + } + + update_event_handlers (); + + } + return p; +} + +void LayoutViewBase::create_plugins (const lay::PluginDeclaration *except_this) +{ + for (std::vector::iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) { + delete *p; + } + mp_plugins.clear (); + + // create the plugins + for (tl::Registrar::iterator cls = tl::Registrar::begin (); cls != tl::Registrar::end (); ++cls) { + + if (&*cls != except_this) { + + // TODO: clean solution. The following is a HACK: + if (cls.current_name () == "ant::Plugin" || cls.current_name () == "img::Plugin") { + // ant and img are created always + create_plugin (&*cls); + } else if ((m_options & LV_NoPlugins) == 0) { + // others: only create unless LV_NoPlugins is set + create_plugin (&*cls); + } else if ((m_options & LV_NoGrid) == 0 && cls.current_name () == "GridNetPlugin") { + // except grid net plugin which is created on request + create_plugin (&*cls); + } + + } + + } + + dm_setup_editor_option_pages (); + + mode (default_mode ()); +} + +Plugin *LayoutViewBase::get_plugin_by_name (const std::string &name) const +{ + lay::PluginDeclaration *decl = 0; + for (tl::Registrar::iterator cls = tl::Registrar::begin (); !decl && cls != tl::Registrar::end (); ++cls) { + if (cls.current_name () == name) { + decl = cls.operator-> (); + } + } + + if (decl) { + for (std::vector::const_iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) { + if ((*p)->plugin_declaration () == decl) { + return *p; + } + } + } + + return 0; +} + +void +LayoutViewBase::set_drawing_workers (int workers) +{ + m_drawing_workers = std::max (0, std::min (100, workers)); +} + +void +LayoutViewBase::set_synchronous (bool s) +{ + m_synchronous = s; +} + +bool +LayoutViewBase::is_dirty () const +{ + return m_dirty; +} + +bool +LayoutViewBase::configure (const std::string &name, const std::string &value) +{ + lay::Dispatcher::configure (name, value); + + if (mp_move_service && mp_move_service->configure (name, value)) { + return true; + } + + if (name == cfg_default_lyp_file) { + + m_def_lyp_file = value; + return false; // not taken - let others set it too. + + } else if (name == cfg_default_add_other_layers) { + + tl::from_string (value, m_add_other_layers); + return false; // not taken - let others set it too. + + } else if (name == cfg_layers_always_show_source) { + + bool a = false; + tl::from_string (value, a); + if (a != m_always_show_source) { + m_always_show_source = a; + layer_list_changed_event (4); + } + + return true; + + } else if (name == cfg_layers_always_show_ld) { + + tl::from_string (value, m_always_show_ld); + update_content (); + return true; + + } else if (name == cfg_layers_always_show_layout_index) { + + tl::from_string (value, m_always_show_layout_index); + update_content (); + return true; + +/*@@@ + } else if (name == cfg_flat_cell_list) { + + bool f; + tl::from_string (value, f); + if (mp_hierarchy_panel) { + mp_hierarchy_panel->set_flat (f); + } + return true; + + } else if (name == cfg_split_cell_list) { + + bool f; + tl::from_string (value, f); + if (mp_hierarchy_panel) { + mp_hierarchy_panel->set_split_mode (f); + } + return true; + + } else if (name == cfg_split_lib_views) { + + bool f; + tl::from_string (value, f); + if (mp_libraries_view) { + mp_libraries_view->set_split_mode (f); + } + return true; + + } else if (name == cfg_bookmarks_follow_selection) { + + bool f; + tl::from_string (value, f); + if (mp_bookmarks_view) { + mp_bookmarks_view->follow_selection (f); + } + return true; + + } else if (name == cfg_current_lib_view) { + + if (mp_libraries_view) { + mp_libraries_view->select_active_lib_by_name (value); + } + return true; + + } else if (name == cfg_cell_list_sorting) { + + if (mp_hierarchy_panel) { + if (value == "by-name") { + mp_hierarchy_panel->set_sorting (CellTreeModel::ByName); + } else if (value == "by-area") { + mp_hierarchy_panel->set_sorting (CellTreeModel::ByArea); + } else if (value == "by-area-reverse") { + mp_hierarchy_panel->set_sorting (CellTreeModel::ByAreaReverse); + } + } + return true; + + } else if (name == cfg_hide_empty_layers) { + + bool f; + tl::from_string (value, f); + if (mp_control_panel) { + mp_control_panel->set_hide_empty_layers (f); + } + return true; + + } else if (name == cfg_test_shapes_in_view) { + + bool f; + tl::from_string (value, f); + if (mp_control_panel) { + mp_control_panel->set_test_shapes_in_view (f); + } + return true; + +@@@*/ + } else if (name == cfg_background_color) { + + lay::Color color; + ColorConverter ().from_string (value, color); + background_color (color); + // do not take - let others receive the background color events as well + return false; + + } else if (name == cfg_default_font_size) { + + int df = 0; + tl::from_string (value, df); + if (m_default_font_size != df) { + // keep a shadow state to correctly issue the redraw call + m_default_font_size = df; + lay::FixedFont::set_default_font_size (df); + redraw (); + } + // do not take - let others have the event for the redraw call + return false; + + } else if (name == cfg_bitmap_oversampling) { + + int os = 1; + tl::from_string (value, os); + mp_canvas->set_oversampling (os); + return true; + + } else if (name == cfg_image_cache_size) { + + int sz = 0; + tl::from_string (value, sz); + mp_canvas->set_image_cache_size (size_t (sz)); + return true; + + } else if (name == cfg_global_trans) { + + tl::Extractor ex (value.c_str ()); + try { + db::DCplxTrans t; + ex.read (t); + set_global_trans (t); + } catch (...) { } + return true; + + } else if (name == cfg_ctx_color) { + + lay::Color color; + ColorConverter ().from_string (value, color); + ctx_color (color); + return true; + + } else if (name == cfg_ctx_dimming) { + + int n; + tl::from_string (value, n); + ctx_dimming (n); + return true; + + } else if (name == cfg_ctx_hollow) { + + bool h; + tl::from_string (value, h); + ctx_hollow (h); + return true; + + } else if (name == cfg_child_ctx_color) { + + lay::Color color; + ColorConverter ().from_string (value, color); + child_ctx_color (color); + return true; + + } else if (name == cfg_child_ctx_dimming) { + + int n; + tl::from_string (value, n); + child_ctx_dimming (n); + return true; + + } else if (name == cfg_child_ctx_hollow) { + + bool h; + tl::from_string (value, h); + child_ctx_hollow (h); + return true; + + } else if (name == cfg_child_ctx_enabled) { + + bool h; + tl::from_string (value, h); + child_ctx_enabled (h); + return true; + + } else if (name == cfg_search_range) { + + unsigned int n; + tl::from_string (value, n); + set_search_range (n); + return true; + + } else if (name == cfg_search_range_box) { + + unsigned int n; + tl::from_string (value, n); + set_search_range_box (n); + return true; + + } else if (name == cfg_abstract_mode_enabled) { + + bool e; + tl::from_string (value, e); + abstract_mode_enabled (e); + return true; + + } else if (name == cfg_abstract_mode_width) { + + double w; + tl::from_string (value, w); + abstract_mode_width (w); + return true; + + } else if (name == cfg_min_inst_label_size) { + + int n; + tl::from_string (value, n); + min_inst_label_size (n); + return true; + + } else if (name == cfg_cell_box_text_font) { + + int n; + tl::from_string (value, n); + cell_box_text_font (n); + return true; + + } else if (name == cfg_cell_box_text_transform) { + + bool flag; + tl::from_string (value, flag); + cell_box_text_transform (flag); + return true; + + } else if (name == cfg_cell_box_visible) { + + bool flag; + tl::from_string (value, flag); + cell_box_visible (flag); + return true; + + } else if (name == cfg_cell_box_color) { + + lay::Color color; + ColorConverter ().from_string (value, color); + cell_box_color (color); + return true; + + } else if (name == cfg_text_color) { + + lay::Color color; + ColorConverter ().from_string (value, color); + text_color (color); + return true; + + } else if (name == cfg_text_visible) { + + bool flag; + tl::from_string (value, flag); + text_visible (flag); + return true; + + } else if (name == cfg_bitmap_caching) { + + bool flag; + tl::from_string (value, flag); + bitmap_caching (flag); + return true; + + } else if (name == cfg_text_lazy_rendering) { + + bool flag; + tl::from_string (value, flag); + text_lazy_rendering (flag); + return true; + + } else if (name == cfg_show_properties) { + + bool flag; + tl::from_string (value, flag); + show_properties_as_text (flag); + return true; + + } else if (name == cfg_apply_text_trans) { + + bool flag; + tl::from_string (value, flag); + apply_text_trans (flag); + return true; + + } else if (name == cfg_markers_visible) { + + bool flag; + tl::from_string (value, flag); + mp_canvas->set_dismiss_view_objects (! flag); + return true; + + } else if (name == cfg_no_stipple) { + + bool flag; + tl::from_string (value, flag); + no_stipples (flag); + return true; + + } else if (name == cfg_stipple_offset) { + + bool flag; + tl::from_string (value, flag); + offset_stipples (flag); + return true; + + } else if (name == cfg_default_text_size) { + + double sz; + tl::from_string (value, sz); + default_text_size (sz); + return true; + + } else if (name == cfg_text_font) { + + int n; + tl::from_string (value, n); + text_font (n); + return true; + + } else if (name == cfg_full_hier_new_cell) { + + bool flag; + tl::from_string (value, flag); + full_hier_new_cell (flag); + return true; + + } else if (name == cfg_fit_new_cell) { + + bool flag; + tl::from_string (value, flag); + fit_new_cell (flag); + return true; + + } else if (name == cfg_clear_ruler_new_cell) { + + bool flag; + tl::from_string (value, flag); + clear_ruler_new_cell (flag); + return true; + + } else if (name == cfg_abs_units) { + + bool flag; + tl::from_string (value, flag); + absolute_coordinates (flag); + return true; + + } else if (name == cfg_guiding_shape_visible) { + + bool v = false; + tl::from_string (value, v); + guiding_shapes_visible (v); + return true; + + } else if (name == cfg_guiding_shape_line_width) { + + int v = 0; + tl::from_string (value, v); + guiding_shapes_line_width (v); + return true; + + } else if (name == cfg_guiding_shape_color) { + + lay::Color color; + ColorConverter ().from_string (value, color); + guiding_shapes_color (color); + return true; + + } else if (name == cfg_guiding_shape_color) { + + lay::Color color; + ColorConverter ().from_string (value, color); + guiding_shapes_color (color); + return true; + + } else if (name == cfg_guiding_shape_vertex_size) { + + int v = 0; + tl::from_string (value, v); + guiding_shapes_vertex_size (v); + return true; + + } else if (name == cfg_paste_display_mode) { + + tl::from_string (value, m_paste_display_mode); + return true; + + } else if (name == cfg_mouse_wheel_mode) { + + tl::from_string (value, m_wheel_mode); + return true; + + } else if (name == cfg_pan_distance) { + + double pd; + tl::from_string (value, pd); + pan_distance (pd); + return true; + + } else if (name == cfg_drawing_workers) { + + int workers; + tl::from_string (value, workers); + set_drawing_workers (workers); + return true; + + } else if (name == cfg_drop_small_cells) { + + bool flag; + tl::from_string (value, flag); + drop_small_cells (flag); + return true; + + } else if (name == cfg_drop_small_cells_cond) { + + unsigned int n; + tl::from_string (value, n); + drop_small_cells_cond (drop_small_cells_cond_type (n)); + return true; + + } else if (name == cfg_drop_small_cells_value) { + + unsigned int n; + tl::from_string (value, n); + drop_small_cells_value (n); + return true; + + } else if (name == cfg_array_border_instances) { + + bool f; + tl::from_string (value, f); + draw_array_border_instances (f); + return true; + + } else if (name == cfg_dbu_units) { + + bool flag; + tl::from_string (value, flag); + dbu_coordinates (flag); + return true; + + } else if (name == cfg_stipple_palette) { + + lay::StipplePalette palette = lay::StipplePalette::default_palette (); + + try { + // empty string means: default palette + if (! value.empty ()) { + palette.from_string (value); + } + } catch (...) { + // ignore errors: just reset the palette + palette = lay::StipplePalette::default_palette (); + } + + set_palette (palette); + + // others need this property too .. + return false; + + } else if (name == cfg_line_style_palette) { + + lay::LineStylePalette palette = lay::LineStylePalette::default_palette (); + + try { + // empty string means: default palette + if (! value.empty ()) { + palette.from_string (value); + } + } catch (...) { + // ignore errors: just reset the palette + palette = lay::LineStylePalette::default_palette (); + } + + set_palette (palette); + + // others need this property too .. + return false; + + } else if (name == cfg_color_palette) { + + lay::ColorPalette palette = lay::ColorPalette::default_palette (); + + try { + // empty string means: default palette + if (! value.empty ()) { + palette.from_string (value); + } + } catch (...) { + // ignore errors: just reset the palette + palette = lay::ColorPalette::default_palette (); + } + + set_palette (palette); + + // others need this property too .. + return false; + + } else if (name == cfg_sel_inside_pcells_mode) { + + bool flag; + tl::from_string (value, flag); + + if (m_sel_inside_pcells != flag) { + m_sel_inside_pcells = flag; + clear_selection (); + } + + return true; + + } else if (name == cfg_sel_transient_mode) { + + bool flag; + tl::from_string (value, flag); + m_transient_selection_mode = flag; + + if (! m_transient_selection_mode) { + clear_transient_selection (); + } + + // do not take - let others receive this configuration as well + return false; + + } else if (name == cfg_sel_color) { + + lay::Color color; + lay::ColorConverter ().from_string (value, color); + + // Change the color + if (lay::test_and_set (m_marker_color, color)) { + mp_canvas->update_image (); + } + + // do not take - let others receive this configuration as well + return false; + + } else if (name == cfg_sel_line_width) { + + int lw = 0; + tl::from_string (value, lw); + + // Change the line width + if (lay::test_and_set (m_marker_line_width, lw)) { + mp_canvas->update_image (); + } + + // do not take - let others receive this configuration as well + return false; + + } else if (name == cfg_sel_dither_pattern) { + + int dp = 0; + tl::from_string (value, dp); + + // Change the vertex_size + if (lay::test_and_set (m_marker_dither_pattern, dp)) { + mp_canvas->update_image (); + } + + // do not take - let others receive this configuration as well + return false; + + } else if (name == cfg_sel_line_style) { + + int dp = 0; + tl::from_string (value, dp); + + // Change the vertex_size + if (lay::test_and_set (m_marker_line_style, dp)) { + mp_canvas->update_image (); + } + + // do not take - let others receive this configuration as well + return false; + + } else if (name == cfg_sel_vertex_size) { + + int vs = 0; + tl::from_string (value, vs); + + // Change the vertex_size + if (lay::test_and_set (m_marker_vertex_size, vs)) { + mp_canvas->update_image (); + } + + // do not take - let others receive this configuration as well + return false; + + } else if (name == cfg_sel_halo) { + + bool halo = 0; + tl::from_string (value, halo); + + // Change the vertex_size + if (lay::test_and_set (m_marker_halo, halo)) { + mp_canvas->update_image (); + } + + // do not take - let others receive this configuration as well + return false; + + } else { + return false; + } +} + +void +LayoutViewBase::config_finalize () +{ + // It's important that the editor option pages are updated last - because the + // configuration change may trigger other configuration changes + dm_setup_editor_option_pages (); +} + +void +LayoutViewBase::enable_edits (bool enable) +{ + // enable or disable these services: + if (mp_selection_service) { + mp_selection_service->enable (enable); + } + if (mp_move_service) { + mp_move_service->enable (enable); + } + + // enable or disable the services that implement "lay::ViewService" + for (std::vector::iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) { + lay::ViewService *svc = (*p)->view_service_interface (); + if (svc) { + svc->enable (enable); + } + } + + bool is_enabled = edits_enabled (); + + if (enable) { + if (m_disabled_edits > 0) { + --m_disabled_edits; + } + } else { + ++m_disabled_edits; + } + + if (edits_enabled () != is_enabled) { + emit edits_enabled_changed (); + } +} + +void +LayoutViewBase::set_line_styles (const lay::LineStyles &styles) +{ + if (mp_canvas->line_styles () != styles) { + + if (transacting ()) { + manager ()->queue (this, new OpSetLineStyles (mp_canvas->line_styles (), styles)); + } else if (manager () && ! replaying ()) { + manager ()->clear (); + } + mp_canvas->set_line_styles (styles); + + for (unsigned int i = 0; i < layer_lists (); ++i) { + m_layer_properties_lists [i]->set_line_styles (styles); + } + + layer_list_changed_event (1); + + } +} + +void +LayoutViewBase::set_dither_pattern (const lay::DitherPattern &pattern) +{ + if (mp_canvas->dither_pattern () != pattern) { + + if (transacting ()) { + manager ()->queue (this, new OpSetDitherPattern (mp_canvas->dither_pattern (), pattern)); + } else if (manager () && ! replaying ()) { + manager ()->clear (); + } + mp_canvas->set_dither_pattern (pattern); + + for (unsigned int i = 0; i < layer_lists (); ++i) { + m_layer_properties_lists [i]->set_dither_pattern (pattern); + } + + layer_list_changed_event (1); + + } +} + +const LayerPropertiesList & +LayoutViewBase::get_properties (unsigned int index) const +{ + if (index >= layer_lists ()) { + static lay::LayerPropertiesList empty; + return empty; + } else { + return *m_layer_properties_lists [index]; + } +} + +void +LayoutViewBase::set_current_layer_list (unsigned int index) +{ + if (index != m_current_layer_list && index < layer_lists ()) { + m_current_layer_list = index; + current_layer_list_changed_event (index); + redraw (); + } +} + +void +LayoutViewBase::insert_layer_list (unsigned index, const LayerPropertiesList &props) +{ + if (index > layer_lists ()) { + return; + } + + if (transacting ()) { + manager ()->queue (this, new OpInsertLayerList (index, props)); + } else if (manager () && ! replaying ()) { + manager ()->clear (); + } + + m_layer_properties_lists.insert (m_layer_properties_lists.begin () + index, new LayerPropertiesList (props)); + m_layer_properties_lists [index]->attach_view (this, index); + merge_dither_pattern (*m_layer_properties_lists [index]); + + m_current_layer_list = index; + current_layer_list_changed_event (index); + + layer_list_inserted_event (index); + + redraw (); + + dm_prop_changed (); +} + +void +LayoutViewBase::delete_layer_list (unsigned index) +{ + if (index >= layer_lists ()) { + return; + } + + if (transacting ()) { + manager ()->queue (this, new OpDeleteLayerList (index, *m_layer_properties_lists [index])); + } else if (manager () && ! replaying ()) { + manager ()->clear (); + } + + delete m_layer_properties_lists [index]; + m_layer_properties_lists.erase (m_layer_properties_lists.begin () + index); + + if (m_current_layer_list > index) { + + --m_current_layer_list; + current_layer_list_changed_event (m_current_layer_list); + + // don't tell the other observers because effectively nothing has changed. + + } else if (m_current_layer_list == index) { + + if (m_current_layer_list > 0) { + --m_current_layer_list; + } + + current_layer_list_changed_event (m_current_layer_list); + + // the current list has been deleted. + layer_list_changed_event (3); + + redraw (); + + } + + layer_list_deleted_event (index); + dm_prop_changed (); +} + +void +LayoutViewBase::rename_properties (unsigned int index, const std::string &new_name) +{ + if (index >= layer_lists ()) { + return; + } + + if (transacting ()) { + manager ()->queue (this, new OpRenameProps (index, m_layer_properties_lists [index]->name (), new_name)); + } else if (manager () && ! replaying ()) { + manager ()->clear (); + } + + m_layer_properties_lists [index]->set_name (new_name); + + layer_list_changed_event (4); +} + +void +LayoutViewBase::merge_dither_pattern (lay::LayerPropertiesList &props) +{ + { + lay::DitherPattern dp (dither_pattern ()); + + std::map index_map; + dp.merge (props.dither_pattern (), index_map); + + // remap the dither pattern index + for (lay::LayerPropertiesIterator l = props.begin_recursive (); l != props.end_recursive (); ++l) { + int dpi = l->dither_pattern (false /*local*/); + std::map ::iterator m = index_map.find ((unsigned int) dpi); + if (m != index_map.end ()) { + l->set_dither_pattern (int (m->second)); + } + } + + // install the new custom pattern table + if (mp_canvas->dither_pattern () != dp) { + mp_canvas->set_dither_pattern (dp); + for (unsigned int i = 0; i < layer_lists (); ++i) { + m_layer_properties_lists [i]->set_dither_pattern (dp); + } + } + } + + { + lay::LineStyles ls (line_styles ()); + + std::map index_map; + ls.merge (props.line_styles (), index_map); + + // remap the dither pattern index + for (lay::LayerPropertiesIterator l = props.begin_recursive (); l != props.end_recursive (); ++l) { + int lsi = l->line_style (false /*local*/); + std::map ::iterator m = index_map.find ((unsigned int) lsi); + if (m != index_map.end ()) { + l->set_line_style (int (m->second)); + } + } + + // install the new custom pattern table + if (mp_canvas->line_styles () != ls) { + mp_canvas->set_line_styles (ls); + for (unsigned int i = 0; i < layer_lists (); ++i) { + m_layer_properties_lists [i]->set_line_styles (ls); + } + } + } +} + +void +LayoutViewBase::set_properties (unsigned int index, const LayerPropertiesList &props) +{ + // If index is not a valid tab index, don't do anything except for the case of + // index 0 in which the first entry is created (this can happen as a result of + // delete_properties). + if (index >= layer_lists ()) { + if (index > 0) { + return; + } else { + m_layer_properties_lists.push_back (new LayerPropertiesList ()); + m_layer_properties_lists.back ()->attach_view (this, (unsigned int) (m_layer_properties_lists.size () - 1)); + } + } + + // HINT: this method is quite frequently used in an imperative way. + // Since it has some desired side effects such as forcing a recomputation of the internals, + // it should be executed in any case, even if props == get_properties (). + + if (transacting ()) { + manager ()->queue (this, new OpSetAllProps (index, get_properties (), props)); + } else if (manager () && ! replaying ()) { + manager ()->clear (); + } + + if (mp_control_panel && index == current_layer_list ()) { + mp_control_panel->begin_updates (); + } + + *m_layer_properties_lists [index] = props; + m_layer_properties_lists [index]->attach_view (this, index); + + merge_dither_pattern (*m_layer_properties_lists [index]); + + if (index == current_layer_list ()) { + + layer_list_changed_event (3); + + redraw (); + + dm_prop_changed (); + + } +} + +void +LayoutViewBase::expand_properties () +{ + expand_properties (std::map (), false); +} + +void +LayoutViewBase::expand_properties (unsigned int index) +{ + expand_properties (index, std::map (), false); +} + +void +LayoutViewBase::expand_properties (const std::map &map_cv_index, bool add_default) +{ + for (unsigned int i = 0; i < cellviews (); ++i) { + expand_properties (i, map_cv_index, add_default); + } +} + +void +LayoutViewBase::expand_properties (unsigned int index, const std::map &map_cv_index, bool add_default) +{ + if (index < m_layer_properties_lists.size ()) { + m_layer_properties_lists [index]->expand (map_cv_index, add_default); + } +} + +void +LayoutViewBase::replace_layer_node (unsigned int index, const LayerPropertiesConstIterator &iter, const LayerPropertiesNode &node) +{ + if (index >= layer_lists ()) { + return; + } + + // if the source specification changed, a redraw is required + if (*iter != node) { + + if (transacting ()) { + manager ()->queue (this, new OpSetLayerPropsNode (index, (unsigned int) iter.uint (), *iter, node)); + } else if (manager () && ! replaying ()) { + manager ()->clear (); + } + + if (mp_control_panel && index == current_layer_list ()) { + mp_control_panel->begin_updates (); + } + + LayerPropertiesIterator non_const_iter (get_properties (index), iter.uint ()); + *non_const_iter = node; + non_const_iter->attach_view (this, index); + + if (index == current_layer_list ()) { + + layer_list_changed_event (2); + + // TODO: check, if redraw is actually necessary (this is complex!) + redraw (); + + dm_prop_changed (); + + } + } +} + +void +LayoutViewBase::set_properties (unsigned int index, const LayerPropertiesConstIterator &iter, const LayerProperties &props) +{ + if (index >= layer_lists ()) { + return; + } + + // if the source specification changed, a redraw is required + const LayerProperties &l = *iter; + if (l != props) { + + if (transacting ()) { + manager ()->queue (this, new OpSetLayerProps (index, (unsigned int) iter.uint (), l, props)); + } else if (manager () && ! replaying ()) { + manager ()->clear (); + } + + bool need_redraw = (l.source (false /*local*/) != props.source (false /*local*/) || l.xfill (false /*local*/) != props.xfill (false /*local*/)); + bool visible_changed = (l.visible (true /*real*/) != props.visible (true /*real*/)); + + LayerPropertiesIterator non_const_iter (get_properties (index), iter.uint ()); + *non_const_iter = props; + + if (index == current_layer_list ()) { + + layer_list_changed_event (1); + + if (need_redraw) { + redraw (); + } + + if (visible_changed) { + m_visibility_changed = true; + } + + // perform the callbacks asynchronously to collect the necessary calls instead + // of executing them immediately. + dm_prop_changed (); + + } + } +} + +const LayerPropertiesNode & +LayoutViewBase::insert_layer (unsigned int index, const LayerPropertiesConstIterator &before, const LayerPropertiesNode &node) +{ + tl_assert (index < layer_lists ()); + + if (transacting ()) { + manager ()->queue (this, new OpInsertLayerProps (index, (unsigned int) before.uint (), node)); + } else if (manager () && ! replaying ()) { + manager ()->clear (); + } + + if (mp_control_panel && index == current_layer_list ()) { + mp_control_panel->begin_updates (); + } + + const LayerPropertiesNode &ret = m_layer_properties_lists [index]->insert (LayerPropertiesIterator (*m_layer_properties_lists [index], before.uint ()), node); + + // signal to the observers that something has changed + if (index == current_layer_list ()) { + layer_list_changed_event (2); + redraw (); + dm_prop_changed (); + } + + return ret; +} + +void +LayoutViewBase::delete_layer (unsigned int index, LayerPropertiesConstIterator &iter) +{ + if (index >= layer_lists ()) { + return; + } + + lay::LayerPropertiesNode orig = *iter; + + if (mp_control_panel && index == current_layer_list ()) { + mp_control_panel->begin_updates (); + } + + // delete the element + m_layer_properties_lists [index]->erase (LayerPropertiesIterator (*m_layer_properties_lists [index], iter.uint ())); + + if (transacting ()) { + manager ()->queue (this, new OpDeleteLayerProps (index, (unsigned int) iter.uint (), orig)); + } else if (manager () && ! replaying ()) { + manager ()->clear (); + } + + // signal to the observers that something has changed + if (index == current_layer_list ()) { + layer_list_changed_event (2); + redraw (); + dm_prop_changed (); + } + + // invalidate the iterator so it can be used to refer to the next element + iter.invalidate (); +} + +void +LayoutViewBase::signal_selection_changed () +{ + if (selection_size () > 1) { + message (tl::sprintf (tl::to_string (tr ("selected: %ld objects")), selection_size ())); + } + + lay::Editables::signal_selection_changed (); +} + +void +LayoutViewBase::save_as (unsigned int index, const std::string &filename, tl::OutputStream::OutputStreamMode om, const db::SaveLayoutOptions &options, bool update, int keep_backups) +{ + tl_assert (index < cellviews ()); + + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Saving"))); + cellview (index)->save_as (filename, om, options, update, keep_backups); + + cellview_changed (index); +} + +void +LayoutViewBase::redo (db::Op *op) +{ + tl_assert (! transacting ()); + + OpSetLayerProps *sop = dynamic_cast (op); + if (sop) { + if (sop->m_list_index < m_layer_properties_lists.size ()) { + set_properties (sop->m_list_index, lay::LayerPropertiesConstIterator (*m_layer_properties_lists [sop->m_list_index], sop->m_index), sop->m_new); + } + return; + } + + OpSetLayerPropsNode *snop = dynamic_cast (op); + if (snop) { + if (snop->m_list_index < m_layer_properties_lists.size ()) { + replace_layer_node (snop->m_list_index, lay::LayerPropertiesConstIterator (*m_layer_properties_lists [snop->m_list_index], snop->m_index), snop->m_new); + } + return; + } + + OpInsertLayerList *ilop = dynamic_cast (op); + if (ilop) { + if (ilop->m_list_index <= m_layer_properties_lists.size ()) { + insert_layer_list (ilop->m_list_index, ilop->m_new); + } + return; + } + + OpDeleteLayerList *dlop = dynamic_cast (op); + if (dlop) { + if (dlop->m_list_index < m_layer_properties_lists.size ()) { + delete_layer_list (dlop->m_list_index); + } + return; + } + + OpSetAllProps *saop = dynamic_cast (op); + if (saop) { + if (saop->m_list_index < m_layer_properties_lists.size ()) { + set_properties (saop->m_list_index, saop->m_new); + } + return; + } + + OpRenameProps *rnop = dynamic_cast (op); + if (rnop) { + if (rnop->m_list_index < m_layer_properties_lists.size ()) { + rename_properties (rnop->m_list_index, rnop->m_new); + } + return; + } + + OpLayerList *lop = dynamic_cast (op); + if (lop) { + if (lop->m_list_index < m_layer_properties_lists.size ()) { + if (lop->m_mode == OpLayerList::Insert) { + insert_layer (lop->m_list_index, lay::LayerPropertiesConstIterator (*m_layer_properties_lists [lop->m_list_index], lop->m_index), lop->m_node); + } else { + lay::LayerPropertiesConstIterator iter (*m_layer_properties_lists [lop->m_list_index], lop->m_index); + delete_layer (lop->m_list_index, iter); + } + } + return; + } + + OpSetDitherPattern *stpop = dynamic_cast (op); + if (stpop) { + set_dither_pattern (stpop->m_new); + return; + } + + OpHideShowCell *hscop = dynamic_cast (op); + if (hscop) { + if (hscop->m_show) { + show_cell (hscop->m_cell_index, hscop->m_cellview_index); + } else { + hide_cell (hscop->m_cell_index, hscop->m_cellview_index); + } + return; + } + + db::Object::redo (op); +} + +void +LayoutViewBase::undo (db::Op *op) +{ + tl_assert (! transacting ()); + + OpSetLayerProps *sop = dynamic_cast (op); + if (sop) { + if (sop->m_list_index < m_layer_properties_lists.size ()) { + set_properties (sop->m_list_index, lay::LayerPropertiesConstIterator (*m_layer_properties_lists [sop->m_list_index], sop->m_index), sop->m_old); + } + return; + } + + OpSetLayerPropsNode *snop = dynamic_cast (op); + if (snop) { + if (snop->m_list_index < m_layer_properties_lists.size ()) { + replace_layer_node (snop->m_list_index, lay::LayerPropertiesConstIterator (*m_layer_properties_lists [snop->m_list_index], snop->m_index), snop->m_old); + } + return; + } + + OpInsertLayerList *ilop = dynamic_cast (op); + if (ilop) { + if (ilop->m_list_index <= m_layer_properties_lists.size ()) { + delete_layer_list (ilop->m_list_index); + } + return; + } + + OpDeleteLayerList *dlop = dynamic_cast (op); + if (dlop) { + if (dlop->m_list_index < m_layer_properties_lists.size ()) { + insert_layer_list (dlop->m_list_index, dlop->m_old); + } + return; + } + + OpSetAllProps *saop = dynamic_cast (op); + if (saop) { + if (saop->m_list_index < m_layer_properties_lists.size ()) { + set_properties (saop->m_list_index, saop->m_old); + } + return; + } + + OpRenameProps *rnop = dynamic_cast (op); + if (rnop) { + if (rnop->m_list_index < m_layer_properties_lists.size ()) { + rename_properties (rnop->m_list_index, rnop->m_old); + } + return; + } + + OpLayerList *lop = dynamic_cast (op); + if (lop) { + if (lop->m_list_index < m_layer_properties_lists.size ()) { + if (lop->m_mode == OpLayerList::Insert) { + lay::LayerPropertiesConstIterator iter (*m_layer_properties_lists [lop->m_list_index], lop->m_index); + delete_layer (lop->m_list_index, iter); + } else { + insert_layer (lop->m_list_index, lay::LayerPropertiesConstIterator (*m_layer_properties_lists [lop->m_list_index], lop->m_index), lop->m_node); + } + } + return; + } + + OpHideShowCell *hscop = dynamic_cast (op); + if (hscop) { + + if (hscop->m_show) { + hide_cell (hscop->m_cell_index, hscop->m_cellview_index); + } else { + show_cell (hscop->m_cell_index, hscop->m_cellview_index); + } + + return; + + } + + OpSetDitherPattern *stpop = dynamic_cast (op); + if (stpop) { + set_dither_pattern (stpop->m_old); + return; + } + + db::Object::undo (op); +} + +void +LayoutViewBase::signal_hier_changed () +{ + // schedule a redraw request for all layers + redraw (); + // forward this event to our observers + hier_changed_event (); +} + +void +LayoutViewBase::signal_bboxes_from_layer_changed (unsigned int cv_index, unsigned int layer_index) +{ + if (layer_index == std::numeric_limits::max ()) { + + // redraw all + signal_bboxes_changed (); + + } else { + + // redraw only the layers required for redrawing + for (std::vector::const_iterator l = mp_canvas->get_redraw_layers ().begin (); l != mp_canvas->get_redraw_layers ().end (); ++l) { + if (l->cellview_index == int (cv_index) && l->layer_index == int (layer_index)) { + redraw_layer ((unsigned int) (l - mp_canvas->get_redraw_layers ().begin ())); + } + } + + // forward this event to our observers + geom_changed_event (); + + } +} + +void +LayoutViewBase::signal_bboxes_changed () +{ + // schedule a redraw request for all layers + redraw (); + + // forward this event to our observers + geom_changed_event (); +} + +void +LayoutViewBase::signal_cell_name_changed () +{ + cell_visibility_changed_event (); // HINT: that is not what actually is intended, but it serves the function ... + redraw (); // needs redraw +} + +void +LayoutViewBase::signal_layer_properties_changed () +{ + // recompute the source + // TODO: this is a side effect of this method - provide a special method for this purpose + for (unsigned int i = 0; i < layer_lists (); ++i) { + m_layer_properties_lists [i]->attach_view (this, i); + } + + // schedule a redraw request - since the layer views might not have changed, this is necessary + redraw (); +} + +void +LayoutViewBase::signal_prop_ids_changed () +{ + // inform the layer list observers that they need to recompute the property selectors + layer_list_changed_event (1); + + // recompute the source + // TODO: this is a side effect of this method - provide a special method for this purpose + for (unsigned int i = 0; i < layer_lists (); ++i) { + m_layer_properties_lists [i]->attach_view (this, i); + } +} + +void +LayoutViewBase::signal_plugin_enabled_changed () +{ + for (std::vector::iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) { + if ((*p)->editable_interface ()) { + enable ((*p)->editable_interface (), (*p)->plugin_declaration ()->editable_enabled ()); + } + } +} + +void +LayoutViewBase::signal_annotations_changed () +{ + // schedule a redraw request for the annotation shapes + redraw_deco_layer (); + // forward this event to our observers + annotations_changed_event (); +} + +void +LayoutViewBase::finish_cellviews_changed () +{ + update_event_handlers (); + + cellviews_changed_event (); + + redraw (); +} + +std::list::iterator +LayoutViewBase::cellview_iter (int cv_index) +{ + std::list::iterator i = m_cellviews.begin (); + while (cv_index > 0 && i != m_cellviews.end ()) { + ++i; + --cv_index; + } + tl_assert (i != m_cellviews.end ()); + return i; +} + +std::list::const_iterator +LayoutViewBase::cellview_iter (int cv_index) const +{ + std::list::const_iterator i = m_cellviews.begin (); + while (cv_index > 0 && i != m_cellviews.end ()) { + ++i; + --cv_index; + } + tl_assert (i != m_cellviews.end ()); + return i; +} + +void +LayoutViewBase::erase_cellview (unsigned int index) +{ + if (index >= m_cellviews.size ()) { + return; + } + + cancel_esc (); + + // issue to event that signals a change in the cellviews + cellviews_about_to_change_event (); + + // no undo available - clear all transactions + if (manager ()) { + manager ()->clear (); + } + + if (mp_control_panel) { + mp_control_panel->begin_updates (); + } + + m_cellviews.erase (cellview_iter (int (index))); + + if (m_hidden_cells.size () > index) { + m_hidden_cells.erase (m_hidden_cells.begin () + index); + } + + for (unsigned int lindex = 0; lindex < layer_lists (); ++lindex) { + + // remove all references to the cellview + m_layer_properties_lists [lindex]->remove_cv_references (index); + + // rename the ones that got shifted. + lay::LayerPropertiesConstIterator l = begin_layers (lindex); + while (! l.at_end ()) { + lay::ParsedLayerSource source (l->source (false)); + if (source.cv_index () >= int (index)) { + lay::LayerProperties new_props (*l); + source.cv_index (source.cv_index () == int (index) ? -1 : source.cv_index () - 1); + new_props.set_source (source); + LayerPropertiesIterator non_const_iter (*m_layer_properties_lists [lindex], l.uint ()); + *non_const_iter = new_props; + } + ++l; + } + + } + + // clear the history + m_display_states.clear (); + m_display_state_ptr = 0; + + // signal to the observers that something has changed + layer_list_changed_event (3); + + finish_cellviews_changed (); + + update_content (); + + if (m_title.empty ()) { + emit title_changed (); + } +} + +void +LayoutViewBase::clear_cellviews () +{ + // issue to event that signals a change in the cellviews + cellviews_about_to_change_event (); + + // no undo available - clear all transactions + if (manager ()) { + manager ()->clear (); + } + + // clear the layer lists and cellviews + while (layer_lists () > 0) { + delete_layer_list (layer_lists () - 1); + } + set_properties (lay::LayerPropertiesList ()); + m_cellviews.clear (); + + // clear the history, store path and zoom box + m_display_states.clear (); + m_display_state_ptr = 0; + + finish_cellviews_changed (); + + if (m_title.empty ()) { + emit title_changed (); + } +} + +const CellView & +LayoutViewBase::cellview (unsigned int index) const +{ + static const CellView empty; + if (index >= m_cellviews.size ()) { + return empty; + } else { + return *cellview_iter (int (index)); + } +} + +CellViewRef +LayoutViewBase::cellview_ref (unsigned int index) +{ + if (index >= m_cellviews.size ()) { + return CellViewRef (); + } else { + return CellViewRef (cellview_iter (index).operator-> (), this); + } +} + +int +LayoutViewBase::index_of_cellview (const lay::CellView *cv) const +{ + int index = 0; + for (std::list::const_iterator i = m_cellviews.begin (); i != m_cellviews.end (); ++i, ++index) { + if (cv == i.operator-> ()) { + return index; + } + } + return -1; +} + +void +LayoutViewBase::set_layout (const lay::CellView &cv, unsigned int cvindex) +{ + // issue to event that signals a change in the cellviews + cellviews_about_to_change_event (); + + // no undo available - clear all transactions + if (manager ()) { + manager ()->clear (); + } + + // signal the change of layer properties to the observer + layer_list_changed_event (3); + + // create a new cellview if required + while (m_cellviews.size () <= cvindex) { + m_cellviews.push_back (lay::CellView ()); + } + + // set the handle reference and clear all cell related stuff + *cellview_iter (cvindex) = cv; + + // clear the history, store path and zoom box + clear_states (); + + finish_cellviews_changed (); + + // since the hierarchy panel may hold cellviews, we explicitly request an initialization + // of the tree. This will release such references. This way, set_layout guarantees that + // the layouts are released as far as possible. This is important for reload () for example. + if (mp_hierarchy_panel) { + mp_hierarchy_panel->do_update_content (cvindex); + } + + if (m_title.empty ()) { + emit title_changed (); + } +} + +void +LayoutViewBase::signal_apply_technology (lay::LayoutHandle *layout_handle) +{ + // find the cellview which issued the event + for (unsigned int i = 0; i < cellviews (); ++i) { + + if (cellview (i).handle () == layout_handle) { + + cancel_esc (); + + std::string lyp_file; + 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 (); + } + + if (! lyp_file.empty ()) { + + // interpolate the layout properties file name + tl::Eval expr; + expr.set_var ("layoutfile", cellview (i)->filename ()); + lyp_file = expr.interpolate (lyp_file); + + // remove all references to the cellview in the layer properties + for (unsigned int lindex = 0; lindex < layer_lists (); ++lindex) { + m_layer_properties_lists [lindex]->remove_cv_references (i); + } + + // if a layer properties file is set, create the layer properties now + create_initial_layer_props (i, lyp_file, tech->add_other_layers ()); + + } + + } + + } +} + +void +LayoutViewBase::load_layer_props (const std::string &fn) +{ + do_load_layer_props (fn, false, -1, false); +} + +void +LayoutViewBase::load_layer_props (const std::string &fn, bool add_default) +{ + do_load_layer_props (fn, false, -1, add_default); +} + +void +LayoutViewBase::load_layer_props (const std::string &fn, int cv_index, bool add_default) +{ + do_load_layer_props (fn, true, cv_index, add_default); +} + +void +LayoutViewBase::do_load_layer_props (const std::string &fn, bool map_cv, int cv_index, bool add_default) +{ + std::vector props; + bool single_list = false; + + // read the layer properties from the file + try { + tl::XMLFileSource in (fn); + props.push_back (lay::LayerPropertiesList ()); + props.back ().load (in); + single_list = true; + } catch (...) { + props.clear (); + tl::XMLFileSource in (fn); + lay::LayerPropertiesList::load (in, props); + } + + // expand the wildcards and map to the target cv. + for (std::vector::iterator p = props.begin (); p != props.end (); ++p) { + std::map cv_map; + if (map_cv) { + cv_map.insert (std::make_pair (-1, cv_index)); + } + p->attach_view (this, p - props.begin ()); + p->expand (cv_map, add_default); + } + + transaction (tl::to_string (tr ("Load layer properties"))); + + if (single_list) { + + // a single list will only replace the current tab + if (map_cv && cv_index >= 0) { + lay::LayerPropertiesList new_props (get_properties ()); + new_props.remove_cv_references (cv_index); + new_props.append (props [0]); + set_properties (new_props); + } else { + set_properties (props [0]); + } + + } else { + + for (unsigned int i = 0; i < props.size (); ++i) { + + if (i < layer_lists ()) { + + if (map_cv && cv_index >= 0) { + lay::LayerPropertiesList new_props (get_properties (i)); + new_props.remove_cv_references (cv_index); + new_props.append (props [i]); + set_properties (i, new_props); + } else { + set_properties (i, props [i]); + } + + } else { + insert_layer_list (i, props [i]); + } + + } + + while (layer_lists () > props.size () && layer_lists () > 1) { + delete_layer_list (layer_lists () - 1); + } + + } + + commit (); + + update_content (); + + tl::log << "Loaded layer properties from " << fn; +} + +void +LayoutViewBase::save_layer_props (const std::string &fn) +{ + tl::OutputStream os (fn, tl::OutputStream::OM_Plain); + + if (layer_lists () == 1) { + + // a single list is written in the traditional format + get_properties ().save (os); + + } else { + + // multiple tabs are written in the multi-tab format + std::vector props; + for (unsigned int i = 0; i < layer_lists (); ++i) { + props.push_back (get_properties (i)); + } + + lay::LayerPropertiesList::save (os, props); + + } + + tl::log << "Saved layer properties to " << fn; +} + +void +LayoutViewBase::add_new_layers (const std::vector &layer_ids, int cv_index) +{ + if (cv_index >= 0 && cv_index < int (cellviews ())) { + + const lay::CellView &cv = cellview (cv_index); + + // create the layers and do a basic recoloring .. + lay::LayerPropertiesList new_props (get_properties ()); + + bool was_empty = new_props.begin_const_recursive ().at_end (); + + // don't create new layers for those, for which there are layers already: compute a + // set of layers already present + std::set present_layers; + for (LayerPropertiesConstIterator lay_iter = begin_layers (); ! lay_iter.at_end (); ++lay_iter) { + if (! lay_iter->has_children () && lay_iter->cellview_index () == cv_index) { + present_layers.insert (lay_iter->source (true /*real*/).layer_props ()); + } + } + + // determine layers which are new and need to be created + std::vector new_layers; + for (std::vector ::const_iterator l = layer_ids.begin (); l != layer_ids.end (); ++l) { + const db::LayerProperties &lp = cv->layout ().get_properties (*l); + if (present_layers.find (lp) == present_layers.end ()) { + new_layers.push_back (lp); + } + } + + // create them in the sorting order provided by db::LayerProperties + std::sort (new_layers.begin (), new_layers.end (), db::LPLogicalLessFunc ()); + + // and actually create them + for (std::vector ::const_iterator l = new_layers.begin (); l != new_layers.end (); ++l) { + lay::LayerProperties p; + p.set_source (lay::ParsedLayerSource (*l, cv_index)); + init_layer_properties (p, new_props); + new_props.push_back (p); + } + + set_properties (new_props); + + if (was_empty) { + set_current_layer (new_props.begin_const_recursive ()); + } + + } +} + +void +LayoutViewBase::init_layer_properties (LayerProperties &p) const +{ + init_layer_properties (p, get_properties ()); +} + +void +LayoutViewBase::init_layer_properties (LayerProperties &p, const LayerPropertiesList &lp_list) const +{ + lay::color_t c = 0; + if (m_palette.luminous_colors () > 0) { + c = m_palette.luminous_color_by_index (p.source (true /*real*/).color_index ()); + } + + p.set_dither_pattern (m_stipple_palette.standard_stipple_by_index (lp_list.end_const () - lp_list.begin_const ())); + p.set_fill_color (c); + p.set_frame_color (c); + p.set_fill_brightness (0); + p.set_frame_brightness (0); + p.set_frame_brightness (0); + p.set_transparent (false); // :TODO: make variable + p.set_visible (true); + p.set_width (1); + p.set_animation (0); + p.set_marked (false); +} + +#if defined(HAVE_QT) +QImage +LayoutViewBase::get_screenshot () +{ + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Save screenshot"))); + + // Execute all deferred methods - ensure there are no pending tasks + tl::DeferredMethodScheduler::execute (); + + return mp_canvas->screenshot (); +} + +void +LayoutViewBase::save_screenshot (const std::string &fn) +{ + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Save screenshot"))); + + QImageWriter writer (tl::to_qstring (fn), QByteArray ("PNG")); + + // Unfortunately the PNG writer does not allow writing of long strings. + // We separate the description into a set of keys: + + for (unsigned int i = 0; i < cellviews (); ++i) { + if (cellview (i).is_valid ()) { + std::string name = cellview (i)->layout ().cell_name (cellview (i).cell_index ()); + writer.setText (tl::to_qstring ("Cell" + tl::to_string (int (i) + 1)), tl::to_qstring (name)); + } + } + + db::DBox b (box ()); + std::string desc; + desc += tl::micron_to_string (b.left ()) + "," + tl::micron_to_string (b.bottom ()); + desc += "/"; + desc += tl::micron_to_string (b.right ()) + "," + tl::micron_to_string (b.top ()); + writer.setText (QString::fromUtf8 ("Rect"), tl::to_qstring (desc)); + + // Execute all deferred methods - ensure there are no pending tasks + tl::DeferredMethodScheduler::execute (); + + if (! writer.write (mp_canvas->screenshot ())) { + throw tl::Exception (tl::to_string (QObject::tr ("Unable to write screenshot to file: %s (%s)")), fn, tl::to_string (writer.errorString ())); + } + + tl::log << "Saved screen shot to " << fn; +} + +QImage +LayoutViewBase::get_image (unsigned int width, unsigned int height) +{ + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Save image"))); + + // Execute all deferred methods - ensure there are no pending tasks + tl::DeferredMethodScheduler::execute (); + + return mp_canvas->image (width, height); +} + +QImage +LayoutViewBase::get_image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, + lay::Color background, lay::Color foreground, lay::Color active, const db::DBox &target_box, bool monochrome) +{ + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Save image"))); + + // Execute all deferred methods - ensure there are no pending tasks + tl::DeferredMethodScheduler::execute (); + + return mp_canvas->image_with_options (width, height, linewidth, oversampling, resolution, background, foreground, active, target_box, monochrome); +} + +void +LayoutViewBase::save_image (const std::string &fn, unsigned int width, unsigned int height) +{ + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Save image"))); + + QImageWriter writer (tl::to_qstring (fn), QByteArray ("PNG")); + + // Unfortunately the PNG writer does not allow writing of long strings. + // We separate the description into a set of keys: + + for (unsigned int i = 0; i < cellviews (); ++i) { + if (cellview (i).is_valid ()) { + std::string name = cellview (i)->layout ().cell_name (cellview (i).cell_index ()); + writer.setText (tl::to_qstring ("Cell" + tl::to_string (int (i) + 1)), tl::to_qstring (name)); + } + } + + lay::Viewport vp (width, height, mp_canvas->viewport ().target_box ()); + writer.setText (QString::fromUtf8 ("Rect"), tl::to_qstring (vp.box ().to_string ())); + + // Execute all deferred methods - ensure there are no pending tasks + tl::DeferredMethodScheduler::execute (); + + if (! writer.write (mp_canvas->image (width, height))) { + throw tl::Exception (tl::to_string (QObject::tr ("Unable to write screenshot to file: %s (%s)")), fn, tl::to_string (writer.errorString ())); + } + + tl::log << "Saved screen shot to " << fn; +} + +void +LayoutViewBase::save_image_with_options (const std::string &fn, + unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, + lay::Color background, lay::Color foreground, lay::Color active, const db::DBox &target_box, bool monochrome) +{ + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Save image"))); + + QImageWriter writer (tl::to_qstring (fn), QByteArray ("PNG")); + + // Unfortunately the PNG writer does not allow writing of long strings. + // We separate the description into a set of keys: + + for (unsigned int i = 0; i < cellviews (); ++i) { + if (cellview (i).is_valid ()) { + std::string name = cellview (i)->layout ().cell_name (cellview (i).cell_index ()); + writer.setText (tl::to_qstring ("Cell" + tl::to_string (int (i) + 1)), tl::to_qstring (name)); + } + } + + lay::Viewport vp (width, height, mp_canvas->viewport ().target_box ()); + writer.setText (QString::fromUtf8 ("Rect"), tl::to_qstring (vp.box ().to_string ())); + + // Execute all deferred methods - ensure there are no pending tasks + tl::DeferredMethodScheduler::execute (); + + if (! writer.write (mp_canvas->image_with_options (width, height, linewidth, oversampling, resolution, background, foreground, active, target_box, monochrome))) { + throw tl::Exception (tl::to_string (QObject::tr ("Unable to write screenshot to file: %s (%s)")), fn, tl::to_string (writer.errorString ())); + } + + tl::log << "Saved screen shot to " << fn; +} +#endif + +void +LayoutViewBase::reload_layout (unsigned int cv_index) +{ + stop (); + cancel_esc (); + + // save the current view state + lay::DisplayState state; + save_view (state); + + // this is the cellview at the given index (use a copy since the original is overwritten) + CellView cvorg = cellview (cv_index); + + // obtain the original filename + std::string filename = cvorg->filename (); + std::string technology = cvorg->tech_name (); + std::string name = cvorg->name (); + + // recreate hidden cells by doing a name referencing + std::vector hidden_cells; + if (m_hidden_cells.size () > cv_index) { + hidden_cells.reserve (m_hidden_cells [cv_index].size ()); + for (std::set ::const_iterator ci = m_hidden_cells [cv_index].begin (); ci != m_hidden_cells [cv_index].end (); ++ci) { + hidden_cells.push_back (std::string (cvorg->layout ().cell_name (*ci))); + } + } + + // Set up a list of present layers + std::set present_layers; + for (LayerPropertiesConstIterator lay_iter = begin_layers (); ! lay_iter.at_end (); ++lay_iter) { + if (! lay_iter->has_children ()) { + present_layers.insert (lay_iter->source (true /*real*/).layer_props ()); + } + } + + std::map org_layers; + + for (unsigned int i = 0; i < cvorg->layout ().layers (); ++i) { + if (cvorg->layout ().is_valid_layer (i)) { + const db::LayerProperties &p = cvorg->layout ().get_properties (i); + if (! p.log_equal (db::LayerProperties ())) { + org_layers.insert (std::make_pair (i, p)); + } + } + } + + lay::LayoutHandle *handle; + + // reset the layout: create a dummy handle and install this in between + // this will clear the original layout if not further referenced. + // Since the dummy layout will act as a placeholder if something goes wrong + // when reading the file, it must have the layers created as well + lay::CellView cv_empty; + + handle = new lay::LayoutHandle (new db::Layout (manager ()), filename); + handle->set_tech_name (technology); + cv_empty.set (handle); + + for (std::map ::const_iterator ol = org_layers.begin (); ol != org_layers.end (); ++ol) { + cv_empty->layout ().insert_layer (ol->first, ol->second); + } + cv_empty->rename (name, true); + + set_layout (cv_empty, cv_index); + + // create a new handle + lay::CellView cv; + handle = new lay::LayoutHandle (new db::Layout (manager ()), filename); + cv.set (handle); + + try { + + // re-create the layers required + for (std::map ::const_iterator ol = org_layers.begin (); ol != org_layers.end (); ++ol) { + cv->layout ().insert_layer (ol->first, ol->second); + } + + { + tl::log << tl::to_string (tr ("Loading file: ")) << filename; + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Loading"))); + + // Load with the previous options again. + db::LoadLayoutOptions options (cvorg->load_options ()); + cv->load (cvorg->load_options (), technology); + } + + // sort the layout explicitly here. Otherwise it would be done + // implicitly at some other time. This may throw an exception + // if the operation was cancelled. + { + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Sorting"))); + cv->layout ().update (); + } + + // print the memory statistics now. + if (tl::verbosity () >= 31) { + db::MemStatisticsCollector m (false); + cv->layout ().mem_stat (&m, db::MemStatistics::LayoutInfo, 0); + m.print (); + } + + // this is required to release every reference to the cv_empty layout + cv_empty = lay::CellView (); + + // install the new layout + cv->rename (name, true); + set_layout (cv, cv_index); + + } catch (...) { + update_content (); + throw; + } + + // recreate the hidden cell indices from the names + if (m_hidden_cells.size () > cv_index) { + m_hidden_cells [cv_index].clear (); + for (std::vector ::const_iterator cn = hidden_cells.begin (); cn != hidden_cells.end (); ++cn) { + std::pair cid = cv->layout ().cell_by_name (cn->c_str ()); + if (cid.first) { + m_hidden_cells [cv_index].insert (cid.second); + } + } + } + + // Determine which layers to create as new layers. New layer need to be created + // if these have not been present in the original layout and there are no layer views + // referring to them. + std::vector new_layers; + for (unsigned int i = 0; i < cv->layout ().layers (); ++i) { + if (cv->layout ().is_valid_layer (i)) { + std::map ::iterator ol = org_layers.find (i); + if (ol == org_layers.end () && present_layers.find (cv->layout ().get_properties (i)) == present_layers.end ()) { + new_layers.push_back (cv->layout ().get_properties (i)); + } + } + } + + std::sort (new_layers.begin (), new_layers.end (), db::LPLogicalLessFunc ()); + + // create the layers and do a basic recoloring .. + lay::LayerPropertiesList new_props (get_properties ()); + + for (std::vector ::const_iterator l = new_layers.begin (); l != new_layers.end (); ++l) { + lay::LayerProperties p; + p.set_source (lay::ParsedLayerSource (*l, int (cv_index))); + init_layer_properties (p, new_props); + new_props.push_back (p); + } + + set_properties (new_props); + + goto_view (state); + +} + +unsigned int +LayoutViewBase::add_layout (lay::LayoutHandle *layout_handle, bool add_cellview, bool initialize_layers) +{ + unsigned int cv_index = 0; + + try { + + m_active_cellview_changed_event_enabled = false; + + stop_redraw (); + + bool set_max_hier = (m_full_hier_new_cell || has_max_hier ()); + + lay::CellView cv; + + if (! add_cellview) { + clear_cellviews (); + } + + cv.set (layout_handle); + + cv->layout ().update (); + + // select the cell with the largest area as the first top cell + db::Layout::top_down_const_iterator top = cv->layout ().begin_top_down (); + for (db::Layout::top_down_const_iterator t = cv->layout ().begin_top_down (); t != cv->layout ().end_top_cells (); ++t) { + if (cv->layout ().cell (*t).bbox ().area () > cv->layout ().cell (*top).bbox ().area ()) { + top = t; + } + } + + if (top != cv->layout ().end_top_down ()) { + std::vector p; + p.push_back (*top); + cv.set_unspecific_path (p); + } + + cv_index = cellviews (); + set_layout (cv, cv_index); + + if (top != cv->layout ().end_top_cells ()) { + std::vector p; + p.push_back (*top); + select_cell (p, cv_index); + } else { + // even if there is no cell, select the cellview item + // to support applications with an active cellview (that is however invalid) + set_active_cellview_index (cv_index); + } + + if (initialize_layers) { + + bool add_other_layers = m_add_other_layers; + + // 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 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 (); + } + + // Give the layout object a chance to specify a certain layer property file + for (db::Layout::meta_info_iterator meta = cv->layout ().begin_meta (); meta != cv->layout ().end_meta (); ++meta) { + if (meta->name == "layer-properties-file") { + lyp_file = meta->value; + } + if (meta->name == "layer-properties-add-other-layers") { + try { + tl::from_string (meta->value, add_other_layers); + } catch (...) { + } + } + } + + // interpolate the layout properties file name + tl::Eval expr; + expr.set_var ("layoutfile", layout_handle->filename ()); + lyp_file = expr.interpolate (lyp_file); + + // create the initial layer properties + create_initial_layer_props (cv_index, lyp_file, add_other_layers); + + } + + // select the first layer if nothing else is selected + if (cv_index == 0 && ! mp_control_panel->has_selection ()) { + const lay::LayerPropertiesList &lp = get_properties (); + lay::LayerPropertiesConstIterator li = lp.begin_const_recursive (); + while (! li.at_end () && li->has_children ()) { + ++li; + } + if (! li.at_end ()) { + mp_control_panel->set_current_layer (li); + } + } + + // signal to any observers + file_open_event (); + + if (cv->layout ().begin_top_down () != cv->layout ().end_top_down ()) { + + // do a fit and update layer lists etc. + zoom_fit (); + if (set_max_hier) { + max_hier (); + } + update_content (); + + } else { + // even if there is no cell, select the cellview item + // to support applications with an active cellview (that is however invalid) + set_active_cellview_index (cv_index); + } + + m_active_cellview_changed_event_enabled = true; + + } catch (...) { + + update_content (); + + m_active_cellview_changed_event_enabled = true; + throw; + + } + + // this event may not be generated otherwise, hence force it now. + active_cellview_changed (cv_index); + + return cv_index; +} + +unsigned int +LayoutViewBase::create_layout (const std::string &technology, bool add_cellview, bool initialize_layers) +{ + const db::Technology *tech = db::Technologies::instance ()->technology_by_name (technology); + + db::Layout *layout = new db::Layout (manager ()); + if (tech) { + layout->dbu (tech->dbu ()); + } + + lay::LayoutHandle *handle = new lay::LayoutHandle (layout, ""); + handle->set_tech_name (technology); + return add_layout (handle, add_cellview, initialize_layers); +} + +unsigned int +LayoutViewBase::load_layout (const std::string &filename, const std::string &technology, bool add_cellview) +{ + return load_layout (filename, db::LoadLayoutOptions (), technology, add_cellview); +} + +unsigned int +LayoutViewBase::load_layout (const std::string &filename, const db::LoadLayoutOptions &options, const std::string &technology, bool add_cellview) +{ + stop (); + + bool set_max_hier = (m_full_hier_new_cell || has_max_hier ()); + + const db::Technology *tech = db::Technologies::instance ()->technology_by_name (technology); + + // create a new layout handle + lay::CellView cv; + lay::LayoutHandle *handle = new lay::LayoutHandle (new db::Layout (manager ()), filename); + cv.set (handle); + + unsigned int cv_index; + db::LayerMap lmap; + + try { + + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Loading"))); + + // load the file + { + tl::log << tl::to_string (tr ("Loading file: ")) << filename << tl::to_string (tr (" with technology: ")) << technology; + lmap = cv->load (options, technology); + } + + // sort the layout explicitly here. Otherwise it would be done + // implicitly at some other time. This may throw an exception + // if the operation was cancelled. + { + cv->layout ().update (); + } + + // print the memory statistics now. + if (tl::verbosity () >= 31) { + db::MemStatisticsCollector m (false); + cv->layout ().mem_stat (&m, db::MemStatistics::LayoutInfo, 0); + m.print (); + } + + // clear the cellviews if required + if (! add_cellview) { + clear_cellviews (); + } + + // set the new layout as the layout for the last cellview + cv_index = cellviews (); + set_layout (cv, cv_index); + + } catch (...) { + + update_content (); + throw; + + } + + try { + + m_active_cellview_changed_event_enabled = false; + + // select the cell with the largest area as the first top cell + db::Layout::top_down_const_iterator top = cv->layout ().begin_top_down (); + for (db::Layout::top_down_const_iterator t = cv->layout ().begin_top_down (); t != cv->layout ().end_top_cells (); ++t) { + if (cv->layout ().cell (*t).bbox ().area () > cv->layout ().cell (*top).bbox ().area ()) { + top = t; + } + } + if (top != cv->layout ().end_top_cells ()) { + std::vector p; + p.push_back (*top); + select_cell (p, cv_index); + } else { + // even if there is no cell, select the cellview item + // to support applications with an active cellview (that is however invalid) + set_active_cellview_index (cv_index); + } + + bool add_other_layers = m_add_other_layers; + + // 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; + if (tech && ! tech->eff_layer_properties_file ().empty ()) { + lyp_file = tech->eff_layer_properties_file (); + add_other_layers = tech->add_other_layers (); + } + + // Give the layout object a chance to specify a certain layer property file + for (db::Layout::meta_info_iterator meta = cv->layout().begin_meta (); meta != cv->layout().end_meta (); ++meta) { + if (meta->name == "layer-properties-file") { + lyp_file = meta->value; + } + if (meta->name == "layer-properties-add-other-layers") { + try { + tl::from_string (meta->value, add_other_layers); + } catch (...) { + } + } + } + + // interpolate the layout properties file name + tl::Eval expr; + expr.set_var ("layoutfile", filename); + lyp_file = expr.interpolate (lyp_file); + + // create the initial layer properties + create_initial_layer_props (cv_index, lyp_file, add_other_layers); + + // select the first layer if nothing else is selected + if (cv_index == 0 && ! mp_control_panel->has_selection ()) { + const lay::LayerPropertiesList &lp = get_properties (); + lay::LayerPropertiesConstIterator li = lp.begin_const_recursive (); + while (! li.at_end () && li->has_children ()) { + ++li; + } + if (! li.at_end ()) { + mp_control_panel->set_current_layer (li); + } + } + + // signal to any observers + file_open_event (); + + // do a fit and update layer lists etc. + zoom_fit (); + if (set_max_hier) { + max_hier (); + } + update_content (); + + m_active_cellview_changed_event_enabled = true; + + } catch (...) { + + update_content (); + + m_active_cellview_changed_event_enabled = true; + throw; + + } + + // this event may not be generated otherwise, hence force it now. + active_cellview_changed (cv_index); + + return cv_index; +} + +void +LayoutViewBase::create_initial_layer_props (int cv_index, const std::string &lyp_file, bool add_missing) +{ + std::vector props; + bool loaded = false; + + if (! lyp_file.empty ()) { + + // read the layer properties from the file + try { + + try { + tl::XMLFileSource in (lyp_file); + props.push_back (lay::LayerPropertiesList ()); + props.back ().load (in); + loaded = true; + } catch (...) { + props.clear (); + tl::XMLFileSource in (lyp_file); + tl::log << tl::to_string (tr ("Loading layer properties file: ")) << lyp_file; + lay::LayerPropertiesList::load (in, props); + loaded = true; + } + + } catch (tl::Exception &ex) { + tl::warn << tl::to_string (tr ("Initialization of layers failed: ")) << ex.msg (); + } catch (...) { + tl::warn << tl::to_string (tr ("Initialization of layers failed: unspecific error")); + } + + } + + std::map cv_map; + cv_map.insert (std::make_pair (-1, cv_index)); + + if (! loaded) { + + props.clear (); + props.push_back (lay::LayerPropertiesList ()); + + } else { + + // do't map cv's if the input file is a multi-cv one. + std::set cv; + for (std::vector::const_iterator p = props.begin (); p != props.end (); ++p) { + for (lay::LayerPropertiesConstIterator lp = p->begin_const_recursive (); ! lp.at_end (); ++lp) { + if (! lp->has_children ()) { + cv.insert (lp->source (true).cv_index ()); + if (cv.size () >= 2) { + cv_map.clear (); + cv_map.insert (std::make_pair (cv_index, cv_index)); + // erase the others: + cv_map.insert (std::make_pair (-1, -2)); + break; + } + } + } + } + + } + + // expand the wildcards and map to the target cv. + for (std::vector::iterator p = props.begin (); p != props.end (); ++p) { + p->attach_view (this, p - props.begin ()); + p->expand (cv_map, add_missing || !loaded); + } + + merge_layer_props (props); +} + +void +LayoutViewBase::merge_layer_props (const std::vector &props) +{ + lay::LayerPropertiesList p0; + if (layer_lists () > 0) { + p0 = get_properties (0); + } + + // merge the new layer views into the present ones + // If the specific list is a single list (no tabs), it is merged into every tab present. + if (props.size () == 1) { + + for (size_t n = 0; n < layer_lists () || n == 0; ++n) { + + std::vector::const_iterator p = props.begin (); + + if (n < layer_lists ()) { + lay::LayerPropertiesList new_props (get_properties ((unsigned int) n)); + new_props.append (*p); + if (! p->name ().empty ()) { + new_props.set_name (p->name ()); + } + set_properties ((unsigned int) n, new_props); + } else { + + lay::LayerPropertiesList new_props = p0; + new_props.append (*p); + if (! p->name ().empty ()) { + new_props.set_name (p->name ()); + } + insert_layer_list ((unsigned int) n, new_props); + } + + } + + } else { + + size_t n = 0; + for (std::vector::const_iterator p = props.begin (); p != props.end (); ++p, ++n) { + + if (n < layer_lists ()) { + lay::LayerPropertiesList new_props (get_properties ((unsigned int) n)); + new_props.append (*p); + if (! p->name ().empty ()) { + new_props.set_name (p->name ()); + } + set_properties ((unsigned int) n, new_props); + } else { + lay::LayerPropertiesList new_props = p0; + new_props.append (*p); + if (! p->name ().empty ()) { + new_props.set_name (p->name ()); + } + insert_layer_list ((unsigned int) n, new_props); + } + + } + + } +} + +void +LayoutViewBase::pop_state () +{ + if (m_display_state_ptr > 0) { + m_display_states.erase (m_display_states.begin () + m_display_state_ptr, m_display_states.end ()); + --m_display_state_ptr; + } +} + +void +LayoutViewBase::clear_states () +{ + m_display_states.clear (); + m_display_state_ptr = 0; +} + +void +LayoutViewBase::store_state () +{ + // erase all states after the current position + if (m_display_state_ptr + 1 < m_display_states.size ()) { + m_display_states.erase (m_display_states.begin () + m_display_state_ptr + 1, m_display_states.end ()); + } + + // save the state + DisplayState state (box (), get_min_hier_levels (), get_max_hier_levels (), m_cellviews); + m_display_states.push_back (state); + + m_display_state_ptr = (unsigned int) (m_display_states.size () - 1); +} + +db::DBox +LayoutViewBase::box () const +{ + return mp_canvas->viewport ().box (); +} + +void +LayoutViewBase::timer () +{ + bool dirty = false; + for (std::list::const_iterator i = m_cellviews.begin (); i != m_cellviews.end () && ! dirty; ++i) { + dirty = (*i)->layout ().is_editable () && (*i)->is_dirty (); + } + + if (dirty != m_dirty) { + m_dirty = dirty; + emit dirty_changed (); + } + + if (m_animated) { + set_view_ops (); + if (mp_control_panel) { + mp_control_panel->set_phase (int (m_phase)); + } + if (m_animated) { + ++m_phase; + } + } +} + +bool +LayoutViewBase::layer_model_updated () +{ + // because check_updated is called in the initialization phase, we check if the pointers + // to the widgets are non-null: + if (mp_control_panel) { + return mp_control_panel->model_updated (); + } else { + return false; + } +} + +void +LayoutViewBase::force_update_content () +{ + set_view_ops (); +} + +void +LayoutViewBase::update_content () +{ + if (m_activated) { + set_view_ops (); + } +} + +void +LayoutViewBase::zoom_fit_sel () +{ + db::DBox bbox = selection_bbox (); + if (! bbox.empty ()) { + bbox = db::DBox (bbox.left () - 0.025 * bbox.width (), bbox.bottom () - 0.025 * bbox.height (), + bbox.right () + 0.025 * bbox.width (), bbox.top () + 0.025 * bbox.height ()); + zoom_box (bbox); + } +} + +db::DBox +LayoutViewBase::full_box () const +{ + // compute the bounding box over all layers + // this will trigger the update procedures of the layout objects if not done yet .. + + db::DBox bbox; + + for (LayerPropertiesConstIterator l = get_properties ().begin_const_recursive (); ! l.at_end (); ++l) { + bbox += l->bbox (); + } + + for (lay::AnnotationShapes::iterator a = annotation_shapes ().begin (); ! a.at_end (); ++a) { + bbox += a->box (); + } + + if (bbox.empty ()) { + bbox = db::DBox (0, 0, 0, 0); // default box + } else { + bbox = db::DBox (bbox.left () - 0.025 * bbox.width (), bbox.bottom () - 0.025 * bbox.height (), + bbox.right () + 0.025 * bbox.width (), bbox.top () + 0.025 * bbox.height ()); + } + + return bbox; +} + +void +LayoutViewBase::zoom_fit () +{ + mp_canvas->zoom_box (full_box (), true /*precious*/); + store_state (); +} + +void +LayoutViewBase::ensure_selection_visible () +{ + ensure_visible (selection_bbox ()); +} + +void +LayoutViewBase::ensure_visible (const db::DBox &bbox) +{ + db::DBox new_box = bbox + viewport ().box (); + mp_canvas->zoom_box (new_box); + store_state (); +} + +void +LayoutViewBase::zoom_box_and_set_hier_levels (const db::DBox &bbox, const std::pair &levels) +{ + mp_canvas->zoom_box (bbox); + set_hier_levels_basic (levels); + store_state (); +} + +void +LayoutViewBase::zoom_box (const db::DBox &bbox) +{ + mp_canvas->zoom_box (bbox); + store_state (); +} + +void +LayoutViewBase::set_global_trans (const db::DCplxTrans &trans) +{ + mp_canvas->set_global_trans (trans); + store_state (); +} + +void +LayoutViewBase::zoom_trans (const db::DCplxTrans &trans) +{ + mp_canvas->zoom_trans (trans); + store_state (); +} + +void +LayoutViewBase::pan_left () +{ + shift_window (1.0, -m_pan_distance, 0.0); +} + +void +LayoutViewBase::pan_right () +{ + shift_window (1.0, m_pan_distance, 0.0); +} + +void +LayoutViewBase::pan_up () +{ + shift_window (1.0, 0.0, m_pan_distance); +} + +void +LayoutViewBase::pan_down () +{ + shift_window (1.0, 0.0, -m_pan_distance); +} + +void +LayoutViewBase::pan_left_fast () +{ + shift_window (1.0, -m_pan_distance * fast_factor, 0.0); +} + +void +LayoutViewBase::pan_right_fast () +{ + shift_window (1.0, m_pan_distance * fast_factor, 0.0); +} + +void +LayoutViewBase::pan_up_fast () +{ + shift_window (1.0, 0.0, m_pan_distance * fast_factor); +} + +void +LayoutViewBase::pan_down_fast () +{ + shift_window (1.0, 0.0, -m_pan_distance * fast_factor); +} + +void +LayoutViewBase::pan_center (const db::DPoint &p) +{ + db::DBox b = mp_canvas->viewport ().box (); + db::DVector d (b.width () * 0.5, b.height () * 0.5); + zoom_box (db::DBox (p - d, p + d)); +} + +void +LayoutViewBase::zoom_in () +{ + shift_window (zoom_factor, 0.0, 0.0); +} + +void +LayoutViewBase::zoom_out () +{ + shift_window (1.0 / zoom_factor, 0.0, 0.0); +} + +void +LayoutViewBase::shift_window (double f, double dx, double dy) +{ + db::DBox b = mp_canvas->viewport ().box (); + + db::DPoint s = mp_canvas->viewport ().global_trans ().inverted () * db::DPoint (dx, dy); + db::DPoint c = b.center () + db::DVector (b.width () * s.x (), b.height () * s.y ()); + + double w = b.width () * f; + double h = b.height () * f; + + db::DVector d (w * 0.5, h * 0.5); + + zoom_box (db::DBox (c - d, c + d)); +} + +void +LayoutViewBase::goto_window (const db::DPoint &p, double s) +{ + if (s > 1e-6) { + db::DBox b (p.x () - s * 0.5, p.y () - s * 0.5, p.x () + s * 0.5, p.y () + s * 0.5); + zoom_box (b); + } else { + db::DBox b (box ()); + b.move (p - b.center ()); + zoom_box (b); + } +} + +void +LayoutViewBase::redraw_layer (unsigned int index) +{ + do_redraw (index); +} + +void +LayoutViewBase::redraw_cell_boxes () +{ + do_redraw (lay::draw_boxes_queue_entry); +} + +void +LayoutViewBase::redraw_deco_layer () +{ + // redraw background annotations (images etc.) + mp_canvas->touch_bg (); + + // redraw other annotations: + do_redraw (lay::draw_custom_queue_entry); +} + +void +LayoutViewBase::redraw () +{ + std::vector layers; + + size_t nlayers = 0; + for (lay::LayerPropertiesConstIterator l = begin_layers (); !l.at_end (); ++l) { + if (! l->has_children ()) { + ++nlayers; + } + } + layers.reserve (nlayers); + + for (lay::LayerPropertiesConstIterator l = begin_layers (); !l.at_end (); ++l) { + if (! l->has_children ()) { + layers.push_back (RedrawLayerInfo (*l)); + } + } + + mp_canvas->redraw_new (layers); +} + +void +LayoutViewBase::cancel_edits () +{ + // cancel all drag and pending edit operations such as move operations. + mp_canvas->drag_cancel (); + lay::Editables::cancel_edits (); +} + +void +LayoutViewBase::cancel () +{ + // cancel all drags and pending edit operations such as move operations. + cancel_edits (); + // re-enable edit mode + enable_edits (true); + // and clear the selection + clear_selection (); +} + +void +LayoutViewBase::cancel_esc () +{ + cancel (); + switch_mode (default_mode ()); +} + +void +LayoutViewBase::goto_view (const DisplayState &state) +{ + mp_canvas->zoom_box (state.box ()); + + std::list cellviews; + for (unsigned int i = 0; i < m_cellviews.size (); ++i) { + cellviews.push_back (state.cellview (i, cellview_iter (i)->operator-> ())); + } + + select_cellviews (cellviews); + + if (state.min_hier () <= state.max_hier ()) { + set_hier_levels_basic (std::make_pair (state.min_hier (), state.max_hier ())); + } + + update_content (); +} + +void +LayoutViewBase::save_view (DisplayState &state) const +{ + state = DisplayState (box (), get_min_hier_levels (), get_max_hier_levels (), m_cellviews); +} + +void +LayoutViewBase::do_redraw (int layer) +{ + std::vector layers; + layers.push_back (layer); + + mp_canvas->redraw_selected (layers); +} + +void +LayoutViewBase::do_prop_changed () +{ + if (m_visibility_changed) { + + // change visibility and redraw exposed layers + std::vector visibility; + for (lay::LayerPropertiesConstIterator l = begin_layers (); !l.at_end (); ++l) { + if (! l->has_children ()) { + visibility.push_back (l->visible (true /*real*/)); + } + } + mp_canvas->change_visibility (visibility); + + m_visibility_changed = false; + + } + + update_content (); +} + +void +LayoutViewBase::layer_tab_changed () +{ + update_content (); +} + +void +LayoutViewBase::layer_order_changed () +{ + update_content (); +} + +void +LayoutViewBase::set_view_ops () +{ + bool bright_background = (mp_canvas->background_color ().green () > 128); + int brightness_for_context = ((bright_background ? m_ctx_dimming : -m_ctx_dimming) * 256) / 100; + int brightness_for_child_context = ((bright_background ? m_child_ctx_dimming : -m_child_ctx_dimming) * 256) / 100; + + // count the layers to be able to reserve the number of view_ops + size_t nlayers = 0; + for (LayerPropertiesConstIterator lp = get_properties ().begin_const_recursive (); !lp.at_end (); ++lp) { + if (! lp->has_children ()) { + ++nlayers; + } + } + + std::vector view_ops; + view_ops.reserve (nlayers * planes_per_layer + special_planes_before + special_planes_after); + + lay::Color box_color; + if (! m_box_color.is_valid ()) { + box_color = mp_canvas->foreground_color (); + } else { + box_color = m_box_color; + } + + // cell boxes + if (m_cell_box_visible) { + + lay::ViewOp vop; + + // context level + if (m_ctx_color.is_valid ()) { + vop = lay::ViewOp (m_ctx_color.rgb (), lay::ViewOp::Copy, 0, 0, 0); + } else { + vop = lay::ViewOp (lay::LayerProperties::brighter (box_color.rgb (), brightness_for_context), lay::ViewOp::Copy, 0, 0, 0); + } + + // fill, frame, text, vertex + view_ops.push_back (lay::ViewOp (0, lay::ViewOp::Or, 0, 0, 0)); + view_ops.push_back (vop); + view_ops.push_back (vop); + view_ops.push_back (lay::ViewOp (0, lay::ViewOp::Or, 0, 0, 0)); + + // child level + if (m_child_ctx_color.is_valid ()) { + vop = lay::ViewOp (m_child_ctx_color.rgb (), lay::ViewOp::Copy, 0, 0, 0); + } else { + vop = lay::ViewOp (lay::LayerProperties::brighter (box_color.rgb (), brightness_for_context), lay::ViewOp::Copy, 0, 0, 0); + } + + // fill, frame, text, vertex + view_ops.push_back (lay::ViewOp (0, lay::ViewOp::Or, 0, 0, 0)); + view_ops.push_back (vop); + view_ops.push_back (vop); + view_ops.push_back (lay::ViewOp (0, lay::ViewOp::Or, 0, 0, 0)); + + // current level + vop = lay::ViewOp (box_color.rgb (), lay::ViewOp::Copy, 0, 0, 0); + + // fill, frame, text, vertex + view_ops.push_back (lay::ViewOp (0, lay::ViewOp::Or, 0, 0, 0)); + view_ops.push_back (vop); + view_ops.push_back (vop); + view_ops.push_back (lay::ViewOp (0, lay::ViewOp::Or, 0, 0, 0)); + + } else { + // invisible + for (unsigned int i = 0; i < (unsigned int) planes_per_layer; ++i) { // frame, fill, vertex, text + view_ops.push_back (lay::ViewOp (0, lay::ViewOp::Or, 0, 0, 0)); + } + } + + // sanity check: number of planes defined in layRedrawThreadWorker must match to view_ops layout + tl_assert (view_ops.size () == (size_t)cell_box_planes); + + // produce the ViewOps for the guiding shapes + + color_t gs_color = box_color.rgb (); + if (m_guiding_shape_color.is_valid ()) { + gs_color = m_guiding_shape_color.rgb (); + } + + for (int ctx = 0; ctx < 3; ++ctx) { // 0 (context), 1 (child), 2 (current) + + lay::ViewOp::Mode mode = lay::ViewOp::Copy; + + color_t fill_color, frame_color, text_color; + int dp = 1; // no stipples for guiding shapes + + if (ctx == 0) { + + // context planes + if (m_ctx_color.is_valid ()) { + frame_color = text_color = fill_color = m_ctx_color.rgb (); + } else { + frame_color = text_color = fill_color = lay::LayerProperties::brighter (gs_color, brightness_for_context); + } + + if (m_ctx_hollow) { + dp = 1; + } + + } else if (ctx == 1) { + + // child level planes (if used) + if (m_child_ctx_color.is_valid ()) { + frame_color = text_color = fill_color = m_child_ctx_color.rgb (); + } else { + frame_color = text_color = fill_color = lay::LayerProperties::brighter (gs_color, brightness_for_child_context); + } + + if (m_child_ctx_hollow) { + dp = 1; + } + + } else { + + // current level planes + frame_color = text_color = fill_color = gs_color; + + } + + if (m_guiding_shape_visible) { + + // fill + view_ops.push_back (lay::ViewOp (fill_color, mode, 0, dp, 0)); // fill + + // frame + view_ops.push_back (lay::ViewOp (frame_color, mode, 0, 0, 0, lay::ViewOp::Rect, m_guiding_shape_line_width)); + + // text + if (m_text_visible) { + view_ops.push_back (lay::ViewOp (text_color, mode, 0, 0, 0)); + } else { + view_ops.push_back (lay::ViewOp (0, lay::ViewOp::Or, 0, 0, 0)); + } + + // vertex + view_ops.push_back (lay::ViewOp (frame_color, mode, 0, 0, 0, lay::ViewOp::Rect, m_guiding_shape_vertex_size /*mark size*/)); // vertex + + } else { + view_ops.push_back (lay::ViewOp ()); + view_ops.push_back (lay::ViewOp ()); + view_ops.push_back (lay::ViewOp ()); + view_ops.push_back (lay::ViewOp ()); + } + + } + + // sanity check: number of planes defined in layRedrawThreadWorker must match to view_ops layout + tl_assert (view_ops.size () == (size_t)special_planes_before); + + bool animated = false; + + for (int ctx = 0; ctx < 3; ++ctx) { // 0 (context), 1 (child), 2 (current) + + unsigned int ilayer = 0; + for (LayerPropertiesConstIterator lp = get_properties ().begin_const_recursive (); !lp.at_end (); ++lp, ++ilayer) { + + // because accessing the LayerPropertiesNode with lp->... is not quite efficient, we get the pointer here: + const lay::LayerPropertiesNode *l = &*lp; + + if (l->has_children ()) { + continue; + } + + bool animate_visible = true; + unsigned int di_off = m_stipple_offset ? ilayer : 0; + + if (l->animation (true /*real*/)) { + + animated = true; + if (! m_animated) { + m_animated = true; + m_phase = 0; + } + + if (l->animation (true /*real*/) == 1) { + // scrolling + di_off += m_phase; + } else if (l->animation (true /*real*/) == 2) { + // blinking + animate_visible = ((m_phase & 1) == 0); + } else { + // inversely blinking + animate_visible = ((m_phase & 1) != 0); + } + + } + + if (l->visible (true /*real*/) && animate_visible) { + + lay::ViewOp::Mode mode = lay::ViewOp::Copy; + if (l->transparent (true /*real*/)) { + if (bright_background) { + mode = lay::ViewOp::And; + } else { + mode = lay::ViewOp::Or; + } + } + + color_t fill_color, frame_color, text_color; + int dp = m_no_stipples ? 1 : l->dither_pattern (true /*real*/); + int ls = l->line_style (true /*real*/); + + if (ctx == 0) { + + // context planes + if (m_ctx_color.is_valid ()) { + frame_color = text_color = fill_color = m_ctx_color.rgb (); + } else { + fill_color = l->eff_fill_color_brighter (true /*real*/, brightness_for_context); + frame_color = l->eff_frame_color_brighter (true /*real*/, brightness_for_context); + if (m_text_color.is_valid ()) { + text_color = lay::LayerProperties::brighter (m_text_color.rgb (), brightness_for_context); + } else { + text_color = frame_color; + } + } + + if (m_ctx_hollow) { + dp = 1; + } + + } else if (ctx == 1) { + + // child level planes (if used) + if (m_child_ctx_color.is_valid ()) { + frame_color = text_color = fill_color = m_child_ctx_color.rgb (); + } else { + fill_color = l->eff_fill_color_brighter (true /*real*/, brightness_for_child_context); + frame_color = l->eff_frame_color_brighter (true /*real*/, brightness_for_child_context); + if (m_text_color.is_valid ()) { + text_color = lay::LayerProperties::brighter (m_text_color.rgb (), brightness_for_child_context); + } else { + text_color = frame_color; + } + } + + if (m_child_ctx_hollow) { + dp = 1; + } + + } else { + + // current level planes + fill_color = l->eff_fill_color (true /*real*/); + frame_color = l->eff_frame_color (true /*real*/); + if (m_text_color.is_valid ()) { + text_color = m_text_color.rgb (); + } else { + text_color = frame_color; + } + + } + + // fill + view_ops.push_back (lay::ViewOp (fill_color, mode, 0, dp, di_off)); // fill + + // frame + int lw = l->width (true /*real*/); + if (lw < 0) { + // default line width is 0 for parents and 1 for leafs + lw = l->has_children () ? 0 : 1; + } + view_ops.push_back (lay::ViewOp (frame_color, mode, ls, 0, 0, lay::ViewOp::Rect, lw)); + + // text + if (m_text_visible) { + view_ops.push_back (lay::ViewOp (text_color, mode, 0, 0, 0)); + } else { + view_ops.push_back (lay::ViewOp (0, lay::ViewOp::Or, 0, 0, 0)); + } + // vertex + view_ops.push_back (lay::ViewOp (frame_color, mode, 0, 0, 0, lay::ViewOp::Cross, l->marked (true /*real*/) ? 9/*mark size*/ : 0)); // vertex + + } else { + for (unsigned int i = 0; i < (unsigned int) planes_per_layer / 3; ++i) { + view_ops.push_back (lay::ViewOp (0, lay::ViewOp::Or, 0, 0, 0)); + } + } + + } + + } + + if (! animated) { + m_animated = false; + m_phase = 0; + } + + mp_canvas->set_view_ops (view_ops); +} + +void +LayoutViewBase::guiding_shapes_visible (bool v) +{ + if (v != m_guiding_shape_visible) { + m_guiding_shape_visible = v; + update_content (); + } +} + +void +LayoutViewBase::guiding_shapes_color (lay::Color c) +{ + if (c != m_guiding_shape_color) { + m_guiding_shape_color = c; + update_content (); + } +} + +void +LayoutViewBase::guiding_shapes_line_width (int v) +{ + if (v != m_guiding_shape_line_width) { + m_guiding_shape_line_width = v; + update_content (); + } +} + +void +LayoutViewBase::guiding_shapes_vertex_size (int v) +{ + if (v != m_guiding_shape_vertex_size) { + m_guiding_shape_vertex_size = v; + update_content (); + } +} + +void +LayoutViewBase::draw_array_border_instances (bool m) +{ + if (m != m_draw_array_border_instances) { + m_draw_array_border_instances = m; + redraw (); + } +} + +void +LayoutViewBase::drop_small_cells (bool m) +{ + if (m != m_drop_small_cells) { + m_drop_small_cells = m; + redraw (); + } +} + +void +LayoutViewBase::drop_small_cells_value (unsigned int s) +{ + if (s != m_drop_small_cells_value) { + m_drop_small_cells_value = s; + redraw (); + } +} + +void +LayoutViewBase::drop_small_cells_cond (drop_small_cells_cond_type t) +{ + if (t != m_drop_small_cells_cond) { + m_drop_small_cells_cond = t; + redraw (); + } +} + +void +LayoutViewBase::cell_box_color (lay::Color c) +{ + if (c != m_box_color) { + m_box_color = c; + update_content (); + } +} + +void +LayoutViewBase::cell_box_text_transform (bool xform) +{ + if (xform != m_box_text_transform) { + m_box_text_transform = xform; + redraw (); + } +} + +void +LayoutViewBase::cell_box_text_font (unsigned int f) +{ + if (f != m_box_font) { + m_box_font = f; + redraw (); + } +} + +bool +LayoutViewBase::set_hier_levels_basic (std::pair l) +{ + if (l != get_hier_levels ()) { + + if (mp_min_hier_spbx) { + mp_min_hier_spbx->blockSignals (true); + mp_min_hier_spbx->setValue (l.first); + mp_min_hier_spbx->setMaximum (l.second); + mp_min_hier_spbx->blockSignals (false); + } + + if (mp_max_hier_spbx) { + mp_max_hier_spbx->blockSignals (true); + mp_max_hier_spbx->setValue (l.second); + mp_max_hier_spbx->setMinimum (l.first); + mp_max_hier_spbx->blockSignals (false); + } + + m_from_level = l.first; + m_to_level = l.second; + + // notify all connected observers + hier_levels_changed_event (); + + redraw (); + + return true; + + } else { + return false; + } +} + +void +LayoutViewBase::set_hier_levels (std::pair l) +{ + if (set_hier_levels_basic (l)) { + store_state (); + } +} + +std::pair +LayoutViewBase::get_hier_levels () const +{ + return std::make_pair (m_from_level, m_to_level); +} + +void +LayoutViewBase::min_hier_changed (int i) +{ + mp_max_hier_spbx->setMinimum (i); + set_hier_levels (std::make_pair (i, m_to_level)); +} + +void +LayoutViewBase::max_hier_changed (int i) +{ + mp_min_hier_spbx->setMaximum (i); + set_hier_levels (std::make_pair (m_from_level, i)); +} + +/** + * @brief set the maximum hierarchy level to the number of levels available + */ +void +LayoutViewBase::max_hier () +{ + // determine the maximum level of hierarchies + int max_level = max_hier_level (); + + // and set the levels + if (max_level > 0) { + set_hier_levels (std::make_pair (std::min (m_from_level, max_level), max_level)); + } +} + +/** + * @brief determine the maximum hierarchy level + */ +int +LayoutViewBase::max_hier_level () const +{ + int max_level = 0; + for (std::list ::const_iterator cv = m_cellviews.begin (); cv != m_cellviews.end (); ++cv) { + if (cv->is_valid ()) { + int nl = cv->ctx_cell ()->hierarchy_levels () + 1; + if (nl > max_level) { + max_level = nl; + } + } + } + return max_level; +} + +/** + * @brief Returns a value indicating whether the maximum level is shown + */ +bool +LayoutViewBase::has_max_hier () const +{ + int ml = max_hier_level (); + return ml > 0 && m_to_level >= ml; +} + +void +LayoutViewBase::set_palette (const lay::ColorPalette &p) +{ + m_palette = p; +} + +void +LayoutViewBase::set_palette (const lay::StipplePalette &p) +{ + m_stipple_palette = p; +} + +void +LayoutViewBase::set_palette (const lay::LineStylePalette &p) +{ + m_line_style_palette = p; +} + +void +LayoutViewBase::ctx_color (lay::Color c) +{ + if (c != m_ctx_color) { + m_ctx_color = c; + update_content (); + } +} + +void +LayoutViewBase::ctx_dimming (int d) +{ + if (d != m_ctx_dimming) { + m_ctx_dimming = d; + update_content (); + } +} + +void +LayoutViewBase::ctx_hollow (bool h) +{ + if (h != m_ctx_hollow) { + m_ctx_hollow = h; + update_content (); + } +} + +void +LayoutViewBase::child_ctx_color (lay::Color c) +{ + if (c != m_child_ctx_color) { + m_child_ctx_color = c; + update_content (); + } +} + +void +LayoutViewBase::child_ctx_dimming (int d) +{ + if (d != m_child_ctx_dimming) { + m_child_ctx_dimming = d; + update_content (); + } +} + +void +LayoutViewBase::child_ctx_hollow (bool h) +{ + if (h != m_child_ctx_hollow) { + m_child_ctx_hollow = h; + update_content (); + } +} + +void +LayoutViewBase::child_ctx_enabled (bool f) +{ + if (f != m_child_ctx_enabled) { + m_child_ctx_enabled = f; + update_content (); + redraw (); + } +} + +void +LayoutViewBase::abstract_mode_width (double w) +{ + if (fabs (w - m_abstract_mode_width) > 1e-6) { + m_abstract_mode_width = w; + if (m_abstract_mode_enabled) { + redraw (); + } + } +} + +void +LayoutViewBase::abstract_mode_enabled (bool e) +{ + if (e != m_abstract_mode_enabled) { + m_abstract_mode_enabled = e; + redraw (); + } +} + +void +LayoutViewBase::background_color (lay::Color c) +{ + if (c == mp_canvas->background_color ()) { + return; + } + + // replace by "real" background color if required + if (! c.is_valid ()) { + c = lay::Color (palette ().color (QPalette::Normal, QPalette::Base).rgb ()); + } + + lay::Color contrast; + if (c.green () > 128) { + contrast = lay::Color (0, 0, 0); + } else { + contrast = lay::Color (255, 255, 255); + } + + if (mp_control_panel) { + mp_control_panel->set_background_color (c); + mp_control_panel->set_text_color (contrast); + } + + if (mp_hierarchy_panel) { + mp_hierarchy_panel->set_background_color (c); + mp_hierarchy_panel->set_text_color (contrast); + } + + if (mp_libraries_view) { + mp_libraries_view->set_background_color (c); + mp_libraries_view->set_text_color (contrast); + } + + if (mp_bookmarks_view) { + mp_bookmarks_view->set_background_color (c); + mp_bookmarks_view->set_text_color (contrast); + } + + if (mp_selection_service) { + mp_selection_service->set_colors (c, contrast); + } + if (mp_zoom_service) { + mp_zoom_service->set_colors (c, contrast); + } + + // Set the color for all ViewService interfaces + for (std::vector::iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) { + lay::ViewService *svc = (*p)->view_service_interface (); + if (svc) { + svc->set_colors (c, contrast); + } + } + + mp_canvas->set_colors (c, contrast, mp_canvas->active_color ()); + + update_content (); + + background_color_changed_event (); +} + +void +LayoutViewBase::dbu_coordinates (bool f) +{ + m_dbu_coordinates = f; +} + +void +LayoutViewBase::absolute_coordinates (bool f) +{ + m_absolute_coordinates = f; +} + +void +LayoutViewBase::select_cellviews_fit (const std::list &cvs) +{ + if (m_cellviews != cvs) { + + for (int index = 0; index < int (m_cellviews.size ()); ++index) { + cellview_about_to_change_event (index); + } + + cellviews_about_to_change_event (); + + set_min_hier_levels (0); + cancel_esc (); + m_cellviews = cvs; + zoom_fit (); + finish_cellviews_changed (); + + for (int index = 0; index < int (m_cellviews.size ()); ++index) { + cellview_changed (index); + } + + update_content (); + + } else { + zoom_fit (); + } +} + +void +LayoutViewBase::active_cellview_changed (int index) +{ + if (m_active_cellview_changed_event_enabled) { + + // we need to cancel pending drawing or dragging operations to reflect the new cellview (different target, may have different technology etc.) + cancel_esc (); + + // we need to setup the editor option pages because the technology may have changed + dm_setup_editor_option_pages (); + + active_cellview_changed_event (); + active_cellview_changed_with_index_event (index); + + // Because the title reflects the active one, emit a title changed event + if (m_title.empty ()) { + emit title_changed (); + } + + } +} + +void +LayoutViewBase::active_library_changed (int /*index*/) +{ + std::string lib_name; + if (mp_libraries_view->active_lib ()) { + lib_name = mp_libraries_view->active_lib ()->get_name (); + } + + // commit the new active library to the other views and persist this state + // TODO: could be passed through the LibraryController (like through some LibraryController::active_library) + dispatcher ()->config_set (cfg_current_lib_view, lib_name); +} + +void +LayoutViewBase::cellview_changed (unsigned int index) +{ + if (mp_hierarchy_panel) { + mp_hierarchy_panel->do_update_content (index); + } + + cellview_changed_event (index); + + if (m_title.empty ()) { + emit title_changed (); + } +} + +void +LayoutViewBase::select_cell_dispatch (const cell_path_type &path, int cellview_index) +{ + bool set_max_hier = (m_full_hier_new_cell || has_max_hier ()); + if (m_clear_ruler_new_cell) { + + // This is a HACK, but the clean solution would be to provide a new editable + // method like "clear_annotations": + lay::Plugin *antPlugin = get_plugin_by_name ("ant::Plugin"); + if (antPlugin) { + antPlugin->menu_activated ("ant::clear_all_rulers_internal"); + } + + } + + if (m_fit_new_cell) { + select_cell_fit (path, cellview_index); + } else { + select_cell (path, cellview_index); + } + set_current_cell_path (cellview_index, path); + if (set_max_hier) { + max_hier (); + } +} + +void +LayoutViewBase::select_cell_fit (const cell_path_type &path, int index) +{ + if (index >= 0 && int (m_cellviews.size ()) > index && (cellview_iter (index)->specific_path ().size () > 0 || cellview_iter (index)->unspecific_path () != path)) { + + cellview_about_to_change_event (index); + + set_min_hier_levels (0); + cancel (); + cellview_iter (index)->set_specific_path (lay::CellView::specific_cell_path_type ()); + cellview_iter (index)->set_unspecific_path (path); + set_active_cellview_index (index); + redraw (); + zoom_fit (); + + cellview_changed (index); + + update_content (); + + } +} + +void +LayoutViewBase::select_cell_fit (cell_index_type cell_index, int index) +{ + if (index >= 0 && int (m_cellviews.size ()) > index && cellview_iter (index)->cell_index () != cell_index) { + + cellview_about_to_change_event (index); + + set_min_hier_levels (0); + cancel (); + cellview_iter (index)->set_cell (cell_index); + set_active_cellview_index (index); + redraw (); + zoom_fit (); + + cellview_changed (index); + + update_content (); + + } +} + +void +LayoutViewBase::select_cellviews (const std::list &cvs) +{ + if (m_cellviews != cvs) { + + for (int index = 0; index < int (m_cellviews.size ()); ++index) { + cellview_about_to_change_event (index); + } + cellviews_about_to_change_event (); + + set_min_hier_levels (0); + cancel_esc (); + m_cellviews = cvs; + redraw (); + + cellviews_changed_event (); + for (int index = 0; index < int (m_cellviews.size ()); ++index) { + cellview_changed (index); + } + + update_content (); + + } +} + +void +LayoutViewBase::select_cellview (int index, const CellView &cv) +{ + if (index < 0 || index >= int (m_cellviews.size ())) { + return; + } + + if (*cellview_iter (index) != cv) { + + cellview_about_to_change_event (index); + + cancel_esc (); + *cellview_iter (index) = cv; + redraw (); + + cellview_changed (index); + + update_content (); + + } +} + +void +LayoutViewBase::select_cell (const cell_path_type &path, int index) +{ + if (index >= 0 && int (m_cellviews.size ()) > index && (cellview_iter (index)->specific_path ().size () > 0 || cellview_iter (index)->unspecific_path () != path)) { + + cellview_about_to_change_event (index); + + set_min_hier_levels (0); + cancel (); + cellview_iter (index)->set_specific_path (lay::CellView::specific_cell_path_type ()); + cellview_iter (index)->set_unspecific_path (path); + set_active_cellview_index (index); + redraw (); + + cellview_changed (index); + + update_content (); + + } +} + +void +LayoutViewBase::select_cell (cell_index_type cell_index, int index) +{ + if (index >= 0 && int (m_cellviews.size ()) > index && (! cellview_iter (index)->is_valid () || cellview_iter (index)->cell_index () != cell_index)) { + + cellview_about_to_change_event (index); + + set_min_hier_levels (0); + cancel (); + cellview_iter (index)->set_cell (cell_index); + set_active_cellview_index (index); + redraw (); + + cellview_changed (index); + + update_content (); + + } +} + +bool +LayoutViewBase::is_cell_hidden (cell_index_type ci, int cellview_index) const +{ + if (int (m_hidden_cells.size ()) > cellview_index && cellview_index >= 0) { + return m_hidden_cells [cellview_index].find (ci) != m_hidden_cells [cellview_index].end (); + } else { + return false; + } +} + +const std::set & +LayoutViewBase::hidden_cells (int cellview_index) const +{ + if (int (m_hidden_cells.size ()) > cellview_index && cellview_index >= 0) { + return m_hidden_cells[cellview_index]; + } else { + static std::set empty_set; + return empty_set; + } +} + +void +LayoutViewBase::hide_cell (cell_index_type ci, int cellview_index) +{ + if (cellview_index < 0) { + return; + } + while (int (m_hidden_cells.size ()) <= cellview_index) { + m_hidden_cells.push_back (std::set ()); + } + if (m_hidden_cells [cellview_index].insert (ci).second) { + if (transacting ()) { + manager ()->queue (this, new OpHideShowCell (ci, cellview_index, false /*=hide*/)); + } else if (manager () && ! replaying ()) { + manager ()->clear (); + } + cell_visibility_changed_event (); + redraw (); // needs redraw + } +} + +void +LayoutViewBase::show_cell (cell_index_type ci, int cellview_index) +{ + if (cellview_index < 0) { + return; + } + if (int (m_hidden_cells.size ()) > cellview_index) { + if (m_hidden_cells [cellview_index].erase (ci) > 0) { + if (transacting ()) { + manager ()->queue (this, new OpHideShowCell (ci, cellview_index, true /*=show*/)); + } else if (manager () && ! replaying ()) { + manager ()->clear (); + } + cell_visibility_changed_event (); + redraw (); // needs redraw + } + } +} + +void +LayoutViewBase::show_all_cells (int cv_index) +{ + if (cv_index < 0 || cv_index >= int (m_hidden_cells.size ())) { + return; + } + + if (! m_hidden_cells [cv_index].empty ()) { + if (transacting ()) { + for (std::set::const_iterator ci = m_hidden_cells [cv_index].begin (); ci != m_hidden_cells [cv_index].end (); ++ci) { + manager ()->queue (this, new OpHideShowCell (*ci, cv_index, true /*=show*/)); + } + } else if (manager () && ! replaying ()) { + manager ()->clear (); + } + m_hidden_cells [cv_index].clear (); + cell_visibility_changed_event (); + redraw (); // needs redraw + } +} + +void +LayoutViewBase::show_all_cells () +{ + bool any = false; + + for (unsigned int i = 0; i < m_hidden_cells.size (); ++i) { + if (! m_hidden_cells [i].empty ()) { + if (transacting ()) { + for (std::set::const_iterator ci = m_hidden_cells [i].begin (); ci != m_hidden_cells [i].end (); ++ci) { + manager ()->queue (this, new OpHideShowCell (*ci, i, true /*=show*/)); + } + } else if (manager () && ! replaying ()) { + manager ()->clear (); + } + m_hidden_cells [i].clear (); + any = true; + } + } + + if (any) { + cell_visibility_changed_event (); + redraw (); // needs redraw + return; + } +} + +void +LayoutViewBase::min_inst_label_size (int px) +{ + if (m_min_size_for_label != px) { + m_min_size_for_label = px; + redraw (); + } +} + +void +LayoutViewBase::text_visible (bool vis) +{ + if (m_text_visible != vis) { + m_text_visible = vis; + update_content (); + redraw (); // required because we do some optimizations is text is not visible .. + } +} + +void +LayoutViewBase::show_properties_as_text (bool sp) +{ + if (m_show_properties != sp) { + m_show_properties = sp; + redraw (); // required because we do some optimizations is text is not visible .. + } +} + +void +LayoutViewBase::bitmap_caching (bool l) +{ + if (m_bitmap_caching != l) { + m_bitmap_caching = l; + redraw (); // required because we do some optimizations is text is not visible .. + } +} + +void +LayoutViewBase::text_lazy_rendering (bool l) +{ + if (m_text_lazy_rendering != l) { + m_text_lazy_rendering = l; + redraw (); // required because we do some optimizations is text is not visible .. + } +} + +void +LayoutViewBase::cell_box_visible (bool vis) +{ + if (m_cell_box_visible != vis) { + m_cell_box_visible = vis; + update_content (); + } +} + +void +LayoutViewBase::text_font (unsigned int f) +{ + if (m_text_font != f) { + m_text_font = f; + redraw (); + } +} + +void +LayoutViewBase::default_text_size (double fs) +{ + if (m_default_text_size != fs) { + m_default_text_size = fs; + redraw (); + } +} + +void +LayoutViewBase::clear_ruler_new_cell (bool f) +{ + m_clear_ruler_new_cell = f; +} + +void +LayoutViewBase::full_hier_new_cell (bool f) +{ + m_full_hier_new_cell = f; +} + +double +LayoutViewBase::pan_distance () const +{ + return m_pan_distance; +} + +void +LayoutViewBase::pan_distance (double pd) +{ + m_pan_distance = pd; +} + +void +LayoutViewBase::fit_new_cell (bool f) +{ + m_fit_new_cell = f; +} + +void +LayoutViewBase::apply_text_trans (bool f) +{ + if (m_apply_text_trans != f) { + m_apply_text_trans = f; + redraw (); + } +} + +void +LayoutViewBase::offset_stipples (bool f) +{ + if (m_stipple_offset != f) { + m_stipple_offset = f; + update_content (); + } +} + +void +LayoutViewBase::no_stipples (bool f) +{ + if (m_no_stipples != f) { + m_no_stipples = f; + if (mp_control_panel) { + mp_control_panel->set_no_stipples (m_no_stipples); + } + update_content (); + } +} + +void +LayoutViewBase::show_markers (bool f) +{ + if (m_show_markers != f) { + m_show_markers = f; + mp_canvas->update_image (); + } +} + +void +LayoutViewBase::text_color (lay::Color c) +{ + if (m_text_color != c) { + m_text_color = c; + update_content (); + } +} + +bool +LayoutViewBase::has_selection () +{ + if (mp_control_panel && mp_control_panel->has_focus ()) { + return mp_control_panel->has_selection (); + } else if (mp_hierarchy_panel && mp_hierarchy_panel->has_focus ()) { + return mp_hierarchy_panel->has_selection (); + } else { + return lay::Editables::has_selection (); + } +} + +void +LayoutViewBase::paste () +{ + clear_selection (); + + { + db::Transaction trans (manager (), tl::to_string (tr ("Paste"))); + + // let the receivers sort out who is pasting what .. + if (mp_hierarchy_panel) { + mp_hierarchy_panel->paste (); + } + if (mp_control_panel) { + mp_control_panel->paste (); + } + lay::Editables::paste (); + } + + // if we change the state, save it before + store_state (); + + db::DBox sel_bbox = selection_bbox (); + if (! sel_bbox.empty ()) { + if (m_paste_display_mode == 1) { + // just make selection visible, i.e. shift window somewhat + pan_center (sel_bbox.center ()); + } else if (m_paste_display_mode == 2) { + // or: make selection fit into the screen + zoom_fit_sel (); + } + } +} + +void +LayoutViewBase::paste_interactive () +{ + clear_selection (); + + std::unique_ptr trans (new db::Transaction (manager (), tl::to_string (QObject::tr ("Paste and move")))); + + { + // let the receivers sort out who is pasting what .. + if (mp_hierarchy_panel) { + mp_hierarchy_panel->paste (); + } + if (mp_control_panel) { + mp_control_panel->paste (); + } + lay::Editables::paste (); + } + + // temporarily close the transaction and pass to the move service for appending it's own + // operations. + trans->close (); + + if (mp_move_service->begin_move (trans.release (), false)) { + switch_mode (-1); // move mode + } +} + +void +LayoutViewBase::copy () +{ + if (mp_hierarchy_panel && mp_hierarchy_panel->has_focus ()) { + mp_hierarchy_panel->copy (); + } else if (mp_control_panel && mp_control_panel->has_focus ()) { + mp_control_panel->copy (); + } else { + + if (! lay::Editables::has_selection ()) { + // try to use the transient selection for the real one + lay::Editables::transient_to_selection (); + } + + lay::Editables::copy (); + + } +} + +void +LayoutViewBase::cut () +{ + if (mp_hierarchy_panel && mp_hierarchy_panel->has_focus ()) { + // TODO: currently the hierarchy panel's cut function does it's own transaction handling. + // Otherwise the cut function is not working propertly. + mp_hierarchy_panel->cut (); + } else if (mp_control_panel && mp_control_panel->has_focus ()) { + db::Transaction trans (manager (), tl::to_string (QObject::tr ("Cut Layers"))); + mp_control_panel->cut (); + } else { + + if (! lay::Editables::has_selection ()) { + // try to use the transient selection for the real one + lay::Editables::transient_to_selection (); + } + + db::Transaction trans (manager (), tl::to_string (QObject::tr ("Cut"))); + lay::Editables::cut (); + + } +} + +void +LayoutViewBase::add_missing_layers () +{ + std::set present; + LayerPropertiesConstIterator l = begin_layers (); + while (! l.at_end ()) { + if (! l->has_children ()) { + present.insert (l->source (true /*real*/)); + } + ++l; + } + + std::vector actual; + for (unsigned int cv = 0; cv < cellviews (); ++cv) { + const db::Layout &layout = cellview (cv)->layout (); + for (unsigned int l = 0; l < layout.layers (); ++l) { + if (layout.is_valid_layer (l)) { + actual.push_back (lay::ParsedLayerSource (layout.get_properties (l), cv)); + } + } + } + + std::sort (actual.begin (), actual.end ()); + + for (std::vector ::const_iterator a = actual.begin (); a != actual.end (); ++a) { + if (present.find (*a) == present.end ()) { + lay::LayerPropertiesNode node; + node.attach_view (this, current_layer_list ()); + node.set_source (*a); + init_layer_properties (node); + insert_layer (end_layers (), node); + } + } + + emit layer_order_changed (); +} + +LayerState +LayoutViewBase::layer_snapshot () const +{ + LayerState state; + LayerPropertiesConstIterator l = begin_layers (); + while (! l.at_end ()) { + if (! l->has_children ()) { + state.present.insert (l->source (true /*real*/)); + } + ++l; + } + return state; +} + +void +LayoutViewBase::current_layer_changed_slot (const lay::LayerPropertiesConstIterator &iter) +{ + current_layer_changed_event (iter); +} + +void +LayoutViewBase::add_new_layers (const LayerState &state) +{ + std::vector actual; + for (unsigned int cv = 0; cv < cellviews (); ++cv) { + const db::Layout &layout = cellview (cv)->layout (); + for (unsigned int l = 0; l < layout.layers (); ++l) { + if (layout.is_valid_layer (l)) { + actual.push_back (lay::ParsedLayerSource (layout.get_properties (l), cv)); + } + } + } + + std::sort (actual.begin (), actual.end ()); + + bool needs_update = false; + + for (std::vector ::const_iterator a = actual.begin (); a != actual.end (); ++a) { + if (state.present.find (*a) == state.present.end ()) { + needs_update = true; + lay::LayerPropertiesNode node; + node.attach_view (this, current_layer_list ()); + node.set_source (*a); + // HINT: in editable mode it is desireable to present all layers because otherwise they cannot be + // made visible to populate them. + if (is_editable () || ! node.bbox ().empty ()) { + init_layer_properties (node); + insert_layer (end_layers (), node); + } + } + } + + if (needs_update) { + emit layer_order_changed (); + } +} + +void +LayoutViewBase::remove_unused_layers () +{ + if (mp_control_panel) { + mp_control_panel->cm_remove_unused (); + } +} + +void +LayoutViewBase::prev_display_state () +{ + if (m_display_state_ptr > 0) { + m_display_state_ptr--; + goto_view (m_display_states [m_display_state_ptr]); + } +} + +bool +LayoutViewBase::has_prev_display_state () +{ + return m_display_state_ptr > 0; +} + +void +LayoutViewBase::next_display_state () +{ + if (m_display_state_ptr + 1 < m_display_states.size ()) { + m_display_state_ptr++; + goto_view (m_display_states [m_display_state_ptr]); + } +} + +bool +LayoutViewBase::has_next_display_state () +{ + return m_display_state_ptr + 1 < m_display_states.size (); +} + +void +LayoutViewBase::current_pos (double x, double y) +{ + if (m_activated) { + if (dbu_coordinates ()) { + double dx = 0.0, dy = 0.0; + if (active_cellview_index () >= 0) { + double dbu = cellview (active_cellview_index ())->layout ().dbu (); + dx = x / dbu; + dy = y / dbu; + } + emit current_pos_changed (dx, dy, true); + } else { + emit current_pos_changed (x, y, false); + } + } +} + +void +LayoutViewBase::stop_redraw () +{ + mp_canvas->stop_redraw (); +} + +void +LayoutViewBase::stop () +{ + stop_redraw (); + deactivate_all_browsers (); +} + +void +LayoutViewBase::mode (int m) +{ + if (m != m_mode) { + + m_mode = m; + lay::Plugin *active_plugin = 0; + + if (m > 0) { + + for (std::vector::iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) { + if ((*p)->plugin_declaration ()->id () == m) { + active_plugin = *p; + mp_canvas->activate ((*p)->view_service_interface ()); + break; + } + } + + } else if (m == 0 && mp_selection_service) { + mp_canvas->activate (mp_selection_service); + } else if (m == -1 && mp_move_service) { + mp_canvas->activate (mp_move_service); + } + + lay::EditorOptionsPages *eo_pages = editor_options_pages (); + if (eo_pages) { + + // TODO: this is very inefficient as each "activate" will regenerate the tabs + for (std::vector::const_iterator op = eo_pages->pages ().begin (); op != eo_pages->pages ().end (); ++op) { + bool is_active = false; + if ((*op)->plugin_declaration () == 0) { + is_active = true; + } else if (active_plugin && active_plugin->plugin_declaration () == (*op)->plugin_declaration ()) { + is_active = true; + } + (*op)->activate (is_active); + } + + } + + } +} + +bool +LayoutViewBase::is_move_mode () const +{ + return m_mode == -1; +} + +bool +LayoutViewBase::is_selection_mode () const +{ + return m_mode == 0; +} + +unsigned int +LayoutViewBase::intrinsic_mouse_modes (std::vector *descriptions) +{ + if (descriptions) { + descriptions->push_back ("select\t" + tl::to_string (tr ("Select")) + "<:select.png>"); + descriptions->push_back ("move\t" + tl::to_string (tr ("Move")) + "<:move.png>"); + } + return 2; +} + +int +LayoutViewBase::default_mode () +{ + return 0; // TODO: any generic scheme? is select, should be ruler.. +} + +std::vector +LayoutViewBase::menu_symbols () +{ + // TODO: currently these are all symbols from all plugins + return lay::PluginDeclaration::menu_symbols (); +} + +void +LayoutViewBase::menu_activated (const std::string &symbol) +{ + // Try the plugin declarations if the view is the top-level dispatcher + if (dispatcher () == this) { + for (tl::Registrar::iterator cls = tl::Registrar::begin (); cls != tl::Registrar::end (); ++cls) { + if (cls->menu_activated (symbol)) { + return; + } + } + } + + // distribute the menu item call on the plugins - one should take it. + for (std::vector::const_iterator p = plugins ().begin (); p != plugins ().end (); ++p) { + (*p)->menu_activated (symbol); + } +} + +void +LayoutViewBase::rename_cellview (const std::string &name, int cellview_index) +{ + if (cellview_index >= 0 && cellview_index < int (m_cellviews.size ())) { + if ((*cellview_iter (cellview_index))->name () != name) { + (*cellview_iter (cellview_index))->rename (name); + mp_hierarchy_panel->do_update_content (cellview_index); + if (m_title.empty ()) { + emit title_changed (); + } + } + } +} + +std::vector +LayoutViewBase::cv_transform_variants (int cv_index) const +{ + std::set trns_variants; + for (lay::LayerPropertiesConstIterator l = begin_layers (); !l.at_end (); ++l) { + if (! l->has_children ()) { + int cvi = l->cellview_index () >= 0 ? l->cellview_index () : 0; + if (cv_index < int (cellviews ()) && cvi == cv_index) { + trns_variants.insert (l->trans ().begin (), l->trans ().end ()); + } + } + } + return std::vector (trns_variants.begin (), trns_variants.end ()); +} + +std::vector +LayoutViewBase::cv_transform_variants (int cv_index, unsigned int layer) const +{ + if (cellview (cv_index)->layout ().is_valid_layer (layer)) { + std::set trns_variants; + for (lay::LayerPropertiesConstIterator l = begin_layers (); !l.at_end (); ++l) { + if (! l->has_children () && l->layer_index () == int (layer)) { + int cvi = l->cellview_index () >= 0 ? l->cellview_index () : 0; + if (cv_index < int (cellviews ()) && cvi == cv_index) { + trns_variants.insert (l->trans ().begin (), l->trans ().end ()); + } + } + } + return std::vector (trns_variants.begin (), trns_variants.end ()); + } else { + // may happen if the layer is a guiding shape layer for example + return cv_transform_variants (cv_index); + } +} + +std::map > +LayoutViewBase::cv_transform_variants_by_layer (int cv_index) const +{ + std::map > tv_map; + + for (lay::LayerPropertiesConstIterator l = begin_layers (); !l.at_end (); ++l) { + if (! l->has_children () && l->layer_index () >= 0) { + int cvi = l->cellview_index () >= 0 ? l->cellview_index () : 0; + if (cv_index < int (cellviews ()) && cvi == cv_index) { + std::vector &v = tv_map.insert (std::make_pair (l->layer_index (), std::vector ())).first->second; + v.insert (v.end (), l->trans ().begin (), l->trans ().end ()); + } + } + } + + for (std::map >::iterator m = tv_map.begin (); m != tv_map.end (); ++m) { + std::sort (m->second.begin (), m->second.end ()); + m->second.erase (std::unique (m->second.begin (), m->second.end ()), m->second.end ()); + } + + return tv_map; +} + +std::set< std::pair > +LayoutViewBase::cv_transform_variants () const +{ + std::set< std::pair > box_variants; + for (lay::LayerPropertiesConstIterator l = begin_layers (); !l.at_end (); ++l) { + if (! l->has_children ()) { + unsigned int cv_index = l->cellview_index () >= 0 ? (unsigned int) l->cellview_index () : 0; + if (cv_index < cellviews ()) { + for (std::vector::const_iterator t = l->trans ().begin (); t != l->trans ().end (); ++t) { + box_variants.insert (std::make_pair (*t, cv_index)); + } + } + } + } + return box_variants; +} + +db::InstElement +LayoutViewBase::ascend (int index) +{ + tl_assert (int (m_cellviews.size ()) > index && cellview_iter (index)->is_valid ()); + + cellview_about_to_change_event (index); + + lay::CellView::specific_cell_path_type spath (cellview_iter (index)->specific_path ()); + if (spath.empty ()) { + return db::InstElement (); + } else { + + cancel (); + db::InstElement ret = spath.back (); + spath.pop_back (); + cellview_iter (index)->set_specific_path (spath); + + store_state (); + redraw (); + + cellview_changed (index); + + update_content (); + + return ret; + + } +} + +void +LayoutViewBase::descend (const std::vector &path, int index) +{ + if (! path.empty () && index >= 0 && int (m_cellviews.size ()) > index && cellview_iter (index)->is_valid ()) { + + cellview_about_to_change_event (index); + + cancel (); + + lay::CellView::specific_cell_path_type spath (cellview_iter (index)->specific_path ()); + spath.insert (spath.end (), path.begin (), path.end ()); + cellview_iter (index)->set_specific_path (spath); + + store_state (); + redraw (); + + cellview_changed (index); + + update_content (); + + } +} + +bool +LayoutViewBase::is_editable () const +{ + return m_editable; +} + +unsigned int +LayoutViewBase::search_range () +{ + return m_search_range; +} + +void +LayoutViewBase::set_search_range (unsigned int sr) +{ + m_search_range = sr; +} + +unsigned int +LayoutViewBase::search_range_box () +{ + return m_search_range_box; +} + +void +LayoutViewBase::set_search_range_box (unsigned int sr) +{ + m_search_range_box = sr; +} + +void +LayoutViewBase::message (const std::string &s, int timeout) +{ + emit show_message (s, timeout * 1000); +} + +db::cell_index_type +LayoutViewBase::new_cell (int cv_index, const std::string &cell_name) +{ + db::cell_index_type new_ci (0); + + if (cv_index >= 0 && int (m_cellviews.size ()) > cv_index) { + + db::Layout &layout = cellview (cv_index)->layout (); + if (! cell_name.empty () && layout.cell_by_name (cell_name.c_str ()).first) { + throw tl::Exception (tl::to_string (tr ("A cell with that name already exists: %s")), cell_name); + } + + transaction (tl::to_string (tr ("New cell"))); + new_ci = layout.add_cell (cell_name.empty () ? 0 : cell_name.c_str ()); + commit (); + + } + + return new_ci; +} + +void +LayoutViewBase::switch_mode (int m) +{ + if (m_mode != m) { + mode (m); + emit mode_change (m); + } +} + +template +static void make_unique_name (T *object, Iter from, Iter to) +{ + std::string n (object->name ()); + int nn = 0; + + do { + + bool found = n.empty (); + for (Iter i = from; i != to && !found; ++i) { + if ((*i)->name () == n) { + found = true; + } + } + + if (! found) { + break; + } + + n = object->name () + tl::sprintf ("[%d]", ++nn); + + } while (1); + + object->set_name (n); +} + +unsigned int +LayoutViewBase::add_l2ndb (db::LayoutToNetlist *l2ndb) +{ + make_unique_name (l2ndb, m_l2ndbs.begin (), m_l2ndbs.end ()); + m_l2ndbs.push_back (l2ndb); + + // Mark this object as owned by us (for GSI) + l2ndb->keep (); + + l2ndb_list_changed_event (); + + return (unsigned int)(m_l2ndbs.size () - 1); +} + +unsigned int +LayoutViewBase::replace_l2ndb (unsigned int db_index, db::LayoutToNetlist *l2ndb) +{ + tl_assert (l2ndb != 0); + + if (db_index < m_l2ndbs.size ()) { + + // keep the name as it is used for reference in the browser for example + std::string n = m_l2ndbs [db_index]->name (); + l2ndb->set_name (n); + + delete m_l2ndbs [db_index]; + m_l2ndbs [db_index] = l2ndb; + + // Mark this object as owned by us (for GSI) + l2ndb->keep (); + + l2ndb_list_changed_event (); + + return db_index; + + } else { + return add_l2ndb (l2ndb); + } +} + +db::LayoutToNetlist * +LayoutViewBase::get_l2ndb (int index) +{ + if (index >= 0 && index < int (m_l2ndbs.size ())) { + return m_l2ndbs [index]; + } else { + return 0; + } +} + +const db::LayoutToNetlist * +LayoutViewBase::get_l2ndb (int index) const +{ + if (index >= 0 && index < int (m_l2ndbs.size ())) { + return m_l2ndbs [index]; + } else { + return 0; + } +} + +void +LayoutViewBase::remove_l2ndb (unsigned int index) +{ + if (index < (unsigned int) (m_l2ndbs.size ())) { + delete m_l2ndbs [index]; + m_l2ndbs.erase (m_l2ndbs.begin () + index); + l2ndb_list_changed_event (); + } +} + +unsigned int +LayoutViewBase::add_rdb (rdb::Database *rdb) +{ + make_unique_name (rdb, m_rdbs.begin (), m_rdbs.end ()); + m_rdbs.push_back (rdb); + + // Mark this object as owned by us (for GSI) + rdb->keep (); + + rdb_list_changed_event (); + + return (unsigned int)(m_rdbs.size () - 1); +} + +unsigned int +LayoutViewBase::replace_rdb (unsigned int db_index, rdb::Database *rdb) +{ + tl_assert (rdb != 0); + + if (db_index < m_rdbs.size ()) { + + // keep name because it's used for reference in the browser for example + std::string n = m_rdbs [db_index]->name (); + rdb->set_name (n); + + delete m_rdbs [db_index]; + m_rdbs [db_index] = rdb; + + // Mark this object as owned by us (for GSI) + rdb->keep (); + + rdb_list_changed_event (); + + return db_index; + + } else { + return add_rdb (rdb); + } +} + +rdb::Database * +LayoutViewBase::get_rdb (int index) +{ + if (index >= 0 && index < int (m_rdbs.size ())) { + return m_rdbs [index]; + } else { + return 0; + } +} + +const rdb::Database * +LayoutViewBase::get_rdb (int index) const +{ + if (index >= 0 && index < int (m_rdbs.size ())) { + return m_rdbs [index]; + } else { + return 0; + } +} + +void +LayoutViewBase::remove_rdb (unsigned int index) +{ + if (index < (unsigned int) (m_rdbs.size ())) { + delete m_rdbs [index]; + m_rdbs.erase (m_rdbs.begin () + index); + rdb_list_changed_event (); + } +} + +} // namespace lay diff --git a/src/laybasic/laybasic/layLayoutViewBase.h b/src/laybasic/laybasic/layLayoutViewBase.h new file mode 100644 index 000000000..65e3af2b8 --- /dev/null +++ b/src/laybasic/laybasic/layLayoutViewBase.h @@ -0,0 +1,2566 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 + +*/ + + +#ifndef HDR_layLayoutViewBase +#define HDR_layLayoutViewBase + +#include "laybasicCommon.h" + +#include +#include +#include +#include +#include +#include + +#include "layLayerProperties.h" +#include "layAbstractMenu.h" +#include "layAnnotationShapes.h" +#include "layDispatcher.h" +#include "layLayoutCanvas.h" +#include "layColorPalette.h" +#include "layStipplePalette.h" +#include "layLineStylePalette.h" +#include "layCellView.h" +#include "layViewOp.h" +#include "layEditable.h" +#include "layPlugin.h" +#include "layDisplayState.h" +#include "layBookmarkList.h" +#include "gsi.h" +#include "tlException.h" +#include "tlEvents.h" +#include "dbInstElement.h" + +namespace rdb { + class Database; +} + +namespace db { + class Layout; + class Manager; + class SaveLayoutOptions; + class LayoutToNetlist; +} + +namespace lay { + +class MouseTracker; +class ZoomService; +class SelectionService; +class MoveService; +class ColorButton; +class ConfigureAction; + +/** + * @brief Stores a layer reference to create layers which have been added by some action + * + * This object is delivered by LayoutViewBase::layer_snapshot and can be used in add_missing_layers + * to create new layer views for layers which have been created between layer_snapshot and + * add_missing_layers. + */ +struct LayerState +{ + /** + * @brief Constructor + */ + LayerState () { } + + std::set present; +}; + +/** + * @brief A layer display properties structure + * + * The layer properties encapsulate the settings relevant for + * the display of a layer. + * + * "brightness" is a index that indicates how much to make the + * color brighter to darker rendering the effective color + * (eff_frame_color (), eff_fill_color ()). It's value is roughly between + * -255 and 255. + */ +struct LAYBASIC_PUBLIC LayerDisplayProperties +{ + LayerDisplayProperties (); + + bool operator== (const LayerDisplayProperties &d); + bool operator!= (const LayerDisplayProperties &d); + + /** + * @brief render the effective frame color + * + * The effective frame color is computed from the frame color brightness and the + * frame color. + */ + color_t eff_frame_color () const; + + /** + * @brief render the effective frame color + * + * The effective frame color is computed from the frame color brightness and the + * frame color. + */ + color_t eff_fill_color () const; + + // display styles + color_t frame_color; + color_t fill_color; + int frame_brightness; + int fill_brightness; + unsigned int dither_pattern; + bool visible; + bool transparent; + int width; + bool marked; + int animation; + std::string name; +}; + +/** + * @brief The layout view object + * + * The layout view is responsible for displaying one or a set of layouts. + * It is composed of a canvas and controls to control the appearance. + * It manages the layer display list, bookmark list etc. + */ +class LAYBASIC_PUBLIC LayoutViewBase : + public lay::Editables, + public lay::Dispatcher +{ +public: + typedef lay::CellView::unspecific_cell_path_type cell_path_type; + typedef lay::CellView::cell_index_type cell_index_type; + typedef std::pair bookmark_type; + + /** + * @brief Define some options for the view + */ + enum options_type { + LV_Normal = 0, + LV_NoLayers = 1, + LV_NoHierarchyPanel = 2, + LV_NoLibrariesView = 4, + LV_NoEditorOptionsPanel = 8, + LV_NoBookmarksView = 16, + LV_Naked = 32, + LV_NoZoom = 64, + LV_NoGrid = 128, + LV_NoMove = 256, + LV_NoTracker = 512, + LV_NoSelection = 1024, + LV_NoPlugins = 2048, + LV_NoServices = LV_NoMove + LV_NoTracker + LV_NoSelection + LV_NoPlugins + }; + + enum drop_small_cells_cond_type { DSC_Max = 0, DSC_Min = 1, DSC_Sum = 2 }; + + /** + * @brief Constructor + */ + LayoutViewBase (db::Manager *mgr, bool editable, lay::Plugin *plugin_parent, unsigned int options = (unsigned int) LV_Normal); + + /** + * @brief Constructor (clone from another view) + */ + LayoutViewBase (lay::LayoutViewBase *source, db::Manager *mgr, bool editable, lay::Plugin *plugin_parent, unsigned int options = (unsigned int) LV_Normal); + + /** + * @brief Destructor + */ + ~LayoutViewBase (); + + /** + * @brief Determine if there is something to copy + * + * This reimplementation of the lay::Editables interface additionally + * looks for content providers in the tree views for example. + */ + bool has_selection (); + + /** + * @brief Pastes from clipboard + * + * This reimplementation of the lay::Editables interface additionally + * looks for paste receivers in the tree views for example. + */ + void paste (); + + /** + * @brief Pastes from clipboard and initiates a move + */ + void paste_interactive (); + + /** + * @brief Copies to clipboard + * + * This reimplementation of the lay::Editables interface additionally + * looks for copy providers in the tree views for example. + */ + void copy (); + + /** + * @brief Cuts to clipboard + * + * This reimplementation of the lay::Editables interface additionally + * looks for cut & copy providers in the tree views for example. + */ + void cut (); + + /** + * @brief Gets the explicit title string of the view + * + * This is the one explicitly set, not the one displayed. The displayed text is composed of internal information + * if no title string is set. + */ + const std::string &title_string () const + { + return m_title; + } + + /** + * @brief The "dirty" flag indicates that one of the layout has been modified + * + * A signal is provided on a change of this flag (dirty_changed). + */ + bool is_dirty () const; + + /** + * @brief Fill the layer properties for a new layer + * + * The layer's source must be set already to allow computing of the initial color. + * It is assumed that the layer is appended at the end of the layer list. This + * is important to set the dither pattern index accordingly. + */ + void init_layer_properties (LayerProperties &props) const; + + /** + * @brief Create a set of new layers for the given layers of the given cellview + */ + void add_new_layers (const std::vector &layer_ids, int cv_index); + + /** + * @brief Set the layer properties of a layer with the given position (by iterator) for the current layer list + * + * @param iter Points to the layer to be replaced + * @param props The properties to replace the current properties + */ + void set_properties (const LayerPropertiesConstIterator &iter, const LayerProperties &props) + { + set_properties (current_layer_list (), iter, props); + } + + /** + * @brief Set the layer properties of a layer with the given position (by iterator) for the layer list with the given index + * + * @param index The layer list's index + * @param iter Points to the layer to be replaced + * @param props The properties to replace the current properties + */ + void set_properties (unsigned int index, const LayerPropertiesConstIterator &iter, const LayerProperties &props); + + /** + * @brief Expand the layer properties of all tabs + * + * This method will replace the wildcard specifications in the layer properties of all + * tabs. All unspecific cv index specifications will be expanded to all cellviews, all + * layer and datatype specs will be expanded into all available (remaining) specs. + */ + void expand_properties (); + + /** + * @brief Expand the layer properties for the given tab + * + * @param index The index of the tab to which to apply the expansion to. + */ + void expand_properties (unsigned int index); + + /** + * @brief Expand the layer properties of all tabs with some options + * + * @param map_cv_index Maps a specified cv index to the one to use. Use -1 for the first entry to map any present cv index. Map to -1 to specify expansion to all available cv indices. + * @param add_default Set this parameter to true to implicitly add an entry for all "missing" layers. + */ + void expand_properties (const std::map &map_cv_index, bool add_default); + + /** + * @brief Expand the layer properties of the specified tab with some options + * + * @param index The index of the tab to which to apply the expansion to. + * @param map_cv_index Maps a specified cv index to the one to use. Use -1 for the first entry to map any present cv index. Map to -1 to specify expansion to all available cv indices. + * @param add_default Set this parameter to true to implicitly add an entry for all "missing" layers. + */ + void expand_properties (unsigned int index, const std::map &map_cv_index, bool add_default); + + /** + * @brief Replace the layer node with a new one for the current layer list + */ + void replace_layer_node (const LayerPropertiesConstIterator &iter, const LayerPropertiesNode &props) + { + replace_layer_node (current_layer_list (), iter, props); + } + + /** + * @brief Replace the layer node with a new one for the layer list with the given index + */ + void replace_layer_node (unsigned int index, const LayerPropertiesConstIterator &iter, const LayerPropertiesNode &props); + + /** + * @brief Insert the given layer properties node into the list for the current layer list + * + * This method returns a reference to the element created. + */ + const LayerPropertiesNode &insert_layer (const LayerPropertiesConstIterator &iter, const LayerPropertiesNode &props) + { + return insert_layer (current_layer_list (), iter, props); + } + + /** + * @brief Insert the given layer properties node into the list before the given index + * + * This method returns a reference to the element created. + */ + const LayerPropertiesNode &insert_layer (unsigned int index, const LayerPropertiesConstIterator &iter, const LayerPropertiesNode &props); + + /** + * @brief Delete the layer properties node for the current layer list + * + * This method deletes the object that the iterator points to and invalidates + * the iterator since the object that the iterator points to is no longer valid. + */ + void delete_layer (LayerPropertiesConstIterator &iter) + { + delete_layer (current_layer_list (), iter); + } + + /** + * @brief Delete the layer properties node for the layer list with the given index + * + * This method deletes the object that the iterator points to and invalidates + * the iterator since the object that the iterator points to is no longer valid. + */ + void delete_layer (unsigned int index, LayerPropertiesConstIterator &iter); + + /** + * @brief Begin iterator for the layers + * + * This iterator delivers recursively the layers of this view + */ + LayerPropertiesConstIterator begin_layers () const + { + return get_properties ().begin_const_recursive (); + } + + /** + * @brief End iterator for the layers + */ + LayerPropertiesConstIterator end_layers () const + { + return get_properties ().end_const_recursive (); + } + + /** + * @brief Begin iterator for the layers for a given list + * + * This iterator delivers recursively the layers of this view + */ + LayerPropertiesConstIterator begin_layers (unsigned int index) const + { + return get_properties (index).begin_const_recursive (); + } + + /** + * @brief End iterator for the layers for a given list + */ + LayerPropertiesConstIterator end_layers (unsigned int index) const + { + return get_properties (index).end_const_recursive (); + } + + /** + * @brief Replace the current layer properties list + */ + void set_properties (const LayerPropertiesList &list) + { + set_properties (current_layer_list (), list); + } + + /** + * @brief Rename a layer properties list + */ + void rename_properties (unsigned int index, const std::string &new_name); + + /** + * @brief Replace the specified layer properties list + */ + void set_properties (unsigned int index, const LayerPropertiesList &list); + + /** + * @brief Clear the given layer view list + */ + void clear_layers (unsigned int index) + { + set_properties (index, LayerPropertiesList ()); + } + + /** + * @brief Clear the current layer view list + */ + void clear_layers () + { + set_properties (LayerPropertiesList ()); + } + + /** + * @brief Access the current layer properties list + */ + const LayerPropertiesList &get_properties () const + { + return get_properties (current_layer_list ()); + } + + /** + * @brief Access the specified layer properties list + */ + const LayerPropertiesList &get_properties (unsigned int index) const; + + /** + * @brief Get the number of lists present in this view + */ + unsigned int layer_lists () const + { + return (unsigned int) m_layer_properties_lists.size (); + } + + /** + * @brief Get the index of the current properties list + */ + unsigned int current_layer_list () const + { + return m_current_layer_list; + } + + /** + * @brief Set the index of the current properties list + */ + void set_current_layer_list (unsigned int index); + + /** + * @brief Delete the specified layer properties list + */ + void delete_layer_list (unsigned int index); + + /** + * @brief Insert the layer properties list at the given index and make it the current list. + */ + void insert_layer_list (unsigned int index, const LayerPropertiesList &props); + + /** + * @brief Insert the layer properties list at the given index and make it the current list. + */ + void insert_layer_list (unsigned int index) + { + insert_layer_list (index, LayerPropertiesList ()); + } + + /** + * @brief Set the custom dither pattern + */ + void set_dither_pattern (const DitherPattern &pattern); + + /** + * @brief Obtain the custom dither pattern + */ + const DitherPattern &dither_pattern () const + { + return mp_canvas->dither_pattern (); + } + + /** + * @brief Set the custom line styles + */ + void set_line_styles (const LineStyles &styles); + + /** + * @brief Obtain the custom line styles + */ + const LineStyles &line_styles () const + { + return mp_canvas->line_styles (); + } + + /** + * @brief An event signalling the change in the number of hierarchy levels shown + */ + tl::Event hier_levels_changed_event; + + /** + * @brief An event signalling a change in the annotations shape list + * + * If annotation shapes are added or removed, this event is triggered. + */ + tl::Event annotations_changed_event; + + /** + * @brief An event signalling a change in the hierarchy of the layouts + * + * If the hierarchy of a layout is changed, this event is triggered. + * This may happen due to the removal or insertion of cells or instances. + */ + tl::Event hier_changed_event; + + /** + * @brief An event signalling a change in the geometries of the layouts + * + * If something on the geometries of a cell in one the layouts changes, this + * event is triggered. This may happed due to the removal or insertion of shapes or cell instances. + * In general, this indicates the need for redrawing of the layout for example. + */ + tl::Event geom_changed_event; + + /** + * @brief An event triggered before something on a cellview is changed + * + * This event is triggered before something on the cellview (i.e. the current cell of + * of set of the cellview) is changed. The argument is the index of the cell view to be + * changed. + * This event is followed by a corresponding cellview_changed event after the cellview + * has changed. + */ + tl::event cellview_about_to_change_event; + + /** + * @brief An event triggered before something on the cellviews is changed + * + * This event is triggered before something on the cellviews is changed, i.e. a cellview is deleted or inserted. + * Each of these events is followed by a cellviews_changed event after the change has been made. + */ + tl::Event cellviews_about_to_change_event; + + /** + * @brief An event signalling that the cell views have changed. + * + * When a cellview is added or removed, this event is triggered after the change has been made. + * The corresponding event that is triggered before the change is made is cellviews_about_to_change_event. + */ + tl::Event cellviews_changed_event; + + /** + * @brief An event signalling a change in a cellview. + * + * If a cellview is changed (i.e. the cell is changed) this event is triggered. + * The integer argument will receive the index of the cellview that has changed. + * The corresponding event that is triggered before the change is made is cellview_about_to_change_event. + */ + tl::event cellview_changed_event; + + /** + * @brief An event signalling that a file has been loaded. + * + * If a new file is loaded, this event is triggered. + */ + tl::Event file_open_event; + + /** + * @brief An event signalling that the viewport has changed. + * + * If the viewport (the rectangle that is shown) changes, this event + * is triggered. + */ + tl::Event viewport_changed_event; + + /** + * @brief This event is triggered if the background color changed + */ + tl::Event background_color_changed_event; + + /** + * @brief An event signalling that the layer list has changed. + * + * If the layer list changes, this event is triggered with an integer argument. + * The arguments's bit 0 is set, if the properties have changed. If the arguments bit 1 is + * set, the hierarchy has changed. If the name of layer properties is changed, bit 2 is + * set. + */ + tl::event layer_list_changed_event; + + /** + * @brief An event signalling that a layer list was deleted. + * + * If a layer list is deleted from the layer list set, the event is triggered with + * the index of the deleted list as an integer parameter. + */ + tl::event layer_list_deleted_event; + + /** + * @brief An event signalling that a layer list was inserted. + * + * If a layer list is inserted into the layer list set, the event is triggered with + * the index of the new list as an integer parameter. + */ + tl::event layer_list_inserted_event; + + /** + * @brief An event signalling that the current layer list has changed. + * + * If the current layer list is changed, this event is triggered. + */ + tl::event current_layer_list_changed_event; + + /** + * @brief An event signalling that the current layer has changed + */ + tl::event current_layer_changed_event; + + + /** + * @brief An event signalling that the visibility of some cells has changed + */ + tl::Event cell_visibility_changed_event; + + /** + * @brief An event triggered if the active cellview changes + * This event is triggered after the active cellview changed. + */ + tl::Event active_cellview_changed_event; + + /** + * @brief An event triggered if the active cellview changes + * This event is triggered after the active cellview changed. The integer parameter is the index of the + * new cellview. + */ + tl::event active_cellview_changed_with_index_event; + + /** + * @brief Save the given cellview into the given file (with options) + * If "update" is true, the cell view's properties will be updated (options, filename etc.). + */ + void save_as (unsigned int index, const std::string &filename, tl::OutputStream::OutputStreamMode om, const db::SaveLayoutOptions &options, bool update, int keep_backups); + + /** + * @brief Implementation of the undo operations + */ + virtual void undo (db::Op *op); + + /** + * @brief Implementation of the redo operations + */ + virtual void redo (db::Op *op); + + /** + * @brief Set the cellview at the given index + * + * If cvindex is used as the cellview index to associate the + * layout with. As a side effect, this method will emit a + * title_changed signal, which means that the cellview passed + * should be correctly named before to reflect the correct + * title if no explicit title is set. + */ + void set_layout (const lay::CellView &cv, unsigned int cvindex); + + /** + * @brief clear the cellviews + */ + void clear_cellviews (); + + /** + * @brief erase one cellview with the given index + */ + void erase_cellview (unsigned int index); + + /** + * @brief Save the layer properties + */ + void save_layer_props (const std::string &fn); + + /** + * @brief Load the layer properties + * + * @param fn The file to load. + */ + void load_layer_props (const std::string &fn); + + /** + * @brief Load the layer properties + * + * @param fn The file to load + * + * This version allows one to specify whether defaults should be used for all other layers by + * setting add_default to true + */ + void load_layer_props (const std::string &fn, bool add_default); + + /** + * @brief Load the layer properties + * + * @param fn The file to load + * + * This version allows one to specify whether defaults should be used for all other layers by + * setting add_default to true. In addition, this version will apply the .lyp definitions + * to a specific cellview after removing all definitions for this one. If cv_index is set + * to -1, the .lyp file will be applied to each cellview. In any case, the cv index specs + * in the .lyp file will be overridden. + */ + void load_layer_props (const std::string &fn, int cv_index, bool add_default); + + /** + * @brief Save the screen content to a file + */ + void save_screenshot (const std::string &fn); + +#if defined(HAVE_QT) + /** + * @brief Get the screen content as a QImage object + */ + QImage get_screenshot (); + + /** + * @brief Save an image file with the given width and height + */ + void save_image (const std::string &fn, unsigned int width, unsigned int height); + + /** + * @brief Save an image file with some options + * + * @param fn The path of the file to write + * @param width The width of the image in pixels + * @param height The height of the image + * @param linewidth The width of a line in pixels (usually 1) or 0 for default + * @param oversampling The oversampling factor (1..3) or 0 for default + * @param resolution The resolution (pixel size compared to a screen pixel size, i.e 1/oversampling) or 0 for default + * @param background The background color or lay::Color() for default + * @param foreground The foreground color or lay::Color() for default + * @param active The active color or lay::Color() for default + * @param target_box The box to draw or db::DBox() for default + * @param monochrome If true, monochrome images will be produced + */ + void save_image_with_options (const std::string &fn, unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, Color background, Color foreground, Color active_color, const db::DBox &target_box, bool monochrome); + + /** + * @brief Get the screen content as a QImage object with the given width and height + */ + QImage get_image (unsigned int width, unsigned int height); + + /** + * @brief Get the screen content as a QImage object with the given width and height + * + * @param width The width of the image in pixels + * @param height The height of the image + * @param linewidth The width of a line in pixels (usually 1) or 0 for default + * @param oversampling The oversampling factor (1..3) or 0 for default + * @param resolution The resolution (pixel size compared to a screen pixel size, i.e 1/oversampling) or 0 for default + * @param background The background color or lay::Color() for default + * @param foreground The foreground color or lay::Color() for default + * @param active The active color or lay::Color() for default + * @param target_box The box to draw or db::DBox() for default + * @param monochrome If true, monochrome images will be produced + */ + QImage get_image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, lay::Color background, lay::Color foreground, lay::Color active_color, const db::DBox &target_box, bool monochrome); +#endif + + /** + * @brief Hierarchy level selection setter + */ + void set_hier_levels (std::pair l); + + /** + * @brief Hierarchy level selection setter + */ + void set_min_hier_levels (int l) + { + set_hier_levels (std::pair (l, get_max_hier_levels ())); + } + + /** + * @brief Hierarchy level selection setter + */ + void set_max_hier_levels (int l) + { + set_hier_levels (std::pair (get_min_hier_levels (), l)); + } + + /** + * @brief Hierarchy level selection getter + */ + std::pair get_hier_levels () const; + + /** + * @brief Hierarchy level selection getter + */ + int get_min_hier_levels () const + { + return get_hier_levels ().first; + } + + /** + * @brief Hierarchy level selection getter + */ + int get_max_hier_levels () const + { + return get_hier_levels ().second; + } + + /** + * @brief Return true, if there is a "last" display state + */ + bool has_prev_display_state (); + + /** + * @brief Return true, if there is a "next" display state + */ + bool has_next_display_state (); + + /** + * @brief Cell box/label color setter + */ + void cell_box_color (lay::Color c); + + /** + * @brief Cell box/label getter + */ + lay::Color cell_box_color () const + { + return m_box_color; + } + + /** + * @brief Transform label flag setter + */ + void cell_box_text_transform (bool xform); + + /** + * @brief Transform label flag getter + */ + bool cell_box_text_transform () const + { + return m_box_text_transform; + } + + /** + * @brief Label font setter + */ + void cell_box_text_font (unsigned int f); + + /** + * @brief Label font setter + */ + unsigned int cell_box_text_font () const + { + return m_box_font; + } + + /** + * @brief Visibility of cell boxes + */ + void cell_box_visible (bool vis); + + /** + * @brief Visibility of cell boxes + */ + bool cell_box_visible () const + { + return m_cell_box_visible; + } + + /** + * @brief Min instance label size setter + */ + void min_inst_label_size (int px); + + /** + * @brief Min instance label size getter + */ + int min_inst_label_size () const + { + return m_min_size_for_label; + } + + /** + * @brief Visibility of text objects + */ + void text_visible (bool vis); + + /** + * @brief Visibility of text objects + */ + bool text_visible () const + { + return m_text_visible; + } + + /** + * @brief Show properties + */ + void show_properties_as_text (bool sp); + + /** + * @brief Show properties + */ + bool show_properties_as_text () + { + return m_show_properties; + } + + /** + * @brief Enable or disable bitmap caching + * + * Bitmap caching is used to optimize drawing by storing bitmaps + * in a cache for each cell. Repeated cells will be drawn faster then. + */ + void bitmap_caching (bool en); + + /** + * @brief Lazy rendering of text objects + */ + bool bitmap_caching () + { + return m_bitmap_caching; + } + + /** + * @brief Lazy rendering of text objects + */ + void text_lazy_rendering (bool lzy); + + /** + * @brief Lazy rendering of text objects + */ + bool text_lazy_rendering () + { + return m_text_lazy_rendering; + } + + /** + * @brief Text object font setter + */ + void text_font (unsigned int f); + + /** + * @brief Text object font getter + */ + unsigned int text_font () const + { + return m_text_font; + } + + /** + * @brief The default text size property + */ + void default_text_size (double fs); + + /** + * @brief The default text size property + */ + double default_text_size () const + { + return m_default_text_size; + } + + /** + * @brief Show or hide markers + */ + void show_markers (bool f); + + /** + * @brief "show_markers" property getter + */ + bool show_markers () const + { + return m_show_markers; + } + + /** + * @brief Don't show stipples + */ + void no_stipples (bool f); + + /** + * @brief "Don't show stipples" property getter + */ + bool no_stipples () const + { + return m_no_stipples; + } + + /** + * @brief Offset stipples property + */ + void offset_stipples (bool f); + + /** + * @brief Offset stipples property getter + */ + bool offset_stipples () const + { + return m_stipple_offset; + } + + /** + * @brief Apply text transformation property + */ + void apply_text_trans (bool f); + + /** + * @brief Apply text transformation property + */ + bool apply_text_trans () const + { + return m_apply_text_trans; + } + + /** + * @brief Text object color + */ + void text_color (lay::Color c); + + /** + * @brief Text object color + */ + lay::Color text_color () const + { + return m_text_color; + } + + /** + * @brief Clear all rulers if a new cell is selected (setter) + * + * If this property is set to true, all rulers are cleared + * if the cell is changed. + */ + void clear_ruler_new_cell (bool f); + + /** + * @brief Clear all rulers if a new cell is selected (getter) + * + * If this property is set to true, all rulers are cleared + * if the cell is changed. + */ + bool clear_ruler_new_cell () const + { + return m_clear_ruler_new_cell; + } + + /** + * @brief Switch new cell to full hierarchy property + * + * If this property is set to true, all hierarchy levels are selected + * if the cell is changed. + */ + void full_hier_new_cell (bool f); + + /** + * @brief Switch new cell to full hierarchy property + * + * If this property is set to true, all hierarchy levels are selected + * if the cell is changed. + */ + bool full_hier_new_cell () const + { + return m_full_hier_new_cell; + } + + /** + * @brief Fit new cell property + * + * If this property is set to false, the coordinate window is not + * changed if the cell is changed. + */ + void fit_new_cell (bool f); + + /** + * @brief Fit new cell + * + * If this property is set to false, the coordinate window is not + * changed if the cell is changed. + */ + bool fit_new_cell () const + { + return m_fit_new_cell; + } + + /** + * @brief The pan distance + * + * The pan distance is given relative to the current width and height. + */ + void pan_distance (double d); + + /** + * @brief Gets the pan distance + */ + double pan_distance () const; + + /** + * @brief Get the mouse wheel mode + * + * The mouse wheel mode determines how the wheel behaves. Mode 0 is the + * default mode, mode 1 is the alternative mode (default is up/down, + * shift is left/right, ctrl is zoom). + */ + int mouse_wheel_mode () const + { + return m_wheel_mode; + } + + /** + * @brief Set the mouse wheel mode + * + * The mouse wheel mode determines how the wheel behaves. Mode 0 is the + * default mode, mode 1 is the alternative mode (default is up/down, + * shift is left/right, ctrl is zoom). + */ + void mouse_wheel_mode (int m) + { + m_wheel_mode = m; + } + + /** + * @brief Sets the color palette + * + * The color palette is used for coloring new layers and is shown in the + * layer toolbox. + */ + void set_palette (const lay::ColorPalette &); + + /** + * @brief Gets the color palette + */ + const lay::ColorPalette &get_palette () const + { + return m_palette; + } + + /** + * @brief Sets the stipple palette + * + * The stipple palette is used for selecting stipples for new layers and is shown in the + * layer toolbox. + */ + void set_palette (const lay::StipplePalette &); + + /** + * @brief Gets the stipple palette + */ + const lay::StipplePalette &get_stipple_palette () const + { + return m_stipple_palette; + } + + /** + * @brief Sets the line style palette + * + * The line style palette is used for selecting line styles and is shown in the + * layer toolbox. + */ + void set_palette (const lay::LineStylePalette &); + + /** + * @brief Gets the line style palette + */ + const lay::LineStylePalette &get_line_style_palette () const + { + return m_line_style_palette; + } + + /** + * @brief Reloads the given cellview into the current view + * + * The cellview is given by index in the current view's cellview list. + */ + void reload_layout (unsigned int cv_index); + + /** + * @brief Load a (new) file into the layout + * + * The add_cellview param controls whether to create a new cellview + * or clear all cellviews before. + * + * The new layout will use the default technology. + * + * @return The index of the cellview loaded. + */ + unsigned int load_layout (const std::string &filename, bool add_cellview) + { + return load_layout (filename, std::string (), add_cellview); + } + + /** + * @brief Load a (new) file into the layout associating it with the given technology + * + * The add_cellview param controls whether to create a new cellview + * or clear all cellviews before. + * + * @return The index of the cellview loaded. + */ + unsigned int load_layout (const std::string &filename, const std::string &technology, bool add_cellview); + + /** + * @brief Load a (new) file into the layout with the options + * + * The add_cellview param controls whether to create a new cellview + * or clear all cellviews before. + * + * The new layout will use the default technology. + * + * @param options The options to use when loading. + * @param add_cellview_param See above. + * @return The index of the cellview loaded. + */ + unsigned int load_layout (const std::string &filename, const db::LoadLayoutOptions &options, bool add_cellview) + { + return load_layout (filename, options, std::string (), add_cellview); + } + + /** + * @brief Load a (new) file into the layout with the options and using the specified technology + * + * The add_cellview param controls whether to create a new cellview + * or clear all cellviews before. + * + * @param options The options to use when loading. + * @param add_cellview_param See above. + * @return The index of the cellview loaded. + */ + unsigned int load_layout (const std::string &filename, const db::LoadLayoutOptions &options, const std::string &technology, bool add_cellview); + + /** + * @brief Create a new, empty layout + * + * The add_cellview param controls whether to create a new cellview + * or clear all cellviews before. + * + * The new layout will use the default technology. + * + * @return The index of the cellview loaded. + */ + unsigned int create_layout (bool add_cellview) + { + return create_layout (std::string (), add_cellview, true); + } + + /** + * @brief Create a new, empty layout using the specified technology + * + * The add_cellview param controls whether to create a new cellview + * or clear all cellviews before. + * + * @return The index of the cellview created. + */ + unsigned int create_layout (const std::string &technology, bool add_cellview) + { + return create_layout (technology, add_cellview, true); + } + + /** + * @brief Create a new, empty layout using the specified technology + * + * The add_cellview param controls whether to create a new cellview + * or clear all cellviews before. This version allows one to specify whether layer properties shall be created. + * + * @return The index of the cellview created. + */ + unsigned int create_layout (const std::string &technology, bool add_cellview, bool initialize_layers); + + /** + * @brief Add an existing layout or replace the current cellview by the given layout + * + * The add_cellview param controls whether to add the layout as a new cellview + * or clear all cellviews before. + * + * The "initialize_layers" parameter allows one to specify whether the layer properties shall be initialized. + * + * @return The index of the cellview loaded. + */ + unsigned int add_layout (lay::LayoutHandle *layout_handle, bool add_cellview, bool initialize_layers = true); + + /** + * @brief Pass the current position from the mouse tracker to the status bar + */ + void current_pos (double x, double y); + + /** + * @brief Obtain the number of cellviews + */ + unsigned int cellviews () const + { + return (unsigned int) m_cellviews.size (); + } + + /** + * @brief Obtain the cellviews as a vector + */ + const std::list &cellview_list () const + { + return m_cellviews; + } + + /** + * @brief Obtain the cell view reference for an index + * + * If the index is invalid, an empty cell view reference is returned + */ + const CellView &cellview (unsigned int index) const; + + /** + * @brief Gets a cellview reference to the active cellview + */ + lay::CellViewRef cellview_ref (unsigned int index); + + /** + * @brief Gets the index of the given cellview + * Based on the pointer passed to the function, the index of the respective cellview + * will be returned. If a null pointer is given or the pointer is not a valid cellview, + * -1 will be returned. + */ + int index_of_cellview (const lay::CellView *cv) const; + + /** + * @brief Obtain the list of annotation shapes + */ + const lay::AnnotationShapes &annotation_shapes () const + { + return m_annotation_shapes; + } + + /** + * @brief Obtain the list of annotation shapes (non-const version) + */ + lay::AnnotationShapes &annotation_shapes () + { + return m_annotation_shapes; + } + + /** + * @brief Select the list of cellviews for this window and fit cell + * + * Warning: use with care! + */ + void select_cellviews_fit (const std::list &cvs); + + /** + * @brief Select the list of cellviews for this window + * + * Warning: use with care! + */ + void select_cellviews (const std::list &cvs); + + /** + * @brief Configures the cellview with the given index + * @param index Index of the cellview to configure + * @param cv The cellview that provides the new configuration + */ + void select_cellview (int index, const CellView &cv); + + /** + * @brief Shift and scale the window + */ + void shift_window (double f, double dx, double dy); + + /** + * @brief Goto window + * + * Position the window to the new position x and y with a size of s (approximately). + * If s is negative or zero, the windows is just shifted. + */ + void goto_window (const db::DPoint &p, double s = -1.0); + + /** + * @brief Return the displayed window + */ + db::DBox box () const; + + /** + * @brief Display a status message + */ + void message (const std::string &s = "", int timeout = 10); + + /** + * @brief Create a new cell with the given in the given cellview + * + * @param cv_index The index of the cellview where to create the cell + * @param cell_name The name of the cell (an exception is thrown if a cell of that name already exists) + * @return The index of the new cell + */ + db::cell_index_type new_cell (int cv_index, const std::string &cell_name); + + std::pair redo_available (); + std::pair undo_available (); + + /** + * @brief Select a certain mode (by index) + */ + void mode (int m); + + /** + * @brief Switches the application's mode + * + * Switches the mode on application level. Use this method to initiate + * a mode switch from the view. + */ + void switch_mode (int m); + + /** + * @brief Test, if the view is currently in move mode. + */ + bool is_move_mode () const; + + /** + * @brief Test, if the view is currently in selection mode. + */ + bool is_selection_mode () const; + + /** + * @brief Query the intrinsic mouse modes available + */ + static unsigned int intrinsic_mouse_modes (std::vector *descriptions); + + /** + * @brief Updates the menu for the given view + * If the view is 0, the menu shall be updated to reflect "no view active" + */ + static void update_menu (lay::LayoutViewBase *view, lay::AbstractMenu &menu); + + /** + * @brief Query the default mode + */ + static int default_mode (); + + /** + * @brief Get a list of cellview index and transform variants + */ + std::set< std::pair > cv_transform_variants () const; + + /** + * @brief Get the global transform variants for a given cellview index + */ + std::vector cv_transform_variants (int cv_index) const; + + /** + * @brief Get the global transform variants for a given cellview index and layer + */ + std::vector cv_transform_variants (int cv_index, unsigned int layer) const; + + /** + * @brief Get the transformation variants for a given cellview index ordered by layer + */ + std::map > cv_transform_variants_by_layer (int cv_index) const; + + /** + * @brief Access to the hidden cell list + */ + const std::vector > &hidden_cells () const + { + return m_hidden_cells; + } + + /** + * @brief Get the "dbu_coordinates" flag + * + * If this flag is true, the property dialogs and other display functions should use + * database units to display coordinates etc. + */ + bool dbu_coordinates () const + { + return m_dbu_coordinates; + } + + /** + * @brief Set the "dbu_coordinates" flag + * + * If this flag is true, the property dialogs and other display functions should use + * database units to display coordinates etc. + */ + void dbu_coordinates (bool f); + + /** + * @brief Get the "absolute_coordinates" flag + * + * If this flag is true, the property dialogs and other display functions should use + * absolute (on top level) coordinates for points etc. + * "absolute" may as well refer to orientation, not only to coordinates, + * if transformations are considered. + */ + bool absolute_coordinates () const + { + return m_absolute_coordinates; + } + + /** + * @brief Set the "absolute_coordinates" flag + * + * If this flag is true, the property dialogs and other display functions should use + * absolute (on top level) coordinates for points etc. + * "absolute" may as well refer to orientation, not only to coordinates, + * if transformations are considered. + */ + void absolute_coordinates (bool f); + + /** + * @brief Get the view object widget + * + * This method intentionally delivers the ViewObjectWidget, not the + * LayoutCanvas to emphasize that the LayoutCanvas object shall not + * be modified. + */ + lay::ViewObjectWidget *view_object_widget () + { + return mp_canvas; + } + + /** + * @brief Get the current viewport + */ + const lay::Viewport &viewport () const + { + return mp_canvas->viewport (); + } + + /** + * @brief Background color property + */ + lay::Color background_color () const + { + return mp_canvas->background_color (); + } + + /** + * @brief Foreground color property + */ + lay::Color foreground_color () const + { + return mp_canvas->foreground_color (); + } + + /** + * @brief Active color property + */ + lay::Color active_color () const + { + return mp_canvas->active_color (); + } + + /** + * @brief Write accessor to the "drop small cells" flag + */ + void drop_small_cells (bool m); + + /** + * @brief Read accessor to the "drop small cells" flag + */ + bool drop_small_cells () const + { + return m_drop_small_cells; + } + + /** + * @brief Write accessor to the "drop small cells" value + */ + void drop_small_cells_value (unsigned int s); + + /** + * @brief Read accessor to the "drop small cells" value + */ + unsigned int drop_small_cells_value () const + { + return m_drop_small_cells_value; + } + + /** + * @brief Write accessor to the "drop small cells" condition + */ + void drop_small_cells_cond (drop_small_cells_cond_type t); + + /** + * @brief Read accessor to the "drop small cells" condition + */ + drop_small_cells_cond_type drop_small_cells_cond () const + { + return m_drop_small_cells_cond; + } + + /** + * @brief Gets a value indicating whether guiding shapes are visible + */ + bool guiding_shapes_visible () const + { + return m_guiding_shape_visible; + } + + /** + * @brief Sets a value indicating whether guiding shapes are visible + */ + void guiding_shapes_visible (bool v); + + /** + * @brief Gets the guiding shapes color + */ + lay::Color guiding_shapes_color () const + { + return m_guiding_shape_color; + } + + /** + * @brief Sets the guiding shapes color + */ + void guiding_shapes_color (lay::Color c); + + /** + * @brief Gets the guiding shapes line width + */ + int guiding_shapes_line_width () const + { + return m_guiding_shape_line_width; + } + + /** + * @brief Sets the guiding shapes line width + */ + void guiding_shapes_line_width (int lw); + + /** + * @brief Gets the guiding shapes vertex size + */ + int guiding_shapes_vertex_size () const + { + return m_guiding_shape_vertex_size; + } + + /** + * @brief Sets the guiding shapes vertex size + */ + void guiding_shapes_vertex_size (int lw); + + /** + * @brief Read accessor to the "abstract mode width" property. + * + * The abstract mode width enables abstract mode (for values > 0) and + * specifies the border to search for touching shapes. + */ + double abstract_mode_width () const + { + return m_abstract_mode_enabled ? m_abstract_mode_width : 0.0; + } + + /** + * @brief Read accessor to the "child context enabled" property. + * + * If child context is enabled, a third set of bit planes must be created by the redraw thread + * containing the shapes for the below-top-level objects. + */ + bool child_context_enabled () const + { + return m_child_ctx_enabled; + } + + /** + * @brief Write accessor to the "draw array border instances" flag + */ + void draw_array_border_instances (bool m); + + /** + * @brief Read accessor to the "draw array border instances" flag + */ + bool draw_array_border_instances () const + { + return m_draw_array_border_instances; + } + + /** + * @brief Get the Drawings interface + * + * Although the Drawings interface is implemented by LayoutCanvas, + * it is a different interface from ViewObjectWidget. + */ + lay::Drawings *drawings () + { + return mp_canvas; + } + + /** + * @brief Select synchronous mode or deselect it + */ + void set_synchronous (bool sync_mode); + + /** + * @brief Tell the state of synchronous mode + */ + bool synchronous () const + { + return m_synchronous; + } + + /** + * @brief Set the number of drawing workers (if not synchronous) + */ + void set_drawing_workers (int workers); + + /** + * @brief Get the number of drawing workers + */ + int drawing_workers () const + { + return m_drawing_workers; + } + + /** + * @brief Gets a value indicating whether the view will accept a dropped file with the given URL or path + */ + virtual bool accepts_drop (const std::string &path_or_url) const; + + /** + * @brief Gets called when a file or URL is dropped on the view + */ + virtual void drop_url (const std::string &path_or_url); + + /** + * @brief Gets a list of all plugins + */ + const std::vector &plugins () + { + return mp_plugins; + } + + /** + * @brief Localize a plugin by name + * + * This method will return 0, if no such plugin is registered + */ + Plugin *get_plugin_by_name (const std::string &name) const; + + /** + * @brief Localize the plugin of the given Type + * + * This method will return 0, if no such plugin is registered + */ + template + PI *get_plugin () const + { + PI *pi = 0; + for (std::vector::const_iterator p = mp_plugins.begin (); p != mp_plugins.end () && !pi; ++p) { + pi = dynamic_cast (*p); + } + return pi; + } + + /** + * @brief Localize the plugins of the given Type + * + * This method will return 0, if no such plugin is registered + */ + template + std::vector get_plugins () const + { + std::vector pi; + for (std::vector::const_iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) { + if (dynamic_cast (*p) != 0) { + pi.push_back (dynamic_cast (*p)); + } + } + return pi; + } + + /** + * @brief Create a plugin of the given type + * + * This method can be used to selectively create plugins when the NoPlugin option + * is used. If no such plugin is registered, no plugin is created. + * If a plugin with that name is already registered, it is not created again. + * PD is the type of the declaration. + */ + template + void create_plugin () + { + for (std::vector::const_iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) { + if (dynamic_cast ((*p)->plugin_declaration ()) != 0) { + return; + } + } + for (tl::Registrar::iterator cls = tl::Registrar::begin (); cls != tl::Registrar::end (); ++cls) { + if (dynamic_cast (&*cls) != 0) { + create_plugin (&*cls); + break; + } + } + } + + + /** + * @brief Enable or disable the actions for edit functions + * + * This method is used by non-modal dialogs that want to suppress any editing + * activities (like browsers) while they are open. + * + * This method can be called multiple times and will count the enable/disable + * transitions. Each disable will cancel on enable call. + */ + void enable_edits (bool enable); + + /** + * @brief Gets a value indicating whether edits are enabled or not + * + * "enable_edits" will change this value. + */ + bool edits_enabled () const + { + return m_disabled_edits <= 0; + } + + /** + * @brief Rename the given cellview to the given name + * + * The name of the cell view is shown in the title + */ + void rename_cellview (const std::string &name, int cellview_index); + + /** + * @brief Descend into the hierarchy along the given specific path for the given cellview + */ + void descend (const std::vector &path, int cellview_index); + + /** + * @brief Ascend one level in the hierarchy for the given cellview + * + * @return The instance element removed by ascending the path + */ + db::InstElement ascend (int cellview_index); + + /** + * @brief Select a cell by path for a certain cell view and fit cell + */ + void select_cell_fit (const cell_path_type &path, int cellview_index); + + /** + * @brief Select a cell by index for a certain cell view and fit cell + */ + void select_cell_fit (cell_index_type index, int cellview_index); + + /** + * @brief Select a cell by path for a certain cell view + */ + void select_cell (const cell_path_type &path, int cellview_index); + + /** + * @brief Select a cell by index for a certain cell view + */ + void select_cell (cell_index_type index, int cellview_index); + + /** + * @brief Check if a cell is hidden + */ + bool is_cell_hidden (cell_index_type ci, int cellview_index) const; + + /** + * @brief Get the hidden cells for a certain cellview + */ + const std::set &hidden_cells (int cellview_index) const; + + /** + * @brief Add a cell to the hidden cell list + */ + void hide_cell (cell_index_type ci, int cellview_index); + + /** + * @brief Remove a cell from the hidden cell list + */ + void show_cell (cell_index_type ci, int cellview_index); + + /** + * @brief Clears the hidden cell list + */ + void show_all_cells (); + + /** + * @brief Clears the hidden cell list for the given cellview + */ + void show_all_cells (int cv_index); + + /** + * @brief Update the layout view to the current state + * + * This method must be called in order to trigger the update of + * the contents. It will be known, what needs to be updated. + */ + void update_content (); + + /** + * @brief Force an unconditional update + * + * This method is supposed to be used to ensure everything is updated. + * TODO: this method should become obsolete once there is a consistent + * signalling of states implemented. + */ + void force_update_content (); + + /** + * @brief Create a set of initial layer properties for the given cellview + * + * @param cv_index The cellview for which to produce a set of layer properties + * @param lyp_file The layer properties file to load or empty if no file should be loaded + * @param add_missing True, if missing layers should be added (ignored if lyp_file is empty) + */ + void create_initial_layer_props (int cv_index, const std::string &lyp_file, bool add_missing); + + /** + * @brief Merges the given properties into the cell properties of this view + */ + void merge_layer_props (const std::vector &props); + + /** + * @brief Internal method: check, if the layer tree is and an consistent state. + * + * This method is used by the layer tree model to check, if the tree has been brought into + * a consistent state. + * HINT: for the layout this is solved more consistently with the "under construction" attribute + * of the layout. There is no equivalent object for the layer tree currently. + */ + bool layer_model_updated (); + + /** + * @brief Get the "select inside PCells" selection mode + * + * @return true, objects inside PCells can be selected + */ + bool select_inside_pcells_mode () const + { + return m_sel_inside_pcells; + } + + /** + * @brief Get the transient selection mode + * + * @return true, if transient (hover) selection mode is enabled + */ + bool transient_selection_mode () const + { + return m_transient_selection_mode; + } + + /** + * @brief Get the default color for markers + */ + lay::Color default_marker_color () const + { + return m_marker_color; + } + + /** + * @brief Get the default line width for markers + */ + int default_marker_line_width () const + { + return m_marker_line_width; + } + + /** + * @brief Get the default marker dither pattern index + */ + int default_dither_pattern () const + { + return m_marker_dither_pattern; + } + + /** + * @brief Get the default marker line style index + */ + int default_line_style () const + { + return m_marker_line_style; + } + + /** + * @brief Get the default vertex size for markers + */ + int default_marker_vertex_size () const + { + return m_marker_vertex_size; + } + + /** + * @brief Get the default halo flag for markers + */ + int default_marker_halo () const + { + return m_marker_halo; + } + + /** + * @brief Gets the "search range" in pixels (for single click) + * The search range applies whenever some object is looked up in the vicinity of the + * mouse cursor. This value gives the search range in pixels. + */ + unsigned int search_range (); + + /** + * @brief Sets the "search range" in pixels (for single click) + */ + void set_search_range (unsigned int sr); + + /** + * @brief Gets the "search range" in pixels (for box) + * The search range applies whenever some object is looked up in the vicinity of the + * mouse cursor. This value gives the search range in pixels. + */ + unsigned int search_range_box (); + + /** + * @brief Sets the "search range" in pixels (for box) + */ + void set_search_range_box (unsigned int sr); + + /** + * @brief Return true, if any cellview is editable + */ + bool is_editable () const; + + /** + * @brief Get the view_op's for rendering the layers + */ + const std::vector &get_view_ops () const + { + return mp_canvas->get_view_ops (); + } + + /** + * @brief Get the redraw layer info vector + */ + const std::vector &get_redraw_layers () const + { + return mp_canvas->get_redraw_layers (); + } + + /** + * @brief Add missing layers + */ + void add_missing_layers (); + + /** + * @brief Add layers which are not part of the LayerState + */ + void add_new_layers (const LayerState &snapshot); + + /** + * @brief Gets a snapshot of the current layers (can be used for add_missing_layers later) + */ + LayerState layer_snapshot () const; + + /** + * @brief Remove unused layers + */ + void remove_unused_layers (); + + /** + * @brief Returns true, if the layer source shall be shown always in the layer properties tree + */ + bool always_show_source () const + { + return m_always_show_source; + } + + /** + * @brief Returns true, if the layer/datatype shall be shown always in the layer properties tree + */ + bool always_show_ld () const + { + return m_always_show_ld; + } + + /** + * @brief Returns true, if the layout index shall be shown always in the layer properties tree + */ + bool always_show_layout_index () const + { + return m_always_show_layout_index; + } + + /** + * @brief Add a marker database + * + * The layout view will become owner of the database. + * + * @param rdb The database to add + * @return The index of the database + */ + unsigned int add_rdb (rdb::Database *rdb); + + /** + * @brief Replaces a marker database + * + * The layout view will become owner of the database. + * If the index is not valid, the database will be added and the new index will be returned. + * + * @param db_index The index of the database to replace + * @param rdb The database to add + */ + unsigned int replace_rdb (unsigned int db_index, rdb::Database *rdb); + + /** + * @brief Get the marker database by index + * + * @param index The index of the database + * @return A pointer to the database or 0 if the index was not valid. + */ + rdb::Database *get_rdb (int index); + + /** + * @brief Get the marker database by index (const version) + * + * @param index The index of the database + * @return A pointer to the database or 0 if the index was not valid. + */ + const rdb::Database *get_rdb (int index) const; + + /** + * @brief Remove the marker database with the given index + * + * This will release the marker database at the given index. The list + * will be reduced by that element. This means, that the following elements + * will have different indicies. + */ + void remove_rdb (unsigned int index); + + /** + * @brief Get the number of marker databases + */ + unsigned int num_rdbs () const + { + return (unsigned int) m_rdbs.size (); + } + + /** + * @brief An event signalling a change in the marker database list + * + * If marker databases are added or removed, this event is triggered. + */ + tl::Event rdb_list_changed_event; + + /** + * @brief Add a Netlist database + * + * The layout view will become owner of the database. + * + * @param l2ndb The database to add + * @return The index of the database + */ + unsigned int add_l2ndb (db::LayoutToNetlist *l2ndb); + + /** + * @brief Replaces a Netlist database + * + * The layout view will become owner of the database. + * If the index is not valid, the database will be added and the new index will be returned. + * + * @param db_index The index of the database to replace + * @param l2ndb The database to add + */ + unsigned int replace_l2ndb (unsigned int db_index, db::LayoutToNetlist *l2ndb); + + /** + * @brief Get the netlist database by index + * + * @param index The index of the database + * @return A pointer to the database or 0 if the index was not valid. + */ + db::LayoutToNetlist *get_l2ndb (int index); + + /** + * @brief Get the netlist database by index (const version) + * + * @param index The index of the database + * @return A pointer to the database or 0 if the index was not valid. + */ + const db::LayoutToNetlist *get_l2ndb (int index) const; + + /** + * @brief Remove the netlist database with the given index + * + * This will release the netlist database at the given index. The list + * will be reduced by that element. This means, that the following elements + * will have different indicies. + */ + void remove_l2ndb (unsigned int index); + + /** + * @brief Get the number of netlist databases + */ + unsigned int num_l2ndbs () const + { + return (unsigned int) m_l2ndbs.size (); + } + + /** + * @brief An event signalling a change in the netlist database list + * + * If netlist databases are added or removed, this event is triggered. + */ + tl::Event l2ndb_list_changed_event; + + /** + * @brief Ensure the given box is visible + */ + void ensure_visible (const db::DBox &b); + + /** + * @brief Specify the global transformation + */ + void set_global_trans (const db::DCplxTrans &b); + + /** + * @brief Gets the global transformation + */ + const db::DCplxTrans &global_trans () const + { + return mp_canvas->global_trans (); + } + + /** + * @brief Removes the previous state from the stack + */ + void pop_state (); + + /** + * @brief Clears the state stack + */ + void clear_states (); + + /** + * @brief Zoom the given box into view + */ + void zoom_box (const db::DBox &b); + + /** + * @brief Zoom the given box into view and select hierarchy levels + */ + void zoom_box_and_set_hier_levels (const db::DBox &b, const std::pair &levels); + + /** + * @brief Specify the transformation explicitly + */ + void zoom_trans (const db::DCplxTrans &b); + + /** + * @brief Move the viewport such that the given point is at the center of the viewport + */ + void pan_center (const db::DPoint &p); + + /** + * @brief Goto a position/cell view that was saved with save_view + */ + void goto_view (const DisplayState &state); + + /** + * @brief Save a position/cell view that can be used for "goto_view" + */ + void save_view (DisplayState &state) const; + + // access to the basic services + lay::MouseTracker *mouse_tracker () const { return mp_tracker; } + lay::ZoomService *zoom_service () const { return mp_zoom_service; } + lay::SelectionService *selection_service () const { return mp_selection_service; } + lay::MoveService *move_service () const { return mp_move_service; } + + /** + * @brief Create all plugins + * + * If plugins already exist, they are deleted and created again + */ + void create_plugins (const lay::PluginDeclaration *except_this = 0); + + /** + * @brief Gets the full field box + * + * This is the box to which the view will zoom on zoom_fit(). + * This box is supposed to cover everything inside the view. + */ + db::DBox full_box () const; + + /** + * @brief Gets called when a menu item is activated + */ + void menu_activated (const std::string &symbol); + + /** + * @brief Gets all available menu symbols + */ + static std::vector menu_symbols (); + + /** + * @brief Store the current state on the "previous states" stack + */ + void store_state (); + + /** + * @brief Cancels all edit operations, clears the selection and resets the mode to "Select" + */ + void cancel_esc (); + + /** + * @brief Cancels all edit operations and clears the selection + */ + void cancel (); + + /** + * @brief Cancels all edit operations but maintains selection + */ + void cancel_edits (); + + /** + * @brief Select all levels of hierarchy available + */ + void max_hier (); + + /** + * @brief Stop activities like shape browser and redrawing thread + */ + void stop (); + + /** + * @brief Stop redrawing thread + */ + void stop_redraw (); + + /** + * @brief Select last display state + */ + void prev_display_state (); + + /** + * @brief Select next display state + */ + void next_display_state (); + + /** + * @brief Ensure the selection is visible + */ + void ensure_selection_visible (); + + /** + * @brief Select a cell by index for a certain cell view + * + * This will be forwarded to select_cell or select_cell_fit depending + * on the m_fit_new_cell flag. + */ + void select_cell_dispatch (const cell_path_type &path, int cellview_index); + + /** + * @brief Called when the current layer changed + */ + void current_layer_changed_slot (const lay::LayerPropertiesConstIterator &iter); + + // zoom slots + void zoom_fit (); + void zoom_fit_sel (); + void zoom_in (); + void zoom_out (); + void pan_left (); + void pan_up (); + void pan_right (); + void pan_down (); + void pan_left_fast (); + void pan_up_fast (); + void pan_right_fast (); + void pan_down_fast (); + + // called by children and owner + void redraw (); + void redraw_layer (unsigned int index); + void redraw_deco_layer (); + void redraw_cell_boxes (); + void layer_tab_changed (); + void layer_order_changed (); + void timer (); + void min_hier_changed (int i); + void max_hier_changed (int i); + +private: + // event handlers used to connect to the layout object's events + void signal_hier_changed (); + void signal_bboxes_from_layer_changed (unsigned int cv_index, unsigned int layer_index); + void signal_bboxes_changed (); + void signal_prop_ids_changed (); + void signal_layer_properties_changed (); + void signal_cell_name_changed (); + void signal_annotations_changed (); + void signal_plugin_enabled_changed (); + void signal_apply_technology (lay::LayoutHandle *layout_handle); + + void active_cellview_changed (int index); + void active_library_changed (int index); + void side_panel_destroyed (); + +private: + bool m_editable; + int m_disabled_edits; + unsigned int m_options; + lay::LayoutCanvas *mp_canvas; + std::list m_cellviews; + lay::AnnotationShapes m_annotation_shapes; + std::vector > m_hidden_cells; + std::string m_title; + tl::vector m_rdbs; + tl::vector m_l2ndbs; + std::string m_def_lyp_file; + bool m_add_other_layers; + bool m_always_show_source; + bool m_always_show_ld; + bool m_always_show_layout_index; + bool m_synchronous; + int m_drawing_workers; + + int m_from_level, m_to_level; + double m_pan_distance; + int m_paste_display_mode; + int m_wheel_mode; + bool m_guiding_shape_visible; + lay::Color m_guiding_shape_color; + int m_guiding_shape_line_width; + int m_guiding_shape_vertex_size; + + lay::Color m_ctx_color; + int m_ctx_dimming; + bool m_ctx_hollow; + + lay::Color m_child_ctx_color; + int m_child_ctx_dimming; + bool m_child_ctx_hollow; + bool m_child_ctx_enabled; + + double m_abstract_mode_width; + bool m_abstract_mode_enabled; + + lay::Color m_box_color; + bool m_box_text_transform; + unsigned int m_box_font; + int m_min_size_for_label; + bool m_cell_box_visible; + + lay::Color m_marker_color; + int m_marker_line_width; + int m_marker_vertex_size; + int m_marker_dither_pattern; + int m_marker_line_style; + bool m_marker_halo; + + unsigned int m_search_range; + unsigned int m_search_range_box; + + bool m_transient_selection_mode; + bool m_sel_inside_pcells; + + int m_default_font_size; + bool m_text_visible; + bool m_text_lazy_rendering; + bool m_bitmap_caching; + bool m_show_properties; + lay::Color m_text_color; + bool m_apply_text_trans; + double m_default_text_size; + unsigned int m_text_font; + bool m_show_markers; + bool m_no_stipples; + bool m_stipple_offset; + + bool m_drop_small_cells; + unsigned int m_drop_small_cells_value; + drop_small_cells_cond_type m_drop_small_cells_cond; + + bool m_draw_array_border_instances; + + bool m_fit_new_cell; + bool m_full_hier_new_cell; + bool m_clear_ruler_new_cell; + bool m_dbu_coordinates; + bool m_absolute_coordinates; + + bool m_dirty; + bool m_activated; + bool m_animated; + unsigned int m_phase; + + lay::ColorPalette m_palette; + lay::StipplePalette m_stipple_palette; + lay::LineStylePalette m_line_style_palette; + + std::vector m_display_states; + unsigned int m_display_state_ptr; + + std::vector m_layer_properties_lists; + unsigned int m_current_layer_list; + + // service and editable management + int m_mode; + + // services & editables + lay::MouseTracker *mp_tracker; + lay::ZoomService *mp_zoom_service; + lay::SelectionService *mp_selection_service; + lay::MoveService *mp_move_service; + + std::vector mp_plugins; + + bool m_visibility_changed; + + void init (db::Manager *mgr); + + void do_prop_changed (); + void do_redraw (int layer); + void do_redraw (); + + void set_view_ops (); + void background_color (lay::Color c); + void ctx_color (lay::Color c); + void ctx_dimming (int percent); + void ctx_hollow (bool h); + void child_ctx_color (lay::Color c); + void child_ctx_dimming (int percent); + void child_ctx_hollow (bool h); + void child_ctx_enabled (bool e); + void abstract_mode_width (double w); + void abstract_mode_enabled (bool e); + bool has_max_hier () const; + int max_hier_level () const; + bool set_hier_levels_basic (std::pair l); + + void update_event_handlers (); + void viewport_changed (); + void cellview_changed (unsigned int index); + + bool configure (const std::string &name, const std::string &value); + void config_finalize (); + + void do_load_layer_props (const std::string &fn, bool map_cv, int cv_index, bool add_default); + void finish_cellviews_changed (); + void init_layer_properties (LayerProperties &props, const LayerPropertiesList &lp_list) const; + void merge_dither_pattern (lay::LayerPropertiesList &props); + + // overrides Editables method to display a message + void signal_selection_changed (); + + lay::Plugin *create_plugin (const lay::PluginDeclaration *cls); + + std::list::iterator cellview_iter (int cv_index); + std::list::const_iterator cellview_iter (int cv_index) const; +}; + +} + +#endif diff --git a/src/laybasic/laybasic/layMouseTracker.h b/src/laybasic/laybasic/layMouseTracker.h index 3e826606b..2eb5c33e5 100644 --- a/src/laybasic/laybasic/layMouseTracker.h +++ b/src/laybasic/laybasic/layMouseTracker.h @@ -31,17 +31,17 @@ class QMouseEvent; namespace lay { class LayoutCanvas; -class LayoutView; +class LayoutViewBase; class MouseTracker : public lay::ViewService { public: - MouseTracker (lay::LayoutView *view); + MouseTracker (lay::LayoutViewBase *view); virtual bool mouse_move_event (const db::DPoint &p, unsigned int buttons, bool prio); private: - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; }; } diff --git a/src/laybasic/laybasic/layMove.h b/src/laybasic/laybasic/layMove.h index 0bea3f5a9..3908c6505 100644 --- a/src/laybasic/laybasic/layMove.h +++ b/src/laybasic/laybasic/layMove.h @@ -20,32 +20,24 @@ */ - - #ifndef HDR_layMove #define HDR_layMove #include "dbManager.h" #include "layViewObject.h" -#include -#include - #include namespace lay { class Editables; -class LayoutView; +class LayoutViewBase; -class MoveService - : public QObject, +class MoveService : public lay::ViewService { -Q_OBJECT - public: - MoveService (lay::LayoutView *view); + MoveService (lay::LayoutViewBase *view); ~MoveService (); virtual bool configure (const std::string &name, const std::string &value); @@ -67,7 +59,7 @@ private: bool m_dragging; bool m_dragging_transient; lay::Editables *mp_editables; - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; double m_global_grid; db::DPoint m_shift; db::DPoint m_mouse_pos; diff --git a/src/laybasic/laybasic/layParsedLayerSource.cc b/src/laybasic/laybasic/layParsedLayerSource.cc index da2c51a16..5e7dee250 100644 --- a/src/laybasic/laybasic/layParsedLayerSource.cc +++ b/src/laybasic/laybasic/layParsedLayerSource.cc @@ -22,7 +22,7 @@ #include "layParsedLayerSource.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "tlString.h" #include "tlGlobPattern.h" @@ -1163,7 +1163,7 @@ ParsedLayerSource::to_string () const } std::string -ParsedLayerSource::display_string (const lay::LayoutView *view) const +ParsedLayerSource::display_string (const lay::LayoutViewBase *view) const { std::string r; diff --git a/src/laybasic/laybasic/layParsedLayerSource.h b/src/laybasic/laybasic/layParsedLayerSource.h index e3bbfa511..e2c7936bf 100644 --- a/src/laybasic/laybasic/layParsedLayerSource.h +++ b/src/laybasic/laybasic/layParsedLayerSource.h @@ -43,7 +43,7 @@ namespace lay { class LayerProperties; -class LayoutView; +class LayoutViewBase; class PropertySelectorBase; /** @@ -640,7 +640,7 @@ public: * This method delivers a display version that may be abbreviated and is supposed * to be used in the layer list display. */ - std::string display_string (const lay::LayoutView *view) const; + std::string display_string (const lay::LayoutViewBase *view) const; /** * @brief Comparison (equality) diff --git a/src/laybasic/laybasic/layPlugin.h b/src/laybasic/laybasic/layPlugin.h index 8f634c0a9..c03fae38e 100644 --- a/src/laybasic/laybasic/layPlugin.h +++ b/src/laybasic/laybasic/layPlugin.h @@ -48,7 +48,7 @@ namespace lay class Plugin; class Dispatcher; -class LayoutView; +class LayoutViewBase; class ViewService; class Editable; class Drawing; @@ -302,7 +302,7 @@ public: * This method may return 0 for "dummy" plugins that just register menu entries * or configuration options. */ - virtual lay::Plugin *create_plugin (db::Manager * /*manager*/, lay::Dispatcher * /*dispatcher*/, lay::LayoutView * /*view*/) const + virtual lay::Plugin *create_plugin (db::Manager * /*manager*/, lay::Dispatcher * /*dispatcher*/, lay::LayoutViewBase * /*view*/) const { return 0; } @@ -329,7 +329,7 @@ public: * * The new pages are returned in the "pages" vector. The layout view will take ownership of these pages. */ - virtual void get_editor_options_pages (std::vector & /*pages*/, lay::LayoutView * /*view*/, lay::Dispatcher * /*dispatcher*/) const + virtual void get_editor_options_pages (std::vector & /*pages*/, lay::LayoutViewBase * /*view*/, lay::Dispatcher * /*dispatcher*/) const { // .. no pages in the default implementation .. } @@ -351,8 +351,8 @@ public: /** * @brief Specifies the primary mouse modes * - * These are built-in modes from the LayoutView. This method is intended for - * the LayoutView's standard modes only. + * These are built-in modes from the LayoutViewBase. This method is intended for + * the LayoutViewBase's standard modes only. */ virtual void implements_primary_mouse_modes (std::vector > > & /*modes*/) { diff --git a/src/laybasic/laybasic/laySelector.h b/src/laybasic/laybasic/laySelector.h index b7f5f5e22..f804b243e 100644 --- a/src/laybasic/laybasic/laySelector.h +++ b/src/laybasic/laybasic/laySelector.h @@ -30,23 +30,29 @@ #include "layViewObject.h" #include "layEditable.h" -#include -#include +#if defined (HAVE_QT) +# include +# include +#endif namespace lay { class RubberBox; -class LayoutView; +class LayoutViewBase; class LayoutCanvas; -class LAYBASIC_PUBLIC SelectionService - : public QObject, +class LAYBASIC_PUBLIC SelectionService : +#if defined (HAVE_QT) + public QObject, +#endif public lay::ViewService { +#if defined (HAVE_QT) Q_OBJECT +#endif public: - SelectionService (lay::LayoutView *view); + SelectionService (lay::LayoutViewBase *view); ~SelectionService (); void set_colors (lay::Color background, lay::Color color); @@ -72,8 +78,10 @@ public: */ void hover_reset (); +#if defined (HAVE_QT) public slots: void timeout (); +#endif private: virtual void deactivated (); @@ -84,11 +92,13 @@ private: lay::RubberBox *mp_box; unsigned int m_color; unsigned int m_buttons; - QTimer m_timer; bool m_hover; bool m_hover_wait; db::DPoint m_hover_point; bool m_mouse_in_window; +#if defined (HAVE_QT) + QTimer m_timer; +#endif void reset_box (); }; diff --git a/src/laybasic/laybasic/layZoomBox.h b/src/laybasic/laybasic/layZoomBox.h index a0a497a83..7794c6473 100644 --- a/src/laybasic/laybasic/layZoomBox.h +++ b/src/laybasic/laybasic/layZoomBox.h @@ -30,7 +30,7 @@ namespace lay { -class LayoutView; +class LayoutViewBase; class LayoutCanvas; class RubberBox; @@ -38,7 +38,7 @@ class LAYBASIC_PUBLIC ZoomService : public lay::ViewService { public: - ZoomService (lay::LayoutView *view); + ZoomService (lay::LayoutViewBase *view); ~ZoomService (); void set_colors (lay::Color background, lay::Color text); @@ -55,7 +55,7 @@ private: db::DPoint m_p1, m_p2; db::DBox m_vp; - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; lay::RubberBox *mp_box; unsigned int m_color; }; diff --git a/src/laybasic/laybasic/laybasic.pro b/src/laybasic/laybasic/laybasic.pro index 5c370f207..6010e29b0 100644 --- a/src/laybasic/laybasic/laybasic.pro +++ b/src/laybasic/laybasic/laybasic.pro @@ -273,6 +273,7 @@ SOURCES += \ layStipplePalette.cc \ layStream.cc \ layCanvasPlane.cc \ + layLayoutViewBase.cc \ layLayerProperties.cc \ layViewObject.cc \ layViewOp.cc \ @@ -289,6 +290,7 @@ HEADERS += \ layEditable.h \ layFinder.h \ layFixedFont.h \ + layLayoutViewBase.h \ layLineStylePalette.h \ layLineStyles.h \ layMarker.h \ From 2378f7964e1f3ae1a222a06a7b0565cd7f462530 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 30 Apr 2022 19:13:36 +0200 Subject: [PATCH 08/88] WIP --- src/laybasic/laybasic/layLayoutView.cc | 5222 +------------------- src/laybasic/laybasic/layLayoutView.h | 148 +- src/laybasic/laybasic/layLayoutViewBase.cc | 361 +- src/laybasic/laybasic/layLayoutViewBase.h | 99 +- src/laybasic/laybasic/layMouseTracker.cc | 2 +- 5 files changed, 247 insertions(+), 5585 deletions(-) diff --git a/src/laybasic/laybasic/layLayoutView.cc b/src/laybasic/laybasic/layLayoutView.cc index 9fd12f057..0cfd4853a 100644 --- a/src/laybasic/laybasic/layLayoutView.cc +++ b/src/laybasic/laybasic/layLayoutView.cc @@ -85,245 +85,37 @@ namespace lay { -// factor for "zoom in & out" -const double zoom_factor = 0.7; - -// factor by which panning is faster in "fast" (+Shift) mode -const double fast_factor = 3.0; - // ------------------------------------------------------------- -struct OpHideShowCell - : public db::Op -{ - OpHideShowCell (lay::CellView::cell_index_type ci, int cv_index, bool show) - : m_cell_index (ci), m_cellview_index (cv_index), m_show (show) - { } - - lay::CellView::cell_index_type m_cell_index; - int m_cellview_index; - bool m_show; -}; - -struct OpSetDitherPattern - : public db::Op -{ - OpSetDitherPattern (const lay::DitherPattern &o, const lay::DitherPattern &n) - : db::Op (), m_old (o), m_new (n) - { - // nothing yet. - } - - lay::DitherPattern m_old, m_new; -}; - -struct OpSetLineStyles - : public db::Op -{ - OpSetLineStyles (const lay::LineStyles &o, const lay::LineStyles &n) - : db::Op (), m_old (o), m_new (n) - { - // nothing yet. - } - - lay::LineStyles m_old, m_new; -}; - -struct OpSetLayerProps - : public db::Op -{ - OpSetLayerProps (unsigned int li, unsigned int i, const lay::LayerProperties &o, const lay::LayerProperties &n) - : m_list_index (li), m_index (i), m_old (o), m_new (n) - { - // .. nothing yet .. - } - - unsigned int m_list_index; - size_t m_index; - lay::LayerProperties m_old, m_new; -}; - -struct OpSetLayerPropsNode - : public db::Op -{ - OpSetLayerPropsNode (unsigned int li, unsigned int i, const lay::LayerPropertiesNode &o, const lay::LayerPropertiesNode &n) - : m_list_index (li), m_index (i), m_old (o), m_new (n) - { - // .. nothing yet .. - } - - unsigned int m_list_index; - size_t m_index; - lay::LayerPropertiesNode m_old, m_new; -}; - -struct OpDeleteLayerList - : public db::Op -{ - OpDeleteLayerList (unsigned int li, const lay::LayerPropertiesList &o) - : m_list_index (li), m_old (o) - { - // .. nothing yet .. - } - - unsigned int m_list_index; - lay::LayerPropertiesList m_old; -}; - -struct OpInsertLayerList - : public db::Op -{ - OpInsertLayerList (unsigned int li, const lay::LayerPropertiesList &n) - : m_list_index (li), m_new (n) - { - // .. nothing yet .. - } - - unsigned int m_list_index; - lay::LayerPropertiesList m_new; -}; - -struct OpRenameProps - : public db::Op -{ - OpRenameProps (unsigned int li, const std::string &old_name, const std::string &new_name) - : m_list_index (li), m_old (old_name), m_new (new_name) - { - // .. nothing yet .. - } - - unsigned int m_list_index; - std::string m_old, m_new; -}; - -struct OpSetAllProps - : public db::Op -{ - OpSetAllProps (unsigned int li, const lay::LayerPropertiesList &o, const lay::LayerPropertiesList &n) - : m_list_index (li), m_old (o), m_new (n) - { - // .. nothing yet .. - } - - unsigned int m_list_index; - lay::LayerPropertiesList m_old, m_new; -}; - -struct OpLayerList - : public db::Op -{ - enum Mode { Delete, Insert }; - - OpLayerList (unsigned int li, unsigned int i, const lay::LayerPropertiesNode &n, Mode m) - : m_list_index (li), m_index (i), m_mode (m), m_node (n) - { } - - unsigned int m_list_index; - size_t m_index; - Mode m_mode; - lay::LayerPropertiesNode m_node; -}; - -struct OpInsertLayerProps - : public OpLayerList -{ - OpInsertLayerProps (unsigned int li, unsigned int i, const lay::LayerPropertiesNode &n) - : OpLayerList (li, i, n, Insert) - { - // .. nothing yet .. - } -}; - -struct OpDeleteLayerProps - : public OpLayerList -{ - OpDeleteLayerProps (unsigned int li, unsigned int i, const lay::LayerPropertiesNode &n) - : OpLayerList (li, i, n, Delete) - { - // .. nothing yet .. - } -}; - -// ------------------------------------------------------------- - -const int timer_interval = 500; +const int timer_interval = 10; static LayoutView *ms_current = 0; LayoutView::LayoutView (db::Manager *manager, bool editable, lay::Plugin *plugin_parent, QWidget *parent, const char *name, unsigned int options) - : QFrame (parent), - lay::Dispatcher (this, plugin_parent, false /*not standalone*/), - m_editable (editable), - m_options (options), - m_annotation_shapes (manager), - dm_prop_changed (this, &LayoutView::do_prop_changed), + : QFrame (parent), + LayoutViewBase (manager, editable, plugin_parent, options), dm_setup_editor_option_pages (this, &LayoutView::do_setup_editor_options_pages) { - // either it's us or the parent has a dispatcher - tl_assert (dispatcher () != 0); - // ensures the deferred method scheduler is present tl::DeferredMethodScheduler::instance (); setObjectName (QString::fromUtf8(name)); - init (manager, parent); + init_ui (); } LayoutView::LayoutView (lay::LayoutView *source, db::Manager *manager, bool editable, lay::Plugin *plugin_parent, QWidget *parent, const char *name, unsigned int options) : QFrame (parent), - lay::Dispatcher (plugin_parent, false /*not standalone*/), - m_editable (editable), - m_options (options), - m_annotation_shapes (manager), - dm_prop_changed (this, &LayoutView::do_prop_changed), + LayoutViewBase (source, manager, editable, plugin_parent, options), dm_setup_editor_option_pages (this, &LayoutView::do_setup_editor_options_pages) { - // either it's us or the parent has a dispatcher - tl_assert (dispatcher () != 0); - // ensures the deferred method scheduler is present tl::DeferredMethodScheduler::instance (); setObjectName (QString::fromUtf8 (name)); - - m_annotation_shapes = source->m_annotation_shapes; - - init (manager, parent); - - // set the handle reference and clear all cell related stuff - m_cellviews = source->cellview_list (); - m_hidden_cells = source->m_hidden_cells; - - // clear the history, store path and zoom box - m_display_states.clear (); - m_display_state_ptr = 0; - m_synchronous = source->synchronous (); - m_drawing_workers = source->drawing_workers (); - - // duplicate the layer properties - for (size_t i = 0; i < source->m_layer_properties_lists.size (); ++i) { - if (i >= m_layer_properties_lists.size ()) { - m_layer_properties_lists.push_back (new lay::LayerPropertiesList (*source->m_layer_properties_lists [i])); - } else { - *m_layer_properties_lists [i] = *source->m_layer_properties_lists [i]; - } - m_layer_properties_lists [i]->attach_view (this, (unsigned int) i); - } - - if (! m_layer_properties_lists.empty ()) { - mp_canvas->set_dither_pattern (m_layer_properties_lists [0]->dither_pattern ()); - } + init_ui (); bookmarks (source->bookmarks ()); - set_active_cellview_index (source->active_cellview_index ()); - - // copy the title - m_title = source->m_title; - - layer_list_changed_event (3); - - finish_cellviews_changed (); } bool @@ -370,120 +162,15 @@ LayoutView::init_menu () } void -LayoutView::init (db::Manager *mgr, QWidget * /*parent*/) +LayoutView::init_ui () { - manager (mgr); - - if (dispatcher () == this) { - // if we're the root dispatcher initialize the menu and build the context menus. No other menus are built so far. - init_menu (); - menu ()->build (0, 0); - } - - m_annotation_shapes.manager (mgr); - - m_visibility_changed = false; - m_active_cellview_changed_event_enabled = true; - m_disabled_edits = 0; - m_synchronous = false; - m_drawing_workers = 1; - mp_control_panel = 0; - mp_control_frame = 0; - mp_hierarchy_panel = 0; - mp_hierarchy_frame = 0; - mp_libraries_view = 0; - mp_bookmarks_view = 0; - mp_libraries_frame = 0; - mp_editor_options_frame = 0; - mp_bookmarks_frame = 0; - mp_min_hier_spbx = 0; - mp_max_hier_spbx = 0; - m_from_level = 0; - m_pan_distance = 0.15; - m_wheel_mode = 0; - m_paste_display_mode = 2; - m_guiding_shape_visible = true; - m_guiding_shape_line_width = 1; - m_guiding_shape_color = lay::Color (); - m_guiding_shape_vertex_size = 5; - m_to_level = 0; - m_ctx_dimming = 50; - m_ctx_hollow = false; - m_child_ctx_dimming = 50; - m_child_ctx_hollow = false; - m_child_ctx_enabled = false; - m_abstract_mode_width = 10.0; - m_abstract_mode_enabled = false; - m_box_text_transform = true; - m_box_font = 0; - m_min_size_for_label = 16; - m_cell_box_visible = true; - m_text_visible = true; - m_default_font_size = lay::FixedFont::default_font_size (); - m_text_lazy_rendering = true; - m_bitmap_caching = true; - m_show_properties = false; - m_apply_text_trans = true; - m_default_text_size = 0.1; - m_text_font = 0; - m_show_markers = true; - m_no_stipples = false; - m_stipple_offset = true; - m_fit_new_cell = true; - m_full_hier_new_cell = true; - m_clear_ruler_new_cell = false; - m_dbu_coordinates = false; - m_absolute_coordinates = false; - m_drop_small_cells = false; - m_drop_small_cells_value = 10; - m_drop_small_cells_cond = DSC_Max; - m_draw_array_border_instances = false; - m_dirty = false; m_activated = true; - m_animated = false; - m_phase = 0; - m_palette = lay::ColorPalette::default_palette (); - m_stipple_palette = lay::StipplePalette::default_palette (); - m_display_state_ptr = 0; - m_mode = std::numeric_limits::min (); // nothing selected yet. - mp_tracker = 0; - mp_zoom_service = 0; - mp_selection_service = 0; - mp_move_service = 0; - m_marker_line_width = 0; - m_marker_vertex_size = 0; - m_marker_dither_pattern = 1; - m_marker_line_style = 0; - m_marker_halo = true; - m_transient_selection_mode = true; - m_sel_inside_pcells = false; - m_add_other_layers = false; - m_always_show_source = false; - m_always_show_ld = true; - m_always_show_layout_index = false; - m_search_range = 5; - m_search_range_box = 0; - - m_layer_properties_lists.push_back (new LayerPropertiesList ()); - m_layer_properties_lists.back ()->attach_view (this, (unsigned int) (m_layer_properties_lists.size () - 1)); - m_current_layer_list = 0; QVBoxLayout *vbl = new QVBoxLayout (this); vbl->setContentsMargins (0, 0, 0, 0); vbl->setSpacing (0); - mp_canvas = new lay::LayoutCanvas (this, this); - vbl->addWidget (mp_canvas); - connect (mp_canvas, SIGNAL (left_arrow_key_pressed ()), this, SLOT (pan_left ())); - connect (mp_canvas, SIGNAL (up_arrow_key_pressed ()), this, SLOT (pan_up ())); - connect (mp_canvas, SIGNAL (right_arrow_key_pressed ()), this, SLOT (pan_right ())); - connect (mp_canvas, SIGNAL (down_arrow_key_pressed ()), this, SLOT (pan_down ())); - connect (mp_canvas, SIGNAL (left_arrow_key_pressed_with_shift ()), this, SLOT (pan_left_fast ())); - connect (mp_canvas, SIGNAL (up_arrow_key_pressed_with_shift ()), this, SLOT (pan_up_fast ())); - connect (mp_canvas, SIGNAL (right_arrow_key_pressed_with_shift ()), this, SLOT (pan_right_fast ())); - connect (mp_canvas, SIGNAL (down_arrow_key_pressed_with_shift ()), this, SLOT (pan_down_fast ())); - - if ((m_options & LV_NoHierarchyPanel) == 0 && (m_options & LV_Naked) == 0) { + if ((options () & LV_NoHierarchyPanel) == 0 && (options () & LV_Naked) == 0) { QFrame *hierarchy_frame = new QFrame (0); hierarchy_frame->setObjectName (QString::fromUtf8 ("left")); @@ -530,7 +217,7 @@ LayoutView::init (db::Manager *mgr, QWidget * /*parent*/) } - if ((m_options & LV_NoBookmarksView) == 0 && (m_options & LV_Naked) == 0) { + if ((options () & LV_NoBookmarksView) == 0 && (options () & LV_Naked) == 0) { QFrame *bookmarks_frame = new QFrame (0); bookmarks_frame->setObjectName (QString::fromUtf8 ("bookmarks_frame")); @@ -546,7 +233,7 @@ LayoutView::init (db::Manager *mgr, QWidget * /*parent*/) } - if ((m_options & LV_NoLibrariesView) == 0 && (m_options & LV_Naked) == 0) { + if ((options () & LV_NoLibrariesView) == 0 && (options () & LV_Naked) == 0) { mp_libraries_frame = new QFrame (0); mp_libraries_frame->setObjectName (QString::fromUtf8 ("libs_frame")); @@ -562,7 +249,7 @@ LayoutView::init (db::Manager *mgr, QWidget * /*parent*/) } - if ((m_options & LV_NoEditorOptionsPanel) == 0 && (m_options & LV_Naked) == 0) { + if ((options () & LV_NoEditorOptionsPanel) == 0 && (options () & LV_Naked) == 0) { mp_editor_options_frame = new lay::EditorOptionsFrame (0); mp_editor_options_frame->populate (this); @@ -571,22 +258,7 @@ LayoutView::init (db::Manager *mgr, QWidget * /*parent*/) } - // occupy services and editables: - // these services get deleted by the canvas destructor automatically: - if ((m_options & LV_NoTracker) == 0) { - mp_tracker = new lay::MouseTracker (this); - } - if ((m_options & LV_NoZoom) == 0) { - mp_zoom_service = new lay::ZoomService (this); - } - if ((m_options & LV_NoSelection) == 0) { - mp_selection_service = new lay::SelectionService (this); - } - if ((m_options & LV_NoMove) == 0) { - mp_move_service = new lay::MoveService (this); - } - - if ((m_options & LV_NoLayers) == 0 && (m_options & LV_Naked) == 0) { + if ((options () & LV_NoLayers) == 0 && (options () & LV_Naked) == 0) { mp_control_panel = new lay::LayerControlPanel (this, manager (), 0, "lcp"); mp_control_frame = mp_control_panel; @@ -620,69 +292,6 @@ LayoutView::~LayoutView () { close_event (); - if (ms_current == this) { - ms_current = 0; - } - - // detach all observers - // This is to prevent signals to partially destroyed observers that own a LayoutView - close_event.clear (); - layer_list_changed_event.clear (); - layer_list_deleted_event.clear (); - layer_list_inserted_event.clear (); - current_layer_list_changed_event.clear (); - cell_visibility_changed_event.clear (); - cellviews_about_to_change_event.clear (); - cellview_about_to_change_event.clear (); - cellviews_changed_event.clear (); - cellview_changed_event.clear (); - rdb_list_changed_event.clear (); - l2ndb_list_changed_event.clear (); - file_open_event.clear (); - hier_changed_event.clear (); - geom_changed_event.clear (); - annotations_changed_event.clear (); - - // detach ourselves from any observed objects to prevent signals while destroying - tl::Object::detach_from_all_events (); - - // remove all rdb's - while (num_rdbs () > 0) { - remove_rdb (0); - } - - // remove all L2N DB's - while (num_l2ndbs () > 0) { - remove_l2ndb (0); - } - - // delete layer lists - std::vector layer_properties_lists; - layer_properties_lists.swap (m_layer_properties_lists); - for (std::vector::iterator l = layer_properties_lists.begin (); l != layer_properties_lists.end (); ++l) { - if (*l) { - delete *l; - } - } - - // delete all plugins - std::vector plugins; - plugins.swap (mp_plugins); - for (std::vector::iterator p = plugins.begin (); p != plugins.end (); ++p) { - delete *p; - } - - // detach from the manager, so we can safely delete the manager - manager (0); - - stop (); - - // because LayoutView and LayoutCanvas both control lifetimes of - // ruler objects for example, it is safer to explicitly delete the - // LayoutCanvas object here: - delete mp_canvas; - mp_canvas = 0; - if (mp_control_frame) { delete mp_control_frame; } @@ -785,83 +394,9 @@ LayoutView *LayoutView::current () return ms_current; } -void LayoutView::update_event_handlers () -{ - tl::Object::detach_from_all_events (); - - for (std::vector::iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) { - // TODO: get rid of the const_cast hack - const_cast ((*p)->plugin_declaration ())->editable_enabled_changed_event.add (this, &LayoutView::signal_plugin_enabled_changed); - } - - for (unsigned int i = 0; i < cellviews (); ++i) { - cellview (i)->layout ().hier_changed_event.add (this, &LayoutView::signal_hier_changed); - cellview (i)->layout ().bboxes_changed_event.add (this, &LayoutView::signal_bboxes_from_layer_changed, i); - cellview (i)->layout ().dbu_changed_event.add (this, &LayoutView::signal_bboxes_changed); - cellview (i)->layout ().prop_ids_changed_event.add (this, &LayoutView::signal_prop_ids_changed); - cellview (i)->layout ().layer_properties_changed_event.add (this, &LayoutView::signal_layer_properties_changed); - cellview (i)->layout ().cell_name_changed_event.add (this, &LayoutView::signal_cell_name_changed); - cellview (i)->apply_technology_with_sender_event.add (this, &LayoutView::signal_apply_technology); - } - - annotation_shapes ().bboxes_changed_any_event.add (this, &LayoutView::signal_annotations_changed); - - mp_canvas->viewport_changed_event.add (this, &LayoutView::viewport_changed); -} - -void LayoutView::viewport_changed () -{ - viewport_changed_event (); -} - -bool LayoutView::accepts_drop (const std::string &path_or_url) const -{ - for (std::vector::const_iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) { - if ((*p)->accepts_drop (path_or_url)) { - return true; - } - } - return false; -} - -void LayoutView::drop_url (const std::string &path_or_url) -{ - for (std::vector::const_iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) { - if ((*p)->accepts_drop (path_or_url)) { - (*p)->drop_url (path_or_url); - break; - } - } -} - -lay::Plugin *LayoutView::create_plugin (const lay::PluginDeclaration *cls) -{ - lay::Plugin *p = cls->create_plugin (manager (), dispatcher (), this); - if (p) { - - // unhook the plugin from the script side if created there (prevent GC from destroying it) - p->gsi::ObjectBase::keep (); - - mp_plugins.push_back (p); - p->set_plugin_declaration (cls); - - // enable editable functionality - if (p->editable_interface ()) { - enable (p->editable_interface (), cls->editable_enabled ()); - } - - update_event_handlers (); - - } - return p; -} - void LayoutView::create_plugins (const lay::PluginDeclaration *except_this) { - for (std::vector::iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) { - delete *p; - } - mp_plugins.clear (); + clear_plugins (); // create the plugins for (tl::Registrar::iterator cls = tl::Registrar::begin (); cls != tl::Registrar::end (); ++cls) { @@ -872,10 +407,10 @@ void LayoutView::create_plugins (const lay::PluginDeclaration *except_this) if (cls.current_name () == "ant::Plugin" || cls.current_name () == "img::Plugin") { // ant and img are created always create_plugin (&*cls); - } else if ((m_options & LV_NoPlugins) == 0) { + } else if ((options () & LV_NoPlugins) == 0) { // others: only create unless LV_NoPlugins is set create_plugin (&*cls); - } else if ((m_options & LV_NoGrid) == 0 && cls.current_name () == "GridNetPlugin") { + } else if ((options () & LV_NoGrid) == 0 && cls.current_name () == "GridNetPlugin") { // except grid net plugin which is created on request create_plugin (&*cls); } @@ -889,26 +424,6 @@ void LayoutView::create_plugins (const lay::PluginDeclaration *except_this) mode (default_mode ()); } -Plugin *LayoutView::get_plugin_by_name (const std::string &name) const -{ - lay::PluginDeclaration *decl = 0; - for (tl::Registrar::iterator cls = tl::Registrar::begin (); !decl && cls != tl::Registrar::end (); ++cls) { - if (cls.current_name () == name) { - decl = cls.operator-> (); - } - } - - if (decl) { - for (std::vector::const_iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) { - if ((*p)->plugin_declaration () == decl) { - return *p; - } - } - } - - return 0; -} - namespace { class GotoBookmarkAction @@ -963,119 +478,14 @@ LayoutView::update_menu (lay::LayoutView *view, lay::AbstractMenu &menu) } } -void -LayoutView::set_drawing_workers (int workers) -{ - m_drawing_workers = std::max (0, std::min (100, workers)); -} - -void -LayoutView::set_synchronous (bool s) -{ - m_synchronous = s; -} - -bool -LayoutView::is_dirty () const -{ - return m_dirty; -} - -std::string -LayoutView::title () const -{ - if (! m_title.empty ()) { - return m_title; - } else if (cellviews () == 0) { - return tl::to_string (QObject::tr ("")); - } else { - - int cv_index = active_cellview_index (); - if (cv_index < 0 || cv_index >= int (cellviews ())) { - cv_index = 0; - } - - const lay::CellView &cv0 = cellview (cv_index); - - std::string t; - - t += cv0->name (); - if (cv0->layout ().is_valid_cell_index (cv0.cell_index ())) { - t += " ["; - t += cv0->layout ().cell_name (cv0.cell_index ()); - t += "]"; - } - - if (cellviews () > 1) { - t += " ..."; - } - - return t; - - } -} - -void -LayoutView::set_title (const std::string &t) -{ - if (m_title != t) { - m_title = t; - emit title_changed (); - } -} - -void -LayoutView::reset_title () -{ - if (! m_title.empty ()) { - m_title = ""; - emit title_changed (); - } -} - bool LayoutView::configure (const std::string &name, const std::string &value) { - lay::Dispatcher::configure (name, value); - - if (mp_move_service && mp_move_service->configure (name, value)) { + if (LayoutViewBase::configure (name, value)) { return true; } - if (name == cfg_default_lyp_file) { - - m_def_lyp_file = value; - return false; // not taken - let others set it too. - - } else if (name == cfg_default_add_other_layers) { - - tl::from_string (value, m_add_other_layers); - return false; // not taken - let others set it too. - - } else if (name == cfg_layers_always_show_source) { - - bool a = false; - tl::from_string (value, a); - if (a != m_always_show_source) { - m_always_show_source = a; - layer_list_changed_event (4); - } - - return true; - - } else if (name == cfg_layers_always_show_ld) { - - tl::from_string (value, m_always_show_ld); - update_content (); - return true; - - } else if (name == cfg_layers_always_show_layout_index) { - - tl::from_string (value, m_always_show_layout_index); - update_content (); - return true; - - } else if (name == cfg_flat_cell_list) { + if (name == cfg_flat_cell_list) { bool f; tl::from_string (value, f); @@ -1149,522 +559,6 @@ LayoutView::configure (const std::string &name, const std::string &value) } return true; - } else if (name == cfg_background_color) { - - lay::Color color; - ColorConverter ().from_string (value, color); - background_color (color); - // do not take - let others receive the background color events as well - return false; - - } else if (name == cfg_default_font_size) { - - int df = 0; - tl::from_string (value, df); - if (m_default_font_size != df) { - // keep a shadow state to correctly issue the redraw call - m_default_font_size = df; - lay::FixedFont::set_default_font_size (df); - redraw (); - } - // do not take - let others have the event for the redraw call - return false; - - } else if (name == cfg_bitmap_oversampling) { - - int os = 1; - tl::from_string (value, os); - mp_canvas->set_oversampling (os); - return true; - - } else if (name == cfg_image_cache_size) { - - int sz = 0; - tl::from_string (value, sz); - mp_canvas->set_image_cache_size (size_t (sz)); - return true; - - } else if (name == cfg_global_trans) { - - tl::Extractor ex (value.c_str ()); - try { - db::DCplxTrans t; - ex.read (t); - set_global_trans (t); - } catch (...) { } - return true; - - } else if (name == cfg_ctx_color) { - - lay::Color color; - ColorConverter ().from_string (value, color); - ctx_color (color); - return true; - - } else if (name == cfg_ctx_dimming) { - - int n; - tl::from_string (value, n); - ctx_dimming (n); - return true; - - } else if (name == cfg_ctx_hollow) { - - bool h; - tl::from_string (value, h); - ctx_hollow (h); - return true; - - } else if (name == cfg_child_ctx_color) { - - lay::Color color; - ColorConverter ().from_string (value, color); - child_ctx_color (color); - return true; - - } else if (name == cfg_child_ctx_dimming) { - - int n; - tl::from_string (value, n); - child_ctx_dimming (n); - return true; - - } else if (name == cfg_child_ctx_hollow) { - - bool h; - tl::from_string (value, h); - child_ctx_hollow (h); - return true; - - } else if (name == cfg_child_ctx_enabled) { - - bool h; - tl::from_string (value, h); - child_ctx_enabled (h); - return true; - - } else if (name == cfg_search_range) { - - unsigned int n; - tl::from_string (value, n); - set_search_range (n); - return true; - - } else if (name == cfg_search_range_box) { - - unsigned int n; - tl::from_string (value, n); - set_search_range_box (n); - return true; - - } else if (name == cfg_abstract_mode_enabled) { - - bool e; - tl::from_string (value, e); - abstract_mode_enabled (e); - return true; - - } else if (name == cfg_abstract_mode_width) { - - double w; - tl::from_string (value, w); - abstract_mode_width (w); - return true; - - } else if (name == cfg_min_inst_label_size) { - - int n; - tl::from_string (value, n); - min_inst_label_size (n); - return true; - - } else if (name == cfg_cell_box_text_font) { - - int n; - tl::from_string (value, n); - cell_box_text_font (n); - return true; - - } else if (name == cfg_cell_box_text_transform) { - - bool flag; - tl::from_string (value, flag); - cell_box_text_transform (flag); - return true; - - } else if (name == cfg_cell_box_visible) { - - bool flag; - tl::from_string (value, flag); - cell_box_visible (flag); - return true; - - } else if (name == cfg_cell_box_color) { - - lay::Color color; - ColorConverter ().from_string (value, color); - cell_box_color (color); - return true; - - } else if (name == cfg_text_color) { - - lay::Color color; - ColorConverter ().from_string (value, color); - text_color (color); - return true; - - } else if (name == cfg_text_visible) { - - bool flag; - tl::from_string (value, flag); - text_visible (flag); - return true; - - } else if (name == cfg_bitmap_caching) { - - bool flag; - tl::from_string (value, flag); - bitmap_caching (flag); - return true; - - } else if (name == cfg_text_lazy_rendering) { - - bool flag; - tl::from_string (value, flag); - text_lazy_rendering (flag); - return true; - - } else if (name == cfg_show_properties) { - - bool flag; - tl::from_string (value, flag); - show_properties_as_text (flag); - return true; - - } else if (name == cfg_apply_text_trans) { - - bool flag; - tl::from_string (value, flag); - apply_text_trans (flag); - return true; - - } else if (name == cfg_markers_visible) { - - bool flag; - tl::from_string (value, flag); - mp_canvas->set_dismiss_view_objects (! flag); - return true; - - } else if (name == cfg_no_stipple) { - - bool flag; - tl::from_string (value, flag); - no_stipples (flag); - return true; - - } else if (name == cfg_stipple_offset) { - - bool flag; - tl::from_string (value, flag); - offset_stipples (flag); - return true; - - } else if (name == cfg_default_text_size) { - - double sz; - tl::from_string (value, sz); - default_text_size (sz); - return true; - - } else if (name == cfg_text_font) { - - int n; - tl::from_string (value, n); - text_font (n); - return true; - - } else if (name == cfg_full_hier_new_cell) { - - bool flag; - tl::from_string (value, flag); - full_hier_new_cell (flag); - return true; - - } else if (name == cfg_fit_new_cell) { - - bool flag; - tl::from_string (value, flag); - fit_new_cell (flag); - return true; - - } else if (name == cfg_clear_ruler_new_cell) { - - bool flag; - tl::from_string (value, flag); - clear_ruler_new_cell (flag); - return true; - - } else if (name == cfg_abs_units) { - - bool flag; - tl::from_string (value, flag); - absolute_coordinates (flag); - return true; - - } else if (name == cfg_guiding_shape_visible) { - - bool v = false; - tl::from_string (value, v); - guiding_shapes_visible (v); - return true; - - } else if (name == cfg_guiding_shape_line_width) { - - int v = 0; - tl::from_string (value, v); - guiding_shapes_line_width (v); - return true; - - } else if (name == cfg_guiding_shape_color) { - - lay::Color color; - ColorConverter ().from_string (value, color); - guiding_shapes_color (color); - return true; - - } else if (name == cfg_guiding_shape_color) { - - lay::Color color; - ColorConverter ().from_string (value, color); - guiding_shapes_color (color); - return true; - - } else if (name == cfg_guiding_shape_vertex_size) { - - int v = 0; - tl::from_string (value, v); - guiding_shapes_vertex_size (v); - return true; - - } else if (name == cfg_paste_display_mode) { - - tl::from_string (value, m_paste_display_mode); - return true; - - } else if (name == cfg_mouse_wheel_mode) { - - tl::from_string (value, m_wheel_mode); - return true; - - } else if (name == cfg_pan_distance) { - - double pd; - tl::from_string (value, pd); - pan_distance (pd); - return true; - - } else if (name == cfg_drawing_workers) { - - int workers; - tl::from_string (value, workers); - set_drawing_workers (workers); - return true; - - } else if (name == cfg_drop_small_cells) { - - bool flag; - tl::from_string (value, flag); - drop_small_cells (flag); - return true; - - } else if (name == cfg_drop_small_cells_cond) { - - unsigned int n; - tl::from_string (value, n); - drop_small_cells_cond (drop_small_cells_cond_type (n)); - return true; - - } else if (name == cfg_drop_small_cells_value) { - - unsigned int n; - tl::from_string (value, n); - drop_small_cells_value (n); - return true; - - } else if (name == cfg_array_border_instances) { - - bool f; - tl::from_string (value, f); - draw_array_border_instances (f); - return true; - - } else if (name == cfg_dbu_units) { - - bool flag; - tl::from_string (value, flag); - dbu_coordinates (flag); - return true; - - } else if (name == cfg_stipple_palette) { - - lay::StipplePalette palette = lay::StipplePalette::default_palette (); - - try { - // empty string means: default palette - if (! value.empty ()) { - palette.from_string (value); - } - } catch (...) { - // ignore errors: just reset the palette - palette = lay::StipplePalette::default_palette (); - } - - set_palette (palette); - - // others need this property too .. - return false; - - } else if (name == cfg_line_style_palette) { - - lay::LineStylePalette palette = lay::LineStylePalette::default_palette (); - - try { - // empty string means: default palette - if (! value.empty ()) { - palette.from_string (value); - } - } catch (...) { - // ignore errors: just reset the palette - palette = lay::LineStylePalette::default_palette (); - } - - set_palette (palette); - - // others need this property too .. - return false; - - } else if (name == cfg_color_palette) { - - lay::ColorPalette palette = lay::ColorPalette::default_palette (); - - try { - // empty string means: default palette - if (! value.empty ()) { - palette.from_string (value); - } - } catch (...) { - // ignore errors: just reset the palette - palette = lay::ColorPalette::default_palette (); - } - - set_palette (palette); - - // others need this property too .. - return false; - - } else if (name == cfg_sel_inside_pcells_mode) { - - bool flag; - tl::from_string (value, flag); - - if (m_sel_inside_pcells != flag) { - m_sel_inside_pcells = flag; - clear_selection (); - } - - return true; - - } else if (name == cfg_sel_transient_mode) { - - bool flag; - tl::from_string (value, flag); - m_transient_selection_mode = flag; - - if (! m_transient_selection_mode) { - clear_transient_selection (); - } - - // do not take - let others receive this configuration as well - return false; - - } else if (name == cfg_sel_color) { - - lay::Color color; - lay::ColorConverter ().from_string (value, color); - - // Change the color - if (lay::test_and_set (m_marker_color, color)) { - mp_canvas->update_image (); - } - - // do not take - let others receive this configuration as well - return false; - - } else if (name == cfg_sel_line_width) { - - int lw = 0; - tl::from_string (value, lw); - - // Change the line width - if (lay::test_and_set (m_marker_line_width, lw)) { - mp_canvas->update_image (); - } - - // do not take - let others receive this configuration as well - return false; - - } else if (name == cfg_sel_dither_pattern) { - - int dp = 0; - tl::from_string (value, dp); - - // Change the vertex_size - if (lay::test_and_set (m_marker_dither_pattern, dp)) { - mp_canvas->update_image (); - } - - // do not take - let others receive this configuration as well - return false; - - } else if (name == cfg_sel_line_style) { - - int dp = 0; - tl::from_string (value, dp); - - // Change the vertex_size - if (lay::test_and_set (m_marker_line_style, dp)) { - mp_canvas->update_image (); - } - - // do not take - let others receive this configuration as well - return false; - - } else if (name == cfg_sel_vertex_size) { - - int vs = 0; - tl::from_string (value, vs); - - // Change the vertex_size - if (lay::test_and_set (m_marker_vertex_size, vs)) { - mp_canvas->update_image (); - } - - // do not take - let others receive this configuration as well - return false; - - } else if (name == cfg_sel_halo) { - - bool halo = 0; - tl::from_string (value, halo); - - // Change the vertex_size - if (lay::test_and_set (m_marker_halo, halo)) { - mp_canvas->update_image (); - } - - // do not take - let others receive this configuration as well - return false; - } else { return false; } @@ -1678,40 +572,6 @@ LayoutView::config_finalize () dm_setup_editor_option_pages (); } -void -LayoutView::enable_edits (bool enable) -{ - // enable or disable these services: - if (mp_selection_service) { - mp_selection_service->enable (enable); - } - if (mp_move_service) { - mp_move_service->enable (enable); - } - - // enable or disable the services that implement "lay::ViewService" - for (std::vector::iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) { - lay::ViewService *svc = (*p)->view_service_interface (); - if (svc) { - svc->enable (enable); - } - } - - bool is_enabled = edits_enabled (); - - if (enable) { - if (m_disabled_edits > 0) { - --m_disabled_edits; - } - } else { - ++m_disabled_edits; - } - - if (edits_enabled () != is_enabled) { - emit edits_enabled_changed (); - } -} - bool LayoutView::set_or_request_current_layer (unsigned int cv_index, const db::LayerProperties &lp) { @@ -1797,2201 +657,6 @@ LayoutView::set_selected_layers (const std::vectorline_styles () != styles) { - - if (transacting ()) { - manager ()->queue (this, new OpSetLineStyles (mp_canvas->line_styles (), styles)); - } else if (manager () && ! replaying ()) { - manager ()->clear (); - } - mp_canvas->set_line_styles (styles); - - for (unsigned int i = 0; i < layer_lists (); ++i) { - m_layer_properties_lists [i]->set_line_styles (styles); - } - - layer_list_changed_event (1); - - } -} - -void -LayoutView::set_dither_pattern (const lay::DitherPattern &pattern) -{ - if (mp_canvas->dither_pattern () != pattern) { - - if (transacting ()) { - manager ()->queue (this, new OpSetDitherPattern (mp_canvas->dither_pattern (), pattern)); - } else if (manager () && ! replaying ()) { - manager ()->clear (); - } - mp_canvas->set_dither_pattern (pattern); - - for (unsigned int i = 0; i < layer_lists (); ++i) { - m_layer_properties_lists [i]->set_dither_pattern (pattern); - } - - layer_list_changed_event (1); - - } -} - -const LayerPropertiesList & -LayoutView::get_properties (unsigned int index) const -{ - if (index >= layer_lists ()) { - static lay::LayerPropertiesList empty; - return empty; - } else { - return *m_layer_properties_lists [index]; - } -} - -void -LayoutView::set_current_layer_list (unsigned int index) -{ - if (index != m_current_layer_list && index < layer_lists ()) { - m_current_layer_list = index; - current_layer_list_changed_event (index); - redraw (); - } -} - -void -LayoutView::insert_layer_list (unsigned index, const LayerPropertiesList &props) -{ - if (index > layer_lists ()) { - return; - } - - if (transacting ()) { - manager ()->queue (this, new OpInsertLayerList (index, props)); - } else if (manager () && ! replaying ()) { - manager ()->clear (); - } - - m_layer_properties_lists.insert (m_layer_properties_lists.begin () + index, new LayerPropertiesList (props)); - m_layer_properties_lists [index]->attach_view (this, index); - merge_dither_pattern (*m_layer_properties_lists [index]); - - m_current_layer_list = index; - current_layer_list_changed_event (index); - - layer_list_inserted_event (index); - - redraw (); - - dm_prop_changed (); -} - -void -LayoutView::delete_layer_list (unsigned index) -{ - if (index >= layer_lists ()) { - return; - } - - if (transacting ()) { - manager ()->queue (this, new OpDeleteLayerList (index, *m_layer_properties_lists [index])); - } else if (manager () && ! replaying ()) { - manager ()->clear (); - } - - delete m_layer_properties_lists [index]; - m_layer_properties_lists.erase (m_layer_properties_lists.begin () + index); - - if (m_current_layer_list > index) { - - --m_current_layer_list; - current_layer_list_changed_event (m_current_layer_list); - - // don't tell the other observers because effectively nothing has changed. - - } else if (m_current_layer_list == index) { - - if (m_current_layer_list > 0) { - --m_current_layer_list; - } - - current_layer_list_changed_event (m_current_layer_list); - - // the current list has been deleted. - layer_list_changed_event (3); - - redraw (); - - } - - layer_list_deleted_event (index); - dm_prop_changed (); -} - -void -LayoutView::rename_properties (unsigned int index, const std::string &new_name) -{ - if (index >= layer_lists ()) { - return; - } - - if (transacting ()) { - manager ()->queue (this, new OpRenameProps (index, m_layer_properties_lists [index]->name (), new_name)); - } else if (manager () && ! replaying ()) { - manager ()->clear (); - } - - m_layer_properties_lists [index]->set_name (new_name); - - layer_list_changed_event (4); -} - -void -LayoutView::merge_dither_pattern (lay::LayerPropertiesList &props) -{ - { - lay::DitherPattern dp (dither_pattern ()); - - std::map index_map; - dp.merge (props.dither_pattern (), index_map); - - // remap the dither pattern index - for (lay::LayerPropertiesIterator l = props.begin_recursive (); l != props.end_recursive (); ++l) { - int dpi = l->dither_pattern (false /*local*/); - std::map ::iterator m = index_map.find ((unsigned int) dpi); - if (m != index_map.end ()) { - l->set_dither_pattern (int (m->second)); - } - } - - // install the new custom pattern table - if (mp_canvas->dither_pattern () != dp) { - mp_canvas->set_dither_pattern (dp); - for (unsigned int i = 0; i < layer_lists (); ++i) { - m_layer_properties_lists [i]->set_dither_pattern (dp); - } - } - } - - { - lay::LineStyles ls (line_styles ()); - - std::map index_map; - ls.merge (props.line_styles (), index_map); - - // remap the dither pattern index - for (lay::LayerPropertiesIterator l = props.begin_recursive (); l != props.end_recursive (); ++l) { - int lsi = l->line_style (false /*local*/); - std::map ::iterator m = index_map.find ((unsigned int) lsi); - if (m != index_map.end ()) { - l->set_line_style (int (m->second)); - } - } - - // install the new custom pattern table - if (mp_canvas->line_styles () != ls) { - mp_canvas->set_line_styles (ls); - for (unsigned int i = 0; i < layer_lists (); ++i) { - m_layer_properties_lists [i]->set_line_styles (ls); - } - } - } -} - -void -LayoutView::set_properties (unsigned int index, const LayerPropertiesList &props) -{ - // If index is not a valid tab index, don't do anything except for the case of - // index 0 in which the first entry is created (this can happen as a result of - // delete_properties). - if (index >= layer_lists ()) { - if (index > 0) { - return; - } else { - m_layer_properties_lists.push_back (new LayerPropertiesList ()); - m_layer_properties_lists.back ()->attach_view (this, (unsigned int) (m_layer_properties_lists.size () - 1)); - } - } - - // HINT: this method is quite frequently used in an imperative way. - // Since it has some desired side effects such as forcing a recomputation of the internals, - // it should be executed in any case, even if props == get_properties (). - - if (transacting ()) { - manager ()->queue (this, new OpSetAllProps (index, get_properties (), props)); - } else if (manager () && ! replaying ()) { - manager ()->clear (); - } - - if (mp_control_panel && index == current_layer_list ()) { - mp_control_panel->begin_updates (); - } - - *m_layer_properties_lists [index] = props; - m_layer_properties_lists [index]->attach_view (this, index); - - merge_dither_pattern (*m_layer_properties_lists [index]); - - if (index == current_layer_list ()) { - - layer_list_changed_event (3); - - redraw (); - - dm_prop_changed (); - - } -} - -void -LayoutView::expand_properties () -{ - expand_properties (std::map (), false); -} - -void -LayoutView::expand_properties (unsigned int index) -{ - expand_properties (index, std::map (), false); -} - -void -LayoutView::expand_properties (const std::map &map_cv_index, bool add_default) -{ - for (unsigned int i = 0; i < cellviews (); ++i) { - expand_properties (i, map_cv_index, add_default); - } -} - -void -LayoutView::expand_properties (unsigned int index, const std::map &map_cv_index, bool add_default) -{ - if (index < m_layer_properties_lists.size ()) { - m_layer_properties_lists [index]->expand (map_cv_index, add_default); - } -} - -void -LayoutView::replace_layer_node (unsigned int index, const LayerPropertiesConstIterator &iter, const LayerPropertiesNode &node) -{ - if (index >= layer_lists ()) { - return; - } - - // if the source specification changed, a redraw is required - if (*iter != node) { - - if (transacting ()) { - manager ()->queue (this, new OpSetLayerPropsNode (index, (unsigned int) iter.uint (), *iter, node)); - } else if (manager () && ! replaying ()) { - manager ()->clear (); - } - - if (mp_control_panel && index == current_layer_list ()) { - mp_control_panel->begin_updates (); - } - - LayerPropertiesIterator non_const_iter (get_properties (index), iter.uint ()); - *non_const_iter = node; - non_const_iter->attach_view (this, index); - - if (index == current_layer_list ()) { - - layer_list_changed_event (2); - - // TODO: check, if redraw is actually necessary (this is complex!) - redraw (); - - dm_prop_changed (); - - } - } -} - -void -LayoutView::set_properties (unsigned int index, const LayerPropertiesConstIterator &iter, const LayerProperties &props) -{ - if (index >= layer_lists ()) { - return; - } - - // if the source specification changed, a redraw is required - const LayerProperties &l = *iter; - if (l != props) { - - if (transacting ()) { - manager ()->queue (this, new OpSetLayerProps (index, (unsigned int) iter.uint (), l, props)); - } else if (manager () && ! replaying ()) { - manager ()->clear (); - } - - bool need_redraw = (l.source (false /*local*/) != props.source (false /*local*/) || l.xfill (false /*local*/) != props.xfill (false /*local*/)); - bool visible_changed = (l.visible (true /*real*/) != props.visible (true /*real*/)); - - LayerPropertiesIterator non_const_iter (get_properties (index), iter.uint ()); - *non_const_iter = props; - - if (index == current_layer_list ()) { - - layer_list_changed_event (1); - - if (need_redraw) { - redraw (); - } - - if (visible_changed) { - m_visibility_changed = true; - } - - // perform the callbacks asynchronously to collect the necessary calls instead - // of executing them immediately. - dm_prop_changed (); - - } - } -} - -const LayerPropertiesNode & -LayoutView::insert_layer (unsigned int index, const LayerPropertiesConstIterator &before, const LayerPropertiesNode &node) -{ - tl_assert (index < layer_lists ()); - - if (transacting ()) { - manager ()->queue (this, new OpInsertLayerProps (index, (unsigned int) before.uint (), node)); - } else if (manager () && ! replaying ()) { - manager ()->clear (); - } - - if (mp_control_panel && index == current_layer_list ()) { - mp_control_panel->begin_updates (); - } - - const LayerPropertiesNode &ret = m_layer_properties_lists [index]->insert (LayerPropertiesIterator (*m_layer_properties_lists [index], before.uint ()), node); - - // signal to the observers that something has changed - if (index == current_layer_list ()) { - layer_list_changed_event (2); - redraw (); - dm_prop_changed (); - } - - return ret; -} - -void -LayoutView::delete_layer (unsigned int index, LayerPropertiesConstIterator &iter) -{ - if (index >= layer_lists ()) { - return; - } - - lay::LayerPropertiesNode orig = *iter; - - if (mp_control_panel && index == current_layer_list ()) { - mp_control_panel->begin_updates (); - } - - // delete the element - m_layer_properties_lists [index]->erase (LayerPropertiesIterator (*m_layer_properties_lists [index], iter.uint ())); - - if (transacting ()) { - manager ()->queue (this, new OpDeleteLayerProps (index, (unsigned int) iter.uint (), orig)); - } else if (manager () && ! replaying ()) { - manager ()->clear (); - } - - // signal to the observers that something has changed - if (index == current_layer_list ()) { - layer_list_changed_event (2); - redraw (); - dm_prop_changed (); - } - - // invalidate the iterator so it can be used to refer to the next element - iter.invalidate (); -} - -void -LayoutView::signal_selection_changed () -{ - if (selection_size () > 1) { - message (tl::sprintf (tl::to_string (QObject::tr ("selected: %ld objects")), selection_size ())); - } - - lay::Editables::signal_selection_changed (); -} - -void -LayoutView::save_as (unsigned int index, const std::string &filename, tl::OutputStream::OutputStreamMode om, const db::SaveLayoutOptions &options, bool update, int keep_backups) -{ - tl_assert (index < cellviews ()); - - tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Saving"))); - cellview (index)->save_as (filename, om, options, update, keep_backups); - - cellview_changed (index); -} - -void -LayoutView::redo (db::Op *op) -{ - tl_assert (! transacting ()); - - OpSetLayerProps *sop = dynamic_cast (op); - if (sop) { - if (sop->m_list_index < m_layer_properties_lists.size ()) { - set_properties (sop->m_list_index, lay::LayerPropertiesConstIterator (*m_layer_properties_lists [sop->m_list_index], sop->m_index), sop->m_new); - } - return; - } - - OpSetLayerPropsNode *snop = dynamic_cast (op); - if (snop) { - if (snop->m_list_index < m_layer_properties_lists.size ()) { - replace_layer_node (snop->m_list_index, lay::LayerPropertiesConstIterator (*m_layer_properties_lists [snop->m_list_index], snop->m_index), snop->m_new); - } - return; - } - - OpInsertLayerList *ilop = dynamic_cast (op); - if (ilop) { - if (ilop->m_list_index <= m_layer_properties_lists.size ()) { - insert_layer_list (ilop->m_list_index, ilop->m_new); - } - return; - } - - OpDeleteLayerList *dlop = dynamic_cast (op); - if (dlop) { - if (dlop->m_list_index < m_layer_properties_lists.size ()) { - delete_layer_list (dlop->m_list_index); - } - return; - } - - OpSetAllProps *saop = dynamic_cast (op); - if (saop) { - if (saop->m_list_index < m_layer_properties_lists.size ()) { - set_properties (saop->m_list_index, saop->m_new); - } - return; - } - - OpRenameProps *rnop = dynamic_cast (op); - if (rnop) { - if (rnop->m_list_index < m_layer_properties_lists.size ()) { - rename_properties (rnop->m_list_index, rnop->m_new); - } - return; - } - - OpLayerList *lop = dynamic_cast (op); - if (lop) { - if (lop->m_list_index < m_layer_properties_lists.size ()) { - if (lop->m_mode == OpLayerList::Insert) { - insert_layer (lop->m_list_index, lay::LayerPropertiesConstIterator (*m_layer_properties_lists [lop->m_list_index], lop->m_index), lop->m_node); - } else { - lay::LayerPropertiesConstIterator iter (*m_layer_properties_lists [lop->m_list_index], lop->m_index); - delete_layer (lop->m_list_index, iter); - } - } - return; - } - - OpSetDitherPattern *stpop = dynamic_cast (op); - if (stpop) { - set_dither_pattern (stpop->m_new); - return; - } - - OpHideShowCell *hscop = dynamic_cast (op); - if (hscop) { - if (hscop->m_show) { - show_cell (hscop->m_cell_index, hscop->m_cellview_index); - } else { - hide_cell (hscop->m_cell_index, hscop->m_cellview_index); - } - return; - } - - db::Object::redo (op); -} - -void -LayoutView::undo (db::Op *op) -{ - tl_assert (! transacting ()); - - OpSetLayerProps *sop = dynamic_cast (op); - if (sop) { - if (sop->m_list_index < m_layer_properties_lists.size ()) { - set_properties (sop->m_list_index, lay::LayerPropertiesConstIterator (*m_layer_properties_lists [sop->m_list_index], sop->m_index), sop->m_old); - } - return; - } - - OpSetLayerPropsNode *snop = dynamic_cast (op); - if (snop) { - if (snop->m_list_index < m_layer_properties_lists.size ()) { - replace_layer_node (snop->m_list_index, lay::LayerPropertiesConstIterator (*m_layer_properties_lists [snop->m_list_index], snop->m_index), snop->m_old); - } - return; - } - - OpInsertLayerList *ilop = dynamic_cast (op); - if (ilop) { - if (ilop->m_list_index <= m_layer_properties_lists.size ()) { - delete_layer_list (ilop->m_list_index); - } - return; - } - - OpDeleteLayerList *dlop = dynamic_cast (op); - if (dlop) { - if (dlop->m_list_index < m_layer_properties_lists.size ()) { - insert_layer_list (dlop->m_list_index, dlop->m_old); - } - return; - } - - OpSetAllProps *saop = dynamic_cast (op); - if (saop) { - if (saop->m_list_index < m_layer_properties_lists.size ()) { - set_properties (saop->m_list_index, saop->m_old); - } - return; - } - - OpRenameProps *rnop = dynamic_cast (op); - if (rnop) { - if (rnop->m_list_index < m_layer_properties_lists.size ()) { - rename_properties (rnop->m_list_index, rnop->m_old); - } - return; - } - - OpLayerList *lop = dynamic_cast (op); - if (lop) { - if (lop->m_list_index < m_layer_properties_lists.size ()) { - if (lop->m_mode == OpLayerList::Insert) { - lay::LayerPropertiesConstIterator iter (*m_layer_properties_lists [lop->m_list_index], lop->m_index); - delete_layer (lop->m_list_index, iter); - } else { - insert_layer (lop->m_list_index, lay::LayerPropertiesConstIterator (*m_layer_properties_lists [lop->m_list_index], lop->m_index), lop->m_node); - } - } - return; - } - - OpHideShowCell *hscop = dynamic_cast (op); - if (hscop) { - - if (hscop->m_show) { - hide_cell (hscop->m_cell_index, hscop->m_cellview_index); - } else { - show_cell (hscop->m_cell_index, hscop->m_cellview_index); - } - - return; - - } - - OpSetDitherPattern *stpop = dynamic_cast (op); - if (stpop) { - set_dither_pattern (stpop->m_old); - return; - } - - db::Object::undo (op); -} - -void -LayoutView::signal_hier_changed () -{ - // schedule a redraw request for all layers - redraw (); - // forward this event to our observers - hier_changed_event (); -} - -void -LayoutView::signal_bboxes_from_layer_changed (unsigned int cv_index, unsigned int layer_index) -{ - if (layer_index == std::numeric_limits::max ()) { - - // redraw all - signal_bboxes_changed (); - - } else { - - // redraw only the layers required for redrawing - for (std::vector::const_iterator l = mp_canvas->get_redraw_layers ().begin (); l != mp_canvas->get_redraw_layers ().end (); ++l) { - if (l->cellview_index == int (cv_index) && l->layer_index == int (layer_index)) { - redraw_layer ((unsigned int) (l - mp_canvas->get_redraw_layers ().begin ())); - } - } - - // forward this event to our observers - geom_changed_event (); - - } -} - -void -LayoutView::signal_bboxes_changed () -{ - // schedule a redraw request for all layers - redraw (); - - // forward this event to our observers - geom_changed_event (); -} - -void -LayoutView::signal_cell_name_changed () -{ - cell_visibility_changed_event (); // HINT: that is not what actually is intended, but it serves the function ... - redraw (); // needs redraw -} - -void -LayoutView::signal_layer_properties_changed () -{ - // recompute the source - // TODO: this is a side effect of this method - provide a special method for this purpose - for (unsigned int i = 0; i < layer_lists (); ++i) { - m_layer_properties_lists [i]->attach_view (this, i); - } - - // schedule a redraw request - since the layer views might not have changed, this is necessary - redraw (); -} - -void -LayoutView::signal_prop_ids_changed () -{ - // inform the layer list observers that they need to recompute the property selectors - layer_list_changed_event (1); - - // recompute the source - // TODO: this is a side effect of this method - provide a special method for this purpose - for (unsigned int i = 0; i < layer_lists (); ++i) { - m_layer_properties_lists [i]->attach_view (this, i); - } -} - -void -LayoutView::signal_plugin_enabled_changed () -{ - for (std::vector::iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) { - if ((*p)->editable_interface ()) { - enable ((*p)->editable_interface (), (*p)->plugin_declaration ()->editable_enabled ()); - } - } -} - -void -LayoutView::signal_annotations_changed () -{ - // schedule a redraw request for the annotation shapes - redraw_deco_layer (); - // forward this event to our observers - annotations_changed_event (); -} - -void -LayoutView::finish_cellviews_changed () -{ - update_event_handlers (); - - cellviews_changed_event (); - - redraw (); -} - -std::list::iterator -LayoutView::cellview_iter (int cv_index) -{ - std::list::iterator i = m_cellviews.begin (); - while (cv_index > 0 && i != m_cellviews.end ()) { - ++i; - --cv_index; - } - tl_assert (i != m_cellviews.end ()); - return i; -} - -std::list::const_iterator -LayoutView::cellview_iter (int cv_index) const -{ - std::list::const_iterator i = m_cellviews.begin (); - while (cv_index > 0 && i != m_cellviews.end ()) { - ++i; - --cv_index; - } - tl_assert (i != m_cellviews.end ()); - return i; -} - -void -LayoutView::erase_cellview (unsigned int index) -{ - if (index >= m_cellviews.size ()) { - return; - } - - cancel_esc (); - - // issue to event that signals a change in the cellviews - cellviews_about_to_change_event (); - - // no undo available - clear all transactions - if (manager ()) { - manager ()->clear (); - } - - if (mp_control_panel) { - mp_control_panel->begin_updates (); - } - - m_cellviews.erase (cellview_iter (int (index))); - - if (m_hidden_cells.size () > index) { - m_hidden_cells.erase (m_hidden_cells.begin () + index); - } - - for (unsigned int lindex = 0; lindex < layer_lists (); ++lindex) { - - // remove all references to the cellview - m_layer_properties_lists [lindex]->remove_cv_references (index); - - // rename the ones that got shifted. - lay::LayerPropertiesConstIterator l = begin_layers (lindex); - while (! l.at_end ()) { - lay::ParsedLayerSource source (l->source (false)); - if (source.cv_index () >= int (index)) { - lay::LayerProperties new_props (*l); - source.cv_index (source.cv_index () == int (index) ? -1 : source.cv_index () - 1); - new_props.set_source (source); - LayerPropertiesIterator non_const_iter (*m_layer_properties_lists [lindex], l.uint ()); - *non_const_iter = new_props; - } - ++l; - } - - } - - // clear the history - m_display_states.clear (); - m_display_state_ptr = 0; - - // signal to the observers that something has changed - layer_list_changed_event (3); - - finish_cellviews_changed (); - - update_content (); - - if (m_title.empty ()) { - emit title_changed (); - } -} - -void -LayoutView::clear_cellviews () -{ - // issue to event that signals a change in the cellviews - cellviews_about_to_change_event (); - - // no undo available - clear all transactions - if (manager ()) { - manager ()->clear (); - } - - // clear the layer lists and cellviews - while (layer_lists () > 0) { - delete_layer_list (layer_lists () - 1); - } - set_properties (lay::LayerPropertiesList ()); - m_cellviews.clear (); - - // clear the history, store path and zoom box - m_display_states.clear (); - m_display_state_ptr = 0; - - finish_cellviews_changed (); - - if (m_title.empty ()) { - emit title_changed (); - } -} - -const CellView & -LayoutView::cellview (unsigned int index) const -{ - static const CellView empty; - if (index >= m_cellviews.size ()) { - return empty; - } else { - return *cellview_iter (int (index)); - } -} - -CellViewRef -LayoutView::cellview_ref (unsigned int index) -{ - if (index >= m_cellviews.size ()) { - return CellViewRef (); - } else { - return CellViewRef (cellview_iter (index).operator-> (), this); - } -} - -int -LayoutView::index_of_cellview (const lay::CellView *cv) const -{ - int index = 0; - for (std::list::const_iterator i = m_cellviews.begin (); i != m_cellviews.end (); ++i, ++index) { - if (cv == i.operator-> ()) { - return index; - } - } - return -1; -} - -void -LayoutView::set_layout (const lay::CellView &cv, unsigned int cvindex) -{ - // issue to event that signals a change in the cellviews - cellviews_about_to_change_event (); - - // no undo available - clear all transactions - if (manager ()) { - manager ()->clear (); - } - - // signal the change of layer properties to the observer - layer_list_changed_event (3); - - // create a new cellview if required - while (m_cellviews.size () <= cvindex) { - m_cellviews.push_back (lay::CellView ()); - } - - // set the handle reference and clear all cell related stuff - *cellview_iter (cvindex) = cv; - - // clear the history, store path and zoom box - clear_states (); - - finish_cellviews_changed (); - - // since the hierarchy panel may hold cellviews, we explicitly request an initialization - // of the tree. This will release such references. This way, set_layout guarantees that - // the layouts are released as far as possible. This is important for reload () for example. - if (mp_hierarchy_panel) { - mp_hierarchy_panel->do_update_content (cvindex); - } - - if (m_title.empty ()) { - emit title_changed (); - } -} - -void -LayoutView::signal_apply_technology (lay::LayoutHandle *layout_handle) -{ - // find the cellview which issued the event - for (unsigned int i = 0; i < cellviews (); ++i) { - - if (cellview (i).handle () == layout_handle) { - - cancel_esc (); - - std::string lyp_file; - 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 (); - } - - if (! lyp_file.empty ()) { - - // interpolate the layout properties file name - tl::Eval expr; - expr.set_var ("layoutfile", cellview (i)->filename ()); - lyp_file = expr.interpolate (lyp_file); - - // remove all references to the cellview in the layer properties - for (unsigned int lindex = 0; lindex < layer_lists (); ++lindex) { - m_layer_properties_lists [lindex]->remove_cv_references (i); - } - - // if a layer properties file is set, create the layer properties now - create_initial_layer_props (i, lyp_file, tech->add_other_layers ()); - - } - - } - - } -} - -void -LayoutView::load_layer_props (const std::string &fn) -{ - do_load_layer_props (fn, false, -1, false); -} - -void -LayoutView::load_layer_props (const std::string &fn, bool add_default) -{ - do_load_layer_props (fn, false, -1, add_default); -} - -void -LayoutView::load_layer_props (const std::string &fn, int cv_index, bool add_default) -{ - do_load_layer_props (fn, true, cv_index, add_default); -} - -void -LayoutView::do_load_layer_props (const std::string &fn, bool map_cv, int cv_index, bool add_default) -{ - std::vector props; - bool single_list = false; - - // read the layer properties from the file - try { - tl::XMLFileSource in (fn); - props.push_back (lay::LayerPropertiesList ()); - props.back ().load (in); - single_list = true; - } catch (...) { - props.clear (); - tl::XMLFileSource in (fn); - lay::LayerPropertiesList::load (in, props); - } - - // expand the wildcards and map to the target cv. - for (std::vector::iterator p = props.begin (); p != props.end (); ++p) { - std::map cv_map; - if (map_cv) { - cv_map.insert (std::make_pair (-1, cv_index)); - } - p->attach_view (this, p - props.begin ()); - p->expand (cv_map, add_default); - } - - transaction (tl::to_string (QObject::tr ("Load layer properties"))); - - if (single_list) { - - // a single list will only replace the current tab - if (map_cv && cv_index >= 0) { - lay::LayerPropertiesList new_props (get_properties ()); - new_props.remove_cv_references (cv_index); - new_props.append (props [0]); - set_properties (new_props); - } else { - set_properties (props [0]); - } - - } else { - - for (unsigned int i = 0; i < props.size (); ++i) { - - if (i < layer_lists ()) { - - if (map_cv && cv_index >= 0) { - lay::LayerPropertiesList new_props (get_properties (i)); - new_props.remove_cv_references (cv_index); - new_props.append (props [i]); - set_properties (i, new_props); - } else { - set_properties (i, props [i]); - } - - } else { - insert_layer_list (i, props [i]); - } - - } - - while (layer_lists () > props.size () && layer_lists () > 1) { - delete_layer_list (layer_lists () - 1); - } - - } - - commit (); - - update_content (); - - tl::log << "Loaded layer properties from " << fn; -} - -void -LayoutView::save_layer_props (const std::string &fn) -{ - tl::OutputStream os (fn, tl::OutputStream::OM_Plain); - - if (layer_lists () == 1) { - - // a single list is written in the traditional format - get_properties ().save (os); - - } else { - - // multiple tabs are written in the multi-tab format - std::vector props; - for (unsigned int i = 0; i < layer_lists (); ++i) { - props.push_back (get_properties (i)); - } - - lay::LayerPropertiesList::save (os, props); - - } - - tl::log << "Saved layer properties to " << fn; -} - -void -LayoutView::add_new_layers (const std::vector &layer_ids, int cv_index) -{ - if (cv_index >= 0 && cv_index < int (cellviews ())) { - - const lay::CellView &cv = cellview (cv_index); - - // create the layers and do a basic recoloring .. - lay::LayerPropertiesList new_props (get_properties ()); - - bool was_empty = new_props.begin_const_recursive ().at_end (); - - // don't create new layers for those, for which there are layers already: compute a - // set of layers already present - std::set present_layers; - for (LayerPropertiesConstIterator lay_iter = begin_layers (); ! lay_iter.at_end (); ++lay_iter) { - if (! lay_iter->has_children () && lay_iter->cellview_index () == cv_index) { - present_layers.insert (lay_iter->source (true /*real*/).layer_props ()); - } - } - - // determine layers which are new and need to be created - std::vector new_layers; - for (std::vector ::const_iterator l = layer_ids.begin (); l != layer_ids.end (); ++l) { - const db::LayerProperties &lp = cv->layout ().get_properties (*l); - if (present_layers.find (lp) == present_layers.end ()) { - new_layers.push_back (lp); - } - } - - // create them in the sorting order provided by db::LayerProperties - std::sort (new_layers.begin (), new_layers.end (), db::LPLogicalLessFunc ()); - - // and actually create them - for (std::vector ::const_iterator l = new_layers.begin (); l != new_layers.end (); ++l) { - lay::LayerProperties p; - p.set_source (lay::ParsedLayerSource (*l, cv_index)); - init_layer_properties (p, new_props); - new_props.push_back (p); - } - - set_properties (new_props); - - if (was_empty) { - set_current_layer (new_props.begin_const_recursive ()); - } - - } -} - -void -LayoutView::init_layer_properties (LayerProperties &p) const -{ - init_layer_properties (p, get_properties ()); -} - -void -LayoutView::init_layer_properties (LayerProperties &p, const LayerPropertiesList &lp_list) const -{ - lay::color_t c = 0; - if (m_palette.luminous_colors () > 0) { - c = m_palette.luminous_color_by_index (p.source (true /*real*/).color_index ()); - } - - p.set_dither_pattern (m_stipple_palette.standard_stipple_by_index (lp_list.end_const () - lp_list.begin_const ())); - p.set_fill_color (c); - p.set_frame_color (c); - p.set_fill_brightness (0); - p.set_frame_brightness (0); - p.set_frame_brightness (0); - p.set_transparent (false); // :TODO: make variable - p.set_visible (true); - p.set_width (1); - p.set_animation (0); - p.set_marked (false); -} - -QImage -LayoutView::get_screenshot () -{ - tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Save screenshot"))); - - // Execute all deferred methods - ensure there are no pending tasks - tl::DeferredMethodScheduler::execute (); - - return mp_canvas->screenshot (); -} - -void -LayoutView::save_screenshot (const std::string &fn) -{ - tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Save screenshot"))); - - QImageWriter writer (tl::to_qstring (fn), QByteArray ("PNG")); - - // Unfortunately the PNG writer does not allow writing of long strings. - // We separate the description into a set of keys: - - for (unsigned int i = 0; i < cellviews (); ++i) { - if (cellview (i).is_valid ()) { - std::string name = cellview (i)->layout ().cell_name (cellview (i).cell_index ()); - writer.setText (tl::to_qstring ("Cell" + tl::to_string (int (i) + 1)), tl::to_qstring (name)); - } - } - - db::DBox b (box ()); - std::string desc; - desc += tl::micron_to_string (b.left ()) + "," + tl::micron_to_string (b.bottom ()); - desc += "/"; - desc += tl::micron_to_string (b.right ()) + "," + tl::micron_to_string (b.top ()); - writer.setText (QString::fromUtf8 ("Rect"), tl::to_qstring (desc)); - - // Execute all deferred methods - ensure there are no pending tasks - tl::DeferredMethodScheduler::execute (); - - if (! writer.write (mp_canvas->screenshot ())) { - throw tl::Exception (tl::to_string (QObject::tr ("Unable to write screenshot to file: %s (%s)")), fn, tl::to_string (writer.errorString ())); - } - - tl::log << "Saved screen shot to " << fn; -} - -QImage -LayoutView::get_image (unsigned int width, unsigned int height) -{ - tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Save image"))); - - // Execute all deferred methods - ensure there are no pending tasks - tl::DeferredMethodScheduler::execute (); - - return mp_canvas->image (width, height); -} - -QImage -LayoutView::get_image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, - lay::Color background, lay::Color foreground, lay::Color active, const db::DBox &target_box, bool monochrome) -{ - tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Save image"))); - - // Execute all deferred methods - ensure there are no pending tasks - tl::DeferredMethodScheduler::execute (); - - return mp_canvas->image_with_options (width, height, linewidth, oversampling, resolution, background, foreground, active, target_box, monochrome); -} - -void -LayoutView::save_image (const std::string &fn, unsigned int width, unsigned int height) -{ - tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Save image"))); - - QImageWriter writer (tl::to_qstring (fn), QByteArray ("PNG")); - - // Unfortunately the PNG writer does not allow writing of long strings. - // We separate the description into a set of keys: - - for (unsigned int i = 0; i < cellviews (); ++i) { - if (cellview (i).is_valid ()) { - std::string name = cellview (i)->layout ().cell_name (cellview (i).cell_index ()); - writer.setText (tl::to_qstring ("Cell" + tl::to_string (int (i) + 1)), tl::to_qstring (name)); - } - } - - lay::Viewport vp (width, height, mp_canvas->viewport ().target_box ()); - writer.setText (QString::fromUtf8 ("Rect"), tl::to_qstring (vp.box ().to_string ())); - - // Execute all deferred methods - ensure there are no pending tasks - tl::DeferredMethodScheduler::execute (); - - if (! writer.write (mp_canvas->image (width, height))) { - throw tl::Exception (tl::to_string (QObject::tr ("Unable to write screenshot to file: %s (%s)")), fn, tl::to_string (writer.errorString ())); - } - - tl::log << "Saved screen shot to " << fn; -} - -void -LayoutView::save_image_with_options (const std::string &fn, - unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, - lay::Color background, lay::Color foreground, lay::Color active, const db::DBox &target_box, bool monochrome) -{ - tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Save image"))); - - QImageWriter writer (tl::to_qstring (fn), QByteArray ("PNG")); - - // Unfortunately the PNG writer does not allow writing of long strings. - // We separate the description into a set of keys: - - for (unsigned int i = 0; i < cellviews (); ++i) { - if (cellview (i).is_valid ()) { - std::string name = cellview (i)->layout ().cell_name (cellview (i).cell_index ()); - writer.setText (tl::to_qstring ("Cell" + tl::to_string (int (i) + 1)), tl::to_qstring (name)); - } - } - - lay::Viewport vp (width, height, mp_canvas->viewport ().target_box ()); - writer.setText (QString::fromUtf8 ("Rect"), tl::to_qstring (vp.box ().to_string ())); - - // Execute all deferred methods - ensure there are no pending tasks - tl::DeferredMethodScheduler::execute (); - - if (! writer.write (mp_canvas->image_with_options (width, height, linewidth, oversampling, resolution, background, foreground, active, target_box, monochrome))) { - throw tl::Exception (tl::to_string (QObject::tr ("Unable to write screenshot to file: %s (%s)")), fn, tl::to_string (writer.errorString ())); - } - - tl::log << "Saved screen shot to " << fn; -} - -void -LayoutView::reload_layout (unsigned int cv_index) -{ - stop (); - cancel_esc (); - - // save the current view state - lay::DisplayState state; - save_view (state); - - // this is the cellview at the given index (use a copy since the original is overwritten) - CellView cvorg = cellview (cv_index); - - // obtain the original filename - std::string filename = cvorg->filename (); - std::string technology = cvorg->tech_name (); - std::string name = cvorg->name (); - - // recreate hidden cells by doing a name referencing - std::vector hidden_cells; - if (m_hidden_cells.size () > cv_index) { - hidden_cells.reserve (m_hidden_cells [cv_index].size ()); - for (std::set ::const_iterator ci = m_hidden_cells [cv_index].begin (); ci != m_hidden_cells [cv_index].end (); ++ci) { - hidden_cells.push_back (std::string (cvorg->layout ().cell_name (*ci))); - } - } - - // Set up a list of present layers - std::set present_layers; - for (LayerPropertiesConstIterator lay_iter = begin_layers (); ! lay_iter.at_end (); ++lay_iter) { - if (! lay_iter->has_children ()) { - present_layers.insert (lay_iter->source (true /*real*/).layer_props ()); - } - } - - std::map org_layers; - - for (unsigned int i = 0; i < cvorg->layout ().layers (); ++i) { - if (cvorg->layout ().is_valid_layer (i)) { - const db::LayerProperties &p = cvorg->layout ().get_properties (i); - if (! p.log_equal (db::LayerProperties ())) { - org_layers.insert (std::make_pair (i, p)); - } - } - } - - lay::LayoutHandle *handle; - - // reset the layout: create a dummy handle and install this in between - // this will clear the original layout if not further referenced. - // Since the dummy layout will act as a placeholder if something goes wrong - // when reading the file, it must have the layers created as well - lay::CellView cv_empty; - - handle = new lay::LayoutHandle (new db::Layout (manager ()), filename); - handle->set_tech_name (technology); - cv_empty.set (handle); - - for (std::map ::const_iterator ol = org_layers.begin (); ol != org_layers.end (); ++ol) { - cv_empty->layout ().insert_layer (ol->first, ol->second); - } - cv_empty->rename (name, true); - - set_layout (cv_empty, cv_index); - - // create a new handle - lay::CellView cv; - handle = new lay::LayoutHandle (new db::Layout (manager ()), filename); - cv.set (handle); - - try { - - // re-create the layers required - for (std::map ::const_iterator ol = org_layers.begin (); ol != org_layers.end (); ++ol) { - cv->layout ().insert_layer (ol->first, ol->second); - } - - { - tl::log << tl::to_string (QObject::tr ("Loading file: ")) << filename; - tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Loading"))); - - // Load with the previous options again. - db::LoadLayoutOptions options (cvorg->load_options ()); - cv->load (cvorg->load_options (), technology); - } - - // sort the layout explicitly here. Otherwise it would be done - // implicitly at some other time. This may throw an exception - // if the operation was cancelled. - { - tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Sorting"))); - cv->layout ().update (); - } - - // print the memory statistics now. - if (tl::verbosity () >= 31) { - db::MemStatisticsCollector m (false); - cv->layout ().mem_stat (&m, db::MemStatistics::LayoutInfo, 0); - m.print (); - } - - // this is required to release every reference to the cv_empty layout - cv_empty = lay::CellView (); - - // install the new layout - cv->rename (name, true); - set_layout (cv, cv_index); - - } catch (...) { - update_content (); - throw; - } - - // recreate the hidden cell indices from the names - if (m_hidden_cells.size () > cv_index) { - m_hidden_cells [cv_index].clear (); - for (std::vector ::const_iterator cn = hidden_cells.begin (); cn != hidden_cells.end (); ++cn) { - std::pair cid = cv->layout ().cell_by_name (cn->c_str ()); - if (cid.first) { - m_hidden_cells [cv_index].insert (cid.second); - } - } - } - - // Determine which layers to create as new layers. New layer need to be created - // if these have not been present in the original layout and there are no layer views - // referring to them. - std::vector new_layers; - for (unsigned int i = 0; i < cv->layout ().layers (); ++i) { - if (cv->layout ().is_valid_layer (i)) { - std::map ::iterator ol = org_layers.find (i); - if (ol == org_layers.end () && present_layers.find (cv->layout ().get_properties (i)) == present_layers.end ()) { - new_layers.push_back (cv->layout ().get_properties (i)); - } - } - } - - std::sort (new_layers.begin (), new_layers.end (), db::LPLogicalLessFunc ()); - - // create the layers and do a basic recoloring .. - lay::LayerPropertiesList new_props (get_properties ()); - - for (std::vector ::const_iterator l = new_layers.begin (); l != new_layers.end (); ++l) { - lay::LayerProperties p; - p.set_source (lay::ParsedLayerSource (*l, int (cv_index))); - init_layer_properties (p, new_props); - new_props.push_back (p); - } - - set_properties (new_props); - - goto_view (state); - -} - -unsigned int -LayoutView::add_layout (lay::LayoutHandle *layout_handle, bool add_cellview, bool initialize_layers) -{ - unsigned int cv_index = 0; - - try { - - m_active_cellview_changed_event_enabled = false; - - stop_redraw (); - - bool set_max_hier = (m_full_hier_new_cell || has_max_hier ()); - - lay::CellView cv; - - if (! add_cellview) { - clear_cellviews (); - } - - cv.set (layout_handle); - - cv->layout ().update (); - - // select the cell with the largest area as the first top cell - db::Layout::top_down_const_iterator top = cv->layout ().begin_top_down (); - for (db::Layout::top_down_const_iterator t = cv->layout ().begin_top_down (); t != cv->layout ().end_top_cells (); ++t) { - if (cv->layout ().cell (*t).bbox ().area () > cv->layout ().cell (*top).bbox ().area ()) { - top = t; - } - } - - if (top != cv->layout ().end_top_down ()) { - std::vector p; - p.push_back (*top); - cv.set_unspecific_path (p); - } - - cv_index = cellviews (); - set_layout (cv, cv_index); - - if (top != cv->layout ().end_top_cells ()) { - std::vector p; - p.push_back (*top); - select_cell (p, cv_index); - } else { - // even if there is no cell, select the cellview item - // to support applications with an active cellview (that is however invalid) - set_active_cellview_index (cv_index); - } - - if (initialize_layers) { - - bool add_other_layers = m_add_other_layers; - - // 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 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 (); - } - - // Give the layout object a chance to specify a certain layer property file - for (db::Layout::meta_info_iterator meta = cv->layout ().begin_meta (); meta != cv->layout ().end_meta (); ++meta) { - if (meta->name == "layer-properties-file") { - lyp_file = meta->value; - } - if (meta->name == "layer-properties-add-other-layers") { - try { - tl::from_string (meta->value, add_other_layers); - } catch (...) { - } - } - } - - // interpolate the layout properties file name - tl::Eval expr; - expr.set_var ("layoutfile", layout_handle->filename ()); - lyp_file = expr.interpolate (lyp_file); - - // create the initial layer properties - create_initial_layer_props (cv_index, lyp_file, add_other_layers); - - } - - // select the first layer if nothing else is selected - if (cv_index == 0 && ! mp_control_panel->has_selection ()) { - const lay::LayerPropertiesList &lp = get_properties (); - lay::LayerPropertiesConstIterator li = lp.begin_const_recursive (); - while (! li.at_end () && li->has_children ()) { - ++li; - } - if (! li.at_end ()) { - mp_control_panel->set_current_layer (li); - } - } - - // signal to any observers - file_open_event (); - - if (cv->layout ().begin_top_down () != cv->layout ().end_top_down ()) { - - // do a fit and update layer lists etc. - zoom_fit (); - if (set_max_hier) { - max_hier (); - } - update_content (); - - } else { - // even if there is no cell, select the cellview item - // to support applications with an active cellview (that is however invalid) - set_active_cellview_index (cv_index); - } - - m_active_cellview_changed_event_enabled = true; - - } catch (...) { - - update_content (); - - m_active_cellview_changed_event_enabled = true; - throw; - - } - - // this event may not be generated otherwise, hence force it now. - active_cellview_changed (cv_index); - - return cv_index; -} - -unsigned int -LayoutView::create_layout (const std::string &technology, bool add_cellview, bool initialize_layers) -{ - const db::Technology *tech = db::Technologies::instance ()->technology_by_name (technology); - - db::Layout *layout = new db::Layout (manager ()); - if (tech) { - layout->dbu (tech->dbu ()); - } - - lay::LayoutHandle *handle = new lay::LayoutHandle (layout, ""); - handle->set_tech_name (technology); - return add_layout (handle, add_cellview, initialize_layers); -} - -unsigned int -LayoutView::load_layout (const std::string &filename, const std::string &technology, bool add_cellview) -{ - return load_layout (filename, db::LoadLayoutOptions (), technology, add_cellview); -} - -unsigned int -LayoutView::load_layout (const std::string &filename, const db::LoadLayoutOptions &options, const std::string &technology, bool add_cellview) -{ - stop (); - - bool set_max_hier = (m_full_hier_new_cell || has_max_hier ()); - - const db::Technology *tech = db::Technologies::instance ()->technology_by_name (technology); - - // create a new layout handle - lay::CellView cv; - lay::LayoutHandle *handle = new lay::LayoutHandle (new db::Layout (manager ()), filename); - cv.set (handle); - - unsigned int cv_index; - db::LayerMap lmap; - - try { - - tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Loading"))); - - // load the file - { - tl::log << tl::to_string (QObject::tr ("Loading file: ")) << filename << tl::to_string (QObject::tr (" with technology: ")) << technology; - lmap = cv->load (options, technology); - } - - // sort the layout explicitly here. Otherwise it would be done - // implicitly at some other time. This may throw an exception - // if the operation was cancelled. - { - cv->layout ().update (); - } - - // print the memory statistics now. - if (tl::verbosity () >= 31) { - db::MemStatisticsCollector m (false); - cv->layout ().mem_stat (&m, db::MemStatistics::LayoutInfo, 0); - m.print (); - } - - // clear the cellviews if required - if (! add_cellview) { - clear_cellviews (); - } - - // set the new layout as the layout for the last cellview - cv_index = cellviews (); - set_layout (cv, cv_index); - - } catch (...) { - - update_content (); - throw; - - } - - try { - - m_active_cellview_changed_event_enabled = false; - - // select the cell with the largest area as the first top cell - db::Layout::top_down_const_iterator top = cv->layout ().begin_top_down (); - for (db::Layout::top_down_const_iterator t = cv->layout ().begin_top_down (); t != cv->layout ().end_top_cells (); ++t) { - if (cv->layout ().cell (*t).bbox ().area () > cv->layout ().cell (*top).bbox ().area ()) { - top = t; - } - } - if (top != cv->layout ().end_top_cells ()) { - std::vector p; - p.push_back (*top); - select_cell (p, cv_index); - } else { - // even if there is no cell, select the cellview item - // to support applications with an active cellview (that is however invalid) - set_active_cellview_index (cv_index); - } - - bool add_other_layers = m_add_other_layers; - - // 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; - if (tech && ! tech->eff_layer_properties_file ().empty ()) { - lyp_file = tech->eff_layer_properties_file (); - add_other_layers = tech->add_other_layers (); - } - - // Give the layout object a chance to specify a certain layer property file - for (db::Layout::meta_info_iterator meta = cv->layout().begin_meta (); meta != cv->layout().end_meta (); ++meta) { - if (meta->name == "layer-properties-file") { - lyp_file = meta->value; - } - if (meta->name == "layer-properties-add-other-layers") { - try { - tl::from_string (meta->value, add_other_layers); - } catch (...) { - } - } - } - - // interpolate the layout properties file name - tl::Eval expr; - expr.set_var ("layoutfile", filename); - lyp_file = expr.interpolate (lyp_file); - - // create the initial layer properties - create_initial_layer_props (cv_index, lyp_file, add_other_layers); - - // select the first layer if nothing else is selected - if (cv_index == 0 && ! mp_control_panel->has_selection ()) { - const lay::LayerPropertiesList &lp = get_properties (); - lay::LayerPropertiesConstIterator li = lp.begin_const_recursive (); - while (! li.at_end () && li->has_children ()) { - ++li; - } - if (! li.at_end ()) { - mp_control_panel->set_current_layer (li); - } - } - - // signal to any observers - file_open_event (); - - // do a fit and update layer lists etc. - zoom_fit (); - if (set_max_hier) { - max_hier (); - } - update_content (); - - m_active_cellview_changed_event_enabled = true; - - } catch (...) { - - update_content (); - - m_active_cellview_changed_event_enabled = true; - throw; - - } - - // this event may not be generated otherwise, hence force it now. - active_cellview_changed (cv_index); - - return cv_index; -} - -void -LayoutView::create_initial_layer_props (int cv_index, const std::string &lyp_file, bool add_missing) -{ - std::vector props; - bool loaded = false; - - if (! lyp_file.empty ()) { - - // read the layer properties from the file - try { - - try { - tl::XMLFileSource in (lyp_file); - props.push_back (lay::LayerPropertiesList ()); - props.back ().load (in); - loaded = true; - } catch (...) { - props.clear (); - tl::XMLFileSource in (lyp_file); - tl::log << tl::to_string (QObject::tr ("Loading layer properties file: ")) << lyp_file; - lay::LayerPropertiesList::load (in, props); - loaded = true; - } - - } catch (tl::Exception &ex) { - tl::warn << tl::to_string (QObject::tr ("Initialization of layers failed: ")) << ex.msg (); - } catch (...) { - tl::warn << tl::to_string (QObject::tr ("Initialization of layers failed: unspecific error")); - } - - } - - std::map cv_map; - cv_map.insert (std::make_pair (-1, cv_index)); - - if (! loaded) { - - props.clear (); - props.push_back (lay::LayerPropertiesList ()); - - } else { - - // do't map cv's if the input file is a multi-cv one. - std::set cv; - for (std::vector::const_iterator p = props.begin (); p != props.end (); ++p) { - for (lay::LayerPropertiesConstIterator lp = p->begin_const_recursive (); ! lp.at_end (); ++lp) { - if (! lp->has_children ()) { - cv.insert (lp->source (true).cv_index ()); - if (cv.size () >= 2) { - cv_map.clear (); - cv_map.insert (std::make_pair (cv_index, cv_index)); - // erase the others: - cv_map.insert (std::make_pair (-1, -2)); - break; - } - } - } - } - - } - - // expand the wildcards and map to the target cv. - for (std::vector::iterator p = props.begin (); p != props.end (); ++p) { - p->attach_view (this, p - props.begin ()); - p->expand (cv_map, add_missing || !loaded); - } - - merge_layer_props (props); -} - -void -LayoutView::merge_layer_props (const std::vector &props) -{ - lay::LayerPropertiesList p0; - if (layer_lists () > 0) { - p0 = get_properties (0); - } - - // merge the new layer views into the present ones - // If the specific list is a single list (no tabs), it is merged into every tab present. - if (props.size () == 1) { - - for (size_t n = 0; n < layer_lists () || n == 0; ++n) { - - std::vector::const_iterator p = props.begin (); - - if (n < layer_lists ()) { - lay::LayerPropertiesList new_props (get_properties ((unsigned int) n)); - new_props.append (*p); - if (! p->name ().empty ()) { - new_props.set_name (p->name ()); - } - set_properties ((unsigned int) n, new_props); - } else { - - lay::LayerPropertiesList new_props = p0; - new_props.append (*p); - if (! p->name ().empty ()) { - new_props.set_name (p->name ()); - } - insert_layer_list ((unsigned int) n, new_props); - } - - } - - } else { - - size_t n = 0; - for (std::vector::const_iterator p = props.begin (); p != props.end (); ++p, ++n) { - - if (n < layer_lists ()) { - lay::LayerPropertiesList new_props (get_properties ((unsigned int) n)); - new_props.append (*p); - if (! p->name ().empty ()) { - new_props.set_name (p->name ()); - } - set_properties ((unsigned int) n, new_props); - } else { - lay::LayerPropertiesList new_props = p0; - new_props.append (*p); - if (! p->name ().empty ()) { - new_props.set_name (p->name ()); - } - insert_layer_list ((unsigned int) n, new_props); - } - - } - - } -} - -void -LayoutView::pop_state () -{ - if (m_display_state_ptr > 0) { - m_display_states.erase (m_display_states.begin () + m_display_state_ptr, m_display_states.end ()); - --m_display_state_ptr; - } -} - -void -LayoutView::clear_states () -{ - m_display_states.clear (); - m_display_state_ptr = 0; -} - -void -LayoutView::store_state () -{ - // erase all states after the current position - if (m_display_state_ptr + 1 < m_display_states.size ()) { - m_display_states.erase (m_display_states.begin () + m_display_state_ptr + 1, m_display_states.end ()); - } - - // save the state - DisplayState state (box (), get_min_hier_levels (), get_max_hier_levels (), m_cellviews); - m_display_states.push_back (state); - - m_display_state_ptr = (unsigned int) (m_display_states.size () - 1); -} - -db::DBox -LayoutView::box () const -{ - return mp_canvas->viewport ().box (); -} - -void -LayoutView::timer () -{ - bool dirty = false; - for (std::list::const_iterator i = m_cellviews.begin (); i != m_cellviews.end () && ! dirty; ++i) { - dirty = (*i)->layout ().is_editable () && (*i)->is_dirty (); - } - - if (dirty != m_dirty) { - m_dirty = dirty; - emit dirty_changed (); - } - - if (m_animated) { - set_view_ops (); - if (mp_control_panel) { - mp_control_panel->set_phase (int (m_phase)); - } - if (m_animated) { - ++m_phase; - } - } -} - -bool -LayoutView::layer_model_updated () -{ - // because check_updated is called in the initialization phase, we check if the pointers - // to the widgets are non-null: - if (mp_control_panel) { - return mp_control_panel->model_updated (); - } else { - return false; - } -} - -void -LayoutView::force_update_content () -{ - set_view_ops (); -} - -void -LayoutView::update_content () -{ - if (m_activated) { - set_view_ops (); - } -} - -void -LayoutView::zoom_fit_sel () -{ - db::DBox bbox = selection_bbox (); - if (! bbox.empty ()) { - bbox = db::DBox (bbox.left () - 0.025 * bbox.width (), bbox.bottom () - 0.025 * bbox.height (), - bbox.right () + 0.025 * bbox.width (), bbox.top () + 0.025 * bbox.height ()); - zoom_box (bbox); - } -} - -db::DBox -LayoutView::full_box () const -{ - // compute the bounding box over all layers - // this will trigger the update procedures of the layout objects if not done yet .. - - db::DBox bbox; - - for (LayerPropertiesConstIterator l = get_properties ().begin_const_recursive (); ! l.at_end (); ++l) { - bbox += l->bbox (); - } - - for (lay::AnnotationShapes::iterator a = annotation_shapes ().begin (); ! a.at_end (); ++a) { - bbox += a->box (); - } - - if (bbox.empty ()) { - bbox = db::DBox (0, 0, 0, 0); // default box - } else { - bbox = db::DBox (bbox.left () - 0.025 * bbox.width (), bbox.bottom () - 0.025 * bbox.height (), - bbox.right () + 0.025 * bbox.width (), bbox.top () + 0.025 * bbox.height ()); - } - - return bbox; -} - -void -LayoutView::zoom_fit () -{ - mp_canvas->zoom_box (full_box (), true /*precious*/); - store_state (); -} - -void -LayoutView::ensure_selection_visible () -{ - ensure_visible (selection_bbox ()); -} - -void -LayoutView::ensure_visible (const db::DBox &bbox) -{ - db::DBox new_box = bbox + viewport ().box (); - mp_canvas->zoom_box (new_box); - store_state (); -} - -void -LayoutView::zoom_box_and_set_hier_levels (const db::DBox &bbox, const std::pair &levels) -{ - mp_canvas->zoom_box (bbox); - set_hier_levels_basic (levels); - store_state (); -} - -void -LayoutView::zoom_box (const db::DBox &bbox) -{ - mp_canvas->zoom_box (bbox); - store_state (); -} - -void -LayoutView::set_global_trans (const db::DCplxTrans &trans) -{ - mp_canvas->set_global_trans (trans); - store_state (); -} - -void -LayoutView::zoom_trans (const db::DCplxTrans &trans) -{ - mp_canvas->zoom_trans (trans); - store_state (); -} - -void -LayoutView::pan_left () -{ - shift_window (1.0, -m_pan_distance, 0.0); -} - -void -LayoutView::pan_right () -{ - shift_window (1.0, m_pan_distance, 0.0); -} - -void -LayoutView::pan_up () -{ - shift_window (1.0, 0.0, m_pan_distance); -} - -void -LayoutView::pan_down () -{ - shift_window (1.0, 0.0, -m_pan_distance); -} - -void -LayoutView::pan_left_fast () -{ - shift_window (1.0, -m_pan_distance * fast_factor, 0.0); -} - -void -LayoutView::pan_right_fast () -{ - shift_window (1.0, m_pan_distance * fast_factor, 0.0); -} - -void -LayoutView::pan_up_fast () -{ - shift_window (1.0, 0.0, m_pan_distance * fast_factor); -} - -void -LayoutView::pan_down_fast () -{ - shift_window (1.0, 0.0, -m_pan_distance * fast_factor); -} - -void -LayoutView::pan_center (const db::DPoint &p) -{ - db::DBox b = mp_canvas->viewport ().box (); - db::DVector d (b.width () * 0.5, b.height () * 0.5); - zoom_box (db::DBox (p - d, p + d)); -} - -void -LayoutView::zoom_in () -{ - shift_window (zoom_factor, 0.0, 0.0); -} - -void -LayoutView::zoom_out () -{ - shift_window (1.0 / zoom_factor, 0.0, 0.0); -} - -void -LayoutView::shift_window (double f, double dx, double dy) -{ - db::DBox b = mp_canvas->viewport ().box (); - - db::DPoint s = mp_canvas->viewport ().global_trans ().inverted () * db::DPoint (dx, dy); - db::DPoint c = b.center () + db::DVector (b.width () * s.x (), b.height () * s.y ()); - - double w = b.width () * f; - double h = b.height () * f; - - db::DVector d (w * 0.5, h * 0.5); - - zoom_box (db::DBox (c - d, c + d)); -} - -void -LayoutView::goto_window (const db::DPoint &p, double s) -{ - if (s > 1e-6) { - db::DBox b (p.x () - s * 0.5, p.y () - s * 0.5, p.x () + s * 0.5, p.y () + s * 0.5); - zoom_box (b); - } else { - db::DBox b (box ()); - b.move (p - b.center ()); - zoom_box (b); - } -} - -void -LayoutView::redraw_layer (unsigned int index) -{ - do_redraw (index); -} - -void -LayoutView::redraw_cell_boxes () -{ - do_redraw (lay::draw_boxes_queue_entry); -} - -void -LayoutView::redraw_deco_layer () -{ - // redraw background annotations (images etc.) - mp_canvas->touch_bg (); - - // redraw other annotations: - do_redraw (lay::draw_custom_queue_entry); -} - -void -LayoutView::redraw () -{ - std::vector layers; - - size_t nlayers = 0; - for (lay::LayerPropertiesConstIterator l = begin_layers (); !l.at_end (); ++l) { - if (! l->has_children ()) { - ++nlayers; - } - } - layers.reserve (nlayers); - - for (lay::LayerPropertiesConstIterator l = begin_layers (); !l.at_end (); ++l) { - if (! l->has_children ()) { - layers.push_back (RedrawLayerInfo (*l)); - } - } - - mp_canvas->redraw_new (layers); -} - -void -LayoutView::cancel_edits () -{ - // cancel all drag and pending edit operations such as move operations. - mp_canvas->drag_cancel (); - lay::Editables::cancel_edits (); -} - -void -LayoutView::cancel () -{ - // cancel all drags and pending edit operations such as move operations. - cancel_edits (); - // re-enable edit mode - enable_edits (true); - // and clear the selection - clear_selection (); -} - -void -LayoutView::cancel_esc () -{ - cancel (); - switch_mode (default_mode ()); -} - void LayoutView::bookmark_current_view () { @@ -4037,67 +702,12 @@ LayoutView::bookmarks (const BookmarkList &b) void LayoutView::bookmark_view (const std::string &name) { - DisplayState state (box (), get_min_hier_levels (), get_max_hier_levels (), m_cellviews); + DisplayState state (box (), get_min_hier_levels (), get_max_hier_levels (), cellview_list ()); m_bookmarks.add (name, state); mp_bookmarks_view->refresh (); emit menu_needs_update (); } -void -LayoutView::goto_view (const DisplayState &state) -{ - mp_canvas->zoom_box (state.box ()); - - std::list cellviews; - for (unsigned int i = 0; i < m_cellviews.size (); ++i) { - cellviews.push_back (state.cellview (i, cellview_iter (i)->operator-> ())); - } - - select_cellviews (cellviews); - - if (state.min_hier () <= state.max_hier ()) { - set_hier_levels_basic (std::make_pair (state.min_hier (), state.max_hier ())); - } - - update_content (); -} - -void -LayoutView::save_view (DisplayState &state) const -{ - state = DisplayState (box (), get_min_hier_levels (), get_max_hier_levels (), m_cellviews); -} - -void -LayoutView::do_redraw (int layer) -{ - std::vector layers; - layers.push_back (layer); - - mp_canvas->redraw_selected (layers); -} - -void -LayoutView::do_prop_changed () -{ - if (m_visibility_changed) { - - // change visibility and redraw exposed layers - std::vector visibility; - for (lay::LayerPropertiesConstIterator l = begin_layers (); !l.at_end (); ++l) { - if (! l->has_children ()) { - visibility.push_back (l->visible (true /*real*/)); - } - } - mp_canvas->change_visibility (visibility); - - m_visibility_changed = false; - - } - - update_content (); -} - void LayoutView::layer_tab_changed () { @@ -4110,625 +720,29 @@ LayoutView::layer_order_changed () update_content (); } -void -LayoutView::set_view_ops () -{ - bool bright_background = (mp_canvas->background_color ().green () > 128); - int brightness_for_context = ((bright_background ? m_ctx_dimming : -m_ctx_dimming) * 256) / 100; - int brightness_for_child_context = ((bright_background ? m_child_ctx_dimming : -m_child_ctx_dimming) * 256) / 100; - - // count the layers to be able to reserve the number of view_ops - size_t nlayers = 0; - for (LayerPropertiesConstIterator lp = get_properties ().begin_const_recursive (); !lp.at_end (); ++lp) { - if (! lp->has_children ()) { - ++nlayers; - } - } - - std::vector view_ops; - view_ops.reserve (nlayers * planes_per_layer + special_planes_before + special_planes_after); - - lay::Color box_color; - if (! m_box_color.is_valid ()) { - box_color = mp_canvas->foreground_color (); - } else { - box_color = m_box_color; - } - - // cell boxes - if (m_cell_box_visible) { - - lay::ViewOp vop; - - // context level - if (m_ctx_color.is_valid ()) { - vop = lay::ViewOp (m_ctx_color.rgb (), lay::ViewOp::Copy, 0, 0, 0); - } else { - vop = lay::ViewOp (lay::LayerProperties::brighter (box_color.rgb (), brightness_for_context), lay::ViewOp::Copy, 0, 0, 0); - } - - // fill, frame, text, vertex - view_ops.push_back (lay::ViewOp (0, lay::ViewOp::Or, 0, 0, 0)); - view_ops.push_back (vop); - view_ops.push_back (vop); - view_ops.push_back (lay::ViewOp (0, lay::ViewOp::Or, 0, 0, 0)); - - // child level - if (m_child_ctx_color.is_valid ()) { - vop = lay::ViewOp (m_child_ctx_color.rgb (), lay::ViewOp::Copy, 0, 0, 0); - } else { - vop = lay::ViewOp (lay::LayerProperties::brighter (box_color.rgb (), brightness_for_context), lay::ViewOp::Copy, 0, 0, 0); - } - - // fill, frame, text, vertex - view_ops.push_back (lay::ViewOp (0, lay::ViewOp::Or, 0, 0, 0)); - view_ops.push_back (vop); - view_ops.push_back (vop); - view_ops.push_back (lay::ViewOp (0, lay::ViewOp::Or, 0, 0, 0)); - - // current level - vop = lay::ViewOp (box_color.rgb (), lay::ViewOp::Copy, 0, 0, 0); - - // fill, frame, text, vertex - view_ops.push_back (lay::ViewOp (0, lay::ViewOp::Or, 0, 0, 0)); - view_ops.push_back (vop); - view_ops.push_back (vop); - view_ops.push_back (lay::ViewOp (0, lay::ViewOp::Or, 0, 0, 0)); - - } else { - // invisible - for (unsigned int i = 0; i < (unsigned int) planes_per_layer; ++i) { // frame, fill, vertex, text - view_ops.push_back (lay::ViewOp (0, lay::ViewOp::Or, 0, 0, 0)); - } - } - - // sanity check: number of planes defined in layRedrawThreadWorker must match to view_ops layout - tl_assert (view_ops.size () == (size_t)cell_box_planes); - - // produce the ViewOps for the guiding shapes - - color_t gs_color = box_color.rgb (); - if (m_guiding_shape_color.is_valid ()) { - gs_color = m_guiding_shape_color.rgb (); - } - - for (int ctx = 0; ctx < 3; ++ctx) { // 0 (context), 1 (child), 2 (current) - - lay::ViewOp::Mode mode = lay::ViewOp::Copy; - - color_t fill_color, frame_color, text_color; - int dp = 1; // no stipples for guiding shapes - - if (ctx == 0) { - - // context planes - if (m_ctx_color.is_valid ()) { - frame_color = text_color = fill_color = m_ctx_color.rgb (); - } else { - frame_color = text_color = fill_color = lay::LayerProperties::brighter (gs_color, brightness_for_context); - } - - if (m_ctx_hollow) { - dp = 1; - } - - } else if (ctx == 1) { - - // child level planes (if used) - if (m_child_ctx_color.is_valid ()) { - frame_color = text_color = fill_color = m_child_ctx_color.rgb (); - } else { - frame_color = text_color = fill_color = lay::LayerProperties::brighter (gs_color, brightness_for_child_context); - } - - if (m_child_ctx_hollow) { - dp = 1; - } - - } else { - - // current level planes - frame_color = text_color = fill_color = gs_color; - - } - - if (m_guiding_shape_visible) { - - // fill - view_ops.push_back (lay::ViewOp (fill_color, mode, 0, dp, 0)); // fill - - // frame - view_ops.push_back (lay::ViewOp (frame_color, mode, 0, 0, 0, lay::ViewOp::Rect, m_guiding_shape_line_width)); - - // text - if (m_text_visible) { - view_ops.push_back (lay::ViewOp (text_color, mode, 0, 0, 0)); - } else { - view_ops.push_back (lay::ViewOp (0, lay::ViewOp::Or, 0, 0, 0)); - } - - // vertex - view_ops.push_back (lay::ViewOp (frame_color, mode, 0, 0, 0, lay::ViewOp::Rect, m_guiding_shape_vertex_size /*mark size*/)); // vertex - - } else { - view_ops.push_back (lay::ViewOp ()); - view_ops.push_back (lay::ViewOp ()); - view_ops.push_back (lay::ViewOp ()); - view_ops.push_back (lay::ViewOp ()); - } - - } - - // sanity check: number of planes defined in layRedrawThreadWorker must match to view_ops layout - tl_assert (view_ops.size () == (size_t)special_planes_before); - - bool animated = false; - - for (int ctx = 0; ctx < 3; ++ctx) { // 0 (context), 1 (child), 2 (current) - - unsigned int ilayer = 0; - for (LayerPropertiesConstIterator lp = get_properties ().begin_const_recursive (); !lp.at_end (); ++lp, ++ilayer) { - - // because accessing the LayerPropertiesNode with lp->... is not quite efficient, we get the pointer here: - const lay::LayerPropertiesNode *l = &*lp; - - if (l->has_children ()) { - continue; - } - - bool animate_visible = true; - unsigned int di_off = m_stipple_offset ? ilayer : 0; - - if (l->animation (true /*real*/)) { - - animated = true; - if (! m_animated) { - m_animated = true; - m_phase = 0; - } - - if (l->animation (true /*real*/) == 1) { - // scrolling - di_off += m_phase; - } else if (l->animation (true /*real*/) == 2) { - // blinking - animate_visible = ((m_phase & 1) == 0); - } else { - // inversely blinking - animate_visible = ((m_phase & 1) != 0); - } - - } - - if (l->visible (true /*real*/) && animate_visible) { - - lay::ViewOp::Mode mode = lay::ViewOp::Copy; - if (l->transparent (true /*real*/)) { - if (bright_background) { - mode = lay::ViewOp::And; - } else { - mode = lay::ViewOp::Or; - } - } - - color_t fill_color, frame_color, text_color; - int dp = m_no_stipples ? 1 : l->dither_pattern (true /*real*/); - int ls = l->line_style (true /*real*/); - - if (ctx == 0) { - - // context planes - if (m_ctx_color.is_valid ()) { - frame_color = text_color = fill_color = m_ctx_color.rgb (); - } else { - fill_color = l->eff_fill_color_brighter (true /*real*/, brightness_for_context); - frame_color = l->eff_frame_color_brighter (true /*real*/, brightness_for_context); - if (m_text_color.is_valid ()) { - text_color = lay::LayerProperties::brighter (m_text_color.rgb (), brightness_for_context); - } else { - text_color = frame_color; - } - } - - if (m_ctx_hollow) { - dp = 1; - } - - } else if (ctx == 1) { - - // child level planes (if used) - if (m_child_ctx_color.is_valid ()) { - frame_color = text_color = fill_color = m_child_ctx_color.rgb (); - } else { - fill_color = l->eff_fill_color_brighter (true /*real*/, brightness_for_child_context); - frame_color = l->eff_frame_color_brighter (true /*real*/, brightness_for_child_context); - if (m_text_color.is_valid ()) { - text_color = lay::LayerProperties::brighter (m_text_color.rgb (), brightness_for_child_context); - } else { - text_color = frame_color; - } - } - - if (m_child_ctx_hollow) { - dp = 1; - } - - } else { - - // current level planes - fill_color = l->eff_fill_color (true /*real*/); - frame_color = l->eff_frame_color (true /*real*/); - if (m_text_color.is_valid ()) { - text_color = m_text_color.rgb (); - } else { - text_color = frame_color; - } - - } - - // fill - view_ops.push_back (lay::ViewOp (fill_color, mode, 0, dp, di_off)); // fill - - // frame - int lw = l->width (true /*real*/); - if (lw < 0) { - // default line width is 0 for parents and 1 for leafs - lw = l->has_children () ? 0 : 1; - } - view_ops.push_back (lay::ViewOp (frame_color, mode, ls, 0, 0, lay::ViewOp::Rect, lw)); - - // text - if (m_text_visible) { - view_ops.push_back (lay::ViewOp (text_color, mode, 0, 0, 0)); - } else { - view_ops.push_back (lay::ViewOp (0, lay::ViewOp::Or, 0, 0, 0)); - } - // vertex - view_ops.push_back (lay::ViewOp (frame_color, mode, 0, 0, 0, lay::ViewOp::Cross, l->marked (true /*real*/) ? 9/*mark size*/ : 0)); // vertex - - } else { - for (unsigned int i = 0; i < (unsigned int) planes_per_layer / 3; ++i) { - view_ops.push_back (lay::ViewOp (0, lay::ViewOp::Or, 0, 0, 0)); - } - } - - } - - } - - if (! animated) { - m_animated = false; - m_phase = 0; - } - - mp_canvas->set_view_ops (view_ops); -} - -void -LayoutView::guiding_shapes_visible (bool v) -{ - if (v != m_guiding_shape_visible) { - m_guiding_shape_visible = v; - update_content (); - } -} - -void -LayoutView::guiding_shapes_color (lay::Color c) -{ - if (c != m_guiding_shape_color) { - m_guiding_shape_color = c; - update_content (); - } -} - -void -LayoutView::guiding_shapes_line_width (int v) -{ - if (v != m_guiding_shape_line_width) { - m_guiding_shape_line_width = v; - update_content (); - } -} - -void -LayoutView::guiding_shapes_vertex_size (int v) -{ - if (v != m_guiding_shape_vertex_size) { - m_guiding_shape_vertex_size = v; - update_content (); - } -} - -void -LayoutView::draw_array_border_instances (bool m) -{ - if (m != m_draw_array_border_instances) { - m_draw_array_border_instances = m; - redraw (); - } -} - -void -LayoutView::drop_small_cells (bool m) -{ - if (m != m_drop_small_cells) { - m_drop_small_cells = m; - redraw (); - } -} - -void -LayoutView::drop_small_cells_value (unsigned int s) -{ - if (s != m_drop_small_cells_value) { - m_drop_small_cells_value = s; - redraw (); - } -} - -void -LayoutView::drop_small_cells_cond (drop_small_cells_cond_type t) -{ - if (t != m_drop_small_cells_cond) { - m_drop_small_cells_cond = t; - redraw (); - } -} - -void -LayoutView::cell_box_color (lay::Color c) -{ - if (c != m_box_color) { - m_box_color = c; - update_content (); - } -} - -void -LayoutView::cell_box_text_transform (bool xform) -{ - if (xform != m_box_text_transform) { - m_box_text_transform = xform; - redraw (); - } -} - -void -LayoutView::cell_box_text_font (unsigned int f) -{ - if (f != m_box_font) { - m_box_font = f; - redraw (); - } -} - -bool -LayoutView::set_hier_levels_basic (std::pair l) -{ - if (l != get_hier_levels ()) { - - if (mp_min_hier_spbx) { - mp_min_hier_spbx->blockSignals (true); - mp_min_hier_spbx->setValue (l.first); - mp_min_hier_spbx->setMaximum (l.second); - mp_min_hier_spbx->blockSignals (false); - } - - if (mp_max_hier_spbx) { - mp_max_hier_spbx->blockSignals (true); - mp_max_hier_spbx->setValue (l.second); - mp_max_hier_spbx->setMinimum (l.first); - mp_max_hier_spbx->blockSignals (false); - } - - m_from_level = l.first; - m_to_level = l.second; - - // notify all connected observers - hier_levels_changed_event (); - - redraw (); - - return true; - - } else { - return false; - } -} - -void -LayoutView::set_hier_levels (std::pair l) -{ - if (set_hier_levels_basic (l)) { - store_state (); - } -} - -std::pair -LayoutView::get_hier_levels () const -{ - return std::make_pair (m_from_level, m_to_level); -} - void LayoutView::min_hier_changed (int i) { mp_max_hier_spbx->setMinimum (i); - set_hier_levels (std::make_pair (i, m_to_level)); + set_hier_levels (std::make_pair (i, get_hier_levels ().second)); } void LayoutView::max_hier_changed (int i) { mp_min_hier_spbx->setMaximum (i); - set_hier_levels (std::make_pair (m_from_level, i)); + set_hier_levels (std::make_pair (get_hier_levels ().first, i)); } -/** - * @brief set the maximum hierarchy level to the number of levels available - */ -void -LayoutView::max_hier () +lay::Color +LayoutView::default_background_color () { - // determine the maximum level of hierarchies - int max_level = max_hier_level (); - - // and set the levels - if (max_level > 0) { - set_hier_levels (std::make_pair (std::min (m_from_level, max_level), max_level)); - } -} - -/** - * @brief determine the maximum hierarchy level - */ -int -LayoutView::max_hier_level () const -{ - int max_level = 0; - for (std::list ::const_iterator cv = m_cellviews.begin (); cv != m_cellviews.end (); ++cv) { - if (cv->is_valid ()) { - int nl = cv->ctx_cell ()->hierarchy_levels () + 1; - if (nl > max_level) { - max_level = nl; - } - } - } - return max_level; -} - -/** - * @brief Returns a value indicating whether the maximum level is shown - */ -bool -LayoutView::has_max_hier () const -{ - int ml = max_hier_level (); - return ml > 0 && m_to_level >= ml; -} - -void -LayoutView::set_palette (const lay::ColorPalette &p) -{ - m_palette = p; -} - -void -LayoutView::set_palette (const lay::StipplePalette &p) -{ - m_stipple_palette = p; -} - -void -LayoutView::set_palette (const lay::LineStylePalette &p) -{ - m_line_style_palette = p; -} - -void -LayoutView::ctx_color (lay::Color c) -{ - if (c != m_ctx_color) { - m_ctx_color = c; - update_content (); - } -} - -void -LayoutView::ctx_dimming (int d) -{ - if (d != m_ctx_dimming) { - m_ctx_dimming = d; - update_content (); - } -} - -void -LayoutView::ctx_hollow (bool h) -{ - if (h != m_ctx_hollow) { - m_ctx_hollow = h; - update_content (); - } -} - -void -LayoutView::child_ctx_color (lay::Color c) -{ - if (c != m_child_ctx_color) { - m_child_ctx_color = c; - update_content (); - } -} - -void -LayoutView::child_ctx_dimming (int d) -{ - if (d != m_child_ctx_dimming) { - m_child_ctx_dimming = d; - update_content (); - } -} - -void -LayoutView::child_ctx_hollow (bool h) -{ - if (h != m_child_ctx_hollow) { - m_child_ctx_hollow = h; - update_content (); - } -} - -void -LayoutView::child_ctx_enabled (bool f) -{ - if (f != m_child_ctx_enabled) { - m_child_ctx_enabled = f; - update_content (); - redraw (); - } -} - -void -LayoutView::abstract_mode_width (double w) -{ - if (fabs (w - m_abstract_mode_width) > 1e-6) { - m_abstract_mode_width = w; - if (m_abstract_mode_enabled) { - redraw (); - } - } -} - -void -LayoutView::abstract_mode_enabled (bool e) -{ - if (e != m_abstract_mode_enabled) { - m_abstract_mode_enabled = e; - redraw (); - } + return lay::Color (palette ().color (QPalette::Normal, QPalette::Base).rgb ()); } void -LayoutView::background_color (lay::Color c) +LayoutView::do_set_background_color (lay::Color c, lay::Color contrast) { - if (c == mp_canvas->background_color ()) { - return; - } - - // replace by "real" background color if required - if (! c.is_valid ()) { - c = lay::Color (palette ().color (QPalette::Normal, QPalette::Base).rgb ()); - } - - lay::Color contrast; - if (c.green () > 128) { - contrast = lay::Color (0, 0, 0); - } else { - contrast = lay::Color (255, 255, 255); - } - if (mp_control_panel) { mp_control_panel->set_background_color (c); mp_control_panel->set_text_color (contrast); @@ -4748,67 +762,6 @@ LayoutView::background_color (lay::Color c) mp_bookmarks_view->set_background_color (c); mp_bookmarks_view->set_text_color (contrast); } - - if (mp_selection_service) { - mp_selection_service->set_colors (c, contrast); - } - if (mp_zoom_service) { - mp_zoom_service->set_colors (c, contrast); - } - - // Set the color for all ViewService interfaces - for (std::vector::iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) { - lay::ViewService *svc = (*p)->view_service_interface (); - if (svc) { - svc->set_colors (c, contrast); - } - } - - mp_canvas->set_colors (c, contrast, mp_canvas->active_color ()); - - update_content (); - - background_color_changed_event (); -} - -void -LayoutView::dbu_coordinates (bool f) -{ - m_dbu_coordinates = f; -} - -void -LayoutView::absolute_coordinates (bool f) -{ - m_absolute_coordinates = f; -} - -void -LayoutView::select_cellviews_fit (const std::list &cvs) -{ - if (m_cellviews != cvs) { - - for (int index = 0; index < int (m_cellviews.size ()); ++index) { - cellview_about_to_change_event (index); - } - - cellviews_about_to_change_event (); - - set_min_hier_levels (0); - cancel_esc (); - m_cellviews = cvs; - zoom_fit (); - finish_cellviews_changed (); - - for (int index = 0; index < int (m_cellviews.size ()); ++index) { - cellview_changed (index); - } - - update_content (); - - } else { - zoom_fit (); - } } void @@ -4826,7 +779,7 @@ LayoutView::active_cellview_changed (int index) active_cellview_changed_with_index_event (index); // Because the title reflects the active one, emit a title changed event - if (m_title.empty ()) { + if (title_string ().empty ()) { emit title_changed (); } @@ -4846,435 +799,6 @@ LayoutView::active_library_changed (int /*index*/) dispatcher ()->config_set (cfg_current_lib_view, lib_name); } -void -LayoutView::cellview_changed (unsigned int index) -{ - if (mp_hierarchy_panel) { - mp_hierarchy_panel->do_update_content (index); - } - - cellview_changed_event (index); - - if (m_title.empty ()) { - emit title_changed (); - } -} - -void -LayoutView::select_cell_dispatch (const cell_path_type &path, int cellview_index) -{ - bool set_max_hier = (m_full_hier_new_cell || has_max_hier ()); - if (m_clear_ruler_new_cell) { - - // This is a HACK, but the clean solution would be to provide a new editable - // method like "clear_annotations": - lay::Plugin *antPlugin = get_plugin_by_name ("ant::Plugin"); - if (antPlugin) { - antPlugin->menu_activated ("ant::clear_all_rulers_internal"); - } - - } - - if (m_fit_new_cell) { - select_cell_fit (path, cellview_index); - } else { - select_cell (path, cellview_index); - } - set_current_cell_path (cellview_index, path); - if (set_max_hier) { - max_hier (); - } -} - -void -LayoutView::select_cell_fit (const cell_path_type &path, int index) -{ - if (index >= 0 && int (m_cellviews.size ()) > index && (cellview_iter (index)->specific_path ().size () > 0 || cellview_iter (index)->unspecific_path () != path)) { - - cellview_about_to_change_event (index); - - set_min_hier_levels (0); - cancel (); - cellview_iter (index)->set_specific_path (lay::CellView::specific_cell_path_type ()); - cellview_iter (index)->set_unspecific_path (path); - set_active_cellview_index (index); - redraw (); - zoom_fit (); - - cellview_changed (index); - - update_content (); - - } -} - -void -LayoutView::select_cell_fit (cell_index_type cell_index, int index) -{ - if (index >= 0 && int (m_cellviews.size ()) > index && cellview_iter (index)->cell_index () != cell_index) { - - cellview_about_to_change_event (index); - - set_min_hier_levels (0); - cancel (); - cellview_iter (index)->set_cell (cell_index); - set_active_cellview_index (index); - redraw (); - zoom_fit (); - - cellview_changed (index); - - update_content (); - - } -} - -void -LayoutView::select_cellviews (const std::list &cvs) -{ - if (m_cellviews != cvs) { - - for (int index = 0; index < int (m_cellviews.size ()); ++index) { - cellview_about_to_change_event (index); - } - cellviews_about_to_change_event (); - - set_min_hier_levels (0); - cancel_esc (); - m_cellviews = cvs; - redraw (); - - cellviews_changed_event (); - for (int index = 0; index < int (m_cellviews.size ()); ++index) { - cellview_changed (index); - } - - update_content (); - - } -} - -void -LayoutView::select_cellview (int index, const CellView &cv) -{ - if (index < 0 || index >= int (m_cellviews.size ())) { - return; - } - - if (*cellview_iter (index) != cv) { - - cellview_about_to_change_event (index); - - cancel_esc (); - *cellview_iter (index) = cv; - redraw (); - - cellview_changed (index); - - update_content (); - - } -} - -void -LayoutView::select_cell (const cell_path_type &path, int index) -{ - if (index >= 0 && int (m_cellviews.size ()) > index && (cellview_iter (index)->specific_path ().size () > 0 || cellview_iter (index)->unspecific_path () != path)) { - - cellview_about_to_change_event (index); - - set_min_hier_levels (0); - cancel (); - cellview_iter (index)->set_specific_path (lay::CellView::specific_cell_path_type ()); - cellview_iter (index)->set_unspecific_path (path); - set_active_cellview_index (index); - redraw (); - - cellview_changed (index); - - update_content (); - - } -} - -void -LayoutView::select_cell (cell_index_type cell_index, int index) -{ - if (index >= 0 && int (m_cellviews.size ()) > index && (! cellview_iter (index)->is_valid () || cellview_iter (index)->cell_index () != cell_index)) { - - cellview_about_to_change_event (index); - - set_min_hier_levels (0); - cancel (); - cellview_iter (index)->set_cell (cell_index); - set_active_cellview_index (index); - redraw (); - - cellview_changed (index); - - update_content (); - - } -} - -bool -LayoutView::is_cell_hidden (cell_index_type ci, int cellview_index) const -{ - if (int (m_hidden_cells.size ()) > cellview_index && cellview_index >= 0) { - return m_hidden_cells [cellview_index].find (ci) != m_hidden_cells [cellview_index].end (); - } else { - return false; - } -} - -const std::set & -LayoutView::hidden_cells (int cellview_index) const -{ - if (int (m_hidden_cells.size ()) > cellview_index && cellview_index >= 0) { - return m_hidden_cells[cellview_index]; - } else { - static std::set empty_set; - return empty_set; - } -} - -void -LayoutView::hide_cell (cell_index_type ci, int cellview_index) -{ - if (cellview_index < 0) { - return; - } - while (int (m_hidden_cells.size ()) <= cellview_index) { - m_hidden_cells.push_back (std::set ()); - } - if (m_hidden_cells [cellview_index].insert (ci).second) { - if (transacting ()) { - manager ()->queue (this, new OpHideShowCell (ci, cellview_index, false /*=hide*/)); - } else if (manager () && ! replaying ()) { - manager ()->clear (); - } - cell_visibility_changed_event (); - redraw (); // needs redraw - } -} - -void -LayoutView::show_cell (cell_index_type ci, int cellview_index) -{ - if (cellview_index < 0) { - return; - } - if (int (m_hidden_cells.size ()) > cellview_index) { - if (m_hidden_cells [cellview_index].erase (ci) > 0) { - if (transacting ()) { - manager ()->queue (this, new OpHideShowCell (ci, cellview_index, true /*=show*/)); - } else if (manager () && ! replaying ()) { - manager ()->clear (); - } - cell_visibility_changed_event (); - redraw (); // needs redraw - } - } -} - -void -LayoutView::show_all_cells (int cv_index) -{ - if (cv_index < 0 || cv_index >= int (m_hidden_cells.size ())) { - return; - } - - if (! m_hidden_cells [cv_index].empty ()) { - if (transacting ()) { - for (std::set::const_iterator ci = m_hidden_cells [cv_index].begin (); ci != m_hidden_cells [cv_index].end (); ++ci) { - manager ()->queue (this, new OpHideShowCell (*ci, cv_index, true /*=show*/)); - } - } else if (manager () && ! replaying ()) { - manager ()->clear (); - } - m_hidden_cells [cv_index].clear (); - cell_visibility_changed_event (); - redraw (); // needs redraw - } -} - -void -LayoutView::show_all_cells () -{ - bool any = false; - - for (unsigned int i = 0; i < m_hidden_cells.size (); ++i) { - if (! m_hidden_cells [i].empty ()) { - if (transacting ()) { - for (std::set::const_iterator ci = m_hidden_cells [i].begin (); ci != m_hidden_cells [i].end (); ++ci) { - manager ()->queue (this, new OpHideShowCell (*ci, i, true /*=show*/)); - } - } else if (manager () && ! replaying ()) { - manager ()->clear (); - } - m_hidden_cells [i].clear (); - any = true; - } - } - - if (any) { - cell_visibility_changed_event (); - redraw (); // needs redraw - return; - } -} - -void -LayoutView::min_inst_label_size (int px) -{ - if (m_min_size_for_label != px) { - m_min_size_for_label = px; - redraw (); - } -} - -void -LayoutView::text_visible (bool vis) -{ - if (m_text_visible != vis) { - m_text_visible = vis; - update_content (); - redraw (); // required because we do some optimizations is text is not visible .. - } -} - -void -LayoutView::show_properties_as_text (bool sp) -{ - if (m_show_properties != sp) { - m_show_properties = sp; - redraw (); // required because we do some optimizations is text is not visible .. - } -} - -void -LayoutView::bitmap_caching (bool l) -{ - if (m_bitmap_caching != l) { - m_bitmap_caching = l; - redraw (); // required because we do some optimizations is text is not visible .. - } -} - -void -LayoutView::text_lazy_rendering (bool l) -{ - if (m_text_lazy_rendering != l) { - m_text_lazy_rendering = l; - redraw (); // required because we do some optimizations is text is not visible .. - } -} - -void -LayoutView::cell_box_visible (bool vis) -{ - if (m_cell_box_visible != vis) { - m_cell_box_visible = vis; - update_content (); - } -} - -void -LayoutView::text_font (unsigned int f) -{ - if (m_text_font != f) { - m_text_font = f; - redraw (); - } -} - -void -LayoutView::default_text_size (double fs) -{ - if (m_default_text_size != fs) { - m_default_text_size = fs; - redraw (); - } -} - -void -LayoutView::clear_ruler_new_cell (bool f) -{ - m_clear_ruler_new_cell = f; -} - -void -LayoutView::full_hier_new_cell (bool f) -{ - m_full_hier_new_cell = f; -} - -double -LayoutView::pan_distance () const -{ - return m_pan_distance; -} - -void -LayoutView::pan_distance (double pd) -{ - m_pan_distance = pd; -} - -void -LayoutView::fit_new_cell (bool f) -{ - m_fit_new_cell = f; -} - -void -LayoutView::apply_text_trans (bool f) -{ - if (m_apply_text_trans != f) { - m_apply_text_trans = f; - redraw (); - } -} - -void -LayoutView::offset_stipples (bool f) -{ - if (m_stipple_offset != f) { - m_stipple_offset = f; - update_content (); - } -} - -void -LayoutView::no_stipples (bool f) -{ - if (m_no_stipples != f) { - m_no_stipples = f; - if (mp_control_panel) { - mp_control_panel->set_no_stipples (m_no_stipples); - } - update_content (); - } -} - -void -LayoutView::show_markers (bool f) -{ - if (m_show_markers != f) { - m_show_markers = f; - mp_canvas->update_image (); - } -} - -void -LayoutView::text_color (lay::Color c) -{ - if (m_text_color != c) { - m_text_color = c; - update_content (); - } -} - bool LayoutView::has_selection () { @@ -5283,67 +807,19 @@ LayoutView::has_selection () } else if (mp_hierarchy_panel && mp_hierarchy_panel->has_focus ()) { return mp_hierarchy_panel->has_selection (); } else { - return lay::Editables::has_selection (); + return lay::LayoutViewBase::has_selection (); } } void -LayoutView::paste () +LayoutView::do_paste () { - clear_selection (); - - { - db::Transaction trans (manager (), tl::to_string (QObject::tr ("Paste"))); - - // let the receivers sort out who is pasting what .. - if (mp_hierarchy_panel) { - mp_hierarchy_panel->paste (); - } - if (mp_control_panel) { - mp_control_panel->paste (); - } - lay::Editables::paste (); + // let the receivers sort out who is pasting what .. + if (mp_hierarchy_panel) { + mp_hierarchy_panel->paste (); } - - // if we change the state, save it before - store_state (); - - db::DBox sel_bbox = selection_bbox (); - if (! sel_bbox.empty ()) { - if (m_paste_display_mode == 1) { - // just make selection visible, i.e. shift window somewhat - pan_center (sel_bbox.center ()); - } else if (m_paste_display_mode == 2) { - // or: make selection fit into the screen - zoom_fit_sel (); - } - } -} - -void -LayoutView::paste_interactive () -{ - clear_selection (); - - std::unique_ptr trans (new db::Transaction (manager (), tl::to_string (QObject::tr ("Paste and move")))); - - { - // let the receivers sort out who is pasting what .. - if (mp_hierarchy_panel) { - mp_hierarchy_panel->paste (); - } - if (mp_control_panel) { - mp_control_panel->paste (); - } - lay::Editables::paste (); - } - - // temporarily close the transaction and pass to the move service for appending it's own - // operations. - trans->close (); - - if (mp_move_service->begin_move (trans.release (), false)) { - switch_mode (-1); // move mode + if (mp_control_panel) { + mp_control_panel->paste (); } } @@ -5355,14 +831,7 @@ LayoutView::copy () } else if (mp_control_panel && mp_control_panel->has_focus ()) { mp_control_panel->copy (); } else { - - if (! lay::Editables::has_selection ()) { - // try to use the transient selection for the real one - lay::Editables::transient_to_selection (); - } - - lay::Editables::copy (); - + LayoutViewBase::copy (); } } @@ -5377,150 +846,10 @@ LayoutView::cut () db::Transaction trans (manager (), tl::to_string (QObject::tr ("Cut Layers"))); mp_control_panel->cut (); } else { - - if (! lay::Editables::has_selection ()) { - // try to use the transient selection for the real one - lay::Editables::transient_to_selection (); - } - - db::Transaction trans (manager (), tl::to_string (QObject::tr ("Cut"))); - lay::Editables::cut (); - + LayoutViewBase::cut (); } } -void -LayoutView::add_missing_layers () -{ - std::set present; - LayerPropertiesConstIterator l = begin_layers (); - while (! l.at_end ()) { - if (! l->has_children ()) { - present.insert (l->source (true /*real*/)); - } - ++l; - } - - std::vector actual; - for (unsigned int cv = 0; cv < cellviews (); ++cv) { - const db::Layout &layout = cellview (cv)->layout (); - for (unsigned int l = 0; l < layout.layers (); ++l) { - if (layout.is_valid_layer (l)) { - actual.push_back (lay::ParsedLayerSource (layout.get_properties (l), cv)); - } - } - } - - std::sort (actual.begin (), actual.end ()); - - for (std::vector ::const_iterator a = actual.begin (); a != actual.end (); ++a) { - if (present.find (*a) == present.end ()) { - lay::LayerPropertiesNode node; - node.attach_view (this, current_layer_list ()); - node.set_source (*a); - init_layer_properties (node); - insert_layer (end_layers (), node); - } - } - - emit layer_order_changed (); -} - -LayerState -LayoutView::layer_snapshot () const -{ - LayerState state; - LayerPropertiesConstIterator l = begin_layers (); - while (! l.at_end ()) { - if (! l->has_children ()) { - state.present.insert (l->source (true /*real*/)); - } - ++l; - } - return state; -} - -void -LayoutView::current_layer_changed_slot (const lay::LayerPropertiesConstIterator &iter) -{ - current_layer_changed_event (iter); -} - -void -LayoutView::add_new_layers (const LayerState &state) -{ - std::vector actual; - for (unsigned int cv = 0; cv < cellviews (); ++cv) { - const db::Layout &layout = cellview (cv)->layout (); - for (unsigned int l = 0; l < layout.layers (); ++l) { - if (layout.is_valid_layer (l)) { - actual.push_back (lay::ParsedLayerSource (layout.get_properties (l), cv)); - } - } - } - - std::sort (actual.begin (), actual.end ()); - - bool needs_update = false; - - for (std::vector ::const_iterator a = actual.begin (); a != actual.end (); ++a) { - if (state.present.find (*a) == state.present.end ()) { - needs_update = true; - lay::LayerPropertiesNode node; - node.attach_view (this, current_layer_list ()); - node.set_source (*a); - // HINT: in editable mode it is desireable to present all layers because otherwise they cannot be - // made visible to populate them. - if (is_editable () || ! node.bbox ().empty ()) { - init_layer_properties (node); - insert_layer (end_layers (), node); - } - } - } - - if (needs_update) { - emit layer_order_changed (); - } -} - -void -LayoutView::remove_unused_layers () -{ - if (mp_control_panel) { - mp_control_panel->cm_remove_unused (); - } -} - -void -LayoutView::prev_display_state () -{ - if (m_display_state_ptr > 0) { - m_display_state_ptr--; - goto_view (m_display_states [m_display_state_ptr]); - } -} - -bool -LayoutView::has_prev_display_state () -{ - return m_display_state_ptr > 0; -} - -void -LayoutView::next_display_state () -{ - if (m_display_state_ptr + 1 < m_display_states.size ()) { - m_display_state_ptr++; - goto_view (m_display_states [m_display_state_ptr]); - } -} - -bool -LayoutView::has_next_display_state () -{ - return m_display_state_ptr + 1 < m_display_states.size (); -} - const lay::CellView & LayoutView::active_cellview () const { @@ -5542,7 +871,7 @@ LayoutView::active_cellview_index () const void LayoutView::set_active_cellview_index (int index) { - if (index >= 0 && index < int (m_cellviews.size ())) { + if (index >= 0 && index < int (cellviews ())) { mp_hierarchy_panel->select_active (index); } } @@ -5569,7 +898,7 @@ void LayoutView::activate () { if (! m_activated) { - for (std::vector::iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) { + for (std::vector::const_iterator p = plugins ().begin (); p != plugins ().end (); ++p) { if ((*p)->browser_interface () && (*p)->browser_interface ()->active ()) { (*p)->browser_interface ()->show (); } @@ -5583,14 +912,14 @@ LayoutView::activate () void LayoutView::deactivate () { - for (std::vector::iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) { + for (std::vector::const_iterator p = plugins ().begin (); p != plugins ().end (); ++p) { if ((*p)->browser_interface ()) { (*p)->browser_interface ()->hide (); } } emit clear_current_pos (); - mp_canvas->free_resources (); + free_resources (); mp_timer->stop (); m_activated = false; } @@ -5598,7 +927,7 @@ LayoutView::deactivate () void LayoutView::deactivate_all_browsers () { - for (std::vector::iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) { + for (std::vector::const_iterator p = plugins ().begin (); p != plugins ().end (); ++p) { if ((*p)->browser_interface ()) { (*p)->browser_interface ()->deactivate (); } @@ -5623,398 +952,21 @@ LayoutView::current_pos (double x, double y) } } -void -LayoutView::stop_redraw () -{ - mp_canvas->stop_redraw (); -} - -void -LayoutView::stop () -{ - stop_redraw (); - deactivate_all_browsers (); -} - -void -LayoutView::mode (int m) -{ - if (m != m_mode) { - - m_mode = m; - lay::Plugin *active_plugin = 0; - - if (m > 0) { - - for (std::vector::iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) { - if ((*p)->plugin_declaration ()->id () == m) { - active_plugin = *p; - mp_canvas->activate ((*p)->view_service_interface ()); - break; - } - } - - } else if (m == 0 && mp_selection_service) { - mp_canvas->activate (mp_selection_service); - } else if (m == -1 && mp_move_service) { - mp_canvas->activate (mp_move_service); - } - - lay::EditorOptionsPages *eo_pages = editor_options_pages (); - if (eo_pages) { - - // TODO: this is very inefficient as each "activate" will regenerate the tabs - for (std::vector::const_iterator op = eo_pages->pages ().begin (); op != eo_pages->pages ().end (); ++op) { - bool is_active = false; - if ((*op)->plugin_declaration () == 0) { - is_active = true; - } else if (active_plugin && active_plugin->plugin_declaration () == (*op)->plugin_declaration ()) { - is_active = true; - } - (*op)->activate (is_active); - } - - } - - } -} - -bool -LayoutView::is_move_mode () const -{ - return m_mode == -1; -} - -bool -LayoutView::is_selection_mode () const -{ - return m_mode == 0; -} - -unsigned int -LayoutView::intrinsic_mouse_modes (std::vector *descriptions) -{ - if (descriptions) { - descriptions->push_back ("select\t" + tl::to_string (QObject::tr ("Select")) + "<:select.png>"); - descriptions->push_back ("move\t" + tl::to_string (QObject::tr ("Move")) + "<:move.png>"); - } - return 2; -} - -int -LayoutView::default_mode () -{ - return 0; // TODO: any generic scheme? is select, should be ruler.. -} - -std::vector -LayoutView::menu_symbols () -{ - // TODO: currently these are all symbols from all plugins - return lay::PluginDeclaration::menu_symbols (); -} - -void -LayoutView::menu_activated (const std::string &symbol) -{ - // Try the plugin declarations if the view is the top-level dispatcher - if (dispatcher () == this) { - for (tl::Registrar::iterator cls = tl::Registrar::begin (); cls != tl::Registrar::end (); ++cls) { - if (cls->menu_activated (symbol)) { - return; - } - } - } - - // distribute the menu item call on the plugins - one should take it. - for (std::vector::const_iterator p = plugins ().begin (); p != plugins ().end (); ++p) { - (*p)->menu_activated (symbol); - } -} - -void -LayoutView::rename_cellview (const std::string &name, int cellview_index) -{ - if (cellview_index >= 0 && cellview_index < int (m_cellviews.size ())) { - if ((*cellview_iter (cellview_index))->name () != name) { - (*cellview_iter (cellview_index))->rename (name); - mp_hierarchy_panel->do_update_content (cellview_index); - if (m_title.empty ()) { - emit title_changed (); - } - } - } -} - -std::vector -LayoutView::cv_transform_variants (int cv_index) const -{ - std::set trns_variants; - for (lay::LayerPropertiesConstIterator l = begin_layers (); !l.at_end (); ++l) { - if (! l->has_children ()) { - int cvi = l->cellview_index () >= 0 ? l->cellview_index () : 0; - if (cv_index < int (cellviews ()) && cvi == cv_index) { - trns_variants.insert (l->trans ().begin (), l->trans ().end ()); - } - } - } - return std::vector (trns_variants.begin (), trns_variants.end ()); -} - -std::vector -LayoutView::cv_transform_variants (int cv_index, unsigned int layer) const -{ - if (cellview (cv_index)->layout ().is_valid_layer (layer)) { - std::set trns_variants; - for (lay::LayerPropertiesConstIterator l = begin_layers (); !l.at_end (); ++l) { - if (! l->has_children () && l->layer_index () == int (layer)) { - int cvi = l->cellview_index () >= 0 ? l->cellview_index () : 0; - if (cv_index < int (cellviews ()) && cvi == cv_index) { - trns_variants.insert (l->trans ().begin (), l->trans ().end ()); - } - } - } - return std::vector (trns_variants.begin (), trns_variants.end ()); - } else { - // may happen if the layer is a guiding shape layer for example - return cv_transform_variants (cv_index); - } -} - -std::map > -LayoutView::cv_transform_variants_by_layer (int cv_index) const -{ - std::map > tv_map; - - for (lay::LayerPropertiesConstIterator l = begin_layers (); !l.at_end (); ++l) { - if (! l->has_children () && l->layer_index () >= 0) { - int cvi = l->cellview_index () >= 0 ? l->cellview_index () : 0; - if (cv_index < int (cellviews ()) && cvi == cv_index) { - std::vector &v = tv_map.insert (std::make_pair (l->layer_index (), std::vector ())).first->second; - v.insert (v.end (), l->trans ().begin (), l->trans ().end ()); - } - } - } - - for (std::map >::iterator m = tv_map.begin (); m != tv_map.end (); ++m) { - std::sort (m->second.begin (), m->second.end ()); - m->second.erase (std::unique (m->second.begin (), m->second.end ()), m->second.end ()); - } - - return tv_map; -} - -std::set< std::pair > -LayoutView::cv_transform_variants () const -{ - std::set< std::pair > box_variants; - for (lay::LayerPropertiesConstIterator l = begin_layers (); !l.at_end (); ++l) { - if (! l->has_children ()) { - unsigned int cv_index = l->cellview_index () >= 0 ? (unsigned int) l->cellview_index () : 0; - if (cv_index < cellviews ()) { - for (std::vector::const_iterator t = l->trans ().begin (); t != l->trans ().end (); ++t) { - box_variants.insert (std::make_pair (*t, cv_index)); - } - } - } - } - return box_variants; -} - -db::InstElement -LayoutView::ascend (int index) -{ - tl_assert (int (m_cellviews.size ()) > index && cellview_iter (index)->is_valid ()); - - cellview_about_to_change_event (index); - - lay::CellView::specific_cell_path_type spath (cellview_iter (index)->specific_path ()); - if (spath.empty ()) { - return db::InstElement (); - } else { - - cancel (); - db::InstElement ret = spath.back (); - spath.pop_back (); - cellview_iter (index)->set_specific_path (spath); - - store_state (); - redraw (); - - cellview_changed (index); - - update_content (); - - return ret; - - } -} - -void -LayoutView::descend (const std::vector &path, int index) -{ - if (! path.empty () && index >= 0 && int (m_cellviews.size ()) > index && cellview_iter (index)->is_valid ()) { - - cellview_about_to_change_event (index); - - cancel (); - - lay::CellView::specific_cell_path_type spath (cellview_iter (index)->specific_path ()); - spath.insert (spath.end (), path.begin (), path.end ()); - cellview_iter (index)->set_specific_path (spath); - - store_state (); - redraw (); - - cellview_changed (index); - - update_content (); - - } -} - -bool -LayoutView::is_editable () const -{ - return m_editable; -} - -unsigned int -LayoutView::search_range () -{ - return m_search_range; -} - -void -LayoutView::set_search_range (unsigned int sr) -{ - m_search_range = sr; -} - -unsigned int -LayoutView::search_range_box () -{ - return m_search_range_box; -} - -void -LayoutView::set_search_range_box (unsigned int sr) -{ - m_search_range_box = sr; -} - void LayoutView::message (const std::string &s, int timeout) { emit show_message (s, timeout * 1000); } -db::cell_index_type -LayoutView::new_cell (int cv_index, const std::string &cell_name) -{ - db::cell_index_type new_ci (0); - - if (cv_index >= 0 && int (m_cellviews.size ()) > cv_index) { - - db::Layout &layout = cellview (cv_index)->layout (); - if (! cell_name.empty () && layout.cell_by_name (cell_name.c_str ()).first) { - throw tl::Exception (tl::to_string (QObject::tr ("A cell with that name already exists: %s")), cell_name); - } - - transaction (tl::to_string (QObject::tr ("New cell"))); - new_ci = layout.add_cell (cell_name.empty () ? 0 : cell_name.c_str ()); - commit (); - - } - - return new_ci; -} - void LayoutView::switch_mode (int m) { - if (m_mode != m) { + if (mode () != m) { mode (m); emit mode_change (m); } } -template -static void make_unique_name (T *object, Iter from, Iter to) -{ - std::string n (object->name ()); - int nn = 0; - - do { - - bool found = n.empty (); - for (Iter i = from; i != to && !found; ++i) { - if ((*i)->name () == n) { - found = true; - } - } - - if (! found) { - break; - } - - n = object->name () + tl::sprintf ("[%d]", ++nn); - - } while (1); - - object->set_name (n); -} - -unsigned int -LayoutView::add_l2ndb (db::LayoutToNetlist *l2ndb) -{ - make_unique_name (l2ndb, m_l2ndbs.begin (), m_l2ndbs.end ()); - m_l2ndbs.push_back (l2ndb); - - // Mark this object as owned by us (for GSI) - l2ndb->keep (); - - l2ndb_list_changed_event (); - - return (unsigned int)(m_l2ndbs.size () - 1); -} - -unsigned int -LayoutView::replace_l2ndb (unsigned int db_index, db::LayoutToNetlist *l2ndb) -{ - tl_assert (l2ndb != 0); - - if (db_index < m_l2ndbs.size ()) { - - // keep the name as it is used for reference in the browser for example - std::string n = m_l2ndbs [db_index]->name (); - l2ndb->set_name (n); - - delete m_l2ndbs [db_index]; - m_l2ndbs [db_index] = l2ndb; - - // Mark this object as owned by us (for GSI) - l2ndb->keep (); - - l2ndb_list_changed_event (); - - return db_index; - - } else { - return add_l2ndb (l2ndb); - } -} - -db::LayoutToNetlist * -LayoutView::get_l2ndb (int index) -{ - if (index >= 0 && index < int (m_l2ndbs.size ())) { - return m_l2ndbs [index]; - } else { - return 0; - } -} - void LayoutView::open_l2ndb_browser (int l2ndb_index, int cv_index) { @@ -6024,76 +976,6 @@ LayoutView::open_l2ndb_browser (int l2ndb_index, int cv_index) } } -const db::LayoutToNetlist * -LayoutView::get_l2ndb (int index) const -{ - if (index >= 0 && index < int (m_l2ndbs.size ())) { - return m_l2ndbs [index]; - } else { - return 0; - } -} - -void -LayoutView::remove_l2ndb (unsigned int index) -{ - if (index < (unsigned int) (m_l2ndbs.size ())) { - delete m_l2ndbs [index]; - m_l2ndbs.erase (m_l2ndbs.begin () + index); - l2ndb_list_changed_event (); - } -} - -unsigned int -LayoutView::add_rdb (rdb::Database *rdb) -{ - make_unique_name (rdb, m_rdbs.begin (), m_rdbs.end ()); - m_rdbs.push_back (rdb); - - // Mark this object as owned by us (for GSI) - rdb->keep (); - - rdb_list_changed_event (); - - return (unsigned int)(m_rdbs.size () - 1); -} - -unsigned int -LayoutView::replace_rdb (unsigned int db_index, rdb::Database *rdb) -{ - tl_assert (rdb != 0); - - if (db_index < m_rdbs.size ()) { - - // keep name because it's used for reference in the browser for example - std::string n = m_rdbs [db_index]->name (); - rdb->set_name (n); - - delete m_rdbs [db_index]; - m_rdbs [db_index] = rdb; - - // Mark this object as owned by us (for GSI) - rdb->keep (); - - rdb_list_changed_event (); - - return db_index; - - } else { - return add_rdb (rdb); - } -} - -rdb::Database * -LayoutView::get_rdb (int index) -{ - if (index >= 0 && index < int (m_rdbs.size ())) { - return m_rdbs [index]; - } else { - return 0; - } -} - void LayoutView::open_rdb_browser (int rdb_index, int cv_index) { @@ -6103,32 +985,12 @@ LayoutView::open_rdb_browser (int rdb_index, int cv_index) } } -const rdb::Database * -LayoutView::get_rdb (int index) const -{ - if (index >= 0 && index < int (m_rdbs.size ())) { - return m_rdbs [index]; - } else { - return 0; - } -} - -void -LayoutView::remove_rdb (unsigned int index) -{ - if (index < (unsigned int) (m_rdbs.size ())) { - delete m_rdbs [index]; - m_rdbs.erase (m_rdbs.begin () + index); - rdb_list_changed_event (); - } -} - QSize LayoutView::sizeHint () const { - if ((m_options & LV_Naked) != 0) { + if ((options () & LV_Naked) != 0) { return QSize (200, 200); - } else if ((m_options & LV_NoLayers) != 0 || (m_options & LV_NoHierarchyPanel) != 0 || (m_options & LV_NoLibrariesView) != 0) { + } else if ((options () & LV_NoLayers) != 0 || (options () & LV_NoHierarchyPanel) != 0 || (options () & LV_NoLibrariesView) != 0) { return QSize (400, 200); } else { return QSize (600, 200); diff --git a/src/laybasic/laybasic/layLayoutView.h b/src/laybasic/laybasic/layLayoutView.h index a8ad43acf..06094a64e 100644 --- a/src/laybasic/laybasic/layLayoutView.h +++ b/src/laybasic/laybasic/layLayoutView.h @@ -94,7 +94,8 @@ class EditorOptionsPages; * It manages the layer display list, bookmark list etc. */ class LAYBASIC_PUBLIC LayoutView - : public LayoutViewBase + : public QFrame, + public LayoutViewBase { Q_OBJECT @@ -109,6 +110,11 @@ public: */ LayoutView (lay::LayoutView *source, db::Manager *mgr, bool editable, lay::Plugin *plugin_parent, QWidget *parent = 0, const char *name = "view", unsigned int options = (unsigned int) LV_Normal); + /** + * @brief Destructor + */ + ~LayoutView (); + /** * @brief Makes this view the current one */ @@ -119,12 +125,20 @@ public: * * The argument can be 0 which means there is no current view. */ - static void set_current (LayoutViewBase *); + static void set_current (LayoutView *); /** * @brief Gets the current view */ - static LayoutViewBase *current (); + static LayoutView *current (); + + /** + * @brief Determine if there is something to copy + * + * This reimplementation of the lay::Editables interface additionally + * looks for content providers in the tree views for example. + */ + virtual bool has_selection (); /** * @brief Gets the window title of the view @@ -141,6 +155,32 @@ public: */ void reset_title (); + /** + * @brief Display a status message + */ + void message (const std::string &s = "", int timeout = 10); + + /** + * @brief Switches the application's mode + * + * Switches the mode on application level. Use this method to initiate + * a mode switch from the view. + */ + void switch_mode (int m); + + /** + * @brief Updates the menu for the given view + * If the view is 0, the menu shall be updated to reflect "no view active" + */ + static void update_menu (lay::LayoutView *view, lay::AbstractMenu &menu); + + /** + * @brief Create all plugins + * + * If plugins already exist, they are deleted and created again + */ + void create_plugins (const lay::PluginDeclaration *except_this = 0); + /** * @brief Sets the currently active layer by layer properties and cell view index * @@ -264,6 +304,11 @@ public: set_current_cell_path (active_cellview_index (), path); } + /** + * @brief Indicates the current position + */ + virtual void current_pos (double x, double y); + /** * @brief Bookmark the current view under the given name */ @@ -358,10 +403,26 @@ public: return mp_editor_options_frame; } + /** + * @brief Copies to clipboard + * + * This reimplementation of the lay::Editables interface additionally + * looks for copy providers in the tree views for example. + */ + virtual void copy (); + + /** + * @brief Cuts to clipboard + * + * This reimplementation of the lay::Editables interface additionally + * looks for cut & copy providers in the tree views for example. + */ + virtual void cut (); + /** * @brief Deliver a size hint (reimplementation of QWidget) */ - QSize sizeHint () const; + virtual QSize sizeHint () const; /** * @brief An event signalling that the view is going to close @@ -378,6 +439,19 @@ public: */ tl::Event hide_event; + /** + * @brief An event triggered if the active cellview changes + * This event is triggered after the active cellview changed. + */ + tl::Event active_cellview_changed_event; + + /** + * @brief An event triggered if the active cellview changes + * This event is triggered after the active cellview changed. The integer parameter is the index of the + * new cellview. + */ + tl::event active_cellview_changed_with_index_event; + public slots: /** * @brief Store the current state on the "previous states" stack @@ -560,56 +634,22 @@ public slots: LayoutViewBase::redraw_cell_boxes (); } - void layer_tab_changed () - { - LayoutViewBase::layer_tab_changed (); - } - - void layer_order_changed () - { - LayoutViewBase::layer_order_changed (); - } + void layer_tab_changed (); + void layer_order_changed (); void timer () { LayoutViewBase::timer (); } - void min_hier_changed (int i) - { - LayoutViewBase::min_hier_changed (i); - } - - void max_hier_changed (int i) - { - LayoutViewBase::max_hier_changed (i); - } + void min_hier_changed (int i); + void max_hier_changed (int i); void deactivate_all_browsers (); -private: - // event handlers used to connect to the layout object's events - void signal_hier_changed (); - void signal_bboxes_from_layer_changed (unsigned int cv_index, unsigned int layer_index); - void signal_bboxes_changed (); - void signal_prop_ids_changed (); - void signal_layer_properties_changed (); - void signal_cell_name_changed (); - void signal_annotations_changed (); - void signal_plugin_enabled_changed (); - void signal_apply_technology (lay::LayoutHandle *layout_handle); - private slots: - void active_cellview_changed (int index) - { - LayoutViewBase::active_cellview_changed (index); - } - - void active_library_changed (int index) - { - LayoutViewBase::active_library_changed (index); - } - + void active_cellview_changed (int index); + void active_library_changed (int index); void side_panel_destroyed (); signals: @@ -660,6 +700,7 @@ signals: private: QTimer *mp_timer; + bool m_activated; QFrame *mp_left_frame; lay::LayerControlPanel *mp_control_panel; lay::HierarchyControlPanel *mp_hierarchy_panel; @@ -672,18 +713,27 @@ private: BookmarkList m_bookmarks; bool m_active_cellview_changed_event_enabled; - tl::DeferredMethod dm_prop_changed; tl::DeferredMethod dm_setup_editor_option_pages; - void init (db::Manager *mgr, QWidget *parent); + void init_ui (); void init_menu (); + lay::EditorOptionsPages *editor_options_pages (); void do_setup_editor_options_pages (); + +protected: void activate (); void deactivate (); - bool eventFilter(QObject *obj, QEvent *ev); - void showEvent (QShowEvent *); - void hideEvent (QHideEvent *); + virtual bool eventFilter(QObject *obj, QEvent *ev); + virtual void showEvent (QShowEvent *); + virtual void hideEvent (QHideEvent *); + + virtual bool configure (const std::string &name, const std::string &value); + virtual void config_finalize (); + + virtual lay::Color default_background_color (); + virtual void do_set_background_color (lay::Color color, lay::Color contrast); + virtual void do_paste (); }; } diff --git a/src/laybasic/laybasic/layLayoutViewBase.cc b/src/laybasic/laybasic/layLayoutViewBase.cc index f5713323a..1c0ec0d6e 100644 --- a/src/laybasic/laybasic/layLayoutViewBase.cc +++ b/src/laybasic/laybasic/layLayoutViewBase.cc @@ -236,23 +236,17 @@ struct OpDeleteLayerProps // ------------------------------------------------------------- -const int timer_interval = 500; - -static LayoutViewBase *ms_current = 0; +const double animation_interval = 0.5; LayoutViewBase::LayoutViewBase (db::Manager *manager, bool editable, lay::Plugin *plugin_parent, unsigned int options) : lay::Dispatcher (plugin_parent, false /*not standalone*/), m_editable (editable), m_options (options), - m_annotation_shapes (manager), - dm_prop_changed (this, &LayoutViewBase::do_prop_changed) + m_annotation_shapes (manager) { // either it's us or the parent has a dispatcher tl_assert (dispatcher () != 0); - // ensures the deferred method scheduler is present - tl::DeferredMethodScheduler::instance (); - init (manager); } @@ -260,15 +254,11 @@ LayoutViewBase::LayoutViewBase (lay::LayoutViewBase *source, db::Manager *manage : lay::Dispatcher (plugin_parent, false /*not standalone*/), m_editable (editable), m_options (options), - m_annotation_shapes (manager), - dm_prop_changed (this, &LayoutViewBase::do_prop_changed) + m_annotation_shapes (manager) { // either it's us or the parent has a dispatcher tl_assert (dispatcher () != 0); - // ensures the deferred method scheduler is present - tl::DeferredMethodScheduler::instance (); - m_annotation_shapes = source->m_annotation_shapes; init (manager); @@ -297,10 +287,6 @@ LayoutViewBase::LayoutViewBase (lay::LayoutViewBase *source, db::Manager *manage mp_canvas->set_dither_pattern (m_layer_properties_lists [0]->dither_pattern ()); } - bookmarks (source->bookmarks ()); - - set_active_cellview_index (source->active_cellview_index ()); - // copy the title m_title = source->m_title; @@ -361,7 +347,7 @@ LayoutViewBase::init (db::Manager *mgr) m_drop_small_cells_cond = DSC_Max; m_draw_array_border_instances = false; m_dirty = false; - m_activated = true; + m_prop_changed = false; m_animated = false; m_phase = 0; m_palette = lay::ColorPalette::default_palette (); @@ -423,10 +409,6 @@ LayoutViewBase::init (db::Manager *mgr) LayoutViewBase::~LayoutViewBase () { - if (ms_current == this) { - ms_current = 0; - } - // detach all observers // This is to prevent signals to partially destroyed observers that own a LayoutViewBase layer_list_changed_event.clear (); @@ -535,6 +517,14 @@ void LayoutViewBase::drop_url (const std::string &path_or_url) } } +void LayoutViewBase::clear_plugins () +{ + for (std::vector::iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) { + delete *p; + } + mp_plugins.clear (); +} + lay::Plugin *LayoutViewBase::create_plugin (const lay::PluginDeclaration *cls) { lay::Plugin *p = cls->create_plugin (manager (), dispatcher (), this); @@ -557,39 +547,6 @@ lay::Plugin *LayoutViewBase::create_plugin (const lay::PluginDeclaration *cls) return p; } -void LayoutViewBase::create_plugins (const lay::PluginDeclaration *except_this) -{ - for (std::vector::iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) { - delete *p; - } - mp_plugins.clear (); - - // create the plugins - for (tl::Registrar::iterator cls = tl::Registrar::begin (); cls != tl::Registrar::end (); ++cls) { - - if (&*cls != except_this) { - - // TODO: clean solution. The following is a HACK: - if (cls.current_name () == "ant::Plugin" || cls.current_name () == "img::Plugin") { - // ant and img are created always - create_plugin (&*cls); - } else if ((m_options & LV_NoPlugins) == 0) { - // others: only create unless LV_NoPlugins is set - create_plugin (&*cls); - } else if ((m_options & LV_NoGrid) == 0 && cls.current_name () == "GridNetPlugin") { - // except grid net plugin which is created on request - create_plugin (&*cls); - } - - } - - } - - dm_setup_editor_option_pages (); - - mode (default_mode ()); -} - Plugin *LayoutViewBase::get_plugin_by_name (const std::string &name) const { lay::PluginDeclaration *decl = 0; @@ -670,82 +627,6 @@ LayoutViewBase::configure (const std::string &name, const std::string &value) update_content (); return true; -/*@@@ - } else if (name == cfg_flat_cell_list) { - - bool f; - tl::from_string (value, f); - if (mp_hierarchy_panel) { - mp_hierarchy_panel->set_flat (f); - } - return true; - - } else if (name == cfg_split_cell_list) { - - bool f; - tl::from_string (value, f); - if (mp_hierarchy_panel) { - mp_hierarchy_panel->set_split_mode (f); - } - return true; - - } else if (name == cfg_split_lib_views) { - - bool f; - tl::from_string (value, f); - if (mp_libraries_view) { - mp_libraries_view->set_split_mode (f); - } - return true; - - } else if (name == cfg_bookmarks_follow_selection) { - - bool f; - tl::from_string (value, f); - if (mp_bookmarks_view) { - mp_bookmarks_view->follow_selection (f); - } - return true; - - } else if (name == cfg_current_lib_view) { - - if (mp_libraries_view) { - mp_libraries_view->select_active_lib_by_name (value); - } - return true; - - } else if (name == cfg_cell_list_sorting) { - - if (mp_hierarchy_panel) { - if (value == "by-name") { - mp_hierarchy_panel->set_sorting (CellTreeModel::ByName); - } else if (value == "by-area") { - mp_hierarchy_panel->set_sorting (CellTreeModel::ByArea); - } else if (value == "by-area-reverse") { - mp_hierarchy_panel->set_sorting (CellTreeModel::ByAreaReverse); - } - } - return true; - - } else if (name == cfg_hide_empty_layers) { - - bool f; - tl::from_string (value, f); - if (mp_control_panel) { - mp_control_panel->set_hide_empty_layers (f); - } - return true; - - } else if (name == cfg_test_shapes_in_view) { - - bool f; - tl::from_string (value, f); - if (mp_control_panel) { - mp_control_panel->set_test_shapes_in_view (f); - } - return true; - -@@@*/ } else if (name == cfg_background_color) { lay::Color color; @@ -1270,9 +1151,7 @@ LayoutViewBase::configure (const std::string &name, const std::string &value) void LayoutViewBase::config_finalize () { - // It's important that the editor option pages are updated last - because the - // configuration change may trigger other configuration changes - dm_setup_editor_option_pages (); + // .. nothing yet .. } void @@ -1396,7 +1275,7 @@ LayoutViewBase::insert_layer_list (unsigned index, const LayerPropertiesList &pr redraw (); - dm_prop_changed (); + m_prop_changed = true; } void @@ -1438,7 +1317,7 @@ LayoutViewBase::delete_layer_list (unsigned index) } layer_list_deleted_event (index); - dm_prop_changed (); + m_prop_changed = true; } void @@ -1551,7 +1430,7 @@ LayoutViewBase::set_properties (unsigned int index, const LayerPropertiesList &p redraw (); - dm_prop_changed (); + m_prop_changed = true; } } @@ -1615,7 +1494,7 @@ LayoutViewBase::replace_layer_node (unsigned int index, const LayerPropertiesCon // TODO: check, if redraw is actually necessary (this is complex!) redraw (); - dm_prop_changed (); + m_prop_changed = true; } } @@ -1658,7 +1537,7 @@ LayoutViewBase::set_properties (unsigned int index, const LayerPropertiesConstIt // perform the callbacks asynchronously to collect the necessary calls instead // of executing them immediately. - dm_prop_changed (); + m_prop_changed = true; } } @@ -1685,7 +1564,7 @@ LayoutViewBase::insert_layer (unsigned int index, const LayerPropertiesConstIter if (index == current_layer_list ()) { layer_list_changed_event (2); redraw (); - dm_prop_changed (); + m_prop_changed = true; } return ret; @@ -1717,7 +1596,7 @@ LayoutViewBase::delete_layer (unsigned int index, LayerPropertiesConstIterator & if (index == current_layer_list ()) { layer_list_changed_event (2); redraw (); - dm_prop_changed (); + m_prop_changed = true; } // invalidate the iterator so it can be used to refer to the next element @@ -3202,6 +3081,7 @@ LayoutViewBase::box () const return mp_canvas->viewport ().box (); } +// @@@ needs to be called "as often as possible" void LayoutViewBase::timer () { @@ -3215,26 +3095,23 @@ LayoutViewBase::timer () emit dirty_changed (); } - if (m_animated) { - set_view_ops (); - if (mp_control_panel) { - mp_control_panel->set_phase (int (m_phase)); - } - if (m_animated) { - ++m_phase; - } + if (m_prop_changed) { + do_prop_changed (); + m_prop_changed = false; } -} -bool -LayoutViewBase::layer_model_updated () -{ - // because check_updated is called in the initialization phase, we check if the pointers - // to the widgets are non-null: - if (mp_control_panel) { - return mp_control_panel->model_updated (); - } else { - return false; + tl::Clock current_time = tl::Clock::current (); + if ((current_time - m_last_checked).seconds () > animation_interval) { + m_last_checked = current_time; + if (m_animated) { + set_view_ops (); + if (mp_control_panel) { + mp_control_panel->set_phase (int (m_phase)); + } + if (m_animated) { + ++m_phase; + } + } } } @@ -3561,18 +3438,6 @@ LayoutViewBase::do_prop_changed () update_content (); } -void -LayoutViewBase::layer_tab_changed () -{ - update_content (); -} - -void -LayoutViewBase::layer_order_changed () -{ - update_content (); -} - void LayoutViewBase::set_view_ops () { @@ -4014,20 +3879,6 @@ LayoutViewBase::get_hier_levels () const return std::make_pair (m_from_level, m_to_level); } -void -LayoutViewBase::min_hier_changed (int i) -{ - mp_max_hier_spbx->setMinimum (i); - set_hier_levels (std::make_pair (i, m_to_level)); -} - -void -LayoutViewBase::max_hier_changed (int i) -{ - mp_min_hier_spbx->setMaximum (i); - set_hier_levels (std::make_pair (m_from_level, i)); -} - /** * @brief set the maximum hierarchy level to the number of levels available */ @@ -4173,6 +4024,18 @@ LayoutViewBase::abstract_mode_enabled (bool e) } } +lay::Color +LayoutViewBase::default_background_color () +{ + return lay::Color (0, 0, 0); // black. +} + +void +LayoutViewBase::do_set_background_color (lay::Color /*color*/, lay::Color /*contrast*/) +{ + // .. nothing yet .. +} + void LayoutViewBase::background_color (lay::Color c) { @@ -4182,7 +4045,7 @@ LayoutViewBase::background_color (lay::Color c) // replace by "real" background color if required if (! c.is_valid ()) { - c = lay::Color (palette ().color (QPalette::Normal, QPalette::Base).rgb ()); + c = default_background_color (); } lay::Color contrast; @@ -4192,25 +4055,7 @@ LayoutViewBase::background_color (lay::Color c) contrast = lay::Color (255, 255, 255); } - if (mp_control_panel) { - mp_control_panel->set_background_color (c); - mp_control_panel->set_text_color (contrast); - } - - if (mp_hierarchy_panel) { - mp_hierarchy_panel->set_background_color (c); - mp_hierarchy_panel->set_text_color (contrast); - } - - if (mp_libraries_view) { - mp_libraries_view->set_background_color (c); - mp_libraries_view->set_text_color (contrast); - } - - if (mp_bookmarks_view) { - mp_bookmarks_view->set_background_color (c); - mp_bookmarks_view->set_text_color (contrast); - } + do_set_background_color (c, contrast); if (mp_selection_service) { mp_selection_service->set_colors (c, contrast); @@ -4274,41 +4119,6 @@ LayoutViewBase::select_cellviews_fit (const std::list &cvs) } } -void -LayoutViewBase::active_cellview_changed (int index) -{ - if (m_active_cellview_changed_event_enabled) { - - // we need to cancel pending drawing or dragging operations to reflect the new cellview (different target, may have different technology etc.) - cancel_esc (); - - // we need to setup the editor option pages because the technology may have changed - dm_setup_editor_option_pages (); - - active_cellview_changed_event (); - active_cellview_changed_with_index_event (index); - - // Because the title reflects the active one, emit a title changed event - if (m_title.empty ()) { - emit title_changed (); - } - - } -} - -void -LayoutViewBase::active_library_changed (int /*index*/) -{ - std::string lib_name; - if (mp_libraries_view->active_lib ()) { - lib_name = mp_libraries_view->active_lib ()->get_name (); - } - - // commit the new active library to the other views and persist this state - // TODO: could be passed through the LibraryController (like through some LibraryController::active_library) - dispatcher ()->config_set (cfg_current_lib_view, lib_name); -} - void LayoutViewBase::cellview_changed (unsigned int index) { @@ -4741,13 +4551,13 @@ LayoutViewBase::text_color (lay::Color c) bool LayoutViewBase::has_selection () { - if (mp_control_panel && mp_control_panel->has_focus ()) { - return mp_control_panel->has_selection (); - } else if (mp_hierarchy_panel && mp_hierarchy_panel->has_focus ()) { - return mp_hierarchy_panel->has_selection (); - } else { - return lay::Editables::has_selection (); - } + return lay::Editables::has_selection (); +} + +void +LayoutViewBase::do_paste () +{ + // .. nothing yet .. } void @@ -4759,12 +4569,7 @@ LayoutViewBase::paste () db::Transaction trans (manager (), tl::to_string (tr ("Paste"))); // let the receivers sort out who is pasting what .. - if (mp_hierarchy_panel) { - mp_hierarchy_panel->paste (); - } - if (mp_control_panel) { - mp_control_panel->paste (); - } + do_paste (); lay::Editables::paste (); } @@ -4792,12 +4597,7 @@ LayoutViewBase::paste_interactive () { // let the receivers sort out who is pasting what .. - if (mp_hierarchy_panel) { - mp_hierarchy_panel->paste (); - } - if (mp_control_panel) { - mp_control_panel->paste (); - } + do_paste (); lay::Editables::paste (); } @@ -4985,21 +4785,9 @@ LayoutViewBase::has_next_display_state () } void -LayoutViewBase::current_pos (double x, double y) +LayoutViewBase::current_pos (double /*x*/, double /*y*/) { - if (m_activated) { - if (dbu_coordinates ()) { - double dx = 0.0, dy = 0.0; - if (active_cellview_index () >= 0) { - double dbu = cellview (active_cellview_index ())->layout ().dbu (); - dx = x / dbu; - dy = y / dbu; - } - emit current_pos_changed (dx, dy, true); - } else { - emit current_pos_changed (x, y, false); - } - } + // .. nothing yet .. } void @@ -5008,6 +4796,12 @@ LayoutViewBase::stop_redraw () mp_canvas->stop_redraw (); } +void +LayoutViewBase::free_resources () +{ + mp_canvas->free_resources (); +} + void LayoutViewBase::stop () { @@ -5015,6 +4809,12 @@ LayoutViewBase::stop () deactivate_all_browsers (); } +void +LayoutViewBase::switch_mode (int /*m*/) +{ + // .. nothing yet .. +} + void LayoutViewBase::mode (int m) { @@ -5282,12 +5082,6 @@ LayoutViewBase::set_search_range_box (unsigned int sr) m_search_range_box = sr; } -void -LayoutViewBase::message (const std::string &s, int timeout) -{ - emit show_message (s, timeout * 1000); -} - db::cell_index_type LayoutViewBase::new_cell (int cv_index, const std::string &cell_name) { @@ -5309,15 +5103,6 @@ LayoutViewBase::new_cell (int cv_index, const std::string &cell_name) return new_ci; } -void -LayoutViewBase::switch_mode (int m) -{ - if (m_mode != m) { - mode (m); - emit mode_change (m); - } -} - template static void make_unique_name (T *object, Iter from, Iter to) { diff --git a/src/laybasic/laybasic/layLayoutViewBase.h b/src/laybasic/laybasic/layLayoutViewBase.h index 65e3af2b8..6a6254114 100644 --- a/src/laybasic/laybasic/layLayoutViewBase.h +++ b/src/laybasic/laybasic/layLayoutViewBase.h @@ -50,6 +50,7 @@ #include "gsi.h" #include "tlException.h" #include "tlEvents.h" +#include "tlTimer.h" #include "dbInstElement.h" namespace rdb { @@ -196,7 +197,7 @@ public: * This reimplementation of the lay::Editables interface additionally * looks for content providers in the tree views for example. */ - bool has_selection (); + virtual bool has_selection (); /** * @brief Pastes from clipboard @@ -217,7 +218,7 @@ public: * This reimplementation of the lay::Editables interface additionally * looks for copy providers in the tree views for example. */ - void copy (); + virtual void copy (); /** * @brief Cuts to clipboard @@ -225,7 +226,7 @@ public: * This reimplementation of the lay::Editables interface additionally * looks for cut & copy providers in the tree views for example. */ - void cut (); + virtual void cut (); /** * @brief Gets the explicit title string of the view @@ -638,19 +639,6 @@ public: */ tl::Event cell_visibility_changed_event; - /** - * @brief An event triggered if the active cellview changes - * This event is triggered after the active cellview changed. - */ - tl::Event active_cellview_changed_event; - - /** - * @brief An event triggered if the active cellview changes - * This event is triggered after the active cellview changed. The integer parameter is the index of the - * new cellview. - */ - tl::event active_cellview_changed_with_index_event; - /** * @brief Save the given cellview into the given file (with options) * If "update" is true, the cell view's properties will be updated (options, filename etc.). @@ -1294,9 +1282,9 @@ public: unsigned int add_layout (lay::LayoutHandle *layout_handle, bool add_cellview, bool initialize_layers = true); /** - * @brief Pass the current position from the mouse tracker to the status bar + * @brief Indicates the current position */ - void current_pos (double x, double y); + virtual void current_pos (double x, double y); /** * @brief Obtain the number of cellviews @@ -1389,11 +1377,6 @@ public: */ db::DBox box () const; - /** - * @brief Display a status message - */ - void message (const std::string &s = "", int timeout = 10); - /** * @brief Create a new cell with the given in the given cellview * @@ -1411,14 +1394,6 @@ public: */ void mode (int m); - /** - * @brief Switches the application's mode - * - * Switches the mode on application level. Use this method to initiate - * a mode switch from the view. - */ - void switch_mode (int m); - /** * @brief Test, if the view is currently in move mode. */ @@ -1434,12 +1409,6 @@ public: */ static unsigned int intrinsic_mouse_modes (std::vector *descriptions); - /** - * @brief Updates the menu for the given view - * If the view is 0, the menu shall be updated to reflect "no view active" - */ - static void update_menu (lay::LayoutViewBase *view, lay::AbstractMenu &menu); - /** * @brief Query the default mode */ @@ -1925,16 +1894,6 @@ public: */ void merge_layer_props (const std::vector &props); - /** - * @brief Internal method: check, if the layer tree is and an consistent state. - * - * This method is used by the layer tree model to check, if the tree has been brought into - * a consistent state. - * HINT: for the layout this is solved more consistently with the "under construction" attribute - * of the layout. There is no equivalent object for the layer tree currently. - */ - bool layer_model_updated (); - /** * @brief Get the "select inside PCells" selection mode * @@ -2278,13 +2237,6 @@ public: lay::SelectionService *selection_service () const { return mp_selection_service; } lay::MoveService *move_service () const { return mp_move_service; } - /** - * @brief Create all plugins - * - * If plugins already exist, they are deleted and created again - */ - void create_plugins (const lay::PluginDeclaration *except_this = 0); - /** * @brief Gets the full field box * @@ -2385,11 +2337,7 @@ public: void redraw_layer (unsigned int index); void redraw_deco_layer (); void redraw_cell_boxes (); - void layer_tab_changed (); - void layer_order_changed (); void timer (); - void min_hier_changed (int i); - void max_hier_changed (int i); private: // event handlers used to connect to the layout object's events @@ -2403,10 +2351,6 @@ private: void signal_plugin_enabled_changed (); void signal_apply_technology (lay::LayoutHandle *layout_handle); - void active_cellview_changed (int index); - void active_library_changed (int index); - void side_panel_destroyed (); - private: bool m_editable; int m_disabled_edits; @@ -2492,7 +2436,7 @@ private: bool m_absolute_coordinates; bool m_dirty; - bool m_activated; + bool m_prop_changed; bool m_animated; unsigned int m_phase; @@ -2519,6 +2463,8 @@ private: bool m_visibility_changed; + tl::Clock m_clock, m_last_checked; + void init (db::Manager *mgr); void do_prop_changed (); @@ -2544,9 +2490,6 @@ private: void viewport_changed (); void cellview_changed (unsigned int index); - bool configure (const std::string &name, const std::string &value); - void config_finalize (); - void do_load_layer_props (const std::string &fn, bool map_cv, int cv_index, bool add_default); void finish_cellviews_changed (); void init_layer_properties (LayerProperties &props, const LayerPropertiesList &lp_list) const; @@ -2555,10 +2498,32 @@ private: // overrides Editables method to display a message void signal_selection_changed (); - lay::Plugin *create_plugin (const lay::PluginDeclaration *cls); +protected: + unsigned int options () const + { + return m_options; + } + + int mode () const + { + return m_mode; + } + + bool configure (const std::string &name, const std::string &value); + void config_finalize (); std::list::iterator cellview_iter (int cv_index); std::list::const_iterator cellview_iter (int cv_index) const; + + lay::Plugin *create_plugin (const lay::PluginDeclaration *cls); + void clear_plugins (); + + void free_resources (); + + virtual lay::Color default_background_color (); + virtual void do_set_background_color (lay::Color color, lay::Color contrast); + virtual void do_paste (); + virtual void switch_mode (int m); }; } diff --git a/src/laybasic/laybasic/layMouseTracker.cc b/src/laybasic/laybasic/layMouseTracker.cc index 73caa324b..f84a48779 100644 --- a/src/laybasic/laybasic/layMouseTracker.cc +++ b/src/laybasic/laybasic/layMouseTracker.cc @@ -28,7 +28,7 @@ namespace lay { -MouseTracker::MouseTracker (lay::LayoutView *view) +MouseTracker::MouseTracker (lay::LayoutViewBase *view) : lay::ViewService (view->view_object_widget ()), mp_view (view) { widget ()->grab_mouse (this, false); From c4be80bb2f3ef9d613d2cf67c91076d41c685a73 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 30 Apr 2022 20:51:54 +0200 Subject: [PATCH 09/88] WIP --- src/laybasic/laybasic/layLayoutView.cc | 258 ++++++++++++++-- src/laybasic/laybasic/layLayoutView.h | 71 ++++- src/laybasic/laybasic/layLayoutViewBase.cc | 328 ++++++++++----------- src/laybasic/laybasic/layLayoutViewBase.h | 71 +++-- 4 files changed, 485 insertions(+), 243 deletions(-) diff --git a/src/laybasic/laybasic/layLayoutView.cc b/src/laybasic/laybasic/layLayoutView.cc index 0cfd4853a..70de70c82 100644 --- a/src/laybasic/laybasic/layLayoutView.cc +++ b/src/laybasic/laybasic/layLayoutView.cc @@ -165,6 +165,9 @@ void LayoutView::init_ui () { m_activated = true; + m_always_show_source = false; + m_always_show_ld = true; + m_always_show_layout_index = false; QVBoxLayout *vbl = new QVBoxLayout (this); vbl->setContentsMargins (0, 0, 0, 0); @@ -282,10 +285,6 @@ LayoutView::init_ui () mp_timer = new QTimer (this); connect (mp_timer, SIGNAL (timeout ()), this, SLOT (timer ())); mp_timer->start (timer_interval); - - create_plugins (); - - config_setup (); } LayoutView::~LayoutView () @@ -396,32 +395,8 @@ LayoutView *LayoutView::current () void LayoutView::create_plugins (const lay::PluginDeclaration *except_this) { - clear_plugins (); - - // create the plugins - for (tl::Registrar::iterator cls = tl::Registrar::begin (); cls != tl::Registrar::end (); ++cls) { - - if (&*cls != except_this) { - - // TODO: clean solution. The following is a HACK: - if (cls.current_name () == "ant::Plugin" || cls.current_name () == "img::Plugin") { - // ant and img are created always - create_plugin (&*cls); - } else if ((options () & LV_NoPlugins) == 0) { - // others: only create unless LV_NoPlugins is set - create_plugin (&*cls); - } else if ((options () & LV_NoGrid) == 0 && cls.current_name () == "GridNetPlugin") { - // except grid net plugin which is created on request - create_plugin (&*cls); - } - - } - - } - + LayoutViewBase::create_plugins (except_this); dm_setup_editor_option_pages (); - - mode (default_mode ()); } namespace { @@ -559,6 +534,39 @@ LayoutView::configure (const std::string &name, const std::string &value) } return true; + } else if (name == cfg_layers_always_show_source) { + + bool a = false; + tl::from_string (value, a); + if (a != m_always_show_source) { + m_always_show_source = a; + layer_list_changed_event (4); + } + + return true; + + } else if (name == cfg_layers_always_show_ld) { + + bool a = false; + tl::from_string (value, a); + if (a != m_always_show_ld) { + m_always_show_ld = a; + layer_list_changed_event (4); + } + + return true; + + } else if (name == cfg_layers_always_show_layout_index) { + + bool a = false; + tl::from_string (value, a); + if (a != m_always_show_layout_index) { + m_always_show_layout_index = a; + layer_list_changed_event (4); + } + + return true; + } else { return false; } @@ -629,6 +637,12 @@ LayoutView::set_current_layer (const lay::LayerPropertiesConstIterator &l) } } +void +LayoutView::do_set_current_layer (const lay::LayerPropertiesConstIterator &l) +{ + set_current_layer (l); +} + lay::LayerPropertiesConstIterator LayoutView::current_layer () const { @@ -657,6 +671,37 @@ LayoutView::set_selected_layers (const std::vectorhas_selection ()) { + const lay::LayerPropertiesList &lp = get_properties (); + lay::LayerPropertiesConstIterator li = lp.begin_const_recursive (); + while (! li.at_end () && li->has_children ()) { + ++li; + } + if (! li.at_end ()) { + mp_control_panel->set_current_layer (li); + } + } +} + +void +LayoutView::remove_unused_layers () +{ + if (mp_control_panel) { + mp_control_panel->cm_remove_unused (); + } +} + +void +LayoutView::begin_layer_updates () +{ + if (mp_control_panel) { + mp_control_panel->begin_updates (); + } +} + void LayoutView::bookmark_current_view () { @@ -764,6 +809,59 @@ LayoutView::do_set_background_color (lay::Color c, lay::Color contrast) } } +void +LayoutView::do_set_no_stipples (bool no_stipples) +{ + if (mp_control_panel) { + mp_control_panel->set_no_stipples (no_stipples); + } +} + +void +LayoutView::do_set_phase (int phase) +{ + if (mp_control_panel) { + mp_control_panel->set_phase (phase); + } +} + +void +LayoutView::enable_active_cellview_changed_event (bool enable, bool silent) +{ + if (m_active_cellview_changed_event_enabled == enable) { + return; + } + + m_active_cellview_changed_event_enabled = enable; + if (enable) { + + if (!silent && ! m_active_cellview_changed_events.empty ()) { + + // deliver stored events + + // we need to cancel pending drawing or dragging operations to reflect the new cellview (different target, may have different technology etc.) + cancel_esc (); + + // we need to setup the editor option pages because the technology may have changed + dm_setup_editor_option_pages (); + + active_cellview_changed_event (); + for (std::set::const_iterator i = m_active_cellview_changed_events.begin (); i != m_active_cellview_changed_events.end (); ++i) { + active_cellview_changed_with_index_event (*i); + } + + // Because the title reflects the active one, emit a title changed event + if (title_string ().empty ()) { + emit title_changed (); + } + + } + + } + + m_active_cellview_changed_events.clear (); +} + void LayoutView::active_cellview_changed (int index) { @@ -783,6 +881,8 @@ LayoutView::active_cellview_changed (int index) emit title_changed (); } + } else { + m_active_cellview_changed_events.insert (index); } } @@ -799,6 +899,32 @@ LayoutView::active_library_changed (int /*index*/) dispatcher ()->config_set (cfg_current_lib_view, lib_name); } +bool +LayoutView::set_hier_levels_basic (std::pair l) +{ + if (l != get_hier_levels ()) { + + if (mp_min_hier_spbx) { + mp_min_hier_spbx->blockSignals (true); + mp_min_hier_spbx->setValue (l.first); + mp_min_hier_spbx->setMaximum (l.second); + mp_min_hier_spbx->blockSignals (false); + } + + if (mp_max_hier_spbx) { + mp_max_hier_spbx->blockSignals (true); + mp_max_hier_spbx->setValue (l.second); + mp_max_hier_spbx->setMinimum (l.first); + mp_max_hier_spbx->blockSignals (false); + } + + return LayoutViewBase::set_hier_levels_basic (l); + + } else { + return false; + } +} + bool LayoutView::has_selection () { @@ -924,6 +1050,12 @@ LayoutView::deactivate () m_activated = false; } +bool +LayoutView::is_activated () const +{ + return m_activated; +} + void LayoutView::deactivate_all_browsers () { @@ -934,6 +1066,14 @@ LayoutView::deactivate_all_browsers () } } +void +LayoutView::update_content_for_cv (int cellview_index) +{ + if (mp_hierarchy_panel) { + mp_hierarchy_panel->do_update_content (cellview_index); + } +} + void LayoutView::current_pos (double x, double y) { @@ -952,12 +1092,72 @@ LayoutView::current_pos (double x, double y) } } +void +LayoutView::emit_edits_enabled_changed () +{ + emit edits_enabled_changed (); +} + +void +LayoutView::emit_title_changed () +{ + emit title_changed (); +} + +void +LayoutView::emit_dirty_changed () +{ + emit dirty_changed (); +} + +void +LayoutView::emit_layer_order_changed () +{ + emit layer_order_changed (); +} + +void +LayoutView::signal_selection_changed () +{ + if (selection_size () > 1) { + message (tl::sprintf (tl::to_string (tr ("selected: %ld objects")), selection_size ())); + } + + lay::Editables::signal_selection_changed (); +} + void LayoutView::message (const std::string &s, int timeout) { emit show_message (s, timeout * 1000); } +void +LayoutView::mode (int m) +{ + if (mode () != m) { + + LayoutViewBase::mode (m); + + lay::EditorOptionsPages *eo_pages = editor_options_pages (); + if (eo_pages) { + + // TODO: this is very inefficient as each "activate" will regenerate the tabs + for (std::vector::const_iterator op = eo_pages->pages ().begin (); op != eo_pages->pages ().end (); ++op) { + bool is_active = false; + if ((*op)->plugin_declaration () == 0) { + is_active = true; + } else if (active_plugin () && active_plugin ()->plugin_declaration () == (*op)->plugin_declaration ()) { + is_active = true; + } + (*op)->activate (is_active); + } + + } + + } +} + void LayoutView::switch_mode (int m) { diff --git a/src/laybasic/laybasic/layLayoutView.h b/src/laybasic/laybasic/layLayoutView.h index 06094a64e..707754d4d 100644 --- a/src/laybasic/laybasic/layLayoutView.h +++ b/src/laybasic/laybasic/layLayoutView.h @@ -160,6 +160,19 @@ public: */ void message (const std::string &s = "", int timeout = 10); + /** + * @brief Select a certain mode (by index) + */ + virtual void mode (int m); + + /** + * @brief Gets the current mode + */ + int mode () const + { + return LayoutViewBase::mode (); + } + /** * @brief Switches the application's mode * @@ -179,7 +192,7 @@ public: * * If plugins already exist, they are deleted and created again */ - void create_plugins (const lay::PluginDeclaration *except_this = 0); + virtual void create_plugins (const lay::PluginDeclaration *except_this = 0); /** * @brief Sets the currently active layer by layer properties and cell view index @@ -246,7 +259,7 @@ public: /** * @brief Select a certain cellview for the active one */ - void set_active_cellview_index (int index); + virtual void set_active_cellview_index (int index); /** * @brief Cell paths of the selected cells @@ -292,7 +305,7 @@ public: * The current cell is the one highlighted in the browser with the focus rectangle. The * cell given by the path is highlighted and scrolled into view. */ - void set_current_cell_path (int cv_index, const cell_path_type &path); + virtual void set_current_cell_path (int cv_index, const cell_path_type &path); /** * @brief Set the path to the current cell is the current cellview @@ -304,6 +317,35 @@ public: set_current_cell_path (active_cellview_index (), path); } + /** + * @brief Remove unused layers + */ + void remove_unused_layers (); + + /** + * @brief Returns true, if the layer source shall be shown always in the layer properties tree + */ + bool always_show_source () const + { + return m_always_show_source; + } + + /** + * @brief Returns true, if the layer/datatype shall be shown always in the layer properties tree + */ + bool always_show_ld () const + { + return m_always_show_ld; + } + + /** + * @brief Returns true, if the layout index shall be shown always in the layer properties tree + */ + bool always_show_layout_index () const + { + return m_always_show_layout_index; + } + /** * @brief Indicates the current position */ @@ -712,6 +754,10 @@ private: QSpinBox *mp_max_hier_spbx; BookmarkList m_bookmarks; bool m_active_cellview_changed_event_enabled; + std::set m_active_cellview_changed_events; + bool m_always_show_source; + bool m_always_show_ld; + bool m_always_show_layout_index; tl::DeferredMethod dm_setup_editor_option_pages; @@ -734,6 +780,25 @@ protected: virtual lay::Color default_background_color (); virtual void do_set_background_color (lay::Color color, lay::Color contrast); virtual void do_paste (); + virtual void begin_layer_updates (); + virtual void ensure_layer_selected (); + virtual void do_set_current_layer (const lay::LayerPropertiesConstIterator &l); + virtual void update_content_for_cv (int cv_index); + virtual void do_set_no_stipples (bool no_stipples); + virtual void do_set_phase (int phase); + virtual bool set_hier_levels_basic (std::pair l); + virtual bool is_activated () const; + virtual void enable_active_cellview_changed_event (bool enable, bool silent = false); + + // overrides Editables method to display a message + void signal_selection_changed (); + + virtual void emit_edits_enabled_changed (); + virtual void emit_title_changed (); + virtual void emit_dirty_changed (); + virtual void emit_layer_order_changed (); + + virtual QWidget *widget () { return this; } }; } diff --git a/src/laybasic/laybasic/layLayoutViewBase.cc b/src/laybasic/laybasic/layLayoutViewBase.cc index 1c0ec0d6e..7323a86ac 100644 --- a/src/laybasic/laybasic/layLayoutViewBase.cc +++ b/src/laybasic/laybasic/layLayoutViewBase.cc @@ -70,6 +70,10 @@ #include "gsi.h" #include "gtf.h" +#if defined(HAVE_QT) +# include +#endif + #include namespace lay @@ -366,9 +370,6 @@ LayoutViewBase::init (db::Manager *mgr) m_transient_selection_mode = true; m_sel_inside_pcells = false; m_add_other_layers = false; - m_always_show_source = false; - m_always_show_ld = true; - m_always_show_layout_index = false; m_search_range = 5; m_search_range_box = 0; @@ -376,7 +377,11 @@ LayoutViewBase::init (db::Manager *mgr) m_layer_properties_lists.back ()->attach_view (this, (unsigned int) (m_layer_properties_lists.size () - 1)); m_current_layer_list = 0; - mp_canvas = new lay::LayoutCanvas (this); // @@@ Widget parent??? +#if defined(HAVE_QT) + mp_canvas = new lay::LayoutCanvas (widget (), this); +#else + mp_canvas = new lay::LayoutCanvas (this); +#endif mp_canvas->left_arrow_key_pressed.add (this, &LayoutViewBase::pan_left); mp_canvas->up_arrow_key_pressed.add (this, &LayoutViewBase::pan_up); @@ -523,6 +528,35 @@ void LayoutViewBase::clear_plugins () delete *p; } mp_plugins.clear (); + mp_active_plugin = 0; +} + +void LayoutViewBase::create_plugins (const lay::PluginDeclaration *except_this) +{ + clear_plugins (); + + // create the plugins + for (tl::Registrar::iterator cls = tl::Registrar::begin (); cls != tl::Registrar::end (); ++cls) { + + if (&*cls != except_this) { + + // TODO: clean solution. The following is a HACK: + if (cls.current_name () == "ant::Plugin" || cls.current_name () == "img::Plugin") { + // ant and img are created always + create_plugin (&*cls); + } else if ((options () & LV_NoPlugins) == 0) { + // others: only create unless LV_NoPlugins is set + create_plugin (&*cls); + } else if ((options () & LV_NoGrid) == 0 && cls.current_name () == "GridNetPlugin") { + // except grid net plugin which is created on request + create_plugin (&*cls); + } + + } + + } + + mode (default_mode ()); } lay::Plugin *LayoutViewBase::create_plugin (const lay::PluginDeclaration *cls) @@ -604,29 +638,6 @@ LayoutViewBase::configure (const std::string &name, const std::string &value) tl::from_string (value, m_add_other_layers); return false; // not taken - let others set it too. - } else if (name == cfg_layers_always_show_source) { - - bool a = false; - tl::from_string (value, a); - if (a != m_always_show_source) { - m_always_show_source = a; - layer_list_changed_event (4); - } - - return true; - - } else if (name == cfg_layers_always_show_ld) { - - tl::from_string (value, m_always_show_ld); - update_content (); - return true; - - } else if (name == cfg_layers_always_show_layout_index) { - - tl::from_string (value, m_always_show_layout_index); - update_content (); - return true; - } else if (name == cfg_background_color) { lay::Color color; @@ -1184,7 +1195,7 @@ LayoutViewBase::enable_edits (bool enable) } if (edits_enabled () != is_enabled) { - emit edits_enabled_changed (); + emit_edits_enabled_changed (); } } @@ -1415,8 +1426,8 @@ LayoutViewBase::set_properties (unsigned int index, const LayerPropertiesList &p manager ()->clear (); } - if (mp_control_panel && index == current_layer_list ()) { - mp_control_panel->begin_updates (); + if (index == current_layer_list ()) { + begin_layer_updates (); } *m_layer_properties_lists [index] = props; @@ -1479,9 +1490,9 @@ LayoutViewBase::replace_layer_node (unsigned int index, const LayerPropertiesCon manager ()->clear (); } - if (mp_control_panel && index == current_layer_list ()) { - mp_control_panel->begin_updates (); - } + if (index == current_layer_list ()) { + begin_layer_updates (); + } LayerPropertiesIterator non_const_iter (get_properties (index), iter.uint ()); *non_const_iter = node; @@ -1554,8 +1565,8 @@ LayoutViewBase::insert_layer (unsigned int index, const LayerPropertiesConstIter manager ()->clear (); } - if (mp_control_panel && index == current_layer_list ()) { - mp_control_panel->begin_updates (); + if (index == current_layer_list ()) { + begin_layer_updates (); } const LayerPropertiesNode &ret = m_layer_properties_lists [index]->insert (LayerPropertiesIterator (*m_layer_properties_lists [index], before.uint ()), node); @@ -1579,8 +1590,8 @@ LayoutViewBase::delete_layer (unsigned int index, LayerPropertiesConstIterator & lay::LayerPropertiesNode orig = *iter; - if (mp_control_panel && index == current_layer_list ()) { - mp_control_panel->begin_updates (); + if (index == current_layer_list ()) { + begin_layer_updates (); } // delete the element @@ -1603,16 +1614,6 @@ LayoutViewBase::delete_layer (unsigned int index, LayerPropertiesConstIterator & iter.invalidate (); } -void -LayoutViewBase::signal_selection_changed () -{ - if (selection_size () > 1) { - message (tl::sprintf (tl::to_string (tr ("selected: %ld objects")), selection_size ())); - } - - lay::Editables::signal_selection_changed (); -} - void LayoutViewBase::save_as (unsigned int index, const std::string &filename, tl::OutputStream::OutputStreamMode om, const db::SaveLayoutOptions &options, bool update, int keep_backups) { @@ -1942,9 +1943,7 @@ LayoutViewBase::erase_cellview (unsigned int index) manager ()->clear (); } - if (mp_control_panel) { - mp_control_panel->begin_updates (); - } + begin_layer_updates (); m_cellviews.erase (cellview_iter (int (index))); @@ -1985,7 +1984,7 @@ LayoutViewBase::erase_cellview (unsigned int index) update_content (); if (m_title.empty ()) { - emit title_changed (); + emit_title_changed (); } } @@ -2014,7 +2013,7 @@ LayoutViewBase::clear_cellviews () finish_cellviews_changed (); if (m_title.empty ()) { - emit title_changed (); + emit_title_changed (); } } @@ -2081,12 +2080,10 @@ LayoutViewBase::set_layout (const lay::CellView &cv, unsigned int cvindex) // since the hierarchy panel may hold cellviews, we explicitly request an initialization // of the tree. This will release such references. This way, set_layout guarantees that // the layouts are released as far as possible. This is important for reload () for example. - if (mp_hierarchy_panel) { - mp_hierarchy_panel->do_update_content (cvindex); - } + update_content_for_cv (cvindex); if (m_title.empty ()) { - emit title_changed (); + emit_title_changed (); } } @@ -2291,7 +2288,7 @@ LayoutViewBase::add_new_layers (const std::vector &layer_ids, int set_properties (new_props); if (was_empty) { - set_current_layer (new_props.begin_const_recursive ()); + do_set_current_layer (new_props.begin_const_recursive ()); } } @@ -2618,7 +2615,7 @@ LayoutViewBase::add_layout (lay::LayoutHandle *layout_handle, bool add_cellview, try { - m_active_cellview_changed_event_enabled = false; + enable_active_cellview_changed_event (false); stop_redraw (); @@ -2698,15 +2695,8 @@ LayoutViewBase::add_layout (lay::LayoutHandle *layout_handle, bool add_cellview, } // select the first layer if nothing else is selected - if (cv_index == 0 && ! mp_control_panel->has_selection ()) { - const lay::LayerPropertiesList &lp = get_properties (); - lay::LayerPropertiesConstIterator li = lp.begin_const_recursive (); - while (! li.at_end () && li->has_children ()) { - ++li; - } - if (! li.at_end ()) { - mp_control_panel->set_current_layer (li); - } + if (cv_index == 0) { + ensure_layer_selected (); } // signal to any observers @@ -2727,20 +2717,17 @@ LayoutViewBase::add_layout (lay::LayoutHandle *layout_handle, bool add_cellview, set_active_cellview_index (cv_index); } - m_active_cellview_changed_event_enabled = true; + enable_active_cellview_changed_event (true); } catch (...) { update_content (); - m_active_cellview_changed_event_enabled = true; + enable_active_cellview_changed_event (true, true); throw; } - // this event may not be generated otherwise, hence force it now. - active_cellview_changed (cv_index); - return cv_index; } @@ -2824,7 +2811,7 @@ LayoutViewBase::load_layout (const std::string &filename, const db::LoadLayoutOp try { - m_active_cellview_changed_event_enabled = false; + enable_active_cellview_changed_event (false); // select the cell with the largest area as the first top cell db::Layout::top_down_const_iterator top = cv->layout ().begin_top_down (); @@ -2875,15 +2862,8 @@ LayoutViewBase::load_layout (const std::string &filename, const db::LoadLayoutOp create_initial_layer_props (cv_index, lyp_file, add_other_layers); // select the first layer if nothing else is selected - if (cv_index == 0 && ! mp_control_panel->has_selection ()) { - const lay::LayerPropertiesList &lp = get_properties (); - lay::LayerPropertiesConstIterator li = lp.begin_const_recursive (); - while (! li.at_end () && li->has_children ()) { - ++li; - } - if (! li.at_end ()) { - mp_control_panel->set_current_layer (li); - } + if (cv_index == 0) { + ensure_layer_selected (); } // signal to any observers @@ -2896,20 +2876,17 @@ LayoutViewBase::load_layout (const std::string &filename, const db::LoadLayoutOp } update_content (); - m_active_cellview_changed_event_enabled = true; + enable_active_cellview_changed_event (true); } catch (...) { update_content (); - m_active_cellview_changed_event_enabled = true; + enable_active_cellview_changed_event (true, true /*silent*/); throw; } - // this event may not be generated otherwise, hence force it now. - active_cellview_changed (cv_index); - return cv_index; } @@ -3092,7 +3069,7 @@ LayoutViewBase::timer () if (dirty != m_dirty) { m_dirty = dirty; - emit dirty_changed (); + emit_dirty_changed (); } if (m_prop_changed) { @@ -3105,9 +3082,7 @@ LayoutViewBase::timer () m_last_checked = current_time; if (m_animated) { set_view_ops (); - if (mp_control_panel) { - mp_control_panel->set_phase (int (m_phase)); - } + do_set_phase (int (m_phase)); if (m_animated) { ++m_phase; } @@ -3124,7 +3099,7 @@ LayoutViewBase::force_update_content () void LayoutViewBase::update_content () { - if (m_activated) { + if (is_activated ()) { set_view_ops (); } } @@ -3836,20 +3811,6 @@ LayoutViewBase::set_hier_levels_basic (std::pair l) { if (l != get_hier_levels ()) { - if (mp_min_hier_spbx) { - mp_min_hier_spbx->blockSignals (true); - mp_min_hier_spbx->setValue (l.first); - mp_min_hier_spbx->setMaximum (l.second); - mp_min_hier_spbx->blockSignals (false); - } - - if (mp_max_hier_spbx) { - mp_max_hier_spbx->blockSignals (true); - mp_max_hier_spbx->setValue (l.second); - mp_max_hier_spbx->setMinimum (l.first); - mp_max_hier_spbx->blockSignals (false); - } - m_from_level = l.first; m_to_level = l.second; @@ -4122,17 +4083,21 @@ LayoutViewBase::select_cellviews_fit (const std::list &cvs) void LayoutViewBase::cellview_changed (unsigned int index) { - if (mp_hierarchy_panel) { - mp_hierarchy_panel->do_update_content (index); - } + update_content_for_cv (index); cellview_changed_event (index); if (m_title.empty ()) { - emit title_changed (); + emit_title_changed (); } } +void +LayoutViewBase::set_current_cell_path (int /*cv_index*/, const cell_path_type & /*path*/) +{ + // .. nothing yet .. +} + void LayoutViewBase::select_cell_dispatch (const cell_path_type &path, int cellview_index) { @@ -4523,9 +4488,7 @@ LayoutViewBase::no_stipples (bool f) { if (m_no_stipples != f) { m_no_stipples = f; - if (mp_control_panel) { - mp_control_panel->set_no_stipples (m_no_stipples); - } + do_set_no_stipples (f); update_content (); } } @@ -4613,43 +4576,24 @@ LayoutViewBase::paste_interactive () void LayoutViewBase::copy () { - if (mp_hierarchy_panel && mp_hierarchy_panel->has_focus ()) { - mp_hierarchy_panel->copy (); - } else if (mp_control_panel && mp_control_panel->has_focus ()) { - mp_control_panel->copy (); - } else { - - if (! lay::Editables::has_selection ()) { - // try to use the transient selection for the real one - lay::Editables::transient_to_selection (); - } - - lay::Editables::copy (); - + if (! lay::Editables::has_selection ()) { + // try to use the transient selection for the real one + lay::Editables::transient_to_selection (); } + + lay::Editables::copy (); } void LayoutViewBase::cut () { - if (mp_hierarchy_panel && mp_hierarchy_panel->has_focus ()) { - // TODO: currently the hierarchy panel's cut function does it's own transaction handling. - // Otherwise the cut function is not working propertly. - mp_hierarchy_panel->cut (); - } else if (mp_control_panel && mp_control_panel->has_focus ()) { - db::Transaction trans (manager (), tl::to_string (QObject::tr ("Cut Layers"))); - mp_control_panel->cut (); - } else { - - if (! lay::Editables::has_selection ()) { - // try to use the transient selection for the real one - lay::Editables::transient_to_selection (); - } - - db::Transaction trans (manager (), tl::to_string (QObject::tr ("Cut"))); - lay::Editables::cut (); - + if (! lay::Editables::has_selection ()) { + // try to use the transient selection for the real one + lay::Editables::transient_to_selection (); } + + db::Transaction trans (manager (), tl::to_string (QObject::tr ("Cut"))); + lay::Editables::cut (); } void @@ -4686,7 +4630,7 @@ LayoutViewBase::add_missing_layers () } } - emit layer_order_changed (); + emit_layer_order_changed (); } LayerState @@ -4742,15 +4686,7 @@ LayoutViewBase::add_new_layers (const LayerState &state) } if (needs_update) { - emit layer_order_changed (); - } -} - -void -LayoutViewBase::remove_unused_layers () -{ - if (mp_control_panel) { - mp_control_panel->cm_remove_unused (); + emit_layer_order_changed (); } } @@ -4809,25 +4745,79 @@ LayoutViewBase::stop () deactivate_all_browsers (); } +void +LayoutViewBase::begin_layer_updates () +{ + // .. nothing yet .. +} + +void +LayoutViewBase::ensure_layer_selected () +{ + // .. nothing yet .. +} + +void +LayoutViewBase::do_set_current_layer (const lay::LayerPropertiesConstIterator & /*l*/) +{ + // .. nothing yet .. +} + +void +LayoutViewBase::do_set_no_stipples (bool /*no_stipples*/) +{ + // .. nothing yet .. +} + +void +LayoutViewBase::do_set_phase (int /*phase*/) +{ + // .. nothing yet .. +} + +void +LayoutViewBase::deactivate_all_browsers () +{ + // .. nothing yet .. +} + +bool +LayoutViewBase::is_activated () const +{ + return true; +} + void LayoutViewBase::switch_mode (int /*m*/) { // .. nothing yet .. } +void +LayoutViewBase::set_active_cellview_index (int /*index*/) +{ + // .. nothing yet .. +} + +void +LayoutViewBase::enable_active_cellview_changed_event (bool /*enable*/, bool /*silent*/) +{ + // .. nothing yet .. +} + void LayoutViewBase::mode (int m) { if (m != m_mode) { m_mode = m; - lay::Plugin *active_plugin = 0; + mp_active_plugin = 0; if (m > 0) { for (std::vector::iterator p = mp_plugins.begin (); p != mp_plugins.end (); ++p) { if ((*p)->plugin_declaration ()->id () == m) { - active_plugin = *p; + mp_active_plugin = *p; mp_canvas->activate ((*p)->view_service_interface ()); break; } @@ -4839,22 +4829,6 @@ LayoutViewBase::mode (int m) mp_canvas->activate (mp_move_service); } - lay::EditorOptionsPages *eo_pages = editor_options_pages (); - if (eo_pages) { - - // TODO: this is very inefficient as each "activate" will regenerate the tabs - for (std::vector::const_iterator op = eo_pages->pages ().begin (); op != eo_pages->pages ().end (); ++op) { - bool is_active = false; - if ((*op)->plugin_declaration () == 0) { - is_active = true; - } else if (active_plugin && active_plugin->plugin_declaration () == (*op)->plugin_declaration ()) { - is_active = true; - } - (*op)->activate (is_active); - } - - } - } } @@ -4911,15 +4885,21 @@ LayoutViewBase::menu_activated (const std::string &symbol) } } -void +void +LayoutViewBase::update_content_for_cv (int /*cellview_index*/) +{ + // .. nothing yet .. +} + +void LayoutViewBase::rename_cellview (const std::string &name, int cellview_index) { if (cellview_index >= 0 && cellview_index < int (m_cellviews.size ())) { if ((*cellview_iter (cellview_index))->name () != name) { (*cellview_iter (cellview_index))->rename (name); - mp_hierarchy_panel->do_update_content (cellview_index); + update_content_for_cv (cellview_index); if (m_title.empty ()) { - emit title_changed (); + emit_title_changed (); } } } diff --git a/src/laybasic/laybasic/layLayoutViewBase.h b/src/laybasic/laybasic/layLayoutViewBase.h index 6a6254114..55fd70dd8 100644 --- a/src/laybasic/laybasic/layLayoutViewBase.h +++ b/src/laybasic/laybasic/layLayoutViewBase.h @@ -53,6 +53,10 @@ #include "tlTimer.h" #include "dbInstElement.h" +#if defined(HAVE_QT) +class QWidget; +#endif + namespace rdb { class Database; } @@ -1392,7 +1396,7 @@ public: /** * @brief Select a certain mode (by index) */ - void mode (int m); + virtual void mode (int m); /** * @brief Test, if the view is currently in move mode. @@ -2022,35 +2026,6 @@ public: */ LayerState layer_snapshot () const; - /** - * @brief Remove unused layers - */ - void remove_unused_layers (); - - /** - * @brief Returns true, if the layer source shall be shown always in the layer properties tree - */ - bool always_show_source () const - { - return m_always_show_source; - } - - /** - * @brief Returns true, if the layer/datatype shall be shown always in the layer properties tree - */ - bool always_show_ld () const - { - return m_always_show_ld; - } - - /** - * @brief Returns true, if the layout index shall be shown always in the layer properties tree - */ - bool always_show_layout_index () const - { - return m_always_show_layout_index; - } - /** * @brief Add a marker database * @@ -2364,9 +2339,6 @@ private: tl::vector m_l2ndbs; std::string m_def_lyp_file; bool m_add_other_layers; - bool m_always_show_source; - bool m_always_show_ld; - bool m_always_show_layout_index; bool m_synchronous; int m_drawing_workers; @@ -2461,6 +2433,8 @@ private: std::vector mp_plugins; + lay::Plugin *mp_active_plugin; + bool m_visibility_changed; tl::Clock m_clock, m_last_checked; @@ -2484,7 +2458,6 @@ private: void abstract_mode_enabled (bool e); bool has_max_hier () const; int max_hier_level () const; - bool set_hier_levels_basic (std::pair l); void update_event_handlers (); void viewport_changed (); @@ -2495,9 +2468,6 @@ private: void init_layer_properties (LayerProperties &props, const LayerPropertiesList &lp_list) const; void merge_dither_pattern (lay::LayerPropertiesList &props); - // overrides Editables method to display a message - void signal_selection_changed (); - protected: unsigned int options () const { @@ -2509,6 +2479,11 @@ protected: return m_mode; } + lay::Plugin *active_plugin () const + { + return mp_active_plugin; + } + bool configure (const std::string &name, const std::string &value); void config_finalize (); @@ -2517,6 +2492,7 @@ protected: lay::Plugin *create_plugin (const lay::PluginDeclaration *cls); void clear_plugins (); + virtual void create_plugins (const lay::PluginDeclaration *except_this = 0); void free_resources (); @@ -2524,6 +2500,27 @@ protected: virtual void do_set_background_color (lay::Color color, lay::Color contrast); virtual void do_paste (); virtual void switch_mode (int m); + virtual void begin_layer_updates (); + virtual void ensure_layer_selected (); + virtual void do_set_current_layer (const lay::LayerPropertiesConstIterator &l); + virtual void do_set_no_stipples (bool no_stipples); + virtual void do_set_phase (int phase); + virtual void deactivate_all_browsers (); + virtual bool is_activated () const; + virtual void update_content_for_cv (int cv_index); + virtual void set_active_cellview_index (int index); + virtual void enable_active_cellview_changed_event (bool enable, bool silent = false); + virtual bool set_hier_levels_basic (std::pair l); + virtual void set_current_cell_path (int cv_index, const cell_path_type &path); + + virtual void emit_edits_enabled_changed () { } + virtual void emit_title_changed () { } + virtual void emit_dirty_changed () { } + virtual void emit_layer_order_changed () { } + +#if defined(HAVE_QT) + virtual QWidget *widget () { return 0; } +#endif }; } From 63a1b24d244464fe814a40d1b91f2817df29197d Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 30 Apr 2022 23:08:05 +0200 Subject: [PATCH 10/88] WIP --- src/ant/ant/antPlugin.cc | 2 +- src/ant/ant/antPlugin.h | 2 +- src/ant/ant/antService.cc | 2 +- src/ant/ant/antService.h | 8 ++-- src/ant/ant/gsiDeclAnt.cc | 30 +++++++++----- src/edt/edt/edtDialogs.cc | 4 +- src/edt/edt/edtDialogs.h | 4 +- src/edt/edt/edtInstPropertiesPage.cc | 26 ++++++++---- src/edt/edt/edtMainService.cc | 39 +++++++++--------- src/edt/edt/edtMainService.h | 6 +-- src/edt/edt/edtPartialService.cc | 2 +- src/edt/edt/edtPartialService.h | 6 +-- src/edt/edt/edtPlugin.cc | 31 +++++++++----- src/edt/edt/edtPlugin.h | 3 +- src/edt/edt/edtPropertiesPages.cc | 10 ++++- src/edt/edt/edtService.cc | 6 +-- src/edt/edt/edtService.h | 8 ++-- src/edt/edt/edtServiceImpl.cc | 12 +++--- src/edt/edt/edtServiceImpl.h | 12 +++--- src/edt/edt/edtUtils.cc | 4 +- src/edt/edt/edtUtils.h | 6 +-- src/img/img/gsiDeclImg.cc | 28 +++++++++---- src/img/img/imgPlugin.cc | 2 +- src/img/img/imgPlugin.h | 2 +- src/img/img/imgService.cc | 2 +- src/img/img/imgService.h | 6 +-- src/lay/lay/layClipDialog.cc | 2 +- src/lay/lay/layFillDialog.cc | 2 +- src/lay/lay/laySearchReplacePlugin.cc | 2 +- src/laybasic/laybasic/gsiDeclLayMarker.cc | 2 +- src/laybasic/laybasic/gsiDeclLayPlugin.cc | 8 ++-- .../laybasic/layBrowseInstancesForm.cc | 24 +++++++---- .../laybasic/layBrowseInstancesForm.h | 2 +- src/laybasic/laybasic/layBrowseShapesForm.cc | 13 +++--- src/laybasic/laybasic/layBrowseShapesForm.h | 2 +- src/laybasic/laybasic/layBrowser.cc | 4 +- src/laybasic/laybasic/layBrowser.h | 8 ++-- src/laybasic/laybasic/layCellSelectionForm.cc | 2 +- src/laybasic/laybasic/layCellSelectionForm.h | 2 +- src/laybasic/laybasic/layCellView.cc | 4 +- src/laybasic/laybasic/layDispatcher.cc | 15 ------- .../laybasic/layEditorOptionsFrame.cc | 2 +- src/laybasic/laybasic/layEditorOptionsFrame.h | 4 +- src/laybasic/laybasic/layEditorServiceBase.cc | 2 +- src/laybasic/laybasic/layEditorServiceBase.h | 2 +- src/laybasic/laybasic/layFinder.cc | 14 +++---- src/laybasic/laybasic/layFinder.h | 28 ++++++------- src/laybasic/laybasic/layGridNet.cc | 4 +- src/laybasic/laybasic/layGridNet.h | 6 +-- src/laybasic/laybasic/layLayerTreeModel.cc | 2 +- src/laybasic/laybasic/layLayerTreeModel.h | 3 +- src/laybasic/laybasic/layLayoutCanvas.cc | 2 +- src/laybasic/laybasic/layLayoutView.cc | 13 ++++++ src/laybasic/laybasic/layLayoutView.h | 22 ++++++++-- src/laybasic/laybasic/layLayoutViewBase.cc | 24 +++++++++++ src/laybasic/laybasic/layLayoutViewBase.h | 41 ++++++++++++++----- .../laybasic/layLayoutViewFunctions.cc | 10 +++-- .../laybasic/layLayoutViewFunctions.h | 2 +- src/laybasic/laybasic/layMarker.cc | 12 +++--- src/laybasic/laybasic/layMarker.h | 22 +++++----- src/laybasic/laybasic/layMove.cc | 5 +-- src/laybasic/laybasic/layNetlistBrowser.cc | 2 +- .../laybasic/layNetlistBrowserDialog.cc | 15 ++++--- .../laybasic/layNetlistBrowserDialog.h | 2 +- .../laybasic/layNetlistBrowserPage.cc | 4 +- src/laybasic/laybasic/layNetlistBrowserPage.h | 4 +- src/laybasic/laybasic/layRedrawThread.cc | 2 +- src/laybasic/laybasic/layRedrawThread.h | 4 +- .../laybasic/layRedrawThreadWorker.cc | 2 +- src/laybasic/laybasic/layRedrawThreadWorker.h | 2 +- src/laybasic/laybasic/laySelector.cc | 2 +- src/laybasic/laybasic/laySelector.h | 2 +- src/laybasic/laybasic/laySnap.cc | 22 +++++----- src/laybasic/laybasic/laySnap.h | 14 +++---- src/laybasic/laybasic/layZoomBox.cc | 2 +- src/laybasic/laybasic/rdbMarkerBrowser.cc | 2 +- .../laybasic/rdbMarkerBrowserDialog.cc | 29 ++++++++----- .../laybasic/rdbMarkerBrowserDialog.h | 2 +- src/laybasic/laybasic/rdbMarkerBrowserPage.cc | 2 +- src/laybasic/laybasic/rdbMarkerBrowserPage.h | 4 +- .../lay_plugin/layBooleanOperationsPlugin.cc | 2 +- .../tools/diff/lay_plugin/layDiffPlugin.cc | 2 +- .../lay_plugin/layNetTracerPlugin.cc | 2 +- .../tools/view_25d/lay_plugin/layD25Plugin.cc | 2 +- .../tools/xor/lay_plugin/layXORPlugin.cc | 4 +- .../tools/xor/lay_plugin/layXORToolDialog.cc | 2 +- .../tools/xor/lay_plugin/layXORToolDialog.h | 2 +- 87 files changed, 421 insertions(+), 288 deletions(-) diff --git a/src/ant/ant/antPlugin.cc b/src/ant/ant/antPlugin.cc index 330442a94..10f8643b2 100644 --- a/src/ant/ant/antPlugin.cc +++ b/src/ant/ant/antPlugin.cc @@ -91,7 +91,7 @@ PluginDeclaration::get_menu_entries (std::vector &menu_entries) } lay::Plugin * -PluginDeclaration::create_plugin (db::Manager *manager, lay::Dispatcher *, lay::LayoutView *view) const +PluginDeclaration::create_plugin (db::Manager *manager, lay::Dispatcher *, lay::LayoutViewBase *view) const { return new ant::Service (manager, view); } diff --git a/src/ant/ant/antPlugin.h b/src/ant/ant/antPlugin.h index 6d65c03e6..18950ffac 100644 --- a/src/ant/ant/antPlugin.h +++ b/src/ant/ant/antPlugin.h @@ -40,7 +40,7 @@ public: virtual void get_options (std::vector < std::pair > &options) const; virtual void get_menu_entries (std::vector &menu_entries) const; - virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *, lay::LayoutView *view) const; + virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *, lay::LayoutViewBase *view) const; virtual bool implements_editable (std::string &title) const; virtual bool implements_mouse_mode (std::string &title) const; virtual bool configure (const std::string &name, const std::string &value); diff --git a/src/ant/ant/antService.cc b/src/ant/ant/antService.cc index 5c6db1ec2..761b8e059 100644 --- a/src/ant/ant/antService.cc +++ b/src/ant/ant/antService.cc @@ -784,7 +784,7 @@ View::render (const lay::Viewport &vp, lay::ViewObjectCanvas &canvas) // ------------------------------------------------------------- // ant::Service implementation -Service::Service (db::Manager *manager, lay::LayoutView *view) +Service::Service (db::Manager *manager, lay::LayoutViewBase *view) : lay::EditorServiceBase (view), lay::Drawing (1/*number of planes*/, view->drawings ()), db::Object (manager), diff --git a/src/ant/ant/antService.h b/src/ant/ant/antService.h index 9b53cbe03..9aeee7458 100644 --- a/src/ant/ant/antService.h +++ b/src/ant/ant/antService.h @@ -41,7 +41,7 @@ namespace ant { -class LayoutView; +class LayoutViewBase; class LayoutCanvas; class Service; @@ -201,7 +201,7 @@ public: */ enum MoveMode { MoveNone, MoveP1, MoveP2, MoveP12, MoveP21, MoveP1X, MoveP2X, MoveP1Y, MoveP2Y, MoveRuler, MoveSelected }; - Service (db::Manager *manager, lay::LayoutView *view); + Service (db::Manager *manager, lay::LayoutViewBase *view); ~Service (); @@ -427,7 +427,7 @@ public: /** * @brief Access to the view object */ - lay::LayoutView *view () const + lay::LayoutViewBase *view () const { return mp_view; } @@ -510,7 +510,7 @@ private: int m_max_number_of_rulers; // The layout view that the ruler service is attached to - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; // The ruler view objects representing the selection // and the moved rules in move mode diff --git a/src/ant/ant/gsiDeclAnt.cc b/src/ant/ant/gsiDeclAnt.cc index ee928abc6..f7391f5cd 100644 --- a/src/ant/ant/gsiDeclAnt.cc +++ b/src/ant/ant/gsiDeclAnt.cc @@ -72,8 +72,8 @@ static int align_up () { return int (ant::Object::AL_up); } static void clear_annotations (lay::LayoutView *view); static void insert_annotation (lay::LayoutView *view, AnnotationRef *obj); -static void erase_annotation (lay::LayoutView *view, int id); -static void replace_annotation (lay::LayoutView *view, int id, const AnnotationRef &obj); +static void erase_annotation_base (lay::LayoutViewBase *view, int id); +static void replace_annotation_base (lay::LayoutViewBase *view, int id, const AnnotationRef &obj); /** * @brief An extension of the ant::Object that provides "live" updates of the view @@ -88,7 +88,7 @@ public: // .. nothing yet .. } - AnnotationRef (const ant::Object &other, lay::LayoutView *view) + AnnotationRef (const ant::Object &other, lay::LayoutViewBase *view) : ant::Object (other), mp_view (view) { // .. nothing yet .. @@ -132,7 +132,7 @@ public: void erase () { if (mp_view && id () >= 0) { - erase_annotation (mp_view.get (), id ()); + erase_annotation_base (mp_view.get (), id ()); detach (); } } @@ -140,10 +140,10 @@ public: template AnnotationRef transformed (const T &t) const { - return AnnotationRef (ant::Object::transformed (t), const_cast (mp_view.get ())); + return AnnotationRef (ant::Object::transformed (t), const_cast (mp_view.get ())); } - void set_view (lay::LayoutView *view) + void set_view (lay::LayoutViewBase *view) { mp_view.reset (view); } @@ -152,12 +152,12 @@ protected: void property_changed () { if (mp_view && id () >= 0) { - replace_annotation (mp_view.get (), id (), *this); + replace_annotation_base (mp_view.get (), id (), *this); } } private: - tl::weak_ptr mp_view; + tl::weak_ptr mp_view; }; static void clear_annotations (lay::LayoutView *view) @@ -182,7 +182,7 @@ static void insert_annotation (lay::LayoutView *view, AnnotationRef *obj) } } -static void erase_annotation (lay::LayoutView *view, int id) +static void erase_annotation_base (lay::LayoutViewBase *view, int id) { ant::Service *ant_service = view->get_plugin (); if (ant_service) { @@ -195,7 +195,12 @@ static void erase_annotation (lay::LayoutView *view, int id) } } -static void replace_annotation (lay::LayoutView *view, int id, const AnnotationRef &obj) +static void erase_annotation (lay::LayoutView *view, int id) +{ + erase_annotation_base (view, id); +} + +static void replace_annotation_base (lay::LayoutViewBase *view, int id, const AnnotationRef &obj) { ant::Service *ant_service = view->get_plugin (); if (ant_service) { @@ -208,6 +213,11 @@ static void replace_annotation (lay::LayoutView *view, int id, const AnnotationR } } +static void replace_annotation (lay::LayoutView *view, int id, const AnnotationRef &obj) +{ + replace_annotation_base (view, id, obj); +} + static AnnotationRef create_measure_ruler (lay::LayoutView *view, const db::DPoint &pt, int angle_constraint) { std::vector ant_services = view->get_plugins (); diff --git a/src/edt/edt/edtDialogs.cc b/src/edt/edt/edtDialogs.cc index 55fd4a0a2..3cd05ea3f 100644 --- a/src/edt/edt/edtDialogs.cc +++ b/src/edt/edt/edtDialogs.cc @@ -280,7 +280,7 @@ AlignOptionsDialog::~AlignOptionsDialog () } bool -AlignOptionsDialog::exec_dialog (lay::LayoutView * /*view*/, int &hmode, int &vmode, bool &visible_layers) +AlignOptionsDialog::exec_dialog (int &hmode, int &vmode, bool &visible_layers) { QRadioButton *hmode_buttons [] = { this->h_none_rb, this->h_left_rb, this->h_center_rb, this->h_right_rb }; QRadioButton *vmode_buttons [] = { this->v_none_rb, this->v_top_rb, this->v_center_rb, this->v_bottom_rb }; @@ -343,7 +343,7 @@ DistributeOptionsDialog::~DistributeOptionsDialog () } bool -DistributeOptionsDialog::exec_dialog (lay::LayoutView * /*view*/, bool &hdistribute, int &hmode, double &hpitch, double &hspace, bool &vdistribute, int &vmode, double &vpitch, double &vspace, bool &visible_layers) +DistributeOptionsDialog::exec_dialog (bool &hdistribute, int &hmode, double &hpitch, double &hspace, bool &vdistribute, int &vmode, double &vpitch, double &vspace, bool &visible_layers) { QRadioButton *hmode_buttons [] = { this->h_none_rb, this->h_left_rb, this->h_center_rb, this->h_right_rb }; QRadioButton *vmode_buttons [] = { this->v_none_rb, this->v_top_rb, this->v_center_rb, this->v_bottom_rb }; diff --git a/src/edt/edt/edtDialogs.h b/src/edt/edt/edtDialogs.h index 30444311a..f700e01d4 100644 --- a/src/edt/edt/edtDialogs.h +++ b/src/edt/edt/edtDialogs.h @@ -125,7 +125,7 @@ public: AlignOptionsDialog (QWidget *parent); virtual ~AlignOptionsDialog (); - bool exec_dialog (lay::LayoutView *view, int &hmode, int &vmode, bool &visible_layers); + bool exec_dialog (int &hmode, int &vmode, bool &visible_layers); }; /** @@ -141,7 +141,7 @@ public: DistributeOptionsDialog (QWidget *parent); virtual ~DistributeOptionsDialog (); - bool exec_dialog (lay::LayoutView *view, bool &hdistribute, int &hmode, double &hpitch, double &hspace, bool &vdistribute, int &vmode, double &vpitch, double &vspace, bool &visible_layers); + bool exec_dialog (bool &hdistribute, int &hmode, double &hpitch, double &hspace, bool &vdistribute, int &vmode, double &vpitch, double &vspace, bool &visible_layers); }; /** diff --git a/src/edt/edt/edtInstPropertiesPage.cc b/src/edt/edt/edtInstPropertiesPage.cc index cc18336da..a4fe4ac54 100644 --- a/src/edt/edt/edtInstPropertiesPage.cc +++ b/src/edt/edt/edtInstPropertiesPage.cc @@ -206,8 +206,11 @@ END_PROTECTED void InstPropertiesPage::show_props () { + lay::LayoutView *lv = dynamic_cast (mp_service->view ()); + tl_assert (lv != 0); + lay::UserPropertiesForm props_form (this); - if (props_form.show (mp_service->view (), m_selection_ptrs [m_index]->cv_index (), m_prop_id)) { + if (props_form.show (lv, m_selection_ptrs [m_index]->cv_index (), m_prop_id)) { emit edited (); } } @@ -381,21 +384,27 @@ InstPropertiesPage::update () void InstPropertiesPage::show_cell () { + lay::LayoutView *lv = dynamic_cast (mp_service->view ()); + tl_assert (lv != 0); + edt::Service::obj_iterator pos = m_selection_ptrs [m_index]; - lay::CellView::unspecific_cell_path_type path (mp_service->view ()->cellview (pos->cv_index ()).combined_unspecific_path ()); + lay::CellView::unspecific_cell_path_type path (lv->cellview (pos->cv_index ()).combined_unspecific_path ()); for (lay::ObjectInstPath::iterator p = pos->begin (); p != pos->end (); ++p) { path.push_back (p->inst_ptr.cell_index ()); } - mp_service->view ()->set_current_cell_path (pos->cv_index (), path); + lv->set_current_cell_path (pos->cv_index (), path); } void InstPropertiesPage::show_inst () { + lay::LayoutView *lv = dynamic_cast (mp_service->view ()); + tl_assert (lv != 0); + InstantiationForm inst_form (this); - inst_form.show (mp_service->view (), *m_selection_ptrs [m_index]); + inst_form.show (lv, *m_selection_ptrs [m_index]); } bool @@ -843,6 +852,9 @@ InstPropertiesPage::apply_to_all (bool relative) void InstPropertiesPage::update_pcell_parameters () { + lay::LayoutView *lv = dynamic_cast (mp_service->view ()); + tl_assert (lv != 0); + db::Layout *layout; // find the layout the cell has to be looked up: that is either the layout of the current instance or @@ -854,7 +866,7 @@ InstPropertiesPage::update_pcell_parameters () } else { edt::Service::obj_iterator pos = m_selection_ptrs [m_index]; - const lay::CellView &cv = mp_service->view ()->cellview (pos->cv_index ()); + const lay::CellView &cv = lv->cellview (pos->cv_index ()); layout = &cv->layout (); } @@ -878,7 +890,7 @@ InstPropertiesPage::update_pcell_parameters () std::vector parameters; edt::Service::obj_iterator pos = m_selection_ptrs [m_index]; - const lay::CellView &cv = mp_service->view ()->cellview (pos->cv_index ()); + const lay::CellView &cv = lv->cellview (pos->cv_index ()); db::Cell &cell = cv->layout ().cell (pos->cell_index ()); std::pair pci = cell.is_pcell_instance (pos->back ().inst_ptr); const db::Library *pci_lib = cv->layout ().defining_library (pos->back ().inst_ptr.cell_index ()).first; @@ -912,7 +924,7 @@ InstPropertiesPage::update_pcell_parameters () mp_pcell_parameters = new PCellParametersPage (pcell_tab); connect (mp_pcell_parameters, SIGNAL (edited ()), this, SIGNAL (edited ())); - mp_pcell_parameters->setup (mp_service->view (), pos->cv_index (), layout->pcell_declaration (pc.second), parameters); + mp_pcell_parameters->setup (lv, pos->cv_index (), layout->pcell_declaration (pc.second), parameters); pcell_tab->layout ()->addWidget (mp_pcell_parameters); } diff --git a/src/edt/edt/edtMainService.cc b/src/edt/edt/edtMainService.cc index 837b0c944..30e5ff26c 100644 --- a/src/edt/edt/edtMainService.cc +++ b/src/edt/edt/edtMainService.cc @@ -55,7 +55,7 @@ namespace edt // ----------------------------------------------------------------------------- // Main Service implementation -MainService::MainService (db::Manager *manager, lay::LayoutView *view, lay::Dispatcher *root) +MainService::MainService (db::Manager *manager, lay::LayoutViewBase *view, lay::Dispatcher *root) : lay::Plugin (view), lay::Editable (view), db::Object (manager), @@ -93,7 +93,7 @@ edt::RoundCornerOptionsDialog * MainService::round_corners_dialog () { if (! mp_round_corners_dialog) { - mp_round_corners_dialog = new edt::RoundCornerOptionsDialog (view ()); + mp_round_corners_dialog = new edt::RoundCornerOptionsDialog (view ()->widget ()); } return mp_round_corners_dialog; } @@ -102,7 +102,7 @@ edt::AlignOptionsDialog * MainService::align_options_dialog () { if (! mp_align_options_dialog) { - mp_align_options_dialog = new edt::AlignOptionsDialog (view ()); + mp_align_options_dialog = new edt::AlignOptionsDialog (view ()->widget ()); } return mp_align_options_dialog; } @@ -111,7 +111,7 @@ edt::DistributeOptionsDialog * MainService::distribute_options_dialog () { if (! mp_distribute_options_dialog) { - mp_distribute_options_dialog = new edt::DistributeOptionsDialog (view ()); + mp_distribute_options_dialog = new edt::DistributeOptionsDialog (view ()->widget ()); } return mp_distribute_options_dialog; } @@ -120,7 +120,7 @@ lay::FlattenInstOptionsDialog * MainService::flatten_inst_options_dialog () { if (! mp_flatten_inst_options_dialog) { - mp_flatten_inst_options_dialog = new lay::FlattenInstOptionsDialog (view (), false /*don't allow pruning*/); + mp_flatten_inst_options_dialog = new lay::FlattenInstOptionsDialog (view ()->widget (), false /*don't allow pruning*/); } return mp_flatten_inst_options_dialog; } @@ -129,7 +129,7 @@ edt::MakeCellOptionsDialog * MainService::make_cell_options_dialog () { if (! mp_make_cell_options_dialog) { - mp_make_cell_options_dialog = new edt::MakeCellOptionsDialog (view ()); + mp_make_cell_options_dialog = new edt::MakeCellOptionsDialog (view ()->widget ()); } return mp_make_cell_options_dialog; } @@ -138,7 +138,7 @@ edt::MakeArrayOptionsDialog * MainService::make_array_options_dialog () { if (! mp_make_array_options_dialog) { - mp_make_array_options_dialog = new edt::MakeArrayOptionsDialog (view ()); + mp_make_array_options_dialog = new edt::MakeArrayOptionsDialog (view ()->widget ()); } return mp_make_array_options_dialog; } @@ -1188,9 +1188,10 @@ MainService::cm_convert_to_pcell () } bool ok = false; - QString item = QInputDialog::getItem (view (), QObject::tr ("Select Target PCell"), - QObject::tr ("Select the PCell the shape should be converted into"), - items, 0, false, &ok); + QString item = QInputDialog::getItem (view ()->widget (), + QObject::tr ("Select Target PCell"), + QObject::tr ("Select the PCell the shape should be converted into"), + items, 0, false, &ok); if (! ok) { return; } @@ -1289,7 +1290,7 @@ MainService::cm_convert_to_pcell () } if (any_non_converted) { - QMessageBox::warning (view (), QObject::tr ("Warning"), QObject::tr ("Some of the shapes could not be converted to the desired PCell")); + QMessageBox::warning (view ()->widget (), QObject::tr ("Warning"), QObject::tr ("Some of the shapes could not be converted to the desired PCell")); } manager ()->commit (); @@ -1505,7 +1506,7 @@ MainService::cm_size () } bool ok = false; - QString s = QInputDialog::getText (view (), + QString s = QInputDialog::getText (view ()->widget (), QObject::tr ("Sizing"), QObject::tr ("Sizing (in micron, positive or negative). Two values (dx, dy) for anisotropic sizing."), QLineEdit::Normal, QString::fromUtf8 ("0.0"), @@ -1750,7 +1751,7 @@ db::DVector compute_alignment_vector (const db::DBox &prim_box, const db::DBox & } static db::DBox -inst_bbox (const db::CplxTrans &tr, lay::LayoutView *view, int cv_index, const db::InstElement &inst_element, bool visible_only) +inst_bbox (const db::CplxTrans &tr, lay::LayoutViewBase *view, int cv_index, const db::InstElement &inst_element, bool visible_only) { db::DBox box; @@ -1779,7 +1780,7 @@ MainService::cm_align () std::vector edt_services = view ()->get_plugins (); - if (! align_options_dialog ()->exec_dialog (view (), m_align_hmode, m_align_vmode, m_align_visible_layers)) { + if (! align_options_dialog ()->exec_dialog (m_align_hmode, m_align_vmode, m_align_visible_layers)) { return; } @@ -1865,9 +1866,9 @@ MainService::cm_distribute () std::vector edt_services = view ()->get_plugins (); - if (! distribute_options_dialog ()->exec_dialog (view (), m_hdistribute, m_distribute_hmode, m_distribute_hpitch, m_distribute_hspace, - m_vdistribute, m_distribute_vmode, m_distribute_vpitch, m_distribute_vspace, - m_distribute_visible_layers)) { + if (! distribute_options_dialog ()->exec_dialog (m_hdistribute, m_distribute_hmode, m_distribute_hpitch, m_distribute_hspace, + m_vdistribute, m_distribute_vmode, m_distribute_vpitch, m_distribute_vspace, + m_distribute_visible_layers)) { return; } @@ -2107,7 +2108,7 @@ MainService::cm_tap () // List the layers under the cursor as pop up a menu - std::unique_ptr menu (new QMenu (view ())); + std::unique_ptr menu (new QMenu (view ()->widget ())); menu->show (); int icon_size = menu->style ()->pixelMetric (QStyle::PM_ButtonIconSize); @@ -2294,7 +2295,7 @@ class NewObjectsSelection : public db::ClipboardDataInsertReceiver { public: - NewObjectsSelection (int cv_index, db::cell_index_type topcell, lay::LayoutView *view) + NewObjectsSelection (int cv_index, db::cell_index_type topcell, lay::LayoutViewBase *view) : m_cv_index (cv_index), m_topcell (topcell) { mp_polygon_service = view->get_plugin (); diff --git a/src/edt/edt/edtMainService.h b/src/edt/edt/edtMainService.h index 60c8c4a8f..3ca99c373 100644 --- a/src/edt/edt/edtMainService.h +++ b/src/edt/edt/edtMainService.h @@ -64,7 +64,7 @@ public: /** * @brief The constructor */ - MainService (db::Manager *manager, lay::LayoutView *view, lay::Dispatcher *root); + MainService (db::Manager *manager, lay::LayoutViewBase *view, lay::Dispatcher *root); /** * @brief The destructor @@ -74,7 +74,7 @@ public: /** * @brief Access to the view object */ - lay::LayoutView *view () const + lay::LayoutViewBase *view () const { return mp_view; } @@ -196,7 +196,7 @@ public: private: // The layout view that this service is attached to - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; lay::Dispatcher *mp_root; bool m_needs_update; diff --git a/src/edt/edt/edtPartialService.cc b/src/edt/edt/edtPartialService.cc index a22882651..f43270b35 100644 --- a/src/edt/edt/edtPartialService.cc +++ b/src/edt/edt/edtPartialService.cc @@ -1010,7 +1010,7 @@ PartialShapeFinder::visit_cell (const db::Cell &cell, const db::Box &search_box, // ----------------------------------------------------------------------------- // Main Service implementation -PartialService::PartialService (db::Manager *manager, lay::LayoutView *view, lay::Dispatcher *root) +PartialService::PartialService (db::Manager *manager, lay::LayoutViewBase *view, lay::Dispatcher *root) : QObject (), lay::EditorServiceBase (view), db::Object (manager), diff --git a/src/edt/edt/edtPartialService.h b/src/edt/edt/edtPartialService.h index 0781dcf81..4c7018334 100644 --- a/src/edt/edt/edtPartialService.h +++ b/src/edt/edt/edtPartialService.h @@ -149,7 +149,7 @@ public: /** * @brief The constructor */ - PartialService (db::Manager *manager, lay::LayoutView *view, lay::Dispatcher *root); + PartialService (db::Manager *manager, lay::LayoutViewBase *view, lay::Dispatcher *root); /** * @brief The destructor @@ -159,7 +159,7 @@ public: /** * @brief Access to the view object */ - lay::LayoutView *view () const + lay::LayoutViewBase *view () const { tl_assert (mp_view != 0); return mp_view; @@ -298,7 +298,7 @@ protected: private: // The layout view that this service is attached to - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; lay::Dispatcher *mp_root; bool m_dragging; bool m_keep_selection; diff --git a/src/edt/edt/edtPlugin.cc b/src/edt/edt/edtPlugin.cc index a4a6e3608..518aaa140 100644 --- a/src/edt/edt/edtPlugin.cc +++ b/src/edt/edt/edtPlugin.cc @@ -179,18 +179,21 @@ public: // .. nothing yet .. } - virtual void get_editor_options_pages (std::vector &pages, lay::LayoutView *view, lay::Dispatcher *root) const + virtual void get_editor_options_pages (std::vector &pages, lay::LayoutViewBase *view, lay::Dispatcher *root) const { + lay::LayoutView *lv = dynamic_cast (view); + tl_assert (lv != 0); + if (mp_pages_f != 0) { size_t nstart = pages.size (); - (*mp_pages_f) (pages, view, root); + (*mp_pages_f) (pages, lv, root); while (nstart < pages.size ()) { pages [nstart++]->set_plugin_declaration (this); } } } - virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *, lay::LayoutView *view) const + virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *, lay::LayoutViewBase *view) const { Svc *service = new Svc (manager, view); service->set_plugin_declaration (this); @@ -312,7 +315,7 @@ public: return false; } - virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *root, lay::LayoutView *view) const + virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *root, lay::LayoutViewBase *view) const { return new edt::MainService (manager, view, root); } @@ -327,10 +330,13 @@ public: return false; } - virtual void get_editor_options_pages (std::vector &pages, lay::LayoutView *view, lay::Dispatcher *dispatcher) const + virtual void get_editor_options_pages (std::vector &pages, lay::LayoutViewBase *view, lay::Dispatcher *dispatcher) const { + lay::LayoutView *lv = dynamic_cast (view); + tl_assert (lv != 0); + // NOTE: we do not set plugin_declaration which makes the page unspecific - EditorOptionsGeneric *generic_opt = new EditorOptionsGeneric (view, dispatcher); + EditorOptionsGeneric *generic_opt = new EditorOptionsGeneric (lv, dispatcher); pages.push_back (generic_opt); } @@ -413,9 +419,14 @@ private: static tl::RegisteredClass config_decl_main (new edt::MainPluginDeclaration (tl::to_string (QObject::tr ("Instances and shapes"))), 4000, "edt::MainService"); void -commit_recent (lay::LayoutView *view) +commit_recent (lay::LayoutViewBase *view) { - lay::EditorOptionsPages *eo_pages = view->editor_options_pages ();; + lay::LayoutView *lv = dynamic_cast (view); + if (!lv) { + return; + } + + lay::EditorOptionsPages *eo_pages = lv->editor_options_pages (); if (!eo_pages) { return; } @@ -442,12 +453,12 @@ public: // .. nothing yet .. } - virtual void get_editor_options_pages (std::vector & /*pages*/, lay::LayoutView * /*view*/, lay::Dispatcher * /*root*/) const + virtual void get_editor_options_pages (std::vector & /*pages*/, lay::LayoutViewBase * /*view*/, lay::Dispatcher * /*root*/) const { // .. no specific ones .. } - virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *root, lay::LayoutView *view) const + virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *root, lay::LayoutViewBase *view) const { return new edt::PartialService (manager, view, root); } diff --git a/src/edt/edt/edtPlugin.h b/src/edt/edt/edtPlugin.h index f5a789a3e..1baee02fa 100644 --- a/src/edt/edt/edtPlugin.h +++ b/src/edt/edt/edtPlugin.h @@ -32,6 +32,7 @@ namespace lay { class Dispatcher; class EditorOptionsPage; + class LayoutView; } namespace edt @@ -48,7 +49,7 @@ namespace edt /** * @brief Commits the current configuration for the recently used configuration list */ - void commit_recent (lay::LayoutView *view); + void commit_recent (lay::LayoutViewBase *view); } #endif diff --git a/src/edt/edt/edtPropertiesPages.cc b/src/edt/edt/edtPropertiesPages.cc index 5943d609a..21b3079c9 100644 --- a/src/edt/edt/edtPropertiesPages.cc +++ b/src/edt/edt/edtPropertiesPages.cc @@ -360,15 +360,21 @@ ShapePropertiesPage::update_shape () void ShapePropertiesPage::show_inst () { + lay::LayoutView *lv = dynamic_cast (mp_service->view ()); + tl_assert (lv != 0); + InstantiationForm inst_form (this); - inst_form.show (mp_service->view (), *m_selection_ptrs [m_index]); + inst_form.show (lv, *m_selection_ptrs [m_index]); } void ShapePropertiesPage::show_props () { + lay::LayoutView *lv = dynamic_cast (mp_service->view ()); + tl_assert (lv != 0); + lay::UserPropertiesForm props_form (this); - if (props_form.show (mp_service->view (), m_selection_ptrs [m_index]->cv_index (), m_prop_id)) { + if (props_form.show (lv, m_selection_ptrs [m_index]->cv_index (), m_prop_id)) { emit edited (); } } diff --git a/src/edt/edt/edtService.cc b/src/edt/edt/edtService.cc index 40dbefc39..1f750dad2 100644 --- a/src/edt/edt/edtService.cc +++ b/src/edt/edt/edtService.cc @@ -60,7 +60,7 @@ ac_from_buttons (unsigned int buttons) // ------------------------------------------------------------- -Service::Service (db::Manager *manager, lay::LayoutView *view, db::ShapeIterator::flags_type flags) +Service::Service (db::Manager *manager, lay::LayoutViewBase *view, db::ShapeIterator::flags_type flags) : lay::EditorServiceBase (view), db::Object (manager), mp_view (view), @@ -80,7 +80,7 @@ Service::Service (db::Manager *manager, lay::LayoutView *view, db::ShapeIterator // .. nothing yet .. } -Service::Service (db::Manager *manager, lay::LayoutView *view) +Service::Service (db::Manager *manager, lay::LayoutViewBase *view) : lay::EditorServiceBase (view), db::Object (manager), mp_view (view), @@ -312,7 +312,7 @@ Service::copy () void Service::copy_selected () { - edt::CopyModeDialog mode_dialog (view ()); + edt::CopyModeDialog mode_dialog (view ()->widget ()); bool need_to_ask_for_copy_mode = false; unsigned int inst_mode = 0; diff --git a/src/edt/edt/edtService.h b/src/edt/edt/edtService.h index 2dc67d46a..ea420c4cb 100644 --- a/src/edt/edt/edtService.h +++ b/src/edt/edt/edtService.h @@ -82,12 +82,12 @@ public: /** * @brief The constructor for an service selecting shapes */ - Service (db::Manager *manager, lay::LayoutView *view, db::ShapeIterator::flags_type shape_types); + Service (db::Manager *manager, lay::LayoutViewBase *view, db::ShapeIterator::flags_type shape_types); /** * @brief The constructor for an service selecting instances */ - Service (db::Manager *manager, lay::LayoutView *view); + Service (db::Manager *manager, lay::LayoutViewBase *view); /** * @brief The destructor @@ -243,7 +243,7 @@ public: /** * @brief Access to the view object */ - lay::LayoutView *view () const + lay::LayoutViewBase *view () const { tl_assert (mp_view != 0); return mp_view; @@ -559,7 +559,7 @@ protected: private: // The layout view that the editor service is attached to - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; // The marker objects representing the selection std::vector m_markers; diff --git a/src/edt/edt/edtServiceImpl.cc b/src/edt/edt/edtServiceImpl.cc index b22360339..d4aa7413d 100644 --- a/src/edt/edt/edtServiceImpl.cc +++ b/src/edt/edt/edtServiceImpl.cc @@ -47,7 +47,7 @@ namespace edt // ----------------------------------------------------------------------------- // ShapeEditService implementation -ShapeEditService::ShapeEditService (db::Manager *manager, lay::LayoutView *view, db::ShapeIterator::flags_type shape_types) +ShapeEditService::ShapeEditService (db::Manager *manager, lay::LayoutViewBase *view, db::ShapeIterator::flags_type shape_types) : edt::Service (manager, view, shape_types), m_layer (0), m_cv_index (0), mp_cell (0), mp_layout (0), m_combine_mode (CM_Add) { @@ -362,7 +362,7 @@ ShapeEditService::deliver_shape (const db::Box &box) // ----------------------------------------------------------------------------- // PolygonService implementation -PolygonService::PolygonService (db::Manager *manager, lay::LayoutView *view) +PolygonService::PolygonService (db::Manager *manager, lay::LayoutViewBase *view) : ShapeEditService (manager, view, db::ShapeIterator::Polygons), m_closure_set (false), m_closure () { @@ -692,7 +692,7 @@ PolygonService::update_marker () // ----------------------------------------------------------------------------- // BoxService implementation -BoxService::BoxService (db::Manager *manager, lay::LayoutView *view) +BoxService::BoxService (db::Manager *manager, lay::LayoutViewBase *view) : ShapeEditService (manager, view, db::ShapeIterator::Boxes) { // .. nothing yet .. @@ -784,7 +784,7 @@ BoxService::selection_applies (const lay::ObjectInstPath &sel) const // ----------------------------------------------------------------------------- // TextService implementation -TextService::TextService (db::Manager *manager, lay::LayoutView *view) +TextService::TextService (db::Manager *manager, lay::LayoutViewBase *view) : ShapeEditService (manager, view, db::ShapeIterator::Texts), m_rot (0) { @@ -972,7 +972,7 @@ TextService::configure (const std::string &name, const std::string &value) // ----------------------------------------------------------------------------- // PathService implementation -PathService::PathService (db::Manager *manager, lay::LayoutView *view) +PathService::PathService (db::Manager *manager, lay::LayoutViewBase *view) : ShapeEditService (manager, view, db::ShapeIterator::Paths), m_width (0.1), m_bgnext (0.0), m_endext (0.0), m_type (Flush), m_needs_update (true) { @@ -1211,7 +1211,7 @@ PathService::config_finalize () // ----------------------------------------------------------------------------- // InstService implementation -InstService::InstService (db::Manager *manager, lay::LayoutView *view) +InstService::InstService (db::Manager *manager, lay::LayoutViewBase *view) : edt::Service (manager, view), m_angle (0.0), m_scale (1.0), m_mirror (false), m_is_pcell (false), diff --git a/src/edt/edt/edtServiceImpl.h b/src/edt/edt/edtServiceImpl.h index c3caf4383..145a8d2ff 100644 --- a/src/edt/edt/edtServiceImpl.h +++ b/src/edt/edt/edtServiceImpl.h @@ -45,7 +45,7 @@ class ShapeEditService : public edt::Service { public: - ShapeEditService (db::Manager *manager, lay::LayoutView *view, db::ShapeIterator::flags_type shape_types); + ShapeEditService (db::Manager *manager, lay::LayoutViewBase *view, db::ShapeIterator::flags_type shape_types); protected: void get_edit_layer (); @@ -86,7 +86,7 @@ class PolygonService : public ShapeEditService { public: - PolygonService (db::Manager *manager, lay::LayoutView *view); + PolygonService (db::Manager *manager, lay::LayoutViewBase *view); virtual lay::PropertiesPage *properties_page (db::Manager *manager, QWidget *parent); virtual void do_delete (); @@ -117,7 +117,7 @@ class BoxService : public ShapeEditService { public: - BoxService (db::Manager *manager, lay::LayoutView *view); + BoxService (db::Manager *manager, lay::LayoutViewBase *view); virtual lay::PropertiesPage *properties_page (db::Manager *manager, QWidget *parent); virtual void do_begin_edit (const db::DPoint &p); @@ -142,7 +142,7 @@ class TextService : public ShapeEditService { public: - TextService (db::Manager *manager, lay::LayoutView *view); + TextService (db::Manager *manager, lay::LayoutViewBase *view); ~TextService (); virtual lay::PropertiesPage *properties_page (db::Manager *manager, QWidget *parent); @@ -174,7 +174,7 @@ class PathService : public ShapeEditService { public: - PathService (db::Manager *manager, lay::LayoutView *view); + PathService (db::Manager *manager, lay::LayoutViewBase *view); ~PathService (); virtual lay::PropertiesPage *properties_page (db::Manager *manager, QWidget *parent); @@ -211,7 +211,7 @@ class InstService : public edt::Service { public: - InstService (db::Manager *manager, lay::LayoutView *view); + InstService (db::Manager *manager, lay::LayoutViewBase *view); virtual lay::PropertiesPage *properties_page (db::Manager *manager, QWidget *parent); virtual void do_begin_edit (const db::DPoint &p); diff --git a/src/edt/edt/edtUtils.cc b/src/edt/edt/edtUtils.cc index 4b04d9de8..08ca08827 100644 --- a/src/edt/edt/edtUtils.cc +++ b/src/edt/edt/edtUtils.cc @@ -77,7 +77,7 @@ std::map pcell_parameters_from_string (const std::stri // ------------------------------------------------------------- // SelectionIterator implementation -SelectionIterator::SelectionIterator (lay::LayoutView *view, bool including_transient) +SelectionIterator::SelectionIterator (lay::LayoutViewBase *view, bool including_transient) : m_transient_mode (false) { mp_edt_services = view->get_plugins (); @@ -145,7 +145,7 @@ SelectionIterator::next () // TransformationsVariants implementation // for a lay::LayoutView -TransformationVariants::TransformationVariants (const lay::LayoutView *view, bool per_cv_and_layer, bool per_cv) +TransformationVariants::TransformationVariants (const lay::LayoutViewBase *view, bool per_cv_and_layer, bool per_cv) { // build the transformation variants cache diff --git a/src/edt/edt/edtUtils.h b/src/edt/edt/edtUtils.h index af9a81999..703dcfbf7 100644 --- a/src/edt/edt/edtUtils.h +++ b/src/edt/edt/edtUtils.h @@ -40,7 +40,7 @@ namespace lay { - class LayoutView; + class LayoutViewBase; } namespace edt { @@ -84,7 +84,7 @@ public: class TransformationVariants { public: - TransformationVariants (const lay::LayoutView *view, bool per_cv_and_layer = true, bool per_cv = true); + TransformationVariants (const lay::LayoutViewBase *view, bool per_cv_and_layer = true, bool per_cv = true); const std::vector *per_cv_and_layer (unsigned int cv, unsigned int layer) const; const std::vector *per_cv (unsigned int cv) const; @@ -109,7 +109,7 @@ public: * * If "including_transient" is true, the transient selection will be used as fallback. */ - SelectionIterator (lay::LayoutView *view, bool including_transient = true); + SelectionIterator (lay::LayoutViewBase *view, bool including_transient = true); /** * @brief Returns a value indicating whether the transient selection is taken diff --git a/src/img/img/gsiDeclImg.cc b/src/img/img/gsiDeclImg.cc index 096375845..bc40cc8c1 100644 --- a/src/img/img/gsiDeclImg.cc +++ b/src/img/img/gsiDeclImg.cc @@ -299,8 +299,8 @@ gsi::Class decl_ImageDataMapping ("lay", "ImageDataMapping", class ImageRef; -static void replace_image (lay::LayoutView *view, size_t id, ImageRef &new_obj); -static void erase_image (lay::LayoutView *view, size_t id); +static void replace_image_base (lay::LayoutViewBase *view, size_t id, ImageRef &new_obj); +static void erase_image_base (lay::LayoutViewBase *view, size_t id); /** * @brief An extension of the img::Object that provides "live" updates of the view @@ -321,7 +321,7 @@ public: // .. nothing yet .. } - ImageRef (const img::Object &other, lay::LayoutView *view) + ImageRef (const img::Object &other, lay::LayoutViewBase *view) : img::Object (other), mp_view (view), dm_update_view (this, &ImageRef::do_update_view) { // .. nothing yet .. @@ -365,7 +365,7 @@ public: void erase () { if (mp_view) { - erase_image (mp_view.get (), id ()); + erase_image_base (mp_view.get (), id ()); detach (); } } @@ -373,7 +373,7 @@ public: template ImageRef transformed (const T &t) const { - return ImageRef (img::Object::transformed (t), const_cast (mp_view.get ())); + return ImageRef (img::Object::transformed (t), const_cast (mp_view.get ())); } void set_view (lay::LayoutView *view) @@ -398,12 +398,12 @@ protected: void do_update_view () { if (mp_view) { - replace_image (mp_view.get (), id (), *this); + replace_image_base (mp_view.get (), id (), *this); } } private: - tl::weak_ptr mp_view; + tl::weak_ptr mp_view; tl::DeferredMethod dm_update_view; }; @@ -1114,7 +1114,7 @@ static void show_image (lay::LayoutView *view, size_t id, bool visible) } } -static void replace_image (lay::LayoutView *view, size_t id, ImageRef &new_obj) +void replace_image_base (lay::LayoutViewBase *view, size_t id, ImageRef &new_obj) { img::Service *img_service = view->get_plugin (); if (img_service) { @@ -1129,7 +1129,12 @@ static void replace_image (lay::LayoutView *view, size_t id, ImageRef &new_obj) } } -static void erase_image (lay::LayoutView *view, size_t id) +static void replace_image (lay::LayoutView *view, size_t id, ImageRef &new_obj) +{ + replace_image_base (view, id, new_obj); +} + +void erase_image_base (lay::LayoutViewBase *view, size_t id) { img::Service *img_service = view->get_plugin (); if (img_service) { @@ -1144,6 +1149,11 @@ static void erase_image (lay::LayoutView *view, size_t id) } } +static void erase_image (lay::LayoutView *view, size_t id) +{ + erase_image_base (view, id); +} + static void insert_image (lay::LayoutView *view, ImageRef &obj) { if (obj.is_valid ()) { diff --git a/src/img/img/imgPlugin.cc b/src/img/img/imgPlugin.cc index 74d710786..33b15b146 100644 --- a/src/img/img/imgPlugin.cc +++ b/src/img/img/imgPlugin.cc @@ -45,7 +45,7 @@ PluginDeclaration::get_menu_entries (std::vector &menu_entries) } lay::Plugin * -PluginDeclaration::create_plugin (db::Manager *manager, lay::Dispatcher *, lay::LayoutView *view) const +PluginDeclaration::create_plugin (db::Manager *manager, lay::Dispatcher *, lay::LayoutViewBase *view) const { return new img::Service (manager, view); } diff --git a/src/img/img/imgPlugin.h b/src/img/img/imgPlugin.h index 4dc9fa0bd..1575ceccb 100644 --- a/src/img/img/imgPlugin.h +++ b/src/img/img/imgPlugin.h @@ -36,7 +36,7 @@ class PluginDeclaration { public: virtual void get_menu_entries (std::vector &menu_entries) const; - virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *, lay::LayoutView *view) const; + virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *, lay::LayoutViewBase *view) const; virtual bool implements_editable (std::string &title) const; virtual void get_options (std::vector < std::pair > &options) const; }; diff --git a/src/img/img/imgService.cc b/src/img/img/imgService.cc index 627c03967..86c7cef71 100644 --- a/src/img/img/imgService.cc +++ b/src/img/img/imgService.cc @@ -402,7 +402,7 @@ View::render (const lay::Viewport &vp, lay::ViewObjectCanvas &canvas) // ------------------------------------------------------------- // img::Service implementation -Service::Service (db::Manager *manager, lay::LayoutView *view) +Service::Service (db::Manager *manager, lay::LayoutViewBase *view) : lay::BackgroundViewObject (view->view_object_widget ()), lay::Editable (view), lay::Plugin (view), diff --git a/src/img/img/imgService.h b/src/img/img/imgService.h index 65e7bfa70..167177727 100644 --- a/src/img/img/imgService.h +++ b/src/img/img/imgService.h @@ -203,7 +203,7 @@ public: typedef lay::AnnotationShapes::iterator obj_iterator; enum MoveMode { move_none, move_selected, move_landmark, move_l, move_r, move_t, move_b, move_lr, move_tr, move_ll, move_tl, move_all }; - Service (db::Manager *manager, lay::LayoutView *view); + Service (db::Manager *manager, lay::LayoutViewBase *view); ~Service (); @@ -432,7 +432,7 @@ public: /** * @brief Access to the view object */ - lay::LayoutView *view () const + lay::LayoutViewBase *view () const { return mp_view; } @@ -480,7 +480,7 @@ public: private: // The layout view that the image service is attached to - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; // The view objects representing the selection and the moved images in move mode std::vector m_selected_image_views; diff --git a/src/lay/lay/layClipDialog.cc b/src/lay/lay/layClipDialog.cc index e28d5589d..f644a8ce5 100644 --- a/src/lay/lay/layClipDialog.cc +++ b/src/lay/lay/layClipDialog.cc @@ -55,7 +55,7 @@ public: menu_entries.push_back (lay::menu_item ("clip_tool::show", "clip_tool:edit_mode", "edit_menu.utils_menu.end", tl::to_string (QObject::tr ("Clip Tool")))); } - virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutView *view) const + virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutViewBase *view) const { return new ClipDialog (root, view); } diff --git a/src/lay/lay/layFillDialog.cc b/src/lay/lay/layFillDialog.cc index 2cc2d500b..5969b677a 100644 --- a/src/lay/lay/layFillDialog.cc +++ b/src/lay/lay/layFillDialog.cc @@ -62,7 +62,7 @@ public: menu_entries.push_back (lay::menu_item ("fill_tool::show", "fill_tool:edit_mode", "edit_menu.utils_menu.end", tl::to_string (QObject::tr ("Fill Tool")))); } - virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutView *view) const + virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutViewBase *view) const { return new FillDialog (root, view); } diff --git a/src/lay/lay/laySearchReplacePlugin.cc b/src/lay/lay/laySearchReplacePlugin.cc index bc603736d..6c4be161b 100644 --- a/src/lay/lay/laySearchReplacePlugin.cc +++ b/src/lay/lay/laySearchReplacePlugin.cc @@ -63,7 +63,7 @@ public: menu_entries.push_back (lay::menu_item ("search_replace::show", "search_replace_viewer:edit:view_mode", "edit_menu.utils_group+", tl::to_string (QObject::tr ("Search")))); } - virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutView *view) const + virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutViewBase *view) const { return new SearchReplaceDialog (root, view); } diff --git a/src/laybasic/laybasic/gsiDeclLayMarker.cc b/src/laybasic/laybasic/gsiDeclLayMarker.cc index 5e23b71aa..9f5e58bd9 100644 --- a/src/laybasic/laybasic/gsiDeclLayMarker.cc +++ b/src/laybasic/laybasic/gsiDeclLayMarker.cc @@ -29,7 +29,7 @@ namespace gsi { static -lay::DMarker *create_marker (lay::LayoutView *view) +lay::DMarker *create_marker (lay::LayoutViewBase *view) { return new lay::DMarker (view); } diff --git a/src/laybasic/laybasic/gsiDeclLayPlugin.cc b/src/laybasic/laybasic/gsiDeclLayPlugin.cc index 9d8cf8e1c..530fd82d7 100644 --- a/src/laybasic/laybasic/gsiDeclLayPlugin.cc +++ b/src/laybasic/laybasic/gsiDeclLayPlugin.cc @@ -40,7 +40,7 @@ namespace gsi // since PluginBase object are only allowed to be created inside the create_plugin method // of the factory, this hack is a quick but dirty workaround. static bool s_in_create_plugin = false; -static lay::LayoutView *sp_view = 0; +static lay::LayoutViewBase *sp_view = 0; static lay::Dispatcher *sp_dispatcher = 0; class PluginBase @@ -393,7 +393,7 @@ public: } } - virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *root, lay::LayoutView *view) const + virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *root, lay::LayoutViewBase *view) const { if (f_create_plugin.can_issue ()) { return create_plugin_gsi (manager, root, view); @@ -402,7 +402,7 @@ public: } } - virtual gsi::PluginBase *create_plugin_gsi (db::Manager *manager, lay::Dispatcher *root, lay::LayoutView *view) const + virtual gsi::PluginBase *create_plugin_gsi (db::Manager *manager, lay::Dispatcher *root, lay::LayoutViewBase *view) const { // TODO: this is a hack. See notes above at s_in_create_plugin s_in_create_plugin = true; @@ -410,7 +410,7 @@ public: sp_dispatcher = root; gsi::PluginBase *ret = 0; try { - ret = f_create_plugin.issue (&PluginFactoryBase::create_plugin_gsi, manager, root, view); + ret = f_create_plugin.issue (&PluginFactoryBase::create_plugin_gsi, manager, root, view); s_in_create_plugin = false; sp_view = 0; sp_dispatcher = 0; diff --git a/src/laybasic/laybasic/layBrowseInstancesForm.cc b/src/laybasic/laybasic/layBrowseInstancesForm.cc index fb28e6b65..1d486a42e 100644 --- a/src/laybasic/laybasic/layBrowseInstancesForm.cc +++ b/src/laybasic/laybasic/layBrowseInstancesForm.cc @@ -79,7 +79,7 @@ public: menu_entries.push_back (lay::menu_item ("browse_instances::show", "browse_instances", "tools_menu.end", tl::to_string (QObject::tr ("Browse Instances")))); } - virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutView *view) const + virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutViewBase *view) const { return new BrowseInstancesForm (root, view); } @@ -289,7 +289,7 @@ private: // ------------------------------------------------------------ -BrowseInstancesForm::BrowseInstancesForm (lay::Dispatcher *root, lay::LayoutView *vw) +BrowseInstancesForm::BrowseInstancesForm (lay::Dispatcher *root, LayoutViewBase *vw) : lay::Browser (root, vw), Ui::BrowseInstancesForm (), m_cv_index (0), @@ -349,9 +349,12 @@ void BrowseInstancesForm::choose_cell_pressed () { BEGIN_PROTECTED - CellSelectionForm form (this, view (), "browse_cell", true /*simple mode*/); - if (form.exec ()) { - change_cell (form.selected_cellview ().cell_index (), form.selected_cellview_index ()); + lay::LayoutView *lv = dynamic_cast (view ()); + if (lv) { + CellSelectionForm form (this, lv, "browse_cell", true /*simple mode*/); + if (form.exec ()) { + change_cell (form.selected_cellview ().cell_index (), form.selected_cellview_index ()); + } } END_PROTECTED } @@ -522,18 +525,21 @@ struct BrowseInstancesCellInfo void BrowseInstancesForm::activated () { - view ()->save_view (m_display_state); + lay::LayoutView *lv = dynamic_cast (view ()); + tl_assert (lv != 0); + + lv->save_view (m_display_state); // if no cellviews are available, don't do anything - if (! view ()->cellviews ()) { + if (! lv->cellviews ()) { return; } // obtain active cellview index and cell index - int cv_index = view ()->active_cellview_index (); + int cv_index = lv->active_cellview_index (); lay::LayoutView::cell_path_type path; - view ()->current_cell_path (path); + lv->current_cell_path (path); // no cell to index if (path.empty ()) { diff --git a/src/laybasic/laybasic/layBrowseInstancesForm.h b/src/laybasic/laybasic/layBrowseInstancesForm.h index ae4d5e2b0..61bec73de 100644 --- a/src/laybasic/laybasic/layBrowseInstancesForm.h +++ b/src/laybasic/laybasic/layBrowseInstancesForm.h @@ -65,7 +65,7 @@ public: enum mode_type { ToCellView = 0, AnyTop, Parent }; enum window_type { DontChange = 0, FitCell, FitMarker, Center, CenterSize }; - BrowseInstancesForm (lay::Dispatcher *root, lay::LayoutView *view); + BrowseInstancesForm (lay::Dispatcher *root, lay::LayoutViewBase *view); ~BrowseInstancesForm (); bool eventFilter (QObject *watched, QEvent *event); diff --git a/src/laybasic/laybasic/layBrowseShapesForm.cc b/src/laybasic/laybasic/layBrowseShapesForm.cc index 08304872a..a31e6ff42 100644 --- a/src/laybasic/laybasic/layBrowseShapesForm.cc +++ b/src/laybasic/laybasic/layBrowseShapesForm.cc @@ -80,7 +80,7 @@ public: menu_entries.push_back (lay::menu_item ("browse_shapes::show", "browse_shapes", "tools_menu.end", tl::to_string (QObject::tr ("Browse Shapes")))); } - virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutView *view) const + virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutViewBase *view) const { return new BrowseShapesForm (root, view); } @@ -392,7 +392,7 @@ private: // ------------------------------------------------------------ -BrowseShapesForm::BrowseShapesForm (lay::Dispatcher *root, lay::LayoutView *vw) +BrowseShapesForm::BrowseShapesForm (lay::Dispatcher *root, LayoutViewBase *vw) : lay::Browser (root, vw), Ui::BrowseShapesForm (), m_cv_index (-1), @@ -660,9 +660,12 @@ BrowseShapesForm::cell_inst_changed (QTreeWidgetItem *, QTreeWidgetItem *) void BrowseShapesForm::activated () { - view ()->save_view (m_display_state); + lay::LayoutView *lv = dynamic_cast (view ()); + tl_assert (lv != 0); - std::vector sel_layers = view ()->selected_layers (); + lv->save_view (m_display_state); + + std::vector sel_layers = lv->selected_layers (); if (sel_layers.empty ()) { throw tl::Exception (tl::to_string (QObject::tr ("No layer selected"))); @@ -688,7 +691,7 @@ BrowseShapesForm::activated () } } else { m_cv_index = cv_index; - m_cellview = view ()->cellview (m_cv_index); + m_cellview = lv->cellview (m_cv_index); } } diff --git a/src/laybasic/laybasic/layBrowseShapesForm.h b/src/laybasic/laybasic/layBrowseShapesForm.h index d4c74afff..4ff63c739 100644 --- a/src/laybasic/laybasic/layBrowseShapesForm.h +++ b/src/laybasic/laybasic/layBrowseShapesForm.h @@ -64,7 +64,7 @@ public: enum mode_type { ToCellView = 0, AnyTop, Local }; enum window_type { DontChange = 0, FitCell, FitMarker, Center, CenterSize }; - BrowseShapesForm (lay::Dispatcher *root, lay::LayoutView *view); + BrowseShapesForm (lay::Dispatcher *root, LayoutViewBase *view); ~BrowseShapesForm (); bool eventFilter (QObject *watched, QEvent *event); diff --git a/src/laybasic/laybasic/layBrowser.cc b/src/laybasic/laybasic/layBrowser.cc index 8a9fcc241..07b2a9828 100644 --- a/src/laybasic/laybasic/layBrowser.cc +++ b/src/laybasic/laybasic/layBrowser.cc @@ -32,9 +32,9 @@ namespace lay { #if QT_VERSION >= 0x050000 -Browser::Browser (lay::Dispatcher *root, lay::LayoutView *view, const char *name, Qt::WindowFlags fl) +Browser::Browser (lay::Dispatcher *root, lay::LayoutViewBase *view, const char *name, Qt::WindowFlags fl) #else -Browser::Browser (lay::Dispatcher *root, lay::LayoutView *view, const char *name, Qt::WFlags fl) +Browser::Browser (lay::Dispatcher *root, lay::LayoutViewBase *view, const char *name, Qt::WFlags fl) #endif // TODO: clarify whether to keep the browsers as separate (potentially hidden) windows : QDialog (0 /*view*/, fl), diff --git a/src/laybasic/laybasic/layBrowser.h b/src/laybasic/laybasic/layBrowser.h index 31510fd5f..fcc490c53 100644 --- a/src/laybasic/laybasic/layBrowser.h +++ b/src/laybasic/laybasic/layBrowser.h @@ -47,9 +47,9 @@ public: * @brief Constructor */ #if QT_VERSION >= 0x050000 - Browser (lay::Dispatcher *root, lay::LayoutView *view, const char *name = "", Qt::WindowFlags fl = Qt::Window /*adds minimize button for example*/); + Browser (lay::Dispatcher *root, lay::LayoutViewBase *view, const char *name = "", Qt::WindowFlags fl = Qt::Window /*adds minimize button for example*/); #else - Browser (lay::Dispatcher *root, lay::LayoutView *view, const char *name = "", Qt::WFlags fl = Qt::Window /*adds minimize button for example*/); + Browser (lay::Dispatcher *root, lay::LayoutViewBase *view, const char *name = "", Qt::WFlags fl = Qt::Window /*adds minimize button for example*/); #endif /** @@ -93,7 +93,7 @@ public: /** * @brief Return the pointer to the layout view */ - lay::LayoutView *view () + lay::LayoutViewBase *view () { return mp_view; } @@ -132,7 +132,7 @@ public: private: bool m_active; - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; lay::Dispatcher *mp_root; void closeEvent (QCloseEvent *); diff --git a/src/laybasic/laybasic/layCellSelectionForm.cc b/src/laybasic/laybasic/layCellSelectionForm.cc index fd84934c0..0bd3ff519 100644 --- a/src/laybasic/laybasic/layCellSelectionForm.cc +++ b/src/laybasic/laybasic/layCellSelectionForm.cc @@ -49,7 +49,7 @@ static const std::string cfg_cell_selection_search_use_expressions ("cell-select // ------------------------------------------------------------ -CellSelectionForm::CellSelectionForm (QWidget *parent, lay::LayoutView *view, const char *name, bool simple_mode) +CellSelectionForm::CellSelectionForm (QWidget *parent, LayoutView *view, const char *name, bool simple_mode) : QDialog (parent), Ui::CellSelectionForm (), mp_view (view), m_current_cv (-1), diff --git a/src/laybasic/laybasic/layCellSelectionForm.h b/src/laybasic/laybasic/layCellSelectionForm.h index 3d6f8c42b..adc0a5cc7 100644 --- a/src/laybasic/laybasic/layCellSelectionForm.h +++ b/src/laybasic/laybasic/layCellSelectionForm.h @@ -49,7 +49,7 @@ class LAYBASIC_PUBLIC CellSelectionForm Q_OBJECT public: - CellSelectionForm (QWidget *parent, lay::LayoutView *view, const char *name, bool simple_mode = false); + CellSelectionForm (QWidget *parent, LayoutView *view, const char *name, bool simple_mode = false); /** * @brief Obtain the selected cellview's index (with changes) diff --git a/src/laybasic/laybasic/layCellView.cc b/src/laybasic/laybasic/layCellView.cc index 476b6867e..ee28b6cbc 100644 --- a/src/laybasic/laybasic/layCellView.cc +++ b/src/laybasic/laybasic/layCellView.cc @@ -674,7 +674,7 @@ CellViewRef::CellViewRef () // .. nothing yet .. } -CellViewRef::CellViewRef (lay::CellView *cv, lay::LayoutView *view) +CellViewRef::CellViewRef (lay::CellView *cv, lay::LayoutViewBase *view) : mp_cv (cv), mp_view (view) { // .. nothing yet .. @@ -706,7 +706,7 @@ CellViewRef::index () const } } -lay::LayoutView * +lay::LayoutViewBase * CellViewRef::view () { return mp_view.get (); diff --git a/src/laybasic/laybasic/layDispatcher.cc b/src/laybasic/laybasic/layDispatcher.cc index 809d25a56..740393388 100644 --- a/src/laybasic/laybasic/layDispatcher.cc +++ b/src/laybasic/laybasic/layDispatcher.cc @@ -46,21 +46,6 @@ Dispatcher::Dispatcher (Plugin *parent, bool standalone) } } -#if defined(HAVE_QT) -Dispatcher::Dispatcher (QWidget *menu_parent_widget, Plugin *parent, bool standalone) - : Plugin (parent, standalone), - mp_menu_parent_widget (menu_parent_widget), - mp_delegate (0) -{ - if (mp_menu_parent_widget) { - mp_menu.reset (new lay::AbstractMenu (this)); - } - if (! parent && ! ms_dispatcher_instance) { - ms_dispatcher_instance = this; - } -} -#endif - Dispatcher::Dispatcher (DispatcherDelegate *delegate, Plugin *parent, bool standalone) : Plugin (parent, standalone), #if defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layEditorOptionsFrame.cc b/src/laybasic/laybasic/layEditorOptionsFrame.cc index dd593f9e4..55607c77f 100644 --- a/src/laybasic/laybasic/layEditorOptionsFrame.cc +++ b/src/laybasic/laybasic/layEditorOptionsFrame.cc @@ -47,7 +47,7 @@ EditorOptionsFrame::~EditorOptionsFrame () } void -EditorOptionsFrame::populate (LayoutView *view) +EditorOptionsFrame::populate (LayoutViewBase *view) { std::vector prop_dialog_pages; for (tl::Registrar::iterator cls = tl::Registrar::begin (); cls != tl::Registrar::end (); ++cls) { diff --git a/src/laybasic/laybasic/layEditorOptionsFrame.h b/src/laybasic/laybasic/layEditorOptionsFrame.h index 6ccadf986..0922be2ee 100644 --- a/src/laybasic/laybasic/layEditorOptionsFrame.h +++ b/src/laybasic/laybasic/layEditorOptionsFrame.h @@ -30,7 +30,7 @@ namespace lay { class EditorOptionsPages; -class LayoutView; +class LayoutViewBase; class LAYBASIC_PUBLIC EditorOptionsFrame : public QFrame @@ -39,7 +39,7 @@ public: EditorOptionsFrame (QWidget *parent); virtual ~EditorOptionsFrame (); - void populate (LayoutView *view); + void populate (lay::LayoutViewBase *view); EditorOptionsPages *pages_widget () const { diff --git a/src/laybasic/laybasic/layEditorServiceBase.cc b/src/laybasic/laybasic/layEditorServiceBase.cc index 7dbc0fad1..2e887fa5b 100644 --- a/src/laybasic/laybasic/layEditorServiceBase.cc +++ b/src/laybasic/laybasic/layEditorServiceBase.cc @@ -202,7 +202,7 @@ private: // -------------------------------------------------------------------------------------- -EditorServiceBase::EditorServiceBase (lay::LayoutView *view) +EditorServiceBase::EditorServiceBase (LayoutViewBase *view) : lay::ViewService (view->view_object_widget ()), lay::Editable (view), lay::Plugin (view), diff --git a/src/laybasic/laybasic/layEditorServiceBase.h b/src/laybasic/laybasic/layEditorServiceBase.h index 276f1a66a..7316eeba6 100644 --- a/src/laybasic/laybasic/layEditorServiceBase.h +++ b/src/laybasic/laybasic/layEditorServiceBase.h @@ -46,7 +46,7 @@ public: /** * @brief Constructor */ - EditorServiceBase (lay::LayoutView *view); + EditorServiceBase (lay::LayoutViewBase *view); /** * @brief Destructor diff --git a/src/laybasic/laybasic/layFinder.cc b/src/laybasic/laybasic/layFinder.cc index 7fa2d4589..7bd3dac16 100644 --- a/src/laybasic/laybasic/layFinder.cc +++ b/src/laybasic/laybasic/layFinder.cc @@ -86,7 +86,7 @@ Finder::closer (double d) } void -Finder::start (lay::LayoutView *view, const lay::CellView &cv, unsigned int cv_index, const std::vector &trans, const db::Box ®ion, int min_level, int max_level, const std::vector &layers) +Finder::start (lay::LayoutViewBase *view, const lay::CellView &cv, unsigned int cv_index, const std::vector &trans, const db::Box ®ion, int min_level, int max_level, const std::vector &layers) { m_layers = layers; m_region = region; @@ -265,7 +265,7 @@ struct LPContextCompareOp }; bool -ShapeFinder::find (lay::LayoutView *view, const db::DBox ®ion_mu) +ShapeFinder::find (LayoutViewBase *view, const db::DBox ®ion_mu) { tl::AbsoluteProgress progress (tl::to_string (QObject::tr ("Selecting ..."))); progress.set_unit (1000); @@ -330,7 +330,7 @@ ShapeFinder::find (lay::LayoutView *view, const db::DBox ®ion_mu) } bool -ShapeFinder::find (lay::LayoutView *view, const lay::LayerProperties &lprops, const db::DBox ®ion_mu) +ShapeFinder::find (lay::LayoutViewBase *view, const lay::LayerProperties &lprops, const db::DBox ®ion_mu) { tl::AbsoluteProgress progress (tl::to_string (QObject::tr ("Selecting ..."))); progress.set_unit (1000); @@ -349,7 +349,7 @@ ShapeFinder::find (lay::LayoutView *view, const lay::LayerProperties &lprops, co } bool -ShapeFinder::find_internal (lay::LayoutView *view, unsigned int cv_index, const std::set *prop_sel, bool inv_prop_sel, const lay::HierarchyLevelSelection &hier_sel, const std::vector &trans_mu, const std::vector &layers, const db::DBox ®ion_mu) +ShapeFinder::find_internal (lay::LayoutViewBase *view, unsigned int cv_index, const std::set *prop_sel, bool inv_prop_sel, const lay::HierarchyLevelSelection &hier_sel, const std::vector &trans_mu, const std::vector &layers, const db::DBox ®ion_mu) { m_cv_index = cv_index; @@ -624,7 +624,7 @@ InstFinder::InstFinder (bool point_mode, bool top_level_sel, bool full_arrays, b } bool -InstFinder::find (lay::LayoutView *view, const db::DBox ®ion_mu) +InstFinder::find (lay::LayoutViewBase *view, const db::DBox ®ion_mu) { tl::AbsoluteProgress progress (tl::to_string (QObject::tr ("Selecting ..."))); progress.set_unit (1000); @@ -641,7 +641,7 @@ InstFinder::find (lay::LayoutView *view, const db::DBox ®ion_mu) } bool -InstFinder::find (lay::LayoutView *view, unsigned int cv_index, const db::DCplxTrans &trans_mu, const db::DBox ®ion_mu) +InstFinder::find (LayoutViewBase *view, unsigned int cv_index, const db::DCplxTrans &trans_mu, const db::DBox ®ion_mu) { tl::AbsoluteProgress progress (tl::to_string (QObject::tr ("Selecting ..."))); progress.set_unit (1000); @@ -655,7 +655,7 @@ InstFinder::find (lay::LayoutView *view, unsigned int cv_index, const db::DCplxT } bool -InstFinder::find_internal (lay::LayoutView *view, unsigned int cv_index, const db::DCplxTrans &trans_mu, const db::DBox ®ion_mu) +InstFinder::find_internal (LayoutViewBase *view, unsigned int cv_index, const db::DCplxTrans &trans_mu, const db::DBox ®ion_mu) { const lay::CellView &cv = view->cellview (cv_index); if (! cv.is_valid ()) { diff --git a/src/laybasic/laybasic/layFinder.h b/src/laybasic/laybasic/layFinder.h index 166842421..f411872b6 100644 --- a/src/laybasic/laybasic/layFinder.h +++ b/src/laybasic/laybasic/layFinder.h @@ -136,7 +136,7 @@ protected: return m_max_level; } - lay::LayoutView *view () const + lay::LayoutViewBase *view () const { return mp_view; } @@ -153,7 +153,7 @@ protected: * path of instantiations up to the top cell is maintained and accessible by * the path() accessor. */ - void start (lay::LayoutView *view, const lay::CellView &cv, unsigned int cv_index, const std::vector &trans, const db::Box ®ion, int min_level, int max_level, const std::vector &layers = std::vector ()); + void start (LayoutViewBase *view, const lay::CellView &cv, unsigned int cv_index, const std::vector &trans, const db::Box ®ion, int min_level, int max_level, const std::vector &layers = std::vector ()); /** * @brief Provide a basic edge test facility @@ -186,7 +186,7 @@ private: int m_min_level, m_max_level; std::vector m_path; const db::Layout *mp_layout; - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; unsigned int m_cv_index; db::Box m_region; std::vector m_layers; @@ -214,8 +214,8 @@ public: ShapeFinder (bool point_mode, bool top_level_sel, db::ShapeIterator::flags_type flags, const std::set *excludes = 0); - bool find (lay::LayoutView *view, const lay::LayerProperties &lprops, const db::DBox ®ion_mu); - bool find (lay::LayoutView *view, const db::DBox ®ion_mu); + bool find (LayoutViewBase *view, const lay::LayerProperties &lprops, const db::DBox ®ion_mu); + bool find (LayoutViewBase *view, const db::DBox ®ion_mu); iterator begin () const { @@ -262,13 +262,13 @@ protected: private: virtual void visit_cell (const db::Cell &cell, const db::Box &search_box, const db::ICplxTrans &t, int /*level*/); - bool find_internal (lay::LayoutView *view, - unsigned int cv_index, - const std::set *prop_sel, - bool inv_prop_sel, + bool find_internal (LayoutViewBase *view, + unsigned int cv_index, + const std::set *prop_sel, + bool inv_prop_sel, const lay::HierarchyLevelSelection &hier_sel, const std::vector &trans_mu, - const std::vector &layers, + const std::vector &layers, const db::DBox ®ion_mu); const std::set *mp_excludes; @@ -300,8 +300,8 @@ public: InstFinder (bool point_mode, bool top_level_sel, bool full_arrays, bool enclose_inst = true, const std::set *excludes = 0, bool visible_layers = false); - bool find (lay::LayoutView *view, unsigned int cv_index, const db::DCplxTrans &trans, const db::DBox ®ion_mu); - bool find (lay::LayoutView *view, const db::DBox ®ion_mu); + bool find (LayoutViewBase *view, unsigned int cv_index, const db::DCplxTrans &trans, const db::DBox ®ion_mu); + bool find (LayoutViewBase *view, const db::DBox ®ion_mu); iterator begin () const { @@ -315,7 +315,7 @@ public: private: virtual void visit_cell (const db::Cell &cell, const db::Box &search_box, const db::ICplxTrans &t, int level); - bool find_internal (lay::LayoutView *view, unsigned int cv_index, const db::DCplxTrans &trans_mu, const db::DBox ®ion_mu); + bool find_internal (LayoutViewBase *view, unsigned int cv_index, const db::DCplxTrans &trans_mu, const db::DBox ®ion_mu); unsigned int m_cv_index; db::cell_index_type m_topcell; @@ -326,7 +326,7 @@ private: bool m_enclose_insts; bool m_visible_layers; std::vector m_visible_layer_indexes; - lay::LayoutView *mp_view; + LayoutViewBase *mp_view; tl::AbsoluteProgress *mp_progress; }; diff --git a/src/laybasic/laybasic/layGridNet.cc b/src/laybasic/laybasic/layGridNet.cc index 31f0dca4f..f7f205ad1 100644 --- a/src/laybasic/laybasic/layGridNet.cc +++ b/src/laybasic/laybasic/layGridNet.cc @@ -105,7 +105,7 @@ GridNetPluginDeclaration::config_page (QWidget *parent, std::string &title) cons } lay::Plugin * -GridNetPluginDeclaration::create_plugin (db::Manager *, Dispatcher *, lay::LayoutView *view) const +GridNetPluginDeclaration::create_plugin (db::Manager *, Dispatcher *, lay::LayoutViewBase *view) const { return new lay::GridNet (view); } @@ -192,7 +192,7 @@ GridNetConfigPage::commit (lay::Dispatcher *root) // ------------------------------------------------------------ // Implementation of the GridNet object -GridNet::GridNet (lay::LayoutView *view) +GridNet::GridNet (LayoutViewBase *view) : lay::BackgroundViewObject (view->view_object_widget ()), lay::Plugin (view), mp_view (view), diff --git a/src/laybasic/laybasic/layGridNet.h b/src/laybasic/laybasic/layGridNet.h index 98063d9bd..0a7ab5d95 100644 --- a/src/laybasic/laybasic/layGridNet.h +++ b/src/laybasic/laybasic/layGridNet.h @@ -45,7 +45,7 @@ class GridNetPluginDeclaration public: virtual void get_options (std::vector < std::pair > &options) const; virtual lay::ConfigPage *config_page (QWidget *parent, std::string &title) const; - virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *, lay::LayoutView *view) const; + virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *, lay::LayoutViewBase *view) const; }; class GridNetConfigPage @@ -83,7 +83,7 @@ public: CheckerBoard }; - GridNet (lay::LayoutView *view); + GridNet (lay::LayoutViewBase *view); private: virtual void render_bg (const lay::Viewport &vp, lay::ViewObjectCanvas &canvas); @@ -91,7 +91,7 @@ private: // implementation of the lay::Plugin interface virtual bool configure (const std::string &name, const std::string &value); - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; bool m_visible; bool m_show_ruler; double m_grid; diff --git a/src/laybasic/laybasic/layLayerTreeModel.cc b/src/laybasic/laybasic/layLayerTreeModel.cc index 5a3c09eea..d52ace764 100644 --- a/src/laybasic/laybasic/layLayerTreeModel.cc +++ b/src/laybasic/laybasic/layLayerTreeModel.cc @@ -631,7 +631,7 @@ LayerTreeModel::empty_within_view_predicate (const QModelIndex &index) const LAYBASIC_PUBLIC QIcon -LayerTreeModel::icon_for_layer (const lay::LayerPropertiesConstIterator &iter, lay::LayoutView *view, unsigned int w, unsigned int h, unsigned int di_off, bool no_state) +LayerTreeModel::icon_for_layer (const lay::LayerPropertiesConstIterator &iter, lay::LayoutViewBase *view, unsigned int w, unsigned int h, unsigned int di_off, bool no_state) { h = std::max ((unsigned int) 16, h); w = std::max ((unsigned int) 16, w); diff --git a/src/laybasic/laybasic/layLayerTreeModel.h b/src/laybasic/laybasic/layLayerTreeModel.h index 8273526f7..7da95e367 100644 --- a/src/laybasic/laybasic/layLayerTreeModel.h +++ b/src/laybasic/laybasic/layLayerTreeModel.h @@ -48,6 +48,7 @@ namespace lay { class LayoutView; +class LayoutViewBase; class LayerPropertiesConstIterator; /** @@ -108,7 +109,7 @@ public: /** * @brief Provides an icon for a given layer style */ - static QIcon icon_for_layer (const lay::LayerPropertiesConstIterator &iter, lay::LayoutView *view, unsigned int w, unsigned int h, unsigned int di_offset, bool no_state = false); + static QIcon icon_for_layer (const lay::LayerPropertiesConstIterator &iter, lay::LayoutViewBase *view, unsigned int w, unsigned int h, unsigned int di_offset, bool no_state = false); /** * @brief Gets the preferred icon size diff --git a/src/laybasic/laybasic/layLayoutCanvas.cc b/src/laybasic/laybasic/layLayoutCanvas.cc index 99a6200dd..6e60f4a2f 100644 --- a/src/laybasic/laybasic/layLayoutCanvas.cc +++ b/src/laybasic/laybasic/layLayoutCanvas.cc @@ -274,7 +274,7 @@ invert (unsigned char *data, unsigned int width, unsigned int height) } } -LayoutCanvas::LayoutCanvas (QWidget *parent, lay::LayoutView *view, const char *name) +LayoutCanvas::LayoutCanvas (QWidget *parent, lay::LayoutViewBase *view, const char *name) : lay::ViewObjectWidget (parent, name), mp_view (view), mp_image (0), mp_image_bg (0), mp_pixmap (0), diff --git a/src/laybasic/laybasic/layLayoutView.cc b/src/laybasic/laybasic/layLayoutView.cc index 70de70c82..47e531863 100644 --- a/src/laybasic/laybasic/layLayoutView.cc +++ b/src/laybasic/laybasic/layLayoutView.cc @@ -689,6 +689,7 @@ LayoutView::ensure_layer_selected () void LayoutView::remove_unused_layers () { + // @@@ should not be in control panel if (mp_control_panel) { mp_control_panel->cm_remove_unused (); } @@ -702,6 +703,18 @@ LayoutView::begin_layer_updates () } } +bool +LayoutView::layer_model_updated () +{ + // because check_updated is called in the initialization phase, we check if the pointers + // to the widgets are non-null: + if (mp_control_panel) { + return mp_control_panel->model_updated (); + } else { + return false; + } +} + void LayoutView::bookmark_current_view () { diff --git a/src/laybasic/laybasic/layLayoutView.h b/src/laybasic/laybasic/layLayoutView.h index 707754d4d..69af08d9d 100644 --- a/src/laybasic/laybasic/layLayoutView.h +++ b/src/laybasic/laybasic/layLayoutView.h @@ -322,10 +322,20 @@ public: */ void remove_unused_layers (); + /** + * @brief Internal method: check, if the layer tree is and an consistent state. + * + * This method is used by the layer tree model to check, if the tree has been brought into + * a consistent state. + * HINT: for the layout this is solved more consistently with the "under construction" attribute + * of the layout. There is no equivalent object for the layer tree currently. + */ + bool layer_model_updated (); + /** * @brief Returns true, if the layer source shall be shown always in the layer properties tree */ - bool always_show_source () const + virtual bool always_show_source () const { return m_always_show_source; } @@ -333,7 +343,7 @@ public: /** * @brief Returns true, if the layer/datatype shall be shown always in the layer properties tree */ - bool always_show_ld () const + virtual bool always_show_ld () const { return m_always_show_ld; } @@ -341,7 +351,7 @@ public: /** * @brief Returns true, if the layout index shall be shown always in the layer properties tree */ - bool always_show_layout_index () const + virtual bool always_show_layout_index () const { return m_always_show_layout_index; } @@ -389,6 +399,11 @@ public: */ void open_l2ndb_browser (int l2ndb_index, int cv_index); + /** + * @brief Gets the editor options pages + */ + lay::EditorOptionsPages *editor_options_pages (); + /** * @brief Gets the container with the layer control panel */ @@ -763,7 +778,6 @@ private: void init_ui (); void init_menu (); - lay::EditorOptionsPages *editor_options_pages (); void do_setup_editor_options_pages (); protected: diff --git a/src/laybasic/laybasic/layLayoutViewBase.cc b/src/laybasic/laybasic/layLayoutViewBase.cc index 7323a86ac..84ecfad9e 100644 --- a/src/laybasic/laybasic/layLayoutViewBase.cc +++ b/src/laybasic/laybasic/layLayoutViewBase.cc @@ -613,6 +613,12 @@ LayoutViewBase::set_synchronous (bool s) m_synchronous = s; } +void +LayoutViewBase::message (const std::string & /*s*/, int /*timeout*/) +{ + // .. nothing yet .. +} + bool LayoutViewBase::is_dirty () const { @@ -1401,6 +1407,24 @@ LayoutViewBase::merge_dither_pattern (lay::LayerPropertiesList &props) } } +bool +LayoutViewBase::always_show_source () const +{ + return false; +} + +bool +LayoutViewBase::always_show_ld () const +{ + return true; +} + +bool +LayoutViewBase::always_show_layout_index () const +{ + return false; +} + void LayoutViewBase::set_properties (unsigned int index, const LayerPropertiesList &props) { diff --git a/src/laybasic/laybasic/layLayoutViewBase.h b/src/laybasic/laybasic/layLayoutViewBase.h index 55fd70dd8..781b534d2 100644 --- a/src/laybasic/laybasic/layLayoutViewBase.h +++ b/src/laybasic/laybasic/layLayoutViewBase.h @@ -243,6 +243,11 @@ public: return m_title; } + /** + * @brief Display a status message + */ + void message (const std::string &s = "", int timeout = 10); + /** * @brief The "dirty" flag indicates that one of the layout has been modified * @@ -250,6 +255,21 @@ public: */ bool is_dirty () const; + /** + * @brief Returns true, if the layer source shall be shown always in the layer properties tree + */ + virtual bool always_show_source () const; + + /** + * @brief Returns true, if the layer/datatype shall be shown always in the layer properties tree + */ + virtual bool always_show_ld () const; + + /** + * @brief Returns true, if the layout index shall be shown always in the layer properties tree + */ + virtual bool always_show_layout_index () const; + /** * @brief Fill the layer properties for a new layer * @@ -402,6 +422,11 @@ public: return get_properties (index).end_const_recursive (); } + /** + * @brief Rename a layer properties list + */ + void rename_properties (unsigned int index, const std::string &new_name); + /** * @brief Replace the current layer properties list */ @@ -410,11 +435,6 @@ public: set_properties (current_layer_list (), list); } - /** - * @brief Rename a layer properties list - */ - void rename_properties (unsigned int index, const std::string &new_name); - /** * @brief Replace the specified layer properties list */ @@ -2314,6 +2334,12 @@ public: void redraw_cell_boxes (); void timer (); + virtual void deactivate_all_browsers (); + +#if defined(HAVE_QT) + virtual QWidget *widget () { return 0; } +#endif + private: // event handlers used to connect to the layout object's events void signal_hier_changed (); @@ -2505,7 +2531,6 @@ protected: virtual void do_set_current_layer (const lay::LayerPropertiesConstIterator &l); virtual void do_set_no_stipples (bool no_stipples); virtual void do_set_phase (int phase); - virtual void deactivate_all_browsers (); virtual bool is_activated () const; virtual void update_content_for_cv (int cv_index); virtual void set_active_cellview_index (int index); @@ -2517,10 +2542,6 @@ protected: virtual void emit_title_changed () { } virtual void emit_dirty_changed () { } virtual void emit_layer_order_changed () { } - -#if defined(HAVE_QT) - virtual QWidget *widget () { return 0; } -#endif }; } diff --git a/src/laybasic/laybasic/layLayoutViewFunctions.cc b/src/laybasic/laybasic/layLayoutViewFunctions.cc index ba769f0d6..65188d4de 100644 --- a/src/laybasic/laybasic/layLayoutViewFunctions.cc +++ b/src/laybasic/laybasic/layLayoutViewFunctions.cc @@ -77,8 +77,8 @@ validate_cell_path (const db::Layout &layout, lay::LayoutView::cell_path_type &p return false; } -LayoutViewFunctions::LayoutViewFunctions (db::Manager *manager, LayoutView *view) - : lay::Plugin (view), mp_view (view), mp_manager (manager) +LayoutViewFunctions::LayoutViewFunctions (db::Manager *manager, LayoutViewBase *view) + : lay::Plugin (view), mp_view (dynamic_cast (view)), mp_manager (manager) { m_del_cell_mode = 0; m_move_to_origin_mode_x = 0; @@ -104,6 +104,10 @@ LayoutViewFunctions::~LayoutViewFunctions () void LayoutViewFunctions::menu_activated (const std::string &symbol) { + if (! view ()) { + return; + } + if (symbol == "cm_show_properties") { view ()->show_properties (view ()); @@ -2240,7 +2244,7 @@ public: } } - lay::Plugin *create_plugin (db::Manager *manager, Dispatcher *, LayoutView *view) const + lay::Plugin *create_plugin (db::Manager *manager, Dispatcher *, LayoutViewBase *view) const { return new LayoutViewFunctions (manager, view); } diff --git a/src/laybasic/laybasic/layLayoutViewFunctions.h b/src/laybasic/laybasic/layLayoutViewFunctions.h index 37fdeb676..6661a4753 100644 --- a/src/laybasic/laybasic/layLayoutViewFunctions.h +++ b/src/laybasic/laybasic/layLayoutViewFunctions.h @@ -46,7 +46,7 @@ public: /** * @brief Constructor */ - LayoutViewFunctions (db::Manager *manager, lay::LayoutView *view); + LayoutViewFunctions (db::Manager *manager, lay::LayoutViewBase *view); /** * @brief Destructor diff --git a/src/laybasic/laybasic/layMarker.cc b/src/laybasic/laybasic/layMarker.cc index 8e1f7ab7d..959f3601a 100644 --- a/src/laybasic/laybasic/layMarker.cc +++ b/src/laybasic/laybasic/layMarker.cc @@ -188,7 +188,7 @@ void render_cell_inst (const db::Layout &layout, const db::CellInstArray &inst, // ------------------------------------------------------------------------ -MarkerBase::MarkerBase (lay::LayoutView *view) +MarkerBase::MarkerBase (lay::LayoutViewBase *view) : lay::ViewObject (view->view_object_widget ()), m_line_width (-1), m_vertex_size (-1), m_halo (-1), m_text_enabled (true), m_vertex_shape (lay::ViewOp::Rect), m_line_style (-1), m_dither_pattern (-1), m_frame_pattern (0), mp_view (view) { @@ -372,7 +372,7 @@ MarkerBase::get_bitmaps (const Viewport & /*vp*/, ViewObjectCanvas &canvas, lay: // ------------------------------------------------------------------------ -GenericMarkerBase::GenericMarkerBase (lay::LayoutView *view, unsigned int cv_index) +GenericMarkerBase::GenericMarkerBase (lay::LayoutViewBase *view, unsigned int cv_index) : MarkerBase (view), mp_trans_vector (0), mp_view (view), m_cv_index (cv_index) { // .. nothing yet .. @@ -496,7 +496,7 @@ GenericMarkerBase::dbu () const // ------------------------------------------------------------------------ -InstanceMarker::InstanceMarker (lay::LayoutView *view, unsigned int cv_index, bool draw_outline, size_t max_shapes) +InstanceMarker::InstanceMarker (LayoutViewBase *view, unsigned int cv_index, bool draw_outline, size_t max_shapes) : GenericMarkerBase (view, cv_index), m_draw_outline (draw_outline), m_max_shapes (max_shapes), m_inst () { // .. nothing yet .. @@ -576,7 +576,7 @@ InstanceMarker::item_bbox () const // ------------------------------------------------------------------------ -ShapeMarker::ShapeMarker (lay::LayoutView *view, unsigned int cv_index) +ShapeMarker::ShapeMarker (LayoutViewBase *view, unsigned int cv_index) : GenericMarkerBase (view, cv_index), m_shape () { // .. nothing yet .. @@ -643,7 +643,7 @@ ShapeMarker::item_bbox () const // ------------------------------------------------------------------------ -Marker::Marker (lay::LayoutView *view, unsigned int cv_index, bool draw_outline, size_t max_shapes) +Marker::Marker (lay::LayoutViewBase *view, unsigned int cv_index, bool draw_outline, size_t max_shapes) : GenericMarkerBase (view, cv_index), m_draw_outline (draw_outline), m_max_shapes (max_shapes) { m_type = None; @@ -1135,7 +1135,7 @@ Marker::render (const Viewport &vp, ViewObjectCanvas &canvas) // ------------------------------------------------------------------------ -DMarker::DMarker (lay::LayoutView *view) +DMarker::DMarker (LayoutViewBase *view) : MarkerBase (view), mp_view (view) { m_type = None; diff --git a/src/laybasic/laybasic/layMarker.h b/src/laybasic/laybasic/layMarker.h index 7b18deab6..2cc4a4133 100644 --- a/src/laybasic/laybasic/layMarker.h +++ b/src/laybasic/laybasic/layMarker.h @@ -44,7 +44,7 @@ namespace lay { -class LayoutView; +class LayoutViewBase; /** * @brief The marker base class @@ -59,7 +59,7 @@ public: /** * @brief The constructor */ - MarkerBase (lay::LayoutView *view); + MarkerBase (lay::LayoutViewBase *view); /** * @brief Get the color by which the marker is drawn @@ -232,7 +232,7 @@ protected: bool m_text_enabled; lay::ViewOp::Shape m_vertex_shape; int m_line_style, m_dither_pattern, m_frame_pattern; - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; }; /** @@ -252,7 +252,7 @@ public: /** * @brief The constructor */ - GenericMarkerBase (lay::LayoutView *view, unsigned int cv_index); + GenericMarkerBase (lay::LayoutViewBase *view, unsigned int cv_index); /** * @brief The destructor @@ -321,7 +321,7 @@ public: /** * @brief Gets the view object */ - lay::LayoutView *view () const + lay::LayoutViewBase *view () const { return mp_view; } @@ -344,7 +344,7 @@ public: private: db::CplxTrans m_trans; std::vector *mp_trans_vector; - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; unsigned int m_cv_index; /** @@ -367,7 +367,7 @@ public: /** * @brief The constructor */ - ShapeMarker (lay::LayoutView *view, unsigned int cv_index); + ShapeMarker (lay::LayoutViewBase *view, unsigned int cv_index); /** * @brief The destructor @@ -418,7 +418,7 @@ public: * @param draw_outline True to have instances drawing their outline * @param max_shapes The maximum number of shapes to draw for instances (just a box is drawn if more shapes are present) */ - InstanceMarker (lay::LayoutView *view, unsigned int cv_index, bool draw_outline = true, size_t max_shapes = 0); + InstanceMarker (lay::LayoutViewBase *view, unsigned int cv_index, bool draw_outline = true, size_t max_shapes = 0); /** * @brief The destructor @@ -508,7 +508,7 @@ public: * @param draw_outline True to have instances drawing their outline * @param max_shapes The maximum number of shapes to draw for instances (just a box is drawn if more shapes are present) */ - Marker (lay::LayoutView *view, unsigned int cv_index, bool draw_outline = true, size_t max_shapes = 0); + Marker (lay::LayoutViewBase *view, unsigned int cv_index, bool draw_outline = true, size_t max_shapes = 0); /** * @brief The destructor @@ -743,7 +743,7 @@ public: /** * @brief The constructor */ - DMarker (lay::LayoutView *view); + DMarker (lay::LayoutViewBase *view); /** * @brief The destructor @@ -806,7 +806,7 @@ private: void *any; } m_object; - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; }; } diff --git a/src/laybasic/laybasic/layMove.cc b/src/laybasic/laybasic/layMove.cc index 5347b8999..9e6102f39 100644 --- a/src/laybasic/laybasic/layMove.cc +++ b/src/laybasic/laybasic/layMove.cc @@ -34,9 +34,8 @@ namespace lay // ------------------------------------------------------------- // MoveService implementation -MoveService::MoveService (lay::LayoutView *view) - : QObject (), - lay::ViewService (view->view_object_widget ()), +MoveService::MoveService (lay::LayoutViewBase *view) + : lay::ViewService (view->view_object_widget ()), m_dragging (false), m_dragging_transient (false), mp_editables (view), diff --git a/src/laybasic/laybasic/layNetlistBrowser.cc b/src/laybasic/laybasic/layNetlistBrowser.cc index d43501a38..ab689cb92 100644 --- a/src/laybasic/laybasic/layNetlistBrowser.cc +++ b/src/laybasic/laybasic/layNetlistBrowser.cc @@ -376,7 +376,7 @@ public: menu_entries.push_back (lay::menu_item ("netlist_browser::show", "browse_netlists", "tools_menu.end", tl::to_string (QObject::tr ("Netlist Browser")))); } - virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutView *view) const + virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutViewBase *view) const { return new lay::NetlistBrowserDialog (root, view); } diff --git a/src/laybasic/laybasic/layNetlistBrowserDialog.cc b/src/laybasic/laybasic/layNetlistBrowserDialog.cc index 820ebdf32..b294befc6 100644 --- a/src/laybasic/laybasic/layNetlistBrowserDialog.cc +++ b/src/laybasic/laybasic/layNetlistBrowserDialog.cc @@ -56,7 +56,7 @@ extern const std::string cfg_l2ndb_max_shapes_highlighted; extern const std::string cfg_l2ndb_show_all; extern const std::string cfg_l2ndb_window_state; -NetlistBrowserDialog::NetlistBrowserDialog (lay::Dispatcher *root, lay::LayoutView *vw) +NetlistBrowserDialog::NetlistBrowserDialog (lay::Dispatcher *root, lay::LayoutViewBase *vw) : lay::Browser (root, vw), lay::ViewService (vw->view_object_widget ()), Ui::NetlistBrowserDialog (), @@ -729,19 +729,22 @@ NetlistBrowserDialog::cv_index_changed (int index) void NetlistBrowserDialog::activated () { + lay::LayoutView *lv = dynamic_cast (view ()); + tl_assert (lv != 0); + std::string state; - view ()->config_get (cfg_l2ndb_window_state, state); + lv->config_get (cfg_l2ndb_window_state, state); lay::restore_dialog_state (this, state, false /*don't adjust the section sizes*/); // Switch to the active cellview index when no valid one is set. - lay::CellView cv = view ()->cellview (m_cv_index); + lay::CellView cv = lv->cellview (m_cv_index); if (! cv.is_valid ()) { - m_cv_index = view ()->active_cellview_index (); + m_cv_index = lv->active_cellview_index (); } - if (m_l2n_index < 0 && view ()->get_l2ndb (0) != 0) { + if (m_l2n_index < 0 && lv->get_l2ndb (0) != 0) { - m_l2ndb_name = view ()->get_l2ndb (0)->name (); + m_l2ndb_name = lv->get_l2ndb (0)->name (); l2ndbs_changed (); } else { diff --git a/src/laybasic/laybasic/layNetlistBrowserDialog.h b/src/laybasic/laybasic/layNetlistBrowserDialog.h index ebebe1c14..d7ad87699 100644 --- a/src/laybasic/laybasic/layNetlistBrowserDialog.h +++ b/src/laybasic/laybasic/layNetlistBrowserDialog.h @@ -42,7 +42,7 @@ class NetlistBrowserDialog Q_OBJECT public: - NetlistBrowserDialog (lay::Dispatcher *root, lay::LayoutView *view); + NetlistBrowserDialog (lay::Dispatcher *root, lay::LayoutViewBase *view); ~NetlistBrowserDialog (); void load (int lay_index, int cv_index); diff --git a/src/laybasic/laybasic/layNetlistBrowserPage.cc b/src/laybasic/laybasic/layNetlistBrowserPage.cc index ef1fdc4f0..828be2771 100644 --- a/src/laybasic/laybasic/layNetlistBrowserPage.cc +++ b/src/laybasic/laybasic/layNetlistBrowserPage.cc @@ -242,7 +242,7 @@ NetlistBrowserPage::set_highlight_style (lay::Color color, int line_width, int v } void -NetlistBrowserPage::set_view (lay::LayoutView *view, int cv_index) +NetlistBrowserPage::set_view (lay::LayoutViewBase *view, int cv_index) { if (mp_view) { mp_view->layer_list_changed_event.remove (this, &NetlistBrowserPage::layer_list_changed); @@ -1424,7 +1424,7 @@ NetlistBrowserPage::export_nets (const std::vector *nets) if (dialog->exec_dialog (mp_plugin_root)) { // NOTE: mp_view and database might get reset to 0 in create_layout - lay::LayoutView *view = mp_view; + lay::LayoutViewBase *view = mp_view; db::LayoutToNetlist *database = mp_database.get (); unsigned int cv_index = view->create_layout (true); diff --git a/src/laybasic/laybasic/layNetlistBrowserPage.h b/src/laybasic/laybasic/layNetlistBrowserPage.h index d11f126e9..2d330b0d7 100644 --- a/src/laybasic/laybasic/layNetlistBrowserPage.h +++ b/src/laybasic/laybasic/layNetlistBrowserPage.h @@ -86,7 +86,7 @@ public: * If that pointer is non-null, the browser will attach itself to * the view and provide highlights for the selected markers inside the given cellview. */ - void set_view (lay::LayoutView *view, int cv_index); + void set_view (LayoutViewBase *view, int cv_index); /** * @brief Attaches the page to a L2N DB @@ -224,7 +224,7 @@ private: int m_marker_dither_pattern; int m_marker_intensity; bool m_use_original_colors; - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; unsigned int m_cv_index; lay::Dispatcher *mp_plugin_root; tl::weak_ptr mp_database; diff --git a/src/laybasic/laybasic/layRedrawThread.cc b/src/laybasic/laybasic/layRedrawThread.cc index b0902a379..25d1a24b3 100644 --- a/src/laybasic/laybasic/layRedrawThread.cc +++ b/src/laybasic/laybasic/layRedrawThread.cc @@ -39,7 +39,7 @@ namespace lay // ------------------------------------------------------------- // RedrawThread implementation -RedrawThread::RedrawThread (lay::RedrawThreadCanvas *canvas, lay::LayoutView *view) +RedrawThread::RedrawThread (lay::RedrawThreadCanvas *canvas, LayoutViewBase *view) : tl::Object () { m_initial_update = false; diff --git a/src/laybasic/laybasic/layRedrawThread.h b/src/laybasic/laybasic/layRedrawThread.h index 4658b8c85..47ac943e2 100644 --- a/src/laybasic/laybasic/layRedrawThread.h +++ b/src/laybasic/laybasic/layRedrawThread.h @@ -55,7 +55,7 @@ class RedrawThread public tl::JobBase { public: - RedrawThread (lay::RedrawThreadCanvas *canvas, lay::LayoutView *view); + RedrawThread (lay::RedrawThreadCanvas *canvas, lay::LayoutViewBase *view); virtual ~RedrawThread (); void commit (const std::vector &layers, const lay::Viewport &vp, double resolution); @@ -116,7 +116,7 @@ private: db::DFTrans m_stored_fp; lay::RedrawThreadCanvas *mp_canvas; - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; bool m_start_recursion_sentinel; tl::Clock m_clock; diff --git a/src/laybasic/laybasic/layRedrawThreadWorker.cc b/src/laybasic/laybasic/layRedrawThreadWorker.cc index b63e15b2a..661d61224 100644 --- a/src/laybasic/laybasic/layRedrawThreadWorker.cc +++ b/src/laybasic/laybasic/layRedrawThreadWorker.cc @@ -496,7 +496,7 @@ RedrawThreadWorker::finish () } void -RedrawThreadWorker::setup (LayoutView *view, RedrawThreadCanvas *canvas, const std::vector &redraw_region, const db::DCplxTrans &vp_trans) +RedrawThreadWorker::setup (LayoutViewBase *view, RedrawThreadCanvas *canvas, const std::vector &redraw_region, const db::DCplxTrans &vp_trans) { m_redraw_region = redraw_region; m_vp_trans = vp_trans; diff --git a/src/laybasic/laybasic/layRedrawThreadWorker.h b/src/laybasic/laybasic/layRedrawThreadWorker.h index 545772118..68cc2e264 100644 --- a/src/laybasic/laybasic/layRedrawThreadWorker.h +++ b/src/laybasic/laybasic/layRedrawThreadWorker.h @@ -168,7 +168,7 @@ public: RedrawThreadWorker (RedrawThread *redraw_thread); virtual ~RedrawThreadWorker (); - void setup (LayoutView *view, RedrawThreadCanvas *canvas, const std::vector &redraw_region, const db::DCplxTrans &vp_trans); + void setup (LayoutViewBase *view, RedrawThreadCanvas *canvas, const std::vector &redraw_region, const db::DCplxTrans &vp_trans); void finish (); protected: diff --git a/src/laybasic/laybasic/laySelector.cc b/src/laybasic/laybasic/laySelector.cc index e1dea2f3b..029b1cbe1 100644 --- a/src/laybasic/laybasic/laySelector.cc +++ b/src/laybasic/laybasic/laySelector.cc @@ -37,7 +37,7 @@ namespace lay // ------------------------------------------------------------- // SelectionService implementation -SelectionService::SelectionService (lay::LayoutView *view) +SelectionService::SelectionService (lay::LayoutViewBase *view) : QObject (), lay::ViewService (view->view_object_widget ()), mp_view (view), diff --git a/src/laybasic/laybasic/laySelector.h b/src/laybasic/laybasic/laySelector.h index f804b243e..ad81060b3 100644 --- a/src/laybasic/laybasic/laySelector.h +++ b/src/laybasic/laybasic/laySelector.h @@ -88,7 +88,7 @@ private: db::DPoint m_p1, m_p2; db::DPoint m_current_position; - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; lay::RubberBox *mp_box; unsigned int m_color; unsigned int m_buttons; diff --git a/src/laybasic/laybasic/laySnap.cc b/src/laybasic/laybasic/laySnap.cc index f7a92dca6..6c005d933 100644 --- a/src/laybasic/laybasic/laySnap.cc +++ b/src/laybasic/laybasic/laySnap.cc @@ -23,7 +23,7 @@ #include "laySnap.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "dbEdge.h" @@ -282,7 +282,7 @@ public: * This will run the finder on the given view. * "search_range" is the search range in micron units. */ - void find (lay::LayoutView *view, double search_range) + void find (lay::LayoutViewBase *view, double search_range) { if (! view) { return; @@ -586,7 +586,7 @@ private: } void - do_find (lay::LayoutView *view, int cv_index, const db::Cell &cell, unsigned int l, int min_level, int max_level, const db::CplxTrans &t) + do_find (lay::LayoutViewBase *view, int cv_index, const db::Cell &cell, unsigned int l, int min_level, int max_level, const db::CplxTrans &t) { db::Box touch_box = t.inverted () * m_region; @@ -727,7 +727,7 @@ private: }; static PointSnapToObjectResult -do_obj_snap (lay::LayoutView *view, const db::DPoint &pt, const db::DVector &grid, double snap_range, const std::vector &cutlines) +do_obj_snap (lay::LayoutViewBase *view, const db::DPoint &pt, const db::DVector &grid, double snap_range, const std::vector &cutlines) { db::DPoint dp (pt); @@ -792,7 +792,7 @@ do_obj_snap (lay::LayoutView *view, const db::DPoint &pt, const db::DVector &gri } static TwoPointSnapToObjectResult -do_obj_snap2 (lay::LayoutView *view, const db::DPoint &pt1, const db::DPoint &pt2, const db::DVector &grid, double min_search_range, double max_search_range, const std::vector &cutlines) +do_obj_snap2 (lay::LayoutViewBase *view, const db::DPoint &pt1, const db::DPoint &pt2, const db::DVector &grid, double min_search_range, double max_search_range, const std::vector &cutlines) { db::DPoint dp1 (pt1); db::DPoint dp2 (pt2); @@ -915,13 +915,13 @@ make_cutlines (lay::angle_constraint_type snap_mode, const db::DPoint &p1, std:: } PointSnapToObjectResult -obj_snap (lay::LayoutView *view, const db::DPoint &pt, const db::DVector &grid, double snap_range) +obj_snap (lay::LayoutViewBase *view, const db::DPoint &pt, const db::DVector &grid, double snap_range) { return do_obj_snap (view, pt, grid, snap_range, std::vector ()); } PointSnapToObjectResult -obj_snap (lay::LayoutView *view, const db::DPoint &p1, const db::DPoint &p2, const db::DVector &grid, lay::angle_constraint_type snap_mode, double snap_range) +obj_snap (lay::LayoutViewBase *view, const db::DPoint &p1, const db::DPoint &p2, const db::DVector &grid, lay::angle_constraint_type snap_mode, double snap_range) { std::vector cutlines; make_cutlines (snap_mode, p1, cutlines); @@ -929,19 +929,19 @@ obj_snap (lay::LayoutView *view, const db::DPoint &p1, const db::DPoint &p2, con } TwoPointSnapToObjectResult -obj_snap2 (lay::LayoutView *view, const db::DPoint &pt, const db::DVector &grid, double min_search_range, double max_search_range) +obj_snap2 (lay::LayoutViewBase *view, const db::DPoint &pt, const db::DVector &grid, double min_search_range, double max_search_range) { return obj_snap2 (view, pt, pt, grid, min_search_range, max_search_range); } TwoPointSnapToObjectResult -obj_snap2 (lay::LayoutView *view, const db::DPoint &pt, const db::DVector &grid, lay::angle_constraint_type ac, double min_search_range, double max_search_range) +obj_snap2 (lay::LayoutViewBase *view, const db::DPoint &pt, const db::DVector &grid, lay::angle_constraint_type ac, double min_search_range, double max_search_range) { return obj_snap2 (view, pt, pt, grid, ac, min_search_range, max_search_range); } TwoPointSnapToObjectResult -obj_snap2 (lay::LayoutView *view, const db::DPoint &pt1, const db::DPoint &pt2, const db::DVector &grid, double min_search_range, double max_search_range) +obj_snap2 (lay::LayoutViewBase *view, const db::DPoint &pt1, const db::DPoint &pt2, const db::DVector &grid, double min_search_range, double max_search_range) { db::DPoint dp1 = lay::snap_xy (pt1, grid); db::DPoint dp2 = lay::snap_xy (pt2, grid); @@ -950,7 +950,7 @@ obj_snap2 (lay::LayoutView *view, const db::DPoint &pt1, const db::DPoint &pt2, } TwoPointSnapToObjectResult -obj_snap2 (lay::LayoutView *view, const db::DPoint &pt1, const db::DPoint &pt2, const db::DVector &grid, lay::angle_constraint_type snap_mode, double min_search_range, double max_search_range) +obj_snap2 (lay::LayoutViewBase *view, const db::DPoint &pt1, const db::DPoint &pt2, const db::DVector &grid, lay::angle_constraint_type snap_mode, double min_search_range, double max_search_range) { db::DPoint dp1 = lay::snap_xy (pt1, grid); db::DPoint dp2 = lay::snap_xy (pt2, grid); diff --git a/src/laybasic/laybasic/laySnap.h b/src/laybasic/laybasic/laySnap.h index c05eabda3..776cb1acd 100644 --- a/src/laybasic/laybasic/laySnap.h +++ b/src/laybasic/laybasic/laySnap.h @@ -41,7 +41,7 @@ namespace lay { - class LayoutView; + class LayoutViewBase; /** * @brief An angle constraint type @@ -154,7 +154,7 @@ namespace lay * @param grid Either (0,0) to disable grid snapping or a (gx,gy) value for the (potentially anisotropic grid) * @param snap_range The search range for objects */ - LAYBASIC_PUBLIC PointSnapToObjectResult obj_snap (lay::LayoutView *view, const db::DPoint &pt, const db::DVector &grid, double snap_range); + LAYBASIC_PUBLIC PointSnapToObjectResult obj_snap (lay::LayoutViewBase *view, const db::DPoint &pt, const db::DVector &grid, double snap_range); /** * @brief combined grid-, projection- and object snapping provided to implementing "magnetic features" @@ -162,7 +162,7 @@ namespace lay * This is a convenience method that creates the projection axes from a reference point and an angle mode. * "pr" is the reference point, "pt" is the point to snap. */ - LAYBASIC_PUBLIC PointSnapToObjectResult obj_snap (lay::LayoutView *view, const db::DPoint &pr, const db::DPoint &pt, const db::DVector &grid, lay::angle_constraint_type ac, double snap_range); + LAYBASIC_PUBLIC PointSnapToObjectResult obj_snap (lay::LayoutViewBase *view, const db::DPoint &pr, const db::DPoint &pt, const db::DVector &grid, lay::angle_constraint_type ac, double snap_range); /** * @brief A structure describing the snap result for a two-sided object snap (distance measurement) @@ -208,7 +208,7 @@ namespace lay * This method basically implements "auto measure". The first value of the returned pair * is true if such an edge could be found. Otherwise it's false. */ - LAYBASIC_PUBLIC TwoPointSnapToObjectResult obj_snap2 (lay::LayoutView *view, const db::DPoint &pt, const db::DVector &grid, double min_search_range, double max_search_range); + LAYBASIC_PUBLIC TwoPointSnapToObjectResult obj_snap2 (lay::LayoutViewBase *view, const db::DPoint &pt, const db::DVector &grid, double min_search_range, double max_search_range); /** * @brief Same than obj_snap, but delivers two points on two opposite sides of the initial points @@ -218,14 +218,14 @@ namespace lay * * This version accepts two points defining different search regions for first and second edge. */ - LAYBASIC_PUBLIC TwoPointSnapToObjectResult obj_snap2 (lay::LayoutView *view, const db::DPoint &pt1, const db::DPoint &pt2, const db::DVector &grid, double min_search_range, double max_search_range); + LAYBASIC_PUBLIC TwoPointSnapToObjectResult obj_snap2 (lay::LayoutViewBase *view, const db::DPoint &pt1, const db::DPoint &pt2, const db::DVector &grid, double min_search_range, double max_search_range); /** * @brief Same than the previous obj_snap2, but allows specification of an angle constraint * * Measurements will be confined to the direction specified. */ - LAYBASIC_PUBLIC TwoPointSnapToObjectResult obj_snap2 (lay::LayoutView *view, const db::DPoint &pt, const db::DVector &grid, lay::angle_constraint_type ac, double min_search_range, double max_search_range); + LAYBASIC_PUBLIC TwoPointSnapToObjectResult obj_snap2 (lay::LayoutViewBase *view, const db::DPoint &pt, const db::DVector &grid, lay::angle_constraint_type ac, double min_search_range, double max_search_range); /** * @brief Same than the previous obj_snap2, but allows specification of an angle constraint @@ -234,7 +234,7 @@ namespace lay * * This version accepts two points defining different search regions for first and second edge. */ - LAYBASIC_PUBLIC TwoPointSnapToObjectResult obj_snap2 (lay::LayoutView *view, const db::DPoint &pt1, const db::DPoint &pt2, const db::DVector &grid, lay::angle_constraint_type ac, double min_search_range, double max_search_range); + LAYBASIC_PUBLIC TwoPointSnapToObjectResult obj_snap2 (lay::LayoutViewBase *view, const db::DPoint &pt1, const db::DPoint &pt2, const db::DVector &grid, lay::angle_constraint_type ac, double min_search_range, double max_search_range); /** * @brief Reduce a given vector according to the angle constraint diff --git a/src/laybasic/laybasic/layZoomBox.cc b/src/laybasic/laybasic/layZoomBox.cc index bef7e40f2..97f080aa5 100644 --- a/src/laybasic/laybasic/layZoomBox.cc +++ b/src/laybasic/laybasic/layZoomBox.cc @@ -31,7 +31,7 @@ namespace lay // ------------------------------------------------------------- // ZoomService implementation -ZoomService::ZoomService (lay::LayoutView *view) +ZoomService::ZoomService (lay::LayoutViewBase *view) : lay::ViewService (view->view_object_widget ()), mp_view (view), mp_box (0), diff --git a/src/laybasic/laybasic/rdbMarkerBrowser.cc b/src/laybasic/laybasic/rdbMarkerBrowser.cc index 2a7e9928a..6311b0f1b 100644 --- a/src/laybasic/laybasic/rdbMarkerBrowser.cc +++ b/src/laybasic/laybasic/rdbMarkerBrowser.cc @@ -302,7 +302,7 @@ public: menu_entries.push_back (lay::menu_item ("marker_browser::scan_layers_flat", "scan_layers_flat", "tools_menu.shapes_to_markers.end", tl::to_string (QObject::tr ("Flat")))); } - virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutView *view) const + virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutViewBase *view) const { return new rdb::MarkerBrowserDialog (root, view); } diff --git a/src/laybasic/laybasic/rdbMarkerBrowserDialog.cc b/src/laybasic/laybasic/rdbMarkerBrowserDialog.cc index c85b40024..a7caa9026 100644 --- a/src/laybasic/laybasic/rdbMarkerBrowserDialog.cc +++ b/src/laybasic/laybasic/rdbMarkerBrowserDialog.cc @@ -54,7 +54,7 @@ extern std::string cfg_rdb_marker_vertex_size; extern std::string cfg_rdb_marker_halo; extern std::string cfg_rdb_marker_dither_pattern; -MarkerBrowserDialog::MarkerBrowserDialog (lay::Dispatcher *root, lay::LayoutView *vw) +MarkerBrowserDialog::MarkerBrowserDialog (lay::Dispatcher *root, lay::LayoutViewBase *vw) : lay::Browser (root, vw), Ui::MarkerBrowserDialog (), m_context (rdb::AnyCell), @@ -635,19 +635,22 @@ MarkerBrowserDialog::cv_index_changed (int index) void MarkerBrowserDialog::activated () { + lay::LayoutView *lv = dynamic_cast (view ()); + tl_assert (lv != 0); + std::string state; - view ()->config_get (cfg_rdb_window_state, state); + lv->config_get (cfg_rdb_window_state, state); lay::restore_dialog_state (this, state); // Switch to the active cellview index when no valid one is set. - lay::CellView cv = view ()->cellview (m_cv_index); + lay::CellView cv = lv->cellview (m_cv_index); if (! cv.is_valid ()) { - m_cv_index = view ()->active_cellview_index (); + m_cv_index = lv->active_cellview_index (); } - if (m_rdb_index < 0 && view ()->get_rdb (0) != 0) { + if (m_rdb_index < 0 && lv->get_rdb (0) != 0) { - m_rdb_name = view ()->get_rdb (0)->name (); + m_rdb_name = lv->get_rdb (0)->name (); rdbs_changed (); } else { @@ -714,7 +717,10 @@ MarkerBrowserDialog::deactivated () void MarkerBrowserDialog::scan_layer () { - std::vector layers = view ()->selected_layers (); + lay::LayoutView *lv = dynamic_cast (view ()); + tl_assert (lv != 0); + + std::vector layers = lv->selected_layers (); if (layers.empty ()) { throw tl::Exception (tl::to_string (QObject::tr ("No layer selected to get shapes from"))); } @@ -806,13 +812,16 @@ MarkerBrowserDialog::scan_layer () } unsigned int rdb_index = view ()->add_rdb (rdb.release ()); - view ()->open_rdb_browser (rdb_index, cv_index); + lv->open_rdb_browser (rdb_index, cv_index); } void MarkerBrowserDialog::scan_layer_flat () { - std::vector layers = view ()->selected_layers (); + lay::LayoutView *lv = dynamic_cast (view ()); + tl_assert (lv != 0); + + std::vector layers = lv->selected_layers (); if (layers.empty ()) { throw tl::Exception (tl::to_string (QObject::tr ("No layer selected to get shapes from"))); } @@ -882,7 +891,7 @@ MarkerBrowserDialog::scan_layer_flat () } unsigned int rdb_index = view ()->add_rdb (rdb.release ()); - view ()->open_rdb_browser (rdb_index, cv_index); + lv->open_rdb_browser (rdb_index, cv_index); } void diff --git a/src/laybasic/laybasic/rdbMarkerBrowserDialog.h b/src/laybasic/laybasic/rdbMarkerBrowserDialog.h index 5e0bd782e..57836ca33 100644 --- a/src/laybasic/laybasic/rdbMarkerBrowserDialog.h +++ b/src/laybasic/laybasic/rdbMarkerBrowserDialog.h @@ -38,7 +38,7 @@ class MarkerBrowserDialog Q_OBJECT public: - MarkerBrowserDialog (lay::Dispatcher *root, lay::LayoutView *view); + MarkerBrowserDialog (lay::Dispatcher *root, lay::LayoutViewBase *view); ~MarkerBrowserDialog (); void load (int rdb_index, int cv_index); diff --git a/src/laybasic/laybasic/rdbMarkerBrowserPage.cc b/src/laybasic/laybasic/rdbMarkerBrowserPage.cc index df28158db..6560e3044 100644 --- a/src/laybasic/laybasic/rdbMarkerBrowserPage.cc +++ b/src/laybasic/laybasic/rdbMarkerBrowserPage.cc @@ -1620,7 +1620,7 @@ MarkerBrowserPage::set_marker_style (lay::Color color, int line_width, int verte } void -MarkerBrowserPage::set_view (lay::LayoutView *view, unsigned int cv_index) +MarkerBrowserPage::set_view (lay::LayoutViewBase *view, unsigned int cv_index) { mp_view = view; m_cv_index = cv_index; diff --git a/src/laybasic/laybasic/rdbMarkerBrowserPage.h b/src/laybasic/laybasic/rdbMarkerBrowserPage.h index f879884a6..6c7ab7820 100644 --- a/src/laybasic/laybasic/rdbMarkerBrowserPage.h +++ b/src/laybasic/laybasic/rdbMarkerBrowserPage.h @@ -78,7 +78,7 @@ public: * If that pointer is non-null, the browser will attach itself to * the view and provide highlights for the selected markers inside the given cellview. */ - void set_view (lay::LayoutView *view, unsigned int cv_index); + void set_view (lay::LayoutViewBase *view, unsigned int cv_index); /** * @brief Attach the page to a RDB @@ -184,7 +184,7 @@ private: rdb::Database *mp_database; bool m_show_all; QAction *m_show_all_action; - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; unsigned int m_cv_index; std::vector mp_markers; db::DBox m_markers_bbox; diff --git a/src/plugins/tools/bool/lay_plugin/layBooleanOperationsPlugin.cc b/src/plugins/tools/bool/lay_plugin/layBooleanOperationsPlugin.cc index 668f159e6..7202d66e1 100644 --- a/src/plugins/tools/bool/lay_plugin/layBooleanOperationsPlugin.cc +++ b/src/plugins/tools/bool/lay_plugin/layBooleanOperationsPlugin.cc @@ -494,7 +494,7 @@ public: // .. nothing yet .. } - lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutView *view) const + lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutViewBase *view) const { return new BooleanOperationsPlugin (root, view); } diff --git a/src/plugins/tools/diff/lay_plugin/layDiffPlugin.cc b/src/plugins/tools/diff/lay_plugin/layDiffPlugin.cc index 7cc1a6f52..7f207a1d2 100644 --- a/src/plugins/tools/diff/lay_plugin/layDiffPlugin.cc +++ b/src/plugins/tools/diff/lay_plugin/layDiffPlugin.cc @@ -102,7 +102,7 @@ public: // .. nothing yet .. } - lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutView *view) const + lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutViewBase *view) const { return new DiffPlugin (root, view); } diff --git a/src/plugins/tools/net_tracer/lay_plugin/layNetTracerPlugin.cc b/src/plugins/tools/net_tracer/lay_plugin/layNetTracerPlugin.cc index 9d7eb3d27..4382851b4 100644 --- a/src/plugins/tools/net_tracer/lay_plugin/layNetTracerPlugin.cc +++ b/src/plugins/tools/net_tracer/lay_plugin/layNetTracerPlugin.cc @@ -75,7 +75,7 @@ public: menu_entries.push_back (lay::menu_item ("lay::edit_layer_stack", "edit_layer_stack", "tools_menu.end", tl::to_string (QObject::tr ("Edit Layer Stack")))); } - virtual lay::Plugin *create_plugin (db::Manager * /*manager*/, lay::Dispatcher *root, lay::LayoutView *view) const + virtual lay::Plugin *create_plugin (db::Manager * /*manager*/, lay::Dispatcher *root, lay::LayoutViewBase *view) const { return new NetTracerDialog (root, view); } diff --git a/src/plugins/tools/view_25d/lay_plugin/layD25Plugin.cc b/src/plugins/tools/view_25d/lay_plugin/layD25Plugin.cc index c6830127c..4bb1601c8 100644 --- a/src/plugins/tools/view_25d/lay_plugin/layD25Plugin.cc +++ b/src/plugins/tools/view_25d/lay_plugin/layD25Plugin.cc @@ -67,7 +67,7 @@ public: // .. nothing yet .. } - lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutView *view) const + lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutViewBase *view) const { return new D25View (root, view); } diff --git a/src/plugins/tools/xor/lay_plugin/layXORPlugin.cc b/src/plugins/tools/xor/lay_plugin/layXORPlugin.cc index f6f9f79e1..094f67beb 100644 --- a/src/plugins/tools/xor/lay_plugin/layXORPlugin.cc +++ b/src/plugins/tools/xor/lay_plugin/layXORPlugin.cc @@ -34,7 +34,7 @@ class XORPlugin : public lay::Plugin { public: - XORPlugin (Plugin *parent, lay::LayoutView *view) + XORPlugin (Plugin *parent, lay::LayoutViewBase *view) : lay::Plugin (parent), mp_view (view) { mp_dialog = new lay::XORToolDialog (0); @@ -110,7 +110,7 @@ public: // .. nothing yet .. } - lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutView *view) const + lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutViewBase *view) const { return new XORPlugin (root, view); } diff --git a/src/plugins/tools/xor/lay_plugin/layXORToolDialog.cc b/src/plugins/tools/xor/lay_plugin/layXORToolDialog.cc index ff8c7888b..f5141f114 100644 --- a/src/plugins/tools/xor/lay_plugin/layXORToolDialog.cc +++ b/src/plugins/tools/xor/lay_plugin/layXORToolDialog.cc @@ -186,7 +186,7 @@ XORToolDialog::~XORToolDialog () } int -XORToolDialog::exec_dialog (lay::LayoutView *view) +XORToolDialog::exec_dialog (lay::LayoutViewBase *view) { mp_view = view; diff --git a/src/plugins/tools/xor/lay_plugin/layXORToolDialog.h b/src/plugins/tools/xor/lay_plugin/layXORToolDialog.h index adeb9fb1b..a5b0d52be 100644 --- a/src/plugins/tools/xor/lay_plugin/layXORToolDialog.h +++ b/src/plugins/tools/xor/lay_plugin/layXORToolDialog.h @@ -61,7 +61,7 @@ public: XORToolDialog (QWidget *parent); ~XORToolDialog (); - int exec_dialog (lay::LayoutView *view); + int exec_dialog (lay::LayoutViewBase *view); protected: void accept (); From 9b7a237a798986ae5a3f17f9ce9e718ec0d1f782 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 1 May 2022 10:30:26 +0200 Subject: [PATCH 11/88] WIP --- src/lay/lay/layClipDialog.cc | 2 +- src/lay/lay/layClipDialog.h | 2 +- src/lay/lay/layFillDialog.cc | 14 +- src/lay/lay/layFillDialog.h | 4 +- src/lay/lay/layMainWindow.cc | 4 +- src/lay/lay/laySearchReplacePlugin.cc | 4 +- src/laybasic/laybasic/layCellSelectionForm.cc | 2 +- src/laybasic/laybasic/layCellSelectionForm.h | 4 +- src/laybasic/laybasic/layCellTreeModel.cc | 6 +- src/laybasic/laybasic/layCellTreeModel.h | 10 +- src/laybasic/laybasic/layLayoutView.cc | 102 +------- src/laybasic/laybasic/layLayoutView.h | 82 +----- src/laybasic/laybasic/layLayoutViewBase.cc | 244 ++++++++++++++++-- src/laybasic/laybasic/layLayoutViewBase.h | 171 +++++++++++- .../lay_plugin/layBooleanOperationsPlugin.cc | 4 +- .../tools/diff/lay_plugin/layDiffPlugin.cc | 5 +- .../lay_plugin/layNetTracerDialog.cc | 3 +- .../lay_plugin/layNetTracerDialog.h | 7 + .../lay_plugin/layNetTracerPlugin.cc | 5 +- .../tools/view_25d/lay_plugin/layD25View.cc | 4 +- .../tools/view_25d/lay_plugin/layD25View.h | 2 +- .../view_25d/lay_plugin/layD25ViewWidget.cc | 2 +- .../view_25d/lay_plugin/layD25ViewWidget.h | 6 +- .../tools/xor/lay_plugin/layXORPlugin.cc | 7 +- .../tools/xor/lay_plugin/layXORToolDialog.cc | 2 +- .../tools/xor/lay_plugin/layXORToolDialog.h | 2 +- 26 files changed, 466 insertions(+), 234 deletions(-) diff --git a/src/lay/lay/layClipDialog.cc b/src/lay/lay/layClipDialog.cc index f644a8ce5..2c28187e0 100644 --- a/src/lay/lay/layClipDialog.cc +++ b/src/lay/lay/layClipDialog.cc @@ -66,7 +66,7 @@ static tl::RegisteredClass config_decl (new ClipDialogPl // ------------------------------------------------------------ -ClipDialog::ClipDialog (lay::Dispatcher *root, lay::LayoutView *vw) +ClipDialog::ClipDialog (lay::Dispatcher *root, LayoutViewBase *vw) : lay::Browser (root, vw), Ui::ClipDialog () { diff --git a/src/lay/lay/layClipDialog.h b/src/lay/lay/layClipDialog.h index bab730bf9..e84ad2435 100644 --- a/src/lay/lay/layClipDialog.h +++ b/src/lay/lay/layClipDialog.h @@ -40,7 +40,7 @@ class ClipDialog Q_OBJECT public: - ClipDialog (lay::Dispatcher *root, lay::LayoutView *view); + ClipDialog (lay::Dispatcher *root, lay::LayoutViewBase *view); ~ClipDialog (); public slots: diff --git a/src/lay/lay/layFillDialog.cc b/src/lay/lay/layFillDialog.cc index 5969b677a..ec0e30fed 100644 --- a/src/lay/lay/layFillDialog.cc +++ b/src/lay/lay/layFillDialog.cc @@ -73,8 +73,8 @@ static tl::RegisteredClass config_decl (new FillDialogPl // ------------------------------------------------------------ -FillDialog::FillDialog (lay::Dispatcher *main, lay::LayoutView *view) - : QDialog (view), +FillDialog::FillDialog (lay::Dispatcher *main, LayoutViewBase *view) + : QDialog (view->widget ()), lay::Plugin (main), Ui::FillDialog (), mp_view (view) @@ -315,8 +315,14 @@ FillDialog::get_fill_parameters () } else if (layer_spec_cbx->currentIndex () == 2) { - // selected layers - std::vector s = mp_view->selected_layers (); + // get selected layers + std::vector s; + + lay::LayoutView *lv = dynamic_cast (mp_view); + if (lv) { + s = lv->selected_layers (); // @@@ should be part of LayoutViewBase too + } + for (std::vector::const_iterator l = s.begin (); l != s.end (); ++l) { if (! (*l)->has_children () && cv->layout ().is_valid_layer ((*l)->layer_index ())) { fp.exclude_layers.push_back (cv->layout ().get_properties ((*l)->layer_index ())); diff --git a/src/lay/lay/layFillDialog.h b/src/lay/lay/layFillDialog.h index 52deb5826..faa06851a 100644 --- a/src/lay/lay/layFillDialog.h +++ b/src/lay/lay/layFillDialog.h @@ -76,7 +76,7 @@ class LAY_PUBLIC FillDialog Q_OBJECT public: - FillDialog (lay::Dispatcher *root, lay::LayoutView *view); + FillDialog (lay::Dispatcher *root, lay::LayoutViewBase *view); ~FillDialog (); public slots: @@ -95,7 +95,7 @@ private: void generate_fill (const FillParameters &fp); FillParameters get_fill_parameters (); - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; }; } diff --git a/src/lay/lay/layMainWindow.cc b/src/lay/lay/layMainWindow.cc index e1690b121..d632ce26a 100644 --- a/src/lay/lay/layMainWindow.cc +++ b/src/lay/lay/layMainWindow.cc @@ -159,7 +159,7 @@ MainWindow::MainWindow (QApplication *app, const char *name, bool undo_enabled) : QMainWindow (0), tl::Object (), lay::DispatcherDelegate (), - m_dispatcher (this, this), + m_dispatcher (this), m_text_progress (this, 10 /*verbosity threshold*/), m_mode (std::numeric_limits::max ()), mp_setup_form (0), @@ -179,6 +179,8 @@ MainWindow::MainWindow (QApplication *app, const char *name, bool undo_enabled) mp_app (app), m_manager (undo_enabled) { + m_dispatcher.set_menu_parent_widget (this); + // ensures the deferred method scheduler is present tl::DeferredMethodScheduler::instance (); diff --git a/src/lay/lay/laySearchReplacePlugin.cc b/src/lay/lay/laySearchReplacePlugin.cc index 6c4be161b..cca26248a 100644 --- a/src/lay/lay/laySearchReplacePlugin.cc +++ b/src/lay/lay/laySearchReplacePlugin.cc @@ -65,7 +65,9 @@ public: virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutViewBase *view) const { - return new SearchReplaceDialog (root, view); + lay::LayoutView *lv = dynamic_cast (view); + tl_assert (lv != 0); + return new SearchReplaceDialog (root, lv); } }; diff --git a/src/laybasic/laybasic/layCellSelectionForm.cc b/src/laybasic/laybasic/layCellSelectionForm.cc index 0bd3ff519..be93b86ea 100644 --- a/src/laybasic/laybasic/layCellSelectionForm.cc +++ b/src/laybasic/laybasic/layCellSelectionForm.cc @@ -49,7 +49,7 @@ static const std::string cfg_cell_selection_search_use_expressions ("cell-select // ------------------------------------------------------------ -CellSelectionForm::CellSelectionForm (QWidget *parent, LayoutView *view, const char *name, bool simple_mode) +CellSelectionForm::CellSelectionForm (QWidget *parent, LayoutViewBase *view, const char *name, bool simple_mode) : QDialog (parent), Ui::CellSelectionForm (), mp_view (view), m_current_cv (-1), diff --git a/src/laybasic/laybasic/layCellSelectionForm.h b/src/laybasic/laybasic/layCellSelectionForm.h index adc0a5cc7..f1447eee7 100644 --- a/src/laybasic/laybasic/layCellSelectionForm.h +++ b/src/laybasic/laybasic/layCellSelectionForm.h @@ -49,7 +49,7 @@ class LAYBASIC_PUBLIC CellSelectionForm Q_OBJECT public: - CellSelectionForm (QWidget *parent, LayoutView *view, const char *name, bool simple_mode = false); + CellSelectionForm (QWidget *parent, LayoutViewBase *view, const char *name, bool simple_mode = false); /** * @brief Obtain the selected cellview's index (with changes) @@ -76,7 +76,7 @@ public slots: void find_prev_clicked(); private: - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; std::vector m_cellviews; int m_current_cv; bool m_name_cb_enabled; diff --git a/src/laybasic/laybasic/layCellTreeModel.cc b/src/laybasic/laybasic/layCellTreeModel.cc index d8e4ca573..d15ddf2fd 100644 --- a/src/laybasic/laybasic/layCellTreeModel.cc +++ b/src/laybasic/laybasic/layCellTreeModel.cc @@ -303,7 +303,7 @@ CellTreeItem::by_area_equal_than (const CellTreeItem *b) const // valid ("under construction"). In this case, the model will return defaults or void // objects. -CellTreeModel::CellTreeModel (QWidget *parent, lay::LayoutView *view, int cv_index, unsigned int flags, const db::Cell *base, Sorting sorting) +CellTreeModel::CellTreeModel (QWidget *parent, lay::LayoutViewBase *view, int cv_index, unsigned int flags, const db::Cell *base, Sorting sorting) : QAbstractItemModel (parent), m_flags (flags), m_sorting (sorting), @@ -379,7 +379,7 @@ CellTreeModel::~CellTreeModel () } void -CellTreeModel::configure (lay::LayoutView *view, int cv_index, unsigned int flags, const db::Cell *base, Sorting sorting) +CellTreeModel::configure (lay::LayoutViewBase *view, int cv_index, unsigned int flags, const db::Cell *base, Sorting sorting) { db::Layout *layout = & view->cellview (cv_index)->layout (); do_configure (layout, 0, view, cv_index, flags, base, sorting); @@ -398,7 +398,7 @@ CellTreeModel::configure (db::Library *library, unsigned int flags, const db::Ce } void -CellTreeModel::do_configure (db::Layout *layout, db::Library *library, lay::LayoutView *view, int cv_index, unsigned int flags, const db::Cell *base, Sorting sorting) +CellTreeModel::do_configure (db::Layout *layout, db::Library *library, lay::LayoutViewBase *view, int cv_index, unsigned int flags, const db::Cell *base, Sorting sorting) { bool flat = ((flags & Flat) != 0) && ((flags & TopCells) == 0); diff --git a/src/laybasic/laybasic/layCellTreeModel.h b/src/laybasic/laybasic/layCellTreeModel.h index 2e8569e55..b0c6af312 100644 --- a/src/laybasic/laybasic/layCellTreeModel.h +++ b/src/laybasic/laybasic/layCellTreeModel.h @@ -45,7 +45,7 @@ namespace db namespace lay { -class LayoutView; +class LayoutViewBase; class CellTreeItem; /** @@ -85,7 +85,7 @@ public: * If flags "Children" or "Parents" are given, "base" must be set to the cell of which * the children or parents should be derived. */ - CellTreeModel (QWidget *parent, lay::LayoutView *view, int cv_index, unsigned int flags = 0, const db::Cell *base = 0, Sorting sorting = ByName); + CellTreeModel (QWidget *parent, lay::LayoutViewBase *view, int cv_index, unsigned int flags = 0, const db::Cell *base = 0, Sorting sorting = ByName); /** * @brief Constructor @@ -120,7 +120,7 @@ public: /** * @brief Reconfigures the model with a LayoutView */ - void configure (lay::LayoutView *view, int cv_index, unsigned int flags = 0, const db::Cell *base = 0, Sorting sorting = ByName); + void configure (LayoutViewBase *view, int cv_index, unsigned int flags = 0, const db::Cell *base = 0, Sorting sorting = ByName); /** * @brief Reconfigures the model with a pure Layout @@ -257,7 +257,7 @@ private: unsigned int m_flags; Sorting m_sorting; QWidget *mp_parent; - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; db::Layout *mp_layout; db::Library *mp_library; int m_cv_index; @@ -271,7 +271,7 @@ private: void build_top_level (); void clear_top_level (); bool search_children (const tl::GlobPattern &pattern, CellTreeItem *item); - void do_configure (db::Layout *layout, db::Library *library, lay::LayoutView *view, int cv_index, unsigned int flags, const db::Cell *base, Sorting sorting); + void do_configure (db::Layout *layout, db::Library *library, LayoutViewBase *view, int cv_index, unsigned int flags, const db::Cell *base, Sorting sorting); }; /** diff --git a/src/laybasic/laybasic/layLayoutView.cc b/src/laybasic/laybasic/layLayoutView.cc index 47e531863..95408cdad 100644 --- a/src/laybasic/laybasic/layLayoutView.cc +++ b/src/laybasic/laybasic/layLayoutView.cc @@ -321,6 +321,12 @@ LayoutView::~LayoutView () mp_bookmarks_view = 0; } +void +LayoutView::do_change_active_cellview () +{ + dm_setup_editor_option_pages (); +} + lay::EditorOptionsPages *LayoutView::editor_options_pages () { if (! mp_editor_options_frame) { @@ -614,21 +620,6 @@ LayoutView::set_or_request_current_layer (unsigned int cv_index, const db::Layer return false; } -bool -LayoutView::set_current_layer (unsigned int cv_index, const db::LayerProperties &lp) -{ - // rename the ones that got shifted. - lay::LayerPropertiesConstIterator l = begin_layers (); - while (! l.at_end ()) { - if (l->source (true).cv_index () == int (cv_index) && l->source (true).layer_props ().log_equal (lp)) { - set_current_layer (l); - return true; - } - ++l; - } - return false; -} - void LayoutView::set_current_layer (const lay::LayerPropertiesConstIterator &l) { @@ -637,13 +628,7 @@ LayoutView::set_current_layer (const lay::LayerPropertiesConstIterator &l) } } -void -LayoutView::do_set_current_layer (const lay::LayerPropertiesConstIterator &l) -{ - set_current_layer (l); -} - -lay::LayerPropertiesConstIterator +lay::LayerPropertiesConstIterator LayoutView::current_layer () const { if (mp_control_panel) { @@ -838,67 +823,6 @@ LayoutView::do_set_phase (int phase) } } -void -LayoutView::enable_active_cellview_changed_event (bool enable, bool silent) -{ - if (m_active_cellview_changed_event_enabled == enable) { - return; - } - - m_active_cellview_changed_event_enabled = enable; - if (enable) { - - if (!silent && ! m_active_cellview_changed_events.empty ()) { - - // deliver stored events - - // we need to cancel pending drawing or dragging operations to reflect the new cellview (different target, may have different technology etc.) - cancel_esc (); - - // we need to setup the editor option pages because the technology may have changed - dm_setup_editor_option_pages (); - - active_cellview_changed_event (); - for (std::set::const_iterator i = m_active_cellview_changed_events.begin (); i != m_active_cellview_changed_events.end (); ++i) { - active_cellview_changed_with_index_event (*i); - } - - // Because the title reflects the active one, emit a title changed event - if (title_string ().empty ()) { - emit title_changed (); - } - - } - - } - - m_active_cellview_changed_events.clear (); -} - -void -LayoutView::active_cellview_changed (int index) -{ - if (m_active_cellview_changed_event_enabled) { - - // we need to cancel pending drawing or dragging operations to reflect the new cellview (different target, may have different technology etc.) - cancel_esc (); - - // we need to setup the editor option pages because the technology may have changed - dm_setup_editor_option_pages (); - - active_cellview_changed_event (); - active_cellview_changed_with_index_event (index); - - // Because the title reflects the active one, emit a title changed event - if (title_string ().empty ()) { - emit title_changed (); - } - - } else { - m_active_cellview_changed_events.insert (index); - } -} - void LayoutView::active_library_changed (int /*index*/) { @@ -989,18 +913,6 @@ LayoutView::cut () } } -const lay::CellView & -LayoutView::active_cellview () const -{ - return cellview ((unsigned int) active_cellview_index ()); -} - -lay::CellViewRef -LayoutView::active_cellview_ref () -{ - return cellview_ref ((unsigned int) active_cellview_index ()); -} - int LayoutView::active_cellview_index () const { diff --git a/src/laybasic/laybasic/layLayoutView.h b/src/laybasic/laybasic/layLayoutView.h index 69af08d9d..7b06b183d 100644 --- a/src/laybasic/laybasic/layLayoutView.h +++ b/src/laybasic/laybasic/layLayoutView.h @@ -140,21 +140,6 @@ public: */ virtual bool has_selection (); - /** - * @brief Gets the window title of the view - */ - std::string title () const; - - /** - * @brief Sets the window title to an explicit string - */ - void set_title (const std::string &t); - - /** - * @brief Resets the explicit title and enable the automatic naming - */ - void reset_title (); - /** * @brief Display a status message */ @@ -179,7 +164,7 @@ public: * Switches the mode on application level. Use this method to initiate * a mode switch from the view. */ - void switch_mode (int m); + virtual void switch_mode (int m); /** * @brief Updates the menu for the given view @@ -210,7 +195,10 @@ public: * * Returns false if the layer is not a valid one. */ - bool set_current_layer (unsigned int cv_index, const db::LayerProperties &properties); + bool set_current_layer (unsigned int cv_index, const db::LayerProperties &properties) + { + return LayoutViewBase::set_current_layer (cv_index, properties); + } /** * @brief Sets the currently active layer @@ -218,7 +206,7 @@ public: * The active layer is the one that is active in the layer * browser panel. This method will also select this layer. */ - void set_current_layer (const lay::LayerPropertiesConstIterator &l); + virtual void set_current_layer (const lay::LayerPropertiesConstIterator &l); /** * @brief Retrieve the index of the currently active layer @@ -227,7 +215,7 @@ public: * browser panel. * This method returns a null iterator, if no layer is active. */ - lay::LayerPropertiesConstIterator current_layer () const; + virtual lay::LayerPropertiesConstIterator current_layer () const; /** * @brief Return the layers that are selected in the layer browser @@ -246,16 +234,6 @@ public: */ int active_cellview_index () const; - /** - * @brief Get the index of the active cellview (shown in hierarchy browser) - */ - const lay::CellView &active_cellview () const; - - /** - * @brief Gets a cellview reference to the active cellview - */ - lay::CellViewRef active_cellview_ref (); - /** * @brief Select a certain cellview for the active one */ @@ -277,18 +255,6 @@ public: */ void current_cell_path (int cv_index, cell_path_type &path) const; - /** - * @brief Cell path of the current cell - * - * This method version is provided for automation purposes mainly. - */ - cell_path_type get_current_cell_path (int cv_index) const - { - cell_path_type r; - current_cell_path (cv_index, r); - return r; - } - /** * @brief Cell path of the current cell in the active cellview * @@ -307,16 +273,6 @@ public: */ virtual void set_current_cell_path (int cv_index, const cell_path_type &path); - /** - * @brief Set the path to the current cell is the current cellview - * - * This is a convenience function setting the path for the active cellview. - */ - void set_current_cell_path (const cell_path_type &path) - { - set_current_cell_path (active_cellview_index (), path); - } - /** * @brief Remove unused layers */ @@ -496,19 +452,6 @@ public: */ tl::Event hide_event; - /** - * @brief An event triggered if the active cellview changes - * This event is triggered after the active cellview changed. - */ - tl::Event active_cellview_changed_event; - - /** - * @brief An event triggered if the active cellview changes - * This event is triggered after the active cellview changed. The integer parameter is the index of the - * new cellview. - */ - tl::event active_cellview_changed_with_index_event; - public slots: /** * @brief Store the current state on the "previous states" stack @@ -705,7 +648,11 @@ public slots: void deactivate_all_browsers (); private slots: - void active_cellview_changed (int index); + void active_cellview_changed (int index) + { + LayoutViewBase::active_cellview_changed (index); + } + void active_library_changed (int index); void side_panel_destroyed (); @@ -768,8 +715,6 @@ private: QSpinBox *mp_min_hier_spbx; QSpinBox *mp_max_hier_spbx; BookmarkList m_bookmarks; - bool m_active_cellview_changed_event_enabled; - std::set m_active_cellview_changed_events; bool m_always_show_source; bool m_always_show_ld; bool m_always_show_layout_index; @@ -796,13 +741,12 @@ protected: virtual void do_paste (); virtual void begin_layer_updates (); virtual void ensure_layer_selected (); - virtual void do_set_current_layer (const lay::LayerPropertiesConstIterator &l); virtual void update_content_for_cv (int cv_index); virtual void do_set_no_stipples (bool no_stipples); virtual void do_set_phase (int phase); virtual bool set_hier_levels_basic (std::pair l); + virtual void do_change_active_cellview (); virtual bool is_activated () const; - virtual void enable_active_cellview_changed_event (bool enable, bool silent = false); // overrides Editables method to display a message void signal_selection_changed (); diff --git a/src/laybasic/laybasic/layLayoutViewBase.cc b/src/laybasic/laybasic/layLayoutViewBase.cc index 84ecfad9e..488402a1d 100644 --- a/src/laybasic/laybasic/layLayoutViewBase.cc +++ b/src/laybasic/laybasic/layLayoutViewBase.cc @@ -304,6 +304,9 @@ LayoutViewBase::init (db::Manager *mgr) { manager (mgr); + m_active_cellview_index = -1; + m_active_cellview_changed_event_enabled = true; + m_annotation_shapes.manager (mgr); m_visibility_changed = false; @@ -625,6 +628,58 @@ LayoutViewBase::is_dirty () const return m_dirty; } +std::string +LayoutViewBase::title () const +{ + if (! m_title.empty ()) { + return m_title; + } else if (cellviews () == 0) { + return tl::to_string (QObject::tr ("")); + } else { + + int cv_index = active_cellview_index (); + if (cv_index < 0 || cv_index >= int (cellviews ())) { + cv_index = 0; + } + + const lay::CellView &cv0 = cellview (cv_index); + + std::string t; + + t += cv0->name (); + if (cv0->layout ().is_valid_cell_index (cv0.cell_index ())) { + t += " ["; + t += cv0->layout ().cell_name (cv0.cell_index ()); + t += "]"; + } + + if (cellviews () > 1) { + t += " ..."; + } + + return t; + + } +} + +void +LayoutViewBase::set_title (const std::string &t) +{ + if (m_title != t) { + m_title = t; + emit_title_changed (); + } +} + +void +LayoutViewBase::reset_title () +{ + if (! m_title.empty ()) { + m_title = ""; + emit_title_changed (); + } +} + bool LayoutViewBase::configure (const std::string &name, const std::string &value) { @@ -1355,6 +1410,35 @@ LayoutViewBase::rename_properties (unsigned int index, const std::string &new_na layer_list_changed_event (4); } +bool +LayoutViewBase::set_current_layer (unsigned int cv_index, const db::LayerProperties &lp) +{ + // rename the ones that got shifted. + lay::LayerPropertiesConstIterator l = begin_layers (); + while (! l.at_end ()) { + if (l->source (true).cv_index () == int (cv_index) && l->source (true).layer_props ().log_equal (lp)) { + set_current_layer (l); + return true; + } + ++l; + } + return false; +} + +void +LayoutViewBase::set_current_layer (const lay::LayerPropertiesConstIterator &l) +{ + // @@@ No checking happens + m_current_layer = l; +} + +lay::LayerPropertiesConstIterator +LayoutViewBase::current_layer () const +{ + // @@@ No checking happens + return m_current_layer; +} + void LayoutViewBase::merge_dither_pattern (lay::LayerPropertiesList &props) { @@ -1975,6 +2059,10 @@ LayoutViewBase::erase_cellview (unsigned int index) m_hidden_cells.erase (m_hidden_cells.begin () + index); } + if (m_current_cell_per_cellview.size () > index) { + m_current_cell_per_cellview.erase (m_current_cell_per_cellview.begin () + index); + } + for (unsigned int lindex = 0; lindex < layer_lists (); ++lindex) { // remove all references to the cellview @@ -2030,6 +2118,9 @@ LayoutViewBase::clear_cellviews () set_properties (lay::LayerPropertiesList ()); m_cellviews.clear (); + m_hidden_cells.clear (); + m_current_cell_per_cellview.clear (); + // clear the history, store path and zoom box m_display_states.clear (); m_display_state_ptr = 0; @@ -2312,7 +2403,7 @@ LayoutViewBase::add_new_layers (const std::vector &layer_ids, int set_properties (new_props); if (was_empty) { - do_set_current_layer (new_props.begin_const_recursive ()); + set_current_layer (new_props.begin_const_recursive ()); } } @@ -2601,6 +2692,11 @@ LayoutViewBase::reload_layout (unsigned int cv_index) } } + // clear the current cell (NOTE: this is for providing a cell target for some UI functions only) + if (m_current_cell_per_cellview.size () > cv_index) { + m_current_cell_per_cellview [cv_index] = cell_path_type (); + } + // Determine which layers to create as new layers. New layer need to be created // if these have not been present in the original layout and there are no layer views // referring to them. @@ -4116,13 +4212,133 @@ LayoutViewBase::cellview_changed (unsigned int index) } } +const lay::CellView & +LayoutViewBase::active_cellview () const +{ + return cellview ((unsigned int) active_cellview_index ()); +} + +lay::CellViewRef +LayoutViewBase::active_cellview_ref () +{ + return cellview_ref ((unsigned int) active_cellview_index ()); +} + +int +LayoutViewBase::active_cellview_index () const +{ + return m_active_cellview_index; +} + void -LayoutViewBase::set_current_cell_path (int /*cv_index*/, const cell_path_type & /*path*/) +LayoutViewBase::set_active_cellview_index (int index) +{ + if (index >= 0 && index < int (cellviews ())) { + if (m_active_cellview_index != index) { + m_active_cellview_index = index; + active_cellview_changed (index); + } + } else { + m_active_cellview_index = -1; + } +} + +void +LayoutViewBase::selected_cells_paths (int /*cv_index*/, std::vector & /*paths*/) const +{ + // TODO: not implemented yet as there is no setter so far. + // (but it is implemented in the UI version where it is bound to the hierarchy control panel) +} + +void +LayoutViewBase::current_cell_path (int cv_index, cell_path_type &path) const +{ + if (cv_index >= 0 && cv_index < int (m_current_cell_per_cellview.size ())) { + path = m_current_cell_per_cellview [cv_index]; + } else { + path = cell_path_type (); + } +} + +void +LayoutViewBase::set_current_cell_path (int cv_index, const cell_path_type &path) +{ + if (cv_index >= 0) { + while (cv_index <= int (m_current_cell_per_cellview.size ())) { + m_current_cell_per_cellview.push_back (cell_path_type ()); + } + m_current_cell_per_cellview [cv_index] = path; + } +} + +void +LayoutViewBase::do_change_active_cellview () { // .. nothing yet .. } -void +void +LayoutViewBase::enable_active_cellview_changed_event (bool enable, bool silent) +{ + if (m_active_cellview_changed_event_enabled == enable) { + return; + } + + m_active_cellview_changed_event_enabled = enable; + if (enable) { + + if (!silent && ! m_active_cellview_changed_events.empty ()) { + + // deliver stored events + + // we need to cancel pending drawing or dragging operations to reflect the new cellview (different target, may have different technology etc.) + cancel_esc (); + + // we need to setup the editor option pages because the technology may have changed + do_change_active_cellview (); + + active_cellview_changed_event (); + for (std::set::const_iterator i = m_active_cellview_changed_events.begin (); i != m_active_cellview_changed_events.end (); ++i) { + active_cellview_changed_with_index_event (*i); + } + + // Because the title reflects the active one, emit a title changed event + if (title_string ().empty ()) { + emit_title_changed (); + } + + } + + } + + m_active_cellview_changed_events.clear (); +} + +void +LayoutViewBase::active_cellview_changed (int index) +{ + if (m_active_cellview_changed_event_enabled) { + + // we need to cancel pending drawing or dragging operations to reflect the new cellview (different target, may have different technology etc.) + cancel_esc (); + + // we need to setup the editor option pages because the technology may have changed + do_change_active_cellview (); + + active_cellview_changed_event (); + active_cellview_changed_with_index_event (index); + + // Because the title reflects the active one, emit a title changed event + if (title_string ().empty ()) { + emit_title_changed (); + } + + } else { + m_active_cellview_changed_events.insert (index); + } +} + +void LayoutViewBase::select_cell_dispatch (const cell_path_type &path, int cellview_index) { bool set_max_hier = (m_full_hier_new_cell || has_max_hier ()); @@ -4781,12 +4997,6 @@ LayoutViewBase::ensure_layer_selected () // .. nothing yet .. } -void -LayoutViewBase::do_set_current_layer (const lay::LayerPropertiesConstIterator & /*l*/) -{ - // .. nothing yet .. -} - void LayoutViewBase::do_set_no_stipples (bool /*no_stipples*/) { @@ -4812,21 +5022,9 @@ LayoutViewBase::is_activated () const } void -LayoutViewBase::switch_mode (int /*m*/) +LayoutViewBase::switch_mode (int m) { - // .. nothing yet .. -} - -void -LayoutViewBase::set_active_cellview_index (int /*index*/) -{ - // .. nothing yet .. -} - -void -LayoutViewBase::enable_active_cellview_changed_event (bool /*enable*/, bool /*silent*/) -{ - // .. nothing yet .. + mode (m); } void diff --git a/src/laybasic/laybasic/layLayoutViewBase.h b/src/laybasic/laybasic/layLayoutViewBase.h index 781b534d2..50346e6a7 100644 --- a/src/laybasic/laybasic/layLayoutViewBase.h +++ b/src/laybasic/laybasic/layLayoutViewBase.h @@ -195,6 +195,22 @@ public: */ ~LayoutViewBase (); + /** + * @brief Gets the current mode + */ + int mode () const + { + return m_mode; + } + + /** + * @brief Switches the application's mode + * + * Switches the mode on application level. Use this method to initiate + * a mode switch from the view. + */ + virtual void switch_mode (int m); + /** * @brief Determine if there is something to copy * @@ -508,6 +524,33 @@ public: insert_layer_list (index, LayerPropertiesList ()); } + /** + * @brief Sets the currently active layer by layer properties and cell view index + * + * This method will look up that layer in the layer view tree and select that layer. + * This method will also select this layer. + * + * Returns false if the layer is not a valid one. + */ + bool set_current_layer (unsigned int cv_index, const db::LayerProperties &properties); + + /** + * @brief Sets the currently active layer + * + * The active layer is the one that is active in the layer + * browser panel. This method will also select this layer. + */ + virtual void set_current_layer (const lay::LayerPropertiesConstIterator &l); + + /** + * @brief Retrieve the index of the currently active layer + * + * The active layer is the one that is active in the layer + * browser panel. + * This method returns a null iterator, if no layer is active. + */ + virtual lay::LayerPropertiesConstIterator current_layer () const; + /** * @brief Set the custom dither pattern */ @@ -1837,7 +1880,96 @@ public: */ db::InstElement ascend (int cellview_index); - /** + /** + * @brief Get the index of the active cellview (shown in hierarchy browser) + */ + const lay::CellView &active_cellview () const; + + /** + * @brief Gets a cellview reference to the active cellview + */ + lay::CellViewRef active_cellview_ref (); + + /** + * @brief Get the index of the active cellview (shown in hierarchy browser) + */ + virtual int active_cellview_index () const; + + /** + * @brief Select a certain cellview for the active one + */ + virtual void set_active_cellview_index (int index); + + /** + * @brief An event triggered if the active cellview changes + * This event is triggered after the active cellview changed. + */ + tl::Event active_cellview_changed_event; + + /** + * @brief An event triggered if the active cellview changes + * This event is triggered after the active cellview changed. The integer parameter is the index of the + * new cellview. + */ + tl::event active_cellview_changed_with_index_event; + + /** + * @brief Cell paths of the selected cells + * + * The current cell is the one highlighted in the browser with the focus rectangle. The + * current path is returned for the cellview given by cv_index. + */ + virtual void selected_cells_paths (int cv_index, std::vector &paths) const; + + /** + * @brief Cell path of the current cell + * + * The current cell is the one highlighted in the browser with the focus rectangle. The + * current path is returned for the cellview given by cv_index. + */ + virtual void current_cell_path (int cv_index, cell_path_type &path) const; + + /** + * @brief Cell path of the current cell + * + * This method version is provided for automation purposes mainly. + */ + cell_path_type get_current_cell_path (int cv_index) const + { + cell_path_type r; + current_cell_path (cv_index, r); + return r; + } + + /** + * @brief Cell path of the current cell in the active cellview + * + * This is a convenience function returning the path for the active cellview. + */ + void current_cell_path (cell_path_type &path) const + { + current_cell_path (active_cellview_index (), path); + } + + /** + * @brief Set the path to the current cell + * + * The current cell is the one highlighted in the browser with the focus rectangle. The + * cell given by the path is highlighted and scrolled into view. + */ + virtual void set_current_cell_path (int cv_index, const cell_path_type &path); + + /** + * @brief Set the path to the current cell is the current cellview + * + * This is a convenience function setting the path for the active cellview. + */ + void set_current_cell_path (const cell_path_type &path) + { + set_current_cell_path (active_cellview_index (), path); + } + + /** * @brief Select a cell by path for a certain cell view and fit cell */ void select_cell_fit (const cell_path_type &path, int cellview_index); @@ -2186,6 +2318,21 @@ public: return mp_canvas->global_trans (); } + /** + * @brief Gets the window title of the view + */ + std::string title () const; + + /** + * @brief Sets the window title to an explicit string + */ + void set_title (const std::string &t); + + /** + * @brief Resets the explicit title and enable the automatic naming + */ + void reset_title (); + /** * @brief Removes the previous state from the stack */ @@ -2461,6 +2608,14 @@ private: lay::Plugin *mp_active_plugin; + int m_active_cellview_index; + bool m_active_cellview_changed_event_enabled; + std::set m_active_cellview_changed_events; + + lay::LayerPropertiesConstIterator m_current_layer; + + std::vector m_current_cell_per_cellview; + bool m_visibility_changed; tl::Clock m_clock, m_last_checked; @@ -2500,11 +2655,6 @@ protected: return m_options; } - int mode () const - { - return m_mode; - } - lay::Plugin *active_plugin () const { return mp_active_plugin; @@ -2525,18 +2675,17 @@ protected: virtual lay::Color default_background_color (); virtual void do_set_background_color (lay::Color color, lay::Color contrast); virtual void do_paste (); - virtual void switch_mode (int m); virtual void begin_layer_updates (); virtual void ensure_layer_selected (); - virtual void do_set_current_layer (const lay::LayerPropertiesConstIterator &l); virtual void do_set_no_stipples (bool no_stipples); virtual void do_set_phase (int phase); virtual bool is_activated () const; + virtual void do_change_active_cellview (); virtual void update_content_for_cv (int cv_index); - virtual void set_active_cellview_index (int index); - virtual void enable_active_cellview_changed_event (bool enable, bool silent = false); virtual bool set_hier_levels_basic (std::pair l); - virtual void set_current_cell_path (int cv_index, const cell_path_type &path); + + void enable_active_cellview_changed_event (bool enable, bool silent = false); + void active_cellview_changed (int index); virtual void emit_edits_enabled_changed () { } virtual void emit_title_changed () { } diff --git a/src/plugins/tools/bool/lay_plugin/layBooleanOperationsPlugin.cc b/src/plugins/tools/bool/lay_plugin/layBooleanOperationsPlugin.cc index 7202d66e1..892c78351 100644 --- a/src/plugins/tools/bool/lay_plugin/layBooleanOperationsPlugin.cc +++ b/src/plugins/tools/bool/lay_plugin/layBooleanOperationsPlugin.cc @@ -496,7 +496,9 @@ public: lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutViewBase *view) const { - return new BooleanOperationsPlugin (root, view); + lay::LayoutView *lv = dynamic_cast (view); + tl_assert (lv != 0); + return new BooleanOperationsPlugin (root, lv); } }; diff --git a/src/plugins/tools/diff/lay_plugin/layDiffPlugin.cc b/src/plugins/tools/diff/lay_plugin/layDiffPlugin.cc index 7f207a1d2..b44dfa780 100644 --- a/src/plugins/tools/diff/lay_plugin/layDiffPlugin.cc +++ b/src/plugins/tools/diff/lay_plugin/layDiffPlugin.cc @@ -24,6 +24,7 @@ #include "layDispatcher.h" #include "layPlugin.h" +#include "layLayoutView.h" namespace lay { @@ -104,7 +105,9 @@ public: lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutViewBase *view) const { - return new DiffPlugin (root, view); + lay::LayoutView *lv = dynamic_cast (view); + tl_assert (lv != 0); + return new DiffPlugin (root, lv); } }; diff --git a/src/plugins/tools/net_tracer/lay_plugin/layNetTracerDialog.cc b/src/plugins/tools/net_tracer/lay_plugin/layNetTracerDialog.cc index 132d46a4a..7bda1dbb2 100644 --- a/src/plugins/tools/net_tracer/lay_plugin/layNetTracerDialog.cc +++ b/src/plugins/tools/net_tracer/lay_plugin/layNetTracerDialog.cc @@ -68,7 +68,8 @@ NetTracerDialog::NetTracerDialog (lay::Dispatcher *root, lay::LayoutView *view) m_marker_intensity (0), m_auto_color_enabled (false), m_auto_color_index (0), - m_mouse_state (0) + m_mouse_state (0), + mp_view (view) { mp_export_file_dialog = new lay::FileDialog (this, tl::to_string (QObject::tr ("Export Net")), tl::to_string (QObject::tr ("KLayout net files (*.lyn);;All files (*)"))); diff --git a/src/plugins/tools/net_tracer/lay_plugin/layNetTracerDialog.h b/src/plugins/tools/net_tracer/lay_plugin/layNetTracerDialog.h index 4bff2255f..8e072dbf1 100644 --- a/src/plugins/tools/net_tracer/lay_plugin/layNetTracerDialog.h +++ b/src/plugins/tools/net_tracer/lay_plugin/layNetTracerDialog.h @@ -108,6 +108,8 @@ private: lay::FileDialog *mp_export_file_dialog; std::string m_export_file_name; + lay::LayoutView *mp_view; + void commit (); size_t get_trace_depth (); void update_highlights (); @@ -121,6 +123,11 @@ private: db::NetTracerNet *do_trace (const db::DBox &start_search_box, const db::DBox &stop_search_box, bool trace_path); bool get_net_tracer_setup (const lay::CellView &cv, db::NetTracerData &data); void trace_all_nets (db::LayoutToNetlist *l2ndb, const lay::CellView &cv, bool flat); + + lay::LayoutView *view () + { + return mp_view; + } }; } diff --git a/src/plugins/tools/net_tracer/lay_plugin/layNetTracerPlugin.cc b/src/plugins/tools/net_tracer/lay_plugin/layNetTracerPlugin.cc index 4382851b4..409e0a71e 100644 --- a/src/plugins/tools/net_tracer/lay_plugin/layNetTracerPlugin.cc +++ b/src/plugins/tools/net_tracer/lay_plugin/layNetTracerPlugin.cc @@ -28,6 +28,7 @@ #include "layConverters.h" #include "layCellView.h" +#include "layLayoutView.h" #include "gsiDecl.h" @@ -77,7 +78,9 @@ public: virtual lay::Plugin *create_plugin (db::Manager * /*manager*/, lay::Dispatcher *root, lay::LayoutViewBase *view) const { - return new NetTracerDialog (root, view); + lay::LayoutView *lv = dynamic_cast (view); + tl_assert (lv != 0); + return new NetTracerDialog (root, lv); } }; diff --git a/src/plugins/tools/view_25d/lay_plugin/layD25View.cc b/src/plugins/tools/view_25d/lay_plugin/layD25View.cc index 019dedecd..a00675974 100644 --- a/src/plugins/tools/view_25d/lay_plugin/layD25View.cc +++ b/src/plugins/tools/view_25d/lay_plugin/layD25View.cc @@ -38,7 +38,7 @@ namespace lay const double initial_elevation = 15.0; -D25View::D25View (lay::Dispatcher *root, lay::LayoutView *view) +D25View::D25View (lay::Dispatcher *root, LayoutViewBase *view) : lay::Browser (root, view, "d25_view"), dm_rerun_macro (this, &D25View::rerun_macro), dm_fit (this, &D25View::fit) @@ -94,7 +94,7 @@ D25View::D25View (lay::Dispatcher *root, lay::LayoutView *view) mp_ui->material_list->addAction (mp_ui->hide_selected_action); mp_ui->material_list->setContextMenuPolicy (Qt::ActionsContextMenu); - connect (mp_ui->material_list, SIGNAL (itemChanged (QListWidgetItem *)), this, SLOT (material_item_changed (QListWidgetItem *))); + connect (mp_ui->material_list, SIGNAL (itemChanged(QListWidgetItem *)), this, SLOT (material_item_changed(QListWidgetItem *))); } D25View::~D25View () diff --git a/src/plugins/tools/view_25d/lay_plugin/layD25View.h b/src/plugins/tools/view_25d/lay_plugin/layD25View.h index 724c14e25..6cc5cb269 100644 --- a/src/plugins/tools/view_25d/lay_plugin/layD25View.h +++ b/src/plugins/tools/view_25d/lay_plugin/layD25View.h @@ -57,7 +57,7 @@ class D25View Q_OBJECT public: - D25View (lay::Dispatcher *root, lay::LayoutView *view); + D25View (lay::Dispatcher *root, lay::LayoutViewBase *view); ~D25View (); virtual void menu_activated (const std::string &symbol); diff --git a/src/plugins/tools/view_25d/lay_plugin/layD25ViewWidget.cc b/src/plugins/tools/view_25d/lay_plugin/layD25ViewWidget.cc index 9fa1f77d6..7be0f8c24 100644 --- a/src/plugins/tools/view_25d/lay_plugin/layD25ViewWidget.cc +++ b/src/plugins/tools/view_25d/lay_plugin/layD25ViewWidget.cc @@ -711,7 +711,7 @@ D25ViewWidget::finish () } void -D25ViewWidget::attach_view (LayoutView *view) +D25ViewWidget::attach_view (LayoutViewBase *view) { mp_view = view; } diff --git a/src/plugins/tools/view_25d/lay_plugin/layD25ViewWidget.h b/src/plugins/tools/view_25d/lay_plugin/layD25ViewWidget.h index af5dd0a54..180a9cb89 100644 --- a/src/plugins/tools/view_25d/lay_plugin/layD25ViewWidget.h +++ b/src/plugins/tools/view_25d/lay_plugin/layD25ViewWidget.h @@ -57,7 +57,7 @@ namespace tl namespace lay { -class LayoutView; +class LayoutViewBase; class LayerPropertiesNode; class D25ViewWidget; @@ -106,7 +106,7 @@ public: void mouseReleaseEvent (QMouseEvent *event); void mouseMoveEvent (QMouseEvent *event); - void attach_view(lay::LayoutView *view); + void attach_view(lay::LayoutViewBase *view); QVector3D hit_point_with_scene(const QVector3D &line_dir); void refresh (); @@ -187,7 +187,7 @@ private: double m_scale_factor; double m_vscale_factor; QVector3D m_displacement; - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; db::DBox m_bbox; double m_zmin, m_zmax; bool m_zset; diff --git a/src/plugins/tools/xor/lay_plugin/layXORPlugin.cc b/src/plugins/tools/xor/lay_plugin/layXORPlugin.cc index 094f67beb..14864a9d9 100644 --- a/src/plugins/tools/xor/lay_plugin/layXORPlugin.cc +++ b/src/plugins/tools/xor/lay_plugin/layXORPlugin.cc @@ -26,6 +26,7 @@ #include "layDispatcher.h" #include "layPlugin.h" +#include "layLayoutView.h" namespace lay { @@ -34,7 +35,7 @@ class XORPlugin : public lay::Plugin { public: - XORPlugin (Plugin *parent, lay::LayoutViewBase *view) + XORPlugin (Plugin *parent, lay::LayoutView *view) : lay::Plugin (parent), mp_view (view) { mp_dialog = new lay::XORToolDialog (0); @@ -112,7 +113,9 @@ public: lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutViewBase *view) const { - return new XORPlugin (root, view); + lay::LayoutView *lv = dynamic_cast (view); + tl_assert (lv != 0); + return new XORPlugin (root, lv); } }; diff --git a/src/plugins/tools/xor/lay_plugin/layXORToolDialog.cc b/src/plugins/tools/xor/lay_plugin/layXORToolDialog.cc index f5141f114..ff8c7888b 100644 --- a/src/plugins/tools/xor/lay_plugin/layXORToolDialog.cc +++ b/src/plugins/tools/xor/lay_plugin/layXORToolDialog.cc @@ -186,7 +186,7 @@ XORToolDialog::~XORToolDialog () } int -XORToolDialog::exec_dialog (lay::LayoutViewBase *view) +XORToolDialog::exec_dialog (lay::LayoutView *view) { mp_view = view; diff --git a/src/plugins/tools/xor/lay_plugin/layXORToolDialog.h b/src/plugins/tools/xor/lay_plugin/layXORToolDialog.h index a5b0d52be..adeb9fb1b 100644 --- a/src/plugins/tools/xor/lay_plugin/layXORToolDialog.h +++ b/src/plugins/tools/xor/lay_plugin/layXORToolDialog.h @@ -61,7 +61,7 @@ public: XORToolDialog (QWidget *parent); ~XORToolDialog (); - int exec_dialog (lay::LayoutViewBase *view); + int exec_dialog (lay::LayoutView *view); protected: void accept (); From 8cbb49d5f9fb9249ba10b02abf4aa7935d342af9 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 1 May 2022 17:47:00 +0200 Subject: [PATCH 12/88] WIP --- src/edt/edt/edtInstPropertiesPage.cc | 26 ++--- src/edt/edt/edtPlugin.cc | 17 +-- src/edt/edt/edtPropertiesPages.cc | 10 +- src/lay/lay/layFillDialog.cc | 7 +- src/lay/lay/laySearchReplacePlugin.cc | 4 +- .../laybasic/layBrowseInstancesForm.cc | 20 ++-- src/laybasic/laybasic/layBrowseShapesForm.cc | 9 +- src/laybasic/laybasic/layLayerControlPanel.cc | 29 +---- src/laybasic/laybasic/layLayoutView.cc | 32 ++---- src/laybasic/laybasic/layLayoutView.h | 19 ++-- src/laybasic/laybasic/layLayoutViewBase.cc | 105 ++++++++++++++++-- src/laybasic/laybasic/layLayoutViewBase.h | 34 +++++- .../laybasic/layLayoutViewFunctions.cc | 2 +- .../laybasic/layNetlistBrowserDialog.cc | 13 +-- .../laybasic/rdbMarkerBrowserDialog.cc | 27 ++--- .../lay_plugin/layBooleanOperationsPlugin.cc | 4 +- .../tools/diff/lay_plugin/layDiffPlugin.cc | 4 +- .../lay_plugin/layNetTracerPlugin.cc | 4 +- .../tools/xor/lay_plugin/layXORPlugin.cc | 4 +- 19 files changed, 189 insertions(+), 181 deletions(-) diff --git a/src/edt/edt/edtInstPropertiesPage.cc b/src/edt/edt/edtInstPropertiesPage.cc index a4fe4ac54..51112874f 100644 --- a/src/edt/edt/edtInstPropertiesPage.cc +++ b/src/edt/edt/edtInstPropertiesPage.cc @@ -206,11 +206,8 @@ END_PROTECTED void InstPropertiesPage::show_props () { - lay::LayoutView *lv = dynamic_cast (mp_service->view ()); - tl_assert (lv != 0); - lay::UserPropertiesForm props_form (this); - if (props_form.show (lv, m_selection_ptrs [m_index]->cv_index (), m_prop_id)) { + if (props_form.show (mp_service->view ()->ui (), m_selection_ptrs [m_index]->cv_index (), m_prop_id)) { emit edited (); } } @@ -384,27 +381,21 @@ InstPropertiesPage::update () void InstPropertiesPage::show_cell () { - lay::LayoutView *lv = dynamic_cast (mp_service->view ()); - tl_assert (lv != 0); - edt::Service::obj_iterator pos = m_selection_ptrs [m_index]; - lay::CellView::unspecific_cell_path_type path (lv->cellview (pos->cv_index ()).combined_unspecific_path ()); + lay::CellView::unspecific_cell_path_type path (mp_service->view ()->cellview (pos->cv_index ()).combined_unspecific_path ()); for (lay::ObjectInstPath::iterator p = pos->begin (); p != pos->end (); ++p) { path.push_back (p->inst_ptr.cell_index ()); } - lv->set_current_cell_path (pos->cv_index (), path); + mp_service->view ()->set_current_cell_path (pos->cv_index (), path); } void InstPropertiesPage::show_inst () { - lay::LayoutView *lv = dynamic_cast (mp_service->view ()); - tl_assert (lv != 0); - InstantiationForm inst_form (this); - inst_form.show (lv, *m_selection_ptrs [m_index]); + inst_form.show (mp_service->view ()->ui (), *m_selection_ptrs [m_index]); } bool @@ -852,9 +843,6 @@ InstPropertiesPage::apply_to_all (bool relative) void InstPropertiesPage::update_pcell_parameters () { - lay::LayoutView *lv = dynamic_cast (mp_service->view ()); - tl_assert (lv != 0); - db::Layout *layout; // find the layout the cell has to be looked up: that is either the layout of the current instance or @@ -866,7 +854,7 @@ InstPropertiesPage::update_pcell_parameters () } else { edt::Service::obj_iterator pos = m_selection_ptrs [m_index]; - const lay::CellView &cv = lv->cellview (pos->cv_index ()); + const lay::CellView &cv = mp_service->view ()->cellview (pos->cv_index ()); layout = &cv->layout (); } @@ -890,7 +878,7 @@ InstPropertiesPage::update_pcell_parameters () std::vector parameters; edt::Service::obj_iterator pos = m_selection_ptrs [m_index]; - const lay::CellView &cv = lv->cellview (pos->cv_index ()); + const lay::CellView &cv = mp_service->view ()->cellview (pos->cv_index ()); db::Cell &cell = cv->layout ().cell (pos->cell_index ()); std::pair pci = cell.is_pcell_instance (pos->back ().inst_ptr); const db::Library *pci_lib = cv->layout ().defining_library (pos->back ().inst_ptr.cell_index ()).first; @@ -924,7 +912,7 @@ InstPropertiesPage::update_pcell_parameters () mp_pcell_parameters = new PCellParametersPage (pcell_tab); connect (mp_pcell_parameters, SIGNAL (edited ()), this, SIGNAL (edited ())); - mp_pcell_parameters->setup (lv, pos->cv_index (), layout->pcell_declaration (pc.second), parameters); + mp_pcell_parameters->setup (mp_service->view ()->ui (), pos->cv_index (), layout->pcell_declaration (pc.second), parameters); pcell_tab->layout ()->addWidget (mp_pcell_parameters); } diff --git a/src/edt/edt/edtPlugin.cc b/src/edt/edt/edtPlugin.cc index 518aaa140..a3cb410dc 100644 --- a/src/edt/edt/edtPlugin.cc +++ b/src/edt/edt/edtPlugin.cc @@ -181,12 +181,9 @@ public: virtual void get_editor_options_pages (std::vector &pages, lay::LayoutViewBase *view, lay::Dispatcher *root) const { - lay::LayoutView *lv = dynamic_cast (view); - tl_assert (lv != 0); - if (mp_pages_f != 0) { size_t nstart = pages.size (); - (*mp_pages_f) (pages, lv, root); + (*mp_pages_f) (pages, view->ui (), root); while (nstart < pages.size ()) { pages [nstart++]->set_plugin_declaration (this); } @@ -332,11 +329,8 @@ public: virtual void get_editor_options_pages (std::vector &pages, lay::LayoutViewBase *view, lay::Dispatcher *dispatcher) const { - lay::LayoutView *lv = dynamic_cast (view); - tl_assert (lv != 0); - // NOTE: we do not set plugin_declaration which makes the page unspecific - EditorOptionsGeneric *generic_opt = new EditorOptionsGeneric (lv, dispatcher); + EditorOptionsGeneric *generic_opt = new EditorOptionsGeneric (view->ui (), dispatcher); pages.push_back (generic_opt); } @@ -421,12 +415,7 @@ static tl::RegisteredClass config_decl_main (new edt::Ma void commit_recent (lay::LayoutViewBase *view) { - lay::LayoutView *lv = dynamic_cast (view); - if (!lv) { - return; - } - - lay::EditorOptionsPages *eo_pages = lv->editor_options_pages (); + lay::EditorOptionsPages *eo_pages = view->ui ()->editor_options_pages (); if (!eo_pages) { return; } diff --git a/src/edt/edt/edtPropertiesPages.cc b/src/edt/edt/edtPropertiesPages.cc index 21b3079c9..6f2232da4 100644 --- a/src/edt/edt/edtPropertiesPages.cc +++ b/src/edt/edt/edtPropertiesPages.cc @@ -360,21 +360,15 @@ ShapePropertiesPage::update_shape () void ShapePropertiesPage::show_inst () { - lay::LayoutView *lv = dynamic_cast (mp_service->view ()); - tl_assert (lv != 0); - InstantiationForm inst_form (this); - inst_form.show (lv, *m_selection_ptrs [m_index]); + inst_form.show (mp_service->view ()->ui (), *m_selection_ptrs [m_index]); } void ShapePropertiesPage::show_props () { - lay::LayoutView *lv = dynamic_cast (mp_service->view ()); - tl_assert (lv != 0); - lay::UserPropertiesForm props_form (this); - if (props_form.show (lv, m_selection_ptrs [m_index]->cv_index (), m_prop_id)) { + if (props_form.show (mp_service->view ()->ui (), m_selection_ptrs [m_index]->cv_index (), m_prop_id)) { emit edited (); } } diff --git a/src/lay/lay/layFillDialog.cc b/src/lay/lay/layFillDialog.cc index ec0e30fed..458c90afa 100644 --- a/src/lay/lay/layFillDialog.cc +++ b/src/lay/lay/layFillDialog.cc @@ -316,12 +316,7 @@ FillDialog::get_fill_parameters () } else if (layer_spec_cbx->currentIndex () == 2) { // get selected layers - std::vector s; - - lay::LayoutView *lv = dynamic_cast (mp_view); - if (lv) { - s = lv->selected_layers (); // @@@ should be part of LayoutViewBase too - } + std::vector s = mp_view->selected_layers (); for (std::vector::const_iterator l = s.begin (); l != s.end (); ++l) { if (! (*l)->has_children () && cv->layout ().is_valid_layer ((*l)->layer_index ())) { diff --git a/src/lay/lay/laySearchReplacePlugin.cc b/src/lay/lay/laySearchReplacePlugin.cc index cca26248a..94d53e141 100644 --- a/src/lay/lay/laySearchReplacePlugin.cc +++ b/src/lay/lay/laySearchReplacePlugin.cc @@ -65,9 +65,7 @@ public: virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutViewBase *view) const { - lay::LayoutView *lv = dynamic_cast (view); - tl_assert (lv != 0); - return new SearchReplaceDialog (root, lv); + return new SearchReplaceDialog (root, view->ui ()); } }; diff --git a/src/laybasic/laybasic/layBrowseInstancesForm.cc b/src/laybasic/laybasic/layBrowseInstancesForm.cc index 1d486a42e..cb2e96b01 100644 --- a/src/laybasic/laybasic/layBrowseInstancesForm.cc +++ b/src/laybasic/laybasic/layBrowseInstancesForm.cc @@ -349,12 +349,9 @@ void BrowseInstancesForm::choose_cell_pressed () { BEGIN_PROTECTED - lay::LayoutView *lv = dynamic_cast (view ()); - if (lv) { - CellSelectionForm form (this, lv, "browse_cell", true /*simple mode*/); - if (form.exec ()) { - change_cell (form.selected_cellview ().cell_index (), form.selected_cellview_index ()); - } + CellSelectionForm form (this, view ()->ui (), "browse_cell", true /*simple mode*/); + if (form.exec ()) { + change_cell (form.selected_cellview ().cell_index (), form.selected_cellview_index ()); } END_PROTECTED } @@ -525,21 +522,18 @@ struct BrowseInstancesCellInfo void BrowseInstancesForm::activated () { - lay::LayoutView *lv = dynamic_cast (view ()); - tl_assert (lv != 0); - - lv->save_view (m_display_state); + view ()->save_view (m_display_state); // if no cellviews are available, don't do anything - if (! lv->cellviews ()) { + if (! view ()->cellviews ()) { return; } // obtain active cellview index and cell index - int cv_index = lv->active_cellview_index (); + int cv_index = view ()->active_cellview_index (); lay::LayoutView::cell_path_type path; - lv->current_cell_path (path); + view ()->current_cell_path (path); // no cell to index if (path.empty ()) { diff --git a/src/laybasic/laybasic/layBrowseShapesForm.cc b/src/laybasic/laybasic/layBrowseShapesForm.cc index a31e6ff42..78db4af73 100644 --- a/src/laybasic/laybasic/layBrowseShapesForm.cc +++ b/src/laybasic/laybasic/layBrowseShapesForm.cc @@ -660,12 +660,9 @@ BrowseShapesForm::cell_inst_changed (QTreeWidgetItem *, QTreeWidgetItem *) void BrowseShapesForm::activated () { - lay::LayoutView *lv = dynamic_cast (view ()); - tl_assert (lv != 0); + view ()->save_view (m_display_state); - lv->save_view (m_display_state); - - std::vector sel_layers = lv->selected_layers (); + std::vector sel_layers = view ()->selected_layers (); if (sel_layers.empty ()) { throw tl::Exception (tl::to_string (QObject::tr ("No layer selected"))); @@ -691,7 +688,7 @@ BrowseShapesForm::activated () } } else { m_cv_index = cv_index; - m_cellview = lv->cellview (m_cv_index); + m_cellview = view ()->cellview (m_cv_index); } } diff --git a/src/laybasic/laybasic/layLayerControlPanel.cc b/src/laybasic/laybasic/layLayerControlPanel.cc index 931f5fd1c..1de876250 100644 --- a/src/laybasic/laybasic/layLayerControlPanel.cc +++ b/src/laybasic/laybasic/layLayerControlPanel.cc @@ -444,39 +444,12 @@ void LayerControlPanel::cm_remove_unused () { BEGIN_PROTECTED_CLEANUP - begin_updates (); - transaction (tl::to_string (QObject::tr ("Clean up views"))); - - bool any_deleted; - do { - - std::vector sel; - - lay::LayerPropertiesConstIterator l = mp_view->begin_layers (); - while (! l.at_end ()) { - if (! l->has_children () && l->bbox ().empty ()) { - sel.push_back (l); - } - ++l; - } - - std::sort (sel.begin (), sel.end (), CompareLayerIteratorBottomUp ()); - any_deleted = false; - for (std::vector::iterator s = sel.begin (); s != sel.end (); ++s) { - mp_view->delete_layer (*s); - any_deleted = true; - } - - } while (any_deleted); - + mp_view->remove_unused_layers (); commit (); - end_updates (); - emit order_changed (); - END_PROTECTED_CLEANUP { recover (); } } diff --git a/src/laybasic/laybasic/layLayoutView.cc b/src/laybasic/laybasic/layLayoutView.cc index 95408cdad..d9b0014d9 100644 --- a/src/laybasic/laybasic/layLayoutView.cc +++ b/src/laybasic/laybasic/layLayoutView.cc @@ -656,30 +656,6 @@ LayoutView::set_selected_layers (const std::vectorhas_selection ()) { - const lay::LayerPropertiesList &lp = get_properties (); - lay::LayerPropertiesConstIterator li = lp.begin_const_recursive (); - while (! li.at_end () && li->has_children ()) { - ++li; - } - if (! li.at_end ()) { - mp_control_panel->set_current_layer (li); - } - } -} - -void -LayoutView::remove_unused_layers () -{ - // @@@ should not be in control panel - if (mp_control_panel) { - mp_control_panel->cm_remove_unused (); - } -} - void LayoutView::begin_layer_updates () { @@ -688,6 +664,14 @@ LayoutView::begin_layer_updates () } } +void +LayoutView::end_layer_updates () +{ + if (mp_control_panel) { + mp_control_panel->end_updates (); + } +} + bool LayoutView::layer_model_updated () { diff --git a/src/laybasic/laybasic/layLayoutView.h b/src/laybasic/laybasic/layLayoutView.h index 7b06b183d..1594dfd08 100644 --- a/src/laybasic/laybasic/layLayoutView.h +++ b/src/laybasic/laybasic/layLayoutView.h @@ -273,11 +273,6 @@ public: */ virtual void set_current_cell_path (int cv_index, const cell_path_type &path); - /** - * @brief Remove unused layers - */ - void remove_unused_layers (); - /** * @brief Internal method: check, if the layer tree is and an consistent state. * @@ -416,6 +411,16 @@ public: return mp_editor_options_frame; } + /** + * @brief Gets the QWidget interface + */ + virtual QWidget *widget () { return this; } + + /** + * @brief Gets the LayoutView interface + */ + virtual LayoutView *ui () { return this; } + /** * @brief Copies to clipboard * @@ -740,7 +745,7 @@ protected: virtual void do_set_background_color (lay::Color color, lay::Color contrast); virtual void do_paste (); virtual void begin_layer_updates (); - virtual void ensure_layer_selected (); + virtual void end_layer_updates (); virtual void update_content_for_cv (int cv_index); virtual void do_set_no_stipples (bool no_stipples); virtual void do_set_phase (int phase); @@ -755,8 +760,6 @@ protected: virtual void emit_title_changed (); virtual void emit_dirty_changed (); virtual void emit_layer_order_changed (); - - virtual QWidget *widget () { return this; } }; } diff --git a/src/laybasic/laybasic/layLayoutViewBase.cc b/src/laybasic/laybasic/layLayoutViewBase.cc index 488402a1d..ab539b49f 100644 --- a/src/laybasic/laybasic/layLayoutViewBase.cc +++ b/src/laybasic/laybasic/layLayoutViewBase.cc @@ -1336,6 +1336,8 @@ LayoutViewBase::insert_layer_list (unsigned index, const LayerPropertiesList &pr manager ()->clear (); } + clear_layer_selection (); + m_layer_properties_lists.insert (m_layer_properties_lists.begin () + index, new LayerPropertiesList (props)); m_layer_properties_lists [index]->attach_view (this, index); merge_dither_pattern (*m_layer_properties_lists [index]); @@ -1363,6 +1365,8 @@ LayoutViewBase::delete_layer_list (unsigned index) manager ()->clear (); } + clear_layer_selection (); + delete m_layer_properties_lists [index]; m_layer_properties_lists.erase (m_layer_properties_lists.begin () + index); @@ -1425,20 +1429,44 @@ LayoutViewBase::set_current_layer (unsigned int cv_index, const db::LayerPropert return false; } +void +LayoutViewBase::clear_layer_selection () +{ + m_current_layer = lay::LayerPropertiesConstIterator (); + m_selected_layers.clear (); +} + void LayoutViewBase::set_current_layer (const lay::LayerPropertiesConstIterator &l) { - // @@@ No checking happens m_current_layer = l; + m_selected_layers.clear (); + m_selected_layers.push_back (l); } lay::LayerPropertiesConstIterator LayoutViewBase::current_layer () const { - // @@@ No checking happens return m_current_layer; } +std::vector +LayoutViewBase::selected_layers () const +{ + return m_selected_layers; +} + +void +LayoutViewBase::set_selected_layers (const std::vector &sel) +{ + m_selected_layers = sel; + if (sel.empty ()) { + m_current_layer = lay::LayerPropertiesConstIterator (); + } else { + m_current_layer = sel.front (); + } +} + void LayoutViewBase::merge_dither_pattern (lay::LayerPropertiesList &props) { @@ -1544,13 +1572,10 @@ LayoutViewBase::set_properties (unsigned int index, const LayerPropertiesList &p merge_dither_pattern (*m_layer_properties_lists [index]); if (index == current_layer_list ()) { - + end_layer_updates (); layer_list_changed_event (3); - redraw (); - m_prop_changed = true; - } } @@ -1607,14 +1632,11 @@ LayoutViewBase::replace_layer_node (unsigned int index, const LayerPropertiesCon non_const_iter->attach_view (this, index); if (index == current_layer_list ()) { - + end_layer_updates (); layer_list_changed_event (2); - // TODO: check, if redraw is actually necessary (this is complex!) redraw (); - m_prop_changed = true; - } } } @@ -1681,6 +1703,7 @@ LayoutViewBase::insert_layer (unsigned int index, const LayerPropertiesConstIter // signal to the observers that something has changed if (index == current_layer_list ()) { + end_layer_updates (); layer_list_changed_event (2); redraw (); m_prop_changed = true; @@ -1713,6 +1736,7 @@ LayoutViewBase::delete_layer (unsigned int index, LayerPropertiesConstIterator & // signal to the observers that something has changed if (index == current_layer_list ()) { + end_layer_updates (); layer_list_changed_event (2); redraw (); m_prop_changed = true; @@ -2088,6 +2112,8 @@ LayoutViewBase::erase_cellview (unsigned int index) m_display_states.clear (); m_display_state_ptr = 0; + end_layer_updates (); + // signal to the observers that something has changed layer_list_changed_event (3); @@ -3178,6 +3204,20 @@ LayoutViewBase::box () const return mp_canvas->viewport ().box (); } +#if defined(HAVE_QT) +QWidget * +LayoutViewBase::widget () +{ + tl_assert (false); +} +#endif + +LayoutView * +LayoutViewBase::ui () +{ + tl_assert (false); +} + // @@@ needs to be called "as often as possible" void LayoutViewBase::timer () @@ -4836,6 +4876,34 @@ LayoutViewBase::cut () lay::Editables::cut (); } +void +LayoutViewBase::remove_unused_layers () +{ + bool any_deleted; + do { + + std::vector sel; + + lay::LayerPropertiesConstIterator l = begin_layers (); + while (! l.at_end ()) { + if (! l->has_children () && l->bbox ().empty ()) { + sel.push_back (l); + } + ++l; + } + + std::sort (sel.begin (), sel.end (), CompareLayerIteratorBottomUp ()); + any_deleted = false; + for (std::vector::iterator s = sel.begin (); s != sel.end (); ++s) { + delete_layer (*s); + any_deleted = true; + } + + } while (any_deleted); + + emit_layer_order_changed (); +} + void LayoutViewBase::add_missing_layers () { @@ -4992,11 +5060,26 @@ LayoutViewBase::begin_layer_updates () } void -LayoutViewBase::ensure_layer_selected () +LayoutViewBase::end_layer_updates () { // .. nothing yet .. } +void +LayoutViewBase::ensure_layer_selected () +{ + if (current_layer () == lay::LayerPropertiesConstIterator ()) { + const lay::LayerPropertiesList &lp = get_properties (); + lay::LayerPropertiesConstIterator li = lp.begin_const_recursive (); + while (! li.at_end () && li->has_children ()) { + ++li; + } + if (! li.at_end ()) { + set_current_layer (li); + } + } +} + void LayoutViewBase::do_set_no_stipples (bool /*no_stipples*/) { diff --git a/src/laybasic/laybasic/layLayoutViewBase.h b/src/laybasic/laybasic/layLayoutViewBase.h index 50346e6a7..9b8d0d67c 100644 --- a/src/laybasic/laybasic/layLayoutViewBase.h +++ b/src/laybasic/laybasic/layLayoutViewBase.h @@ -70,6 +70,7 @@ namespace db { namespace lay { +class LayoutView; class MouseTracker; class ZoomService; class SelectionService; @@ -551,6 +552,18 @@ public: */ virtual lay::LayerPropertiesConstIterator current_layer () const; + /** + * @brief Return the layers that are selected in the layer browser + * + * Returns an empty list if no layer is selected. + */ + virtual std::vector selected_layers () const; + + /** + * @brief Sets the layers that are selected in the layer browser + */ + virtual void set_selected_layers (const std::vector &sel); + /** * @brief Set the custom dither pattern */ @@ -2168,6 +2181,11 @@ public: */ void add_missing_layers (); + /** + * @brief Remove unused layers + */ + void remove_unused_layers (); + /** * @brief Add layers which are not part of the LayerState */ @@ -2484,9 +2502,17 @@ public: virtual void deactivate_all_browsers (); #if defined(HAVE_QT) - virtual QWidget *widget () { return 0; } + /** + * @brief Gets the QWidget interface + */ + virtual QWidget *widget (); #endif + /** + * @brief Gets the LayoutView interface + */ + virtual LayoutView *ui (); + private: // event handlers used to connect to the layout object's events void signal_hier_changed (); @@ -2613,6 +2639,7 @@ private: std::set m_active_cellview_changed_events; lay::LayerPropertiesConstIterator m_current_layer; + std::vector m_selected_layers; std::vector m_current_cell_per_cellview; @@ -2676,7 +2703,8 @@ protected: virtual void do_set_background_color (lay::Color color, lay::Color contrast); virtual void do_paste (); virtual void begin_layer_updates (); - virtual void ensure_layer_selected (); + virtual void end_layer_updates (); + virtual void clear_layer_selection (); virtual void do_set_no_stipples (bool no_stipples); virtual void do_set_phase (int phase); virtual bool is_activated () const; @@ -2684,6 +2712,8 @@ protected: virtual void update_content_for_cv (int cv_index); virtual bool set_hier_levels_basic (std::pair l); + void ensure_layer_selected (); + void enable_active_cellview_changed_event (bool enable, bool silent = false); void active_cellview_changed (int index); diff --git a/src/laybasic/laybasic/layLayoutViewFunctions.cc b/src/laybasic/laybasic/layLayoutViewFunctions.cc index 65188d4de..724e8c137 100644 --- a/src/laybasic/laybasic/layLayoutViewFunctions.cc +++ b/src/laybasic/laybasic/layLayoutViewFunctions.cc @@ -78,7 +78,7 @@ validate_cell_path (const db::Layout &layout, lay::LayoutView::cell_path_type &p } LayoutViewFunctions::LayoutViewFunctions (db::Manager *manager, LayoutViewBase *view) - : lay::Plugin (view), mp_view (dynamic_cast (view)), mp_manager (manager) + : lay::Plugin (view), mp_view (view->ui ()), mp_manager (manager) { m_del_cell_mode = 0; m_move_to_origin_mode_x = 0; diff --git a/src/laybasic/laybasic/layNetlistBrowserDialog.cc b/src/laybasic/laybasic/layNetlistBrowserDialog.cc index b294befc6..577865a3b 100644 --- a/src/laybasic/laybasic/layNetlistBrowserDialog.cc +++ b/src/laybasic/laybasic/layNetlistBrowserDialog.cc @@ -729,22 +729,19 @@ NetlistBrowserDialog::cv_index_changed (int index) void NetlistBrowserDialog::activated () { - lay::LayoutView *lv = dynamic_cast (view ()); - tl_assert (lv != 0); - std::string state; - lv->config_get (cfg_l2ndb_window_state, state); + view ()->config_get (cfg_l2ndb_window_state, state); lay::restore_dialog_state (this, state, false /*don't adjust the section sizes*/); // Switch to the active cellview index when no valid one is set. - lay::CellView cv = lv->cellview (m_cv_index); + lay::CellView cv = view ()->cellview (m_cv_index); if (! cv.is_valid ()) { - m_cv_index = lv->active_cellview_index (); + m_cv_index = view ()->active_cellview_index (); } - if (m_l2n_index < 0 && lv->get_l2ndb (0) != 0) { + if (m_l2n_index < 0 && view ()->get_l2ndb (0) != 0) { - m_l2ndb_name = lv->get_l2ndb (0)->name (); + m_l2ndb_name = view ()->get_l2ndb (0)->name (); l2ndbs_changed (); } else { diff --git a/src/laybasic/laybasic/rdbMarkerBrowserDialog.cc b/src/laybasic/laybasic/rdbMarkerBrowserDialog.cc index a7caa9026..51b93ae88 100644 --- a/src/laybasic/laybasic/rdbMarkerBrowserDialog.cc +++ b/src/laybasic/laybasic/rdbMarkerBrowserDialog.cc @@ -635,22 +635,19 @@ MarkerBrowserDialog::cv_index_changed (int index) void MarkerBrowserDialog::activated () { - lay::LayoutView *lv = dynamic_cast (view ()); - tl_assert (lv != 0); - std::string state; - lv->config_get (cfg_rdb_window_state, state); + view ()->config_get (cfg_rdb_window_state, state); lay::restore_dialog_state (this, state); // Switch to the active cellview index when no valid one is set. - lay::CellView cv = lv->cellview (m_cv_index); + lay::CellView cv = view ()->cellview (m_cv_index); if (! cv.is_valid ()) { - m_cv_index = lv->active_cellview_index (); + m_cv_index = view ()->active_cellview_index (); } - if (m_rdb_index < 0 && lv->get_rdb (0) != 0) { + if (m_rdb_index < 0 && view ()->get_rdb (0) != 0) { - m_rdb_name = lv->get_rdb (0)->name (); + m_rdb_name = view ()->get_rdb (0)->name (); rdbs_changed (); } else { @@ -717,10 +714,7 @@ MarkerBrowserDialog::deactivated () void MarkerBrowserDialog::scan_layer () { - lay::LayoutView *lv = dynamic_cast (view ()); - tl_assert (lv != 0); - - std::vector layers = lv->selected_layers (); + std::vector layers = view ()->selected_layers (); if (layers.empty ()) { throw tl::Exception (tl::to_string (QObject::tr ("No layer selected to get shapes from"))); } @@ -812,16 +806,13 @@ MarkerBrowserDialog::scan_layer () } unsigned int rdb_index = view ()->add_rdb (rdb.release ()); - lv->open_rdb_browser (rdb_index, cv_index); + view ()->ui ()->open_rdb_browser (rdb_index, cv_index); } void MarkerBrowserDialog::scan_layer_flat () { - lay::LayoutView *lv = dynamic_cast (view ()); - tl_assert (lv != 0); - - std::vector layers = lv->selected_layers (); + std::vector layers = view ()->selected_layers (); if (layers.empty ()) { throw tl::Exception (tl::to_string (QObject::tr ("No layer selected to get shapes from"))); } @@ -891,7 +882,7 @@ MarkerBrowserDialog::scan_layer_flat () } unsigned int rdb_index = view ()->add_rdb (rdb.release ()); - lv->open_rdb_browser (rdb_index, cv_index); + view ()->ui ()->open_rdb_browser (rdb_index, cv_index); } void diff --git a/src/plugins/tools/bool/lay_plugin/layBooleanOperationsPlugin.cc b/src/plugins/tools/bool/lay_plugin/layBooleanOperationsPlugin.cc index 892c78351..af7c219bd 100644 --- a/src/plugins/tools/bool/lay_plugin/layBooleanOperationsPlugin.cc +++ b/src/plugins/tools/bool/lay_plugin/layBooleanOperationsPlugin.cc @@ -496,9 +496,7 @@ public: lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutViewBase *view) const { - lay::LayoutView *lv = dynamic_cast (view); - tl_assert (lv != 0); - return new BooleanOperationsPlugin (root, lv); + return new BooleanOperationsPlugin (root, view->ui ()); } }; diff --git a/src/plugins/tools/diff/lay_plugin/layDiffPlugin.cc b/src/plugins/tools/diff/lay_plugin/layDiffPlugin.cc index b44dfa780..8486c8155 100644 --- a/src/plugins/tools/diff/lay_plugin/layDiffPlugin.cc +++ b/src/plugins/tools/diff/lay_plugin/layDiffPlugin.cc @@ -105,9 +105,7 @@ public: lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutViewBase *view) const { - lay::LayoutView *lv = dynamic_cast (view); - tl_assert (lv != 0); - return new DiffPlugin (root, lv); + return new DiffPlugin (root, view->ui ()); } }; diff --git a/src/plugins/tools/net_tracer/lay_plugin/layNetTracerPlugin.cc b/src/plugins/tools/net_tracer/lay_plugin/layNetTracerPlugin.cc index 409e0a71e..27400f4dd 100644 --- a/src/plugins/tools/net_tracer/lay_plugin/layNetTracerPlugin.cc +++ b/src/plugins/tools/net_tracer/lay_plugin/layNetTracerPlugin.cc @@ -78,9 +78,7 @@ public: virtual lay::Plugin *create_plugin (db::Manager * /*manager*/, lay::Dispatcher *root, lay::LayoutViewBase *view) const { - lay::LayoutView *lv = dynamic_cast (view); - tl_assert (lv != 0); - return new NetTracerDialog (root, lv); + return new NetTracerDialog (root, view->ui ()); } }; diff --git a/src/plugins/tools/xor/lay_plugin/layXORPlugin.cc b/src/plugins/tools/xor/lay_plugin/layXORPlugin.cc index 14864a9d9..262969a59 100644 --- a/src/plugins/tools/xor/lay_plugin/layXORPlugin.cc +++ b/src/plugins/tools/xor/lay_plugin/layXORPlugin.cc @@ -113,9 +113,7 @@ public: lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutViewBase *view) const { - lay::LayoutView *lv = dynamic_cast (view); - tl_assert (lv != 0); - return new XORPlugin (root, lv); + return new XORPlugin (root, view->ui ()); } }; From 0a804f2e32c8d11ad3a39d8808669e63cd130658 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 1 May 2022 19:29:20 +0200 Subject: [PATCH 13/88] WIP --- src/laybasic/laybasic/layBitmapsToImage.cc | 8 +- src/laybasic/laybasic/layBitmapsToImage.h | 6 +- src/laybasic/laybasic/layConverters.h | 8 +- src/laybasic/laybasic/layFinder.cc | 8 +- src/laybasic/laybasic/layGridNet.cc | 43 +++-- src/laybasic/laybasic/layGridNet.h | 19 ++- src/laybasic/laybasic/layLayerProperties.cc | 2 +- src/laybasic/laybasic/layLayoutCanvas.cc | 72 +++++++-- src/laybasic/laybasic/layLayoutCanvas.h | 15 +- src/laybasic/laybasic/layLayoutView.cc | 24 +++ src/laybasic/laybasic/layLayoutView.h | 34 ++++ src/laybasic/laybasic/layLayoutViewBase.cc | 20 +-- src/laybasic/laybasic/layLayoutViewBase.h | 1 - src/laybasic/laybasic/layLineStylePalette.cc | 6 +- src/laybasic/laybasic/layLineStyles.cc | 27 +++- src/laybasic/laybasic/layMarker.cc | 28 ++-- src/laybasic/laybasic/layMove.cc | 2 + src/laybasic/laybasic/layNetColorizer.cc | 153 ++++++++++++++++++ src/laybasic/laybasic/layNetColorizer.h | 85 ++++++++++ .../laybasic/layNetlistBrowserModel.cc | 123 -------------- .../laybasic/layNetlistBrowserModel.h | 43 +---- src/laybasic/laybasic/layObjectInstPath.h | 2 - src/laybasic/laybasic/layParsedLayerSource.cc | 4 +- src/laybasic/laybasic/layPlugin.cc | 15 +- src/laybasic/laybasic/layPlugin.h | 4 +- src/laybasic/laybasic/layRedrawThread.cc | 9 +- src/laybasic/laybasic/layRedrawThread.h | 9 +- .../laybasic/layRedrawThreadCanvas.cc | 6 + src/laybasic/laybasic/layRedrawThreadCanvas.h | 11 +- .../laybasic/layRedrawThreadWorker.cc | 18 +-- src/laybasic/laybasic/laySnap.cc | 2 + src/laybasic/laybasic/layStipplePalette.cc | 6 +- src/laybasic/laybasic/layViewObject.cc | 92 +++++++++-- src/laybasic/laybasic/layViewObject.h | 46 ++++-- src/laybasic/laybasic/laybasic.pro | 22 +-- .../unit_tests/layAbstractMenuTests.cc | 3 + src/laybasic/unit_tests/layBitmapsToImage.cc | 3 +- .../layNetlistBrowserTreeModelTests.cc | 4 + 38 files changed, 651 insertions(+), 332 deletions(-) create mode 100644 src/laybasic/laybasic/layNetColorizer.cc create mode 100644 src/laybasic/laybasic/layNetColorizer.h diff --git a/src/laybasic/laybasic/layBitmapsToImage.cc b/src/laybasic/laybasic/layBitmapsToImage.cc index f3587e08e..13403920b 100644 --- a/src/laybasic/laybasic/layBitmapsToImage.cc +++ b/src/laybasic/laybasic/layBitmapsToImage.cc @@ -386,7 +386,7 @@ render_scanline_cross (const uint32_t *dp, unsigned int ds, const lay::Bitmap *p } } -static void create_precursor_bitmaps (const std::vector &view_ops_in, const std::vector &vo_map, const std::vector &pbitmaps_in, const std::vector &bm_map, const lay::LineStyles &ls, unsigned int width, unsigned int height, std::map &precursors, QMutex *mutex) +static void create_precursor_bitmaps (const std::vector &view_ops_in, const std::vector &vo_map, const std::vector &pbitmaps_in, const std::vector &bm_map, const lay::LineStyles &ls, unsigned int width, unsigned int height, std::map &precursors, tl::Mutex *mutex) { tl_assert (bm_map.size () == vo_map.size ()); @@ -430,7 +430,7 @@ bitmaps_to_image_rgb (const std::vector &view_ops_in, QImage *pimage, unsigned int width, unsigned int height, bool use_bitmap_index, bool transparent, - QMutex *mutex) + tl::Mutex *mutex) { std::vector bm_map; std::vector vo_map; @@ -668,7 +668,7 @@ bitmaps_to_image_mono (const std::vector &view_ops_in, const lay::LineStyles &ls, QImage *pimage, unsigned int width, unsigned int height, bool use_bitmap_index, - QMutex *mutex) + tl::Mutex *mutex) { std::vector bm_map; std::vector vo_map; @@ -873,7 +873,7 @@ bitmaps_to_image (const std::vector &view_ops_in, const lay::LineStyles &ls, QImage *pimage, unsigned int width, unsigned int height, bool use_bitmap_index, - QMutex *mutex) + tl::Mutex *mutex) { if (pimage->depth () <= 1) { bitmaps_to_image_mono (view_ops_in, pbitmaps_in, dp, ls, pimage, width, height, use_bitmap_index, mutex); diff --git a/src/laybasic/laybasic/layBitmapsToImage.h b/src/laybasic/laybasic/layBitmapsToImage.h index 88930dca3..411369705 100644 --- a/src/laybasic/laybasic/layBitmapsToImage.h +++ b/src/laybasic/laybasic/layBitmapsToImage.h @@ -25,10 +25,10 @@ #define HDR_layBitmapsToImage #include "layViewOp.h" +#include "tlThreads.h" #include -class QMutex; class QImage; namespace lay @@ -46,7 +46,7 @@ class Bitmap; * with the given width and height. * The "view_ops" and "pbitmaps" vectors must have the same size. * The QImage must be initialized to the given width and height. - * If the QMutex pointer is not 0, the mutex is locked between operations + * If the tl::Mutex pointer is not 0, the mutex is locked between operations * if the bitmap is accessed. The set of dither pattern specifies any custom * pattern that are used bz the view operands. * The "use_bitmap_index" parameter specifies whether the bitmap_index @@ -60,7 +60,7 @@ bitmaps_to_image (const std::vector &view_ops, const lay::LineStyles &ls, QImage *pimage, unsigned int width, unsigned int height, bool use_bitmap_index, - QMutex *mutex); + tl::Mutex *mutex); /** * @brief Convert a lay::Bitmap to a unsigned char * data field to be passed to QBitmap diff --git a/src/laybasic/laybasic/layConverters.h b/src/laybasic/laybasic/layConverters.h index 8965fc369..472b22026 100644 --- a/src/laybasic/laybasic/layConverters.h +++ b/src/laybasic/laybasic/layConverters.h @@ -27,7 +27,9 @@ #include "laybasicCommon.h" #include "layColor.h" -#include +#if defined(HAVE_QT) +# include +#endif namespace lay { @@ -37,9 +39,11 @@ namespace lay */ struct LAYBASIC_PUBLIC ColorConverter { +#if defined(HAVE_QT) std::string to_string (const QColor &c) const; - std::string to_string (const lay::Color &c) const; void from_string (const std::string &s, QColor &c) const; +#endif + std::string to_string (const lay::Color &c) const; void from_string (const std::string &s, lay::Color &c) const; }; diff --git a/src/laybasic/laybasic/layFinder.cc b/src/laybasic/laybasic/layFinder.cc index 7bd3dac16..214705fc4 100644 --- a/src/laybasic/laybasic/layFinder.cc +++ b/src/laybasic/laybasic/layFinder.cc @@ -267,7 +267,7 @@ struct LPContextCompareOp bool ShapeFinder::find (LayoutViewBase *view, const db::DBox ®ion_mu) { - tl::AbsoluteProgress progress (tl::to_string (QObject::tr ("Selecting ..."))); + tl::AbsoluteProgress progress (tl::to_string (tr ("Selecting ..."))); progress.set_unit (1000); progress.set_format (""); mp_progress = &progress; @@ -332,7 +332,7 @@ ShapeFinder::find (LayoutViewBase *view, const db::DBox ®ion_mu) bool ShapeFinder::find (lay::LayoutViewBase *view, const lay::LayerProperties &lprops, const db::DBox ®ion_mu) { - tl::AbsoluteProgress progress (tl::to_string (QObject::tr ("Selecting ..."))); + tl::AbsoluteProgress progress (tl::to_string (tr ("Selecting ..."))); progress.set_unit (1000); progress.set_format (""); mp_progress = &progress; @@ -626,7 +626,7 @@ InstFinder::InstFinder (bool point_mode, bool top_level_sel, bool full_arrays, b bool InstFinder::find (lay::LayoutViewBase *view, const db::DBox ®ion_mu) { - tl::AbsoluteProgress progress (tl::to_string (QObject::tr ("Selecting ..."))); + tl::AbsoluteProgress progress (tl::to_string (tr ("Selecting ..."))); progress.set_unit (1000); progress.set_format (""); mp_progress = &progress; @@ -643,7 +643,7 @@ InstFinder::find (lay::LayoutViewBase *view, const db::DBox ®ion_mu) bool InstFinder::find (LayoutViewBase *view, unsigned int cv_index, const db::DCplxTrans &trans_mu, const db::DBox ®ion_mu) { - tl::AbsoluteProgress progress (tl::to_string (QObject::tr ("Selecting ..."))); + tl::AbsoluteProgress progress (tl::to_string (tr ("Selecting ..."))); progress.set_unit (1000); progress.set_format (""); mp_progress = &progress; diff --git a/src/laybasic/laybasic/layGridNet.cc b/src/laybasic/laybasic/layGridNet.cc index f7f205ad1..47fc79b81 100644 --- a/src/laybasic/laybasic/layGridNet.cc +++ b/src/laybasic/laybasic/layGridNet.cc @@ -23,13 +23,17 @@ #include "laybasicConfig.h" #include "layGridNet.h" -#include "layWidgets.h" +#if defined(HAVE_QT) // @@@ +# include "layWidgets.h" +#endif #include "layLayoutView.h" #include "layConverters.h" #include "layFixedFont.h" #include "laySnap.h" #include "dbTrans.h" -#include "ui_GridNetConfigPage.h" +#if defined(HAVE_QT) // @@@ +# include "ui_GridNetConfigPage.h" +#endif namespace lay { @@ -64,7 +68,7 @@ public: return; } } - throw tl::Exception (tl::to_string (QObject::tr ("Invalid grid net style: ")) + value); + throw tl::Exception (tl::to_string (tr ("Invalid grid net style: ")) + value); } std::string @@ -97,12 +101,14 @@ GridNetPluginDeclaration::get_options (std::vector < std::pair config_decl (new GridNetPlugi // ------------------------------------------------------------ // Implementation of the configuration page +#if defined(HAVE_QT) GridNetConfigPage::GridNetConfigPage (QWidget *parent) : lay::ConfigPage (parent) { @@ -188,6 +195,7 @@ GridNetConfigPage::commit (lay::Dispatcher *root) root->config_set (cfg_grid_style1, lay::GridNet::GridStyle (mp_ui->style1_cbx->currentIndex ()), GridNetStyleConverter ()); root->config_set (cfg_grid_style2, lay::GridNet::GridStyle (mp_ui->style2_cbx->currentIndex ()), GridNetStyleConverter ()); } +#endif // ------------------------------------------------------------ // Implementation of the GridNet object @@ -210,25 +218,25 @@ GridNet::configure (const std::string &name, const std::string &value) if (name == cfg_grid_color) { - QColor color; + lay::Color color; ColorConverter ().from_string (value, color); need_update = test_and_set (m_color, color); } else if (name == cfg_grid_grid_color) { - QColor color; + lay::Color color; ColorConverter ().from_string (value, color); need_update = test_and_set (m_grid_color, color); } else if (name == cfg_grid_axis_color) { - QColor color; + lay::Color color; ColorConverter ().from_string (value, color); need_update = test_and_set (m_axis_color, color); } else if (name == cfg_grid_ruler_color) { - QColor color; + lay::Color color; ColorConverter ().from_string (value, color); need_update = test_and_set (m_ruler_color, color); @@ -283,7 +291,7 @@ GridNet::configure (const std::string &name, const std::string &value) return taken; } - +#if defined(HAVE_QT) // @@@ class ImagePainter { public: @@ -427,27 +435,28 @@ private: double m_resolution; int m_width, m_height; }; +#endif void GridNet::render_bg (const lay::Viewport &vp, ViewObjectCanvas &canvas) { if (m_visible) { - QColor color; - if (m_color.isValid ()) { + lay::Color color; + if (m_color.is_valid ()) { color = m_color; } else { - color = QColor (128, 128, 128); // TODO: this is not a "real" automatic color .. + color = lay::Color (128, 128, 128); // TODO: this is not a "real" automatic color .. } - QColor grid_color = color, axis_color = color, ruler_color = color; - if (m_grid_color.isValid ()) { + lay::Color grid_color = color, axis_color = color, ruler_color = color; + if (m_grid_color.is_valid ()) { grid_color = m_grid_color; } - if (m_axis_color.isValid ()) { + if (m_axis_color.is_valid ()) { axis_color = m_axis_color; } - if (m_ruler_color.isValid ()) { + if (m_ruler_color.is_valid ()) { ruler_color = m_ruler_color; } @@ -457,6 +466,7 @@ GridNet::render_bg (const lay::Viewport &vp, ViewObjectCanvas &canvas) return; } +#if defined(HAVE_QT) // @@@ ImagePainter painter (*bmp_canvas); db::DCplxTrans trans = vp.trans (); @@ -769,11 +779,10 @@ GridNet::render_bg (const lay::Viewport &vp, ViewObjectCanvas &canvas) } } +#endif } - } - } // namespace lay diff --git a/src/laybasic/laybasic/layGridNet.h b/src/laybasic/laybasic/layGridNet.h index 0a7ab5d95..011091d6e 100644 --- a/src/laybasic/laybasic/layGridNet.h +++ b/src/laybasic/laybasic/layGridNet.h @@ -26,7 +26,10 @@ #include "layViewObject.h" #include "layPlugin.h" -#include "layPluginConfigPage.h" +#if defined(HAVE_QT) +# include "layPluginConfigPage.h" +#endif +#include "layColor.h" #include "dbTypes.h" #include "dbBox.h" @@ -44,11 +47,14 @@ class GridNetPluginDeclaration { public: virtual void get_options (std::vector < std::pair > &options) const; +#if defined(HAVE_QT) virtual lay::ConfigPage *config_page (QWidget *parent, std::string &title) const; +#endif virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *, lay::LayoutViewBase *view) const; }; -class GridNetConfigPage +#if defined(HAVE_QT) // @@@ +class GridNetConfigPage : public lay::ConfigPage { Q_OBJECT @@ -67,6 +73,7 @@ private: lay::ColorButton *mp_grid_axis_color_cbtn; lay::ColorButton *mp_grid_ruler_color_cbtn; }; +#endif class GridNet : public lay::BackgroundViewObject, @@ -95,10 +102,10 @@ private: bool m_visible; bool m_show_ruler; double m_grid; - QColor m_color; - QColor m_grid_color; - QColor m_axis_color; - QColor m_ruler_color; + lay::Color m_color; + lay::Color m_grid_color; + lay::Color m_axis_color; + lay::Color m_ruler_color; GridStyle m_style0; GridStyle m_style1; GridStyle m_style2; diff --git a/src/laybasic/laybasic/layLayerProperties.cc b/src/laybasic/laybasic/layLayerProperties.cc index a6cdd3726..75aed4563 100644 --- a/src/laybasic/laybasic/layLayerProperties.cc +++ b/src/laybasic/laybasic/layLayerProperties.cc @@ -439,7 +439,7 @@ public: void execute (const tl::ExpressionParserContext &context, tl::Variant &out, const std::vector &vv) const { if (vv.size () != 0) { - throw tl::EvalError (tl::to_string (QObject::tr ("Layer source function must not have arguments")), context); + throw tl::EvalError (tl::to_string (tr ("Layer source function must not have arguments")), context); } out = tl::Variant (); diff --git a/src/laybasic/laybasic/layLayoutCanvas.cc b/src/laybasic/laybasic/layLayoutCanvas.cc index 6e60f4a2f..e13a125fb 100644 --- a/src/laybasic/laybasic/layLayoutCanvas.cc +++ b/src/laybasic/laybasic/layLayoutCanvas.cc @@ -20,14 +20,15 @@ */ - -#include -#include -#include -#include -#include -#include -#include +#if defined(HAVE_QT) +# include +# include +# include +# include +# include +# include +# include +#endif #include "tlTimer.h" #include "tlLog.h" @@ -36,9 +37,13 @@ #include "layRedrawThread.h" #include "layLayoutView.h" #include "layMarker.h" -#include "gtf.h" +#if defined(HAVE_QT) // @@@ +# include "gtf.h" +#endif +#if defined(HAVE_QT) // @@@ #include "layBitmapsToImage.h" +#endif #include #include @@ -131,6 +136,7 @@ std::string ImageCacheEntry::to_string () const // ---------------------------------------------------------------------------- +#if defined(HAVE_QT) // @@@ static void blowup (const QImage &src, QImage &dest, unsigned int os) { @@ -273,7 +279,9 @@ invert (unsigned char *data, unsigned int width, unsigned int height) } } } +#endif +#if defined(HAVE_QT) // @@@ LayoutCanvas::LayoutCanvas (QWidget *parent, lay::LayoutViewBase *view, const char *name) : lay::ViewObjectWidget (parent, name), mp_view (view), @@ -288,6 +296,22 @@ LayoutCanvas::LayoutCanvas (QWidget *parent, lay::LayoutViewBase *view, const ch m_do_update_image_dm (this, &LayoutCanvas::do_update_image), m_do_end_of_drawing_dm (this, &LayoutCanvas::do_end_of_drawing), m_image_cache_size (1) +#else +LayoutCanvas::LayoutCanvas (lay::LayoutViewBase *view) + : lay::ViewObjectWidget (), + mp_view (view), +// @@@ mp_image (0), mp_image_bg (0), mp_pixmap (0), + m_background (0), m_foreground (0), m_active (0), + m_oversampling (1), + m_dpr (1), + m_need_redraw (false), + m_redraw_clearing (false), + m_redraw_force_update (true), + m_update_image (true), + m_do_update_image_dm (this, &LayoutCanvas::do_update_image), + m_do_end_of_drawing_dm (this, &LayoutCanvas::do_end_of_drawing), + m_image_cache_size (1) +#endif { #if QT_VERSION > 0x050000 m_dpr = devicePixelRatio (); @@ -302,11 +326,13 @@ LayoutCanvas::LayoutCanvas (QWidget *parent, lay::LayoutViewBase *view, const ch mp_redraw_thread = new lay::RedrawThread (this, view); +#if defined(HAVE_QT) // @@@ setBackgroundRole (QPalette::NoRole); set_colors (lay::Color (palette ().color (QPalette::Normal, QPalette::Window).rgb ()), lay::Color (palette ().color (QPalette::Normal, QPalette::Text).rgb ()), lay::Color (palette ().color (QPalette::Normal, QPalette::Mid).rgb ())); setAttribute (Qt::WA_NoSystemBackground); +#endif } LayoutCanvas::~LayoutCanvas () @@ -314,6 +340,7 @@ LayoutCanvas::~LayoutCanvas () // Detach all listeners so we don't trigger events in the destructor viewport_changed_event.clear (); +#if defined(HAVE_QT) // @@@ if (mp_image) { delete mp_image; mp_image = 0; @@ -326,6 +353,7 @@ LayoutCanvas::~LayoutCanvas () delete mp_pixmap; mp_pixmap = 0; } +#endif if (mp_redraw_thread) { delete mp_redraw_thread; mp_redraw_thread = 0; @@ -337,6 +365,7 @@ LayoutCanvas::~LayoutCanvas () void LayoutCanvas::key_event (unsigned int key, unsigned int buttons) { +#if defined(HAVE_QT) // @@@ if (! (buttons & lay::ShiftButton)) { if (int (key) == Qt::Key_Down) { emit down_arrow_key_pressed (); @@ -358,6 +387,7 @@ LayoutCanvas::key_event (unsigned int key, unsigned int buttons) emit right_arrow_key_pressed_with_shift (); } } +#endif } void @@ -385,10 +415,12 @@ LayoutCanvas::set_colors (lay::Color background, lay::Color foreground, lay::Col m_active = active.rgb (); // force regeneration of background image .. +#if defined(HAVE_QT) // @@@ if (mp_image_bg) { delete mp_image_bg; } mp_image_bg = 0; +#endif update_image (); } @@ -427,6 +459,7 @@ LayoutCanvas::prepare_drawing () BitmapViewObjectCanvas::set_size (m_viewport_l.width (), m_viewport_l.height (), 1.0 / double (m_oversampling * m_dpr)); +#if defined(HAVE_QT) // @@@ if (! mp_image || (unsigned int) mp_image->width () != m_viewport_l.width () || (unsigned int) mp_image->height () != m_viewport_l.height ()) { @@ -444,6 +477,7 @@ LayoutCanvas::prepare_drawing () } mp_image->fill (m_background); +#endif // Cancel any pending "finish" event so there is no race between finish and restart (important for caching) m_do_end_of_drawing_dm.cancel (); @@ -546,12 +580,15 @@ LayoutCanvas::update_image () void LayoutCanvas::free_resources () { +#if defined(HAVE_QT) // @@@ if (mp_pixmap) { delete mp_pixmap; mp_pixmap = 0; } +#endif } +#if defined(HAVE_QT) // @@@ void LayoutCanvas::paintEvent (QPaintEvent *) { @@ -692,7 +729,9 @@ LayoutCanvas::paintEvent (QPaintEvent *) } } +#endif +#if defined(HAVE_QT) // @@@ class DetachedViewObjectCanvas : public BitmapViewObjectCanvas { @@ -769,14 +808,18 @@ private: QImage *mp_image_l; double m_gamma; }; +#endif +#if defined(HAVE_QT) // @@@ QImage LayoutCanvas::image (unsigned int width, unsigned int height) { return image_with_options (width, height, -1, -1, -1.0, lay::Color (), lay::Color (), lay::Color (), db::DBox (), false); } +#endif -QImage +#if defined(HAVE_QT) // @@@ +QImage LayoutCanvas::image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, lay::Color background, lay::Color foreground, lay::Color active, const db::DBox &target_box, bool is_mono) { if (oversampling <= 0) { @@ -866,8 +909,10 @@ LayoutCanvas::image_with_options (unsigned int width, unsigned int height, int l return img; } +#endif -QImage +#if defined(HAVE_QT) // @@@ +QImage LayoutCanvas::screenshot () { // if required, start the redraw thread .. @@ -896,7 +941,9 @@ LayoutCanvas::screenshot () return img; } +#endif +#if defined(HAVE_QT) void LayoutCanvas::resizeEvent (QResizeEvent *) { @@ -910,6 +957,7 @@ LayoutCanvas::resizeEvent (QResizeEvent *) do_redraw_all (true); viewport_changed_event (); } +#endif void LayoutCanvas::update_viewport () @@ -979,6 +1027,7 @@ LayoutCanvas::do_update_image () update_image (); } +#if defined(HAVE_QT) // @@@ bool LayoutCanvas::event (QEvent *e) { @@ -997,6 +1046,7 @@ LayoutCanvas::event (QEvent *e) return QWidget::event (e); } } +#endif void LayoutCanvas::redraw_all () diff --git a/src/laybasic/laybasic/layLayoutCanvas.h b/src/laybasic/laybasic/layLayoutCanvas.h index de403bc88..c4a8fb8c4 100644 --- a/src/laybasic/laybasic/layLayoutCanvas.h +++ b/src/laybasic/laybasic/layLayoutCanvas.h @@ -29,8 +29,6 @@ #include #include -#include - #include "dbTrans.h" #include "dbBox.h" #include "layViewport.h" @@ -43,6 +41,7 @@ #include "layRedrawThreadCanvas.h" #include "layRedrawLayerInfo.h" #include "tlDeferredExecution.h" +#include "tlThreads.h" namespace lay { @@ -146,7 +145,7 @@ public: #if defined(HAVE_QT) LayoutCanvas (QWidget *parent, lay::LayoutViewBase *view, const char *name = "canvas"); #else - LayoutCanvas (lay::LayoutViewBase *view, const char *name = "canvas"); + LayoutCanvas (lay::LayoutViewBase *view); #endif ~LayoutCanvas (); @@ -171,9 +170,11 @@ public: return m_view_ops; } +#if defined(HAVE_QT) // @@@ QImage screenshot (); QImage image (unsigned int width, unsigned int height); QImage image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, lay::Color background, lay::Color foreground, lay::Color active_color, const db::DBox &target_box, bool monochrome); +#endif void update_image (); @@ -315,6 +316,7 @@ public: return lay::Color (m_active); } +#if defined(HAVE_QT) // @@@ /** * @brief Reimplementation of ViewObjectCanvas: background image */ @@ -322,6 +324,7 @@ public: { return *mp_image; } +#endif /** * @brief Reimplementation of RedrawThreadCanvas: signal end of drawing @@ -359,9 +362,11 @@ public: private: lay::LayoutViewBase *mp_view; +#if defined(HAVE_QT) // @@@ QImage *mp_image; QImage *mp_image_bg; QPixmap *mp_pixmap; +#endif db::DBox m_precious_box; lay::Viewport m_viewport, m_viewport_l; lay::color_t m_background; @@ -388,11 +393,13 @@ private: std::vector m_image_cache; size_t m_image_cache_size; - QMutex m_mutex; + tl::Mutex m_mutex; +#if defined(HAVE_QT) virtual void paintEvent (QPaintEvent *); virtual void resizeEvent (QResizeEvent *); virtual bool event (QEvent *e); +#endif virtual void key_event (unsigned int key, unsigned int buttons); // implementation of the lay::Drawings interface diff --git a/src/laybasic/laybasic/layLayoutView.cc b/src/laybasic/laybasic/layLayoutView.cc index d9b0014d9..438a72bdf 100644 --- a/src/laybasic/laybasic/layLayoutView.cc +++ b/src/laybasic/laybasic/layLayoutView.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include #include @@ -1107,3 +1108,26 @@ LayoutView::sizeHint () const } } // namespace lay + +#else // defined(HAVE_QT) + +#include "layLayoutView.h" + +namespace lay +{ + +LayoutView::LayoutView (db::Manager *mgr, bool editable, lay::Plugin *plugin_parent, unsigned int options) + : LayoutViewBase (mgr, editable, plugin_parent, options) +{ + // .. nothing yet .. +} + +LayoutView::LayoutView (lay::LayoutView *source, db::Manager *mgr, bool editable, lay::Plugin *plugin_parent, unsigned int options) + : LayoutViewBase (source, mgr, editable, plugin_parent, options) +{ + // .. nothing yet .. +} + +} // namespace lay + +#endif diff --git a/src/laybasic/laybasic/layLayoutView.h b/src/laybasic/laybasic/layLayoutView.h index 1594dfd08..d47a22e89 100644 --- a/src/laybasic/laybasic/layLayoutView.h +++ b/src/laybasic/laybasic/layLayoutView.h @@ -26,6 +26,8 @@ #include "laybasicCommon.h" +#if defined(HAVE_QT) + #include #include #include @@ -764,4 +766,36 @@ protected: } +#else // defined(HAVE_QT) + +#include "layLayoutViewBase.h" + +namespace lay +{ + +/** + * @brief The layout view object + * + * The layout view is responsible for displaying one or a set of layouts. + * It manages the layer display list and many other components. + */ +class LAYBASIC_PUBLIC LayoutView + : public LayoutViewBase +{ +public: + /** + * @brief Constructor + */ + LayoutView (db::Manager *mgr, bool editable, lay::Plugin *plugin_parent, unsigned int options = (unsigned int) LV_Normal); + + /** + * @brief Constructor (clone from another view) + */ + LayoutView (lay::LayoutView *source, db::Manager *mgr, bool editable, lay::Plugin *plugin_parent, unsigned int options = (unsigned int) LV_Normal); +}; + +} + +#endif + #endif diff --git a/src/laybasic/laybasic/layLayoutViewBase.cc b/src/laybasic/laybasic/layLayoutViewBase.cc index ab539b49f..233414df7 100644 --- a/src/laybasic/laybasic/layLayoutViewBase.cc +++ b/src/laybasic/laybasic/layLayoutViewBase.cc @@ -25,6 +25,8 @@ #include #include +#include "laybasicConfig.h" + #include "tlInternational.h" #include "tlExpression.h" #include "tlTimer.h" @@ -35,7 +37,6 @@ #include "layLayoutViewBase.h" #include "layViewOp.h" #include "layViewObject.h" -#include "laybasicConfig.h" #include "layConverters.h" #include "layGridNet.h" #include "layMove.h" @@ -45,30 +46,19 @@ #include "layFixedFont.h" #include "laySelector.h" #include "layLayoutCanvas.h" -#include "layLayerControlPanel.h" -#include "layHierarchyControlPanel.h" -#include "layLibrariesView.h" -#include "layBrowser.h" #include "layRedrawThread.h" #include "layRedrawThreadWorker.h" #include "layParsedLayerSource.h" -#include "layBookmarkManagementForm.h" -#include "layNetlistBrowserDialog.h" -#include "layBookmarksView.h" -#include "layEditorOptionsFrame.h" -#include "layEditorOptionsPages.h" #include "dbClipboard.h" #include "dbLayout.h" #include "dbLayoutUtils.h" #include "dbManager.h" #include "dbLibrary.h" #include "rdb.h" -#include "rdbMarkerBrowserDialog.h" #include "dbLayoutToNetlist.h" #include "dbTechnology.h" #include "tlXMLParser.h" #include "gsi.h" -#include "gtf.h" #if defined(HAVE_QT) # include @@ -634,7 +624,7 @@ LayoutViewBase::title () const if (! m_title.empty ()) { return m_title; } else if (cellviews () == 0) { - return tl::to_string (QObject::tr ("")); + return tl::to_string (tr ("")); } else { int cv_index = active_cellview_index (); @@ -4836,7 +4826,7 @@ LayoutViewBase::paste_interactive () { clear_selection (); - std::unique_ptr trans (new db::Transaction (manager (), tl::to_string (QObject::tr ("Paste and move")))); + std::unique_ptr trans (new db::Transaction (manager (), tl::to_string (tr ("Paste and move")))); { // let the receivers sort out who is pasting what .. @@ -4872,7 +4862,7 @@ LayoutViewBase::cut () lay::Editables::transient_to_selection (); } - db::Transaction trans (manager (), tl::to_string (QObject::tr ("Cut"))); + db::Transaction trans (manager (), tl::to_string (tr ("Cut"))); lay::Editables::cut (); } diff --git a/src/laybasic/laybasic/layLayoutViewBase.h b/src/laybasic/laybasic/layLayoutViewBase.h index 9b8d0d67c..0047975fc 100644 --- a/src/laybasic/laybasic/layLayoutViewBase.h +++ b/src/laybasic/laybasic/layLayoutViewBase.h @@ -34,7 +34,6 @@ #include #include "layLayerProperties.h" -#include "layAbstractMenu.h" #include "layAnnotationShapes.h" #include "layDispatcher.h" #include "layLayoutCanvas.h" diff --git a/src/laybasic/laybasic/layLineStylePalette.cc b/src/laybasic/laybasic/layLineStylePalette.cc index a6b56f6a8..ab8ec99de 100644 --- a/src/laybasic/laybasic/layLineStylePalette.cc +++ b/src/laybasic/laybasic/layLineStylePalette.cc @@ -149,16 +149,16 @@ LineStylePalette::from_string (const std::string &s) } if (! x.at_end ()) { - throw tl::Exception (tl::sprintf (tl::to_string (QObject::tr ("unexpected characters: %s")), x.skip ())); + throw tl::Exception (tl::sprintf (tl::to_string (tr ("unexpected characters: %s")), x.skip ())); } if (styles () == 0) { - throw tl::Exception (tl::to_string (QObject::tr ("invalid line style palette - no styles"))); + throw tl::Exception (tl::to_string (tr ("invalid line style palette - no styles"))); } } catch (std::exception &ex) { // reformat error message - throw tl::Exception (tl::sprintf (tl::to_string (QObject::tr ("Line style palette string format error: %s")), ex.what ())); + throw tl::Exception (tl::sprintf (tl::to_string (tr ("Line style palette string format error: %s")), ex.what ())); } } diff --git a/src/laybasic/laybasic/layLineStyles.cc b/src/laybasic/laybasic/layLineStyles.cc index f31fcc1ab..c7c0e9adb 100644 --- a/src/laybasic/laybasic/layLineStyles.cc +++ b/src/laybasic/laybasic/layLineStyles.cc @@ -27,6 +27,7 @@ #include #include +#include namespace lay { @@ -162,6 +163,7 @@ LineStyleInfo::is_bit_set (unsigned int n) const return (pattern () [(n / 32) % pattern_stride ()] & (1 << (n % 32))) != 0; } +#if defined(HAVE_QT) // @@@ QBitmap LineStyleInfo::get_bitmap (int width, int height) const { @@ -196,6 +198,7 @@ LineStyleInfo::get_bitmap (int width, int height) const return bitmap; } +#endif void LineStyleInfo::set_pattern (uint32_t pt, unsigned int w) @@ -351,8 +354,11 @@ struct ReplaceLineStyleOp LineStyleInfo m_old, m_new; }; -LineStyles::LineStyles () - : QObject (), db::Object (0) +LineStyles::LineStyles () : +#if defined(HAVE_QT) + QObject (), +#endif + db::Object (0) { for (unsigned int d = 0; d < sizeof (style_strings) / sizeof (style_strings [0]); d += 2) { m_styles.push_back (LineStyleInfo ()); @@ -361,17 +367,20 @@ LineStyles::LineStyles () } } +LineStyles::LineStyles (const LineStyles &p) : +#if defined(HAVE_QT) + QObject (), +#endif + db::Object (0) +{ + m_styles = p.m_styles; +} + LineStyles::~LineStyles () { // .. nothing yet .. } -LineStyles::LineStyles (const LineStyles &p) - : QObject (), db::Object (0) -{ - m_styles = p.m_styles; -} - LineStyles & LineStyles::operator= (const LineStyles &p) { @@ -418,7 +427,9 @@ LineStyles::replace_style (unsigned int i, const LineStyleInfo &p) // if something has changed emit the signal if (chg) { +#if defined(HAVE_QT) // @@@ emit changed (); +#endif } } diff --git a/src/laybasic/laybasic/layMarker.cc b/src/laybasic/laybasic/layMarker.cc index 959f3601a..29f822673 100644 --- a/src/laybasic/laybasic/layMarker.cc +++ b/src/laybasic/laybasic/layMarker.cc @@ -37,7 +37,7 @@ namespace lay // ------------------------------------------------------------------------ -void render_cell_inst (const db::Layout &layout, const db::CellInstArray &inst, const db::CplxTrans &tr, lay::Renderer &r, +void render_cell_inst (const db::Layout &layout, const db::CellInstArray &inst, const db::CplxTrans &trans, lay::Renderer &r, unsigned int font, lay::CanvasPlane *fill, lay::CanvasPlane *contour, lay::CanvasPlane *vertex, lay::CanvasPlane *text, bool cell_name_text_transform, int min_size_for_label, bool draw_outline, size_t max_shapes) { @@ -83,29 +83,29 @@ void render_cell_inst (const db::Layout &layout, const db::CellInstArray &inst, db::Vector av(a), bv(b); // fallback to simpler representation using a description text - db::CplxTrans tbox (tr * inst.complex_trans ()); + db::CplxTrans tbox (trans * inst.complex_trans ()); // one representative instance r.draw (cell_box, tbox, fill, contour, 0, text); - r.draw (cell_box, db::CplxTrans (tr * (av * long (amax - 1))) * tbox, fill, contour, 0, text); - r.draw (cell_box, db::CplxTrans (tr * (bv * long (bmax - 1))) * tbox, fill, contour, 0, text); - r.draw (cell_box, db::CplxTrans (tr * (av * long (amax - 1) + bv * long (bmax - 1))) * tbox, fill, contour, 0, text); + r.draw (cell_box, db::CplxTrans (trans * (av * long (amax - 1))) * tbox, fill, contour, 0, text); + r.draw (cell_box, db::CplxTrans (trans * (bv * long (bmax - 1))) * tbox, fill, contour, 0, text); + r.draw (cell_box, db::CplxTrans (trans * (av * long (amax - 1) + bv * long (bmax - 1))) * tbox, fill, contour, 0, text); db::DBox cb (tbox * cell_box); db::DPolygon p; db::DPoint points[] = { db::DPoint (cb.lower_left ()), - db::DPoint (cb.lower_left () + tr * (av * long (amax - 1))), - db::DPoint (cb.lower_left () + tr * (av * long (amax - 1) + bv * long (bmax - 1))), - db::DPoint (cb.lower_left () + tr * (bv * long (bmax - 1))), + db::DPoint (cb.lower_left () + trans * (av * long (amax - 1))), + db::DPoint (cb.lower_left () + trans * (av * long (amax - 1) + bv * long (bmax - 1))), + db::DPoint (cb.lower_left () + trans * (bv * long (bmax - 1))), }; p.assign_hull (points, points + sizeof (points) / sizeof (points[0])); r.draw (p, fill, contour, 0, text); if (text) { - db::DBox arr_box (db::DPoint (), db::DPoint () + tr * (av * long (amax - 1) + bv * long (bmax - 1))); + db::DBox arr_box (db::DPoint (), db::DPoint () + trans * (av * long (amax - 1) + bv * long (bmax - 1))); arr_box *= cb; - r.draw (arr_box, tl::sprintf (tl::to_string (QObject::tr ("Array %ldx%ld")), amax, bmax), db::Font (font), db::HAlignCenter, db::VAlignCenter, db::DFTrans (db::DFTrans::r0), 0, 0, 0, text); + r.draw (arr_box, tl::sprintf (tl::to_string (tr ("Array %ldx%ld")), amax, bmax), db::Font (font), db::HAlignCenter, db::VAlignCenter, db::DFTrans (db::DFTrans::r0), 0, 0, 0, text); } } else { @@ -113,7 +113,7 @@ void render_cell_inst (const db::Layout &layout, const db::CellInstArray &inst, for (db::CellInstArray::iterator arr = inst.begin (); ! arr.at_end (); ++arr) { // fallback to simpler representation using a description text - db::CplxTrans tbox (tr * inst.complex_trans ()); + db::CplxTrans tbox (trans * inst.complex_trans ()); r.draw (cell_box, tbox, fill, contour, 0, 0); @@ -149,7 +149,7 @@ void render_cell_inst (const db::Layout &layout, const db::CellInstArray &inst, while (! shapes.at_end ()) { for (db::CellInstArray::iterator arr = inst.begin (); ! arr.at_end (); ++arr) { - r.draw (*shapes, tr * inst.complex_trans (*arr) * shapes.trans (), fill, contour, 0 /*use vertex for origin*/, text); + r.draw (*shapes, trans * inst.complex_trans (*arr) * shapes.trans (), fill, contour, 0 /*use vertex for origin*/, text); } ++shapes; @@ -167,7 +167,7 @@ void render_cell_inst (const db::Layout &layout, const db::CellInstArray &inst, while (! shapes.at_end ()) { for (db::CellInstArray::iterator arr = inst.begin (); ! arr.at_end (); ++arr) { - r.draw (*shapes, tr * inst.complex_trans (*arr) * shapes.trans (), fill, contour, 0 /*use vertex for origin*/, text); + r.draw (*shapes, trans * inst.complex_trans (*arr) * shapes.trans (), fill, contour, 0 /*use vertex for origin*/, text); } ++shapes; @@ -179,7 +179,7 @@ void render_cell_inst (const db::Layout &layout, const db::CellInstArray &inst, if (render_origins && vertex) { for (db::CellInstArray::iterator arr = inst.begin (); ! arr.at_end (); ++arr) { - db::DPoint dp = db::DPoint () + (tr * inst.complex_trans (*arr)).disp (); + db::DPoint dp = db::DPoint () + (trans * inst.complex_trans (*arr)).disp (); r.draw (db::DEdge (dp, dp), 0, 0, vertex, 0); } diff --git a/src/laybasic/laybasic/layMove.cc b/src/laybasic/laybasic/layMove.cc index 9e6102f39..9667ccb77 100644 --- a/src/laybasic/laybasic/layMove.cc +++ b/src/laybasic/laybasic/layMove.cc @@ -89,6 +89,7 @@ bool MoveService::key_event (unsigned int key, unsigned int /*buttons*/) { double dx = 0.0, dy = 0.0; +#if defined(HAVE_QT) // @@@ if (int (key) == Qt::Key_Down) { dy = -1.0; } else if (int (key) == Qt::Key_Up) { @@ -98,6 +99,7 @@ MoveService::key_event (unsigned int key, unsigned int /*buttons*/) } else if (int (key) == Qt::Key_Right) { dx = 1.0; } +#endif if (! m_dragging && fabs (dx + dy) > 0.0 && mp_editables->has_selection ()) { diff --git a/src/laybasic/laybasic/layNetColorizer.cc b/src/laybasic/laybasic/layNetColorizer.cc new file mode 100644 index 000000000..46639fa40 --- /dev/null +++ b/src/laybasic/laybasic/layNetColorizer.cc @@ -0,0 +1,153 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 "layNetColorizer.h" +#include "dbNet.h" +#include "dbCircuit.h" + +namespace lay +{ + +// ---------------------------------------------------------------------------------- +// NetColorizer implementation + +NetColorizer::NetColorizer () +{ + m_auto_colors_enabled = false; + m_update_needed = false; + m_signals_enabled = true; +} + +void +NetColorizer::configure (const lay::Color &marker_color, const lay::ColorPalette *auto_colors) +{ + m_marker_color = marker_color; + if (auto_colors) { + m_auto_colors = *auto_colors; + m_auto_colors_enabled = true; + } else { + m_auto_colors_enabled = false; + } + + emit_colors_changed (); +} + +bool +NetColorizer::has_color_for_net (const db::Net *net) +{ + return net != 0 && (m_auto_colors_enabled || m_custom_color.find (net) != m_custom_color.end ()); +} + +void +NetColorizer::set_color_of_net (const db::Net *net, const lay::Color &color) +{ + m_custom_color[net] = color; + emit_colors_changed (); +} + +void +NetColorizer::reset_color_of_net (const db::Net *net) +{ + m_custom_color.erase (net); + emit_colors_changed (); +} + +void +NetColorizer::clear () +{ + m_net_index_by_object.clear (); + m_custom_color.clear (); + emit_colors_changed (); +} + +void +NetColorizer::begin_changes () +{ + if (m_signals_enabled) { + m_update_needed = false; + m_signals_enabled = false; + } +} + +void +NetColorizer::end_changes () +{ + if (! m_signals_enabled) { + m_signals_enabled = true; + if (m_update_needed) { + colors_changed (); + } + m_update_needed = false; + } +} + +void +NetColorizer::emit_colors_changed () +{ + if (! m_signals_enabled) { + m_update_needed = true; + } else { + colors_changed (); + } +} + +lay::Color +NetColorizer::color_of_net (const db::Net *net) const +{ + if (! net) { + return lay::Color (); + } + + std::map::const_iterator c = m_custom_color.find (net); + if (c != m_custom_color.end ()) { + return c->second; + } + + if (m_auto_colors_enabled) { + + const db::Circuit *circuit = net->circuit (); + + size_t index = 0; + + std::map::iterator cc = m_net_index_by_object.find (net); + if (cc == m_net_index_by_object.end ()) { + + size_t i = 0; + for (db::Circuit::const_net_iterator n = circuit->begin_nets (); n != circuit->end_nets (); ++n, ++i) { + m_net_index_by_object.insert (std::make_pair (n.operator-> (), i)); + if (n.operator-> () == net) { + index = i; + } + } + + } else { + index = cc->second; + } + + return m_auto_colors.color_by_index ((unsigned int) index); + + } else { + return lay::Color (); + } +} + +} diff --git a/src/laybasic/laybasic/layNetColorizer.h b/src/laybasic/laybasic/layNetColorizer.h new file mode 100644 index 000000000..489a4ed7b --- /dev/null +++ b/src/laybasic/laybasic/layNetColorizer.h @@ -0,0 +1,85 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 + +*/ + + +#ifndef HDR_layNetColorizer +#define HDR_layNetColorizer + +#include "laybasicCommon.h" +#include "layColorPalette.h" +#include "layColor.h" +#include "tlEvents.h" + +#include +#include + +namespace db +{ + class Net; +} + +namespace lay +{ + +// ---------------------------------------------------------------------------------- +// NetColorizer definition + +class LAYBASIC_PUBLIC NetColorizer + : public tl::Object +{ +public: + NetColorizer (); + + void configure (const lay::Color &marker_color, const lay::ColorPalette *auto_colors); + bool has_color_for_net (const db::Net *net); + void set_color_of_net (const db::Net *net, const lay::Color &color); + void reset_color_of_net (const db::Net *net); + void clear (); + + lay::Color color_of_net (const db::Net *net) const; + + const lay::Color &marker_color () const + { + return m_marker_color; + } + + void begin_changes (); + void end_changes (); + + tl::Event colors_changed; + +private: + lay::Color m_marker_color; + lay::ColorPalette m_auto_colors; + bool m_auto_colors_enabled; + std::map m_custom_color; + bool m_update_needed; + bool m_signals_enabled; + mutable std::map m_net_index_by_object; + + void emit_colors_changed (); +}; + +} // namespace lay + +#endif + diff --git a/src/laybasic/laybasic/layNetlistBrowserModel.cc b/src/laybasic/laybasic/layNetlistBrowserModel.cc index 82e5f05a4..8ed6a964b 100644 --- a/src/laybasic/laybasic/layNetlistBrowserModel.cc +++ b/src/laybasic/laybasic/layNetlistBrowserModel.cc @@ -100,129 +100,6 @@ NetlistObjectsPath::second () const return p; } -// ---------------------------------------------------------------------------------- -// NetColorizer implementation - -NetColorizer::NetColorizer () -{ - m_auto_colors_enabled = false; - m_update_needed = false; - m_signals_enabled = true; -} - -void -NetColorizer::configure (const lay::Color &marker_color, const lay::ColorPalette *auto_colors) -{ - m_marker_color = marker_color; - if (auto_colors) { - m_auto_colors = *auto_colors; - m_auto_colors_enabled = true; - } else { - m_auto_colors_enabled = false; - } - - emit_colors_changed (); -} - -bool -NetColorizer::has_color_for_net (const db::Net *net) -{ - return net != 0 && (m_auto_colors_enabled || m_custom_color.find (net) != m_custom_color.end ()); -} - -void -NetColorizer::set_color_of_net (const db::Net *net, const lay::Color &color) -{ - m_custom_color[net] = color; - emit_colors_changed (); -} - -void -NetColorizer::reset_color_of_net (const db::Net *net) -{ - m_custom_color.erase (net); - emit_colors_changed (); -} - -void -NetColorizer::clear () -{ - m_net_index_by_object.clear (); - m_custom_color.clear (); - emit_colors_changed (); -} - -void -NetColorizer::begin_changes () -{ - if (m_signals_enabled) { - m_update_needed = false; - m_signals_enabled = false; - } -} - -void -NetColorizer::end_changes () -{ - if (! m_signals_enabled) { - m_signals_enabled = true; - if (m_update_needed) { - emit colors_changed (); - } - m_update_needed = false; - } -} - -void -NetColorizer::emit_colors_changed () -{ - if (! m_signals_enabled) { - m_update_needed = true; - } else { - emit colors_changed (); - } -} - -lay::Color -NetColorizer::color_of_net (const db::Net *net) const -{ - if (! net) { - return lay::Color (); - } - - std::map::const_iterator c = m_custom_color.find (net); - if (c != m_custom_color.end ()) { - return c->second; - } - - if (m_auto_colors_enabled) { - - const db::Circuit *circuit = net->circuit (); - - size_t index = 0; - - std::map::iterator cc = m_net_index_by_object.find (net); - if (cc == m_net_index_by_object.end ()) { - - size_t i = 0; - for (db::Circuit::const_net_iterator n = circuit->begin_nets (); n != circuit->end_nets (); ++n, ++i) { - m_net_index_by_object.insert (std::make_pair (n.operator-> (), i)); - if (n.operator-> () == net) { - index = i; - } - } - - } else { - index = cc->second; - } - - return m_auto_colors.color_by_index ((unsigned int) index); - - } else { - return lay::Color (); - } -} - // ---------------------------------------------------------------------------------- // Implementation of the item classes diff --git a/src/laybasic/laybasic/layNetlistBrowserModel.h b/src/laybasic/laybasic/layNetlistBrowserModel.h index b18c4bbe7..3028792bc 100644 --- a/src/laybasic/laybasic/layNetlistBrowserModel.h +++ b/src/laybasic/laybasic/layNetlistBrowserModel.h @@ -30,6 +30,7 @@ #include "dbLayoutToNetlist.h" #include "dbLayoutVsSchematic.h" +#include "layNetColorizer.h" #include "tlList.h" #include "tlTypeTraits.h" @@ -46,48 +47,6 @@ namespace lay class IndexedNetlistModel; -// ---------------------------------------------------------------------------------- -// NetColorizer definition - -class LAYBASIC_PUBLIC NetColorizer - : public QObject -{ -Q_OBJECT - -public: - NetColorizer (); - - void configure (const lay::Color &marker_color, const lay::ColorPalette *auto_colors); - bool has_color_for_net (const db::Net *net); - void set_color_of_net (const db::Net *net, const Color &color); - void reset_color_of_net (const db::Net *net); - void clear (); - - lay::Color color_of_net (const db::Net *net) const; - - const lay::Color &marker_color () const - { - return m_marker_color; - } - - void begin_changes (); - void end_changes (); - -signals: - void colors_changed (); - -private: - lay::Color m_marker_color; - lay::ColorPalette m_auto_colors; - bool m_auto_colors_enabled; - std::map m_custom_color; - bool m_update_needed; - bool m_signals_enabled; - mutable std::map m_net_index_by_object; - - void emit_colors_changed (); -}; - // ---------------------------------------------------------------------------------- // NetlistBrowserModel definition diff --git a/src/laybasic/laybasic/layObjectInstPath.h b/src/laybasic/laybasic/layObjectInstPath.h index 91d3ef681..13c4ca095 100644 --- a/src/laybasic/laybasic/layObjectInstPath.h +++ b/src/laybasic/laybasic/layObjectInstPath.h @@ -31,8 +31,6 @@ #include #include -#include - #include "dbInstElement.h" #include "dbClipboardData.h" #include "dbClipboard.h" diff --git a/src/laybasic/laybasic/layParsedLayerSource.cc b/src/laybasic/laybasic/layParsedLayerSource.cc index 5e7dee250..66130f12f 100644 --- a/src/laybasic/laybasic/layParsedLayerSource.cc +++ b/src/laybasic/laybasic/layParsedLayerSource.cc @@ -415,7 +415,7 @@ extract_base (tl::Extractor &ex) } else if (ex.test ("!=")) { eq = false; } else { - ex.error (tl::to_string (QObject::tr ("'==' or '!=' operator expected"))); + ex.error (tl::to_string (tr ("'==' or '!=' operator expected"))); } ex.read (v); return new PropertySelectorEqual (n, v, eq); @@ -1376,7 +1376,7 @@ ParsedLayerSource::parse_from_string (const char *cp) if (sp == "CellFrame" || sp == "cellframe" || sp == "CF" || sp == "cell-frame") { m_special_purpose = SP_CellFrame; } else { - throw tl::Exception (tl::to_string (QObject::tr ("Invalid special purpose '%s'")), sp); + throw tl::Exception (tl::to_string (tr ("Invalid special purpose '%s'")), sp); } } else if (x.test ("(")) { diff --git a/src/laybasic/laybasic/layPlugin.cc b/src/laybasic/laybasic/layPlugin.cc index 15685bf13..0cea0604a 100644 --- a/src/laybasic/laybasic/layPlugin.cc +++ b/src/laybasic/laybasic/layPlugin.cc @@ -33,12 +33,13 @@ #include "tlExceptions.h" #include "tlClassRegistry.h" +#if defined(HAVE_QT) #include "gtf.h" +#endif #include #include #include -#include namespace lay { @@ -93,6 +94,7 @@ PluginDeclaration::menu_symbols () return symbols; } +#if defined(HAVE_QT) namespace { class GenericMenuAction @@ -142,10 +144,12 @@ private: }; } +#endif void PluginDeclaration::init_menu (lay::Dispatcher *dispatcher) { +#if defined(HAVE_QT) // @@@ lay::AbstractMenu &menu = *dispatcher->menu (); mp_editable_mode_action.reset ((Action *) 0); @@ -255,11 +259,13 @@ PluginDeclaration::init_menu (lay::Dispatcher *dispatcher) menu.insert_item (m->second.first, name + ":mode_group", mp_mouse_mode_action.get ()); } +#endif } void PluginDeclaration::remove_menu_items (Dispatcher *dispatcher) { +#if defined(HAVE_QT) // @@@ lay::AbstractMenu *menu = dispatcher->menu (); menu->delete_items (mp_editable_mode_action.get ()); menu->delete_items (mp_mouse_mode_action.get ()); @@ -274,6 +280,7 @@ PluginDeclaration::remove_menu_items (Dispatcher *dispatcher) menu->delete_items (*a); } m_menu_actions.clear (); +#endif } void @@ -281,9 +288,11 @@ PluginDeclaration::set_editable_enabled (bool f) { if (f != m_editable_enabled) { m_editable_enabled = f; +#if defined(HAVE_QT) // @@@ if (mp_editable_mode_action.get ()) { mp_editable_mode_action->set_checked (f); } +#endif editable_enabled_changed_event (); } } @@ -358,7 +367,7 @@ Plugin::config_set (const std::string &name, const std::string &value) return; } } catch (tl::Exception &ex) { - tl::error << tl::to_string (QObject::tr ("Error on configure")) << " " << name << "='" << value << "': " << ex.msg (); + tl::error << tl::to_string (tr ("Error on configure")) << " " << name << "='" << value << "': " << ex.msg (); } } } @@ -481,7 +490,7 @@ Plugin::do_config_set (const std::string &name, const std::string &value, bool f return true; } } catch (tl::Exception &ex) { - tl::error << tl::to_string (QObject::tr ("Error on configure")) << " " << name << "='" << value << "': " << ex.msg (); + tl::error << tl::to_string (tr ("Error on configure")) << " " << name << "='" << value << "': " << ex.msg (); } // propagate to all children (not only the first that takes it!) diff --git a/src/laybasic/laybasic/layPlugin.h b/src/laybasic/laybasic/layPlugin.h index c03fae38e..4a0b57ff8 100644 --- a/src/laybasic/laybasic/layPlugin.h +++ b/src/laybasic/laybasic/layPlugin.h @@ -455,8 +455,10 @@ public: #if defined(HAVE_QT) private slots: - void toggle_editable_enabled (); +#else +private: #endif + void toggle_editable_enabled (); private: int m_id; diff --git a/src/laybasic/laybasic/layRedrawThread.cc b/src/laybasic/laybasic/layRedrawThread.cc index 25d1a24b3..478437441 100644 --- a/src/laybasic/laybasic/layRedrawThread.cc +++ b/src/laybasic/laybasic/layRedrawThread.cc @@ -21,9 +21,6 @@ */ -#include -#include - #include "layRedrawThread.h" #include "layRedrawThreadWorker.h" #include "tlLog.h" @@ -63,7 +60,7 @@ RedrawThread::~RedrawThread () void RedrawThread::layout_changed () { if (is_running () && tl::verbosity () >= 30) { - tl::info << tl::to_string (QObject::tr ("Layout changed: redraw thread stopped")); + tl::info << tl::to_string (tr ("Layout changed: redraw thread stopped")); } // if something changed on the layouts we observe, stop the redraw thread @@ -228,9 +225,9 @@ RedrawThread::do_start (bool clear, const db::Vector *shift_vector, const std::v { if (tl::verbosity () >= 40) { - tl::info << tl::to_string (QObject::tr ("Preparing to draw")); + tl::info << tl::to_string (tr ("Preparing to draw")); } - tl::SelfTimer timer (tl::verbosity () >= 41, tl::to_string (QObject::tr ("Preparing to draw"))); + tl::SelfTimer timer (tl::verbosity () >= 41, tl::to_string (tr ("Preparing to draw"))); // detach from all layout objects tl::Object::detach_from_all_events (); diff --git a/src/laybasic/laybasic/layRedrawThread.h b/src/laybasic/laybasic/layRedrawThread.h index 47ac943e2..4dc328aff 100644 --- a/src/laybasic/laybasic/layRedrawThread.h +++ b/src/laybasic/laybasic/layRedrawThread.h @@ -28,10 +28,6 @@ #include #include -#include -#include -#include - #include "dbBox.h" #include "dbTrans.h" #include "dbLayout.h" @@ -41,6 +37,7 @@ #include "layRedrawLayerInfo.h" #include "layCanvasPlane.h" #include "tlTimer.h" +#include "tlThreads.h" #include "tlThreadedWorkers.h" namespace lay { @@ -120,8 +117,8 @@ private: bool m_start_recursion_sentinel; tl::Clock m_clock; - QMutex m_initial_wait_lock; - QWaitCondition m_initial_wait_cond; + tl::Mutex m_initial_wait_lock; + tl::WaitCondition m_initial_wait_cond; std::unique_ptr m_main_timer; }; diff --git a/src/laybasic/laybasic/layRedrawThreadCanvas.cc b/src/laybasic/laybasic/layRedrawThreadCanvas.cc index b6d2964f4..e47eb19ab 100644 --- a/src/laybasic/laybasic/layRedrawThreadCanvas.cc +++ b/src/laybasic/laybasic/layRedrawThreadCanvas.cc @@ -23,11 +23,15 @@ #include "layRedrawThreadCanvas.h" #include "layCanvasPlane.h" +#if defined(HAVE_QT) #include "layBitmapsToImage.h" +#endif #include "layDrawing.h" #include "layBitmap.h" +#if defined(HAVE_QT) // @@@ #include +#endif namespace lay { @@ -393,6 +397,7 @@ BitmapRedrawThreadCanvas::initialize_plane (lay::CanvasPlane *plane, unsigned in unlock (); } +#if defined(HAVE_QT) // @@@ void BitmapRedrawThreadCanvas::to_image (const std::vector &view_ops, const lay::DitherPattern &dp, const lay::LineStyles &ls, lay::Color background, lay::Color foreground, lay::Color active, const lay::Drawings *drawings, QImage &img, unsigned int width, unsigned int height) { @@ -412,6 +417,7 @@ BitmapRedrawThreadCanvas::to_image (const std::vector &view_ops, c bitmaps_to_image (d->get_view_ops (*this, background, foreground, active), *bt, dp, ls, &img, width, height, true, &mutex ()); } } +#endif } diff --git a/src/laybasic/laybasic/layRedrawThreadCanvas.h b/src/laybasic/laybasic/layRedrawThreadCanvas.h index eb22d4717..b231aa557 100644 --- a/src/laybasic/laybasic/layRedrawThreadCanvas.h +++ b/src/laybasic/laybasic/layRedrawThreadCanvas.h @@ -29,13 +29,10 @@ #include "dbTrans.h" #include "layViewOp.h" #include "layBitmapRenderer.h" +#include "tlThreads.h" #include -#include - -class QImage; - namespace lay { class CanvasPlane; @@ -151,7 +148,7 @@ public: /** * @brief Access to the mutex object */ - QMutex &mutex () + tl::Mutex &mutex () { return m_mutex; } @@ -186,7 +183,7 @@ public: virtual lay::Renderer *create_renderer () = 0; private: - QMutex m_mutex; + tl::Mutex m_mutex; double m_resolution; unsigned int m_width, m_height; }; @@ -318,10 +315,12 @@ public: return new lay::BitmapRenderer (m_width, m_height, resolution ()); } +#if defined(HAVE_QT) // @@@ /** * @brief Transfer the content to an QImage */ void to_image (const std::vector &view_ops, const lay::DitherPattern &dp, const lay::LineStyles &ls, lay::Color background, lay::Color foreground, lay::Color active, const lay::Drawings *drawings, QImage &img, unsigned int width, unsigned int height); +#endif /** * @brief Gets the current bitmap data as a BitmapCanvasData object diff --git a/src/laybasic/laybasic/layRedrawThreadWorker.cc b/src/laybasic/laybasic/layRedrawThreadWorker.cc index 661d61224..da0905be8 100644 --- a/src/laybasic/laybasic/layRedrawThreadWorker.cc +++ b/src/laybasic/laybasic/layRedrawThreadWorker.cc @@ -194,9 +194,9 @@ RedrawThreadWorker::perform_task (tl::Task *task) m_layer = li.layer_index; if (tl::verbosity () >= 40) { - tl::info << tl::to_string (QObject::tr ("Drawing layer: ")) << mp_layout->get_properties (m_layer).name; + tl::info << tl::to_string (tr ("Drawing layer: ")) << mp_layout->get_properties (m_layer).name; } - tl::SelfTimer timer (tl::verbosity () >= 41, tl::to_string (QObject::tr ("Drawing layer"))); + tl::SelfTimer timer (tl::verbosity () >= 41, tl::to_string (tr ("Drawing layer"))); // configure renderer .. mp_renderer->set_xfill (m_xfill); @@ -220,9 +220,9 @@ RedrawThreadWorker::perform_task (tl::Task *task) // if no specific layer is assigned, draw cell boxes with the style given if (tl::verbosity () >= 40) { - tl::info << tl::to_string (QObject::tr ("Drawing custom frames")); + tl::info << tl::to_string (tr ("Drawing custom frames")); } - tl::SelfTimer timer (tl::verbosity () >= 41, tl::to_string (QObject::tr ("Drawing frames"))); + tl::SelfTimer timer (tl::verbosity () >= 41, tl::to_string (tr ("Drawing frames"))); for (std::set< std::pair >::const_iterator b = m_box_variants.begin (); b != m_box_variants.end (); ++b) { if (b->second == li.cellview_index) { @@ -245,9 +245,9 @@ RedrawThreadWorker::perform_task (tl::Task *task) // draw the bounding boxes if (tl::verbosity () >= 40) { - tl::info << tl::to_string (QObject::tr ("Drawing frames and guiding shapes")); + tl::info << tl::to_string (tr ("Drawing frames and guiding shapes")); } - tl::SelfTimer timer (tl::verbosity () >= 41, tl::to_string (QObject::tr ("Drawing frames and guiding shapes"))); + tl::SelfTimer timer (tl::verbosity () >= 41, tl::to_string (tr ("Drawing frames and guiding shapes"))); // No xfill for cell boxes mp_renderer->set_xfill (false); @@ -416,9 +416,9 @@ RedrawThreadWorker::perform_task (tl::Task *task) // draw the decorations if (tl::verbosity () >= 40) { - tl::info << tl::to_string (QObject::tr ("Drawing decorations")); + tl::info << tl::to_string (tr ("Drawing decorations")); } - tl::SelfTimer timer (tl::verbosity () >= 41, tl::to_string (QObject::tr ("Drawing decorations"))); + tl::SelfTimer timer (tl::verbosity () >= 41, tl::to_string (tr ("Drawing decorations"))); m_buffers.clear (); mp_canvas->initialize_plane (m_planes[0], m_nlayers * planes_per_layer + special_planes_before); @@ -2172,7 +2172,7 @@ RedrawThreadWorker::iterate_variants (const std::vector &redraw_region m_from_level = fl; if (tl::verbosity () >= 40) { - tl::info << tl::to_string (QObject::tr ("Cell variant cache hits/misses: ")) << m_cache_hits << "/" << m_cache_misses; + tl::info << tl::to_string (tr ("Cell variant cache hits/misses: ")) << m_cache_hits << "/" << m_cache_misses; } } else { diff --git a/src/laybasic/laybasic/laySnap.cc b/src/laybasic/laybasic/laySnap.cc index 6c005d933..1243a7218 100644 --- a/src/laybasic/laybasic/laySnap.cc +++ b/src/laybasic/laybasic/laySnap.cc @@ -129,6 +129,7 @@ int draw_round (double x) } } +#if defined(HAVE_QT) QPoint draw_round (db::DPoint p, int h) { return QPoint (draw_round (p.x ()), h - 1 - draw_round (p.y ())); @@ -140,6 +141,7 @@ draw_round (const db::DPoint &p1, const db::DPoint &p2, int h) std::pair dp = draw_round_dbl (p1, p2, h); return std::make_pair (draw_round (dp.first, h), draw_round (dp.second, h)); } +#endif std::pair draw_round_dbl (const db::DPoint &p1, const db::DPoint &p2, int /*h*/) diff --git a/src/laybasic/laybasic/layStipplePalette.cc b/src/laybasic/laybasic/layStipplePalette.cc index 72e0898e2..b3f8e1469 100644 --- a/src/laybasic/laybasic/layStipplePalette.cc +++ b/src/laybasic/laybasic/layStipplePalette.cc @@ -205,16 +205,16 @@ StipplePalette::from_string (const std::string &s) } if (! x.at_end ()) { - throw tl::Exception (tl::sprintf (tl::to_string (QObject::tr ("unexpected characters: %s")), x.skip ())); + throw tl::Exception (tl::sprintf (tl::to_string (tr ("unexpected characters: %s")), x.skip ())); } if (stipples () == 0 || standard_stipples () == 0) { - throw tl::Exception (tl::to_string (QObject::tr ("invalid palette - no stipples and/or standard stipples"))); + throw tl::Exception (tl::to_string (tr ("invalid palette - no stipples and/or standard stipples"))); } } catch (std::exception &ex) { // reformat error message - throw tl::Exception (tl::sprintf (tl::to_string (QObject::tr ("Stipple palette string format error: %s")), ex.what ())); + throw tl::Exception (tl::sprintf (tl::to_string (tr ("Stipple palette string format error: %s")), ex.what ())); } } diff --git a/src/laybasic/laybasic/layViewObject.cc b/src/laybasic/laybasic/layViewObject.cc index 7a3ecb3a0..9f8ac62d8 100644 --- a/src/laybasic/laybasic/layViewObject.cc +++ b/src/laybasic/laybasic/layViewObject.cc @@ -20,12 +20,13 @@ */ - -#include -#include -#include -#include -#include +#if defined(HAVE_QT) +# include +# include +# include +# include +# include +#endif #include "layViewObject.h" #include "layCanvasPlane.h" @@ -51,6 +52,7 @@ const char *drag_drop_mime_type () return "application/klayout-ddd"; } +#if defined(HAVE_QT) // @@@ QMimeData * DragDropDataBase::to_mime_data () const { @@ -58,10 +60,12 @@ DragDropDataBase::to_mime_data () const mimeData->setData (QString::fromUtf8 (drag_drop_mime_type ()), serialized ()); return mimeData; } +#endif // --------------------------------------------------------------- // Implementation of CellDragDropData +#if defined(HAVE_QT) // @@@ QByteArray CellDragDropData::serialized () const { @@ -119,10 +123,12 @@ CellDragDropData::deserialize (const QByteArray &ba) } } +#endif // --------------------------------------------------------------- // A helper function to convert a Qt modifier/buttons to klayout buttons +#if defined(HAVE_QT) static unsigned int qt_to_buttons (Qt::MouseButtons b, Qt::KeyboardModifiers m) { @@ -139,6 +145,7 @@ qt_to_buttons (Qt::MouseButtons b, Qt::KeyboardModifiers m) ((m & Qt::ControlModifier) != 0 ? ControlButton : 0) | ((m & Qt::AltModifier) != 0 ? AltButton : 0); } +#endif // --------------------------------------------------------------- // BackgroundViewObject implementation @@ -225,7 +232,9 @@ ViewObject::redraw () if (m_static) { widget ()->touch (); } else { - widget ()->update (); +#if defined(HAVE_QT) + widget ()->update (); // @@@ +#endif } } } @@ -280,6 +289,7 @@ ViewService::set_cursor (lay::Cursor::cursor_shape cursor) // --------------------------------------------------------------- // ViewObject implementation +#if defined(HAVE_QT) // @@@ ViewObjectWidget::ViewObjectWidget (QWidget *parent, const char *name) : QWidget (parent), m_view_objects_dismissed (false), @@ -299,6 +309,22 @@ ViewObjectWidget::ViewObjectWidget (QWidget *parent, const char *name) m_objects.changed ().add (this, &ViewObjectWidget::objects_changed); } +#else +ViewObjectWidget::ViewObjectWidget () + : m_view_objects_dismissed (false), + m_needs_update_static (false), + m_needs_update_bg (false), + mp_active_service (0), + m_mouse_pressed_state (false), + m_mouse_buttons (0), + m_in_mouse_move (false), + m_mouse_inside (false), + m_cursor (lay::Cursor::none), + m_default_cursor (lay::Cursor::none) +{ + m_objects.changed ().add (this, &ViewObjectWidget::objects_changed); +} +#endif ViewObjectWidget::~ViewObjectWidget () { @@ -369,6 +395,7 @@ ViewObjectWidget::set_cursor (lay::Cursor::cursor_shape cursor) void ViewObjectWidget::set_default_cursor (lay::Cursor::cursor_shape cursor) { +#if defined(HAVE_QT) // @@@ if (cursor != m_default_cursor) { m_default_cursor = cursor; if (m_cursor == lay::Cursor::none) { @@ -379,14 +406,17 @@ ViewObjectWidget::set_default_cursor (lay::Cursor::cursor_shape cursor) } } } +#endif } void ViewObjectWidget::ensure_entered () { +#if defined(HAVE_QT) // @@@ if (! m_mouse_inside) { enterEvent (0); } +#endif } void @@ -398,6 +428,7 @@ ViewObjectWidget::begin_mouse_event (lay::Cursor::cursor_shape cursor) void ViewObjectWidget::end_mouse_event () { +#if defined(HAVE_QT) // @@@ if (m_cursor == lay::Cursor::none) { if (m_default_cursor == lay::Cursor::none) { unsetCursor (); @@ -407,8 +438,10 @@ ViewObjectWidget::end_mouse_event () } else if (m_cursor != lay::Cursor::keep) { setCursor (lay::Cursor::qcursor (m_cursor)); } +#endif } +#if defined(HAVE_QT) // @@@ bool ViewObjectWidget::focusNextPrevChild (bool /*next*/) { @@ -555,6 +588,7 @@ BEGIN_PROTECTED do_mouse_move (); END_PROTECTED } +#endif void ViewObjectWidget::do_mouse_move () @@ -637,7 +671,8 @@ ViewObjectWidget::do_mouse_move () m_in_mouse_move = false; } -void +#if defined(HAVE_QT) // @@@ +void ViewObjectWidget::mouseDoubleClickEvent (QMouseEvent *e) { BEGIN_PROTECTED @@ -883,17 +918,38 @@ END_PROTECTED m_mouse_pressed_state = false; } +#endif -db::DPoint -ViewObjectWidget::pixel_to_um (const QPoint &pt) const +int +ViewObjectWidget::widget_height () const { - return m_trans.inverted () * db::DPoint (pt.x (), height () - 1 - pt.y ()); +#if defined(HAVE_QT) + return height (); +#else + return 500; // @@@ +#endif +} + +int +ViewObjectWidget::widget_width () const +{ +#if defined(HAVE_QT) + return width (); +#else + return 800; // @@@ +#endif } db::DPoint -ViewObjectWidget::pixel_to_um (const QPointF &pt) const +ViewObjectWidget::pixel_to_um (const db::Point &pt) const { - return m_trans.inverted () * db::DPoint (pt.x (), height () - 1 - pt.y ()); + return m_trans.inverted () * db::DPoint (pt.x (), widget_height () - 1 - pt.y ()); +} + +db::DPoint +ViewObjectWidget::pixel_to_um (const db::DPoint &pt) const +{ + return m_trans.inverted () * db::DPoint (pt.x (), widget_height () - 1 - pt.y ()); } void @@ -1018,6 +1074,14 @@ ViewObjectWidget::thaw (ViewObject *obj) } } +#if !defined(HAVE_QT) +void +ViewObjectWidget::update () +{ + // @@@ +} +#endif + void ViewObjectWidget::touch () { @@ -1057,7 +1121,7 @@ db::DBox ViewObjectWidget::mouse_event_viewport () const { db::DPoint p1 = m_trans.inverted () * db::DPoint (0, 0); - db::DPoint p2 = m_trans.inverted () * db::DPoint (width (), height ()); + db::DPoint p2 = m_trans.inverted () * db::DPoint (widget_width (), widget_height ()); return db::DBox (p1, p2); } diff --git a/src/laybasic/laybasic/layViewObject.h b/src/laybasic/laybasic/layViewObject.h index f69ad4efc..fa0552136 100644 --- a/src/laybasic/laybasic/layViewObject.h +++ b/src/laybasic/laybasic/layViewObject.h @@ -32,10 +32,12 @@ #include #include -#include -#include -#include -#include +#if defined(HAVE_QT) +# include +# include +# include +# include +#endif #include "tlObjectCollection.h" #include "tlVariant.h" @@ -45,6 +47,7 @@ #include "layCursor.h" #include "layBitmapRenderer.h" +#if defined(HAVE_QT) class QMouseEvent; class QImage; class QDragEnterEvent; @@ -52,6 +55,7 @@ class QDragMoveEvent; class QDragLeaveEvent; class QDropEvent; class QMimeData; +#endif namespace db { @@ -89,6 +93,7 @@ public: */ virtual ~DragDropDataBase () { } +#if defined(HAVE_QT) // @@@ /** * @brief Serializes itself to an QByteArray */ @@ -105,6 +110,7 @@ public: * @brief Create a QMimeData object from the object */ QMimeData *to_mime_data () const; +#endif }; /** @@ -176,6 +182,7 @@ public: return m_is_pcell; } +#if defined(HAVE_QT) // @@@ /** * @brief Serializes itself to an QByteArray */ @@ -187,6 +194,7 @@ public: * Returns false, if deserialization failed. */ bool deserialize (const QByteArray &ba); +#endif private: const db::Layout *mp_layout; @@ -644,8 +652,10 @@ enum ButtonState { * painting. */ -class LAYBASIC_PUBLIC ViewObjectWidget - : public QWidget, +class LAYBASIC_PUBLIC ViewObjectWidget : +#if defined(HAVE_QT) + public QWidget, +#endif public tl::Object { public: @@ -657,7 +667,11 @@ public: /** * @brief ctor */ +#if defined(HAVE_QT) ViewObjectWidget (QWidget *view, const char *name); +#else + ViewObjectWidget (); +#endif /** * @brief dtor @@ -984,7 +998,7 @@ public: /** * @brief Gets the current mouse position */ - QPoint mouse_position () const + db::Point mouse_position () const { return m_mouse_pos; } @@ -1000,12 +1014,12 @@ public: /** * @brief Translates a screen coordinate in micrometer coordinates */ - db::DPoint pixel_to_um (const QPoint &pt) const; + db::DPoint pixel_to_um (const db::Point &pt) const; /** * @brief Translates a screen coordinate in micrometer coordinates */ - db::DPoint pixel_to_um (const QPointF &pt) const; + db::DPoint pixel_to_um (const db::DPoint &pt) const; /** * @brief Gets a flag indicating whether the mouse is inside the window @@ -1016,6 +1030,7 @@ public: } protected: +#if defined(HAVE_QT) /** * @brief Qt focus event handler */ @@ -1084,6 +1099,11 @@ protected: * @brief Qt mouse wheel event handler */ void wheelEvent (QWheelEvent *e); +#endif + +#if !defined(HAVE_QT) + void update (); +#endif /** * @brief Set the transformation for mouse events @@ -1104,8 +1124,8 @@ private: bool m_needs_update_bg; lay::ViewService *mp_active_service; db::DCplxTrans m_trans; - QPoint m_mouse_pos; - QPoint m_mouse_pressed; + db::Point m_mouse_pos; + db::Point m_mouse_pressed; bool m_mouse_pressed_state; unsigned int m_mouse_buttons; bool m_in_mouse_move; @@ -1117,6 +1137,8 @@ private: void begin_mouse_event (lay::Cursor::cursor_shape cursor = lay::Cursor::keep); void end_mouse_event (); void objects_changed (); + int widget_height () const; + int widget_width () const; /** * @brief Register a service @@ -1328,10 +1350,12 @@ public: */ void clear_fg_bitmaps (); +#if defined(HAVE_QT) // @@@ /** * @brief Return the background image */ virtual QImage &bg_image () = 0; +#endif /** * @brief Set the width and height and resolution diff --git a/src/laybasic/laybasic/laybasic.pro b/src/laybasic/laybasic/laybasic.pro index 6010e29b0..f2f707d15 100644 --- a/src/laybasic/laybasic/laybasic.pro +++ b/src/laybasic/laybasic/laybasic.pro @@ -93,7 +93,6 @@ DEFINES += MAKE_LAYBASIC_LIBRARY gtf.cc \ layAbstractMenu.cc \ layBackgroundAwareTreeStyle.cc \ - layBitmapRenderer.cc \ layBitmapsToImage.cc \ layBookmarkList.cc \ layBookmarkManagementForm.cc \ @@ -121,7 +120,6 @@ DEFINES += MAKE_LAYBASIC_LIBRARY layEditorServiceBase.cc \ layFileDialog.cc \ layGenericSyntaxHighlighter.cc \ - layGridNet.cc \ layHierarchyControlPanel.cc \ layIndexedNetlistModel.cc \ layItemDelegates.cc \ @@ -129,10 +127,8 @@ DEFINES += MAKE_LAYBASIC_LIBRARY layLayerMappingWidget.cc \ layLayerToolbox.cc \ layLayerTreeModel.cc \ - layLayoutCanvas.cc \ layLayoutPropertiesForm.cc \ layLayoutStatisticsForm.cc \ - layLayoutView.cc \ layLayoutViewConfigPages.cc \ layLayoutViewFunctions.cc \ layLibrariesView.cc \ @@ -154,6 +150,7 @@ DEFINES += MAKE_LAYBASIC_LIBRARY laySelectLineStyleForm.cc \ laySelectStippleForm.cc \ laySelector.cc \ + layStream.cc \ layTechnology.cc \ layTipDialog.cc \ layWidgets.cc \ @@ -168,7 +165,6 @@ DEFINES += MAKE_LAYBASIC_LIBRARY layAbstractMenu.h \ layBackgroundAwareTreeStyle.h \ layBitmap.h \ - layBitmapRenderer.h \ layBitmapsToImage.h \ layBookmarkList.h \ layBookmarkManagementForm.h \ @@ -197,7 +193,6 @@ DEFINES += MAKE_LAYBASIC_LIBRARY layEditorServiceBase.h \ layFileDialog.h \ layGenericSyntaxHighlighter.h \ - layGridNet.h \ layHierarchyControlPanel.h \ layIndexedNetlistModel.h \ layItemDelegates.h \ @@ -205,10 +200,8 @@ DEFINES += MAKE_LAYBASIC_LIBRARY layLayerMappingWidget.h \ layLayerToolbox.h \ layLayerTreeModel.h \ - layLayoutCanvas.h \ layLayoutPropertiesForm.h \ layLayoutStatisticsForm.h \ - layLayoutView.h \ layLayoutViewConfigPages.h \ layLayoutViewFunctions.h \ layLibrariesView.h \ @@ -230,6 +223,7 @@ DEFINES += MAKE_LAYBASIC_LIBRARY laySelectLineStyleForm.h \ laySelectStippleForm.h \ laySelector.h \ + layStream.h \ layTechnology.h \ layTipDialog.h \ layWidgets.h \ @@ -246,6 +240,7 @@ SOURCES += \ gsiDeclLayLayers.cc \ layAnnotationShapes.cc \ layBitmap.cc \ + layBitmapRenderer.cc \ layColor.cc \ layColorPalette.cc \ layDispatcher.cc \ @@ -254,12 +249,16 @@ SOURCES += \ layDrawing.cc \ layEditable.cc \ layFinder.cc \ + layGridNet.cc \ layFixedFont.cc \ + layLayoutCanvas.cc \ + layLayoutView.cc \ layLineStylePalette.cc \ layLineStyles.cc \ layMarker.cc \ layMouseTracker.cc \ layMove.cc \ + layNetColorizer.cc \ layObjectInstPath.cc \ layParsedLayerSource.cc \ layPlugin.cc \ @@ -271,7 +270,6 @@ SOURCES += \ layRubberBox.cc \ laySnap.cc \ layStipplePalette.cc \ - layStream.cc \ layCanvasPlane.cc \ layLayoutViewBase.cc \ layLayerProperties.cc \ @@ -282,20 +280,25 @@ SOURCES += \ HEADERS += \ layAnnotationShapes.h \ layBitmap.h \ + layBitmapRenderer.h \ layColorPalette.h \ layDispatcher.h \ layDisplayState.h \ layDitherPattern.h \ layDrawing.h \ layEditable.h \ + layLayoutCanvas.h \ + layLayoutView.h \ layFinder.h \ layFixedFont.h \ + layGridNet.h \ layLayoutViewBase.h \ layLineStylePalette.h \ layLineStyles.h \ layMarker.h \ layMouseTracker.h \ layMove.h \ + layNetColorizer.h \ layObjectInstPath.h \ layParsedLayerSource.h \ layPlugin.h \ @@ -307,7 +310,6 @@ HEADERS += \ layRubberBox.h \ laySnap.h \ layStipplePalette.h \ - layStream.h \ layLayerProperties.h \ layCanvasPlane.h \ layViewObject.h \ diff --git a/src/laybasic/unit_tests/layAbstractMenuTests.cc b/src/laybasic/unit_tests/layAbstractMenuTests.cc index 16b1ab1ff..3f6c67ada 100644 --- a/src/laybasic/unit_tests/layAbstractMenuTests.cc +++ b/src/laybasic/unit_tests/layAbstractMenuTests.cc @@ -20,6 +20,8 @@ */ +#if defined(HAVE_QT) + #include "layAbstractMenu.h" #include "tlUnitTest.h" @@ -184,3 +186,4 @@ TEST(3_ActionReferences) EXPECT_EQ (action.get () == 0, true); } +#endif diff --git a/src/laybasic/unit_tests/layBitmapsToImage.cc b/src/laybasic/unit_tests/layBitmapsToImage.cc index e38c1c0d0..120c3eafc 100644 --- a/src/laybasic/unit_tests/layBitmapsToImage.cc +++ b/src/laybasic/unit_tests/layBitmapsToImage.cc @@ -20,7 +20,7 @@ */ - +#if defined(HAVE_QT) // @@@ #include "layBitmapsToImage.h" #include "layBitmap.h" #include "layDitherPattern.h" @@ -940,3 +940,4 @@ TEST(1) } +#endif diff --git a/src/laybasic/unit_tests/layNetlistBrowserTreeModelTests.cc b/src/laybasic/unit_tests/layNetlistBrowserTreeModelTests.cc index b6dff3fbd..f87df3f2f 100644 --- a/src/laybasic/unit_tests/layNetlistBrowserTreeModelTests.cc +++ b/src/laybasic/unit_tests/layNetlistBrowserTreeModelTests.cc @@ -20,6 +20,8 @@ */ +#if defined(HAVE_QT) // @@@ + #include "layNetlistBrowserTreeModel.h" #include "tlUnitTest.h" @@ -103,3 +105,5 @@ TEST (2) EXPECT_EQ (model->parent (model->index (1, 0, inv2PairIndex)).isValid (), true); EXPECT_EQ (model->parent (model->index (1, 0, inv2PairIndex)).internalId () == inv2PairIndex.internalId (), true); } + +#endif From 48f5f95a8f4f84734eea6a1086a996fbf0c8fbf9 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 1 May 2022 20:23:53 +0200 Subject: [PATCH 14/88] WIP --- src/edt/edt/edtMainService.cc | 3 +- src/laybasic/laybasic/layGridNet.cc | 233 ++++++------------ src/laybasic/laybasic/layGridNet.h | 29 +-- src/laybasic/laybasic/layGridNetConfigPage.cc | 113 +++++++++ src/laybasic/laybasic/layGridNetConfigPage.h | 60 +++++ .../laybasic/layNetlistBrowserModel.cc | 4 +- .../laybasic/layNetlistBrowserModel.h | 2 +- src/laybasic/laybasic/laySnap.cc | 8 +- src/laybasic/laybasic/laySnap.h | 6 +- src/laybasic/laybasic/layViewObject.cc | 24 +- src/laybasic/laybasic/laybasic.pro | 2 + src/laybasic/unit_tests/layBitmapsToImage.cc | 2 +- 12 files changed, 279 insertions(+), 207 deletions(-) create mode 100644 src/laybasic/laybasic/layGridNetConfigPage.cc create mode 100644 src/laybasic/laybasic/layGridNetConfigPage.h diff --git a/src/edt/edt/edtMainService.cc b/src/edt/edt/edtMainService.cc index 30e5ff26c..8f1500a3f 100644 --- a/src/edt/edt/edtMainService.cc +++ b/src/edt/edt/edtMainService.cc @@ -2113,7 +2113,8 @@ MainService::cm_tap () int icon_size = menu->style ()->pixelMetric (QStyle::PM_ButtonIconSize); - QPoint mp = view ()->view_object_widget ()->mapToGlobal (view ()->view_object_widget ()->mouse_position ()); + db::Point mp_local = view ()->view_object_widget ()->mouse_position (); + QPoint mp = view ()->view_object_widget ()->mapToGlobal (QPoint (mp_local.x (), mp_local.y ())); for (std::vector::const_iterator l = tapped_layers.begin (); l != tapped_layers.end (); ++l) { QAction *a = menu->addAction (lay::LayerTreeModel::icon_for_layer (*l, view (), icon_size, icon_size, 0, true), tl::to_qstring ((*l)->display_string (view (), true, true /*with source*/))); diff --git a/src/laybasic/laybasic/layGridNet.cc b/src/laybasic/laybasic/layGridNet.cc index 47fc79b81..d23d7c858 100644 --- a/src/laybasic/laybasic/layGridNet.cc +++ b/src/laybasic/laybasic/layGridNet.cc @@ -23,16 +23,14 @@ #include "laybasicConfig.h" #include "layGridNet.h" -#if defined(HAVE_QT) // @@@ -# include "layWidgets.h" -#endif -#include "layLayoutView.h" #include "layConverters.h" +#include "layLayoutView.h" #include "layFixedFont.h" #include "laySnap.h" #include "dbTrans.h" -#if defined(HAVE_QT) // @@@ -# include "ui_GridNetConfigPage.h" + +#if defined(HAVE_QT) +# include "layGridNetConfigPage.h" #endif namespace lay @@ -56,32 +54,28 @@ static struct { { lay::GridNet::CheckerBoard, "checkerboard" } }; -class GridNetStyleConverter +void +GridNetStyleConverter::from_string (const std::string &value, lay::GridNet::GridStyle &style) { -public: - void - from_string (const std::string &value, lay::GridNet::GridStyle &style) - { - for (unsigned int i = 0; i < sizeof (grid_styles) / sizeof (grid_styles [0]); ++i) { - if (value == grid_styles [i].string) { - style = grid_styles [i].style; - return; - } + for (unsigned int i = 0; i < sizeof (grid_styles) / sizeof (grid_styles [0]); ++i) { + if (value == grid_styles [i].string) { + style = grid_styles [i].style; + return; } - throw tl::Exception (tl::to_string (tr ("Invalid grid net style: ")) + value); } + throw tl::Exception (tl::to_string (tr ("Invalid grid net style: ")) + value); +} - std::string - to_string (lay::GridNet::GridStyle style) - { - for (unsigned int i = 0; i < sizeof (grid_styles) / sizeof (grid_styles [0]); ++i) { - if (style == grid_styles [i].style) { - return grid_styles [i].string; - } +std::string +GridNetStyleConverter::to_string (lay::GridNet::GridStyle style) +{ + for (unsigned int i = 0; i < sizeof (grid_styles) / sizeof (grid_styles [0]); ++i) { + if (style == grid_styles [i].style) { + return grid_styles [i].string; } - return ""; } -}; + return ""; +} // ------------------------------------------------------------ // Implementation of the GridNetPluginDeclaration @@ -118,85 +112,6 @@ GridNetPluginDeclaration::create_plugin (db::Manager *, Dispatcher *, lay::Layou static tl::RegisteredClass config_decl (new GridNetPluginDeclaration (), 2010, "GridNetPlugin"); -// ------------------------------------------------------------ -// Implementation of the configuration page - -#if defined(HAVE_QT) -GridNetConfigPage::GridNetConfigPage (QWidget *parent) - : lay::ConfigPage (parent) -{ - mp_ui = new Ui::GridNetConfigPage (); - mp_ui->setupUi (this); - - mp_grid_color_cbtn = new lay::ColorButton (mp_ui->grid_net_color_pb); - mp_grid_grid_color_cbtn = new lay::ColorButton (mp_ui->grid_grid_color_pb); - mp_grid_axis_color_cbtn = new lay::ColorButton (mp_ui->grid_axis_color_pb); - mp_grid_ruler_color_cbtn = new lay::ColorButton (mp_ui->grid_ruler_color_pb); -} - -GridNetConfigPage::~GridNetConfigPage () -{ - delete mp_ui; - mp_ui = 0; -} - -void -GridNetConfigPage::setup (lay::Dispatcher *root) -{ - std::string value; - - // Grid visibility - bool visible = false; - root->config_get (cfg_grid_visible, visible); - mp_ui->grid_group->setChecked (visible); - - bool show_ruler = false; - root->config_get (cfg_grid_show_ruler, show_ruler); - mp_ui->show_ruler->setChecked (show_ruler); - - QColor color; - root->config_get (cfg_grid_color, color, ColorConverter ()); - mp_grid_color_cbtn->set_color (color); - - root->config_get (cfg_grid_grid_color, color, ColorConverter ()); - mp_grid_grid_color_cbtn->set_color (color); - - root->config_get (cfg_grid_axis_color, color, ColorConverter ()); - mp_grid_axis_color_cbtn->set_color (color); - - root->config_get (cfg_grid_ruler_color, color, ColorConverter ()); - mp_grid_ruler_color_cbtn->set_color (color); - - lay::GridNet::GridStyle style; - - style = lay::GridNet::Invisible; - root->config_get (cfg_grid_style0, style, GridNetStyleConverter ()); - mp_ui->style0_cbx->setCurrentIndex (int (style)); - - style = lay::GridNet::Invisible; - root->config_get (cfg_grid_style1, style, GridNetStyleConverter ()); - mp_ui->style1_cbx->setCurrentIndex (int (style)); - - style = lay::GridNet::Invisible; - root->config_get (cfg_grid_style2, style, GridNetStyleConverter ()); - mp_ui->style2_cbx->setCurrentIndex (int (style)); -} - -void -GridNetConfigPage::commit (lay::Dispatcher *root) -{ - root->config_set (cfg_grid_visible, mp_ui->grid_group->isChecked ()); - root->config_set (cfg_grid_show_ruler, mp_ui->show_ruler->isChecked ()); - root->config_set (cfg_grid_color, mp_grid_color_cbtn->get_color (), lay::ColorConverter ()); - root->config_set (cfg_grid_grid_color, mp_grid_grid_color_cbtn->get_color (), lay::ColorConverter ()); - root->config_set (cfg_grid_axis_color, mp_grid_axis_color_cbtn->get_color (), lay::ColorConverter ()); - root->config_set (cfg_grid_ruler_color, mp_grid_ruler_color_cbtn->get_color (), lay::ColorConverter ()); - root->config_set (cfg_grid_style0, lay::GridNet::GridStyle (mp_ui->style0_cbx->currentIndex ()), GridNetStyleConverter ()); - root->config_set (cfg_grid_style1, lay::GridNet::GridStyle (mp_ui->style1_cbx->currentIndex ()), GridNetStyleConverter ()); - root->config_set (cfg_grid_style2, lay::GridNet::GridStyle (mp_ui->style2_cbx->currentIndex ()), GridNetStyleConverter ()); -} -#endif - // ------------------------------------------------------------ // Implementation of the GridNet object @@ -302,14 +217,14 @@ public: // .. nothing yet .. } - void set (const QPoint &p, QColor c) + void set (const db::Point &p, lay::Color c) { if (p.x () >= 0 && p.x () < m_width && p.y () >= 0 && p.y () < m_height) { ((unsigned int *) mp_img->scanLine (p.y ())) [p.x ()] = c.rgb (); } } - void draw_line (const QPoint &p1, const QPoint &p2, QColor c) + void draw_line (const db::Point &p1, const db::Point &p2, lay::Color c) { if (p1.x () == p2.x ()) { @@ -343,28 +258,28 @@ public: } } - void fill_rect (const QPoint &p1, const QPoint &p2, QColor c) + void fill_rect (const db::Point &p1, const db::Point &p2, lay::Color c) { int y1 = std::min (p1.y (), p2.y ()); int y2 = std::max (p1.y (), p2.y ()); for (int y = y1; y <= y2; ++y) { - draw_line (QPoint (p1.x (), y), QPoint (p2.x (), y), c); + draw_line (db::Point (p1.x (), y), db::Point (p2.x (), y), c); } } - void draw_rect (const QPoint &p1, const QPoint &p2, QColor c) + void draw_rect (const db::Point &p1, const db::Point &p2, lay::Color c) { int y1 = std::min (p1.y (), p2.y ()); int y2 = std::max (p1.y (), p2.y ()); int x1 = std::min (p1.x (), p2.x ()); int x2 = std::max (p1.x (), p2.x ()); - draw_line (QPoint (x1, y1), QPoint (x2, y1), c); - draw_line (QPoint (x1, y2), QPoint (x2, y2), c); - draw_line (QPoint (x1, y1), QPoint (x1, y2), c); - draw_line (QPoint (x2, y1), QPoint (x2, y2), c); + draw_line (db::Point (x1, y1), db::Point (x2, y1), c); + draw_line (db::Point (x1, y2), db::Point (x2, y2), c); + draw_line (db::Point (x1, y1), db::Point (x1, y2), c); + draw_line (db::Point (x2, y1), db::Point (x2, y2), c); } - void draw_text (const char *t, const QPoint &p, QColor c, int halign, int valign) + void draw_text (const char *t, const db::Point &p, lay::Color c, int halign, int valign) { const lay::FixedFont &ff = lay::FixedFont::get_font (m_resolution); int x = p.x (), y = p.y (); @@ -516,16 +431,16 @@ GridNet::render_bg (const lay::Viewport &vp, ViewObjectCanvas &canvas) int xoffset = int (floor (0.5 + fw * 2.5)); int yoffset = int (floor (0.5 + fw * 2.5)); - painter.fill_rect (QPoint (xoffset, vp.height () - yoffset - rh / 2), - QPoint (xoffset + int (floor (0.5 + dgrid)), vp.height () - yoffset + rh / 2), + painter.fill_rect (db::Point (xoffset, vp.height () - yoffset - rh / 2), + db::Point (xoffset + int (floor (0.5 + dgrid)), vp.height () - yoffset + rh / 2), ruler_color); - painter.draw_rect (QPoint (xoffset + int (floor (0.5 + dgrid)), vp.height () - yoffset - rh / 2), - QPoint (xoffset + int (floor (0.5 + 2 * dgrid)), vp.height () - yoffset + rh / 2), + painter.draw_rect (db::Point (xoffset + int (floor (0.5 + dgrid)), vp.height () - yoffset - rh / 2), + db::Point (xoffset + int (floor (0.5 + 2 * dgrid)), vp.height () - yoffset + rh / 2), ruler_color); painter.draw_text (tl::sprintf ("%g \265m", grid * 2).c_str (), - QPoint (xoffset + int (floor (0.5 + trans.ctrans (2 * grid))), vp.height () - yoffset - rh / 2 - 2), + db::Point (xoffset + int (floor (0.5 + trans.ctrans (2 * grid))), vp.height () - yoffset - rh / 2 - 2), ruler_color, -1, 1); if (mp_view->global_trans ().fp_trans () != db::DFTrans ()) { @@ -550,9 +465,9 @@ GridNet::render_bg (const lay::Viewport &vp, ViewObjectCanvas &canvas) poly.transform (db::FTrans (mp_view->global_trans ().fp_trans ())); for (db::Polygon::polygon_edge_iterator e = poly.begin_edge (); !e.at_end (); ++e) { - QPoint p0 (xoffset + 2 * rh, vp.height () - yoffset - rh * 5); - QPoint p1 = p0 + QPoint (int (floor (0.5 + (*e).p1 ().x () * 0.1 * rh * 4)), -int (floor (0.5 + (*e).p1 ().y () * 0.1 * rh * 4))); - QPoint p2 = p0 + QPoint (int (floor (0.5 + (*e).p2 ().x () * 0.1 * rh * 4)), -int (floor (0.5 + (*e).p2 ().y () * 0.1 * rh * 4))); + db::Point p0 (xoffset + 2 * rh, vp.height () - yoffset - rh * 5); + db::Point p1 = p0 + db::Vector (int (floor (0.5 + (*e).p1 ().x () * 0.1 * rh * 4)), -int (floor (0.5 + (*e).p1 ().y () * 0.1 * rh * 4))); + db::Point p2 = p0 + db::Vector (int (floor (0.5 + (*e).p2 ().x () * 0.1 * rh * 4)), -int (floor (0.5 + (*e).p2 ().y () * 0.1 * rh * 4))); painter.draw_line (p1, p2, ruler_color); } @@ -596,9 +511,9 @@ GridNet::render_bg (const lay::Viewport &vp, ViewObjectCanvas &canvas) for (db::DCoord x = x1; x < x2 + grid * eps; x += grid) { for (db::DCoord y = y1; y < y2 + grid * eps; y += grid) { - QPoint p (draw_round (trans * db::DPoint (x, y), vp.height ())); - painter.draw_line (p - QPoint (2, 0), p + QPoint (2, 0), grid_color); - painter.draw_line (p - QPoint (0, 2), p + QPoint (0, 2), grid_color); + db::Point p (draw_round (trans * db::DPoint (x, y), vp.height ())); + painter.draw_line (p - db::Vector (2, 0), p + db::Vector (2, 0), grid_color); + painter.draw_line (p - db::Vector (0, 2), p + db::Vector (0, 2), grid_color); } } @@ -609,15 +524,15 @@ GridNet::render_bg (const lay::Viewport &vp, ViewObjectCanvas &canvas) // the way we iterate here is safe against integer overflow .. n = nx; for (db::DCoord x = x1; n > 0; x += grid, --n) { - QPoint p1 (draw_round (trans * db::DPoint (x, y1), vp.height ())); - QPoint p2 (draw_round (trans * db::DPoint (x, y2), vp.height ())); + db::Point p1 (draw_round (trans * db::DPoint (x, y1), vp.height ())); + db::Point p2 (draw_round (trans * db::DPoint (x, y2), vp.height ())); painter.draw_line (p1, p2, grid_color); } n = ny; for (db::DCoord y = y1; n > 0; y += grid, --n) { - QPoint p1 (draw_round (trans * db::DPoint (x1, y), vp.height ())); - QPoint p2 (draw_round (trans * db::DPoint (x2, y), vp.height ())); + db::Point p1 (draw_round (trans * db::DPoint (x1, y), vp.height ())); + db::Point p2 (draw_round (trans * db::DPoint (x2, y), vp.height ())); painter.draw_line (p1, p2, grid_color); } @@ -637,23 +552,23 @@ GridNet::render_bg (const lay::Viewport &vp, ViewObjectCanvas &canvas) // the way we iterate here is safe against integer overflow .. n = nx; for (db::DCoord x = x1; n > 0; x += grid, --n) { - QPoint p1 (draw_round (trans * db::DPoint (x, y1), vp.height ())); - QPoint p2 (draw_round (trans * db::DPoint (x, y2), vp.height ())); + db::Point p1 (draw_round (trans * db::DPoint (x, y1), vp.height ())); + db::Point p2 (draw_round (trans * db::DPoint (x, y2), vp.height ())); painter.draw_line (p1, p2, grid_color); for (db::DCoord y = y1; y < y2 + g * eps; y += g) { - QPoint p (draw_round (trans * db::DPoint (x, y), vp.height ())); - painter.draw_line (p - QPoint (2, 0), p + QPoint (2, 0), grid_color); + db::Point p (draw_round (trans * db::DPoint (x, y), vp.height ())); + painter.draw_line (p - db::Vector (2, 0), p + db::Vector (2, 0), grid_color); } } n = ny; for (db::DCoord y = y1; n > 0; y += grid, --n) { - QPoint p1 (draw_round (trans * db::DPoint (x1, y), vp.height ())); - QPoint p2 (draw_round (trans * db::DPoint (x2, y), vp.height ())); + db::Point p1 (draw_round (trans * db::DPoint (x1, y), vp.height ())); + db::Point p2 (draw_round (trans * db::DPoint (x2, y), vp.height ())); painter.draw_line (p1, p2, grid_color); for (db::DCoord x = x1; x < x2 + g * eps; x += g) { - QPoint p (draw_round (trans * db::DPoint (x, y), vp.height ())); - painter.draw_line (p - QPoint (0, 2), p + QPoint (0, 2), grid_color); + db::Point p (draw_round (trans * db::DPoint (x, y), vp.height ())); + painter.draw_line (p - db::Vector (0, 2), p + db::Vector (0, 2), grid_color); } } @@ -663,9 +578,9 @@ GridNet::render_bg (const lay::Viewport &vp, ViewObjectCanvas &canvas) for (db::DCoord y = y1; y < y2 + grid * eps; y += grid) { double idx = (x + y) / grid + eps; if (idx - 2.0 * floor (idx * 0.5) < 0.5) { - QPoint p1 (draw_round (trans * db::DPoint (x, y), vp.height ())); - QPoint p2 (draw_round (trans * db::DPoint (x + grid, y + grid), vp.height ())); - painter.fill_rect (p1, p2 + QPoint (-1, 1), grid_color); + db::Point p1 (draw_round (trans * db::DPoint (x, y), vp.height ())); + db::Point p2 (draw_round (trans * db::DPoint (x + grid, y + grid), vp.height ())); + painter.fill_rect (p1, p2 + db::Vector (-1, 1), grid_color); } } } @@ -718,28 +633,28 @@ GridNet::render_bg (const lay::Viewport &vp, ViewObjectCanvas &canvas) } else if (m_style0 == Crosses) { for (db::DCoord y = y1; y < y2 + grid * eps && draw_yaxis; y += grid) { - QPoint p (draw_round (trans * db::DPoint (0.0, y), vp.height ())); - painter.draw_line (p - QPoint (2, 0), p + QPoint (2, 0), axis_color); - painter.draw_line (p - QPoint (0, 2), p + QPoint (0, 2), axis_color); + db::Point p (draw_round (trans * db::DPoint (0.0, y), vp.height ())); + painter.draw_line (p - db::Vector (2, 0), p + db::Vector (2, 0), axis_color); + painter.draw_line (p - db::Vector (0, 2), p + db::Vector (0, 2), axis_color); } for (db::DCoord x = x1; x < x2 + grid * eps && draw_xaxis; x += grid) { - QPoint p (draw_round (trans * db::DPoint (x, 0.0), vp.height ())); - painter.draw_line (p - QPoint (2, 0), p + QPoint (2, 0), axis_color); - painter.draw_line (p - QPoint (0, 2), p + QPoint (0, 2), axis_color); + db::Point p (draw_round (trans * db::DPoint (x, 0.0), vp.height ())); + painter.draw_line (p - db::Vector (2, 0), p + db::Vector (2, 0), axis_color); + painter.draw_line (p - db::Vector (0, 2), p + db::Vector (0, 2), axis_color); } } else if (m_style0 == Lines) { // the way we iterate here is safe against integer overflow .. if (draw_yaxis) { - QPoint p1 (draw_round (trans * db::DPoint (0.0, y1), vp.height ())); - QPoint p2 (draw_round (trans * db::DPoint (0.0, y2), vp.height ())); + db::Point p1 (draw_round (trans * db::DPoint (0.0, y1), vp.height ())); + db::Point p2 (draw_round (trans * db::DPoint (0.0, y2), vp.height ())); painter.draw_line (p1, p2, axis_color); } if (draw_xaxis) { - QPoint p1 (draw_round (trans * db::DPoint (x1, 0.0), vp.height ())); - QPoint p2 (draw_round (trans * db::DPoint (x2, 0.0), vp.height ())); + db::Point p1 (draw_round (trans * db::DPoint (x1, 0.0), vp.height ())); + db::Point p2 (draw_round (trans * db::DPoint (x2, 0.0), vp.height ())); painter.draw_line (p1, p2, axis_color); } @@ -757,22 +672,22 @@ GridNet::render_bg (const lay::Viewport &vp, ViewObjectCanvas &canvas) // the way we iterate here is safe against integer overflow .. if (draw_yaxis) { - QPoint p1 (draw_round (trans * db::DPoint (0.0, y1), vp.height ())); - QPoint p2 (draw_round (trans * db::DPoint (0.0, y2), vp.height ())); + db::Point p1 (draw_round (trans * db::DPoint (0.0, y1), vp.height ())); + db::Point p2 (draw_round (trans * db::DPoint (0.0, y2), vp.height ())); painter.draw_line (p1, p2, axis_color); for (db::DCoord y = y1; y < y2 + g * eps; y += g) { - QPoint p (draw_round (trans * db::DPoint (0.0, y), vp.height ())); - painter.draw_line (p - QPoint (2, 0), p + QPoint (2, 0), axis_color); + db::Point p (draw_round (trans * db::DPoint (0.0, y), vp.height ())); + painter.draw_line (p - db::Vector (2, 0), p + db::Vector (2, 0), axis_color); } } if (draw_xaxis) { - QPoint p1 (draw_round (trans * db::DPoint (x1, 0.0), vp.height ())); - QPoint p2 (draw_round (trans * db::DPoint (x2, 0.0), vp.height ())); + db::Point p1 (draw_round (trans * db::DPoint (x1, 0.0), vp.height ())); + db::Point p2 (draw_round (trans * db::DPoint (x2, 0.0), vp.height ())); painter.draw_line (p1, p2, axis_color); for (db::DCoord x = x1; x < x2 + g * eps; x += g) { - QPoint p (draw_round (trans * db::DPoint (x, 0.0), vp.height ())); - painter.draw_line (p - QPoint (0, 2), p + QPoint (0, 2), axis_color); + db::Point p (draw_round (trans * db::DPoint (x, 0.0), vp.height ())); + painter.draw_line (p - db::Vector (0, 2), p + db::Vector (0, 2), axis_color); } } diff --git a/src/laybasic/laybasic/layGridNet.h b/src/laybasic/laybasic/layGridNet.h index 011091d6e..469d3d232 100644 --- a/src/laybasic/laybasic/layGridNet.h +++ b/src/laybasic/laybasic/layGridNet.h @@ -53,28 +53,6 @@ public: virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *, lay::LayoutViewBase *view) const; }; -#if defined(HAVE_QT) // @@@ -class GridNetConfigPage - : public lay::ConfigPage -{ -Q_OBJECT - -public: - GridNetConfigPage (QWidget *parent); - ~GridNetConfigPage (); - - virtual void setup (lay::Dispatcher *root); - virtual void commit (lay::Dispatcher *root); - -private: - Ui::GridNetConfigPage *mp_ui; - lay::ColorButton *mp_grid_color_cbtn; - lay::ColorButton *mp_grid_grid_color_cbtn; - lay::ColorButton *mp_grid_axis_color_cbtn; - lay::ColorButton *mp_grid_ruler_color_cbtn; -}; -#endif - class GridNet : public lay::BackgroundViewObject, public lay::Plugin @@ -111,6 +89,13 @@ private: GridStyle m_style2; }; +class GridNetStyleConverter +{ +public: + void from_string (const std::string &value, lay::GridNet::GridStyle &style); + std::string to_string (lay::GridNet::GridStyle style); +}; + } #endif diff --git a/src/laybasic/laybasic/layGridNetConfigPage.cc b/src/laybasic/laybasic/layGridNetConfigPage.cc new file mode 100644 index 000000000..07866fd48 --- /dev/null +++ b/src/laybasic/laybasic/layGridNetConfigPage.cc @@ -0,0 +1,113 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 "laybasicConfig.h" +#include "layGridNetConfigPage.h" +#include "layConverters.h" +#include "layDispatcher.h" +#include "layGridNet.h" +#include "layWidgets.h" +#include "ui_GridNetConfigPage.h" + +namespace lay +{ + +// ------------------------------------------------------------ +// Implementation of the configuration page + +GridNetConfigPage::GridNetConfigPage (QWidget *parent) + : lay::ConfigPage (parent) +{ + mp_ui = new Ui::GridNetConfigPage (); + mp_ui->setupUi (this); + + mp_grid_color_cbtn = new lay::ColorButton (mp_ui->grid_net_color_pb); + mp_grid_grid_color_cbtn = new lay::ColorButton (mp_ui->grid_grid_color_pb); + mp_grid_axis_color_cbtn = new lay::ColorButton (mp_ui->grid_axis_color_pb); + mp_grid_ruler_color_cbtn = new lay::ColorButton (mp_ui->grid_ruler_color_pb); +} + +GridNetConfigPage::~GridNetConfigPage () +{ + delete mp_ui; + mp_ui = 0; +} + +void +GridNetConfigPage::setup (lay::Dispatcher *root) +{ + std::string value; + + // Grid visibility + bool visible = false; + root->config_get (cfg_grid_visible, visible); + mp_ui->grid_group->setChecked (visible); + + bool show_ruler = false; + root->config_get (cfg_grid_show_ruler, show_ruler); + mp_ui->show_ruler->setChecked (show_ruler); + + QColor color; + root->config_get (cfg_grid_color, color, ColorConverter ()); + mp_grid_color_cbtn->set_color (color); + + root->config_get (cfg_grid_grid_color, color, ColorConverter ()); + mp_grid_grid_color_cbtn->set_color (color); + + root->config_get (cfg_grid_axis_color, color, ColorConverter ()); + mp_grid_axis_color_cbtn->set_color (color); + + root->config_get (cfg_grid_ruler_color, color, ColorConverter ()); + mp_grid_ruler_color_cbtn->set_color (color); + + lay::GridNet::GridStyle style; + + style = lay::GridNet::Invisible; + root->config_get (cfg_grid_style0, style, GridNetStyleConverter ()); + mp_ui->style0_cbx->setCurrentIndex (int (style)); + + style = lay::GridNet::Invisible; + root->config_get (cfg_grid_style1, style, GridNetStyleConverter ()); + mp_ui->style1_cbx->setCurrentIndex (int (style)); + + style = lay::GridNet::Invisible; + root->config_get (cfg_grid_style2, style, GridNetStyleConverter ()); + mp_ui->style2_cbx->setCurrentIndex (int (style)); +} + +void +GridNetConfigPage::commit (lay::Dispatcher *root) +{ + root->config_set (cfg_grid_visible, mp_ui->grid_group->isChecked ()); + root->config_set (cfg_grid_show_ruler, mp_ui->show_ruler->isChecked ()); + root->config_set (cfg_grid_color, mp_grid_color_cbtn->get_color (), lay::ColorConverter ()); + root->config_set (cfg_grid_grid_color, mp_grid_grid_color_cbtn->get_color (), lay::ColorConverter ()); + root->config_set (cfg_grid_axis_color, mp_grid_axis_color_cbtn->get_color (), lay::ColorConverter ()); + root->config_set (cfg_grid_ruler_color, mp_grid_ruler_color_cbtn->get_color (), lay::ColorConverter ()); + root->config_set (cfg_grid_style0, lay::GridNet::GridStyle (mp_ui->style0_cbx->currentIndex ()), GridNetStyleConverter ()); + root->config_set (cfg_grid_style1, lay::GridNet::GridStyle (mp_ui->style1_cbx->currentIndex ()), GridNetStyleConverter ()); + root->config_set (cfg_grid_style2, lay::GridNet::GridStyle (mp_ui->style2_cbx->currentIndex ()), GridNetStyleConverter ()); +} + +} // namespace lay + diff --git a/src/laybasic/laybasic/layGridNetConfigPage.h b/src/laybasic/laybasic/layGridNetConfigPage.h new file mode 100644 index 000000000..1e6599131 --- /dev/null +++ b/src/laybasic/laybasic/layGridNetConfigPage.h @@ -0,0 +1,60 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 + +*/ + + +#ifndef HDR_layGridNetConfigPage +#define HDR_layGridNetConfigPage + +#include "layPluginConfigPage.h" + +namespace Ui { + class GridNetConfigPage; +} + +namespace lay { + +class ColorButton; + +class GridNetConfigPage + : public lay::ConfigPage +{ +Q_OBJECT + +public: + GridNetConfigPage (QWidget *parent); + ~GridNetConfigPage (); + + virtual void setup (lay::Dispatcher *root); + virtual void commit (lay::Dispatcher *root); + +private: + Ui::GridNetConfigPage *mp_ui; + lay::ColorButton *mp_grid_color_cbtn; + lay::ColorButton *mp_grid_grid_color_cbtn; + lay::ColorButton *mp_grid_axis_color_cbtn; + lay::ColorButton *mp_grid_ruler_color_cbtn; +}; + +} + +#endif + diff --git a/src/laybasic/laybasic/layNetlistBrowserModel.cc b/src/laybasic/laybasic/layNetlistBrowserModel.cc index 8ed6a964b..67e15af1a 100644 --- a/src/laybasic/laybasic/layNetlistBrowserModel.cc +++ b/src/laybasic/laybasic/layNetlistBrowserModel.cc @@ -2380,7 +2380,7 @@ NetlistBrowserModel::NetlistBrowserModel (QWidget *parent, db::LayoutToNetlist * { mp_root.reset (new RootItemData ()); mp_indexer.reset (new SingleIndexedNetlistModel (l2ndb->netlist ())); - connect (mp_colorizer, SIGNAL (colors_changed ()), this, SLOT (colors_changed ())); + mp_colorizer->colors_changed.add (this, &NetlistBrowserModel::colors_changed); m_object_column = 0; m_status_column = -1; @@ -2393,7 +2393,7 @@ NetlistBrowserModel::NetlistBrowserModel (QWidget *parent, db::LayoutVsSchematic { mp_root.reset (new RootItemData ()); mp_indexer.reset (new NetlistCrossReferenceModel (lvsdb->cross_ref ())); - connect (mp_colorizer, SIGNAL (colors_changed ()), this, SLOT (colors_changed ())); + mp_colorizer->colors_changed.add (this, &NetlistBrowserModel::colors_changed); m_object_column = 0; m_status_column = 1; diff --git a/src/laybasic/laybasic/layNetlistBrowserModel.h b/src/laybasic/laybasic/layNetlistBrowserModel.h index 3028792bc..6a43c954c 100644 --- a/src/laybasic/laybasic/layNetlistBrowserModel.h +++ b/src/laybasic/laybasic/layNetlistBrowserModel.h @@ -221,7 +221,7 @@ struct LAYBASIC_PUBLIC NetlistObjectsPath * - terminals and nets */ class LAYBASIC_PUBLIC NetlistBrowserModel - : public QAbstractItemModel + : public QAbstractItemModel, public tl::Object { Q_OBJECT diff --git a/src/laybasic/laybasic/laySnap.cc b/src/laybasic/laybasic/laySnap.cc index 1243a7218..c123da738 100644 --- a/src/laybasic/laybasic/laySnap.cc +++ b/src/laybasic/laybasic/laySnap.cc @@ -129,19 +129,17 @@ int draw_round (double x) } } -#if defined(HAVE_QT) -QPoint draw_round (db::DPoint p, int h) +db::Point draw_round (db::DPoint p, int h) { - return QPoint (draw_round (p.x ()), h - 1 - draw_round (p.y ())); + return db::Point (draw_round (p.x ()), h - 1 - draw_round (p.y ())); } -std::pair +std::pair draw_round (const db::DPoint &p1, const db::DPoint &p2, int h) { std::pair dp = draw_round_dbl (p1, p2, h); return std::make_pair (draw_round (dp.first, h), draw_round (dp.second, h)); } -#endif std::pair draw_round_dbl (const db::DPoint &p1, const db::DPoint &p2, int /*h*/) diff --git a/src/laybasic/laybasic/laySnap.h b/src/laybasic/laybasic/laySnap.h index 776cb1acd..750ac55a8 100644 --- a/src/laybasic/laybasic/laySnap.h +++ b/src/laybasic/laybasic/laySnap.h @@ -246,17 +246,15 @@ namespace lay */ LAYBASIC_PUBLIC int draw_round (double x); -#if defined(HAVE_QT) /** * @brief rounding (and height-transformation) of a double point */ - LAYBASIC_PUBLIC QPoint draw_round (db::DPoint p, int h); + LAYBASIC_PUBLIC db::Point draw_round (db::DPoint p, int h); /** * @brief rounding (and height-transformation) of a two-point vector */ - LAYBASIC_PUBLIC std::pair draw_round (const db::DPoint &p1, const db::DPoint &p2, int h); -#endif + LAYBASIC_PUBLIC std::pair draw_round (const db::DPoint &p1, const db::DPoint &p2, int h); /** * @brief rounding (and height-transformation) of a two-point vector diff --git a/src/laybasic/laybasic/layViewObject.cc b/src/laybasic/laybasic/layViewObject.cc index 9f8ac62d8..564353267 100644 --- a/src/laybasic/laybasic/layViewObject.cc +++ b/src/laybasic/laybasic/layViewObject.cc @@ -493,7 +493,7 @@ BEGIN_PROTECTED const DragDropDataBase *dd = get_drag_drop_data (event->mimeData ()); if (dd) { - db::DPoint p = pixel_to_um (event->pos ()); + db::DPoint p = pixel_to_um (db::Point (event->pos ().x (), event->pos ().y ())); bool done = drag_enter_event (p, dd); service_iterator svc = begin_services (); @@ -538,7 +538,7 @@ BEGIN_PROTECTED const DragDropDataBase *dd = get_drag_drop_data (event->mimeData ()); if (dd) { - db::DPoint p = pixel_to_um (event->pos ()); + db::DPoint p = pixel_to_um (db::Point (event->pos ().x (), event->pos ().y ())); bool done = drag_move_event (p, dd); service_iterator svc = begin_services (); @@ -562,7 +562,7 @@ BEGIN_PROTECTED const DragDropDataBase *dd = get_drag_drop_data (event->mimeData ()); if (dd) { - db::DPoint p = pixel_to_um (event->pos ()); + db::DPoint p = pixel_to_um (db::Point (event->pos ().x (), event->pos ().y ())); bool done = drop_event (p, dd); service_iterator svc = begin_services (); @@ -583,7 +583,7 @@ ViewObjectWidget::mouseMoveEvent (QMouseEvent *e) { BEGIN_PROTECTED ensure_entered (); - m_mouse_pos = e->pos (); + m_mouse_pos = db::Point (e->pos ().x (), e->pos ().y ()); m_mouse_buttons = qt_to_buttons (e->buttons (), e->modifiers ()); do_mouse_move (); END_PROTECTED @@ -683,13 +683,13 @@ BEGIN_PROTECTED bool done = false; - m_mouse_pos = e->pos (); - m_mouse_pressed = e->pos (); + m_mouse_pos = db::Point (e->pos ().x (), e->pos ().y ()); + m_mouse_pressed = m_mouse_pos; m_mouse_pressed_state = false; unsigned int buttons = qt_to_buttons (e->buttons (), e->modifiers ()); - db::DPoint p = pixel_to_um (e->pos ()); + db::DPoint p = pixel_to_um (m_mouse_pos); for (std::list::iterator g = m_grabbed.begin (); !done && g != m_grabbed.end (); ) { std::list::iterator gg = g; @@ -805,7 +805,7 @@ BEGIN_PROTECTED #if QT_VERSION < 0x60000 int delta = e->delta (); - db::DPoint p = pixel_to_um (e->pos ()); + db::DPoint p = pixel_to_um (db::Point (e->pos ().x (), e->pos ().y ())); bool horizontal = (e->orientation () == Qt::Horizontal); #else int delta = e->angleDelta ().y (); @@ -852,8 +852,8 @@ ViewObjectWidget::mousePressEvent (QMouseEvent *e) ensure_entered (); setFocus (); - m_mouse_pos = e->pos (); - m_mouse_pressed = e->pos (); + m_mouse_pos = db::Point (e->pos ().x (), e->pos ().y ()); + m_mouse_pressed = m_mouse_pos; m_mouse_buttons = qt_to_buttons (e->buttons (), e->modifiers ()); @@ -869,8 +869,8 @@ BEGIN_PROTECTED bool done = false; - m_mouse_pos = e->pos (); - db::DPoint p = pixel_to_um (e->pos ()); + m_mouse_pos = db::Point (e->pos ().x (), e->pos ().y ()); + db::DPoint p = pixel_to_um (m_mouse_pos); for (std::list::iterator g = m_grabbed.begin (); !done && g != m_grabbed.end (); ) { std::list::iterator gg = g; diff --git a/src/laybasic/laybasic/laybasic.pro b/src/laybasic/laybasic/laybasic.pro index f2f707d15..59c6456ac 100644 --- a/src/laybasic/laybasic/laybasic.pro +++ b/src/laybasic/laybasic/laybasic.pro @@ -120,6 +120,7 @@ DEFINES += MAKE_LAYBASIC_LIBRARY layEditorServiceBase.cc \ layFileDialog.cc \ layGenericSyntaxHighlighter.cc \ + layGridNetConfigPage.cc \ layHierarchyControlPanel.cc \ layIndexedNetlistModel.cc \ layItemDelegates.cc \ @@ -193,6 +194,7 @@ DEFINES += MAKE_LAYBASIC_LIBRARY layEditorServiceBase.h \ layFileDialog.h \ layGenericSyntaxHighlighter.h \ + layGridNetConfigPage.h \ layHierarchyControlPanel.h \ layIndexedNetlistModel.h \ layItemDelegates.h \ diff --git a/src/laybasic/unit_tests/layBitmapsToImage.cc b/src/laybasic/unit_tests/layBitmapsToImage.cc index 120c3eafc..299d2c81d 100644 --- a/src/laybasic/unit_tests/layBitmapsToImage.cc +++ b/src/laybasic/unit_tests/layBitmapsToImage.cc @@ -95,7 +95,7 @@ TEST(1) lay::DitherPattern dp; lay::LineStyles ls; - QMutex m; + tl::Mutex m; lay::bitmaps_to_image (view_ops, pbitmaps, dp, ls, &img, 32, 32, 0, &m); EXPECT_EQ (to_string (img, 0x800000), From e49b9a5e8a5defd8078d217d1bef5f1bc20578bd Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 1 May 2022 21:56:47 +0200 Subject: [PATCH 15/88] WIP --- src/ant/ant/antPlugin.cc | 2 +- src/ant/ant/antPlugin.h | 2 +- src/ant/ant/antService.cc | 2 +- src/ant/ant/antService.h | 6 +-- src/ant/ant/gsiDeclAnt.cc | 16 +++--- src/edt/edt/edtInstPropertiesPage.cc | 6 +-- src/edt/edt/edtMainService.cc | 6 +-- src/edt/edt/edtMainService.h | 6 +-- src/edt/edt/edtPartialService.cc | 2 +- src/edt/edt/edtPartialService.h | 6 +-- src/edt/edt/edtPlugin.cc | 20 ++++---- src/edt/edt/edtPlugin.h | 2 +- src/edt/edt/edtPropertiesPages.cc | 4 +- src/edt/edt/edtService.cc | 4 +- src/edt/edt/edtService.h | 8 +-- src/edt/edt/edtServiceImpl.cc | 12 ++--- src/edt/edt/edtServiceImpl.h | 12 ++--- src/edt/edt/edtUtils.cc | 4 +- src/edt/edt/edtUtils.h | 6 +-- src/img/img/gsiDeclImg.cc | 14 +++--- src/img/img/imgPlugin.cc | 2 +- src/img/img/imgPlugin.h | 2 +- src/img/img/imgService.cc | 2 +- src/img/img/imgService.h | 6 +-- src/lay/lay/layClipDialog.cc | 4 +- src/lay/lay/layClipDialog.h | 2 +- src/lay/lay/layFillDialog.cc | 4 +- src/lay/lay/layFillDialog.h | 4 +- src/lay/lay/laySearchReplacePlugin.cc | 4 +- src/laybasic/laybasic/gsiDeclLayLayers.cc | 7 ++- src/laybasic/laybasic/gsiDeclLayLayoutView.cc | 45 ++++++++++++++--- src/laybasic/laybasic/gsiDeclLayMarker.cc | 2 +- src/laybasic/laybasic/gsiDeclLayPlugin.cc | 10 ++-- .../laybasic/layBrowseInstancesForm.cc | 6 +-- .../laybasic/layBrowseInstancesForm.h | 2 +- src/laybasic/laybasic/layBrowseShapesForm.cc | 4 +- src/laybasic/laybasic/layBrowseShapesForm.h | 2 +- src/laybasic/laybasic/layBrowser.cc | 4 +- src/laybasic/laybasic/layBrowser.h | 8 +-- src/laybasic/laybasic/layCellSelectionForm.cc | 2 +- src/laybasic/laybasic/layCellSelectionForm.h | 4 +- src/laybasic/laybasic/layCellTreeModel.cc | 6 +-- src/laybasic/laybasic/layCellTreeModel.h | 10 ++-- src/laybasic/laybasic/layCellView.cc | 49 ++++++++++++++----- src/laybasic/laybasic/layCellView.h | 10 ++++ .../laybasic/layEditorOptionsFrame.cc | 2 +- src/laybasic/laybasic/layEditorOptionsFrame.h | 4 +- src/laybasic/laybasic/layEditorServiceBase.cc | 2 +- src/laybasic/laybasic/layEditorServiceBase.h | 2 +- src/laybasic/laybasic/layFinder.cc | 14 +++--- src/laybasic/laybasic/layFinder.h | 18 +++---- src/laybasic/laybasic/layGridNet.cc | 4 +- src/laybasic/laybasic/layGridNet.h | 6 +-- src/laybasic/laybasic/layLayerProperties.cc | 14 +++--- src/laybasic/laybasic/layLayerProperties.h | 3 +- src/laybasic/laybasic/layLayerTreeModel.cc | 2 +- src/laybasic/laybasic/layLayerTreeModel.h | 4 +- src/laybasic/laybasic/layLayoutView.h | 23 +++++++-- src/laybasic/laybasic/layLayoutViewBase.cc | 30 ++++++------ src/laybasic/laybasic/layLayoutViewBase.h | 17 ++++++- .../laybasic/layLayoutViewFunctions.cc | 6 +-- .../laybasic/layLayoutViewFunctions.h | 2 +- src/laybasic/laybasic/layMarker.cc | 12 ++--- src/laybasic/laybasic/layMarker.h | 22 ++++----- src/laybasic/laybasic/layMouseTracker.cc | 2 +- src/laybasic/laybasic/layMouseTracker.h | 6 +-- src/laybasic/laybasic/layMove.cc | 2 +- src/laybasic/laybasic/layMove.h | 6 +-- src/laybasic/laybasic/layNetlistBrowser.cc | 2 +- .../laybasic/layNetlistBrowserDialog.cc | 2 +- .../laybasic/layNetlistBrowserDialog.h | 2 +- .../laybasic/layNetlistBrowserPage.cc | 4 +- src/laybasic/laybasic/layNetlistBrowserPage.h | 4 +- src/laybasic/laybasic/layParsedLayerSource.cc | 2 +- src/laybasic/laybasic/layPlugin.h | 6 +-- src/laybasic/laybasic/laySelector.cc | 2 +- src/laybasic/laybasic/laySelector.h | 6 +-- src/laybasic/laybasic/laySnap.cc | 22 ++++----- src/laybasic/laybasic/laySnap.h | 14 +++--- src/laybasic/laybasic/layZoomBox.cc | 2 +- src/laybasic/laybasic/layZoomBox.h | 6 +-- src/laybasic/laybasic/laybasic.pro | 10 ++-- src/laybasic/laybasic/rdbMarkerBrowser.cc | 2 +- .../laybasic/rdbMarkerBrowserDialog.cc | 6 +-- .../laybasic/rdbMarkerBrowserDialog.h | 2 +- src/laybasic/laybasic/rdbMarkerBrowserPage.cc | 2 +- src/laybasic/laybasic/rdbMarkerBrowserPage.h | 4 +- .../lay_plugin/layBooleanOperationsPlugin.cc | 4 +- .../tools/diff/lay_plugin/layDiffPlugin.cc | 4 +- .../lay_plugin/layNetTracerPlugin.cc | 4 +- .../tools/view_25d/lay_plugin/layD25Plugin.cc | 2 +- .../tools/view_25d/lay_plugin/layD25View.cc | 2 +- .../tools/view_25d/lay_plugin/layD25View.h | 2 +- .../view_25d/lay_plugin/layD25ViewWidget.cc | 2 +- .../view_25d/lay_plugin/layD25ViewWidget.h | 6 +-- .../tools/xor/lay_plugin/layXORPlugin.cc | 4 +- 96 files changed, 384 insertions(+), 290 deletions(-) diff --git a/src/ant/ant/antPlugin.cc b/src/ant/ant/antPlugin.cc index 10f8643b2..330442a94 100644 --- a/src/ant/ant/antPlugin.cc +++ b/src/ant/ant/antPlugin.cc @@ -91,7 +91,7 @@ PluginDeclaration::get_menu_entries (std::vector &menu_entries) } lay::Plugin * -PluginDeclaration::create_plugin (db::Manager *manager, lay::Dispatcher *, lay::LayoutViewBase *view) const +PluginDeclaration::create_plugin (db::Manager *manager, lay::Dispatcher *, lay::LayoutView *view) const { return new ant::Service (manager, view); } diff --git a/src/ant/ant/antPlugin.h b/src/ant/ant/antPlugin.h index 18950ffac..6d65c03e6 100644 --- a/src/ant/ant/antPlugin.h +++ b/src/ant/ant/antPlugin.h @@ -40,7 +40,7 @@ public: virtual void get_options (std::vector < std::pair > &options) const; virtual void get_menu_entries (std::vector &menu_entries) const; - virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *, lay::LayoutViewBase *view) const; + virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *, lay::LayoutView *view) const; virtual bool implements_editable (std::string &title) const; virtual bool implements_mouse_mode (std::string &title) const; virtual bool configure (const std::string &name, const std::string &value); diff --git a/src/ant/ant/antService.cc b/src/ant/ant/antService.cc index 761b8e059..5c6db1ec2 100644 --- a/src/ant/ant/antService.cc +++ b/src/ant/ant/antService.cc @@ -784,7 +784,7 @@ View::render (const lay::Viewport &vp, lay::ViewObjectCanvas &canvas) // ------------------------------------------------------------- // ant::Service implementation -Service::Service (db::Manager *manager, lay::LayoutViewBase *view) +Service::Service (db::Manager *manager, lay::LayoutView *view) : lay::EditorServiceBase (view), lay::Drawing (1/*number of planes*/, view->drawings ()), db::Object (manager), diff --git a/src/ant/ant/antService.h b/src/ant/ant/antService.h index 9aeee7458..e289800fc 100644 --- a/src/ant/ant/antService.h +++ b/src/ant/ant/antService.h @@ -201,7 +201,7 @@ public: */ enum MoveMode { MoveNone, MoveP1, MoveP2, MoveP12, MoveP21, MoveP1X, MoveP2X, MoveP1Y, MoveP2Y, MoveRuler, MoveSelected }; - Service (db::Manager *manager, lay::LayoutViewBase *view); + Service (db::Manager *manager, lay::LayoutView *view); ~Service (); @@ -427,7 +427,7 @@ public: /** * @brief Access to the view object */ - lay::LayoutViewBase *view () const + lay::LayoutView *view () const { return mp_view; } @@ -510,7 +510,7 @@ private: int m_max_number_of_rulers; // The layout view that the ruler service is attached to - lay::LayoutViewBase *mp_view; + lay::LayoutView *mp_view; // The ruler view objects representing the selection // and the moved rules in move mode diff --git a/src/ant/ant/gsiDeclAnt.cc b/src/ant/ant/gsiDeclAnt.cc index f7391f5cd..a6f28c1a9 100644 --- a/src/ant/ant/gsiDeclAnt.cc +++ b/src/ant/ant/gsiDeclAnt.cc @@ -72,8 +72,8 @@ static int align_up () { return int (ant::Object::AL_up); } static void clear_annotations (lay::LayoutView *view); static void insert_annotation (lay::LayoutView *view, AnnotationRef *obj); -static void erase_annotation_base (lay::LayoutViewBase *view, int id); -static void replace_annotation_base (lay::LayoutViewBase *view, int id, const AnnotationRef &obj); +static void erase_annotation_base (lay::LayoutView *view, int id); +static void replace_annotation_base (lay::LayoutView *view, int id, const AnnotationRef &obj); /** * @brief An extension of the ant::Object that provides "live" updates of the view @@ -88,7 +88,7 @@ public: // .. nothing yet .. } - AnnotationRef (const ant::Object &other, lay::LayoutViewBase *view) + AnnotationRef (const ant::Object &other, lay::LayoutView *view) : ant::Object (other), mp_view (view) { // .. nothing yet .. @@ -140,10 +140,10 @@ public: template AnnotationRef transformed (const T &t) const { - return AnnotationRef (ant::Object::transformed (t), const_cast (mp_view.get ())); + return AnnotationRef (ant::Object::transformed (t), const_cast (mp_view.get ())); } - void set_view (lay::LayoutViewBase *view) + void set_view (lay::LayoutView *view) { mp_view.reset (view); } @@ -157,7 +157,7 @@ protected: } private: - tl::weak_ptr mp_view; + tl::weak_ptr mp_view; }; static void clear_annotations (lay::LayoutView *view) @@ -182,7 +182,7 @@ static void insert_annotation (lay::LayoutView *view, AnnotationRef *obj) } } -static void erase_annotation_base (lay::LayoutViewBase *view, int id) +static void erase_annotation_base (lay::LayoutView *view, int id) { ant::Service *ant_service = view->get_plugin (); if (ant_service) { @@ -200,7 +200,7 @@ static void erase_annotation (lay::LayoutView *view, int id) erase_annotation_base (view, id); } -static void replace_annotation_base (lay::LayoutViewBase *view, int id, const AnnotationRef &obj) +static void replace_annotation_base (lay::LayoutView *view, int id, const AnnotationRef &obj) { ant::Service *ant_service = view->get_plugin (); if (ant_service) { diff --git a/src/edt/edt/edtInstPropertiesPage.cc b/src/edt/edt/edtInstPropertiesPage.cc index 51112874f..cc18336da 100644 --- a/src/edt/edt/edtInstPropertiesPage.cc +++ b/src/edt/edt/edtInstPropertiesPage.cc @@ -207,7 +207,7 @@ void InstPropertiesPage::show_props () { lay::UserPropertiesForm props_form (this); - if (props_form.show (mp_service->view ()->ui (), m_selection_ptrs [m_index]->cv_index (), m_prop_id)) { + if (props_form.show (mp_service->view (), m_selection_ptrs [m_index]->cv_index (), m_prop_id)) { emit edited (); } } @@ -395,7 +395,7 @@ void InstPropertiesPage::show_inst () { InstantiationForm inst_form (this); - inst_form.show (mp_service->view ()->ui (), *m_selection_ptrs [m_index]); + inst_form.show (mp_service->view (), *m_selection_ptrs [m_index]); } bool @@ -912,7 +912,7 @@ InstPropertiesPage::update_pcell_parameters () mp_pcell_parameters = new PCellParametersPage (pcell_tab); connect (mp_pcell_parameters, SIGNAL (edited ()), this, SIGNAL (edited ())); - mp_pcell_parameters->setup (mp_service->view ()->ui (), pos->cv_index (), layout->pcell_declaration (pc.second), parameters); + mp_pcell_parameters->setup (mp_service->view (), pos->cv_index (), layout->pcell_declaration (pc.second), parameters); pcell_tab->layout ()->addWidget (mp_pcell_parameters); } diff --git a/src/edt/edt/edtMainService.cc b/src/edt/edt/edtMainService.cc index 8f1500a3f..efd898f53 100644 --- a/src/edt/edt/edtMainService.cc +++ b/src/edt/edt/edtMainService.cc @@ -55,7 +55,7 @@ namespace edt // ----------------------------------------------------------------------------- // Main Service implementation -MainService::MainService (db::Manager *manager, lay::LayoutViewBase *view, lay::Dispatcher *root) +MainService::MainService (db::Manager *manager, lay::LayoutView *view, lay::Dispatcher *root) : lay::Plugin (view), lay::Editable (view), db::Object (manager), @@ -1751,7 +1751,7 @@ db::DVector compute_alignment_vector (const db::DBox &prim_box, const db::DBox & } static db::DBox -inst_bbox (const db::CplxTrans &tr, lay::LayoutViewBase *view, int cv_index, const db::InstElement &inst_element, bool visible_only) +inst_bbox (const db::CplxTrans &tr, lay::LayoutView *view, int cv_index, const db::InstElement &inst_element, bool visible_only) { db::DBox box; @@ -2296,7 +2296,7 @@ class NewObjectsSelection : public db::ClipboardDataInsertReceiver { public: - NewObjectsSelection (int cv_index, db::cell_index_type topcell, lay::LayoutViewBase *view) + NewObjectsSelection (int cv_index, db::cell_index_type topcell, lay::LayoutView *view) : m_cv_index (cv_index), m_topcell (topcell) { mp_polygon_service = view->get_plugin (); diff --git a/src/edt/edt/edtMainService.h b/src/edt/edt/edtMainService.h index 3ca99c373..60c8c4a8f 100644 --- a/src/edt/edt/edtMainService.h +++ b/src/edt/edt/edtMainService.h @@ -64,7 +64,7 @@ public: /** * @brief The constructor */ - MainService (db::Manager *manager, lay::LayoutViewBase *view, lay::Dispatcher *root); + MainService (db::Manager *manager, lay::LayoutView *view, lay::Dispatcher *root); /** * @brief The destructor @@ -74,7 +74,7 @@ public: /** * @brief Access to the view object */ - lay::LayoutViewBase *view () const + lay::LayoutView *view () const { return mp_view; } @@ -196,7 +196,7 @@ public: private: // The layout view that this service is attached to - lay::LayoutViewBase *mp_view; + lay::LayoutView *mp_view; lay::Dispatcher *mp_root; bool m_needs_update; diff --git a/src/edt/edt/edtPartialService.cc b/src/edt/edt/edtPartialService.cc index f43270b35..a22882651 100644 --- a/src/edt/edt/edtPartialService.cc +++ b/src/edt/edt/edtPartialService.cc @@ -1010,7 +1010,7 @@ PartialShapeFinder::visit_cell (const db::Cell &cell, const db::Box &search_box, // ----------------------------------------------------------------------------- // Main Service implementation -PartialService::PartialService (db::Manager *manager, lay::LayoutViewBase *view, lay::Dispatcher *root) +PartialService::PartialService (db::Manager *manager, lay::LayoutView *view, lay::Dispatcher *root) : QObject (), lay::EditorServiceBase (view), db::Object (manager), diff --git a/src/edt/edt/edtPartialService.h b/src/edt/edt/edtPartialService.h index 4c7018334..0781dcf81 100644 --- a/src/edt/edt/edtPartialService.h +++ b/src/edt/edt/edtPartialService.h @@ -149,7 +149,7 @@ public: /** * @brief The constructor */ - PartialService (db::Manager *manager, lay::LayoutViewBase *view, lay::Dispatcher *root); + PartialService (db::Manager *manager, lay::LayoutView *view, lay::Dispatcher *root); /** * @brief The destructor @@ -159,7 +159,7 @@ public: /** * @brief Access to the view object */ - lay::LayoutViewBase *view () const + lay::LayoutView *view () const { tl_assert (mp_view != 0); return mp_view; @@ -298,7 +298,7 @@ protected: private: // The layout view that this service is attached to - lay::LayoutViewBase *mp_view; + lay::LayoutView *mp_view; lay::Dispatcher *mp_root; bool m_dragging; bool m_keep_selection; diff --git a/src/edt/edt/edtPlugin.cc b/src/edt/edt/edtPlugin.cc index a3cb410dc..1169490ca 100644 --- a/src/edt/edt/edtPlugin.cc +++ b/src/edt/edt/edtPlugin.cc @@ -179,18 +179,18 @@ public: // .. nothing yet .. } - virtual void get_editor_options_pages (std::vector &pages, lay::LayoutViewBase *view, lay::Dispatcher *root) const + virtual void get_editor_options_pages (std::vector &pages, lay::LayoutView *view, lay::Dispatcher *root) const { if (mp_pages_f != 0) { size_t nstart = pages.size (); - (*mp_pages_f) (pages, view->ui (), root); + (*mp_pages_f) (pages, view, root); while (nstart < pages.size ()) { pages [nstart++]->set_plugin_declaration (this); } } } - virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *, lay::LayoutViewBase *view) const + virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *, lay::LayoutView *view) const { Svc *service = new Svc (manager, view); service->set_plugin_declaration (this); @@ -312,7 +312,7 @@ public: return false; } - virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *root, lay::LayoutViewBase *view) const + virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *root, lay::LayoutView *view) const { return new edt::MainService (manager, view, root); } @@ -327,10 +327,10 @@ public: return false; } - virtual void get_editor_options_pages (std::vector &pages, lay::LayoutViewBase *view, lay::Dispatcher *dispatcher) const + virtual void get_editor_options_pages (std::vector &pages, lay::LayoutView *view, lay::Dispatcher *dispatcher) const { // NOTE: we do not set plugin_declaration which makes the page unspecific - EditorOptionsGeneric *generic_opt = new EditorOptionsGeneric (view->ui (), dispatcher); + EditorOptionsGeneric *generic_opt = new EditorOptionsGeneric (view, dispatcher); pages.push_back (generic_opt); } @@ -413,9 +413,9 @@ private: static tl::RegisteredClass config_decl_main (new edt::MainPluginDeclaration (tl::to_string (QObject::tr ("Instances and shapes"))), 4000, "edt::MainService"); void -commit_recent (lay::LayoutViewBase *view) +commit_recent (lay::LayoutView *view) { - lay::EditorOptionsPages *eo_pages = view->ui ()->editor_options_pages (); + lay::EditorOptionsPages *eo_pages = view->editor_options_pages (); if (!eo_pages) { return; } @@ -442,12 +442,12 @@ public: // .. nothing yet .. } - virtual void get_editor_options_pages (std::vector & /*pages*/, lay::LayoutViewBase * /*view*/, lay::Dispatcher * /*root*/) const + virtual void get_editor_options_pages (std::vector & /*pages*/, lay::LayoutView * /*view*/, lay::Dispatcher * /*root*/) const { // .. no specific ones .. } - virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *root, lay::LayoutViewBase *view) const + virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *root, lay::LayoutView *view) const { return new edt::PartialService (manager, view, root); } diff --git a/src/edt/edt/edtPlugin.h b/src/edt/edt/edtPlugin.h index 1baee02fa..d70ade213 100644 --- a/src/edt/edt/edtPlugin.h +++ b/src/edt/edt/edtPlugin.h @@ -49,7 +49,7 @@ namespace edt /** * @brief Commits the current configuration for the recently used configuration list */ - void commit_recent (lay::LayoutViewBase *view); + void commit_recent (lay::LayoutView *view); } #endif diff --git a/src/edt/edt/edtPropertiesPages.cc b/src/edt/edt/edtPropertiesPages.cc index 6f2232da4..5943d609a 100644 --- a/src/edt/edt/edtPropertiesPages.cc +++ b/src/edt/edt/edtPropertiesPages.cc @@ -361,14 +361,14 @@ void ShapePropertiesPage::show_inst () { InstantiationForm inst_form (this); - inst_form.show (mp_service->view ()->ui (), *m_selection_ptrs [m_index]); + inst_form.show (mp_service->view (), *m_selection_ptrs [m_index]); } void ShapePropertiesPage::show_props () { lay::UserPropertiesForm props_form (this); - if (props_form.show (mp_service->view ()->ui (), m_selection_ptrs [m_index]->cv_index (), m_prop_id)) { + if (props_form.show (mp_service->view (), m_selection_ptrs [m_index]->cv_index (), m_prop_id)) { emit edited (); } } diff --git a/src/edt/edt/edtService.cc b/src/edt/edt/edtService.cc index 1f750dad2..de51c832f 100644 --- a/src/edt/edt/edtService.cc +++ b/src/edt/edt/edtService.cc @@ -60,7 +60,7 @@ ac_from_buttons (unsigned int buttons) // ------------------------------------------------------------- -Service::Service (db::Manager *manager, lay::LayoutViewBase *view, db::ShapeIterator::flags_type flags) +Service::Service (db::Manager *manager, lay::LayoutView *view, db::ShapeIterator::flags_type flags) : lay::EditorServiceBase (view), db::Object (manager), mp_view (view), @@ -80,7 +80,7 @@ Service::Service (db::Manager *manager, lay::LayoutViewBase *view, db::ShapeIter // .. nothing yet .. } -Service::Service (db::Manager *manager, lay::LayoutViewBase *view) +Service::Service (db::Manager *manager, lay::LayoutView *view) : lay::EditorServiceBase (view), db::Object (manager), mp_view (view), diff --git a/src/edt/edt/edtService.h b/src/edt/edt/edtService.h index ea420c4cb..2dc67d46a 100644 --- a/src/edt/edt/edtService.h +++ b/src/edt/edt/edtService.h @@ -82,12 +82,12 @@ public: /** * @brief The constructor for an service selecting shapes */ - Service (db::Manager *manager, lay::LayoutViewBase *view, db::ShapeIterator::flags_type shape_types); + Service (db::Manager *manager, lay::LayoutView *view, db::ShapeIterator::flags_type shape_types); /** * @brief The constructor for an service selecting instances */ - Service (db::Manager *manager, lay::LayoutViewBase *view); + Service (db::Manager *manager, lay::LayoutView *view); /** * @brief The destructor @@ -243,7 +243,7 @@ public: /** * @brief Access to the view object */ - lay::LayoutViewBase *view () const + lay::LayoutView *view () const { tl_assert (mp_view != 0); return mp_view; @@ -559,7 +559,7 @@ protected: private: // The layout view that the editor service is attached to - lay::LayoutViewBase *mp_view; + lay::LayoutView *mp_view; // The marker objects representing the selection std::vector m_markers; diff --git a/src/edt/edt/edtServiceImpl.cc b/src/edt/edt/edtServiceImpl.cc index d4aa7413d..b22360339 100644 --- a/src/edt/edt/edtServiceImpl.cc +++ b/src/edt/edt/edtServiceImpl.cc @@ -47,7 +47,7 @@ namespace edt // ----------------------------------------------------------------------------- // ShapeEditService implementation -ShapeEditService::ShapeEditService (db::Manager *manager, lay::LayoutViewBase *view, db::ShapeIterator::flags_type shape_types) +ShapeEditService::ShapeEditService (db::Manager *manager, lay::LayoutView *view, db::ShapeIterator::flags_type shape_types) : edt::Service (manager, view, shape_types), m_layer (0), m_cv_index (0), mp_cell (0), mp_layout (0), m_combine_mode (CM_Add) { @@ -362,7 +362,7 @@ ShapeEditService::deliver_shape (const db::Box &box) // ----------------------------------------------------------------------------- // PolygonService implementation -PolygonService::PolygonService (db::Manager *manager, lay::LayoutViewBase *view) +PolygonService::PolygonService (db::Manager *manager, lay::LayoutView *view) : ShapeEditService (manager, view, db::ShapeIterator::Polygons), m_closure_set (false), m_closure () { @@ -692,7 +692,7 @@ PolygonService::update_marker () // ----------------------------------------------------------------------------- // BoxService implementation -BoxService::BoxService (db::Manager *manager, lay::LayoutViewBase *view) +BoxService::BoxService (db::Manager *manager, lay::LayoutView *view) : ShapeEditService (manager, view, db::ShapeIterator::Boxes) { // .. nothing yet .. @@ -784,7 +784,7 @@ BoxService::selection_applies (const lay::ObjectInstPath &sel) const // ----------------------------------------------------------------------------- // TextService implementation -TextService::TextService (db::Manager *manager, lay::LayoutViewBase *view) +TextService::TextService (db::Manager *manager, lay::LayoutView *view) : ShapeEditService (manager, view, db::ShapeIterator::Texts), m_rot (0) { @@ -972,7 +972,7 @@ TextService::configure (const std::string &name, const std::string &value) // ----------------------------------------------------------------------------- // PathService implementation -PathService::PathService (db::Manager *manager, lay::LayoutViewBase *view) +PathService::PathService (db::Manager *manager, lay::LayoutView *view) : ShapeEditService (manager, view, db::ShapeIterator::Paths), m_width (0.1), m_bgnext (0.0), m_endext (0.0), m_type (Flush), m_needs_update (true) { @@ -1211,7 +1211,7 @@ PathService::config_finalize () // ----------------------------------------------------------------------------- // InstService implementation -InstService::InstService (db::Manager *manager, lay::LayoutViewBase *view) +InstService::InstService (db::Manager *manager, lay::LayoutView *view) : edt::Service (manager, view), m_angle (0.0), m_scale (1.0), m_mirror (false), m_is_pcell (false), diff --git a/src/edt/edt/edtServiceImpl.h b/src/edt/edt/edtServiceImpl.h index 145a8d2ff..c3caf4383 100644 --- a/src/edt/edt/edtServiceImpl.h +++ b/src/edt/edt/edtServiceImpl.h @@ -45,7 +45,7 @@ class ShapeEditService : public edt::Service { public: - ShapeEditService (db::Manager *manager, lay::LayoutViewBase *view, db::ShapeIterator::flags_type shape_types); + ShapeEditService (db::Manager *manager, lay::LayoutView *view, db::ShapeIterator::flags_type shape_types); protected: void get_edit_layer (); @@ -86,7 +86,7 @@ class PolygonService : public ShapeEditService { public: - PolygonService (db::Manager *manager, lay::LayoutViewBase *view); + PolygonService (db::Manager *manager, lay::LayoutView *view); virtual lay::PropertiesPage *properties_page (db::Manager *manager, QWidget *parent); virtual void do_delete (); @@ -117,7 +117,7 @@ class BoxService : public ShapeEditService { public: - BoxService (db::Manager *manager, lay::LayoutViewBase *view); + BoxService (db::Manager *manager, lay::LayoutView *view); virtual lay::PropertiesPage *properties_page (db::Manager *manager, QWidget *parent); virtual void do_begin_edit (const db::DPoint &p); @@ -142,7 +142,7 @@ class TextService : public ShapeEditService { public: - TextService (db::Manager *manager, lay::LayoutViewBase *view); + TextService (db::Manager *manager, lay::LayoutView *view); ~TextService (); virtual lay::PropertiesPage *properties_page (db::Manager *manager, QWidget *parent); @@ -174,7 +174,7 @@ class PathService : public ShapeEditService { public: - PathService (db::Manager *manager, lay::LayoutViewBase *view); + PathService (db::Manager *manager, lay::LayoutView *view); ~PathService (); virtual lay::PropertiesPage *properties_page (db::Manager *manager, QWidget *parent); @@ -211,7 +211,7 @@ class InstService : public edt::Service { public: - InstService (db::Manager *manager, lay::LayoutViewBase *view); + InstService (db::Manager *manager, lay::LayoutView *view); virtual lay::PropertiesPage *properties_page (db::Manager *manager, QWidget *parent); virtual void do_begin_edit (const db::DPoint &p); diff --git a/src/edt/edt/edtUtils.cc b/src/edt/edt/edtUtils.cc index 08ca08827..4b04d9de8 100644 --- a/src/edt/edt/edtUtils.cc +++ b/src/edt/edt/edtUtils.cc @@ -77,7 +77,7 @@ std::map pcell_parameters_from_string (const std::stri // ------------------------------------------------------------- // SelectionIterator implementation -SelectionIterator::SelectionIterator (lay::LayoutViewBase *view, bool including_transient) +SelectionIterator::SelectionIterator (lay::LayoutView *view, bool including_transient) : m_transient_mode (false) { mp_edt_services = view->get_plugins (); @@ -145,7 +145,7 @@ SelectionIterator::next () // TransformationsVariants implementation // for a lay::LayoutView -TransformationVariants::TransformationVariants (const lay::LayoutViewBase *view, bool per_cv_and_layer, bool per_cv) +TransformationVariants::TransformationVariants (const lay::LayoutView *view, bool per_cv_and_layer, bool per_cv) { // build the transformation variants cache diff --git a/src/edt/edt/edtUtils.h b/src/edt/edt/edtUtils.h index 703dcfbf7..af9a81999 100644 --- a/src/edt/edt/edtUtils.h +++ b/src/edt/edt/edtUtils.h @@ -40,7 +40,7 @@ namespace lay { - class LayoutViewBase; + class LayoutView; } namespace edt { @@ -84,7 +84,7 @@ public: class TransformationVariants { public: - TransformationVariants (const lay::LayoutViewBase *view, bool per_cv_and_layer = true, bool per_cv = true); + TransformationVariants (const lay::LayoutView *view, bool per_cv_and_layer = true, bool per_cv = true); const std::vector *per_cv_and_layer (unsigned int cv, unsigned int layer) const; const std::vector *per_cv (unsigned int cv) const; @@ -109,7 +109,7 @@ public: * * If "including_transient" is true, the transient selection will be used as fallback. */ - SelectionIterator (lay::LayoutViewBase *view, bool including_transient = true); + SelectionIterator (lay::LayoutView *view, bool including_transient = true); /** * @brief Returns a value indicating whether the transient selection is taken diff --git a/src/img/img/gsiDeclImg.cc b/src/img/img/gsiDeclImg.cc index bc40cc8c1..0033c38ec 100644 --- a/src/img/img/gsiDeclImg.cc +++ b/src/img/img/gsiDeclImg.cc @@ -299,8 +299,8 @@ gsi::Class decl_ImageDataMapping ("lay", "ImageDataMapping", class ImageRef; -static void replace_image_base (lay::LayoutViewBase *view, size_t id, ImageRef &new_obj); -static void erase_image_base (lay::LayoutViewBase *view, size_t id); +static void replace_image_base (lay::LayoutView *view, size_t id, ImageRef &new_obj); +static void erase_image_base (lay::LayoutView *view, size_t id); /** * @brief An extension of the img::Object that provides "live" updates of the view @@ -321,7 +321,7 @@ public: // .. nothing yet .. } - ImageRef (const img::Object &other, lay::LayoutViewBase *view) + ImageRef (const img::Object &other, lay::LayoutView *view) : img::Object (other), mp_view (view), dm_update_view (this, &ImageRef::do_update_view) { // .. nothing yet .. @@ -373,7 +373,7 @@ public: template ImageRef transformed (const T &t) const { - return ImageRef (img::Object::transformed (t), const_cast (mp_view.get ())); + return ImageRef (img::Object::transformed (t), const_cast (mp_view.get ())); } void set_view (lay::LayoutView *view) @@ -403,7 +403,7 @@ protected: } private: - tl::weak_ptr mp_view; + tl::weak_ptr mp_view; tl::DeferredMethod dm_update_view; }; @@ -1114,7 +1114,7 @@ static void show_image (lay::LayoutView *view, size_t id, bool visible) } } -void replace_image_base (lay::LayoutViewBase *view, size_t id, ImageRef &new_obj) +void replace_image_base (lay::LayoutView *view, size_t id, ImageRef &new_obj) { img::Service *img_service = view->get_plugin (); if (img_service) { @@ -1134,7 +1134,7 @@ static void replace_image (lay::LayoutView *view, size_t id, ImageRef &new_obj) replace_image_base (view, id, new_obj); } -void erase_image_base (lay::LayoutViewBase *view, size_t id) +void erase_image_base (lay::LayoutView *view, size_t id) { img::Service *img_service = view->get_plugin (); if (img_service) { diff --git a/src/img/img/imgPlugin.cc b/src/img/img/imgPlugin.cc index 33b15b146..74d710786 100644 --- a/src/img/img/imgPlugin.cc +++ b/src/img/img/imgPlugin.cc @@ -45,7 +45,7 @@ PluginDeclaration::get_menu_entries (std::vector &menu_entries) } lay::Plugin * -PluginDeclaration::create_plugin (db::Manager *manager, lay::Dispatcher *, lay::LayoutViewBase *view) const +PluginDeclaration::create_plugin (db::Manager *manager, lay::Dispatcher *, lay::LayoutView *view) const { return new img::Service (manager, view); } diff --git a/src/img/img/imgPlugin.h b/src/img/img/imgPlugin.h index 1575ceccb..4dc9fa0bd 100644 --- a/src/img/img/imgPlugin.h +++ b/src/img/img/imgPlugin.h @@ -36,7 +36,7 @@ class PluginDeclaration { public: virtual void get_menu_entries (std::vector &menu_entries) const; - virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *, lay::LayoutViewBase *view) const; + virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *, lay::LayoutView *view) const; virtual bool implements_editable (std::string &title) const; virtual void get_options (std::vector < std::pair > &options) const; }; diff --git a/src/img/img/imgService.cc b/src/img/img/imgService.cc index 86c7cef71..627c03967 100644 --- a/src/img/img/imgService.cc +++ b/src/img/img/imgService.cc @@ -402,7 +402,7 @@ View::render (const lay::Viewport &vp, lay::ViewObjectCanvas &canvas) // ------------------------------------------------------------- // img::Service implementation -Service::Service (db::Manager *manager, lay::LayoutViewBase *view) +Service::Service (db::Manager *manager, lay::LayoutView *view) : lay::BackgroundViewObject (view->view_object_widget ()), lay::Editable (view), lay::Plugin (view), diff --git a/src/img/img/imgService.h b/src/img/img/imgService.h index 167177727..65e7bfa70 100644 --- a/src/img/img/imgService.h +++ b/src/img/img/imgService.h @@ -203,7 +203,7 @@ public: typedef lay::AnnotationShapes::iterator obj_iterator; enum MoveMode { move_none, move_selected, move_landmark, move_l, move_r, move_t, move_b, move_lr, move_tr, move_ll, move_tl, move_all }; - Service (db::Manager *manager, lay::LayoutViewBase *view); + Service (db::Manager *manager, lay::LayoutView *view); ~Service (); @@ -432,7 +432,7 @@ public: /** * @brief Access to the view object */ - lay::LayoutViewBase *view () const + lay::LayoutView *view () const { return mp_view; } @@ -480,7 +480,7 @@ public: private: // The layout view that the image service is attached to - lay::LayoutViewBase *mp_view; + lay::LayoutView *mp_view; // The view objects representing the selection and the moved images in move mode std::vector m_selected_image_views; diff --git a/src/lay/lay/layClipDialog.cc b/src/lay/lay/layClipDialog.cc index 2c28187e0..36679c03e 100644 --- a/src/lay/lay/layClipDialog.cc +++ b/src/lay/lay/layClipDialog.cc @@ -55,7 +55,7 @@ public: menu_entries.push_back (lay::menu_item ("clip_tool::show", "clip_tool:edit_mode", "edit_menu.utils_menu.end", tl::to_string (QObject::tr ("Clip Tool")))); } - virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutViewBase *view) const + virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutView *view) const { return new ClipDialog (root, view); } @@ -66,7 +66,7 @@ static tl::RegisteredClass config_decl (new ClipDialogPl // ------------------------------------------------------------ -ClipDialog::ClipDialog (lay::Dispatcher *root, LayoutViewBase *vw) +ClipDialog::ClipDialog (lay::Dispatcher *root, LayoutView *vw) : lay::Browser (root, vw), Ui::ClipDialog () { diff --git a/src/lay/lay/layClipDialog.h b/src/lay/lay/layClipDialog.h index e84ad2435..bab730bf9 100644 --- a/src/lay/lay/layClipDialog.h +++ b/src/lay/lay/layClipDialog.h @@ -40,7 +40,7 @@ class ClipDialog Q_OBJECT public: - ClipDialog (lay::Dispatcher *root, lay::LayoutViewBase *view); + ClipDialog (lay::Dispatcher *root, lay::LayoutView *view); ~ClipDialog (); public slots: diff --git a/src/lay/lay/layFillDialog.cc b/src/lay/lay/layFillDialog.cc index 458c90afa..63df40cdd 100644 --- a/src/lay/lay/layFillDialog.cc +++ b/src/lay/lay/layFillDialog.cc @@ -62,7 +62,7 @@ public: menu_entries.push_back (lay::menu_item ("fill_tool::show", "fill_tool:edit_mode", "edit_menu.utils_menu.end", tl::to_string (QObject::tr ("Fill Tool")))); } - virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutViewBase *view) const + virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutView *view) const { return new FillDialog (root, view); } @@ -73,7 +73,7 @@ static tl::RegisteredClass config_decl (new FillDialogPl // ------------------------------------------------------------ -FillDialog::FillDialog (lay::Dispatcher *main, LayoutViewBase *view) +FillDialog::FillDialog (lay::Dispatcher *main, LayoutView *view) : QDialog (view->widget ()), lay::Plugin (main), Ui::FillDialog (), diff --git a/src/lay/lay/layFillDialog.h b/src/lay/lay/layFillDialog.h index faa06851a..52deb5826 100644 --- a/src/lay/lay/layFillDialog.h +++ b/src/lay/lay/layFillDialog.h @@ -76,7 +76,7 @@ class LAY_PUBLIC FillDialog Q_OBJECT public: - FillDialog (lay::Dispatcher *root, lay::LayoutViewBase *view); + FillDialog (lay::Dispatcher *root, lay::LayoutView *view); ~FillDialog (); public slots: @@ -95,7 +95,7 @@ private: void generate_fill (const FillParameters &fp); FillParameters get_fill_parameters (); - lay::LayoutViewBase *mp_view; + lay::LayoutView *mp_view; }; } diff --git a/src/lay/lay/laySearchReplacePlugin.cc b/src/lay/lay/laySearchReplacePlugin.cc index 94d53e141..bc603736d 100644 --- a/src/lay/lay/laySearchReplacePlugin.cc +++ b/src/lay/lay/laySearchReplacePlugin.cc @@ -63,9 +63,9 @@ public: menu_entries.push_back (lay::menu_item ("search_replace::show", "search_replace_viewer:edit:view_mode", "edit_menu.utils_group+", tl::to_string (QObject::tr ("Search")))); } - virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutViewBase *view) const + virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutView *view) const { - return new SearchReplaceDialog (root, view->ui ()); + return new SearchReplaceDialog (root, view); } }; diff --git a/src/laybasic/laybasic/gsiDeclLayLayers.cc b/src/laybasic/laybasic/gsiDeclLayLayers.cc index df088a76a..76955760f 100644 --- a/src/laybasic/laybasic/gsiDeclLayLayers.cc +++ b/src/laybasic/laybasic/gsiDeclLayLayers.cc @@ -1165,6 +1165,11 @@ static void clear_children (lay::LayerPropertiesNode *node) node->clear_children (); } +static lay::LayoutView *get_view (lay::LayerPropertiesNode *node) +{ + return node->view ()->ui (); +} + Class decl_LayerPropertiesNode ( decl_LayerProperties, "lay", "LayerPropertiesNode", @@ -1222,7 +1227,7 @@ Class decl_LayerPropertiesNode ( "\n" "@return A bbox in micron units\n" ) + - method ("view", &lay::LayerPropertiesNode::view, + method_ext ("view", &get_view, "@brief Gets the view this node lives in\n" "\n" "This reference can be nil if the node is a orphan node that lives outside a view." diff --git a/src/laybasic/laybasic/gsiDeclLayLayoutView.cc b/src/laybasic/laybasic/gsiDeclLayLayoutView.cc index 1cf36d029..ed41338b1 100644 --- a/src/laybasic/laybasic/gsiDeclLayLayoutView.cc +++ b/src/laybasic/laybasic/gsiDeclLayLayoutView.cc @@ -336,7 +336,9 @@ static QImage get_image_with_options (lay::LayoutView *view, unsigned int width, static void save_image_with_options (lay::LayoutView *view, const std::string &fn, unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, const db::DBox &target_box, bool monochrome) { +#if defined(HAVE_QT) // @@@ view->save_image_with_options (fn, width, height, linewidth, oversampling, resolution, lay::Color (), lay::Color (), lay::Color (), target_box, monochrome); +#endif } static std::vector @@ -417,11 +419,19 @@ static lay::LayoutView *new_view (QWidget *parent, bool editable, db::Manager *m static lay::LayoutView *new_view2 (bool editable, db::Manager *manager, unsigned int options) { +#if defined(HAVE_QT) return new lay::LayoutView (manager, editable, 0 /*plugin parent*/, 0 /*parent*/, "view", options); +#else + return new lay::LayoutView (manager, editable, 0 /*plugin parent*/, options); +#endif } +#if defined(HAVE_QT) Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "LayoutView", -#if defined(HAVE_QTBINDINGS) +#else +Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "LayoutView", +#endif +#if defined(HAVE_QTBINDINGS) && defined(HAVE_QT) gsi::constructor ("new", &new_view, gsi::arg ("parent"), gsi::arg ("editable", false), gsi::arg ("manager", (db::Manager *) 0, "nil"), gsi::arg ("options", (unsigned int) 0), "@brief Creates a standalone view\n" "\n" @@ -574,12 +584,14 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This method has been introduced in version 0.27." ) + +#if defined(HAVE_QT) gsi::method ("current", &lay::LayoutView::current, "@brief Returns the current view\n" "The current view is the one that is shown in the current tab. Returns nil if no layout is loaded.\n" "\n" "This method has been introduced in version 0.23.\n" ) + +#endif gsi::method ("stop_redraw", &lay::LayoutView::stop_redraw, "@brief Stops the redraw thread\n" "\n" @@ -953,11 +965,13 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "@brief Return the viewport height in pixels\n" "This method was introduced in version 0.18.\n" ) + +#if defined(HAVE_QT) gsi::method ("bookmark_view", &lay::LayoutView::bookmark_view, gsi::arg ("name"), "@brief Bookmarks the current view under the given name\n" "\n" "@param name The name under which to bookmark the current state" ) + +#endif gsi::method ("add_missing_layers", &lay::LayoutView::add_missing_layers, "@brief Adds new layers to layer list\n" "This method was introduced in version 0.19.\n" @@ -1149,7 +1163,6 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This method has been introduced in 0.23.10.\n" ) + -#endif gsi::method ("save_screenshot", &lay::LayoutView::save_screenshot, gsi::arg ("filename"), "@brief Saves a screenshot to the given file\n" "\n" @@ -1171,6 +1184,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "The image is written as a PNG file to the given file. " "The image is drawn synchronously with the given width and height. Drawing may take some time. " ) + +#endif gsi::method_ext ("save_image_with_options", &save_image_with_options, gsi::arg ("filename"), gsi::arg ("width"), gsi::arg ("height"), gsi::arg ("linewidth"), gsi::arg ("oversampling"), gsi::arg ("resolution"), gsi::arg ("target"), gsi::arg ("monochrome"), "@brief Saves the layout as an image to the given file (with options)\n" "\n" @@ -1556,6 +1570,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "Before version 0.25 this event was based on the observer pattern obsolete now. The corresponding methods " "(add_file_open_observer/remove_file_open_observer) have been removed in 0.25.\n" ) + +#if defined(HAVE_QT) gsi::event ("on_close", &lay::LayoutView::close_event, "@brief A event indicating that the view is about to close\n" "\n" @@ -1573,6 +1588,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "It has been added in version 0.25." ) + +#endif gsi::event ("on_viewport_changed", &lay::LayoutView::viewport_changed_event, "@brief An event indicating that the viewport (the visible rectangle) has changed\n" "\n" @@ -1690,11 +1706,13 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "If a report database with the given name already exists, a unique name will be created.\n" "The name will be replaced by the file name when a file is loaded into the report database.\n" ) + +#if defined(HAVE_QT) gsi::method ("show_rdb", &lay::LayoutView::open_rdb_browser, gsi::arg ("rdb_index"), gsi::arg ("cv_index"), "@brief Shows a report database in the marker browser on a certain layout\n" "The marker browser is opened showing the report database with the index given by \"rdb_index\".\n" "It will be attached (i.e. navigate to) the layout with the given cellview index in \"cv_index\".\n" ) + +#endif gsi::event ("on_l2ndb_list_changed", &lay::LayoutView::l2ndb_list_changed_event, "@brief An event that is triggered the list of netlist databases is changed\n" "\n" @@ -1749,6 +1767,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This method has been added in version 0.26." ) + +#if defined(HAVE_QT) gsi::method ("show_l2ndb", &lay::LayoutView::open_l2ndb_browser, gsi::arg ("l2ndb_index"), gsi::arg ("cv_index"), "@brief Shows a netlist database in the marker browser on a certain layout\n" "The netlist browser is opened showing the netlist database with the index given by \"l2ndb_index\".\n" @@ -1756,6 +1775,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This method has been added in version 0.26." ) + +#endif gsi::method_ext ("lvsdb", &get_lvsdb, gsi::arg ("index"), "@brief Gets the netlist database with the given index\n" "@return The \\LayoutVsSchematic object or nil if the index is not valid" @@ -1791,6 +1811,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This method has been added in version 0.26." ) + +#if defined(HAVE_QT) gsi::method ("show_lvsdb", &lay::LayoutView::open_l2ndb_browser, gsi::arg ("lvsdb_index"), gsi::arg ("cv_index"), "@brief Shows a netlist database in the marker browser on a certain layout\n" "The netlist browser is opened showing the netlist database with the index given by \"lvsdb_index\".\n" @@ -1798,6 +1819,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This method has been added in version 0.26." ) + +#endif // HINT: the cast is important to direct GSI to the LayoutView method rather than the // Plugin method (in which case we get a segmentation violation ..) // TODO: this method belongs to the Plugin interface and should be located there. @@ -1985,11 +2007,12 @@ static std::string get_technology (const lay::CellViewRef *cv) static tl::Event &get_technology_changed_event (lay::CellViewRef *cv) { if (! cv->is_valid ()) { - throw tl::Exception (tl::to_string (QObject::tr ("Not a valid cellview"))); + throw tl::Exception (tl::to_string (tr ("Not a valid cellview"))); } return (*cv)->technology_changed_event; } +#if defined(HAVE_QT) static lay::CellViewRef get_active_cellview_ref () { lay::LayoutView *view = lay::LayoutView::current (); @@ -2002,6 +2025,7 @@ static lay::CellViewRef get_active_cellview_ref () return lay::CellViewRef (); } } +#endif static void set_cell (lay::CellViewRef *cv, db::Cell *cell) { @@ -2046,7 +2070,7 @@ static bool cv_is_cell_hidden (lay::CellViewRef *cv, const db::Cell *cell) { if (cv->is_valid () && cell) { if (cell->layout () != &(*cv)->layout ()) { - throw tl::Exception (tl::to_string (QObject::tr ("The cell is not a cell of the view's layout"))); + throw tl::Exception (tl::to_string (tr ("The cell is not a cell of the view's layout"))); } return cv->view ()->is_cell_hidden (cell->cell_index (), cv->index ()); } else { @@ -2058,7 +2082,7 @@ static void cv_hide_cell (lay::CellViewRef *cv, const db::Cell *cell) { if (cv->is_valid () && cell) { if (cell->layout () != &(*cv)->layout ()) { - throw tl::Exception (tl::to_string (QObject::tr ("The cell is not a cell of the view's layout"))); + throw tl::Exception (tl::to_string (tr ("The cell is not a cell of the view's layout"))); } cv->view ()->hide_cell (cell->cell_index (), cv->index ()); } @@ -2068,7 +2092,7 @@ static void cv_show_cell (lay::CellViewRef *cv, const db::Cell *cell) { if (cv->is_valid () && cell) { if (cell->layout () != &(*cv)->layout ()) { - throw tl::Exception (tl::to_string (QObject::tr ("The cell is not a cell of the view's layout"))); + throw tl::Exception (tl::to_string (tr ("The cell is not a cell of the view's layout"))); } cv->view ()->show_cell (cell->cell_index (), cv->index ()); } @@ -2081,6 +2105,11 @@ static void cv_show_all_cells (lay::CellViewRef *cv) } } +static lay::LayoutView *get_view (lay::CellViewRef *cv) +{ + return cv->view ()->ui (); +} + Class decl_CellView ("lay", "CellView", method ("==", static_cast (&lay::CellViewRef::operator==), gsi::arg ("other"), "@brief Equality: indicates whether the cellviews refer to the same one\n" @@ -2092,11 +2121,12 @@ Class decl_CellView ("lay", "CellView", "The index will be negative if the cellview is not a valid one.\n" "This method has been added in version 0.25.\n" ) + - method ("view", &lay::CellViewRef::view, + method_ext ("view", &get_view, "@brief Gets the view the cellview resides in\n" "This reference will be nil if the cellview is not a valid one.\n" "This method has been added in version 0.25.\n" ) + +#if defined(HAVE_QT) method ("active", &get_active_cellview_ref, "@brief Gets the active CellView\n" "The active CellView is the one that is selected in the current layout view. This method is " @@ -2108,6 +2138,7 @@ Class decl_CellView ("lay", "CellView", "\n" "This method has been introduced in version 0.23." ) + +#endif method ("is_valid?", &lay::CellViewRef::is_valid, "@brief Returns true, if the cellview is valid\n" "A cellview may become invalid if the corresponding tab is closed for example." diff --git a/src/laybasic/laybasic/gsiDeclLayMarker.cc b/src/laybasic/laybasic/gsiDeclLayMarker.cc index 9f5e58bd9..83dfc7ca7 100644 --- a/src/laybasic/laybasic/gsiDeclLayMarker.cc +++ b/src/laybasic/laybasic/gsiDeclLayMarker.cc @@ -29,7 +29,7 @@ namespace gsi { static -lay::DMarker *create_marker (lay::LayoutViewBase *view) +lay::DMarker *create_marker (lay::LayoutView *view) { return new lay::DMarker (view); } diff --git a/src/laybasic/laybasic/gsiDeclLayPlugin.cc b/src/laybasic/laybasic/gsiDeclLayPlugin.cc index 530fd82d7..d1b1f5d6b 100644 --- a/src/laybasic/laybasic/gsiDeclLayPlugin.cc +++ b/src/laybasic/laybasic/gsiDeclLayPlugin.cc @@ -40,7 +40,7 @@ namespace gsi // since PluginBase object are only allowed to be created inside the create_plugin method // of the factory, this hack is a quick but dirty workaround. static bool s_in_create_plugin = false; -static lay::LayoutViewBase *sp_view = 0; +static lay::LayoutView *sp_view = 0; static lay::Dispatcher *sp_dispatcher = 0; class PluginBase @@ -51,7 +51,7 @@ public: : lay::Plugin (sp_dispatcher), lay::ViewService (sp_view ? sp_view->view_object_widget () : 0) { if (! s_in_create_plugin) { - throw tl::Exception (tl::to_string (QObject::tr ("A PluginBase object can only be created in the PluginFactory's create_plugin method"))); + throw tl::Exception (tl::to_string (tr ("A PluginBase object can only be created in the PluginFactory's create_plugin method"))); } } @@ -393,7 +393,7 @@ public: } } - virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *root, lay::LayoutViewBase *view) const + virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *root, lay::LayoutView *view) const { if (f_create_plugin.can_issue ()) { return create_plugin_gsi (manager, root, view); @@ -402,7 +402,7 @@ public: } } - virtual gsi::PluginBase *create_plugin_gsi (db::Manager *manager, lay::Dispatcher *root, lay::LayoutViewBase *view) const + virtual gsi::PluginBase *create_plugin_gsi (db::Manager *manager, lay::Dispatcher *root, lay::LayoutView *view) const { // TODO: this is a hack. See notes above at s_in_create_plugin s_in_create_plugin = true; @@ -410,7 +410,7 @@ public: sp_dispatcher = root; gsi::PluginBase *ret = 0; try { - ret = f_create_plugin.issue (&PluginFactoryBase::create_plugin_gsi, manager, root, view); + ret = f_create_plugin.issue (&PluginFactoryBase::create_plugin_gsi, manager, root, view); s_in_create_plugin = false; sp_view = 0; sp_dispatcher = 0; diff --git a/src/laybasic/laybasic/layBrowseInstancesForm.cc b/src/laybasic/laybasic/layBrowseInstancesForm.cc index cb2e96b01..0b1214d6f 100644 --- a/src/laybasic/laybasic/layBrowseInstancesForm.cc +++ b/src/laybasic/laybasic/layBrowseInstancesForm.cc @@ -79,7 +79,7 @@ public: menu_entries.push_back (lay::menu_item ("browse_instances::show", "browse_instances", "tools_menu.end", tl::to_string (QObject::tr ("Browse Instances")))); } - virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutViewBase *view) const + virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutView *view) const { return new BrowseInstancesForm (root, view); } @@ -289,7 +289,7 @@ private: // ------------------------------------------------------------ -BrowseInstancesForm::BrowseInstancesForm (lay::Dispatcher *root, LayoutViewBase *vw) +BrowseInstancesForm::BrowseInstancesForm (lay::Dispatcher *root, LayoutView *vw) : lay::Browser (root, vw), Ui::BrowseInstancesForm (), m_cv_index (0), @@ -349,7 +349,7 @@ void BrowseInstancesForm::choose_cell_pressed () { BEGIN_PROTECTED - CellSelectionForm form (this, view ()->ui (), "browse_cell", true /*simple mode*/); + CellSelectionForm form (this, view (), "browse_cell", true /*simple mode*/); if (form.exec ()) { change_cell (form.selected_cellview ().cell_index (), form.selected_cellview_index ()); } diff --git a/src/laybasic/laybasic/layBrowseInstancesForm.h b/src/laybasic/laybasic/layBrowseInstancesForm.h index 61bec73de..ae4d5e2b0 100644 --- a/src/laybasic/laybasic/layBrowseInstancesForm.h +++ b/src/laybasic/laybasic/layBrowseInstancesForm.h @@ -65,7 +65,7 @@ public: enum mode_type { ToCellView = 0, AnyTop, Parent }; enum window_type { DontChange = 0, FitCell, FitMarker, Center, CenterSize }; - BrowseInstancesForm (lay::Dispatcher *root, lay::LayoutViewBase *view); + BrowseInstancesForm (lay::Dispatcher *root, lay::LayoutView *view); ~BrowseInstancesForm (); bool eventFilter (QObject *watched, QEvent *event); diff --git a/src/laybasic/laybasic/layBrowseShapesForm.cc b/src/laybasic/laybasic/layBrowseShapesForm.cc index 78db4af73..d733ac1a2 100644 --- a/src/laybasic/laybasic/layBrowseShapesForm.cc +++ b/src/laybasic/laybasic/layBrowseShapesForm.cc @@ -80,7 +80,7 @@ public: menu_entries.push_back (lay::menu_item ("browse_shapes::show", "browse_shapes", "tools_menu.end", tl::to_string (QObject::tr ("Browse Shapes")))); } - virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutViewBase *view) const + virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutView *view) const { return new BrowseShapesForm (root, view); } @@ -392,7 +392,7 @@ private: // ------------------------------------------------------------ -BrowseShapesForm::BrowseShapesForm (lay::Dispatcher *root, LayoutViewBase *vw) +BrowseShapesForm::BrowseShapesForm (lay::Dispatcher *root, LayoutView *vw) : lay::Browser (root, vw), Ui::BrowseShapesForm (), m_cv_index (-1), diff --git a/src/laybasic/laybasic/layBrowseShapesForm.h b/src/laybasic/laybasic/layBrowseShapesForm.h index 4ff63c739..c13b6b4e3 100644 --- a/src/laybasic/laybasic/layBrowseShapesForm.h +++ b/src/laybasic/laybasic/layBrowseShapesForm.h @@ -64,7 +64,7 @@ public: enum mode_type { ToCellView = 0, AnyTop, Local }; enum window_type { DontChange = 0, FitCell, FitMarker, Center, CenterSize }; - BrowseShapesForm (lay::Dispatcher *root, LayoutViewBase *view); + BrowseShapesForm (lay::Dispatcher *root, LayoutView *view); ~BrowseShapesForm (); bool eventFilter (QObject *watched, QEvent *event); diff --git a/src/laybasic/laybasic/layBrowser.cc b/src/laybasic/laybasic/layBrowser.cc index 07b2a9828..8a9fcc241 100644 --- a/src/laybasic/laybasic/layBrowser.cc +++ b/src/laybasic/laybasic/layBrowser.cc @@ -32,9 +32,9 @@ namespace lay { #if QT_VERSION >= 0x050000 -Browser::Browser (lay::Dispatcher *root, lay::LayoutViewBase *view, const char *name, Qt::WindowFlags fl) +Browser::Browser (lay::Dispatcher *root, lay::LayoutView *view, const char *name, Qt::WindowFlags fl) #else -Browser::Browser (lay::Dispatcher *root, lay::LayoutViewBase *view, const char *name, Qt::WFlags fl) +Browser::Browser (lay::Dispatcher *root, lay::LayoutView *view, const char *name, Qt::WFlags fl) #endif // TODO: clarify whether to keep the browsers as separate (potentially hidden) windows : QDialog (0 /*view*/, fl), diff --git a/src/laybasic/laybasic/layBrowser.h b/src/laybasic/laybasic/layBrowser.h index fcc490c53..24bafc8e4 100644 --- a/src/laybasic/laybasic/layBrowser.h +++ b/src/laybasic/laybasic/layBrowser.h @@ -47,9 +47,9 @@ public: * @brief Constructor */ #if QT_VERSION >= 0x050000 - Browser (lay::Dispatcher *root, lay::LayoutViewBase *view, const char *name = "", Qt::WindowFlags fl = Qt::Window /*adds minimize button for example*/); + Browser (lay::Dispatcher *root, lay::LayoutView *view, const char *name = "", Qt::WindowFlags fl = Qt::Window /*adds minimize button for example*/); #else - Browser (lay::Dispatcher *root, lay::LayoutViewBase *view, const char *name = "", Qt::WFlags fl = Qt::Window /*adds minimize button for example*/); + Browser (lay::Dispatcher *root, lay::LayoutView *view, const char *name = "", Qt::WFlags fl = Qt::Window /*adds minimize button for example*/); #endif /** @@ -93,7 +93,7 @@ public: /** * @brief Return the pointer to the layout view */ - lay::LayoutViewBase *view () + lay::LayoutView *view () { return mp_view; } @@ -132,7 +132,7 @@ public: private: bool m_active; - lay::LayoutViewBase *mp_view; + lay::LayoutView *mp_view; lay::Dispatcher *mp_root; void closeEvent (QCloseEvent *); diff --git a/src/laybasic/laybasic/layCellSelectionForm.cc b/src/laybasic/laybasic/layCellSelectionForm.cc index be93b86ea..0bd3ff519 100644 --- a/src/laybasic/laybasic/layCellSelectionForm.cc +++ b/src/laybasic/laybasic/layCellSelectionForm.cc @@ -49,7 +49,7 @@ static const std::string cfg_cell_selection_search_use_expressions ("cell-select // ------------------------------------------------------------ -CellSelectionForm::CellSelectionForm (QWidget *parent, LayoutViewBase *view, const char *name, bool simple_mode) +CellSelectionForm::CellSelectionForm (QWidget *parent, LayoutView *view, const char *name, bool simple_mode) : QDialog (parent), Ui::CellSelectionForm (), mp_view (view), m_current_cv (-1), diff --git a/src/laybasic/laybasic/layCellSelectionForm.h b/src/laybasic/laybasic/layCellSelectionForm.h index f1447eee7..adc0a5cc7 100644 --- a/src/laybasic/laybasic/layCellSelectionForm.h +++ b/src/laybasic/laybasic/layCellSelectionForm.h @@ -49,7 +49,7 @@ class LAYBASIC_PUBLIC CellSelectionForm Q_OBJECT public: - CellSelectionForm (QWidget *parent, LayoutViewBase *view, const char *name, bool simple_mode = false); + CellSelectionForm (QWidget *parent, LayoutView *view, const char *name, bool simple_mode = false); /** * @brief Obtain the selected cellview's index (with changes) @@ -76,7 +76,7 @@ public slots: void find_prev_clicked(); private: - lay::LayoutViewBase *mp_view; + lay::LayoutView *mp_view; std::vector m_cellviews; int m_current_cv; bool m_name_cb_enabled; diff --git a/src/laybasic/laybasic/layCellTreeModel.cc b/src/laybasic/laybasic/layCellTreeModel.cc index d15ddf2fd..d8e4ca573 100644 --- a/src/laybasic/laybasic/layCellTreeModel.cc +++ b/src/laybasic/laybasic/layCellTreeModel.cc @@ -303,7 +303,7 @@ CellTreeItem::by_area_equal_than (const CellTreeItem *b) const // valid ("under construction"). In this case, the model will return defaults or void // objects. -CellTreeModel::CellTreeModel (QWidget *parent, lay::LayoutViewBase *view, int cv_index, unsigned int flags, const db::Cell *base, Sorting sorting) +CellTreeModel::CellTreeModel (QWidget *parent, lay::LayoutView *view, int cv_index, unsigned int flags, const db::Cell *base, Sorting sorting) : QAbstractItemModel (parent), m_flags (flags), m_sorting (sorting), @@ -379,7 +379,7 @@ CellTreeModel::~CellTreeModel () } void -CellTreeModel::configure (lay::LayoutViewBase *view, int cv_index, unsigned int flags, const db::Cell *base, Sorting sorting) +CellTreeModel::configure (lay::LayoutView *view, int cv_index, unsigned int flags, const db::Cell *base, Sorting sorting) { db::Layout *layout = & view->cellview (cv_index)->layout (); do_configure (layout, 0, view, cv_index, flags, base, sorting); @@ -398,7 +398,7 @@ CellTreeModel::configure (db::Library *library, unsigned int flags, const db::Ce } void -CellTreeModel::do_configure (db::Layout *layout, db::Library *library, lay::LayoutViewBase *view, int cv_index, unsigned int flags, const db::Cell *base, Sorting sorting) +CellTreeModel::do_configure (db::Layout *layout, db::Library *library, lay::LayoutView *view, int cv_index, unsigned int flags, const db::Cell *base, Sorting sorting) { bool flat = ((flags & Flat) != 0) && ((flags & TopCells) == 0); diff --git a/src/laybasic/laybasic/layCellTreeModel.h b/src/laybasic/laybasic/layCellTreeModel.h index b0c6af312..30608ee97 100644 --- a/src/laybasic/laybasic/layCellTreeModel.h +++ b/src/laybasic/laybasic/layCellTreeModel.h @@ -45,7 +45,7 @@ namespace db namespace lay { -class LayoutViewBase; +class LayoutView; class CellTreeItem; /** @@ -85,7 +85,7 @@ public: * If flags "Children" or "Parents" are given, "base" must be set to the cell of which * the children or parents should be derived. */ - CellTreeModel (QWidget *parent, lay::LayoutViewBase *view, int cv_index, unsigned int flags = 0, const db::Cell *base = 0, Sorting sorting = ByName); + CellTreeModel (QWidget *parent, lay::LayoutView *view, int cv_index, unsigned int flags = 0, const db::Cell *base = 0, Sorting sorting = ByName); /** * @brief Constructor @@ -120,7 +120,7 @@ public: /** * @brief Reconfigures the model with a LayoutView */ - void configure (LayoutViewBase *view, int cv_index, unsigned int flags = 0, const db::Cell *base = 0, Sorting sorting = ByName); + void configure (LayoutView *view, int cv_index, unsigned int flags = 0, const db::Cell *base = 0, Sorting sorting = ByName); /** * @brief Reconfigures the model with a pure Layout @@ -257,7 +257,7 @@ private: unsigned int m_flags; Sorting m_sorting; QWidget *mp_parent; - lay::LayoutViewBase *mp_view; + lay::LayoutView *mp_view; db::Layout *mp_layout; db::Library *mp_library; int m_cv_index; @@ -271,7 +271,7 @@ private: void build_top_level (); void clear_top_level (); bool search_children (const tl::GlobPattern &pattern, CellTreeItem *item); - void do_configure (db::Layout *layout, db::Library *library, LayoutViewBase *view, int cv_index, unsigned int flags, const db::Cell *base, Sorting sorting); + void do_configure (db::Layout *layout, db::Library *library, LayoutView *view, int cv_index, unsigned int flags, const db::Cell *base, Sorting sorting); }; /** diff --git a/src/laybasic/laybasic/layCellView.cc b/src/laybasic/laybasic/layCellView.cc index ee28b6cbc..1fa389ca9 100644 --- a/src/laybasic/laybasic/layCellView.cc +++ b/src/laybasic/laybasic/layCellView.cc @@ -23,7 +23,9 @@ #include "layCellView.h" #include "layLayoutView.h" -#include "layStream.h" +#if defined(HAVE_QT) // @@@ +# include "layStream.h" +#endif #include "dbLayout.h" #include "dbWriter.h" #include "dbReader.h" @@ -64,7 +66,7 @@ LayoutHandle::LayoutHandle (db::Layout *layout, const std::string &filename) // layouts in the managed layouts space participate in spare proxy cleanup layout->do_cleanup (true); - file_watcher ().add_file (m_filename); + add_file_to_watcher (m_filename); if (! m_filename.empty ()) { rename (filename_for_caption (m_filename)); @@ -107,7 +109,23 @@ LayoutHandle::~LayoutHandle () ms_dict.erase (m_name); } - file_watcher ().remove_file (filename ()); + remove_file_from_watcher (filename ()); +} + +void +LayoutHandle::remove_file_from_watcher (const std::string &path) +{ +#if defined(HAVE_QT) + file_watcher ().remove_file (path); +#endif +} + +void +LayoutHandle::add_file_to_watcher (const std::string &path) +{ +#if defined(HAVE_QT) + file_watcher ().add_file (path); +#endif } void @@ -176,9 +194,9 @@ LayoutHandle::layout () const void LayoutHandle::set_filename (const std::string &fn) { - file_watcher ().remove_file (m_filename); + remove_file_from_watcher (m_filename); m_filename = fn; - file_watcher ().add_file (m_filename); + add_file_to_watcher (m_filename); } const std::string & @@ -274,6 +292,7 @@ LayoutHandle::set_save_options (const db::SaveLayoutOptions &options, bool valid void LayoutHandle::update_save_options (db::SaveLayoutOptions &options) { +#if defined(HAVE_QT) // @@@ for (tl::Registrar::iterator cls = tl::Registrar::begin (); cls != tl::Registrar::end (); ++cls) { const lay::StreamWriterPluginDeclaration *decl = dynamic_cast (&*cls); @@ -294,6 +313,7 @@ LayoutHandle::update_save_options (db::SaveLayoutOptions &options) } } +#endif } void @@ -307,7 +327,7 @@ LayoutHandle::save_as (const std::string &fn, tl::OutputStream::OutputStreamMode // reader options. m_load_options = db::LoadLayoutOptions (); - file_watcher ().remove_file (filename ()); + remove_file_from_watcher (filename ()); rename (filename_for_caption (fn)); @@ -331,14 +351,14 @@ LayoutHandle::save_as (const std::string &fn, tl::OutputStream::OutputStreamMode } if (update) { - file_watcher ().add_file (filename ()); + add_file_to_watcher (filename ()); m_dirty = false; } } catch (...) { if (update) { - file_watcher ().add_file (filename ()); + add_file_to_watcher (filename ()); } throw; @@ -366,8 +386,8 @@ LayoutHandle::load (const db::LoadLayoutOptions &options, const std::string &tec } // Update the file's data: - file_watcher ().remove_file (filename ()); - file_watcher ().add_file (filename ()); + remove_file_from_watcher (filename ()); + add_file_to_watcher (filename ()); m_dirty = false; return new_lmap; @@ -391,13 +411,14 @@ LayoutHandle::load () } // Update the file's data: - file_watcher ().remove_file (filename ()); - file_watcher ().add_file (filename ()); + remove_file_from_watcher (filename ()); + add_file_to_watcher (filename ()); m_dirty = false; return new_lmap; } +#if defined(HAVE_QT) tl::FileSystemWatcher & LayoutHandle::file_watcher () { @@ -408,8 +429,10 @@ LayoutHandle::file_watcher () return *mp_file_watcher; } -std::map LayoutHandle::ms_dict; tl::FileSystemWatcher *LayoutHandle::mp_file_watcher = 0; +#endif + +std::map LayoutHandle::ms_dict; // ------------------------------------------------------------- // LayoutHandleRef implementation diff --git a/src/laybasic/laybasic/layCellView.h b/src/laybasic/laybasic/layCellView.h index 4fc1e98b4..632b7d304 100644 --- a/src/laybasic/laybasic/layCellView.h +++ b/src/laybasic/laybasic/layCellView.h @@ -297,6 +297,16 @@ public: static tl::FileSystemWatcher &file_watcher (); #endif + /** + * @brief Removes a file from the watcher + */ + static void remove_file_from_watcher (const std::string &path); + + /** + * @brief Adds a file to the watcher + */ + static void add_file_to_watcher (const std::string &path); + private: db::Layout *mp_layout; int m_ref_count; diff --git a/src/laybasic/laybasic/layEditorOptionsFrame.cc b/src/laybasic/laybasic/layEditorOptionsFrame.cc index 55607c77f..dd593f9e4 100644 --- a/src/laybasic/laybasic/layEditorOptionsFrame.cc +++ b/src/laybasic/laybasic/layEditorOptionsFrame.cc @@ -47,7 +47,7 @@ EditorOptionsFrame::~EditorOptionsFrame () } void -EditorOptionsFrame::populate (LayoutViewBase *view) +EditorOptionsFrame::populate (LayoutView *view) { std::vector prop_dialog_pages; for (tl::Registrar::iterator cls = tl::Registrar::begin (); cls != tl::Registrar::end (); ++cls) { diff --git a/src/laybasic/laybasic/layEditorOptionsFrame.h b/src/laybasic/laybasic/layEditorOptionsFrame.h index 0922be2ee..fff1f7d40 100644 --- a/src/laybasic/laybasic/layEditorOptionsFrame.h +++ b/src/laybasic/laybasic/layEditorOptionsFrame.h @@ -30,7 +30,7 @@ namespace lay { class EditorOptionsPages; -class LayoutViewBase; +class LayoutView; class LAYBASIC_PUBLIC EditorOptionsFrame : public QFrame @@ -39,7 +39,7 @@ public: EditorOptionsFrame (QWidget *parent); virtual ~EditorOptionsFrame (); - void populate (lay::LayoutViewBase *view); + void populate (lay::LayoutView *view); EditorOptionsPages *pages_widget () const { diff --git a/src/laybasic/laybasic/layEditorServiceBase.cc b/src/laybasic/laybasic/layEditorServiceBase.cc index 2e887fa5b..925f7a82e 100644 --- a/src/laybasic/laybasic/layEditorServiceBase.cc +++ b/src/laybasic/laybasic/layEditorServiceBase.cc @@ -202,7 +202,7 @@ private: // -------------------------------------------------------------------------------------- -EditorServiceBase::EditorServiceBase (LayoutViewBase *view) +EditorServiceBase::EditorServiceBase (LayoutView *view) : lay::ViewService (view->view_object_widget ()), lay::Editable (view), lay::Plugin (view), diff --git a/src/laybasic/laybasic/layEditorServiceBase.h b/src/laybasic/laybasic/layEditorServiceBase.h index 7316eeba6..276f1a66a 100644 --- a/src/laybasic/laybasic/layEditorServiceBase.h +++ b/src/laybasic/laybasic/layEditorServiceBase.h @@ -46,7 +46,7 @@ public: /** * @brief Constructor */ - EditorServiceBase (lay::LayoutViewBase *view); + EditorServiceBase (lay::LayoutView *view); /** * @brief Destructor diff --git a/src/laybasic/laybasic/layFinder.cc b/src/laybasic/laybasic/layFinder.cc index 214705fc4..cc6ea038a 100644 --- a/src/laybasic/laybasic/layFinder.cc +++ b/src/laybasic/laybasic/layFinder.cc @@ -86,7 +86,7 @@ Finder::closer (double d) } void -Finder::start (lay::LayoutViewBase *view, const lay::CellView &cv, unsigned int cv_index, const std::vector &trans, const db::Box ®ion, int min_level, int max_level, const std::vector &layers) +Finder::start (lay::LayoutView *view, const lay::CellView &cv, unsigned int cv_index, const std::vector &trans, const db::Box ®ion, int min_level, int max_level, const std::vector &layers) { m_layers = layers; m_region = region; @@ -265,7 +265,7 @@ struct LPContextCompareOp }; bool -ShapeFinder::find (LayoutViewBase *view, const db::DBox ®ion_mu) +ShapeFinder::find (LayoutView *view, const db::DBox ®ion_mu) { tl::AbsoluteProgress progress (tl::to_string (tr ("Selecting ..."))); progress.set_unit (1000); @@ -330,7 +330,7 @@ ShapeFinder::find (LayoutViewBase *view, const db::DBox ®ion_mu) } bool -ShapeFinder::find (lay::LayoutViewBase *view, const lay::LayerProperties &lprops, const db::DBox ®ion_mu) +ShapeFinder::find (lay::LayoutView *view, const lay::LayerProperties &lprops, const db::DBox ®ion_mu) { tl::AbsoluteProgress progress (tl::to_string (tr ("Selecting ..."))); progress.set_unit (1000); @@ -349,7 +349,7 @@ ShapeFinder::find (lay::LayoutViewBase *view, const lay::LayerProperties &lprops } bool -ShapeFinder::find_internal (lay::LayoutViewBase *view, unsigned int cv_index, const std::set *prop_sel, bool inv_prop_sel, const lay::HierarchyLevelSelection &hier_sel, const std::vector &trans_mu, const std::vector &layers, const db::DBox ®ion_mu) +ShapeFinder::find_internal (lay::LayoutView *view, unsigned int cv_index, const std::set *prop_sel, bool inv_prop_sel, const lay::HierarchyLevelSelection &hier_sel, const std::vector &trans_mu, const std::vector &layers, const db::DBox ®ion_mu) { m_cv_index = cv_index; @@ -624,7 +624,7 @@ InstFinder::InstFinder (bool point_mode, bool top_level_sel, bool full_arrays, b } bool -InstFinder::find (lay::LayoutViewBase *view, const db::DBox ®ion_mu) +InstFinder::find (lay::LayoutView *view, const db::DBox ®ion_mu) { tl::AbsoluteProgress progress (tl::to_string (tr ("Selecting ..."))); progress.set_unit (1000); @@ -641,7 +641,7 @@ InstFinder::find (lay::LayoutViewBase *view, const db::DBox ®ion_mu) } bool -InstFinder::find (LayoutViewBase *view, unsigned int cv_index, const db::DCplxTrans &trans_mu, const db::DBox ®ion_mu) +InstFinder::find (LayoutView *view, unsigned int cv_index, const db::DCplxTrans &trans_mu, const db::DBox ®ion_mu) { tl::AbsoluteProgress progress (tl::to_string (tr ("Selecting ..."))); progress.set_unit (1000); @@ -655,7 +655,7 @@ InstFinder::find (LayoutViewBase *view, unsigned int cv_index, const db::DCplxTr } bool -InstFinder::find_internal (LayoutViewBase *view, unsigned int cv_index, const db::DCplxTrans &trans_mu, const db::DBox ®ion_mu) +InstFinder::find_internal (LayoutView *view, unsigned int cv_index, const db::DCplxTrans &trans_mu, const db::DBox ®ion_mu) { const lay::CellView &cv = view->cellview (cv_index); if (! cv.is_valid ()) { diff --git a/src/laybasic/laybasic/layFinder.h b/src/laybasic/laybasic/layFinder.h index f411872b6..5b7608de7 100644 --- a/src/laybasic/laybasic/layFinder.h +++ b/src/laybasic/laybasic/layFinder.h @@ -136,7 +136,7 @@ protected: return m_max_level; } - lay::LayoutViewBase *view () const + lay::LayoutView *view () const { return mp_view; } @@ -153,7 +153,7 @@ protected: * path of instantiations up to the top cell is maintained and accessible by * the path() accessor. */ - void start (LayoutViewBase *view, const lay::CellView &cv, unsigned int cv_index, const std::vector &trans, const db::Box ®ion, int min_level, int max_level, const std::vector &layers = std::vector ()); + void start (LayoutView *view, const lay::CellView &cv, unsigned int cv_index, const std::vector &trans, const db::Box ®ion, int min_level, int max_level, const std::vector &layers = std::vector ()); /** * @brief Provide a basic edge test facility @@ -186,7 +186,7 @@ private: int m_min_level, m_max_level; std::vector m_path; const db::Layout *mp_layout; - lay::LayoutViewBase *mp_view; + lay::LayoutView *mp_view; unsigned int m_cv_index; db::Box m_region; std::vector m_layers; @@ -214,8 +214,8 @@ public: ShapeFinder (bool point_mode, bool top_level_sel, db::ShapeIterator::flags_type flags, const std::set *excludes = 0); - bool find (LayoutViewBase *view, const lay::LayerProperties &lprops, const db::DBox ®ion_mu); - bool find (LayoutViewBase *view, const db::DBox ®ion_mu); + bool find (LayoutView *view, const lay::LayerProperties &lprops, const db::DBox ®ion_mu); + bool find (LayoutView *view, const db::DBox ®ion_mu); iterator begin () const { @@ -262,7 +262,7 @@ protected: private: virtual void visit_cell (const db::Cell &cell, const db::Box &search_box, const db::ICplxTrans &t, int /*level*/); - bool find_internal (LayoutViewBase *view, + bool find_internal (LayoutView *view, unsigned int cv_index, const std::set *prop_sel, bool inv_prop_sel, @@ -300,8 +300,8 @@ public: InstFinder (bool point_mode, bool top_level_sel, bool full_arrays, bool enclose_inst = true, const std::set *excludes = 0, bool visible_layers = false); - bool find (LayoutViewBase *view, unsigned int cv_index, const db::DCplxTrans &trans, const db::DBox ®ion_mu); - bool find (LayoutViewBase *view, const db::DBox ®ion_mu); + bool find (LayoutView *view, unsigned int cv_index, const db::DCplxTrans &trans, const db::DBox ®ion_mu); + bool find (LayoutView *view, const db::DBox ®ion_mu); iterator begin () const { @@ -315,7 +315,7 @@ public: private: virtual void visit_cell (const db::Cell &cell, const db::Box &search_box, const db::ICplxTrans &t, int level); - bool find_internal (LayoutViewBase *view, unsigned int cv_index, const db::DCplxTrans &trans_mu, const db::DBox ®ion_mu); + bool find_internal (LayoutView *view, unsigned int cv_index, const db::DCplxTrans &trans_mu, const db::DBox ®ion_mu); unsigned int m_cv_index; db::cell_index_type m_topcell; diff --git a/src/laybasic/laybasic/layGridNet.cc b/src/laybasic/laybasic/layGridNet.cc index d23d7c858..d006ca58c 100644 --- a/src/laybasic/laybasic/layGridNet.cc +++ b/src/laybasic/laybasic/layGridNet.cc @@ -105,7 +105,7 @@ GridNetPluginDeclaration::config_page (QWidget *parent, std::string &title) cons #endif lay::Plugin * -GridNetPluginDeclaration::create_plugin (db::Manager *, Dispatcher *, lay::LayoutViewBase *view) const +GridNetPluginDeclaration::create_plugin (db::Manager *, Dispatcher *, lay::LayoutView *view) const { return new lay::GridNet (view); } @@ -115,7 +115,7 @@ static tl::RegisteredClass config_decl (new GridNetPlugi // ------------------------------------------------------------ // Implementation of the GridNet object -GridNet::GridNet (LayoutViewBase *view) +GridNet::GridNet (LayoutView *view) : lay::BackgroundViewObject (view->view_object_widget ()), lay::Plugin (view), mp_view (view), diff --git a/src/laybasic/laybasic/layGridNet.h b/src/laybasic/laybasic/layGridNet.h index 469d3d232..529b30509 100644 --- a/src/laybasic/laybasic/layGridNet.h +++ b/src/laybasic/laybasic/layGridNet.h @@ -50,7 +50,7 @@ public: #if defined(HAVE_QT) virtual lay::ConfigPage *config_page (QWidget *parent, std::string &title) const; #endif - virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *, lay::LayoutViewBase *view) const; + virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *, lay::LayoutView *view) const; }; class GridNet @@ -68,7 +68,7 @@ public: CheckerBoard }; - GridNet (lay::LayoutViewBase *view); + GridNet (lay::LayoutView *view); private: virtual void render_bg (const lay::Viewport &vp, lay::ViewObjectCanvas &canvas); @@ -76,7 +76,7 @@ private: // implementation of the lay::Plugin interface virtual bool configure (const std::string &name, const std::string &value); - lay::LayoutViewBase *mp_view; + lay::LayoutView *mp_view; bool m_visible; bool m_show_ruler; double m_grid; diff --git a/src/laybasic/laybasic/layLayerProperties.cc b/src/laybasic/laybasic/layLayerProperties.cc index 75aed4563..7b9476a92 100644 --- a/src/laybasic/laybasic/layLayerProperties.cc +++ b/src/laybasic/laybasic/layLayerProperties.cc @@ -23,6 +23,7 @@ #include "layLayerProperties.h" #include "layLayoutViewBase.h" +#include "layLayoutView.h" #include "layConverters.h" #include "tlXMLParser.h" #include "tlException.h" @@ -404,7 +405,7 @@ class LayerSourceEval : public tl::Eval { public: - LayerSourceEval (const lay::LayerProperties &lp, const lay::LayoutViewBase *view, bool real) + LayerSourceEval (const lay::LayerProperties &lp, const lay::LayoutView *view, bool real) : m_lp (lp), mp_view (view), m_real (real) { // .. nothing yet .. @@ -415,14 +416,14 @@ public: return m_lp.source (m_real); } - const lay::LayoutViewBase *view () const + const lay::LayoutView *view () const { return mp_view; } private: const lay::LayerProperties &m_lp; - const lay::LayoutViewBase *mp_view; + const lay::LayoutView *mp_view; bool m_real; }; @@ -498,7 +499,7 @@ LayerProperties::display_string (const lay::LayoutViewBase *view, bool real, boo realize_source (); } - LayerSourceEval eval (*this, view, real); + LayerSourceEval eval (*this, view->ui (), real); eval.define_function ("N", new LayerSourceEvalFunction ('N', &eval)); // layer name eval.define_function ("L", new LayerSourceEvalFunction ('L', &eval)); // layer number eval.define_function ("D", new LayerSourceEvalFunction ('D', &eval)); // datatype @@ -712,8 +713,7 @@ LayerPropertiesNode::operator== (const LayerPropertiesNode &d) const return m_children == d.m_children; } -LayoutViewBase * -LayerPropertiesNode::view () const +LayoutViewBase *LayerPropertiesNode::view() const { return const_cast (mp_view.get ()); } @@ -1373,7 +1373,7 @@ expand_wildcard_layers (const LayerPropertiesNode &lp, const LayerPropertiesList // NOTE: initialization through LayerProperties creates a new ID lay::LayerPropertiesNode node ((const LayerProperties &) lp); - node.attach_view (view, list_index); + node.attach_view (view->ui (), list_index); // Build a new ParsedLayerSource combining the transformation, hierarchy levels and // property selections from the wildcard one and the requested layer source diff --git a/src/laybasic/laybasic/layLayerProperties.h b/src/laybasic/laybasic/layLayerProperties.h index 3df52ade7..1b6bffcdc 100644 --- a/src/laybasic/laybasic/layLayerProperties.h +++ b/src/laybasic/laybasic/layLayerProperties.h @@ -1170,7 +1170,6 @@ public: * This method attaches the properties node and it's children to a view. * This enables the node to realize itself against the view, i.e. * compute the actual property selection set. - * This method is supposed to be */ void attach_view (LayoutViewBase *view, unsigned int list_index); @@ -1912,7 +1911,7 @@ public: * "load" automatically attaches the view. * This method has the side effect of recomputing the layer source parameters. */ - void attach_view (lay::LayoutViewBase *view, unsigned int list_index); + void attach_view (LayoutViewBase *view, unsigned int list_index); /** * @brief Gets the layout view this list is attached to diff --git a/src/laybasic/laybasic/layLayerTreeModel.cc b/src/laybasic/laybasic/layLayerTreeModel.cc index d52ace764..5a3c09eea 100644 --- a/src/laybasic/laybasic/layLayerTreeModel.cc +++ b/src/laybasic/laybasic/layLayerTreeModel.cc @@ -631,7 +631,7 @@ LayerTreeModel::empty_within_view_predicate (const QModelIndex &index) const LAYBASIC_PUBLIC QIcon -LayerTreeModel::icon_for_layer (const lay::LayerPropertiesConstIterator &iter, lay::LayoutViewBase *view, unsigned int w, unsigned int h, unsigned int di_off, bool no_state) +LayerTreeModel::icon_for_layer (const lay::LayerPropertiesConstIterator &iter, lay::LayoutView *view, unsigned int w, unsigned int h, unsigned int di_off, bool no_state) { h = std::max ((unsigned int) 16, h); w = std::max ((unsigned int) 16, w); diff --git a/src/laybasic/laybasic/layLayerTreeModel.h b/src/laybasic/laybasic/layLayerTreeModel.h index 7da95e367..6e39f2efd 100644 --- a/src/laybasic/laybasic/layLayerTreeModel.h +++ b/src/laybasic/laybasic/layLayerTreeModel.h @@ -48,7 +48,7 @@ namespace lay { class LayoutView; -class LayoutViewBase; +class LayoutView; class LayerPropertiesConstIterator; /** @@ -109,7 +109,7 @@ public: /** * @brief Provides an icon for a given layer style */ - static QIcon icon_for_layer (const lay::LayerPropertiesConstIterator &iter, lay::LayoutViewBase *view, unsigned int w, unsigned int h, unsigned int di_offset, bool no_state = false); + static QIcon icon_for_layer (const lay::LayerPropertiesConstIterator &iter, lay::LayoutView *view, unsigned int w, unsigned int h, unsigned int di_offset, bool no_state = false); /** * @brief Gets the preferred icon size diff --git a/src/laybasic/laybasic/layLayoutView.h b/src/laybasic/laybasic/layLayoutView.h index d47a22e89..475926838 100644 --- a/src/laybasic/laybasic/layLayoutView.h +++ b/src/laybasic/laybasic/layLayoutView.h @@ -418,11 +418,6 @@ public: */ virtual QWidget *widget () { return this; } - /** - * @brief Gets the LayoutView interface - */ - virtual LayoutView *ui () { return this; } - /** * @brief Copies to clipboard * @@ -762,6 +757,15 @@ protected: virtual void emit_title_changed (); virtual void emit_dirty_changed (); virtual void emit_layer_order_changed (); + +protected: + /** + * @brief Gets the LayoutView interface + */ + virtual LayoutView *get_ui () { return this; } + +private: + using LayoutViewBase::ui; }; } @@ -792,6 +796,15 @@ public: * @brief Constructor (clone from another view) */ LayoutView (lay::LayoutView *source, db::Manager *mgr, bool editable, lay::Plugin *plugin_parent, unsigned int options = (unsigned int) LV_Normal); + +protected: + /** + * @brief Gets the LayoutView interface + */ + virtual LayoutView *get_ui () { return this; } + +private: + using LayoutViewBase::ui; }; } diff --git a/src/laybasic/laybasic/layLayoutViewBase.cc b/src/laybasic/laybasic/layLayoutViewBase.cc index 233414df7..413204547 100644 --- a/src/laybasic/laybasic/layLayoutViewBase.cc +++ b/src/laybasic/laybasic/layLayoutViewBase.cc @@ -274,7 +274,7 @@ LayoutViewBase::LayoutViewBase (lay::LayoutViewBase *source, db::Manager *manage } else { *m_layer_properties_lists [i] = *source->m_layer_properties_lists [i]; } - m_layer_properties_lists [i]->attach_view (this, (unsigned int) i); + m_layer_properties_lists [i]->attach_view (ui (), (unsigned int) i); } if (! m_layer_properties_lists.empty ()) { @@ -367,7 +367,7 @@ LayoutViewBase::init (db::Manager *mgr) m_search_range_box = 0; m_layer_properties_lists.push_back (new LayerPropertiesList ()); - m_layer_properties_lists.back ()->attach_view (this, (unsigned int) (m_layer_properties_lists.size () - 1)); + m_layer_properties_lists.back ()->attach_view (ui (), (unsigned int) (m_layer_properties_lists.size () - 1)); m_current_layer_list = 0; #if defined(HAVE_QT) @@ -388,16 +388,16 @@ LayoutViewBase::init (db::Manager *mgr) // occupy services and editables: // these services get deleted by the canvas destructor automatically: if ((m_options & LV_NoTracker) == 0) { - mp_tracker = new lay::MouseTracker (this); + mp_tracker = new lay::MouseTracker (ui ()); } if ((m_options & LV_NoZoom) == 0) { - mp_zoom_service = new lay::ZoomService (this); + mp_zoom_service = new lay::ZoomService (ui ()); } if ((m_options & LV_NoSelection) == 0) { - mp_selection_service = new lay::SelectionService (this); + mp_selection_service = new lay::SelectionService (ui ()); } if ((m_options & LV_NoMove) == 0) { - mp_move_service = new lay::MoveService (this); + mp_move_service = new lay::MoveService (ui ()); } create_plugins (); @@ -554,7 +554,7 @@ void LayoutViewBase::create_plugins (const lay::PluginDeclaration *except_this) lay::Plugin *LayoutViewBase::create_plugin (const lay::PluginDeclaration *cls) { - lay::Plugin *p = cls->create_plugin (manager (), dispatcher (), this); + lay::Plugin *p = cls->create_plugin (manager (), dispatcher (), ui ()); if (p) { // unhook the plugin from the script side if created there (prevent GC from destroying it) @@ -1329,7 +1329,7 @@ LayoutViewBase::insert_layer_list (unsigned index, const LayerPropertiesList &pr clear_layer_selection (); m_layer_properties_lists.insert (m_layer_properties_lists.begin () + index, new LayerPropertiesList (props)); - m_layer_properties_lists [index]->attach_view (this, index); + m_layer_properties_lists [index]->attach_view (ui (), index); merge_dither_pattern (*m_layer_properties_lists [index]); m_current_layer_list = index; @@ -1538,7 +1538,7 @@ LayoutViewBase::set_properties (unsigned int index, const LayerPropertiesList &p return; } else { m_layer_properties_lists.push_back (new LayerPropertiesList ()); - m_layer_properties_lists.back ()->attach_view (this, (unsigned int) (m_layer_properties_lists.size () - 1)); + m_layer_properties_lists.back ()->attach_view (ui (), (unsigned int) (m_layer_properties_lists.size () - 1)); } } @@ -1557,7 +1557,7 @@ LayoutViewBase::set_properties (unsigned int index, const LayerPropertiesList &p } *m_layer_properties_lists [index] = props; - m_layer_properties_lists [index]->attach_view (this, index); + m_layer_properties_lists [index]->attach_view (ui (), index); merge_dither_pattern (*m_layer_properties_lists [index]); @@ -1975,7 +1975,7 @@ LayoutViewBase::signal_layer_properties_changed () // recompute the source // TODO: this is a side effect of this method - provide a special method for this purpose for (unsigned int i = 0; i < layer_lists (); ++i) { - m_layer_properties_lists [i]->attach_view (this, i); + m_layer_properties_lists [i]->attach_view (ui (), i); } // schedule a redraw request - since the layer views might not have changed, this is necessary @@ -1991,7 +1991,7 @@ LayoutViewBase::signal_prop_ids_changed () // recompute the source // TODO: this is a side effect of this method - provide a special method for this purpose for (unsigned int i = 0; i < layer_lists (); ++i) { - m_layer_properties_lists [i]->attach_view (this, i); + m_layer_properties_lists [i]->attach_view (ui (), i); } } @@ -2298,7 +2298,7 @@ LayoutViewBase::do_load_layer_props (const std::string &fn, bool map_cv, int cv_ if (map_cv) { cv_map.insert (std::make_pair (-1, cv_index)); } - p->attach_view (this, p - props.begin ()); + p->attach_view (ui (), p - props.begin ()); p->expand (cv_map, add_default); } @@ -3089,7 +3089,7 @@ LayoutViewBase::create_initial_layer_props (int cv_index, const std::string &lyp // expand the wildcards and map to the target cv. for (std::vector::iterator p = props.begin (); p != props.end (); ++p) { - p->attach_view (this, p - props.begin ()); + p->attach_view (ui (), p - props.begin ()); p->expand (cv_map, add_missing || !loaded); } @@ -3203,7 +3203,7 @@ LayoutViewBase::widget () #endif LayoutView * -LayoutViewBase::ui () +LayoutViewBase::get_ui () { tl_assert (false); } diff --git a/src/laybasic/laybasic/layLayoutViewBase.h b/src/laybasic/laybasic/layLayoutViewBase.h index 0047975fc..16434c38e 100644 --- a/src/laybasic/laybasic/layLayoutViewBase.h +++ b/src/laybasic/laybasic/layLayoutViewBase.h @@ -790,12 +790,12 @@ public: */ void load_layer_props (const std::string &fn, int cv_index, bool add_default); +#if defined(HAVE_QT) // @@@ /** * @brief Save the screen content to a file */ void save_screenshot (const std::string &fn); -#if defined(HAVE_QT) /** * @brief Get the screen content as a QImage object */ @@ -2510,7 +2510,18 @@ public: /** * @brief Gets the LayoutView interface */ - virtual LayoutView *ui (); + LayoutView *ui () + { + return get_ui (); + } + + /** + * @brief Gets the LayoutView interface (const version) + */ + const LayoutView *ui () const + { + return const_cast (this)->get_ui (); + } private: // event handlers used to connect to the layout object's events @@ -2686,6 +2697,8 @@ protected: return mp_active_plugin; } + virtual LayoutView *get_ui (); + bool configure (const std::string &name, const std::string &value); void config_finalize (); diff --git a/src/laybasic/laybasic/layLayoutViewFunctions.cc b/src/laybasic/laybasic/layLayoutViewFunctions.cc index 724e8c137..5ae02957d 100644 --- a/src/laybasic/laybasic/layLayoutViewFunctions.cc +++ b/src/laybasic/laybasic/layLayoutViewFunctions.cc @@ -77,8 +77,8 @@ validate_cell_path (const db::Layout &layout, lay::LayoutView::cell_path_type &p return false; } -LayoutViewFunctions::LayoutViewFunctions (db::Manager *manager, LayoutViewBase *view) - : lay::Plugin (view), mp_view (view->ui ()), mp_manager (manager) +LayoutViewFunctions::LayoutViewFunctions (db::Manager *manager, LayoutView *view) + : lay::Plugin (view), mp_view (view), mp_manager (manager) { m_del_cell_mode = 0; m_move_to_origin_mode_x = 0; @@ -2244,7 +2244,7 @@ public: } } - lay::Plugin *create_plugin (db::Manager *manager, Dispatcher *, LayoutViewBase *view) const + lay::Plugin *create_plugin (db::Manager *manager, Dispatcher *, LayoutView *view) const { return new LayoutViewFunctions (manager, view); } diff --git a/src/laybasic/laybasic/layLayoutViewFunctions.h b/src/laybasic/laybasic/layLayoutViewFunctions.h index 6661a4753..37fdeb676 100644 --- a/src/laybasic/laybasic/layLayoutViewFunctions.h +++ b/src/laybasic/laybasic/layLayoutViewFunctions.h @@ -46,7 +46,7 @@ public: /** * @brief Constructor */ - LayoutViewFunctions (db::Manager *manager, lay::LayoutViewBase *view); + LayoutViewFunctions (db::Manager *manager, lay::LayoutView *view); /** * @brief Destructor diff --git a/src/laybasic/laybasic/layMarker.cc b/src/laybasic/laybasic/layMarker.cc index 29f822673..729f4fbcd 100644 --- a/src/laybasic/laybasic/layMarker.cc +++ b/src/laybasic/laybasic/layMarker.cc @@ -188,7 +188,7 @@ void render_cell_inst (const db::Layout &layout, const db::CellInstArray &inst, // ------------------------------------------------------------------------ -MarkerBase::MarkerBase (lay::LayoutViewBase *view) +MarkerBase::MarkerBase (lay::LayoutView *view) : lay::ViewObject (view->view_object_widget ()), m_line_width (-1), m_vertex_size (-1), m_halo (-1), m_text_enabled (true), m_vertex_shape (lay::ViewOp::Rect), m_line_style (-1), m_dither_pattern (-1), m_frame_pattern (0), mp_view (view) { @@ -372,7 +372,7 @@ MarkerBase::get_bitmaps (const Viewport & /*vp*/, ViewObjectCanvas &canvas, lay: // ------------------------------------------------------------------------ -GenericMarkerBase::GenericMarkerBase (lay::LayoutViewBase *view, unsigned int cv_index) +GenericMarkerBase::GenericMarkerBase (lay::LayoutView *view, unsigned int cv_index) : MarkerBase (view), mp_trans_vector (0), mp_view (view), m_cv_index (cv_index) { // .. nothing yet .. @@ -496,7 +496,7 @@ GenericMarkerBase::dbu () const // ------------------------------------------------------------------------ -InstanceMarker::InstanceMarker (LayoutViewBase *view, unsigned int cv_index, bool draw_outline, size_t max_shapes) +InstanceMarker::InstanceMarker (LayoutView *view, unsigned int cv_index, bool draw_outline, size_t max_shapes) : GenericMarkerBase (view, cv_index), m_draw_outline (draw_outline), m_max_shapes (max_shapes), m_inst () { // .. nothing yet .. @@ -576,7 +576,7 @@ InstanceMarker::item_bbox () const // ------------------------------------------------------------------------ -ShapeMarker::ShapeMarker (LayoutViewBase *view, unsigned int cv_index) +ShapeMarker::ShapeMarker (LayoutView *view, unsigned int cv_index) : GenericMarkerBase (view, cv_index), m_shape () { // .. nothing yet .. @@ -643,7 +643,7 @@ ShapeMarker::item_bbox () const // ------------------------------------------------------------------------ -Marker::Marker (lay::LayoutViewBase *view, unsigned int cv_index, bool draw_outline, size_t max_shapes) +Marker::Marker (lay::LayoutView *view, unsigned int cv_index, bool draw_outline, size_t max_shapes) : GenericMarkerBase (view, cv_index), m_draw_outline (draw_outline), m_max_shapes (max_shapes) { m_type = None; @@ -1135,7 +1135,7 @@ Marker::render (const Viewport &vp, ViewObjectCanvas &canvas) // ------------------------------------------------------------------------ -DMarker::DMarker (LayoutViewBase *view) +DMarker::DMarker (LayoutView *view) : MarkerBase (view), mp_view (view) { m_type = None; diff --git a/src/laybasic/laybasic/layMarker.h b/src/laybasic/laybasic/layMarker.h index 2cc4a4133..7b18deab6 100644 --- a/src/laybasic/laybasic/layMarker.h +++ b/src/laybasic/laybasic/layMarker.h @@ -44,7 +44,7 @@ namespace lay { -class LayoutViewBase; +class LayoutView; /** * @brief The marker base class @@ -59,7 +59,7 @@ public: /** * @brief The constructor */ - MarkerBase (lay::LayoutViewBase *view); + MarkerBase (lay::LayoutView *view); /** * @brief Get the color by which the marker is drawn @@ -232,7 +232,7 @@ protected: bool m_text_enabled; lay::ViewOp::Shape m_vertex_shape; int m_line_style, m_dither_pattern, m_frame_pattern; - lay::LayoutViewBase *mp_view; + lay::LayoutView *mp_view; }; /** @@ -252,7 +252,7 @@ public: /** * @brief The constructor */ - GenericMarkerBase (lay::LayoutViewBase *view, unsigned int cv_index); + GenericMarkerBase (lay::LayoutView *view, unsigned int cv_index); /** * @brief The destructor @@ -321,7 +321,7 @@ public: /** * @brief Gets the view object */ - lay::LayoutViewBase *view () const + lay::LayoutView *view () const { return mp_view; } @@ -344,7 +344,7 @@ public: private: db::CplxTrans m_trans; std::vector *mp_trans_vector; - lay::LayoutViewBase *mp_view; + lay::LayoutView *mp_view; unsigned int m_cv_index; /** @@ -367,7 +367,7 @@ public: /** * @brief The constructor */ - ShapeMarker (lay::LayoutViewBase *view, unsigned int cv_index); + ShapeMarker (lay::LayoutView *view, unsigned int cv_index); /** * @brief The destructor @@ -418,7 +418,7 @@ public: * @param draw_outline True to have instances drawing their outline * @param max_shapes The maximum number of shapes to draw for instances (just a box is drawn if more shapes are present) */ - InstanceMarker (lay::LayoutViewBase *view, unsigned int cv_index, bool draw_outline = true, size_t max_shapes = 0); + InstanceMarker (lay::LayoutView *view, unsigned int cv_index, bool draw_outline = true, size_t max_shapes = 0); /** * @brief The destructor @@ -508,7 +508,7 @@ public: * @param draw_outline True to have instances drawing their outline * @param max_shapes The maximum number of shapes to draw for instances (just a box is drawn if more shapes are present) */ - Marker (lay::LayoutViewBase *view, unsigned int cv_index, bool draw_outline = true, size_t max_shapes = 0); + Marker (lay::LayoutView *view, unsigned int cv_index, bool draw_outline = true, size_t max_shapes = 0); /** * @brief The destructor @@ -743,7 +743,7 @@ public: /** * @brief The constructor */ - DMarker (lay::LayoutViewBase *view); + DMarker (lay::LayoutView *view); /** * @brief The destructor @@ -806,7 +806,7 @@ private: void *any; } m_object; - lay::LayoutViewBase *mp_view; + lay::LayoutView *mp_view; }; } diff --git a/src/laybasic/laybasic/layMouseTracker.cc b/src/laybasic/laybasic/layMouseTracker.cc index f84a48779..73caa324b 100644 --- a/src/laybasic/laybasic/layMouseTracker.cc +++ b/src/laybasic/laybasic/layMouseTracker.cc @@ -28,7 +28,7 @@ namespace lay { -MouseTracker::MouseTracker (lay::LayoutViewBase *view) +MouseTracker::MouseTracker (lay::LayoutView *view) : lay::ViewService (view->view_object_widget ()), mp_view (view) { widget ()->grab_mouse (this, false); diff --git a/src/laybasic/laybasic/layMouseTracker.h b/src/laybasic/laybasic/layMouseTracker.h index 2eb5c33e5..3e826606b 100644 --- a/src/laybasic/laybasic/layMouseTracker.h +++ b/src/laybasic/laybasic/layMouseTracker.h @@ -31,17 +31,17 @@ class QMouseEvent; namespace lay { class LayoutCanvas; -class LayoutViewBase; +class LayoutView; class MouseTracker : public lay::ViewService { public: - MouseTracker (lay::LayoutViewBase *view); + MouseTracker (lay::LayoutView *view); virtual bool mouse_move_event (const db::DPoint &p, unsigned int buttons, bool prio); private: - lay::LayoutViewBase *mp_view; + lay::LayoutView *mp_view; }; } diff --git a/src/laybasic/laybasic/layMove.cc b/src/laybasic/laybasic/layMove.cc index 9667ccb77..3d86338ad 100644 --- a/src/laybasic/laybasic/layMove.cc +++ b/src/laybasic/laybasic/layMove.cc @@ -34,7 +34,7 @@ namespace lay // ------------------------------------------------------------- // MoveService implementation -MoveService::MoveService (lay::LayoutViewBase *view) +MoveService::MoveService (lay::LayoutView *view) : lay::ViewService (view->view_object_widget ()), m_dragging (false), m_dragging_transient (false), diff --git a/src/laybasic/laybasic/layMove.h b/src/laybasic/laybasic/layMove.h index 3908c6505..784630d5e 100644 --- a/src/laybasic/laybasic/layMove.h +++ b/src/laybasic/laybasic/layMove.h @@ -31,13 +31,13 @@ namespace lay { class Editables; -class LayoutViewBase; +class LayoutView; class MoveService : public lay::ViewService { public: - MoveService (lay::LayoutViewBase *view); + MoveService (lay::LayoutView *view); ~MoveService (); virtual bool configure (const std::string &name, const std::string &value); @@ -59,7 +59,7 @@ private: bool m_dragging; bool m_dragging_transient; lay::Editables *mp_editables; - lay::LayoutViewBase *mp_view; + lay::LayoutView *mp_view; double m_global_grid; db::DPoint m_shift; db::DPoint m_mouse_pos; diff --git a/src/laybasic/laybasic/layNetlistBrowser.cc b/src/laybasic/laybasic/layNetlistBrowser.cc index ab689cb92..d43501a38 100644 --- a/src/laybasic/laybasic/layNetlistBrowser.cc +++ b/src/laybasic/laybasic/layNetlistBrowser.cc @@ -376,7 +376,7 @@ public: menu_entries.push_back (lay::menu_item ("netlist_browser::show", "browse_netlists", "tools_menu.end", tl::to_string (QObject::tr ("Netlist Browser")))); } - virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutViewBase *view) const + virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutView *view) const { return new lay::NetlistBrowserDialog (root, view); } diff --git a/src/laybasic/laybasic/layNetlistBrowserDialog.cc b/src/laybasic/laybasic/layNetlistBrowserDialog.cc index 577865a3b..820ebdf32 100644 --- a/src/laybasic/laybasic/layNetlistBrowserDialog.cc +++ b/src/laybasic/laybasic/layNetlistBrowserDialog.cc @@ -56,7 +56,7 @@ extern const std::string cfg_l2ndb_max_shapes_highlighted; extern const std::string cfg_l2ndb_show_all; extern const std::string cfg_l2ndb_window_state; -NetlistBrowserDialog::NetlistBrowserDialog (lay::Dispatcher *root, lay::LayoutViewBase *vw) +NetlistBrowserDialog::NetlistBrowserDialog (lay::Dispatcher *root, lay::LayoutView *vw) : lay::Browser (root, vw), lay::ViewService (vw->view_object_widget ()), Ui::NetlistBrowserDialog (), diff --git a/src/laybasic/laybasic/layNetlistBrowserDialog.h b/src/laybasic/laybasic/layNetlistBrowserDialog.h index d7ad87699..ebebe1c14 100644 --- a/src/laybasic/laybasic/layNetlistBrowserDialog.h +++ b/src/laybasic/laybasic/layNetlistBrowserDialog.h @@ -42,7 +42,7 @@ class NetlistBrowserDialog Q_OBJECT public: - NetlistBrowserDialog (lay::Dispatcher *root, lay::LayoutViewBase *view); + NetlistBrowserDialog (lay::Dispatcher *root, lay::LayoutView *view); ~NetlistBrowserDialog (); void load (int lay_index, int cv_index); diff --git a/src/laybasic/laybasic/layNetlistBrowserPage.cc b/src/laybasic/laybasic/layNetlistBrowserPage.cc index 828be2771..ef1fdc4f0 100644 --- a/src/laybasic/laybasic/layNetlistBrowserPage.cc +++ b/src/laybasic/laybasic/layNetlistBrowserPage.cc @@ -242,7 +242,7 @@ NetlistBrowserPage::set_highlight_style (lay::Color color, int line_width, int v } void -NetlistBrowserPage::set_view (lay::LayoutViewBase *view, int cv_index) +NetlistBrowserPage::set_view (lay::LayoutView *view, int cv_index) { if (mp_view) { mp_view->layer_list_changed_event.remove (this, &NetlistBrowserPage::layer_list_changed); @@ -1424,7 +1424,7 @@ NetlistBrowserPage::export_nets (const std::vector *nets) if (dialog->exec_dialog (mp_plugin_root)) { // NOTE: mp_view and database might get reset to 0 in create_layout - lay::LayoutViewBase *view = mp_view; + lay::LayoutView *view = mp_view; db::LayoutToNetlist *database = mp_database.get (); unsigned int cv_index = view->create_layout (true); diff --git a/src/laybasic/laybasic/layNetlistBrowserPage.h b/src/laybasic/laybasic/layNetlistBrowserPage.h index 2d330b0d7..c268baaa5 100644 --- a/src/laybasic/laybasic/layNetlistBrowserPage.h +++ b/src/laybasic/laybasic/layNetlistBrowserPage.h @@ -86,7 +86,7 @@ public: * If that pointer is non-null, the browser will attach itself to * the view and provide highlights for the selected markers inside the given cellview. */ - void set_view (LayoutViewBase *view, int cv_index); + void set_view (LayoutView *view, int cv_index); /** * @brief Attaches the page to a L2N DB @@ -224,7 +224,7 @@ private: int m_marker_dither_pattern; int m_marker_intensity; bool m_use_original_colors; - lay::LayoutViewBase *mp_view; + lay::LayoutView *mp_view; unsigned int m_cv_index; lay::Dispatcher *mp_plugin_root; tl::weak_ptr mp_database; diff --git a/src/laybasic/laybasic/layParsedLayerSource.cc b/src/laybasic/laybasic/layParsedLayerSource.cc index 66130f12f..1b05eaefe 100644 --- a/src/laybasic/laybasic/layParsedLayerSource.cc +++ b/src/laybasic/laybasic/layParsedLayerSource.cc @@ -22,7 +22,7 @@ #include "layParsedLayerSource.h" -#include "layLayoutViewBase.h" +#include "layLayoutView.h" #include "tlString.h" #include "tlGlobPattern.h" diff --git a/src/laybasic/laybasic/layPlugin.h b/src/laybasic/laybasic/layPlugin.h index 4a0b57ff8..fc83a478b 100644 --- a/src/laybasic/laybasic/layPlugin.h +++ b/src/laybasic/laybasic/layPlugin.h @@ -48,7 +48,7 @@ namespace lay class Plugin; class Dispatcher; -class LayoutViewBase; +class LayoutView; class ViewService; class Editable; class Drawing; @@ -302,7 +302,7 @@ public: * This method may return 0 for "dummy" plugins that just register menu entries * or configuration options. */ - virtual lay::Plugin *create_plugin (db::Manager * /*manager*/, lay::Dispatcher * /*dispatcher*/, lay::LayoutViewBase * /*view*/) const + virtual lay::Plugin *create_plugin (db::Manager * /*manager*/, lay::Dispatcher * /*dispatcher*/, lay::LayoutView * /*view*/) const { return 0; } @@ -329,7 +329,7 @@ public: * * The new pages are returned in the "pages" vector. The layout view will take ownership of these pages. */ - virtual void get_editor_options_pages (std::vector & /*pages*/, lay::LayoutViewBase * /*view*/, lay::Dispatcher * /*dispatcher*/) const + virtual void get_editor_options_pages (std::vector & /*pages*/, lay::LayoutView * /*view*/, lay::Dispatcher * /*dispatcher*/) const { // .. no pages in the default implementation .. } diff --git a/src/laybasic/laybasic/laySelector.cc b/src/laybasic/laybasic/laySelector.cc index 029b1cbe1..e1dea2f3b 100644 --- a/src/laybasic/laybasic/laySelector.cc +++ b/src/laybasic/laybasic/laySelector.cc @@ -37,7 +37,7 @@ namespace lay // ------------------------------------------------------------- // SelectionService implementation -SelectionService::SelectionService (lay::LayoutViewBase *view) +SelectionService::SelectionService (lay::LayoutView *view) : QObject (), lay::ViewService (view->view_object_widget ()), mp_view (view), diff --git a/src/laybasic/laybasic/laySelector.h b/src/laybasic/laybasic/laySelector.h index ad81060b3..69c3d4b25 100644 --- a/src/laybasic/laybasic/laySelector.h +++ b/src/laybasic/laybasic/laySelector.h @@ -38,7 +38,7 @@ namespace lay { class RubberBox; -class LayoutViewBase; +class LayoutView; class LayoutCanvas; class LAYBASIC_PUBLIC SelectionService : @@ -52,7 +52,7 @@ Q_OBJECT #endif public: - SelectionService (lay::LayoutViewBase *view); + SelectionService (lay::LayoutView *view); ~SelectionService (); void set_colors (lay::Color background, lay::Color color); @@ -88,7 +88,7 @@ private: db::DPoint m_p1, m_p2; db::DPoint m_current_position; - lay::LayoutViewBase *mp_view; + lay::LayoutView *mp_view; lay::RubberBox *mp_box; unsigned int m_color; unsigned int m_buttons; diff --git a/src/laybasic/laybasic/laySnap.cc b/src/laybasic/laybasic/laySnap.cc index c123da738..14b7d004b 100644 --- a/src/laybasic/laybasic/laySnap.cc +++ b/src/laybasic/laybasic/laySnap.cc @@ -23,7 +23,7 @@ #include "laySnap.h" -#include "layLayoutViewBase.h" +#include "layLayoutView.h" #include "dbEdge.h" @@ -282,7 +282,7 @@ public: * This will run the finder on the given view. * "search_range" is the search range in micron units. */ - void find (lay::LayoutViewBase *view, double search_range) + void find (lay::LayoutView *view, double search_range) { if (! view) { return; @@ -586,7 +586,7 @@ private: } void - do_find (lay::LayoutViewBase *view, int cv_index, const db::Cell &cell, unsigned int l, int min_level, int max_level, const db::CplxTrans &t) + do_find (lay::LayoutView *view, int cv_index, const db::Cell &cell, unsigned int l, int min_level, int max_level, const db::CplxTrans &t) { db::Box touch_box = t.inverted () * m_region; @@ -727,7 +727,7 @@ private: }; static PointSnapToObjectResult -do_obj_snap (lay::LayoutViewBase *view, const db::DPoint &pt, const db::DVector &grid, double snap_range, const std::vector &cutlines) +do_obj_snap (lay::LayoutView *view, const db::DPoint &pt, const db::DVector &grid, double snap_range, const std::vector &cutlines) { db::DPoint dp (pt); @@ -792,7 +792,7 @@ do_obj_snap (lay::LayoutViewBase *view, const db::DPoint &pt, const db::DVector } static TwoPointSnapToObjectResult -do_obj_snap2 (lay::LayoutViewBase *view, const db::DPoint &pt1, const db::DPoint &pt2, const db::DVector &grid, double min_search_range, double max_search_range, const std::vector &cutlines) +do_obj_snap2 (lay::LayoutView *view, const db::DPoint &pt1, const db::DPoint &pt2, const db::DVector &grid, double min_search_range, double max_search_range, const std::vector &cutlines) { db::DPoint dp1 (pt1); db::DPoint dp2 (pt2); @@ -915,13 +915,13 @@ make_cutlines (lay::angle_constraint_type snap_mode, const db::DPoint &p1, std:: } PointSnapToObjectResult -obj_snap (lay::LayoutViewBase *view, const db::DPoint &pt, const db::DVector &grid, double snap_range) +obj_snap (lay::LayoutView *view, const db::DPoint &pt, const db::DVector &grid, double snap_range) { return do_obj_snap (view, pt, grid, snap_range, std::vector ()); } PointSnapToObjectResult -obj_snap (lay::LayoutViewBase *view, const db::DPoint &p1, const db::DPoint &p2, const db::DVector &grid, lay::angle_constraint_type snap_mode, double snap_range) +obj_snap (lay::LayoutView *view, const db::DPoint &p1, const db::DPoint &p2, const db::DVector &grid, lay::angle_constraint_type snap_mode, double snap_range) { std::vector cutlines; make_cutlines (snap_mode, p1, cutlines); @@ -929,19 +929,19 @@ obj_snap (lay::LayoutViewBase *view, const db::DPoint &p1, const db::DPoint &p2, } TwoPointSnapToObjectResult -obj_snap2 (lay::LayoutViewBase *view, const db::DPoint &pt, const db::DVector &grid, double min_search_range, double max_search_range) +obj_snap2 (lay::LayoutView *view, const db::DPoint &pt, const db::DVector &grid, double min_search_range, double max_search_range) { return obj_snap2 (view, pt, pt, grid, min_search_range, max_search_range); } TwoPointSnapToObjectResult -obj_snap2 (lay::LayoutViewBase *view, const db::DPoint &pt, const db::DVector &grid, lay::angle_constraint_type ac, double min_search_range, double max_search_range) +obj_snap2 (lay::LayoutView *view, const db::DPoint &pt, const db::DVector &grid, lay::angle_constraint_type ac, double min_search_range, double max_search_range) { return obj_snap2 (view, pt, pt, grid, ac, min_search_range, max_search_range); } TwoPointSnapToObjectResult -obj_snap2 (lay::LayoutViewBase *view, const db::DPoint &pt1, const db::DPoint &pt2, const db::DVector &grid, double min_search_range, double max_search_range) +obj_snap2 (lay::LayoutView *view, const db::DPoint &pt1, const db::DPoint &pt2, const db::DVector &grid, double min_search_range, double max_search_range) { db::DPoint dp1 = lay::snap_xy (pt1, grid); db::DPoint dp2 = lay::snap_xy (pt2, grid); @@ -950,7 +950,7 @@ obj_snap2 (lay::LayoutViewBase *view, const db::DPoint &pt1, const db::DPoint &p } TwoPointSnapToObjectResult -obj_snap2 (lay::LayoutViewBase *view, const db::DPoint &pt1, const db::DPoint &pt2, const db::DVector &grid, lay::angle_constraint_type snap_mode, double min_search_range, double max_search_range) +obj_snap2 (lay::LayoutView *view, const db::DPoint &pt1, const db::DPoint &pt2, const db::DVector &grid, lay::angle_constraint_type snap_mode, double min_search_range, double max_search_range) { db::DPoint dp1 = lay::snap_xy (pt1, grid); db::DPoint dp2 = lay::snap_xy (pt2, grid); diff --git a/src/laybasic/laybasic/laySnap.h b/src/laybasic/laybasic/laySnap.h index 750ac55a8..19ebcc05c 100644 --- a/src/laybasic/laybasic/laySnap.h +++ b/src/laybasic/laybasic/laySnap.h @@ -41,7 +41,7 @@ namespace lay { - class LayoutViewBase; + class LayoutView; /** * @brief An angle constraint type @@ -154,7 +154,7 @@ namespace lay * @param grid Either (0,0) to disable grid snapping or a (gx,gy) value for the (potentially anisotropic grid) * @param snap_range The search range for objects */ - LAYBASIC_PUBLIC PointSnapToObjectResult obj_snap (lay::LayoutViewBase *view, const db::DPoint &pt, const db::DVector &grid, double snap_range); + LAYBASIC_PUBLIC PointSnapToObjectResult obj_snap (lay::LayoutView *view, const db::DPoint &pt, const db::DVector &grid, double snap_range); /** * @brief combined grid-, projection- and object snapping provided to implementing "magnetic features" @@ -162,7 +162,7 @@ namespace lay * This is a convenience method that creates the projection axes from a reference point and an angle mode. * "pr" is the reference point, "pt" is the point to snap. */ - LAYBASIC_PUBLIC PointSnapToObjectResult obj_snap (lay::LayoutViewBase *view, const db::DPoint &pr, const db::DPoint &pt, const db::DVector &grid, lay::angle_constraint_type ac, double snap_range); + LAYBASIC_PUBLIC PointSnapToObjectResult obj_snap (lay::LayoutView *view, const db::DPoint &pr, const db::DPoint &pt, const db::DVector &grid, lay::angle_constraint_type ac, double snap_range); /** * @brief A structure describing the snap result for a two-sided object snap (distance measurement) @@ -208,7 +208,7 @@ namespace lay * This method basically implements "auto measure". The first value of the returned pair * is true if such an edge could be found. Otherwise it's false. */ - LAYBASIC_PUBLIC TwoPointSnapToObjectResult obj_snap2 (lay::LayoutViewBase *view, const db::DPoint &pt, const db::DVector &grid, double min_search_range, double max_search_range); + LAYBASIC_PUBLIC TwoPointSnapToObjectResult obj_snap2 (lay::LayoutView *view, const db::DPoint &pt, const db::DVector &grid, double min_search_range, double max_search_range); /** * @brief Same than obj_snap, but delivers two points on two opposite sides of the initial points @@ -218,14 +218,14 @@ namespace lay * * This version accepts two points defining different search regions for first and second edge. */ - LAYBASIC_PUBLIC TwoPointSnapToObjectResult obj_snap2 (lay::LayoutViewBase *view, const db::DPoint &pt1, const db::DPoint &pt2, const db::DVector &grid, double min_search_range, double max_search_range); + LAYBASIC_PUBLIC TwoPointSnapToObjectResult obj_snap2 (lay::LayoutView *view, const db::DPoint &pt1, const db::DPoint &pt2, const db::DVector &grid, double min_search_range, double max_search_range); /** * @brief Same than the previous obj_snap2, but allows specification of an angle constraint * * Measurements will be confined to the direction specified. */ - LAYBASIC_PUBLIC TwoPointSnapToObjectResult obj_snap2 (lay::LayoutViewBase *view, const db::DPoint &pt, const db::DVector &grid, lay::angle_constraint_type ac, double min_search_range, double max_search_range); + LAYBASIC_PUBLIC TwoPointSnapToObjectResult obj_snap2 (lay::LayoutView *view, const db::DPoint &pt, const db::DVector &grid, lay::angle_constraint_type ac, double min_search_range, double max_search_range); /** * @brief Same than the previous obj_snap2, but allows specification of an angle constraint @@ -234,7 +234,7 @@ namespace lay * * This version accepts two points defining different search regions for first and second edge. */ - LAYBASIC_PUBLIC TwoPointSnapToObjectResult obj_snap2 (lay::LayoutViewBase *view, const db::DPoint &pt1, const db::DPoint &pt2, const db::DVector &grid, lay::angle_constraint_type ac, double min_search_range, double max_search_range); + LAYBASIC_PUBLIC TwoPointSnapToObjectResult obj_snap2 (lay::LayoutView *view, const db::DPoint &pt1, const db::DPoint &pt2, const db::DVector &grid, lay::angle_constraint_type ac, double min_search_range, double max_search_range); /** * @brief Reduce a given vector according to the angle constraint diff --git a/src/laybasic/laybasic/layZoomBox.cc b/src/laybasic/laybasic/layZoomBox.cc index 97f080aa5..bef7e40f2 100644 --- a/src/laybasic/laybasic/layZoomBox.cc +++ b/src/laybasic/laybasic/layZoomBox.cc @@ -31,7 +31,7 @@ namespace lay // ------------------------------------------------------------- // ZoomService implementation -ZoomService::ZoomService (lay::LayoutViewBase *view) +ZoomService::ZoomService (lay::LayoutView *view) : lay::ViewService (view->view_object_widget ()), mp_view (view), mp_box (0), diff --git a/src/laybasic/laybasic/layZoomBox.h b/src/laybasic/laybasic/layZoomBox.h index 7794c6473..a0a497a83 100644 --- a/src/laybasic/laybasic/layZoomBox.h +++ b/src/laybasic/laybasic/layZoomBox.h @@ -30,7 +30,7 @@ namespace lay { -class LayoutViewBase; +class LayoutView; class LayoutCanvas; class RubberBox; @@ -38,7 +38,7 @@ class LAYBASIC_PUBLIC ZoomService : public lay::ViewService { public: - ZoomService (lay::LayoutViewBase *view); + ZoomService (lay::LayoutView *view); ~ZoomService (); void set_colors (lay::Color background, lay::Color text); @@ -55,7 +55,7 @@ private: db::DPoint m_p1, m_p2; db::DBox m_vp; - lay::LayoutViewBase *mp_view; + lay::LayoutView *mp_view; lay::RubberBox *mp_box; unsigned int m_color; }; diff --git a/src/laybasic/laybasic/laybasic.pro b/src/laybasic/laybasic/laybasic.pro index 59c6456ac..53e543b71 100644 --- a/src/laybasic/laybasic/laybasic.pro +++ b/src/laybasic/laybasic/laybasic.pro @@ -84,11 +84,8 @@ DEFINES += MAKE_LAYBASIC_LIBRARY SOURCES = \ gsiDeclLayDialogs.cc \ - gsiDeclLayLayoutView.cc \ - gsiDeclLayMarker.cc \ gsiDeclLayMenu.cc \ gsiDeclLayNetlistBrowserDialog.cc \ - gsiDeclLayPlugin.cc \ gsiDeclLayStream.cc \ gtf.cc \ layAbstractMenu.cc \ @@ -105,7 +102,6 @@ DEFINES += MAKE_LAYBASIC_LIBRARY layBusy.cc \ layCellSelectionForm.cc \ layCellTreeModel.cc \ - layCellView.cc \ layConfigurationDialog.cc \ layConverters.cc \ layCursor.cc \ @@ -178,7 +174,6 @@ DEFINES += MAKE_LAYBASIC_LIBRARY layBusy.h \ layCellSelectionForm.h \ layCellTreeModel.h \ - layCellView.h \ layConfigurationDialog.h \ layConverters.h \ layColor.h \ @@ -240,9 +235,13 @@ DEFINES += MAKE_LAYBASIC_LIBRARY SOURCES += \ gsiDeclLayLayers.cc \ + gsiDeclLayLayoutView.cc \ + gsiDeclLayMarker.cc \ + gsiDeclLayPlugin.cc \ layAnnotationShapes.cc \ layBitmap.cc \ layBitmapRenderer.cc \ + layCellView.cc \ layColor.cc \ layColorPalette.cc \ layDispatcher.cc \ @@ -283,6 +282,7 @@ HEADERS += \ layAnnotationShapes.h \ layBitmap.h \ layBitmapRenderer.h \ + layCellView.h \ layColorPalette.h \ layDispatcher.h \ layDisplayState.h \ diff --git a/src/laybasic/laybasic/rdbMarkerBrowser.cc b/src/laybasic/laybasic/rdbMarkerBrowser.cc index 6311b0f1b..2a7e9928a 100644 --- a/src/laybasic/laybasic/rdbMarkerBrowser.cc +++ b/src/laybasic/laybasic/rdbMarkerBrowser.cc @@ -302,7 +302,7 @@ public: menu_entries.push_back (lay::menu_item ("marker_browser::scan_layers_flat", "scan_layers_flat", "tools_menu.shapes_to_markers.end", tl::to_string (QObject::tr ("Flat")))); } - virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutViewBase *view) const + virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutView *view) const { return new rdb::MarkerBrowserDialog (root, view); } diff --git a/src/laybasic/laybasic/rdbMarkerBrowserDialog.cc b/src/laybasic/laybasic/rdbMarkerBrowserDialog.cc index 51b93ae88..c85b40024 100644 --- a/src/laybasic/laybasic/rdbMarkerBrowserDialog.cc +++ b/src/laybasic/laybasic/rdbMarkerBrowserDialog.cc @@ -54,7 +54,7 @@ extern std::string cfg_rdb_marker_vertex_size; extern std::string cfg_rdb_marker_halo; extern std::string cfg_rdb_marker_dither_pattern; -MarkerBrowserDialog::MarkerBrowserDialog (lay::Dispatcher *root, lay::LayoutViewBase *vw) +MarkerBrowserDialog::MarkerBrowserDialog (lay::Dispatcher *root, lay::LayoutView *vw) : lay::Browser (root, vw), Ui::MarkerBrowserDialog (), m_context (rdb::AnyCell), @@ -806,7 +806,7 @@ MarkerBrowserDialog::scan_layer () } unsigned int rdb_index = view ()->add_rdb (rdb.release ()); - view ()->ui ()->open_rdb_browser (rdb_index, cv_index); + view ()->open_rdb_browser (rdb_index, cv_index); } void @@ -882,7 +882,7 @@ MarkerBrowserDialog::scan_layer_flat () } unsigned int rdb_index = view ()->add_rdb (rdb.release ()); - view ()->ui ()->open_rdb_browser (rdb_index, cv_index); + view ()->open_rdb_browser (rdb_index, cv_index); } void diff --git a/src/laybasic/laybasic/rdbMarkerBrowserDialog.h b/src/laybasic/laybasic/rdbMarkerBrowserDialog.h index 57836ca33..5e0bd782e 100644 --- a/src/laybasic/laybasic/rdbMarkerBrowserDialog.h +++ b/src/laybasic/laybasic/rdbMarkerBrowserDialog.h @@ -38,7 +38,7 @@ class MarkerBrowserDialog Q_OBJECT public: - MarkerBrowserDialog (lay::Dispatcher *root, lay::LayoutViewBase *view); + MarkerBrowserDialog (lay::Dispatcher *root, lay::LayoutView *view); ~MarkerBrowserDialog (); void load (int rdb_index, int cv_index); diff --git a/src/laybasic/laybasic/rdbMarkerBrowserPage.cc b/src/laybasic/laybasic/rdbMarkerBrowserPage.cc index 6560e3044..df28158db 100644 --- a/src/laybasic/laybasic/rdbMarkerBrowserPage.cc +++ b/src/laybasic/laybasic/rdbMarkerBrowserPage.cc @@ -1620,7 +1620,7 @@ MarkerBrowserPage::set_marker_style (lay::Color color, int line_width, int verte } void -MarkerBrowserPage::set_view (lay::LayoutViewBase *view, unsigned int cv_index) +MarkerBrowserPage::set_view (lay::LayoutView *view, unsigned int cv_index) { mp_view = view; m_cv_index = cv_index; diff --git a/src/laybasic/laybasic/rdbMarkerBrowserPage.h b/src/laybasic/laybasic/rdbMarkerBrowserPage.h index 6c7ab7820..f879884a6 100644 --- a/src/laybasic/laybasic/rdbMarkerBrowserPage.h +++ b/src/laybasic/laybasic/rdbMarkerBrowserPage.h @@ -78,7 +78,7 @@ public: * If that pointer is non-null, the browser will attach itself to * the view and provide highlights for the selected markers inside the given cellview. */ - void set_view (lay::LayoutViewBase *view, unsigned int cv_index); + void set_view (lay::LayoutView *view, unsigned int cv_index); /** * @brief Attach the page to a RDB @@ -184,7 +184,7 @@ private: rdb::Database *mp_database; bool m_show_all; QAction *m_show_all_action; - lay::LayoutViewBase *mp_view; + lay::LayoutView *mp_view; unsigned int m_cv_index; std::vector mp_markers; db::DBox m_markers_bbox; diff --git a/src/plugins/tools/bool/lay_plugin/layBooleanOperationsPlugin.cc b/src/plugins/tools/bool/lay_plugin/layBooleanOperationsPlugin.cc index af7c219bd..668f159e6 100644 --- a/src/plugins/tools/bool/lay_plugin/layBooleanOperationsPlugin.cc +++ b/src/plugins/tools/bool/lay_plugin/layBooleanOperationsPlugin.cc @@ -494,9 +494,9 @@ public: // .. nothing yet .. } - lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutViewBase *view) const + lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutView *view) const { - return new BooleanOperationsPlugin (root, view->ui ()); + return new BooleanOperationsPlugin (root, view); } }; diff --git a/src/plugins/tools/diff/lay_plugin/layDiffPlugin.cc b/src/plugins/tools/diff/lay_plugin/layDiffPlugin.cc index 8486c8155..986dbbf04 100644 --- a/src/plugins/tools/diff/lay_plugin/layDiffPlugin.cc +++ b/src/plugins/tools/diff/lay_plugin/layDiffPlugin.cc @@ -103,9 +103,9 @@ public: // .. nothing yet .. } - lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutViewBase *view) const + lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutView *view) const { - return new DiffPlugin (root, view->ui ()); + return new DiffPlugin (root, view); } }; diff --git a/src/plugins/tools/net_tracer/lay_plugin/layNetTracerPlugin.cc b/src/plugins/tools/net_tracer/lay_plugin/layNetTracerPlugin.cc index 27400f4dd..45b5cd290 100644 --- a/src/plugins/tools/net_tracer/lay_plugin/layNetTracerPlugin.cc +++ b/src/plugins/tools/net_tracer/lay_plugin/layNetTracerPlugin.cc @@ -76,9 +76,9 @@ public: menu_entries.push_back (lay::menu_item ("lay::edit_layer_stack", "edit_layer_stack", "tools_menu.end", tl::to_string (QObject::tr ("Edit Layer Stack")))); } - virtual lay::Plugin *create_plugin (db::Manager * /*manager*/, lay::Dispatcher *root, lay::LayoutViewBase *view) const + virtual lay::Plugin *create_plugin (db::Manager * /*manager*/, lay::Dispatcher *root, lay::LayoutView *view) const { - return new NetTracerDialog (root, view->ui ()); + return new NetTracerDialog (root, view); } }; diff --git a/src/plugins/tools/view_25d/lay_plugin/layD25Plugin.cc b/src/plugins/tools/view_25d/lay_plugin/layD25Plugin.cc index 4bb1601c8..c6830127c 100644 --- a/src/plugins/tools/view_25d/lay_plugin/layD25Plugin.cc +++ b/src/plugins/tools/view_25d/lay_plugin/layD25Plugin.cc @@ -67,7 +67,7 @@ public: // .. nothing yet .. } - lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutViewBase *view) const + lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutView *view) const { return new D25View (root, view); } diff --git a/src/plugins/tools/view_25d/lay_plugin/layD25View.cc b/src/plugins/tools/view_25d/lay_plugin/layD25View.cc index a00675974..f7f885da3 100644 --- a/src/plugins/tools/view_25d/lay_plugin/layD25View.cc +++ b/src/plugins/tools/view_25d/lay_plugin/layD25View.cc @@ -38,7 +38,7 @@ namespace lay const double initial_elevation = 15.0; -D25View::D25View (lay::Dispatcher *root, LayoutViewBase *view) +D25View::D25View (lay::Dispatcher *root, LayoutView *view) : lay::Browser (root, view, "d25_view"), dm_rerun_macro (this, &D25View::rerun_macro), dm_fit (this, &D25View::fit) diff --git a/src/plugins/tools/view_25d/lay_plugin/layD25View.h b/src/plugins/tools/view_25d/lay_plugin/layD25View.h index 6cc5cb269..724c14e25 100644 --- a/src/plugins/tools/view_25d/lay_plugin/layD25View.h +++ b/src/plugins/tools/view_25d/lay_plugin/layD25View.h @@ -57,7 +57,7 @@ class D25View Q_OBJECT public: - D25View (lay::Dispatcher *root, lay::LayoutViewBase *view); + D25View (lay::Dispatcher *root, lay::LayoutView *view); ~D25View (); virtual void menu_activated (const std::string &symbol); diff --git a/src/plugins/tools/view_25d/lay_plugin/layD25ViewWidget.cc b/src/plugins/tools/view_25d/lay_plugin/layD25ViewWidget.cc index 7be0f8c24..9fa1f77d6 100644 --- a/src/plugins/tools/view_25d/lay_plugin/layD25ViewWidget.cc +++ b/src/plugins/tools/view_25d/lay_plugin/layD25ViewWidget.cc @@ -711,7 +711,7 @@ D25ViewWidget::finish () } void -D25ViewWidget::attach_view (LayoutViewBase *view) +D25ViewWidget::attach_view (LayoutView *view) { mp_view = view; } diff --git a/src/plugins/tools/view_25d/lay_plugin/layD25ViewWidget.h b/src/plugins/tools/view_25d/lay_plugin/layD25ViewWidget.h index 180a9cb89..af5dd0a54 100644 --- a/src/plugins/tools/view_25d/lay_plugin/layD25ViewWidget.h +++ b/src/plugins/tools/view_25d/lay_plugin/layD25ViewWidget.h @@ -57,7 +57,7 @@ namespace tl namespace lay { -class LayoutViewBase; +class LayoutView; class LayerPropertiesNode; class D25ViewWidget; @@ -106,7 +106,7 @@ public: void mouseReleaseEvent (QMouseEvent *event); void mouseMoveEvent (QMouseEvent *event); - void attach_view(lay::LayoutViewBase *view); + void attach_view(lay::LayoutView *view); QVector3D hit_point_with_scene(const QVector3D &line_dir); void refresh (); @@ -187,7 +187,7 @@ private: double m_scale_factor; double m_vscale_factor; QVector3D m_displacement; - lay::LayoutViewBase *mp_view; + lay::LayoutView *mp_view; db::DBox m_bbox; double m_zmin, m_zmax; bool m_zset; diff --git a/src/plugins/tools/xor/lay_plugin/layXORPlugin.cc b/src/plugins/tools/xor/lay_plugin/layXORPlugin.cc index 262969a59..9e0416339 100644 --- a/src/plugins/tools/xor/lay_plugin/layXORPlugin.cc +++ b/src/plugins/tools/xor/lay_plugin/layXORPlugin.cc @@ -111,9 +111,9 @@ public: // .. nothing yet .. } - lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutViewBase *view) const + lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutView *view) const { - return new XORPlugin (root, view->ui ()); + return new XORPlugin (root, view); } }; From 0b48cb90200f5829b3a70ed8f7649d1cc944c62a Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Mon, 2 May 2022 00:02:47 +0200 Subject: [PATCH 16/88] WIP: added new lay::Image class --- src/laybasic/laybasic/layImage.cc | 201 +++++++++++++++++++++ src/laybasic/laybasic/layImage.h | 219 +++++++++++++++++++++++ src/laybasic/laybasic/laybasic.pro | 2 + src/laybasic/unit_tests/layImageTests.cc | 0 src/laybasic/unit_tests/unit_tests.pro | 5 +- src/tl/tl/tlCopyOnWrite.h | 16 ++ src/tl/unit_tests/unit_tests.pro | 10 +- 7 files changed, 446 insertions(+), 7 deletions(-) create mode 100644 src/laybasic/laybasic/layImage.cc create mode 100644 src/laybasic/laybasic/layImage.h create mode 100644 src/laybasic/unit_tests/layImageTests.cc diff --git a/src/laybasic/laybasic/layImage.cc b/src/laybasic/laybasic/layImage.cc new file mode 100644 index 000000000..95010135e --- /dev/null +++ b/src/laybasic/laybasic/layImage.cc @@ -0,0 +1,201 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 "layImage.h" +#include "tlAssert.h" + +namespace lay +{ + +Image::Image (unsigned int w, unsigned int h, lay::color_t *data) +{ + m_width = w; + m_height = h; + m_data.reset (new ImageData (data, w * h)); +} + +Image::Image (unsigned int w, unsigned int h, const lay::color_t *data, unsigned int stride) +{ + m_width = w; + m_height = h; + + lay::color_t *d = new color_t [w * h]; + + if (data) { + for (unsigned int i = 0; i < h; ++i) { + for (unsigned int i = 0; i < h; ++i) { + *d++ = *data++; + } + if (stride > w) { + data += stride - w; + } + } + } + + m_data.reset (new ImageData (d, w * h)); +} + +Image::Image () +{ + m_width = 0; + m_height = 0; +} + +Image::Image (const Image &other) +{ + operator= (other); +} + +Image::Image (Image &&other) +{ + swap (other); +} + +Image::~Image () +{ + // .. nothing yet .. +} + +Image & +Image::operator= (const Image &other) +{ + if (this != &other) { + m_width = other.m_width; + m_height = other.m_height; + m_data = other.m_data; + } + return *this; +} + +Image & +Image::operator= (Image &&other) +{ + if (this != &other) { + swap (other); + } + return *this; +} + +void +Image::swap (Image &other) +{ + if (this == &other) { + return; + } + + std::swap (m_width, other.m_width); + std::swap (m_height, other.m_height); + m_data.swap (other.m_data); +} + +void +Image::fill (lay::color_t c) +{ + color_t *d = data (); + for (unsigned int i = 0; i < m_height; ++i) { + for (unsigned int j = 0; j < m_width; ++j) { + *d++ = c; + } + } +} + +color_t * +Image::scan_line (unsigned int n) +{ + tl_assert (n < m_height); + return m_data->data () + n * m_width; +} + +const color_t * +Image::scan_line (unsigned int n) const +{ + tl_assert (n < m_height); + return m_data->data () + n * m_width; +} + +color_t * +Image::data () +{ + return m_data->data (); +} + +const color_t * +Image::data () const +{ + return m_data->data (); +} + +#if defined(HAVE_QT) +QImage +Image::to_image () const +{ + return QImage ((const uchar *) data (), m_width, m_height, QImage::Format_ARGB32); +} +#endif + +void +Image::patch (const Image &other) +{ + tl_assert (width () == other.width ()); + tl_assert (height () == other.height ()); + + const color_t *d = other.data (); + color_t *dd = data (); + for (unsigned int i = 0; i < m_height; ++i) { + for (unsigned int j = 0; j < m_width; ++j) { + color_t c = *d++; + if ((c & 0x80000000) != 0) { + *dd = c; + } + ++dd; + } + } +} + +Image +Image::diff (const Image &other) const +{ + tl_assert (width () == other.width ()); + tl_assert (height () == other.height ()); + + Image res (m_width, m_height); + + const color_t *d2 = other.data (); + const color_t *d1 = data (); + color_t *dd = res.data (); + + for (unsigned int i = 0; i < m_height; ++i) { + for (unsigned int j = 0; j < m_width; ++j) { + if (((*d1 ^ *d2) & 0xffffff) != 0) { + *dd++ = *d2 | 0xff000000; + } else { + *dd++ = 0; + } + ++d1; + ++d2; + } + } + + return res; +} + +} diff --git a/src/laybasic/laybasic/layImage.h b/src/laybasic/laybasic/layImage.h new file mode 100644 index 000000000..7816a5eee --- /dev/null +++ b/src/laybasic/laybasic/layImage.h @@ -0,0 +1,219 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 + +*/ + + +#ifndef HDR_layImage +#define HDR_layImage + +#include "laybasicCommon.h" +#include "layColor.h" +#include "tlCopyOnWrite.h" + +#include + +#if defined(HAVE_QT) +# include +#endif + +namespace lay +{ + +/** + * @brief An 32bit RGBA image class + * + * This class substitutes QImage in Qt-less applications. + * It provides 32bit RGBA pixels with the format used by lay::Color. + */ + +class LAYBASIC_PUBLIC Image +{ +public: + /** + * @brief Creates an image with the given height and width + * + * If data is given, the image is initialized with the given data and will take ownership over the + * data block. + * + * The size of the data block needs to be w*h elements. + */ + Image (unsigned int w, unsigned int h, lay::color_t *data); + + /** + * @brief Creates an image with the given height and width + * + * If data is given, the image is initialized with the given data. A copy of the data is created. + * + * "stride" specifies the stride (distance between two rows of data). + * The size of the data block needs to be stride*h elements or w*h if stride is not given. + */ + Image (unsigned int w, unsigned int h, const lay::color_t *data = 0, unsigned int stride = 0); + + /** + * @brief Default constructor + */ + Image (); + + /** + * @brief Copy constructor + */ + Image (const Image &other); + + /** + * @brief Move constructor + */ + Image (Image &&other); + + /** + * @brief Destructor + */ + ~Image (); + + /** + * @brief Assignment + */ + Image &operator= (const Image &other); + + /** + * @brief Move constructor + */ + Image &operator= (Image &&other); + + /** + * @brief Swaps this image with another one + */ + void swap (Image &other); + + /** + * @brief Gets the images width + */ + unsigned int width () const + { + return m_width; + } + + /** + * @brief Gets the images width + */ + unsigned int height () const + { + return m_height; + } + + /** + * @brief Fills the image with the given color + */ + void fill (lay::color_t); + + /** + * @brief Gets the scanline for row n + */ + color_t *scan_line (unsigned int n); + + /** + * @brief Gets the scanline for row n (const version) + */ + const color_t *scan_line (unsigned int n) const; + + /** + * @brief Gets the data pointer + */ + color_t *data (); + + /** + * @brief Gets the data pointer (const version) + */ + const color_t *data () const; + +#if defined(HAVE_QT) + /** + * @brief Produces a QImage object from the image + */ + QImage to_image () const; +#endif + + /** + * @brief Overlays the other image with this one + * + * This feature does not implement real alpha blending. Instead all + * pixels with an alpha value >= 128 from the other image are patched into this image. + */ + void patch (const Image &other); + + /** + * @brief Generates the image difference + * + * This feature produces a binary-alpha image of *this and other. The + * result can be patched into this image to render the same image than + * "other". + * + * alpha values from this and other are ignored. + */ + Image diff (const Image &other) const; + +private: + class ImageData + { + public: + ImageData () + : mp_data (0), m_length (0) + { + // .. nothing yet .. + } + + ImageData (lay::color_t *data, size_t length) + : mp_data (data), m_length (length) + { + // .. nothing yet .. + } + + ImageData (const ImageData &other) + { + m_length = other.length (); + mp_data = new lay::color_t [other.length ()]; + memcpy (mp_data, other.data (), m_length * sizeof (lay::color_t)); + } + + ~ImageData () + { + delete[] mp_data; + mp_data = 0; + } + + size_t length () const { return m_length; } + lay::color_t *data () { return mp_data; } + const lay::color_t *data () const { return mp_data; } + + private: + lay::color_t *mp_data; + size_t m_length; + size_t m_stride; + + ImageData &operator= (const ImageData &other); + }; + + unsigned int m_width, m_height; + tl::copy_on_write_ptr m_data; +}; + +} + +#endif diff --git a/src/laybasic/laybasic/laybasic.pro b/src/laybasic/laybasic/laybasic.pro index 53e543b71..e760d0d00 100644 --- a/src/laybasic/laybasic/laybasic.pro +++ b/src/laybasic/laybasic/laybasic.pro @@ -118,6 +118,7 @@ DEFINES += MAKE_LAYBASIC_LIBRARY layGenericSyntaxHighlighter.cc \ layGridNetConfigPage.cc \ layHierarchyControlPanel.cc \ + layImage.cc \ layIndexedNetlistModel.cc \ layItemDelegates.cc \ layLayerControlPanel.cc \ @@ -191,6 +192,7 @@ DEFINES += MAKE_LAYBASIC_LIBRARY layGenericSyntaxHighlighter.h \ layGridNetConfigPage.h \ layHierarchyControlPanel.h \ + layImage.h \ layIndexedNetlistModel.h \ layItemDelegates.h \ layLayerControlPanel.h \ diff --git a/src/laybasic/unit_tests/layImageTests.cc b/src/laybasic/unit_tests/layImageTests.cc new file mode 100644 index 000000000..e69de29bb diff --git a/src/laybasic/unit_tests/unit_tests.pro b/src/laybasic/unit_tests/unit_tests.pro index 0da4329f9..40db96675 100644 --- a/src/laybasic/unit_tests/unit_tests.pro +++ b/src/laybasic/unit_tests/unit_tests.pro @@ -10,13 +10,14 @@ SOURCES = \ layAnnotationShapes.cc \ layBitmap.cc \ layBitmapsToImage.cc \ + layImageTests.cc \ layColorTests.cc \ layLayerProperties.cc \ layParsedLayerSource.cc \ layRenderer.cc \ layNetlistBrowserModelTests.cc \ - layNetlistBrowserTreeModelTests.cc \ - layAbstractMenuTests.cc \ + layNetlistBrowserTreeModelTests.cc \ + layAbstractMenuTests.cc \ laySnapTests.cc INCLUDEPATH += $$TL_INC $$LAYBASIC_INC $$DB_INC $$GSI_INC $$OUT_PWD/../laybasic diff --git a/src/tl/tl/tlCopyOnWrite.h b/src/tl/tl/tlCopyOnWrite.h index 717688592..2dbbae8d1 100644 --- a/src/tl/tl/tlCopyOnWrite.h +++ b/src/tl/tl/tlCopyOnWrite.h @@ -143,6 +143,22 @@ public: release (); } + /** + * @brief Swaps two pointers + */ + void swap (copy_on_write_ptr &other) + { + if (this == &other) { + return; + } + + tl::MutexLocker locker1 (&ms_lock); + tl::MutexLocker locker2 (&other.ms_lock); + + std::swap (mp_x, other.mp_x); + std::swap (mp_holder, other.mp_holder); + } + /** * @brief Gets a writable object * This is when we will create a new copy if the object is shared. diff --git a/src/tl/unit_tests/unit_tests.pro b/src/tl/unit_tests/unit_tests.pro index 667e447bd..a0acbddb2 100644 --- a/src/tl/unit_tests/unit_tests.pro +++ b/src/tl/unit_tests/unit_tests.pro @@ -19,6 +19,7 @@ SOURCES = \ tlFileSystemWatcherTests.cc \ tlFileUtilsTests.cc \ tlHttpStreamTests.cc \ + tlImageTests.cc \ tlIncludeTests.cc \ tlInt128SupportTests.cc \ tlIntervalMapTests.cc \ @@ -36,11 +37,10 @@ SOURCES = \ tlUniqueIdTests.cc \ tlListTests.cc \ tlEquivalenceClustersTests.cc \ - tlUniqueNameTests.cc \ - tlGlobPatternTests.cc \ - tlRecipeTests.cc \ - tlUriTests.cc \ - tlUtilsTests.cc \ + tlUniqueNameTests.cc \ + tlGlobPatternTests.cc \ + tlRecipeTests.cc \ + tlUriTests.cc \ tlVariantTests.cc \ tlWebDAVTests.cc \ tlXMLParserTests.cc From 373f307ae6edbccd2183a934b409f7d2a3e20e9d Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Mon, 2 May 2022 00:26:13 +0200 Subject: [PATCH 17/88] WIP: image object, first steps --- src/laybasic/laybasic/layViewObject.h | 4 +- src/laybasic/unit_tests/layImageTests.cc | 92 ++++++++++++++++++++++++ src/tl/tl/tlCopyOnWrite.h | 4 +- src/tl/unit_tests/unit_tests.pro | 1 - 4 files changed, 95 insertions(+), 6 deletions(-) diff --git a/src/laybasic/laybasic/layViewObject.h b/src/laybasic/laybasic/layViewObject.h index fa0552136..38e84f5c1 100644 --- a/src/laybasic/laybasic/layViewObject.h +++ b/src/laybasic/laybasic/layViewObject.h @@ -1030,7 +1030,7 @@ public: } protected: -#if defined(HAVE_QT) +#if defined(HAVE_QT) // @@@ /** * @brief Qt focus event handler */ @@ -1101,7 +1101,7 @@ protected: void wheelEvent (QWheelEvent *e); #endif -#if !defined(HAVE_QT) +#if !defined(HAVE_QT) // @@@ void update (); #endif diff --git a/src/laybasic/unit_tests/layImageTests.cc b/src/laybasic/unit_tests/layImageTests.cc index e69de29bb..896116392 100644 --- a/src/laybasic/unit_tests/layImageTests.cc +++ b/src/laybasic/unit_tests/layImageTests.cc @@ -0,0 +1,92 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 "layImage.h" + +#include "tlUnitTest.h" + +#if defined(HAVE_QT) +#include +#endif + +TEST(1) +{ + lay::Image img (15, 25); + EXPECT_EQ (img.width (), 15); + EXPECT_EQ (img.height (), 25); + + img.fill (0x112233); + EXPECT_EQ (img.scan_line (5)[10], 0x112233); + + lay::Image img2; + img2 = img; + EXPECT_EQ (img2.width (), 15); + EXPECT_EQ (img2.height (), 25); + + EXPECT_EQ (img.scan_line (5)[10], 0x112233); + EXPECT_EQ (img2.scan_line (5)[10], 0x112233); + + img2.fill (0x332211); + EXPECT_EQ (img.scan_line (5)[10], 0x112233); + EXPECT_EQ (img2.scan_line (5)[10], 0x332211); + + img2.swap (img); + EXPECT_EQ (img2.scan_line (5)[10], 0x112233); + EXPECT_EQ (img.scan_line (5)[10], 0x332211); + + img2 = img; + EXPECT_EQ (img.scan_line (5)[10], 0x332211); + EXPECT_EQ (img2.scan_line (5)[10], 0x332211); + + img2 = lay::Image (10, 16); + EXPECT_EQ (img.width (), 15); + EXPECT_EQ (img.height (), 25); + EXPECT_EQ (img2.width (), 10); + EXPECT_EQ (img2.height (), 16); + img2.fill (0x010203); + + EXPECT_EQ (img.scan_line (5)[10], 0x332211); + EXPECT_EQ (img2.scan_line (5)[8], 0x010203); + + img = std::move (img2); + EXPECT_EQ (img.width (), 10); + EXPECT_EQ (img.height (), 16); + EXPECT_EQ (img.scan_line (5)[8], 0x010203); + + lay::Image img3 (img); + EXPECT_EQ (img3.width (), 10); + EXPECT_EQ (img3.height (), 16); + EXPECT_EQ (img3.scan_line (5)[8], 0x010203); + + img.fill (0x102030); + EXPECT_EQ (img3.width (), 10); + EXPECT_EQ (img3.height (), 16); + EXPECT_EQ (img3.scan_line (5)[8], 0x010203); + EXPECT_EQ (img.width (), 10); + EXPECT_EQ (img.height (), 16); + EXPECT_EQ (img.scan_line (5)[8], 0x102030); + + lay::Image img4 (std::move (img)); + EXPECT_EQ (img4.width (), 10); + EXPECT_EQ (img4.height (), 16); + EXPECT_EQ (img4.scan_line (5)[8], 0x102030); +} diff --git a/src/tl/tl/tlCopyOnWrite.h b/src/tl/tl/tlCopyOnWrite.h index 2dbbae8d1..54ef6dc47 100644 --- a/src/tl/tl/tlCopyOnWrite.h +++ b/src/tl/tl/tlCopyOnWrite.h @@ -152,9 +152,7 @@ public: return; } - tl::MutexLocker locker1 (&ms_lock); - tl::MutexLocker locker2 (&other.ms_lock); - + tl::MutexLocker locker (&ms_lock); std::swap (mp_x, other.mp_x); std::swap (mp_holder, other.mp_holder); } diff --git a/src/tl/unit_tests/unit_tests.pro b/src/tl/unit_tests/unit_tests.pro index a0acbddb2..768faad17 100644 --- a/src/tl/unit_tests/unit_tests.pro +++ b/src/tl/unit_tests/unit_tests.pro @@ -19,7 +19,6 @@ SOURCES = \ tlFileSystemWatcherTests.cc \ tlFileUtilsTests.cc \ tlHttpStreamTests.cc \ - tlImageTests.cc \ tlIncludeTests.cc \ tlInt128SupportTests.cc \ tlIntervalMapTests.cc \ From 3a2ae4ede1d7bb180bc312ddb8f3dd711ba12130 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Mon, 2 May 2022 01:02:46 +0200 Subject: [PATCH 18/88] WIP: More tests for lay::Image --- src/laybasic/laybasic/layImage.h | 3 +- src/laybasic/unit_tests/layImageTests.cc | 71 ++++++++++++++++++++++- testdata/lay/au.png | Bin 0 -> 777 bytes testdata/lay/au_diff.png | Bin 0 -> 789 bytes 4 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 testdata/lay/au.png create mode 100644 testdata/lay/au_diff.png diff --git a/src/laybasic/laybasic/layImage.h b/src/laybasic/laybasic/layImage.h index 7816a5eee..bc0a868f5 100644 --- a/src/laybasic/laybasic/layImage.h +++ b/src/laybasic/laybasic/layImage.h @@ -163,7 +163,8 @@ public: * * This feature produces a binary-alpha image of *this and other. The * result can be patched into this image to render the same image than - * "other". + * "other". The difference image will contains the pixels from other which + * are different from *this. * * alpha values from this and other are ignored. */ diff --git a/src/laybasic/unit_tests/layImageTests.cc b/src/laybasic/unit_tests/layImageTests.cc index 896116392..5e02999ed 100644 --- a/src/laybasic/unit_tests/layImageTests.cc +++ b/src/laybasic/unit_tests/layImageTests.cc @@ -25,7 +25,28 @@ #include "tlUnitTest.h" #if defined(HAVE_QT) -#include + +# include + +static bool compare_images (const QImage &qimg, const std::string &au) +{ + QImage qimg2; + qimg2.load (tl::to_qstring (au)); + + if (qimg2.width () == (int) qimg.width () && qimg2.height () == (int) qimg.height ()) { + for (int i = 0; i < qimg.width (); ++i) { + for (int j = 0; j < qimg.height (); ++j) { + if (((const lay::color_t *) qimg.scanLine (j))[i] != ((const lay::color_t *) qimg2.scanLine (j))[i]) { + return false; + } + } + } + return true; + } else { + return false; + } +} + #endif TEST(1) @@ -90,3 +111,51 @@ TEST(1) EXPECT_EQ (img4.height (), 16); EXPECT_EQ (img4.scan_line (5)[8], 0x102030); } + +#if defined(HAVE_QT) + +TEST(2) +{ + lay::Image img (227, 231); + + for (unsigned int i = 0; i < img.width (); ++i) { + for (unsigned int j = 0; j < img.height (); ++j) { + img.scan_line (j) [i] = 0xff000000 | (i << 16) | j; + } + } + + std::string tmp = tmp_file ("test.png"); + QImage qimg = img.to_image (); + qimg.save (tl::to_qstring (tmp)); + tl::info << "PNG file written to " << tmp; + + std::string au = tl::testsrc () + "/testdata/lay/au.png"; + tl::info << "PNG file read from " << au; + + EXPECT_EQ (compare_images (qimg, au), true); + + lay::Image img_saved (img); + img.scan_line (52) [42] = 0xff000000; + + lay::Image diff = img.diff (img_saved); + EXPECT_EQ (compare_images (img.to_image (), au), false); + EXPECT_EQ (compare_images (img_saved.to_image (), au), true); + + img.patch (diff); + EXPECT_EQ (compare_images (img.to_image (), au), true); + + img.fill (0xff000000); + img.patch (diff); + + tmp = tmp_file ("diff.png"); + qimg = img.to_image (); + qimg.save (tl::to_qstring (tmp)); + tl::info << "PNG file written to " << tmp; + + au = tl::testsrc () + "/testdata/lay/au_diff.png"; + tl::info << "PNG file read from " << au; + + EXPECT_EQ (compare_images (qimg, au), true); +} + +#endif diff --git a/testdata/lay/au.png b/testdata/lay/au.png new file mode 100644 index 0000000000000000000000000000000000000000..bc4c91684efb321915f281edf82db931084f3f7b GIT binary patch literal 777 zcmeAS@N?(olHy`uVBq!ia0vp^kAe6(2OE%lBmXc8NO2Z;L>4nJ@ErkR#;MwT(hLkt zyFFbTLn`LHy?l`KfB^%uA^WcXr`|4hej+C%;a`w`yL#Kqn|E#hGj8t`R64>TnAE~y w=+q*i=+q;i=++^i?9wqRJQ^kglOP^3bMdkz8g%lD0Mj;ur>mdKI;Vst0FE=x_5c6? literal 0 HcmV?d00001 diff --git a/testdata/lay/au_diff.png b/testdata/lay/au_diff.png new file mode 100644 index 0000000000000000000000000000000000000000..f29dacca61cec48e01a6a80d86d09c819f01b97c GIT binary patch literal 789 zcmeAS@N?(olHy`uVBq!ia0vp^kAe6(2OE%lBmXc8NO2Z;L>4nJ@ErkR#;MwT(hLkt z$30yfLn`LHy=utY5Fo;GkiBTd$9!HclL`ALNU~nf$(ubhyW#1#tIQ4U5{gbe0*Y=O z0?IBOf=Wj?1e01g44qmAO8DbUiGIs)|Az2f Date: Mon, 2 May 2022 22:27:30 +0200 Subject: [PATCH 19/88] Added performance tests for image --- src/laybasic/unit_tests/layImageTests.cc | 88 ++++++++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/src/laybasic/unit_tests/layImageTests.cc b/src/laybasic/unit_tests/layImageTests.cc index 5e02999ed..91e61fd00 100644 --- a/src/laybasic/unit_tests/layImageTests.cc +++ b/src/laybasic/unit_tests/layImageTests.cc @@ -23,10 +23,12 @@ #include "layImage.h" #include "tlUnitTest.h" +#include "tlTimer.h" #if defined(HAVE_QT) # include +# include static bool compare_images (const QImage &qimg, const std::string &au) { @@ -159,3 +161,89 @@ TEST(2) } #endif + +TEST(3) +{ + { + tl::SelfTimer timer ("Run time - lay::Image copy, no write (should be very fast)"); + + lay::Image img (1000, 1000); + img.fill (0x112233); + + for (unsigned int i = 0; i < 5000; ++i) { + lay::Image img2 (img); + } + } + +#if defined(HAVE_QT) + { + tl::SelfTimer timer ("Run time - QImage copy, no write (should be very fast)"); + + lay::Image img (1000, 1000); + img.fill (0x112233); + QImage qimg (img.to_image ()); + + for (unsigned int i = 0; i < 5000; ++i) { + QImage qimg2 (qimg); + } + } +#endif + + { + tl::SelfTimer timer ("Run time - lay::Image copy on write"); + + lay::Image img (1000, 1000); + img.fill (0x112233); + + for (unsigned int i = 0; i < 5000; ++i) { + lay::Image img2 (img); + img2.scan_line (100) [7] = 0; + } + } + +#if defined(HAVE_QT) + { + tl::SelfTimer timer ("Run time - QImage copy on write (should not be much less than lay::Image copy on write)"); + + lay::Image img (1000, 1000); + img.fill (0x112233); + QImage qimg (img.to_image ()); + + for (unsigned int i = 0; i < 5000; ++i) { + QImage qimg2 (qimg); + qimg2.scanLine (100) [7] = 0; + } + } + + { + tl::SelfTimer timer ("Run time - direct QImage paint"); + + lay::Image img (1000, 1000); + img.fill (0x112233); + QImage qimg (img.to_image ()); + QImage qrec (img.to_image ()); + qrec.fill (0); + + QPainter painter (&qrec); + for (unsigned int i = 0; i < 1000; ++i) { + painter.drawImage (QPoint (0, 0), qimg); + } + } + + { + tl::SelfTimer timer ("Run time - lay::Image paint (should not be much more than direct QImage paint)"); + + lay::Image img (1000, 1000); + img.fill (0x112233); + QImage qrec (img.to_image ()); + qrec.fill (0); + + QPainter painter (&qrec); + for (unsigned int i = 0; i < 1000; ++i) { + painter.drawImage (QPoint (0, 0), img.to_image ()); + } + } + +#endif +} + From 1cdc26b13727394adc4fdcd728d5d5cf0541ed85 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Mon, 2 May 2022 22:46:56 +0200 Subject: [PATCH 20/88] Added transparent flag for lay::Image --- src/laybasic/laybasic/layImage.cc | 15 ++++++++++++++- src/laybasic/laybasic/layImage.h | 15 ++++++++++++++- src/laybasic/unit_tests/layImageTests.cc | 8 ++++++++ 3 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/laybasic/laybasic/layImage.cc b/src/laybasic/laybasic/layImage.cc index 95010135e..1b49d6782 100644 --- a/src/laybasic/laybasic/layImage.cc +++ b/src/laybasic/laybasic/layImage.cc @@ -30,6 +30,7 @@ Image::Image (unsigned int w, unsigned int h, lay::color_t *data) { m_width = w; m_height = h; + m_transparent = false; m_data.reset (new ImageData (data, w * h)); } @@ -37,6 +38,7 @@ Image::Image (unsigned int w, unsigned int h, const lay::color_t *data, unsigned { m_width = w; m_height = h; + m_transparent = false; lay::color_t *d = new color_t [w * h]; @@ -58,6 +60,7 @@ Image::Image () { m_width = 0; m_height = 0; + m_transparent = false; } Image::Image (const Image &other) @@ -82,6 +85,7 @@ Image::operator= (const Image &other) m_width = other.m_width; m_height = other.m_height; m_data = other.m_data; + m_transparent = other.m_transparent; } return *this; } @@ -95,6 +99,12 @@ Image::operator= (Image &&other) return *this; } +void +Image::set_transparent (bool f) +{ + m_transparent = f; +} + void Image::swap (Image &other) { @@ -104,6 +114,7 @@ Image::swap (Image &other) std::swap (m_width, other.m_width); std::swap (m_height, other.m_height); + std::swap (m_transparent, other.m_transparent); m_data.swap (other.m_data); } @@ -148,7 +159,7 @@ Image::data () const QImage Image::to_image () const { - return QImage ((const uchar *) data (), m_width, m_height, QImage::Format_ARGB32); + return QImage ((const uchar *) data (), m_width, m_height, m_transparent ? QImage::Format_ARGB32 : QImage::Format_RGB32); } #endif @@ -157,6 +168,7 @@ Image::patch (const Image &other) { tl_assert (width () == other.width ()); tl_assert (height () == other.height ()); + tl_assert (other.transparent ()); const color_t *d = other.data (); color_t *dd = data (); @@ -178,6 +190,7 @@ Image::diff (const Image &other) const tl_assert (height () == other.height ()); Image res (m_width, m_height); + res.set_transparent (true); const color_t *d2 = other.data (); const color_t *d1 = data (); diff --git a/src/laybasic/laybasic/layImage.h b/src/laybasic/laybasic/layImage.h index bc0a868f5..020da278a 100644 --- a/src/laybasic/laybasic/layImage.h +++ b/src/laybasic/laybasic/layImage.h @@ -97,6 +97,19 @@ public: */ Image &operator= (Image &&other); + /** + * @brief Sets a value indicating whether an alpha channel is present + */ + void set_transparent (bool f); + + /** + * @brief Gets a value indicating whether an alpha channel is present + */ + bool transparent () const + { + return m_transparent; + } + /** * @brief Swaps this image with another one */ @@ -206,12 +219,12 @@ private: private: lay::color_t *mp_data; size_t m_length; - size_t m_stride; ImageData &operator= (const ImageData &other); }; unsigned int m_width, m_height; + bool m_transparent; tl::copy_on_write_ptr m_data; }; diff --git a/src/laybasic/unit_tests/layImageTests.cc b/src/laybasic/unit_tests/layImageTests.cc index 91e61fd00..53fb76e98 100644 --- a/src/laybasic/unit_tests/layImageTests.cc +++ b/src/laybasic/unit_tests/layImageTests.cc @@ -57,11 +57,17 @@ TEST(1) EXPECT_EQ (img.width (), 15); EXPECT_EQ (img.height (), 25); + EXPECT_EQ (img.transparent (), false); + img.set_transparent (true); + EXPECT_EQ (img.transparent (), true); + img.fill (0x112233); EXPECT_EQ (img.scan_line (5)[10], 0x112233); lay::Image img2; + EXPECT_EQ (img2.transparent (), false); img2 = img; + EXPECT_EQ (img2.transparent (), true); EXPECT_EQ (img2.width (), 15); EXPECT_EQ (img2.height (), 25); @@ -72,7 +78,9 @@ TEST(1) EXPECT_EQ (img.scan_line (5)[10], 0x112233); EXPECT_EQ (img2.scan_line (5)[10], 0x332211); + img.set_transparent (false); img2.swap (img); + EXPECT_EQ (img2.transparent (), false); EXPECT_EQ (img2.scan_line (5)[10], 0x112233); EXPECT_EQ (img.scan_line (5)[10], 0x332211); From 20888811100bc047eee7b1c768578abc32ec4c04 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Mon, 2 May 2022 22:48:32 +0200 Subject: [PATCH 21/88] Added transparent flag tests --- src/laybasic/unit_tests/layImageTests.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/laybasic/unit_tests/layImageTests.cc b/src/laybasic/unit_tests/layImageTests.cc index 53fb76e98..304e62e5a 100644 --- a/src/laybasic/unit_tests/layImageTests.cc +++ b/src/laybasic/unit_tests/layImageTests.cc @@ -134,6 +134,9 @@ TEST(2) } } + EXPECT_EQ (img.transparent (), false); + EXPECT_EQ (img.to_image ().format () == QImage::Format_RGB32, true); + std::string tmp = tmp_file ("test.png"); QImage qimg = img.to_image (); qimg.save (tl::to_qstring (tmp)); @@ -148,6 +151,8 @@ TEST(2) img.scan_line (52) [42] = 0xff000000; lay::Image diff = img.diff (img_saved); + EXPECT_EQ (diff.transparent (), true); + EXPECT_EQ (diff.to_image ().format () == QImage::Format_ARGB32, true); EXPECT_EQ (compare_images (img.to_image (), au), false); EXPECT_EQ (compare_images (img_saved.to_image (), au), true); From 17cbcc2877496effb069457b26444e9c95a5dec8 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Wed, 4 May 2022 02:18:01 +0200 Subject: [PATCH 22/88] Added mono image class --- src/db/db/dbStreamLayers.h | 16 +-- src/laybasic/laybasic/layImage.cc | 161 ++++++++++++++++++++- src/laybasic/laybasic/layImage.h | 176 ++++++++++++++++++++++- src/laybasic/unit_tests/layImageTests.cc | 175 +++++++++++++++++++++- src/tl/tl/tlCopyOnWrite.h | 2 - testdata/lay/au_mono.png | Bin 0 -> 6520 bytes 6 files changed, 514 insertions(+), 16 deletions(-) create mode 100644 testdata/lay/au_mono.png diff --git a/src/db/db/dbStreamLayers.h b/src/db/db/dbStreamLayers.h index 6baf6ef36..3ee89a468 100644 --- a/src/db/db/dbStreamLayers.h +++ b/src/db/db/dbStreamLayers.h @@ -201,6 +201,8 @@ public: /** * @brief Returns the first logical layer for a given layer specification + * The first value of the pair indicates whether there is a valid mapping. + * The second value will give the layer to map to. */ template std::pair first_logical (const L &p) const @@ -215,6 +217,8 @@ public: /** * @brief Returns the first logical layer for a given layer specification + * The first value of the pair indicates whether there is a valid mapping. + * The second value will give the layer to map to. */ template std::pair first_logical (const L &p, db::Layout &layout) const @@ -230,24 +234,21 @@ public: /** * @brief Query a layer mapping * - * @return A pair telling if the layer is mapped (first=true) and - * the logical layer mapped (second) if this is the case. + * @return A set of layers which are designated targets. */ std::set logical (const LDPair &p) const; /** * @brief Query a layer mapping from a name * - * @return A pair telling if the layer is mapped (first=true) and - * the logical layer mapped (second) if this is the case. + * @return A set of layers which are designated targets. */ std::set logical (const std::string &name) const; /** * @brief Query a layer mapping from a name or LDPair * - * @return A pair telling if the layer is mapped (first=true) and - * the logical layer mapped (second) if this is the case. + * @return A set of layers which are designated targets. * * @param p The layer that is looked for */ @@ -256,8 +257,7 @@ public: /** * @brief Query or install a layer mapping from a name or LDPair * - * @return A pair telling if the layer is mapped (first=true) and - * the logical layer mapped (second) if this is the case. + * @return A set of layers which are designated targets. * * @param p The layer that is looked for * diff --git a/src/laybasic/laybasic/layImage.cc b/src/laybasic/laybasic/layImage.cc index 1b49d6782..49575c8cd 100644 --- a/src/laybasic/laybasic/layImage.cc +++ b/src/laybasic/laybasic/layImage.cc @@ -26,7 +26,11 @@ namespace lay { +// ----------------------------------------------------------------------------------------------------- +// Image implementation + Image::Image (unsigned int w, unsigned int h, lay::color_t *data) + : m_data () { m_width = w; m_height = h; @@ -35,16 +39,21 @@ Image::Image (unsigned int w, unsigned int h, lay::color_t *data) } Image::Image (unsigned int w, unsigned int h, const lay::color_t *data, unsigned int stride) + : m_data () { m_width = w; m_height = h; m_transparent = false; - lay::color_t *d = new color_t [w * h]; + tl_assert ((stride % sizeof (lay::color_t)) == 0); + stride /= sizeof (lay::color_t); + + lay::color_t *d = new lay::color_t [w * h]; + lay::color_t *new_data = d; if (data) { for (unsigned int i = 0; i < h; ++i) { - for (unsigned int i = 0; i < h; ++i) { + for (unsigned int j = 0; j < w; ++j) { *d++ = *data++; } if (stride > w) { @@ -53,7 +62,7 @@ Image::Image (unsigned int w, unsigned int h, const lay::color_t *data, unsigned } } - m_data.reset (new ImageData (d, w * h)); + m_data.reset (new ImageData (new_data, w * h)); } Image::Image () @@ -211,4 +220,150 @@ Image::diff (const Image &other) const return res; } +// ----------------------------------------------------------------------------------------------------- +// MonoImage implementation + +static unsigned int +stride_from_width (unsigned int w) +{ + // Qt needs 32bit-aligned data + return 4 * ((w + 31) / 32); +} + +MonoImage::MonoImage (unsigned int w, unsigned int h, uint8_t *data) +{ + m_width = w; + m_height = h; + m_stride = stride_from_width (w); + m_data.reset (new MonoImageData (data, m_stride * h)); +} + +MonoImage::MonoImage (unsigned int w, unsigned int h, const uint8_t *data, unsigned int stride) +{ + m_width = w; + m_height = h; + m_stride = stride_from_width (w); + + uint8_t *d = new uint8_t [m_stride * h]; + uint8_t *new_data = d; + + if (data) { + for (unsigned int i = 0; i < h; ++i) { + memcpy (d, data, m_stride); + d += m_stride; + data += m_stride; + if (stride > m_stride) { + data += stride - m_stride; + } + } + } + + m_data.reset (new MonoImageData (new_data, m_stride * h)); +} + +MonoImage::MonoImage () +{ + m_width = 0; + m_height = 0; + m_stride = 0; +} + +MonoImage::MonoImage (const MonoImage &other) +{ + operator= (other); +} + +MonoImage::MonoImage (MonoImage &&other) +{ + swap (other); +} + +MonoImage::~MonoImage () +{ + // .. nothing yet .. +} + +MonoImage & +MonoImage::operator= (const MonoImage &other) +{ + if (this != &other) { + m_width = other.m_width; + m_height = other.m_height; + m_stride = other.m_stride; + m_data = other.m_data; + } + return *this; +} + +MonoImage & +MonoImage::operator= (MonoImage &&other) +{ + if (this != &other) { + swap (other); + } + return *this; +} + +void +MonoImage::swap (MonoImage &other) +{ + if (this == &other) { + return; + } + + std::swap (m_width, other.m_width); + std::swap (m_height, other.m_height); + std::swap (m_stride, other.m_stride); + m_data.swap (other.m_data); +} + +void +MonoImage::fill (bool value) +{ + uint8_t c = value ? 0xff : 0; + uint8_t *d = data (); + for (unsigned int i = 0; i < m_height; ++i) { + for (unsigned int j = 0; j < m_stride; ++j) { + *d++ = c; + } + } +} + +uint8_t * +MonoImage::scan_line (unsigned int n) +{ + tl_assert (n < m_height); + return m_data->data () + n * m_stride; +} + +const uint8_t * +MonoImage::scan_line (unsigned int n) const +{ + tl_assert (n < m_height); + return m_data->data () + n * m_stride; +} + +uint8_t * +MonoImage::data () +{ + return m_data->data (); +} + +const uint8_t * +MonoImage::data () const +{ + return m_data->data (); +} + +#if defined(HAVE_QT) +QImage +MonoImage::to_image () const +{ + QImage img = QImage ((const uchar *) data (), m_width, m_height, QImage::Format_MonoLSB); + img.setColor (0, 0xff000000); + img.setColor (1, 0xffffffff); + return img; +} +#endif + } diff --git a/src/laybasic/laybasic/layImage.h b/src/laybasic/laybasic/layImage.h index 020da278a..da1476bcf 100644 --- a/src/laybasic/laybasic/layImage.h +++ b/src/laybasic/laybasic/layImage.h @@ -29,6 +29,7 @@ #include "tlCopyOnWrite.h" #include +#include #if defined(HAVE_QT) # include @@ -38,7 +39,7 @@ namespace lay { /** - * @brief An 32bit RGBA image class + * @brief An 32bit RGB/RGBA image class * * This class substitutes QImage in Qt-less applications. * It provides 32bit RGBA pixels with the format used by lay::Color. @@ -131,6 +132,14 @@ public: return m_height; } + /** + * @brief Gets the image stride (number of bytes per row) + */ + unsigned int stride () const + { + return sizeof (lay::color_t) * m_width; + } + /** * @brief Fills the image with the given color */ @@ -228,6 +237,171 @@ private: tl::copy_on_write_ptr m_data; }; +/** + * @brief An monochrome image class + * + * This class substitutes QImage for monochrome images in Qt-less applications. + */ + +class LAYBASIC_PUBLIC MonoImage +{ +public: + /** + * @brief Creates an image with the given height and width + * + * If data is given, the image is initialized with the given data and will take ownership over the + * data block. + * + * Lines are byte-aligned. + */ + MonoImage (unsigned int w, unsigned int h, uint8_t *data); + + /** + * @brief Creates an image with the given height and width + * + * If data is given, the image is initialized with the given data. A copy of the data is created. + * + * "stride" specifies the stride (distance in bytes between two rows of data). + * The size of the data block needs to be stride*h elements or bytes(w)*h if stride is not given. + */ + MonoImage (unsigned int w, unsigned int h, const uint8_t *data = 0, unsigned int stride = 0); + + /** + * @brief Default constructor + */ + MonoImage (); + + /** + * @brief Copy constructor + */ + MonoImage (const MonoImage &other); + + /** + * @brief Move constructor + */ + MonoImage (MonoImage &&other); + + /** + * @brief Destructor + */ + ~MonoImage (); + + /** + * @brief Assignment + */ + MonoImage &operator= (const MonoImage &other); + + /** + * @brief Move constructor + */ + MonoImage &operator= (MonoImage &&other); + + /** + * @brief Swaps this image with another one + */ + void swap (MonoImage &other); + + /** + * @brief Gets the images width + */ + unsigned int width () const + { + return m_width; + } + + /** + * @brief Gets the images width + */ + unsigned int height () const + { + return m_height; + } + + /** + * @brief Gets the image stride (number of bytes per row) + */ + unsigned int stride () const + { + return m_stride; + } + + /** + * @brief Fills the image with the given color + */ + void fill (bool value); + + /** + * @brief Gets the scanline for row n + */ + uint8_t *scan_line (unsigned int n); + + /** + * @brief Gets the scanline for row n (const version) + */ + const uint8_t *scan_line (unsigned int n) const; + + /** + * @brief Gets the data pointer + */ + uint8_t *data (); + + /** + * @brief Gets the data pointer (const version) + */ + const uint8_t *data () const; + +#if defined(HAVE_QT) + /** + * @brief Produces a QMonoImage object from the image + */ + QImage to_image () const; +#endif + +private: + class MonoImageData + { + public: + MonoImageData () + : mp_data (0), m_length (0) + { + // .. nothing yet .. + } + + MonoImageData (uint8_t *data, size_t length) + : mp_data (data), m_length (length) + { + // .. nothing yet .. + } + + MonoImageData (const MonoImageData &other) + { + m_length = other.length (); + mp_data = new uint8_t [other.length ()]; + memcpy (mp_data, other.data (), m_length * sizeof (uint8_t)); + } + + ~MonoImageData () + { + delete[] mp_data; + mp_data = 0; + } + + size_t length () const { return m_length; } + uint8_t *data () { return mp_data; } + const uint8_t *data () const { return mp_data; } + + private: + uint8_t *mp_data; + size_t m_length; + + MonoImageData &operator= (const MonoImageData &other); + }; + + unsigned int m_width, m_height; + unsigned int m_stride; + tl::copy_on_write_ptr m_data; +}; + } #endif diff --git a/src/laybasic/unit_tests/layImageTests.cc b/src/laybasic/unit_tests/layImageTests.cc index 304e62e5a..d680feaed 100644 --- a/src/laybasic/unit_tests/layImageTests.cc +++ b/src/laybasic/unit_tests/layImageTests.cc @@ -36,8 +36,8 @@ static bool compare_images (const QImage &qimg, const std::string &au) qimg2.load (tl::to_qstring (au)); if (qimg2.width () == (int) qimg.width () && qimg2.height () == (int) qimg.height ()) { - for (int i = 0; i < qimg.width (); ++i) { - for (int j = 0; j < qimg.height (); ++j) { + for (int j = 0; j < qimg.height (); ++j) { + for (int i = 0; i < qimg.width (); ++i) { if (((const lay::color_t *) qimg.scanLine (j))[i] != ((const lay::color_t *) qimg2.scanLine (j))[i]) { return false; } @@ -49,6 +49,58 @@ static bool compare_images (const QImage &qimg, const std::string &au) } } +static bool compare_images_mono (const QImage &qimg, const std::string &au) +{ + QImage qimg2; + qimg2.load (tl::to_qstring (au)); + + if (qimg2.width () == (int) qimg.width () && qimg2.height () == (int) qimg.height ()) { + // NOTE: slooooow ... + for (int j = 0; j < qimg.height (); ++j) { + for (int i = 0; i < qimg.width (); ++i) { + if ((qimg.scanLine (j)[i / 8] & (0x80 >> (i % 8))) != (qimg2.scanLine (j)[i / 8] & (0x80 >> (i % 8)))) { + return false; + } + } + } + return true; + } else { + return false; + } +} + +static bool compare_images (const lay::Image &img, const lay::Image &img2) +{ + if (img2.width () == img.width () && img2.height () == img.height ()) { + for (unsigned int j = 0; j < img.height (); ++j) { + for (unsigned int i = 0; i < img.width (); ++i) { + if (((const lay::color_t *) img.scan_line (j))[i] != ((const lay::color_t *) img2.scan_line (j))[i]) { + return false; + } + } + } + return true; + } else { + return false; + } +} + +static bool compare_images (const lay::MonoImage &img, const lay::MonoImage &img2) +{ + if (img2.width () == img.width () && img2.height () == img.height ()) { + for (unsigned int j = 0; j < img.height (); ++j) { + for (unsigned int i = 0; i < img.stride (); ++i) { + if (((const uint8_t *) img.scan_line (j))[i] != ((const uint8_t *) img2.scan_line (j))[i]) { + return false; + } + } + } + return true; + } else { + return false; + } +} + #endif TEST(1) @@ -56,6 +108,7 @@ TEST(1) lay::Image img (15, 25); EXPECT_EQ (img.width (), 15); EXPECT_EQ (img.height (), 25); + EXPECT_EQ (img.stride (), 15 * sizeof (lay::color_t)); EXPECT_EQ (img.transparent (), false); img.set_transparent (true); @@ -85,6 +138,7 @@ TEST(1) EXPECT_EQ (img.scan_line (5)[10], 0x332211); img2 = img; + EXPECT_EQ (compare_images (img, img2), true); EXPECT_EQ (img.scan_line (5)[10], 0x332211); EXPECT_EQ (img2.scan_line (5)[10], 0x332211); @@ -94,21 +148,25 @@ TEST(1) EXPECT_EQ (img2.width (), 10); EXPECT_EQ (img2.height (), 16); img2.fill (0x010203); + EXPECT_EQ (compare_images (img, img2), false); EXPECT_EQ (img.scan_line (5)[10], 0x332211); EXPECT_EQ (img2.scan_line (5)[8], 0x010203); img = std::move (img2); + EXPECT_EQ (compare_images (img, img2), false); EXPECT_EQ (img.width (), 10); EXPECT_EQ (img.height (), 16); EXPECT_EQ (img.scan_line (5)[8], 0x010203); lay::Image img3 (img); + EXPECT_EQ (compare_images (img, img3), true); EXPECT_EQ (img3.width (), 10); EXPECT_EQ (img3.height (), 16); EXPECT_EQ (img3.scan_line (5)[8], 0x010203); img.fill (0x102030); + EXPECT_EQ (compare_images (img, img3), false); EXPECT_EQ (img3.width (), 10); EXPECT_EQ (img3.height (), 16); EXPECT_EQ (img3.scan_line (5)[8], 0x010203); @@ -120,6 +178,14 @@ TEST(1) EXPECT_EQ (img4.width (), 10); EXPECT_EQ (img4.height (), 16); EXPECT_EQ (img4.scan_line (5)[8], 0x102030); + + // other constructors + EXPECT_EQ (compare_images (lay::Image (img4.width (), img4.height (), (const lay::color_t *) img4.data ()), img4), true); + EXPECT_EQ (compare_images (lay::Image (img4.width (), img4.height (), (const lay::color_t *) img4.data (), img4.stride ()), img4), true); + + lay::color_t *dnew = new lay::color_t [ img4.width () * img4.height () * sizeof (lay::color_t) ]; + memcpy (dnew, (const lay::color_t *) img4.data (), img4.width () * img4.height () * sizeof (lay::color_t)); + EXPECT_EQ (compare_images (lay::Image (img4.width (), img4.height (), dnew), img4), true); } #if defined(HAVE_QT) @@ -260,3 +326,108 @@ TEST(3) #endif } +// Monochrome version + +TEST(11) +{ + lay::MonoImage img (15, 25); + EXPECT_EQ (img.width (), 15); + EXPECT_EQ (img.height (), 25); + EXPECT_EQ (img.stride (), 4); + + img.fill (true); + EXPECT_EQ (img.scan_line (5)[1], 0xff); + + lay::MonoImage img2; + img2 = img; + EXPECT_EQ (img2.width (), 15); + EXPECT_EQ (img2.height (), 25); + + EXPECT_EQ (img.scan_line (5)[1], 0xff); + EXPECT_EQ (img2.scan_line (5)[1], 0xff); + + img2.fill (false); + EXPECT_EQ (img.scan_line (5)[1], 0xff); + EXPECT_EQ (img2.scan_line (5)[1], 0); + + img2.swap (img); + EXPECT_EQ (img2.scan_line (5)[1], 0xff); + EXPECT_EQ (img.scan_line (5)[1], 0); + + img2 = img; + EXPECT_EQ (compare_images (img, img2), true); + EXPECT_EQ (img.scan_line (5)[1], 0); + EXPECT_EQ (img2.scan_line (5)[1], 0); + + img2 = lay::MonoImage (10, 16); + EXPECT_EQ (img.width (), 15); + EXPECT_EQ (img.height (), 25); + EXPECT_EQ (img2.width (), 10); + EXPECT_EQ (img2.height (), 16); + img2.fill (true); + EXPECT_EQ (compare_images (img, img2), false); + + EXPECT_EQ (img.scan_line (5)[1], 0); + EXPECT_EQ (img2.scan_line (5)[0], 0xff); + + img = std::move (img2); + EXPECT_EQ (compare_images (img, img2), false); + EXPECT_EQ (img.width (), 10); + EXPECT_EQ (img.height (), 16); + EXPECT_EQ (img.scan_line (5)[0], 0xff); + + lay::MonoImage img3 (img); + EXPECT_EQ (compare_images (img, img3), true); + EXPECT_EQ (img3.width (), 10); + EXPECT_EQ (img3.height (), 16); + EXPECT_EQ (img3.scan_line (5)[1], 0xff); + + img.fill (false); + EXPECT_EQ (compare_images (img, img3), false); + EXPECT_EQ (img3.width (), 10); + EXPECT_EQ (img3.height (), 16); + EXPECT_EQ (img3.scan_line (5)[1], 0xff); + EXPECT_EQ (img.width (), 10); + EXPECT_EQ (img.height (), 16); + EXPECT_EQ (img.scan_line (5)[1], 0); + + lay::MonoImage img4 (std::move (img)); + EXPECT_EQ (img4.width (), 10); + EXPECT_EQ (img4.height (), 16); + EXPECT_EQ (img4.scan_line (5)[1], 0); + + // other constructors + EXPECT_EQ (compare_images (lay::MonoImage (img4.width (), img4.height (), (const uint8_t *) img4.data ()), img4), true); + EXPECT_EQ (compare_images (lay::MonoImage (img4.width (), img4.height (), (const uint8_t *) img4.data (), img4.stride ()), img4), true); + + uint8_t *dnew = new uint8_t [ img4.width () * img4.height () * sizeof (uint8_t) ]; + memcpy (dnew, (const uint8_t *) img4.data (), img4.stride () * img4.height ()); + EXPECT_EQ (compare_images (lay::MonoImage (img4.width (), img4.height (), dnew), img4), true); +} + +#if defined(HAVE_QT) + +TEST(12) +{ + lay::MonoImage img (227, 231); + + for (unsigned int i = 0; i < img.stride (); ++i) { + for (unsigned int j = 0; j < img.height (); ++j) { + img.scan_line (j) [i] = uint8_t (i * j); + } + } + + EXPECT_EQ (img.to_image ().format () == QImage::Format_MonoLSB, true); + + std::string tmp = tmp_file ("test.png"); + QImage qimg = img.to_image (); + qimg.save (tl::to_qstring (tmp)); + tl::info << "PNG file written to " << tmp; + + std::string au = tl::testsrc () + "/testdata/lay/au_mono.png"; + tl::info << "PNG file read from " << au; + + EXPECT_EQ (compare_images_mono (qimg.convertToFormat (QImage::Format_Mono), au), true); +} + +#endif diff --git a/src/tl/tl/tlCopyOnWrite.h b/src/tl/tl/tlCopyOnWrite.h index 54ef6dc47..ed1aabca7 100644 --- a/src/tl/tl/tlCopyOnWrite.h +++ b/src/tl/tl/tlCopyOnWrite.h @@ -153,7 +153,6 @@ public: } tl::MutexLocker locker (&ms_lock); - std::swap (mp_x, other.mp_x); std::swap (mp_holder, other.mp_holder); } @@ -250,7 +249,6 @@ public: } private: - X *mp_x; copy_on_write_holder *mp_holder; void release () diff --git a/testdata/lay/au_mono.png b/testdata/lay/au_mono.png new file mode 100644 index 0000000000000000000000000000000000000000..5b7781c39f0a491f01f6400302a9315063a71889 GIT binary patch literal 6520 zcmV-;8HeVHP)+j zjZZjlSl{ptH$39FW_iVP-t>&?761Zd1+)Z111>^S!OO68phA=-tQ1oVDMnW#0$_i^ zc*DDh<-F@1gO!g{Hj_@*%(nduTFAKAG*SzIjAp=TcovkBWg_WBHiUxVNze+c7&XUC z0bqW@JI(Zt!>r9QuWW;gE)rH|eOFIyJ1f~6_`nE2fgys|p-dsw*n${M+AK_&IZo0i zPsCUHhOz;;->}?rIAyfxXVFIO&9JGIH+>6?Co+eyKiBSY27rd+p;#mlfdB4nxC zB!R|CbgI6W8SPh2&6hRs061SU*z_uBqu^-UT>1OVCFDEBqx_!5@1q^>n5+Z9z*CZJ z3@yeik>h>YdZd@oh3Ze!piCkK0f6-xk9C8ZZgSQJzW1F{dx*Fz{jF?x$7RvNsPAR~ z8Z0TIB5fF@&zQ-sb&kfi`zP>9bU}nJa~>UlcO9E;7qg~H9#k&TABrAE{nN1BbUSG# z=S|@X6#zIC2|>V6obYHel8B}Ls{t4ua$2#n>K(6L?SF8CV-9MU);-`)$-U$U zK!mb}k!9|~hw6)k>HZC<7)2E)&)7*0b}N?xaJ*!;=l8e;{42eqT;3*ZCmpPs>UbZz zhIy-ffCc~!%SKR3jA%X6k1FGt5L%7{uM&G7!Ke{l;B$)>q~wL#wH%I1CXI>;spBE64PZJq9}7AI@hh87GkTSB&vFa09>yb zX?_s8M|iGbvf_K*3i74$0hU)$Tj@u7XL$f%5osw#wlmhBrz4o@Dx{xOL-ORv(RQH+ z4uI`BFWg78UgFLV`DvY7d4{+x;jv<9-wpAq_;)4%I&4{zN_{l7!IZ=)R0U)EEjfZZ z*H~h^A%y|J*Pfk@8@aQj&udn?pNJhreb=(ld?9rb_kPJjH2^3C#tDtY{^tTPIOwQ+ zN%1q<T~qy*H#_UDF90EmGJ2|4J1$0B$ItcaM+K=1*~vZ)q$u}F zF#v~)rW!v-ujAeB8mM}dzMgclZif9wz+%SL#xZUHC>dtFUg(cfaExR(sRf~?dlNl) zHjJF@MFn7S(ihh`-TPS^v|FMUbGGR33tZ z7h`E8ffJi3MKLIRBo`;b05Cb~u4+^LSH{@PLq5xUp5o_(pV#dy{45-ha?$}ninfm( z?O#I3Q#DINJnPWO9vzH0-(qTpqKyy0<*I?+F9S9U4z$jaeac!uzEv>V`XF`}?R3`! zJpd+woa{%_VT@uIoQ>m(^x-KezDy64r$j{rU~|?3{ji4HoE5?USSHpTA?{0gAs^Fy zUbHmwmk$6f)HU-#VG`U5v8?ugs` zny36p`IoH##HcHo`KB&>ut$j?(cX@VlGk!GJp0Junj#4Rr^{w|{fSx1ztlfk{de*{ z($UIE{-45DFz>Ytbp=4j@g>ScX0#j4Mo|e32zRz0P9gEeY8VbO0ISo!xsC5R%ib07 z&@ra`I$=TXKgyYnhoqas{`LZ(#vCeaP~?%zEm8Ddj}%O$SAeKZm5nQM#Bu?6)waa% zc+x=eKP5X|F9pn|Jn3HUc_4Qj>wD!U82};*8_Ofmkx~)|EyOXL#8eiBPoyCvWG)JT z*>P7~wpYDp4#+v{y{zK}ep0|~_bugL1tXI8+W^RMZ{>zqD~Sn;K5@LM44tiMq6hoe zP*Pnw1OVKw8{_jhY=`i8(*)-~Icv$+N{0HrjMzv&)IZxD0GmWlHE~o}i@=p=V91gF zB6qS6OO5v9Y4HH;&U@`Ky6p;gao9J%=~X9)>ysWh59qloUKjJl8-N~1uC&HImfB)Y z<(8;Ju^rY-VTCr5*x;GS1mI`i9{<~UbEL28)_9zb8$k*72(D_`_B(h!<3jUr=&yqAh12r=P-?ah$zAM^ zkTVSgSD^)?;+mkp3ll$TW_BK9ZH;|v8(4gvup;}bdP@6g$)13R(BC3sG_OmQPO7s9 zFdE%5Fr_{*l3rO7zSlKmM7DqC#Odmk#^vQw#e(2n0yO2Fu@~C2|et*;u z>d(eqrn|}0Ij;*=LVpQpDguusIT2A5Bo0IVR|7CI^qgWv`78RYl)GNr+kWAO#_rcH zsej0ymU9968>OmeWcu{r!*zwi6h|{E&bfk{eXiK5LCrjsfev4nozt%ItU~TM_7{oK{c=Gh;(D4A6edbSWH|{*bgT%^MewN%=Tzrs%oy5X_0^p9Xn!cpjNmcD@#Y^fur$h$?6K1Jw!Z7VIzUO`D# z_CbGd)($s63fU_>-8fD0Eq^8XeA!=?H_@Bv$9iT!f30E-#fv4!+V~y>Z<-ouk+_kJ zTm{-+pojkM%zf@Ys^tQAVdx+0oQku=&56$xL;7!um&bjC{&v|jB-Oe|YLj;Yr&t+? z?eWbQ)N100Eyi@{@AuyAj$1i1q%UfhyPt{~LH*FW-h3%#0{3C*eCRI*iE_ds(Eqsr z3=KXkUsm*lHZ}ROaa+@8+}P;TuIs8^^X6vXhW>^*m(bHaTXAu2HT-;QFDlTbh@D_= zCPjKwL4S`HPd5G&wT5@MdywjW+9uM8`kD5xfy)?I8pc9@)l3uKLtsbAxt?T=#1EmO znTa~SKgOA5g#Io~{^UBZ>kw;0{0sZw!fS*z8NXd7wjP)43VH(lE%S=u_p6ghmHuJO z7T0`Cu_;p8<(z`Aw+2IhpEj@d-Jdo}^sQj4+wIWtl$SkA3}>?kvESA0g8p)dA~cO6 zM6huZEQ8E*;u6FtI#qyV;ib^usnNGp>+60n#$+7uS=sv-KQHW(Zb!iv;h@yx(BCw- z9(IJIoRF(*l!kfLpcCA?8L^f^YL;^g^!IA@An)ga+XRPNX2`x|FCxuI?FN@Yde<@f3l7z-NQ87dW8HN8>128uHr1R?1=k$4Lw>e8UZlKkBxy z_A!5a-ZkiNoJ$om$GZa`;9f3BwzZ-nWp&&vuO4!UYXS84Z23&DpRtSi=ljN~UncD# z9jTb$|0R4S^LFcC=&w81N>qqVXbs(;;v(=u=vlrvxzvo+GHuY`wdvp8Cib3YZ;!n1 z7*}?SuqfxVaz?`e>DKTU(BC?rFkzE(4!OiPg5K|*j;Zzx7PTrfafSYI(BC)hOZ`qJ z4-$VW-R^oma31AZ*DB9LIb&GgDmFlWB~%VpKx80AWEPr-r#VR}T#S&wM2Jaj=wZ#=8Wa;o3kCaMV-M z)!oqFyY*vzo`&xfo@}1z{4;ko`Eu!C-{+C*>HGWUL4O@mcdD7I##)71q9;>oE#-7J800sse zkS!>9K%0J#IwA3C)U%zj-qI;#}MU{lr5w)HFIpgf)+6@HI0J)%4tTNE6*3DVtJGFB0IvF;YDy0 z_+eZ)KG5F<3GX#CI*zcm#JslsRdk84D(i=OTH86vzQFs?-$FwquTz;ys_ zo{D5=xM6%GGQ5SYLwX9;R0qu!`Ox3@9b0UdvZhJyS1#5cj2=q;-LS)S zCutVvZQ*k0FCIlk5HVCI9GZkAU@8A<07itIQLHL^OP`*4+iPe0Z`_cWL)v9^_xY1^ zFG7DKm9>m)b3Z;rUnETPZ$!l^syX?_4swuN8T9u=$sErgar60?dq=vwN!UR;R5i`< zE_5~XX8S=XoRCIR1F0*c0nc^M(GdNcp9m)_0t}JNl{rh>|;m zWqI#Zvzw1fH-x-~{#KfT1?}<-a*b+~`=DeI^cRi5I-!u5|6Blu1Rawv zE`Cazl61|ux%mrjOw>8o)zxo!bF%J1e?t}J^c1f)T&%X9pX1ku3RV}elYAOU(e4${ z-y=oSjGv;{^6qpEP(4iFKsr@7-Tpmb3FBJhXy~ts;e*!+9VlmxfvlDKB3$SuqC3xy zk+D6Yze|$-ah=_LfVC;^xqWEC6~emApDq(xPD!>0KZX95ddBm6ToOsuju2*>CKprS z9VP8lq~mM+0-?W8n%4OqOdlcoQMlRdZpb9c^WLR~Gg$-JAL@5Nf7t{nnnC3wxOfqk zP7*q?h!PZ&!b5U!V(9ObsC%l7_1_rdG7tK!=y`^p9ezQ#tMHR>V9F`zZ>qMR9pzt2 z$X7Kc$6olnN5;ZK!B@4L8%XpB$zshW?%@o9^{HW*Prt{}}c2eS09+8fak~z@dIdPX=c2vD% z4$L{{y|m*ceqz8K_s!+s1jCaLK!0=HTezXt3Sy$7UmRyDM`vl8=|TRrloXdv=gTr2K3CEvbDxwghW;X*5dZT4_$%+Dqgm47b;v;#!B~YBgO0MpudL- zCmKFRuH@b79IAYlx|MXUcCPJD@B+s9<`K|eXSyfOjc-M{u+1b7u>&Dv8VMSqFGk7r zhW;)}{GgfDd6cy+_Kj^o@dd*2>~HGH?Pnyr10F$ti;YpdZdDqo-X6$kaLdG$_{2(j zWXbp{OE~oRQR7O>vDC4mKgAog*Tbh!UiB|Bp3E4={!+6K`pd)%P+YPEK_l`pEUMUv zffJ%RBq@?k;6Z;UMc!0ytNqOwo_)l;y8jV=X2>=D-lBKHA!(22@^!Qu8f@(&ry$ajl|`#p)&75eMNSCjmi zt{9Wl8E<8IAdLbg)lS!?#WMYYsKL}El4o#U z6|92(644X{4oh|-pr}YZhV-unU{vT?#q#pk^qDF5ymqwx#0`r*pj}-5h(9&wJoGnO zRmaHi>BWcX3WTYSCRDt0B`3$wO%BwSKz~n_&h`8nzleXeXSmDj#GR!5)l(cFLe?>F zv<-s(y0IMurPK@U&ahCO`DTQMYsafa2CSZLh5oKe{jHtce~P^~>aqW*(z}Gk`5#qt zn+{7ig}#CQR(l5uT4dSeLTe1ITc3!jF@%d7)j7CwdnEMtW$Oa#>4ah8_hq{^*MetI z9(JtrI+8b%^{09Z^jAoxV?;PEl22ivq(rupfJDQJ@f-w?%7p&TioKxTUGWcdNZv`) z{O;HIsX^C0HkJMsj7~TP{ms@la)K=N#8i2gD8i>0ou_S~h1)ABNy>ic@2%Pq=7%Bs zgl8J3D!%5gB3~#QWO*CCg?_YWI`r31>`L)u$*^|5JHbSALHbIxBm>tO?GWgozq@k( zb|2Ytp1UaYw{>>KIpUVYr;5S-x5O*rK0trF?U|A)T?Dn+JCReQ48ZpK<_T&v@x)eR z8ua%^?+(Y!oaxe+wJY3D#tf%^Y~5hKm@=OGsB{7J7mGwYVGyYQTmXgzACWIDdQ6*^ ze8sr6=@V{T^cmN+Rj+vSvhP5D!<|d%X`U^(c(+=9p0x)R;8M&^G&hkVJgT9;$BL&I zzeKI(-Ru5K^&o8{>3IDt`?tWQjLQw>iG_gf@OgI zE=&IGI=AZ}YkmAn`;fw`gw+{;Tqd=ikn9Y44E-(liskpIlSmc*;mlUoJWP=(LfY+| eim$T Date: Wed, 4 May 2022 02:23:23 +0200 Subject: [PATCH 23/88] Renamed lay::Image to lay::PixelBuffer --- .../{layImage.cc => layPixelBuffer.cc} | 84 +++++++++---------- .../laybasic/{layImage.h => layPixelBuffer.h} | 48 +++++------ src/laybasic/laybasic/laybasic.pro | 4 +- ...ayImageTests.cc => layPixelBufferTests.cc} | 62 +++++++------- src/laybasic/unit_tests/unit_tests.pro | 2 +- 5 files changed, 100 insertions(+), 100 deletions(-) rename src/laybasic/laybasic/{layImage.cc => layPixelBuffer.cc} (76%) rename src/laybasic/laybasic/{layImage.h => layPixelBuffer.h} (87%) rename src/laybasic/unit_tests/{layImageTests.cc => layPixelBufferTests.cc} (85%) diff --git a/src/laybasic/laybasic/layImage.cc b/src/laybasic/laybasic/layPixelBuffer.cc similarity index 76% rename from src/laybasic/laybasic/layImage.cc rename to src/laybasic/laybasic/layPixelBuffer.cc index 49575c8cd..28a831f01 100644 --- a/src/laybasic/laybasic/layImage.cc +++ b/src/laybasic/laybasic/layPixelBuffer.cc @@ -20,16 +20,16 @@ */ -#include "layImage.h" +#include "layPixelBuffer.h" #include "tlAssert.h" namespace lay { // ----------------------------------------------------------------------------------------------------- -// Image implementation +// PixelBuffer implementation -Image::Image (unsigned int w, unsigned int h, lay::color_t *data) +PixelBuffer::PixelBuffer (unsigned int w, unsigned int h, lay::color_t *data) : m_data () { m_width = w; @@ -38,7 +38,7 @@ Image::Image (unsigned int w, unsigned int h, lay::color_t *data) m_data.reset (new ImageData (data, w * h)); } -Image::Image (unsigned int w, unsigned int h, const lay::color_t *data, unsigned int stride) +PixelBuffer::PixelBuffer (unsigned int w, unsigned int h, const lay::color_t *data, unsigned int stride) : m_data () { m_width = w; @@ -65,30 +65,30 @@ Image::Image (unsigned int w, unsigned int h, const lay::color_t *data, unsigned m_data.reset (new ImageData (new_data, w * h)); } -Image::Image () +PixelBuffer::PixelBuffer () { m_width = 0; m_height = 0; m_transparent = false; } -Image::Image (const Image &other) +PixelBuffer::PixelBuffer (const PixelBuffer &other) { operator= (other); } -Image::Image (Image &&other) +PixelBuffer::PixelBuffer (PixelBuffer &&other) { swap (other); } -Image::~Image () +PixelBuffer::~PixelBuffer () { // .. nothing yet .. } -Image & -Image::operator= (const Image &other) +PixelBuffer & +PixelBuffer::operator= (const PixelBuffer &other) { if (this != &other) { m_width = other.m_width; @@ -99,8 +99,8 @@ Image::operator= (const Image &other) return *this; } -Image & -Image::operator= (Image &&other) +PixelBuffer & +PixelBuffer::operator= (PixelBuffer &&other) { if (this != &other) { swap (other); @@ -109,13 +109,13 @@ Image::operator= (Image &&other) } void -Image::set_transparent (bool f) +PixelBuffer::set_transparent (bool f) { m_transparent = f; } void -Image::swap (Image &other) +PixelBuffer::swap (PixelBuffer &other) { if (this == &other) { return; @@ -128,7 +128,7 @@ Image::swap (Image &other) } void -Image::fill (lay::color_t c) +PixelBuffer::fill (lay::color_t c) { color_t *d = data (); for (unsigned int i = 0; i < m_height; ++i) { @@ -139,41 +139,41 @@ Image::fill (lay::color_t c) } color_t * -Image::scan_line (unsigned int n) +PixelBuffer::scan_line (unsigned int n) { tl_assert (n < m_height); return m_data->data () + n * m_width; } const color_t * -Image::scan_line (unsigned int n) const +PixelBuffer::scan_line (unsigned int n) const { tl_assert (n < m_height); return m_data->data () + n * m_width; } color_t * -Image::data () +PixelBuffer::data () { return m_data->data (); } const color_t * -Image::data () const +PixelBuffer::data () const { return m_data->data (); } #if defined(HAVE_QT) QImage -Image::to_image () const +PixelBuffer::to_image () const { return QImage ((const uchar *) data (), m_width, m_height, m_transparent ? QImage::Format_ARGB32 : QImage::Format_RGB32); } #endif void -Image::patch (const Image &other) +PixelBuffer::patch (const PixelBuffer &other) { tl_assert (width () == other.width ()); tl_assert (height () == other.height ()); @@ -192,13 +192,13 @@ Image::patch (const Image &other) } } -Image -Image::diff (const Image &other) const +PixelBuffer +PixelBuffer::diff (const PixelBuffer &other) const { tl_assert (width () == other.width ()); tl_assert (height () == other.height ()); - Image res (m_width, m_height); + PixelBuffer res (m_width, m_height); res.set_transparent (true); const color_t *d2 = other.data (); @@ -221,7 +221,7 @@ Image::diff (const Image &other) const } // ----------------------------------------------------------------------------------------------------- -// MonoImage implementation +// BitmapBuffer implementation static unsigned int stride_from_width (unsigned int w) @@ -230,7 +230,7 @@ stride_from_width (unsigned int w) return 4 * ((w + 31) / 32); } -MonoImage::MonoImage (unsigned int w, unsigned int h, uint8_t *data) +BitmapBuffer::BitmapBuffer (unsigned int w, unsigned int h, uint8_t *data) { m_width = w; m_height = h; @@ -238,7 +238,7 @@ MonoImage::MonoImage (unsigned int w, unsigned int h, uint8_t *data) m_data.reset (new MonoImageData (data, m_stride * h)); } -MonoImage::MonoImage (unsigned int w, unsigned int h, const uint8_t *data, unsigned int stride) +BitmapBuffer::BitmapBuffer (unsigned int w, unsigned int h, const uint8_t *data, unsigned int stride) { m_width = w; m_height = h; @@ -261,30 +261,30 @@ MonoImage::MonoImage (unsigned int w, unsigned int h, const uint8_t *data, unsig m_data.reset (new MonoImageData (new_data, m_stride * h)); } -MonoImage::MonoImage () +BitmapBuffer::BitmapBuffer () { m_width = 0; m_height = 0; m_stride = 0; } -MonoImage::MonoImage (const MonoImage &other) +BitmapBuffer::BitmapBuffer (const BitmapBuffer &other) { operator= (other); } -MonoImage::MonoImage (MonoImage &&other) +BitmapBuffer::BitmapBuffer (BitmapBuffer &&other) { swap (other); } -MonoImage::~MonoImage () +BitmapBuffer::~BitmapBuffer () { // .. nothing yet .. } -MonoImage & -MonoImage::operator= (const MonoImage &other) +BitmapBuffer & +BitmapBuffer::operator= (const BitmapBuffer &other) { if (this != &other) { m_width = other.m_width; @@ -295,8 +295,8 @@ MonoImage::operator= (const MonoImage &other) return *this; } -MonoImage & -MonoImage::operator= (MonoImage &&other) +BitmapBuffer & +BitmapBuffer::operator= (BitmapBuffer &&other) { if (this != &other) { swap (other); @@ -305,7 +305,7 @@ MonoImage::operator= (MonoImage &&other) } void -MonoImage::swap (MonoImage &other) +BitmapBuffer::swap (BitmapBuffer &other) { if (this == &other) { return; @@ -318,7 +318,7 @@ MonoImage::swap (MonoImage &other) } void -MonoImage::fill (bool value) +BitmapBuffer::fill (bool value) { uint8_t c = value ? 0xff : 0; uint8_t *d = data (); @@ -330,34 +330,34 @@ MonoImage::fill (bool value) } uint8_t * -MonoImage::scan_line (unsigned int n) +BitmapBuffer::scan_line (unsigned int n) { tl_assert (n < m_height); return m_data->data () + n * m_stride; } const uint8_t * -MonoImage::scan_line (unsigned int n) const +BitmapBuffer::scan_line (unsigned int n) const { tl_assert (n < m_height); return m_data->data () + n * m_stride; } uint8_t * -MonoImage::data () +BitmapBuffer::data () { return m_data->data (); } const uint8_t * -MonoImage::data () const +BitmapBuffer::data () const { return m_data->data (); } #if defined(HAVE_QT) QImage -MonoImage::to_image () const +BitmapBuffer::to_image () const { QImage img = QImage ((const uchar *) data (), m_width, m_height, QImage::Format_MonoLSB); img.setColor (0, 0xff000000); diff --git a/src/laybasic/laybasic/layImage.h b/src/laybasic/laybasic/layPixelBuffer.h similarity index 87% rename from src/laybasic/laybasic/layImage.h rename to src/laybasic/laybasic/layPixelBuffer.h index da1476bcf..64aee0315 100644 --- a/src/laybasic/laybasic/layImage.h +++ b/src/laybasic/laybasic/layPixelBuffer.h @@ -21,8 +21,8 @@ */ -#ifndef HDR_layImage -#define HDR_layImage +#ifndef HDR_layPixelBuffer +#define HDR_layPixelBuffer #include "laybasicCommon.h" #include "layColor.h" @@ -45,7 +45,7 @@ namespace lay * It provides 32bit RGBA pixels with the format used by lay::Color. */ -class LAYBASIC_PUBLIC Image +class LAYBASIC_PUBLIC PixelBuffer { public: /** @@ -56,7 +56,7 @@ public: * * The size of the data block needs to be w*h elements. */ - Image (unsigned int w, unsigned int h, lay::color_t *data); + PixelBuffer (unsigned int w, unsigned int h, lay::color_t *data); /** * @brief Creates an image with the given height and width @@ -66,37 +66,37 @@ public: * "stride" specifies the stride (distance between two rows of data). * The size of the data block needs to be stride*h elements or w*h if stride is not given. */ - Image (unsigned int w, unsigned int h, const lay::color_t *data = 0, unsigned int stride = 0); + PixelBuffer (unsigned int w, unsigned int h, const lay::color_t *data = 0, unsigned int stride = 0); /** * @brief Default constructor */ - Image (); + PixelBuffer (); /** * @brief Copy constructor */ - Image (const Image &other); + PixelBuffer (const PixelBuffer &other); /** * @brief Move constructor */ - Image (Image &&other); + PixelBuffer (PixelBuffer &&other); /** * @brief Destructor */ - ~Image (); + ~PixelBuffer (); /** * @brief Assignment */ - Image &operator= (const Image &other); + PixelBuffer &operator= (const PixelBuffer &other); /** * @brief Move constructor */ - Image &operator= (Image &&other); + PixelBuffer &operator= (PixelBuffer &&other); /** * @brief Sets a value indicating whether an alpha channel is present @@ -114,7 +114,7 @@ public: /** * @brief Swaps this image with another one */ - void swap (Image &other); + void swap (PixelBuffer &other); /** * @brief Gets the images width @@ -178,7 +178,7 @@ public: * This feature does not implement real alpha blending. Instead all * pixels with an alpha value >= 128 from the other image are patched into this image. */ - void patch (const Image &other); + void patch (const PixelBuffer &other); /** * @brief Generates the image difference @@ -190,7 +190,7 @@ public: * * alpha values from this and other are ignored. */ - Image diff (const Image &other) const; + PixelBuffer diff (const PixelBuffer &other) const; private: class ImageData @@ -243,7 +243,7 @@ private: * This class substitutes QImage for monochrome images in Qt-less applications. */ -class LAYBASIC_PUBLIC MonoImage +class LAYBASIC_PUBLIC BitmapBuffer { public: /** @@ -254,7 +254,7 @@ public: * * Lines are byte-aligned. */ - MonoImage (unsigned int w, unsigned int h, uint8_t *data); + BitmapBuffer (unsigned int w, unsigned int h, uint8_t *data); /** * @brief Creates an image with the given height and width @@ -264,42 +264,42 @@ public: * "stride" specifies the stride (distance in bytes between two rows of data). * The size of the data block needs to be stride*h elements or bytes(w)*h if stride is not given. */ - MonoImage (unsigned int w, unsigned int h, const uint8_t *data = 0, unsigned int stride = 0); + BitmapBuffer (unsigned int w, unsigned int h, const uint8_t *data = 0, unsigned int stride = 0); /** * @brief Default constructor */ - MonoImage (); + BitmapBuffer (); /** * @brief Copy constructor */ - MonoImage (const MonoImage &other); + BitmapBuffer (const BitmapBuffer &other); /** * @brief Move constructor */ - MonoImage (MonoImage &&other); + BitmapBuffer (BitmapBuffer &&other); /** * @brief Destructor */ - ~MonoImage (); + ~BitmapBuffer (); /** * @brief Assignment */ - MonoImage &operator= (const MonoImage &other); + BitmapBuffer &operator= (const BitmapBuffer &other); /** * @brief Move constructor */ - MonoImage &operator= (MonoImage &&other); + BitmapBuffer &operator= (BitmapBuffer &&other); /** * @brief Swaps this image with another one */ - void swap (MonoImage &other); + void swap (BitmapBuffer &other); /** * @brief Gets the images width diff --git a/src/laybasic/laybasic/laybasic.pro b/src/laybasic/laybasic/laybasic.pro index e760d0d00..bae8ac5e4 100644 --- a/src/laybasic/laybasic/laybasic.pro +++ b/src/laybasic/laybasic/laybasic.pro @@ -118,7 +118,6 @@ DEFINES += MAKE_LAYBASIC_LIBRARY layGenericSyntaxHighlighter.cc \ layGridNetConfigPage.cc \ layHierarchyControlPanel.cc \ - layImage.cc \ layIndexedNetlistModel.cc \ layItemDelegates.cc \ layLayerControlPanel.cc \ @@ -139,6 +138,7 @@ DEFINES += MAKE_LAYBASIC_LIBRARY layNetlistBrowserPage.cc \ layNetlistBrowserTreeModel.cc \ layNetlistCrossReferenceModel.cc \ + layPixelBuffer.cc \ layPluginConfigPage.cc \ layProperties.cc \ layPropertiesDialog.cc \ @@ -192,7 +192,6 @@ DEFINES += MAKE_LAYBASIC_LIBRARY layGenericSyntaxHighlighter.h \ layGridNetConfigPage.h \ layHierarchyControlPanel.h \ - layImage.h \ layIndexedNetlistModel.h \ layItemDelegates.h \ layLayerControlPanel.h \ @@ -213,6 +212,7 @@ DEFINES += MAKE_LAYBASIC_LIBRARY layNetlistBrowserPage.h \ layNetlistBrowserTreeModel.h \ layNetlistCrossReferenceModel.h \ + layPixelBuffer.h \ layPluginConfigPage.h \ layProperties.h \ layPropertiesDialog.h \ diff --git a/src/laybasic/unit_tests/layImageTests.cc b/src/laybasic/unit_tests/layPixelBufferTests.cc similarity index 85% rename from src/laybasic/unit_tests/layImageTests.cc rename to src/laybasic/unit_tests/layPixelBufferTests.cc index d680feaed..9e180568d 100644 --- a/src/laybasic/unit_tests/layImageTests.cc +++ b/src/laybasic/unit_tests/layPixelBufferTests.cc @@ -20,7 +20,7 @@ */ -#include "layImage.h" +#include "layPixelBuffer.h" #include "tlUnitTest.h" #include "tlTimer.h" @@ -69,7 +69,7 @@ static bool compare_images_mono (const QImage &qimg, const std::string &au) } } -static bool compare_images (const lay::Image &img, const lay::Image &img2) +static bool compare_images (const lay::PixelBuffer &img, const lay::PixelBuffer &img2) { if (img2.width () == img.width () && img2.height () == img.height ()) { for (unsigned int j = 0; j < img.height (); ++j) { @@ -85,7 +85,7 @@ static bool compare_images (const lay::Image &img, const lay::Image &img2) } } -static bool compare_images (const lay::MonoImage &img, const lay::MonoImage &img2) +static bool compare_images (const lay::BitmapBuffer &img, const lay::BitmapBuffer &img2) { if (img2.width () == img.width () && img2.height () == img.height ()) { for (unsigned int j = 0; j < img.height (); ++j) { @@ -105,7 +105,7 @@ static bool compare_images (const lay::MonoImage &img, const lay::MonoImage &img TEST(1) { - lay::Image img (15, 25); + lay::PixelBuffer img (15, 25); EXPECT_EQ (img.width (), 15); EXPECT_EQ (img.height (), 25); EXPECT_EQ (img.stride (), 15 * sizeof (lay::color_t)); @@ -117,7 +117,7 @@ TEST(1) img.fill (0x112233); EXPECT_EQ (img.scan_line (5)[10], 0x112233); - lay::Image img2; + lay::PixelBuffer img2; EXPECT_EQ (img2.transparent (), false); img2 = img; EXPECT_EQ (img2.transparent (), true); @@ -142,7 +142,7 @@ TEST(1) EXPECT_EQ (img.scan_line (5)[10], 0x332211); EXPECT_EQ (img2.scan_line (5)[10], 0x332211); - img2 = lay::Image (10, 16); + img2 = lay::PixelBuffer (10, 16); EXPECT_EQ (img.width (), 15); EXPECT_EQ (img.height (), 25); EXPECT_EQ (img2.width (), 10); @@ -159,7 +159,7 @@ TEST(1) EXPECT_EQ (img.height (), 16); EXPECT_EQ (img.scan_line (5)[8], 0x010203); - lay::Image img3 (img); + lay::PixelBuffer img3 (img); EXPECT_EQ (compare_images (img, img3), true); EXPECT_EQ (img3.width (), 10); EXPECT_EQ (img3.height (), 16); @@ -174,25 +174,25 @@ TEST(1) EXPECT_EQ (img.height (), 16); EXPECT_EQ (img.scan_line (5)[8], 0x102030); - lay::Image img4 (std::move (img)); + lay::PixelBuffer img4 (std::move (img)); EXPECT_EQ (img4.width (), 10); EXPECT_EQ (img4.height (), 16); EXPECT_EQ (img4.scan_line (5)[8], 0x102030); // other constructors - EXPECT_EQ (compare_images (lay::Image (img4.width (), img4.height (), (const lay::color_t *) img4.data ()), img4), true); - EXPECT_EQ (compare_images (lay::Image (img4.width (), img4.height (), (const lay::color_t *) img4.data (), img4.stride ()), img4), true); + EXPECT_EQ (compare_images (lay::PixelBuffer (img4.width (), img4.height (), (const lay::color_t *) img4.data ()), img4), true); + EXPECT_EQ (compare_images (lay::PixelBuffer (img4.width (), img4.height (), (const lay::color_t *) img4.data (), img4.stride ()), img4), true); lay::color_t *dnew = new lay::color_t [ img4.width () * img4.height () * sizeof (lay::color_t) ]; memcpy (dnew, (const lay::color_t *) img4.data (), img4.width () * img4.height () * sizeof (lay::color_t)); - EXPECT_EQ (compare_images (lay::Image (img4.width (), img4.height (), dnew), img4), true); + EXPECT_EQ (compare_images (lay::PixelBuffer (img4.width (), img4.height (), dnew), img4), true); } #if defined(HAVE_QT) TEST(2) { - lay::Image img (227, 231); + lay::PixelBuffer img (227, 231); for (unsigned int i = 0; i < img.width (); ++i) { for (unsigned int j = 0; j < img.height (); ++j) { @@ -213,10 +213,10 @@ TEST(2) EXPECT_EQ (compare_images (qimg, au), true); - lay::Image img_saved (img); + lay::PixelBuffer img_saved (img); img.scan_line (52) [42] = 0xff000000; - lay::Image diff = img.diff (img_saved); + lay::PixelBuffer diff = img.diff (img_saved); EXPECT_EQ (diff.transparent (), true); EXPECT_EQ (diff.to_image ().format () == QImage::Format_ARGB32, true); EXPECT_EQ (compare_images (img.to_image (), au), false); @@ -246,11 +246,11 @@ TEST(3) { tl::SelfTimer timer ("Run time - lay::Image copy, no write (should be very fast)"); - lay::Image img (1000, 1000); + lay::PixelBuffer img (1000, 1000); img.fill (0x112233); for (unsigned int i = 0; i < 5000; ++i) { - lay::Image img2 (img); + lay::PixelBuffer img2 (img); } } @@ -258,7 +258,7 @@ TEST(3) { tl::SelfTimer timer ("Run time - QImage copy, no write (should be very fast)"); - lay::Image img (1000, 1000); + lay::PixelBuffer img (1000, 1000); img.fill (0x112233); QImage qimg (img.to_image ()); @@ -271,11 +271,11 @@ TEST(3) { tl::SelfTimer timer ("Run time - lay::Image copy on write"); - lay::Image img (1000, 1000); + lay::PixelBuffer img (1000, 1000); img.fill (0x112233); for (unsigned int i = 0; i < 5000; ++i) { - lay::Image img2 (img); + lay::PixelBuffer img2 (img); img2.scan_line (100) [7] = 0; } } @@ -284,7 +284,7 @@ TEST(3) { tl::SelfTimer timer ("Run time - QImage copy on write (should not be much less than lay::Image copy on write)"); - lay::Image img (1000, 1000); + lay::PixelBuffer img (1000, 1000); img.fill (0x112233); QImage qimg (img.to_image ()); @@ -297,7 +297,7 @@ TEST(3) { tl::SelfTimer timer ("Run time - direct QImage paint"); - lay::Image img (1000, 1000); + lay::PixelBuffer img (1000, 1000); img.fill (0x112233); QImage qimg (img.to_image ()); QImage qrec (img.to_image ()); @@ -312,7 +312,7 @@ TEST(3) { tl::SelfTimer timer ("Run time - lay::Image paint (should not be much more than direct QImage paint)"); - lay::Image img (1000, 1000); + lay::PixelBuffer img (1000, 1000); img.fill (0x112233); QImage qrec (img.to_image ()); qrec.fill (0); @@ -330,7 +330,7 @@ TEST(3) TEST(11) { - lay::MonoImage img (15, 25); + lay::BitmapBuffer img (15, 25); EXPECT_EQ (img.width (), 15); EXPECT_EQ (img.height (), 25); EXPECT_EQ (img.stride (), 4); @@ -338,7 +338,7 @@ TEST(11) img.fill (true); EXPECT_EQ (img.scan_line (5)[1], 0xff); - lay::MonoImage img2; + lay::BitmapBuffer img2; img2 = img; EXPECT_EQ (img2.width (), 15); EXPECT_EQ (img2.height (), 25); @@ -359,7 +359,7 @@ TEST(11) EXPECT_EQ (img.scan_line (5)[1], 0); EXPECT_EQ (img2.scan_line (5)[1], 0); - img2 = lay::MonoImage (10, 16); + img2 = lay::BitmapBuffer (10, 16); EXPECT_EQ (img.width (), 15); EXPECT_EQ (img.height (), 25); EXPECT_EQ (img2.width (), 10); @@ -376,7 +376,7 @@ TEST(11) EXPECT_EQ (img.height (), 16); EXPECT_EQ (img.scan_line (5)[0], 0xff); - lay::MonoImage img3 (img); + lay::BitmapBuffer img3 (img); EXPECT_EQ (compare_images (img, img3), true); EXPECT_EQ (img3.width (), 10); EXPECT_EQ (img3.height (), 16); @@ -391,25 +391,25 @@ TEST(11) EXPECT_EQ (img.height (), 16); EXPECT_EQ (img.scan_line (5)[1], 0); - lay::MonoImage img4 (std::move (img)); + lay::BitmapBuffer img4 (std::move (img)); EXPECT_EQ (img4.width (), 10); EXPECT_EQ (img4.height (), 16); EXPECT_EQ (img4.scan_line (5)[1], 0); // other constructors - EXPECT_EQ (compare_images (lay::MonoImage (img4.width (), img4.height (), (const uint8_t *) img4.data ()), img4), true); - EXPECT_EQ (compare_images (lay::MonoImage (img4.width (), img4.height (), (const uint8_t *) img4.data (), img4.stride ()), img4), true); + EXPECT_EQ (compare_images (lay::BitmapBuffer (img4.width (), img4.height (), (const uint8_t *) img4.data ()), img4), true); + EXPECT_EQ (compare_images (lay::BitmapBuffer (img4.width (), img4.height (), (const uint8_t *) img4.data (), img4.stride ()), img4), true); uint8_t *dnew = new uint8_t [ img4.width () * img4.height () * sizeof (uint8_t) ]; memcpy (dnew, (const uint8_t *) img4.data (), img4.stride () * img4.height ()); - EXPECT_EQ (compare_images (lay::MonoImage (img4.width (), img4.height (), dnew), img4), true); + EXPECT_EQ (compare_images (lay::BitmapBuffer (img4.width (), img4.height (), dnew), img4), true); } #if defined(HAVE_QT) TEST(12) { - lay::MonoImage img (227, 231); + lay::BitmapBuffer img (227, 231); for (unsigned int i = 0; i < img.stride (); ++i) { for (unsigned int j = 0; j < img.height (); ++j) { diff --git a/src/laybasic/unit_tests/unit_tests.pro b/src/laybasic/unit_tests/unit_tests.pro index 40db96675..02ee4a7b4 100644 --- a/src/laybasic/unit_tests/unit_tests.pro +++ b/src/laybasic/unit_tests/unit_tests.pro @@ -10,10 +10,10 @@ SOURCES = \ layAnnotationShapes.cc \ layBitmap.cc \ layBitmapsToImage.cc \ - layImageTests.cc \ layColorTests.cc \ layLayerProperties.cc \ layParsedLayerSource.cc \ + layPixelBufferTests.cc \ layRenderer.cc \ layNetlistBrowserModelTests.cc \ layNetlistBrowserTreeModelTests.cc \ From 5fa984324ec6509faf77dd474fd7b231b3f07619 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Wed, 4 May 2022 21:16:10 +0200 Subject: [PATCH 24/88] PixelBuffer: versions to create independent copies into QImage --- src/laybasic/laybasic/layPixelBuffer.cc | 16 +++++++++++++ src/laybasic/laybasic/layPixelBuffer.h | 24 ++++++++++++++++++- .../unit_tests/layPixelBufferTests.cc | 18 ++++++++++++++ 3 files changed, 57 insertions(+), 1 deletion(-) diff --git a/src/laybasic/laybasic/layPixelBuffer.cc b/src/laybasic/laybasic/layPixelBuffer.cc index 28a831f01..ad041d1bb 100644 --- a/src/laybasic/laybasic/layPixelBuffer.cc +++ b/src/laybasic/laybasic/layPixelBuffer.cc @@ -170,6 +170,14 @@ PixelBuffer::to_image () const { return QImage ((const uchar *) data (), m_width, m_height, m_transparent ? QImage::Format_ARGB32 : QImage::Format_RGB32); } + +QImage +PixelBuffer::to_image_copy () const +{ + QImage img (m_width, m_height, m_transparent ? QImage::Format_ARGB32 : QImage::Format_RGB32); + memcpy (img.bits (), data (), img.sizeInBytes ()); + return img; +} #endif void @@ -364,6 +372,14 @@ BitmapBuffer::to_image () const img.setColor (1, 0xffffffff); return img; } + +QImage +BitmapBuffer::to_image_copy () const +{ + QImage img (m_width, m_height, QImage::Format_MonoLSB); + memcpy (img.bits (), data (), img.sizeInBytes ()); + return img; +} #endif } diff --git a/src/laybasic/laybasic/layPixelBuffer.h b/src/laybasic/laybasic/layPixelBuffer.h index 64aee0315..c78cfbf66 100644 --- a/src/laybasic/laybasic/layPixelBuffer.h +++ b/src/laybasic/laybasic/layPixelBuffer.h @@ -168,8 +168,19 @@ public: #if defined(HAVE_QT) /** * @brief Produces a QImage object from the image + * + * NOTE: this version creates a reference, i.e. the QImage is valid only + * during the lifetime of the PixelBuffer. */ QImage to_image () const; + + /** + * @brief Produces a QImage object from the image + * + * NOTE: this version creates a copy and the QImage is independent of the + * PixelBuffer. + */ + QImage to_image_copy () const; #endif /** @@ -352,9 +363,20 @@ public: #if defined(HAVE_QT) /** - * @brief Produces a QMonoImage object from the image + * @brief Produces a QImage object from the image + * + * NOTE: this version creates a reference, i.e. the QImage is valid only + * during the lifetime of the BitmapBuffer. */ QImage to_image () const; + + /** + * @brief Produces a QImage object from the image + * + * NOTE: this version creates a copy and the QImage is independent of the + * BitmapBuffer. + */ + QImage to_image_copy () const; #endif private: diff --git a/src/laybasic/unit_tests/layPixelBufferTests.cc b/src/laybasic/unit_tests/layPixelBufferTests.cc index 9e180568d..9f79bc8f0 100644 --- a/src/laybasic/unit_tests/layPixelBufferTests.cc +++ b/src/laybasic/unit_tests/layPixelBufferTests.cc @@ -237,6 +237,15 @@ TEST(2) tl::info << "PNG file read from " << au; EXPECT_EQ (compare_images (qimg, au), true); + + qimg = img.to_image_copy (); + img.fill (false); + + tmp = tmp_file ("test2.png"); + qimg.save (tl::to_qstring (tmp)); + tl::info << "PNG file written to " << tmp; + + EXPECT_EQ (compare_images (qimg, au), true); } #endif @@ -428,6 +437,15 @@ TEST(12) tl::info << "PNG file read from " << au; EXPECT_EQ (compare_images_mono (qimg.convertToFormat (QImage::Format_Mono), au), true); + + qimg = img.to_image_copy (); + img.fill (false); + + tmp = tmp_file ("test2.png"); + qimg.save (tl::to_qstring (tmp)); + tl::info << "PNG file written to " << tmp; + + EXPECT_EQ (compare_images_mono (qimg.convertToFormat (QImage::Format_Mono), au), true); } #endif From 0877de73d4b880ec262eeb14f3e5d83dd639d710 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Wed, 4 May 2022 23:34:34 +0200 Subject: [PATCH 25/88] Refactoring: substitute QImage by lay::PixelBuffer --- src/img/img/imgService.cc | 24 +- src/laybasic/laybasic/layBitmapsToImage.cc | 61 ++-- src/laybasic/laybasic/layBitmapsToImage.h | 24 +- src/laybasic/laybasic/layGridNet.cc | 155 +--------- src/laybasic/laybasic/layLayerTreeModel.cc | 9 +- src/laybasic/laybasic/layLayoutCanvas.cc | 281 +++++++++++------- src/laybasic/laybasic/layLayoutCanvas.h | 19 +- src/laybasic/laybasic/layLayoutViewBase.cc | 31 +- .../laybasic/layPixelBufferPainter.cc | 171 +++++++++++ src/laybasic/laybasic/layPixelBufferPainter.h | 61 ++++ .../laybasic/layRedrawThreadCanvas.cc | 33 +- src/laybasic/laybasic/layRedrawThreadCanvas.h | 12 +- src/laybasic/laybasic/layViewObject.cc | 13 + src/laybasic/laybasic/layViewObject.h | 19 +- src/laybasic/laybasic/laybasic.pro | 6 +- src/laybasic/unit_tests/layBitmapsToImage.cc | 14 +- 16 files changed, 552 insertions(+), 381 deletions(-) create mode 100644 src/laybasic/laybasic/layPixelBufferPainter.cc create mode 100644 src/laybasic/laybasic/layPixelBufferPainter.h diff --git a/src/img/img/imgService.cc b/src/img/img/imgService.cc index 627c03967..68fcb1a9f 100644 --- a/src/img/img/imgService.cc +++ b/src/img/img/imgService.cc @@ -83,7 +83,7 @@ private: // ------------------------------------------------------------- static void -draw_scanline (unsigned int level, const img::Object &image_object, QImage &qimage, int y, const db::Matrix3d &t, const db::Matrix3d &it, const db::DPoint &q1, const db::DPoint &q2) +draw_scanline (unsigned int level, const img::Object &image_object, lay::PixelBuffer &pxbuffer, int y, const db::Matrix3d &t, const db::Matrix3d &it, const db::DPoint &q1, const db::DPoint &q2) { double source_width = image_object.width (); double source_height = image_object.height (); @@ -95,8 +95,8 @@ draw_scanline (unsigned int level, const img::Object &image_object, QImage &qima std::swap (x1, x2); } - int xstart = int (std::max (0.0, std::min (floor (x1), double (qimage.width ())))); - int xstop = int (std::max (0.0, std::min (ceil (x2) + 1.0, double (qimage.width ())))); + int xstart = int (std::max (0.0, std::min (floor (x1), double (pxbuffer.width ())))); + int xstop = int (std::max (0.0, std::min (ceil (x2) + 1.0, double (pxbuffer.width ())))); db::DPoint p1 = it.trans (db::DPoint (xstart, y)); db::DPoint p2 = it.trans (db::DPoint (xstop, y)); @@ -106,8 +106,8 @@ draw_scanline (unsigned int level, const img::Object &image_object, QImage &qima if (level < 7 && xstop > xstart + 1 && fabs (xm - (xstart + xstop) / 2) > 1.0 && xm > xstart + 1 && xm < xstop - 1) { - draw_scanline (level + 1, image_object, qimage, y, t, it, q1, qm); - draw_scanline (level + 1, image_object, qimage, y, t, it, qm, q2); + draw_scanline (level + 1, image_object, pxbuffer, y, t, it, q1, qm); + draw_scanline (level + 1, image_object, pxbuffer, y, t, it, qm, q2); } else { @@ -115,8 +115,8 @@ draw_scanline (unsigned int level, const img::Object &image_object, QImage &qima double dpx = (p2.x () - p1.x ()) / double (xstop - xstart); double dpy = (p2.y () - p1.y ()) / double (xstop - xstart); - QRgb *scanline_data = (QRgb *) qimage.scanLine (qimage.height () - y - 1) + xstart; - QRgb *pixel_data = (QRgb *) image_object.pixel_data (); + lay::color_t *scanline_data = pxbuffer.scan_line (pxbuffer.height () - y - 1) + xstart; + lay::color_t *pixel_data = (lay::color_t *) image_object.pixel_data (); const unsigned char *mask_data = image_object.mask (); for (int x = xstart; x < xstop; ++x) { @@ -144,15 +144,15 @@ draw_image (const img::Object &image_object, const lay::Viewport &vp, lay::ViewO { // TODO: currently, the images can only be rendered to a bitmap canvas .. lay::BitmapViewObjectCanvas *bmp_canvas = dynamic_cast (&canvas); - if (! bmp_canvas) { + if (! bmp_canvas || ! bmp_canvas->bg_image ()) { return; } - QImage &qimage = bmp_canvas->bg_image (); + lay::PixelBuffer &image = *bmp_canvas->bg_image (); db::DBox source_image_box (0.0, 0.0, image_object.width (), image_object.height ()); // safety measure to avoid division by zero. - if (qimage.width () < 1 || qimage.height () < 1) { + if (image.width () < 1 || image.height () < 1) { return; } @@ -165,7 +165,7 @@ draw_image (const img::Object &image_object, const lay::Viewport &vp, lay::ViewO db::DBox image_box = source_image_box.transformed (t); int y1 = int (floor (std::max (0.0, image_box.bottom ()))); - int y2 = int (floor (std::min (double (qimage.height ()) - 1, image_box.top ()))); + int y2 = int (floor (std::min (double (image.height ()) - 1, image_box.top ()))); for (int y = y1; y <= y2; ++y) { @@ -175,7 +175,7 @@ draw_image (const img::Object &image_object, const lay::Viewport &vp, lay::ViewO // clip the transformed scanline to the original image std::pair clipped = scanline.clipped_line (source_image_box); if (clipped.first) { - draw_scanline (0, image_object, qimage, y, t, it, clipped.second.p1 (), clipped.second.p2 ()); + draw_scanline (0, image_object, image, y, t, it, clipped.second.p1 (), clipped.second.p2 ()); } } diff --git a/src/laybasic/laybasic/layBitmapsToImage.cc b/src/laybasic/laybasic/layBitmapsToImage.cc index 13403920b..cb1666fb7 100644 --- a/src/laybasic/laybasic/layBitmapsToImage.cc +++ b/src/laybasic/laybasic/layBitmapsToImage.cc @@ -25,11 +25,10 @@ #include "layBitmap.h" #include "layDitherPattern.h" #include "layLineStyles.h" +#include "layPixelBuffer.h" #include "tlTimer.h" #include "tlAssert.h" - -#include -#include +#include "tlThreads.h" namespace lay { @@ -422,16 +421,17 @@ static void create_precursor_bitmaps (const std::vector &view_ops_i } } -static void -bitmaps_to_image_rgb (const std::vector &view_ops_in, - const std::vector &pbitmaps_in, - const lay::DitherPattern &dp, - const lay::LineStyles &ls, - QImage *pimage, unsigned int width, unsigned int height, - bool use_bitmap_index, - bool transparent, - tl::Mutex *mutex) +void +bitmaps_to_image (const std::vector &view_ops_in, + const std::vector &pbitmaps_in, + const lay::DitherPattern &dp, + const lay::LineStyles &ls, + PixelBuffer *pimage, unsigned int width, unsigned int height, + bool use_bitmap_index, + tl::Mutex *mutex) { + bool transparent = pimage->transparent (); + std::vector bm_map; std::vector vo_map; @@ -588,7 +588,7 @@ bitmaps_to_image_rgb (const std::vector &view_ops_in, if (masks.size () > 0) { - lay::color_t *pt = (lay::color_t *) pimage->scanLine (height - 1 - y); + lay::color_t *pt = (lay::color_t *) pimage->scan_line (height - 1 - y); uint32_t *dptr_end = dptr; unsigned int i = 0; @@ -661,14 +661,14 @@ bitmaps_to_image_rgb (const std::vector &view_ops_in, delete [] buffer; } -static void -bitmaps_to_image_mono (const std::vector &view_ops_in, - const std::vector &pbitmaps_in, - const lay::DitherPattern &dp, - const lay::LineStyles &ls, - QImage *pimage, unsigned int width, unsigned int height, - bool use_bitmap_index, - tl::Mutex *mutex) +void +bitmaps_to_image (const std::vector &view_ops_in, + const std::vector &pbitmaps_in, + const lay::DitherPattern &dp, + const lay::LineStyles &ls, + lay::BitmapBuffer *pimage, unsigned int width, unsigned int height, + bool use_bitmap_index, + tl::Mutex *mutex) { std::vector bm_map; std::vector vo_map; @@ -825,7 +825,7 @@ bitmaps_to_image_mono (const std::vector &view_ops_in, if (masks.size () > 0) { - lay::color_t *pt = (lay::color_t *) pimage->scanLine (height - 1 - y); + lay::color_t *pt = (lay::color_t *) pimage->scan_line (height - 1 - y); uint32_t *dptr_end = dptr; unsigned int i = 0; @@ -866,23 +866,6 @@ bitmaps_to_image_mono (const std::vector &view_ops_in, delete [] buffer; } -void -bitmaps_to_image (const std::vector &view_ops_in, - const std::vector &pbitmaps_in, - const lay::DitherPattern &dp, - const lay::LineStyles &ls, - QImage *pimage, unsigned int width, unsigned int height, - bool use_bitmap_index, - tl::Mutex *mutex) -{ - if (pimage->depth () <= 1) { - bitmaps_to_image_mono (view_ops_in, pbitmaps_in, dp, ls, pimage, width, height, use_bitmap_index, mutex); - } else { - bool transparent = (pimage->format () == QImage::Format_ARGB32); - bitmaps_to_image_rgb (view_ops_in, pbitmaps_in, dp, ls, pimage, width, height, use_bitmap_index, transparent, mutex); - } -} - void bitmap_to_bitmap (const lay::ViewOp &view_op, const lay::Bitmap &bitmap, unsigned char *data, diff --git a/src/laybasic/laybasic/layBitmapsToImage.h b/src/laybasic/laybasic/layBitmapsToImage.h index 411369705..3520fdaf5 100644 --- a/src/laybasic/laybasic/layBitmapsToImage.h +++ b/src/laybasic/laybasic/layBitmapsToImage.h @@ -29,17 +29,17 @@ #include -class QImage; - namespace lay { class DitherPattern; class LineStyles; class Bitmap; +class PixelBuffer; +class BitmapBuffer; /** - * @brief This function converts the given set of bitmaps to a QImage + * @brief This function converts the given set of bitmaps to a PixelBuffer * * This function uses the set of bitmaps in "pbitmaps" with the given set * of view operands in "view_ops" and converts these into the QImage @@ -58,12 +58,26 @@ bitmaps_to_image (const std::vector &view_ops, const std::vector &pbitmaps, const lay::DitherPattern &dp, const lay::LineStyles &ls, - QImage *pimage, unsigned int width, unsigned int height, + lay::PixelBuffer *pimage, unsigned int width, unsigned int height, bool use_bitmap_index, tl::Mutex *mutex); /** - * @brief Convert a lay::Bitmap to a unsigned char * data field to be passed to QBitmap + * @brief This function converts the given set of bitmaps to a BitmapBuffer + * + * This is the monochrome version of the previous bitmaps_to_image function. + */ +LAYBASIC_PUBLIC void +bitmaps_to_image (const std::vector &view_ops, + const std::vector &pbitmaps, + const lay::DitherPattern &dp, + const lay::LineStyles &ls, + lay::BitmapBuffer *pimage, unsigned int width, unsigned int height, + bool use_bitmap_index, + tl::Mutex *mutex); + +/** + * @brief Convert a lay::Bitmap to a unsigned char * data field to be passed to lay::BitmapBuffer * * This function converts the bitmap given the view_op into a raw byte data * field that can be passed to a QBitmap constructor. The data field is not diff --git a/src/laybasic/laybasic/layGridNet.cc b/src/laybasic/laybasic/layGridNet.cc index d006ca58c..612f58fc9 100644 --- a/src/laybasic/laybasic/layGridNet.cc +++ b/src/laybasic/laybasic/layGridNet.cc @@ -26,6 +26,7 @@ #include "layConverters.h" #include "layLayoutView.h" #include "layFixedFont.h" +#include "layPixelBufferPainter.h" #include "laySnap.h" #include "dbTrans.h" @@ -206,153 +207,7 @@ GridNet::configure (const std::string &name, const std::string &value) return taken; } -#if defined(HAVE_QT) // @@@ -class ImagePainter -{ -public: - ImagePainter (lay::BitmapViewObjectCanvas &canvas) - : mp_img (&canvas.bg_image ()), - m_resolution (canvas.resolution ()), m_width (canvas.canvas_width ()), m_height (canvas.canvas_height ()) - { - // .. nothing yet .. - } - - void set (const db::Point &p, lay::Color c) - { - if (p.x () >= 0 && p.x () < m_width && p.y () >= 0 && p.y () < m_height) { - ((unsigned int *) mp_img->scanLine (p.y ())) [p.x ()] = c.rgb (); - } - } - - void draw_line (const db::Point &p1, const db::Point &p2, lay::Color c) - { - if (p1.x () == p2.x ()) { - - int x = p1.x (); - int y1 = std::min (p1.y (), p2.y ()); - int y2 = std::max (p1.y (), p2.y ()); - if ((y2 >= 0 || y1 < m_height) && x >= 0 && x < m_width) { - y1 = std::max (y1, 0); - y2 = std::min (y2, m_height - 1); - for (int y = y1; y <= y2; ++y) { - ((unsigned int *) mp_img->scanLine (y)) [x] = c.rgb (); - } - } - - } else if (p1.y () == p2.y ()) { - - int y = p1.y (); - int x1 = std::min (p1.x (), p2.x ()); - int x2 = std::max (p1.x (), p2.x ()); - if ((x2 >= 0 || x1 < m_width) && y >= 0 && y < m_height) { - x1 = std::max (x1, 0); - x2 = std::min (x2, m_width - 1); - unsigned int *sl = (unsigned int *) mp_img->scanLine (y) + x1; - for (int x = x1; x <= x2; ++x) { - *sl++ = c.rgb (); - } - } - - } else { - // TODO: not implemented yet. - } - } - - void fill_rect (const db::Point &p1, const db::Point &p2, lay::Color c) - { - int y1 = std::min (p1.y (), p2.y ()); - int y2 = std::max (p1.y (), p2.y ()); - for (int y = y1; y <= y2; ++y) { - draw_line (db::Point (p1.x (), y), db::Point (p2.x (), y), c); - } - } - - void draw_rect (const db::Point &p1, const db::Point &p2, lay::Color c) - { - int y1 = std::min (p1.y (), p2.y ()); - int y2 = std::max (p1.y (), p2.y ()); - int x1 = std::min (p1.x (), p2.x ()); - int x2 = std::max (p1.x (), p2.x ()); - draw_line (db::Point (x1, y1), db::Point (x2, y1), c); - draw_line (db::Point (x1, y2), db::Point (x2, y2), c); - draw_line (db::Point (x1, y1), db::Point (x1, y2), c); - draw_line (db::Point (x2, y1), db::Point (x2, y2), c); - } - - void draw_text (const char *t, const db::Point &p, lay::Color c, int halign, int valign) - { - const lay::FixedFont &ff = lay::FixedFont::get_font (m_resolution); - int x = p.x (), y = p.y (); - - if (halign < 0) { - x -= ff.width () * int (strlen (t)); - } else if (halign == 0) { - x -= ff.width () * int (strlen (t)) / 2; - } - - if (valign < 0) { - y += ff.height (); - } else if (valign == 0) { - y += ff.height () / 2; - } - - // TODO: simple implementation - for (; *t; ++t) { - - unsigned char ch = *t; - - if (x < -int (ff.width ()) || x >= int (mp_img->width ()) || y < 0 || y >= int (mp_img->height () + ff.height ())) { - continue; - } - - if (ch < ff.first_char () || (ch - ff.first_char ()) >= ff.n_chars ()) { - continue; - } - - const uint32_t *dc = ff.data () + size_t (ch - ff.first_char ()) * ff.height () * ff.stride (); - for (unsigned int i = 0; i < ff.height (); ++i, dc += ff.stride ()) { - - int iy = y - ff.height () + i + 1; - if (iy >= 0 || iy < mp_img->height ()) { - - uint32_t *d = (uint32_t *) mp_img->scanLine (y - ff.height () + i); - uint32_t m = 1; - int ix = x; - const uint32_t *ds = dc; - - for (unsigned int j = 0; j < ff.width (); ++j, ++ix) { - - if ((*ds & m) && ix >= 0 && ix < mp_img->width ()) { - d[ix] = c.rgb (); - } - - m <<= 1; - // word wrap - if (m == 0) { - ++ds; - m = 1; - } - - } - - } - - } - - x += ff.width (); - - } - - } - -private: - QImage *mp_img; - double m_resolution; - int m_width, m_height; -}; -#endif - -void +void GridNet::render_bg (const lay::Viewport &vp, ViewObjectCanvas &canvas) { if (m_visible) { @@ -377,12 +232,11 @@ GridNet::render_bg (const lay::Viewport &vp, ViewObjectCanvas &canvas) // TODO: currently, the grid net can only be rendered to a bitmap canvas .. BitmapViewObjectCanvas *bmp_canvas = dynamic_cast (&canvas); - if (! bmp_canvas) { + if (! bmp_canvas || ! bmp_canvas->bg_image ()) { return; } -#if defined(HAVE_QT) // @@@ - ImagePainter painter (*bmp_canvas); + PixelBufferPainter painter (*bmp_canvas->bg_image (), bmp_canvas->canvas_width (), bmp_canvas->canvas_height (), bmp_canvas->resolution ()); db::DCplxTrans trans = vp.trans (); db::DCplxTrans::inverse_trans trans_inv (trans.inverted ()); @@ -694,7 +548,6 @@ GridNet::render_bg (const lay::Viewport &vp, ViewObjectCanvas &canvas) } } -#endif } } diff --git a/src/laybasic/laybasic/layLayerTreeModel.cc b/src/laybasic/laybasic/layLayerTreeModel.cc index 5a3c09eea..e88941da6 100644 --- a/src/laybasic/laybasic/layLayerTreeModel.cc +++ b/src/laybasic/laybasic/layLayerTreeModel.cc @@ -523,7 +523,7 @@ LayerTreeModel::parent (const QModelIndex &index) const */ static void single_bitmap_to_image (const lay::ViewOp &view_op, lay::Bitmap &bitmap, - QImage *pimage, const lay::DitherPattern &dither_pattern, const lay::LineStyles &line_styles, + lay::PixelBuffer *pimage, const lay::DitherPattern &dither_pattern, const lay::LineStyles &line_styles, unsigned int width, unsigned int height) { std::vector view_ops; @@ -640,11 +640,12 @@ LayerTreeModel::icon_for_layer (const lay::LayerPropertiesConstIterator &iter, l lay::color_t fill_color = iter->has_fill_color (true) ? iter->eff_fill_color (true) : def_color; lay::color_t frame_color = iter->has_frame_color (true) ? iter->eff_frame_color (true) : def_color; - QImage image (w, h, QImage::Format_ARGB32); + lay::PixelBuffer image (w, h); + image.set_transparent (true); image.fill (view->background_color ().rgb ()); // upper scanline is a dummy one - uint32_t *sl0 = (uint32_t *) image.scanLine (0); + uint32_t *sl0 = (uint32_t *) image.scan_line (0); uint32_t transparent = QColor (Qt::transparent).rgba (); for (size_t i = 0; i < w; ++i) { *sl0++ = transparent; @@ -773,7 +774,7 @@ LayerTreeModel::icon_for_layer (const lay::LayerPropertiesConstIterator &iter, l // create vertex single_bitmap_to_image (lay::ViewOp (frame_color, mode, 0, 0, 0, lay::ViewOp::Cross, iter->marked (true) ? 9/*mark size*/ : 0), vertex, &image, view->dither_pattern (), view->line_styles (), w, h); - QPixmap pixmap = QPixmap::fromImage (image); // Qt 4.6.0 workaround + QPixmap pixmap = QPixmap::fromImage (image.to_image ()); // Qt 4.6.0 workaround return QIcon (pixmap); } diff --git a/src/laybasic/laybasic/layLayoutCanvas.cc b/src/laybasic/laybasic/layLayoutCanvas.cc index e13a125fb..7b4be5838 100644 --- a/src/laybasic/laybasic/layLayoutCanvas.cc +++ b/src/laybasic/laybasic/layLayoutCanvas.cc @@ -136,17 +136,16 @@ std::string ImageCacheEntry::to_string () const // ---------------------------------------------------------------------------- -#if defined(HAVE_QT) // @@@ static void -blowup (const QImage &src, QImage &dest, unsigned int os) +blowup (const lay::PixelBuffer &src, lay::PixelBuffer &dest, unsigned int os) { unsigned int ymax = src.height (); unsigned int xmax = src.width (); for (unsigned int y = 0; y < ymax; ++y) { for (unsigned int i = 0; i < os; ++i) { - const uint32_t *psrc = (const uint32_t *) src.scanLine (y); - uint32_t *pdest = (uint32_t *) dest.scanLine (y * os + i); + const uint32_t *psrc = (const uint32_t *) src.scan_line (y); + uint32_t *pdest = (uint32_t *) dest.scan_line (y * os + i); for (unsigned int x = 0; x < xmax; ++x) { for (unsigned int j = 0; j < os; ++j) { *pdest++ = *psrc; @@ -158,7 +157,7 @@ blowup (const QImage &src, QImage &dest, unsigned int os) } static void -subsample (const QImage &src, QImage &dest, unsigned int os, double g) +subsample (const lay::PixelBuffer &src, lay::PixelBuffer &dest, unsigned int os, double g) { // TODO: this is probably not compatible with the endianess of SPARC .. @@ -203,7 +202,7 @@ subsample (const QImage &src, QImage &dest, unsigned int os, double g) { - const unsigned char *psrc = src.scanLine (y * os); + const unsigned char *psrc = (const unsigned char *) src.scan_line (y * os); unsigned short *pdest = buffer; for (unsigned int x = 0; x < xmax; ++x) { @@ -230,7 +229,7 @@ subsample (const QImage &src, QImage &dest, unsigned int os, double g) for (unsigned int i = 1; i < os; ++i) { - const unsigned char *psrc = src.scanLine (y * os + i); + const unsigned char *psrc = (const unsigned char *) src.scan_line (y * os + i); unsigned short *pdest = buffer; for (unsigned int x = 0; x < xmax; ++x) { @@ -251,7 +250,7 @@ subsample (const QImage &src, QImage &dest, unsigned int os, double g) { - unsigned char *pdest = dest.scanLine (y); + unsigned char *pdest = (unsigned char *) dest.scan_line (y); const unsigned short *psrc = buffer; for (unsigned int x = 0; x < xmax; ++x) { @@ -279,9 +278,7 @@ invert (unsigned char *data, unsigned int width, unsigned int height) } } } -#endif -#if defined(HAVE_QT) // @@@ LayoutCanvas::LayoutCanvas (QWidget *parent, lay::LayoutViewBase *view, const char *name) : lay::ViewObjectWidget (parent, name), mp_view (view), @@ -296,25 +293,11 @@ LayoutCanvas::LayoutCanvas (QWidget *parent, lay::LayoutViewBase *view, const ch m_do_update_image_dm (this, &LayoutCanvas::do_update_image), m_do_end_of_drawing_dm (this, &LayoutCanvas::do_end_of_drawing), m_image_cache_size (1) -#else -LayoutCanvas::LayoutCanvas (lay::LayoutViewBase *view) - : lay::ViewObjectWidget (), - mp_view (view), -// @@@ mp_image (0), mp_image_bg (0), mp_pixmap (0), - m_background (0), m_foreground (0), m_active (0), - m_oversampling (1), - m_dpr (1), - m_need_redraw (false), - m_redraw_clearing (false), - m_redraw_force_update (true), - m_update_image (true), - m_do_update_image_dm (this, &LayoutCanvas::do_update_image), - m_do_end_of_drawing_dm (this, &LayoutCanvas::do_end_of_drawing), - m_image_cache_size (1) -#endif { +#if defined(HAVE_QT) #if QT_VERSION > 0x050000 m_dpr = devicePixelRatio (); +#endif #endif // The gamma value used for subsampling: something between 1.8 and 2.2. @@ -326,12 +309,14 @@ LayoutCanvas::LayoutCanvas (lay::LayoutViewBase *view) mp_redraw_thread = new lay::RedrawThread (this, view); -#if defined(HAVE_QT) // @@@ +#if defined(HAVE_QT) setBackgroundRole (QPalette::NoRole); set_colors (lay::Color (palette ().color (QPalette::Normal, QPalette::Window).rgb ()), lay::Color (palette ().color (QPalette::Normal, QPalette::Text).rgb ()), lay::Color (palette ().color (QPalette::Normal, QPalette::Mid).rgb ())); setAttribute (Qt::WA_NoSystemBackground); +#else + set_colors (0xffffffff, 0xff000000, 0xffc0c0c0); #endif } @@ -340,7 +325,6 @@ LayoutCanvas::~LayoutCanvas () // Detach all listeners so we don't trigger events in the destructor viewport_changed_event.clear (); -#if defined(HAVE_QT) // @@@ if (mp_image) { delete mp_image; mp_image = 0; @@ -349,6 +333,7 @@ LayoutCanvas::~LayoutCanvas () delete mp_image_bg; mp_image_bg = 0; } +#if defined(HAVE_QT) if (mp_pixmap) { delete mp_pixmap; mp_pixmap = 0; @@ -415,12 +400,10 @@ LayoutCanvas::set_colors (lay::Color background, lay::Color foreground, lay::Col m_active = active.rgb (); // force regeneration of background image .. -#if defined(HAVE_QT) // @@@ if (mp_image_bg) { delete mp_image_bg; } mp_image_bg = 0; -#endif update_image (); } @@ -459,17 +442,13 @@ LayoutCanvas::prepare_drawing () BitmapViewObjectCanvas::set_size (m_viewport_l.width (), m_viewport_l.height (), 1.0 / double (m_oversampling * m_dpr)); -#if defined(HAVE_QT) // @@@ if (! mp_image || (unsigned int) mp_image->width () != m_viewport_l.width () || (unsigned int) mp_image->height () != m_viewport_l.height ()) { if (mp_image) { delete mp_image; } - mp_image = new QImage (m_viewport_l.width (), m_viewport_l.height (), QImage::Format_RGB32); -#if QT_VERSION > 0x050000 - mp_image->setDevicePixelRatio (double (m_dpr)); -#endif + mp_image = new lay::PixelBuffer (m_viewport_l.width (), m_viewport_l.height ()); if (mp_pixmap) { delete mp_pixmap; mp_pixmap = 0; @@ -477,7 +456,6 @@ LayoutCanvas::prepare_drawing () } mp_image->fill (m_background); -#endif // Cancel any pending "finish" event so there is no race between finish and restart (important for caching) m_do_end_of_drawing_dm.cancel (); @@ -613,7 +591,7 @@ LayoutCanvas::paintEvent (QPaintEvent *) if (mp_image_bg) { delete mp_image_bg; } - mp_image_bg = new QImage (*mp_image); + mp_image_bg = new lay::PixelBuffer (*mp_image); } else { // else reuse the saved image @@ -636,8 +614,8 @@ LayoutCanvas::paintEvent (QPaintEvent *) // and static foreground objects if (! mp_pixmap || needs_update_static () || - mp_image->size ().width () != mp_pixmap->size ().width () * int (m_oversampling) || - mp_image->size ().height () != mp_pixmap->size ().height () * int (m_oversampling)) { + int (mp_image->width ()) != mp_pixmap->size ().width () * int (m_oversampling) || + int (mp_image->height ()) != mp_pixmap->size ().height () * int (m_oversampling)) { if (mp_pixmap) { delete mp_pixmap; @@ -650,36 +628,45 @@ LayoutCanvas::paintEvent (QPaintEvent *) if (fg_bitmaps () > 0) { - QImage full_image (*mp_image); -#if QT_VERSION > 0x050000 - full_image.setDevicePixelRatio (double (m_dpr)); -#endif + lay::PixelBuffer full_image (*mp_image); bitmaps_to_image (fg_view_op_vector (), fg_bitmap_vector (), dither_pattern (), line_styles (), &full_image, m_viewport_l.width (), m_viewport_l.height (), false, &m_mutex); // render the foreground parts .. if (m_oversampling == 1) { - *mp_pixmap = QPixmap::fromImage (full_image); // Qt 4.6.0 workaround - } else { - QImage subsampled_image (m_viewport.width (), m_viewport.height (), mp_image->format ()); + QImage img = full_image.to_image (); #if QT_VERSION > 0x050000 - subsampled_image.setDevicePixelRatio (double (m_dpr)); + img.setDevicePixelRatio (double (m_dpr)); #endif + *mp_pixmap = QPixmap::fromImage (img); // Qt 4.6.0 workaround + } else { + lay::PixelBuffer subsampled_image (m_viewport.width (), m_viewport.height ()); + subsampled_image.set_transparent (mp_image->transparent ()); subsample (full_image, subsampled_image, m_oversampling, m_gamma); - *mp_pixmap = QPixmap::fromImage (subsampled_image); // Qt 4.6.0 workaround + QImage img = subsampled_image.to_image (); +#if QT_VERSION > 0x050000 + img.setDevicePixelRatio (double (m_dpr)); +#endif + *mp_pixmap = QPixmap::fromImage (img); // Qt 4.6.0 workaround } } else if (m_oversampling == 1) { - *mp_pixmap = QPixmap::fromImage (*mp_image); + QImage img = mp_image->to_image (); +#if QT_VERSION > 0x050000 + img.setDevicePixelRatio (double (m_dpr)); +#endif + *mp_pixmap = QPixmap::fromImage (img); } else { - QImage subsampled_image (m_viewport.width (), m_viewport.height (), mp_image->format ()); -#if QT_VERSION > 0x050000 - subsampled_image.setDevicePixelRatio (double (m_dpr)); -#endif + lay::PixelBuffer subsampled_image (m_viewport.width (), m_viewport.height ()); + subsampled_image.set_transparent (mp_image->transparent ()); subsample (*mp_image, subsampled_image, m_oversampling, m_gamma); - *mp_pixmap = QPixmap::fromImage (subsampled_image); + QImage img = subsampled_image.to_image (); +#if QT_VERSION > 0x050000 + img.setDevicePixelRatio (double (m_dpr)); +#endif + *mp_pixmap = QPixmap::fromImage (img); } @@ -697,24 +684,28 @@ LayoutCanvas::paintEvent (QPaintEvent *) if (fg_bitmaps () > 0) { - QImage full_image (mp_image->size ().width (), mp_image->size ().height (), QImage::Format_ARGB32); + lay::PixelBuffer full_image (mp_image->width (), mp_image->height ()); + full_image.set_transparent (true); full_image.fill (0); -#if QT_VERSION > 0x050000 - full_image.setDevicePixelRatio (double (m_dpr)); -#endif bitmaps_to_image (fg_view_op_vector (), fg_bitmap_vector (), dither_pattern (), line_styles (), &full_image, m_viewport_l.width (), m_viewport_l.height (), false, &m_mutex); // render the foreground parts .. if (m_oversampling == 1) { - painter.drawPixmap (QPoint (0, 0), QPixmap::fromImage (full_image)); - } else { - QImage subsampled_image (m_viewport.width (), m_viewport.height (), QImage::Format_ARGB32); + QImage img = full_image.to_image (); #if QT_VERSION > 0x050000 - subsampled_image.setDevicePixelRatio (double (m_dpr)); + img.setDevicePixelRatio (double (m_dpr)); #endif + painter.drawPixmap (QPoint (0, 0), QPixmap::fromImage (img)); + } else { + lay::PixelBuffer subsampled_image (m_viewport.width (), m_viewport.height ()); + subsampled_image.set_transparent (true); subsample (full_image, subsampled_image, m_oversampling, m_gamma); - painter.drawPixmap (QPoint (0, 0), QPixmap::fromImage (subsampled_image)); + QImage img = subsampled_image.to_image (); +#if QT_VERSION > 0x050000 + img.setDevicePixelRatio (double (m_dpr)); +#endif + painter.drawPixmap (QPoint (0, 0), QPixmap::fromImage (img)); } } @@ -731,20 +722,20 @@ LayoutCanvas::paintEvent (QPaintEvent *) } #endif -#if defined(HAVE_QT) // @@@ class DetachedViewObjectCanvas : public BitmapViewObjectCanvas { public: - DetachedViewObjectCanvas (lay::Color bg, lay::Color fg, lay::Color ac, unsigned int width_l, unsigned int height_l, double resolution, QImage *img) + DetachedViewObjectCanvas (lay::Color bg, lay::Color fg, lay::Color ac, unsigned int width_l, unsigned int height_l, double resolution, lay::PixelBuffer *img) : BitmapViewObjectCanvas (width_l, height_l, resolution), m_bg (bg), m_fg (fg), m_ac (ac), mp_image (img) { // TODO: Good choice? m_gamma = 2.0; - if (img->width () != int (width_l) || img->height () != int (height_l)) { - mp_image_l = new QImage (width_l, height_l, img->format ()); + if (img->width () != width_l || img->height () != height_l) { + mp_image_l = new lay::PixelBuffer (width_l, height_l); + mp_image_l->set_transparent (img->transparent ()); mp_image_l->fill (bg.rgb ()); } else { mp_image_l = 0; @@ -776,9 +767,9 @@ public: return m_ac; } - virtual QImage &bg_image () + virtual lay::PixelBuffer *bg_image () { - return mp_image_l ? *mp_image_l : *mp_image; + return mp_image_l ? mp_image_l : mp_image; } void transfer_to_image (const lay::DitherPattern &dp, const lay::LineStyles &ls, unsigned int width, unsigned int height) @@ -804,23 +795,61 @@ public: private: lay::Color m_bg, m_fg, m_ac; - QImage *mp_image; - QImage *mp_image_l; + lay::PixelBuffer *mp_image; + lay::PixelBuffer *mp_image_l; double m_gamma; }; -#endif -#if defined(HAVE_QT) // @@@ -QImage +/** + * @brief A simplistic monochrome canvas + * + * NOTE: this canvas does not support background painting (currently the background objects + * do not support monochrome background painting anyway). + * Nor does it support subsampling (that would mean grayscale). + */ +class DetachedViewObjectCanvasMono + : public BitmapViewObjectCanvas +{ +public: + DetachedViewObjectCanvasMono (bool bg, bool fg, bool ac, unsigned int width, unsigned int height) + : BitmapViewObjectCanvas (width, height, 1.0), + m_bg (bg), m_fg (fg), m_ac (ac) + { + // .. nothing yet .. + } + + ~DetachedViewObjectCanvasMono () + { + clear_fg_bitmaps (); + } + + lay::Color background_color () const + { + return m_bg ? 0xffffffff : 0; + } + + lay::Color foreground_color () const + { + return m_fg ? 0xffffffff : 0; + } + + lay::Color active_color () const + { + return m_ac ? 0xffffffff : 0; + } + +private: + bool m_bg, m_fg, m_ac; +}; + +lay::PixelBuffer LayoutCanvas::image (unsigned int width, unsigned int height) { - return image_with_options (width, height, -1, -1, -1.0, lay::Color (), lay::Color (), lay::Color (), db::DBox (), false); + return image_with_options (width, height, -1, -1, -1.0, lay::Color (), lay::Color (), lay::Color (), db::DBox ()); } -#endif -#if defined(HAVE_QT) // @@@ -QImage -LayoutCanvas::image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, lay::Color background, lay::Color foreground, lay::Color active, const db::DBox &target_box, bool is_mono) +lay::PixelBuffer +LayoutCanvas::image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, lay::Color background, lay::Color foreground, lay::Color active, const db::DBox &target_box) { if (oversampling <= 0) { oversampling = m_oversampling; @@ -842,19 +871,14 @@ LayoutCanvas::image_with_options (unsigned int width, unsigned int height, int l } // TODO: for other architectures MonoLSB may not be the right format - QImage img (width, height, is_mono ? QImage::Format_MonoLSB : QImage::Format_RGB32); + lay::PixelBuffer img (width, height); // this may happen for BIG images: - if (img.width () != int (width) || img.height () != int (height)) { - throw tl::Exception (tl::to_string (QObject::tr ("Unable to create an image with size %dx%d pixels")), width, height); + if (img.width () != width || img.height () != height) { + throw tl::Exception (tl::to_string (tr ("Unable to create an image with size %dx%d pixels")), width, height); } - if (is_mono) { - // in mono mode the background's color is white for green > 128 and black otherwise - img.fill ((background.rgb () & 0x8000) >> 15); - } else { - img.fill (background.rgb ()); - } + img.fill (background.rgb ()); // provide canvas objects for the layout bitmaps and the foreground/background objects BitmapRedrawThreadCanvas rd_canvas; @@ -882,43 +906,71 @@ LayoutCanvas::image_with_options (unsigned int width, unsigned int height, int l redraw_thread.stop (); // safety // paint the background objects. It uses "img" to paint on. - if (! is_mono) { + do_render_bg (vp, vo_canvas); - do_render_bg (vp, vo_canvas); + // paint the layout bitmaps + rd_canvas.to_image (view_ops, dither_pattern (), line_styles (), background, foreground, active, this, *vo_canvas.bg_image (), vp.width (), vp.height ()); - // paint the layout bitmaps - rd_canvas.to_image (view_ops, dither_pattern (), line_styles (), background, foreground, active, this, vo_canvas.bg_image (), vp.width (), vp.height ()); + // subsample current image to provide the background for the foreground objects + vo_canvas.make_background (); - // subsample current image to provide the background for the foreground objects - vo_canvas.make_background (); + // render the foreground parts .. + do_render (vp, vo_canvas, true); + vo_canvas.transfer_to_image (dither_pattern (), line_styles (), width, height); - // render the foreground parts .. - do_render (vp, vo_canvas, true); - vo_canvas.transfer_to_image (dither_pattern (), line_styles (), width, height); - - do_render (vp, vo_canvas, false); - vo_canvas.transfer_to_image (dither_pattern (), line_styles (), width, height); - - } else { - - // TODO: Painting of background objects??? - // paint the layout bitmaps - rd_canvas.to_image (view_ops, dither_pattern (), line_styles (), background, foreground, active, this, vo_canvas.bg_image (), vp.width (), vp.height ()); - - } + do_render (vp, vo_canvas, false); + vo_canvas.transfer_to_image (dither_pattern (), line_styles (), width, height); return img; } -#endif -#if defined(HAVE_QT) // @@@ -QImage +lay::BitmapBuffer +LayoutCanvas::image_with_options_mono (unsigned int width, unsigned int height, int linewidth, bool background, bool foreground, bool active, const db::DBox &target_box) +{ + if (linewidth <= 0) { + linewidth = 1; + } + + // provide canvas objects for the layout bitmaps and the foreground/background objects + BitmapRedrawThreadCanvas rd_canvas; + DetachedViewObjectCanvasMono vo_canvas (background, foreground, active, width, height); + + // compute the new viewport + db::DBox tb (target_box); + if (tb.empty ()) { + tb = m_viewport.target_box (); + } + Viewport vp (width, height, tb); + vp.set_global_trans (m_viewport.global_trans ()); + + std::vector view_ops (m_view_ops); + if (linewidth > 1) { + for (std::vector::iterator vo = view_ops.begin (); vo != view_ops.end (); ++vo) { + vo->width (std::min (31, vo->width () * linewidth)); + } + } + + lay::RedrawThread redraw_thread (&rd_canvas, mp_view); + + // render the layout + redraw_thread.start (0 /*synchronous*/, m_layers, vp, 1.0, true); + redraw_thread.stop (); // safety + + lay::BitmapBuffer img (width, height); + img.fill (background); + + rd_canvas.to_image_mono (view_ops, dither_pattern (), line_styles (), background, foreground, active, this, img, vp.width (), vp.height ()); + + return img; +} + +lay::PixelBuffer LayoutCanvas::screenshot () { // if required, start the redraw thread .. prepare_drawing (); - QImage img (m_viewport.width (), m_viewport.height (), QImage::Format_RGB32); + lay::PixelBuffer img (m_viewport.width (), m_viewport.height ()); img.fill (m_background); DetachedViewObjectCanvas vo_canvas (background_color (), foreground_color (), active_color (), m_viewport_l.width (), m_viewport_l.height (), 1.0 / double (m_oversampling * m_dpr), &img); @@ -927,7 +979,7 @@ LayoutCanvas::screenshot () do_render_bg (m_viewport_l, vo_canvas); // paint the layout bitmaps - to_image (m_view_ops, dither_pattern (), line_styles (), background_color (), foreground_color (), active_color (), this, vo_canvas.bg_image (), m_viewport_l.width (), m_viewport_l.height ()); + to_image (m_view_ops, dither_pattern (), line_styles (), background_color (), foreground_color (), active_color (), this, *vo_canvas.bg_image (), m_viewport_l.width (), m_viewport_l.height ()); // subsample current image to provide the background for the foreground objects vo_canvas.make_background (); @@ -941,7 +993,6 @@ LayoutCanvas::screenshot () return img; } -#endif #if defined(HAVE_QT) void @@ -1036,7 +1087,7 @@ LayoutCanvas::event (QEvent *e) // GTF probe event // record the contents (the screenshot) as ASCII text if (gtf::Recorder::instance () && gtf::Recorder::instance ()->recording ()) { - gtf::Recorder::instance ()->probe (this, gtf::image_to_variant (screenshot ())); + gtf::Recorder::instance ()->probe (this, gtf::image_to_variant (screenshot ().to_image_copy ())); } e->accept (); diff --git a/src/laybasic/laybasic/layLayoutCanvas.h b/src/laybasic/laybasic/layLayoutCanvas.h index c4a8fb8c4..2ce31f095 100644 --- a/src/laybasic/laybasic/layLayoutCanvas.h +++ b/src/laybasic/laybasic/layLayoutCanvas.h @@ -170,11 +170,10 @@ public: return m_view_ops; } -#if defined(HAVE_QT) // @@@ - QImage screenshot (); - QImage image (unsigned int width, unsigned int height); - QImage image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, lay::Color background, lay::Color foreground, lay::Color active_color, const db::DBox &target_box, bool monochrome); -#endif + lay::PixelBuffer screenshot (); + lay::PixelBuffer image (unsigned int width, unsigned int height); + lay::PixelBuffer image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, lay::Color background, lay::Color foreground, lay::Color active_color, const db::DBox &target_box); + lay::BitmapBuffer image_with_options_mono (unsigned int width, unsigned int height, int linewidth, bool background, bool foreground, bool active_color, const db::DBox &target_box); void update_image (); @@ -316,15 +315,13 @@ public: return lay::Color (m_active); } -#if defined(HAVE_QT) // @@@ /** * @brief Reimplementation of ViewObjectCanvas: background image */ - QImage &bg_image () + lay::PixelBuffer *bg_image () { - return *mp_image; + return mp_image; } -#endif /** * @brief Reimplementation of RedrawThreadCanvas: signal end of drawing @@ -362,9 +359,9 @@ public: private: lay::LayoutViewBase *mp_view; + lay::PixelBuffer *mp_image; + lay::PixelBuffer *mp_image_bg; #if defined(HAVE_QT) // @@@ - QImage *mp_image; - QImage *mp_image_bg; QPixmap *mp_pixmap; #endif db::DBox m_precious_box; diff --git a/src/laybasic/laybasic/layLayoutViewBase.cc b/src/laybasic/laybasic/layLayoutViewBase.cc index 413204547..05b8a89e6 100644 --- a/src/laybasic/laybasic/layLayoutViewBase.cc +++ b/src/laybasic/laybasic/layLayoutViewBase.cc @@ -2452,7 +2452,7 @@ LayoutViewBase::init_layer_properties (LayerProperties &p, const LayerProperties p.set_marked (false); } -#if defined(HAVE_QT) +#if defined(HAVE_QT) // @@@ add methods without QImage!!!! QImage LayoutViewBase::get_screenshot () { @@ -2461,7 +2461,7 @@ LayoutViewBase::get_screenshot () // Execute all deferred methods - ensure there are no pending tasks tl::DeferredMethodScheduler::execute (); - return mp_canvas->screenshot (); + return mp_canvas->screenshot ().to_image_copy (); } void @@ -2491,7 +2491,7 @@ LayoutViewBase::save_screenshot (const std::string &fn) // Execute all deferred methods - ensure there are no pending tasks tl::DeferredMethodScheduler::execute (); - if (! writer.write (mp_canvas->screenshot ())) { + if (! writer.write (mp_canvas->screenshot ().to_image ())) { throw tl::Exception (tl::to_string (QObject::tr ("Unable to write screenshot to file: %s (%s)")), fn, tl::to_string (writer.errorString ())); } @@ -2506,19 +2506,23 @@ LayoutViewBase::get_image (unsigned int width, unsigned int height) // Execute all deferred methods - ensure there are no pending tasks tl::DeferredMethodScheduler::execute (); - return mp_canvas->image (width, height); + return mp_canvas->image (width, height).to_image_copy (); } QImage LayoutViewBase::get_image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, - lay::Color background, lay::Color foreground, lay::Color active, const db::DBox &target_box, bool monochrome) + lay::Color background, lay::Color foreground, lay::Color active, const db::DBox &target_box, bool monochrome) { tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Save image"))); // Execute all deferred methods - ensure there are no pending tasks tl::DeferredMethodScheduler::execute (); - return mp_canvas->image_with_options (width, height, linewidth, oversampling, resolution, background, foreground, active, target_box, monochrome); + if (monochrome) { + return mp_canvas->image_with_options_mono (width, height, linewidth, background.green () >= 128, foreground.green () >= 128, active.green () >= 128, target_box).to_image_copy (); + } else { + return mp_canvas->image_with_options (width, height, linewidth, oversampling, resolution, background, foreground, active, target_box).to_image_copy (); + } } void @@ -2544,7 +2548,7 @@ LayoutViewBase::save_image (const std::string &fn, unsigned int width, unsigned // Execute all deferred methods - ensure there are no pending tasks tl::DeferredMethodScheduler::execute (); - if (! writer.write (mp_canvas->image (width, height))) { + if (! writer.write (mp_canvas->image (width, height).to_image ())) { throw tl::Exception (tl::to_string (QObject::tr ("Unable to write screenshot to file: %s (%s)")), fn, tl::to_string (writer.errorString ())); } @@ -2575,9 +2579,15 @@ LayoutViewBase::save_image_with_options (const std::string &fn, // Execute all deferred methods - ensure there are no pending tasks tl::DeferredMethodScheduler::execute (); - - if (! writer.write (mp_canvas->image_with_options (width, height, linewidth, oversampling, resolution, background, foreground, active, target_box, monochrome))) { - throw tl::Exception (tl::to_string (QObject::tr ("Unable to write screenshot to file: %s (%s)")), fn, tl::to_string (writer.errorString ())); + + if (monochrome) { + if (! writer.write (mp_canvas->image_with_options_mono (width, height, linewidth, background.green () >= 128, foreground.green () >= 128, active.green () >= 128, target_box).to_image ())) { + throw tl::Exception (tl::to_string (QObject::tr ("Unable to write screenshot to file: %s (%s)")), fn, tl::to_string (writer.errorString ())); + } + } else { + if (! writer.write (mp_canvas->image_with_options (width, height, linewidth, oversampling, resolution, background, foreground, active, target_box).to_image ())) { + throw tl::Exception (tl::to_string (QObject::tr ("Unable to write screenshot to file: %s (%s)")), fn, tl::to_string (writer.errorString ())); + } } tl::log << "Saved screen shot to " << fn; @@ -2741,7 +2751,6 @@ LayoutViewBase::reload_layout (unsigned int cv_index) set_properties (new_props); goto_view (state); - } unsigned int diff --git a/src/laybasic/laybasic/layPixelBufferPainter.cc b/src/laybasic/laybasic/layPixelBufferPainter.cc new file mode 100644 index 000000000..068c2968e --- /dev/null +++ b/src/laybasic/laybasic/layPixelBufferPainter.cc @@ -0,0 +1,171 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 "layPixelBufferPainter.h" + +#include "layFixedFont.h" +#include "layPixelBuffer.h" + +namespace lay +{ + +PixelBufferPainter::PixelBufferPainter (lay::PixelBuffer &img, unsigned int width, unsigned int height, double resolution) + : mp_img (&img), + m_resolution (resolution), m_width (width), m_height (height) +{ + // .. nothing yet .. +} + +void +PixelBufferPainter::set (const db::Point &p, lay::Color c) +{ + if (p.x () >= 0 && p.x () < m_width && p.y () >= 0 && p.y () < m_height) { + ((unsigned int *) mp_img->scan_line (p.y ())) [p.x ()] = c.rgb (); + } +} + +void +PixelBufferPainter::draw_line (const db::Point &p1, const db::Point &p2, lay::Color c) +{ + if (p1.x () == p2.x ()) { + + int x = p1.x (); + int y1 = std::min (p1.y (), p2.y ()); + int y2 = std::max (p1.y (), p2.y ()); + if ((y2 >= 0 || y1 < m_height) && x >= 0 && x < m_width) { + y1 = std::max (y1, 0); + y2 = std::min (y2, m_height - 1); + for (int y = y1; y <= y2; ++y) { + ((unsigned int *) mp_img->scan_line (y)) [x] = c.rgb (); + } + } + + } else if (p1.y () == p2.y ()) { + + int y = p1.y (); + int x1 = std::min (p1.x (), p2.x ()); + int x2 = std::max (p1.x (), p2.x ()); + if ((x2 >= 0 || x1 < m_width) && y >= 0 && y < m_height) { + x1 = std::max (x1, 0); + x2 = std::min (x2, m_width - 1); + unsigned int *sl = (unsigned int *) mp_img->scan_line (y) + x1; + for (int x = x1; x <= x2; ++x) { + *sl++ = c.rgb (); + } + } + + } else { + // TODO: not implemented yet. + } +} + +void +PixelBufferPainter::fill_rect (const db::Point &p1, const db::Point &p2, lay::Color c) +{ + int y1 = std::min (p1.y (), p2.y ()); + int y2 = std::max (p1.y (), p2.y ()); + for (int y = y1; y <= y2; ++y) { + draw_line (db::Point (p1.x (), y), db::Point (p2.x (), y), c); + } +} + +void +PixelBufferPainter::draw_rect (const db::Point &p1, const db::Point &p2, lay::Color c) +{ + int y1 = std::min (p1.y (), p2.y ()); + int y2 = std::max (p1.y (), p2.y ()); + int x1 = std::min (p1.x (), p2.x ()); + int x2 = std::max (p1.x (), p2.x ()); + draw_line (db::Point (x1, y1), db::Point (x2, y1), c); + draw_line (db::Point (x1, y2), db::Point (x2, y2), c); + draw_line (db::Point (x1, y1), db::Point (x1, y2), c); + draw_line (db::Point (x2, y1), db::Point (x2, y2), c); +} + +void +PixelBufferPainter::draw_text (const char *t, const db::Point &p, lay::Color c, int halign, int valign) +{ + const lay::FixedFont &ff = lay::FixedFont::get_font (m_resolution); + int x = p.x (), y = p.y (); + + if (halign < 0) { + x -= ff.width () * int (strlen (t)); + } else if (halign == 0) { + x -= ff.width () * int (strlen (t)) / 2; + } + + if (valign < 0) { + y += ff.height (); + } else if (valign == 0) { + y += ff.height () / 2; + } + + // TODO: simple implementation + for (; *t; ++t) { + + unsigned char ch = *t; + + if (x < -int (ff.width ()) || x >= int (mp_img->width ()) || y < 0 || y >= int (mp_img->height () + ff.height ())) { + continue; + } + + if (ch < ff.first_char () || (ch - ff.first_char ()) >= ff.n_chars ()) { + continue; + } + + const uint32_t *dc = ff.data () + size_t (ch - ff.first_char ()) * ff.height () * ff.stride (); + for (unsigned int i = 0; i < ff.height (); ++i, dc += ff.stride ()) { + + int iy = y - ff.height () + i + 1; + if (iy >= 0 || iy < int (mp_img->height ())) { + + uint32_t *d = (uint32_t *) mp_img->scan_line (y - ff.height () + i); + uint32_t m = 1; + int ix = x; + const uint32_t *ds = dc; + + for (unsigned int j = 0; j < ff.width (); ++j, ++ix) { + + if ((*ds & m) && ix >= 0 && ix < int (mp_img->width ())) { + d[ix] = c.rgb (); + } + + m <<= 1; + // word wrap + if (m == 0) { + ++ds; + m = 1; + } + + } + + } + + } + + x += ff.width (); + + } + +} + +} diff --git a/src/laybasic/laybasic/layPixelBufferPainter.h b/src/laybasic/laybasic/layPixelBufferPainter.h new file mode 100644 index 000000000..45da9d309 --- /dev/null +++ b/src/laybasic/laybasic/layPixelBufferPainter.h @@ -0,0 +1,61 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 + +*/ + +#ifndef HDR_layPixelBufferPainter +#define HDR_layPixelBufferPainter + +#include "laybasicCommon.h" + +#include "layColor.h" +#include "dbPoint.h" + +namespace lay { + +class PixelBuffer; + +/** + * @brief A very simplistic painter for lay::PixelBuffer + * + * This painter supports very few primitives currently and is used to paint the + * background grid for example. + */ +class LAYBASIC_PUBLIC PixelBufferPainter +{ +public: + PixelBufferPainter (lay::PixelBuffer &img, unsigned int width, unsigned int height, double resolution); + + void set (const db::Point &p, lay::Color c); + void draw_line (const db::Point &p1, const db::Point &p2, lay::Color c); + void fill_rect (const db::Point &p1, const db::Point &p2, lay::Color c); + void draw_rect (const db::Point &p1, const db::Point &p2, lay::Color c); + void draw_text (const char *t, const db::Point &p, lay::Color c, int halign, int valign); + +private: + lay::PixelBuffer *mp_img; + double m_resolution; + int m_width, m_height; +}; + +} + +#endif + diff --git a/src/laybasic/laybasic/layRedrawThreadCanvas.cc b/src/laybasic/laybasic/layRedrawThreadCanvas.cc index e47eb19ab..9b72833b7 100644 --- a/src/laybasic/laybasic/layRedrawThreadCanvas.cc +++ b/src/laybasic/laybasic/layRedrawThreadCanvas.cc @@ -23,16 +23,10 @@ #include "layRedrawThreadCanvas.h" #include "layCanvasPlane.h" -#if defined(HAVE_QT) #include "layBitmapsToImage.h" -#endif #include "layDrawing.h" #include "layBitmap.h" -#if defined(HAVE_QT) // @@@ -#include -#endif - namespace lay { @@ -397,9 +391,8 @@ BitmapRedrawThreadCanvas::initialize_plane (lay::CanvasPlane *plane, unsigned in unlock (); } -#if defined(HAVE_QT) // @@@ -void -BitmapRedrawThreadCanvas::to_image (const std::vector &view_ops, const lay::DitherPattern &dp, const lay::LineStyles &ls, lay::Color background, lay::Color foreground, lay::Color active, const lay::Drawings *drawings, QImage &img, unsigned int width, unsigned int height) +void +BitmapRedrawThreadCanvas::to_image (const std::vector &view_ops, const lay::DitherPattern &dp, const lay::LineStyles &ls, lay::Color background, lay::Color foreground, lay::Color active, const lay::Drawings *drawings, lay::PixelBuffer &img, unsigned int width, unsigned int height) { if (width > m_width) { width = m_width; @@ -417,7 +410,27 @@ BitmapRedrawThreadCanvas::to_image (const std::vector &view_ops, c bitmaps_to_image (d->get_view_ops (*this, background, foreground, active), *bt, dp, ls, &img, width, height, true, &mutex ()); } } -#endif +void +BitmapRedrawThreadCanvas::to_image_mono (const std::vector &view_ops, const lay::DitherPattern &dp, const lay::LineStyles &ls, bool background, bool foreground, bool active, const lay::Drawings *drawings, lay::BitmapBuffer &img, unsigned int width, unsigned int height) +{ + if (width > m_width) { + width = m_width; + } + if (height > m_height) { + height = m_height; + } + + unsigned int all_one = 0xffffffff; + + // convert the plane data to image data + bitmaps_to_image (view_ops, mp_plane_buffers, dp, ls, &img, width, height, true, &mutex ()); + + // convert the planes of the "drawing" objects too: + std::vector >::const_iterator bt = mp_drawing_plane_buffers.begin (); + for (lay::Drawings::const_iterator d = drawings->begin (); d != drawings->end () && bt != mp_drawing_plane_buffers.end (); ++d, ++bt) { + bitmaps_to_image (d->get_view_ops (*this, background ? all_one : 0, foreground ? all_one : 0, active ? all_one : 0), *bt, dp, ls, &img, width, height, true, &mutex ()); + } } +} diff --git a/src/laybasic/laybasic/layRedrawThreadCanvas.h b/src/laybasic/laybasic/layRedrawThreadCanvas.h index b231aa557..77614c628 100644 --- a/src/laybasic/laybasic/layRedrawThreadCanvas.h +++ b/src/laybasic/laybasic/layRedrawThreadCanvas.h @@ -29,6 +29,7 @@ #include "dbTrans.h" #include "layViewOp.h" #include "layBitmapRenderer.h" +#include "layPixelBuffer.h" #include "tlThreads.h" #include @@ -315,12 +316,15 @@ public: return new lay::BitmapRenderer (m_width, m_height, resolution ()); } -#if defined(HAVE_QT) // @@@ /** - * @brief Transfer the content to an QImage + * @brief Transfer the content to a PixelBuffer */ - void to_image (const std::vector &view_ops, const lay::DitherPattern &dp, const lay::LineStyles &ls, lay::Color background, lay::Color foreground, lay::Color active, const lay::Drawings *drawings, QImage &img, unsigned int width, unsigned int height); -#endif + void to_image (const std::vector &view_ops, const lay::DitherPattern &dp, const lay::LineStyles &ls, lay::Color background, lay::Color foreground, lay::Color active, const lay::Drawings *drawings, PixelBuffer &img, unsigned int width, unsigned int height); + + /** + * @brief Transfer the content to a BitmapBuffer (monochrome) + */ + void to_image_mono (const std::vector &view_ops, const lay::DitherPattern &dp, const lay::LineStyles &ls, bool background, bool foreground, bool active, const lay::Drawings *drawings, lay::BitmapBuffer &img, unsigned int width, unsigned int height); /** * @brief Gets the current bitmap data as a BitmapCanvasData object diff --git a/src/laybasic/laybasic/layViewObject.cc b/src/laybasic/laybasic/layViewObject.cc index 564353267..528b3e689 100644 --- a/src/laybasic/laybasic/layViewObject.cc +++ b/src/laybasic/laybasic/layViewObject.cc @@ -1244,5 +1244,18 @@ BitmapViewObjectCanvas::set_size (double resolution) m_resolution = resolution; } +lay::PixelBuffer * +BitmapViewObjectCanvas::bg_image () +{ + return 0; +} + +lay::BitmapBuffer * +BitmapViewObjectCanvas::bg_bitmap () +{ + return 0; +} + + } diff --git a/src/laybasic/laybasic/layViewObject.h b/src/laybasic/laybasic/layViewObject.h index 38e84f5c1..bd1350dff 100644 --- a/src/laybasic/laybasic/layViewObject.h +++ b/src/laybasic/laybasic/layViewObject.h @@ -70,6 +70,8 @@ class ViewObjectWidget; class ViewObjectCanvas; class CanvasPlane; class Bitmap; +class PixelBuffer; +class BitmapBuffer; LAYBASIC_PUBLIC const char *drag_drop_mime_type (); @@ -1350,13 +1352,6 @@ public: */ void clear_fg_bitmaps (); -#if defined(HAVE_QT) // @@@ - /** - * @brief Return the background image - */ - virtual QImage &bg_image () = 0; -#endif - /** * @brief Set the width and height and resolution */ @@ -1388,6 +1383,16 @@ public: return m_height; } + /** + * @brief Gets the pixel buffer that background objects render to + */ + virtual lay::PixelBuffer *bg_image (); + + /** + * @brief Gets the monochrome pixel buffer that background objects render to + */ + virtual lay::BitmapBuffer *bg_bitmap (); + private: std::map m_fg_bitmap_table; std::map , unsigned int> m_fgv_bitmap_table; diff --git a/src/laybasic/laybasic/laybasic.pro b/src/laybasic/laybasic/laybasic.pro index bae8ac5e4..c542dca47 100644 --- a/src/laybasic/laybasic/laybasic.pro +++ b/src/laybasic/laybasic/laybasic.pro @@ -138,7 +138,8 @@ DEFINES += MAKE_LAYBASIC_LIBRARY layNetlistBrowserPage.cc \ layNetlistBrowserTreeModel.cc \ layNetlistCrossReferenceModel.cc \ - layPixelBuffer.cc \ + layPixelBuffer.cc \ + layPixelBufferPainter.cc \ layPluginConfigPage.cc \ layProperties.cc \ layPropertiesDialog.cc \ @@ -212,7 +213,8 @@ DEFINES += MAKE_LAYBASIC_LIBRARY layNetlistBrowserPage.h \ layNetlistBrowserTreeModel.h \ layNetlistCrossReferenceModel.h \ - layPixelBuffer.h \ + layPixelBuffer.h \ + layPixelBufferPainter.h \ layPluginConfigPage.h \ layProperties.h \ layPropertiesDialog.h \ diff --git a/src/laybasic/unit_tests/layBitmapsToImage.cc b/src/laybasic/unit_tests/layBitmapsToImage.cc index 299d2c81d..47d61206f 100644 --- a/src/laybasic/unit_tests/layBitmapsToImage.cc +++ b/src/laybasic/unit_tests/layBitmapsToImage.cc @@ -20,23 +20,19 @@ */ -#if defined(HAVE_QT) // @@@ #include "layBitmapsToImage.h" #include "layBitmap.h" #include "layDitherPattern.h" #include "layLineStyles.h" +#include "layPixelBuffer.h" #include "tlUnitTest.h" -#include -#include -#include - std::string -to_string (const QImage &img, unsigned int mask) +to_string (const lay::PixelBuffer &img, unsigned int mask) { std::string s; for (unsigned int i = 0; i < 32; ++i) { - const unsigned int *data = (const unsigned int *)img.scanLine (i); + const unsigned int *data = (const unsigned int *)img.scan_line (i); for (unsigned int j = 0; j < 32; ++j) { s += (data[j] & mask) ? "x" : "."; } @@ -89,7 +85,7 @@ TEST(1) view_ops.push_back (lay::ViewOp (0x000080, lay::ViewOp::Copy, 0, 0, 0, lay::ViewOp::Rect, 1)); view_ops.push_back (lay::ViewOp (0x0000c0, lay::ViewOp::Or, 0, 0, 0, lay::ViewOp::Rect, 3)); - QImage img (QSize (32, 32), QImage::Format_RGB32); + lay::PixelBuffer img (32, 32); img.fill (0); lay::DitherPattern dp; @@ -939,5 +935,3 @@ TEST(1) ); } - -#endif From 6feed828085c1661c7a29009ef3708fb4f333e69 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Thu, 5 May 2022 23:37:33 +0200 Subject: [PATCH 26/88] Bug fixes and tests for LayoutView --- src/laybasic/laybasic/gsiDeclLayLayoutView.cc | 2 +- src/laybasic/laybasic/layLayoutCanvas.cc | 4 +- src/laybasic/laybasic/layLayoutView.cc | 8 +- src/laybasic/laybasic/layLayoutView.h | 11 -- src/laybasic/laybasic/layLayoutViewBase.cc | 36 +++- src/laybasic/laybasic/layLayoutViewBase.h | 18 +- src/laybasic/laybasic/layMouseTracker.cc | 2 +- src/laybasic/laybasic/layMouseTracker.h | 6 +- src/laybasic/laybasic/layMove.cc | 2 +- src/laybasic/laybasic/layMove.h | 6 +- src/laybasic/laybasic/laySelector.cc | 2 +- src/laybasic/laybasic/laySelector.h | 6 +- src/laybasic/laybasic/layZoomBox.cc | 2 +- src/laybasic/laybasic/layZoomBox.h | 6 +- src/laybasic/unit_tests/layLayoutViewTests.cc | 171 ++++++++++++++++++ src/laybasic/unit_tests/unit_tests.pro | 1 + testdata/lay/au_lv1.png | Bin 0 -> 3983 bytes testdata/lay/au_lv2.png | Bin 0 -> 15317 bytes testdata/lay/au_lv3.png | Bin 0 -> 2584 bytes 19 files changed, 235 insertions(+), 48 deletions(-) create mode 100644 src/laybasic/unit_tests/layLayoutViewTests.cc create mode 100644 testdata/lay/au_lv1.png create mode 100644 testdata/lay/au_lv2.png create mode 100644 testdata/lay/au_lv3.png diff --git a/src/laybasic/laybasic/gsiDeclLayLayoutView.cc b/src/laybasic/laybasic/gsiDeclLayLayoutView.cc index ed41338b1..f76bc9c99 100644 --- a/src/laybasic/laybasic/gsiDeclLayLayoutView.cc +++ b/src/laybasic/laybasic/gsiDeclLayLayoutView.cc @@ -327,7 +327,7 @@ static void save_as2 (lay::LayoutView *view, unsigned int index, const std::stri view->save_as (index, filename, tl::OutputStream::OM_Auto, options, true, 0); } -#if defined(HAVE_QTBINDINGS) +#if defined(HAVE_QTBINDINGS) // @@@ static QImage get_image_with_options (lay::LayoutView *view, unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, const db::DBox &target_box, bool monochrome) { return view->get_image_with_options (width, height, linewidth, oversampling, resolution, lay::Color (), lay::Color (), lay::Color (), target_box, monochrome); diff --git a/src/laybasic/laybasic/layLayoutCanvas.cc b/src/laybasic/laybasic/layLayoutCanvas.cc index 7b4be5838..a69f4872d 100644 --- a/src/laybasic/laybasic/layLayoutCanvas.cc +++ b/src/laybasic/laybasic/layLayoutCanvas.cc @@ -37,13 +37,11 @@ #include "layRedrawThread.h" #include "layLayoutView.h" #include "layMarker.h" -#if defined(HAVE_QT) // @@@ +#if defined(HAVE_QT) # include "gtf.h" #endif -#if defined(HAVE_QT) // @@@ #include "layBitmapsToImage.h" -#endif #include #include diff --git a/src/laybasic/laybasic/layLayoutView.cc b/src/laybasic/laybasic/layLayoutView.cc index 438a72bdf..11dedc436 100644 --- a/src/laybasic/laybasic/layLayoutView.cc +++ b/src/laybasic/laybasic/layLayoutView.cc @@ -94,7 +94,7 @@ static LayoutView *ms_current = 0; LayoutView::LayoutView (db::Manager *manager, bool editable, lay::Plugin *plugin_parent, QWidget *parent, const char *name, unsigned int options) : QFrame (parent), - LayoutViewBase (manager, editable, plugin_parent, options), + LayoutViewBase (this, this, manager, editable, plugin_parent, options), dm_setup_editor_option_pages (this, &LayoutView::do_setup_editor_options_pages) { // ensures the deferred method scheduler is present @@ -106,7 +106,7 @@ LayoutView::LayoutView (db::Manager *manager, bool editable, lay::Plugin *plugin LayoutView::LayoutView (lay::LayoutView *source, db::Manager *manager, bool editable, lay::Plugin *plugin_parent, QWidget *parent, const char *name, unsigned int options) : QFrame (parent), - LayoutViewBase (source, manager, editable, plugin_parent, options), + LayoutViewBase (this, this, source, manager, editable, plugin_parent, options), dm_setup_editor_option_pages (this, &LayoutView::do_setup_editor_options_pages) { // ensures the deferred method scheduler is present @@ -1117,13 +1117,13 @@ namespace lay { LayoutView::LayoutView (db::Manager *mgr, bool editable, lay::Plugin *plugin_parent, unsigned int options) - : LayoutViewBase (mgr, editable, plugin_parent, options) + : LayoutViewBase (this, mgr, editable, plugin_parent, options) { // .. nothing yet .. } LayoutView::LayoutView (lay::LayoutView *source, db::Manager *mgr, bool editable, lay::Plugin *plugin_parent, unsigned int options) - : LayoutViewBase (source, mgr, editable, plugin_parent, options) + : LayoutViewBase (this, source, mgr, editable, plugin_parent, options) { // .. nothing yet .. } diff --git a/src/laybasic/laybasic/layLayoutView.h b/src/laybasic/laybasic/layLayoutView.h index 475926838..20a399634 100644 --- a/src/laybasic/laybasic/layLayoutView.h +++ b/src/laybasic/laybasic/layLayoutView.h @@ -413,11 +413,6 @@ public: return mp_editor_options_frame; } - /** - * @brief Gets the QWidget interface - */ - virtual QWidget *widget () { return this; } - /** * @brief Copies to clipboard * @@ -758,12 +753,6 @@ protected: virtual void emit_dirty_changed (); virtual void emit_layer_order_changed (); -protected: - /** - * @brief Gets the LayoutView interface - */ - virtual LayoutView *get_ui () { return this; } - private: using LayoutViewBase::ui; }; diff --git a/src/laybasic/laybasic/layLayoutViewBase.cc b/src/laybasic/laybasic/layLayoutViewBase.cc index 05b8a89e6..2e84b2b25 100644 --- a/src/laybasic/laybasic/layLayoutViewBase.cc +++ b/src/laybasic/laybasic/layLayoutViewBase.cc @@ -232,8 +232,16 @@ struct OpDeleteLayerProps const double animation_interval = 0.5; -LayoutViewBase::LayoutViewBase (db::Manager *manager, bool editable, lay::Plugin *plugin_parent, unsigned int options) +#if defined(HAVE_QT) +LayoutViewBase::LayoutViewBase (QWidget *widget, lay::LayoutView *ui, db::Manager *manager, bool editable, lay::Plugin *plugin_parent, unsigned int options) +#else +LayoutViewBase::LayoutViewBase (lay::LayoutView *ui, db::Manager *manager, bool editable, lay::Plugin *plugin_parent, unsigned int options) +#endif : lay::Dispatcher (plugin_parent, false /*not standalone*/), +#if defined(HAVE_QT) + mp_widget (widget), +#endif + mp_ui (ui), m_editable (editable), m_options (options), m_annotation_shapes (manager) @@ -244,8 +252,16 @@ LayoutViewBase::LayoutViewBase (db::Manager *manager, bool editable, lay::Plugin init (manager); } -LayoutViewBase::LayoutViewBase (lay::LayoutViewBase *source, db::Manager *manager, bool editable, lay::Plugin *plugin_parent, unsigned int options) +#if defined(HAVE_QT) +LayoutViewBase::LayoutViewBase (QWidget *widget, lay::LayoutView *ui, lay::LayoutViewBase *source, db::Manager *manager, bool editable, lay::Plugin *plugin_parent, unsigned int options) +#else +LayoutViewBase::LayoutViewBase (lay::LayoutView *ui, lay::LayoutViewBase *source, db::Manager *manager, bool editable, lay::Plugin *plugin_parent, unsigned int options) +#endif : lay::Dispatcher (plugin_parent, false /*not standalone*/), +#if defined(HAVE_QT) + mp_widget (widget), +#endif + mp_ui (ui), m_editable (editable), m_options (options), m_annotation_shapes (manager) @@ -274,7 +290,7 @@ LayoutViewBase::LayoutViewBase (lay::LayoutViewBase *source, db::Manager *manage } else { *m_layer_properties_lists [i] = *source->m_layer_properties_lists [i]; } - m_layer_properties_lists [i]->attach_view (ui (), (unsigned int) i); + m_layer_properties_lists [i]->attach_view (this, (unsigned int) i); } if (! m_layer_properties_lists.empty ()) { @@ -367,7 +383,7 @@ LayoutViewBase::init (db::Manager *mgr) m_search_range_box = 0; m_layer_properties_lists.push_back (new LayerPropertiesList ()); - m_layer_properties_lists.back ()->attach_view (ui (), (unsigned int) (m_layer_properties_lists.size () - 1)); + m_layer_properties_lists.back ()->attach_view (this, (unsigned int) (m_layer_properties_lists.size () - 1)); m_current_layer_list = 0; #if defined(HAVE_QT) @@ -388,16 +404,16 @@ LayoutViewBase::init (db::Manager *mgr) // occupy services and editables: // these services get deleted by the canvas destructor automatically: if ((m_options & LV_NoTracker) == 0) { - mp_tracker = new lay::MouseTracker (ui ()); + mp_tracker = new lay::MouseTracker (this); } if ((m_options & LV_NoZoom) == 0) { - mp_zoom_service = new lay::ZoomService (ui ()); + mp_zoom_service = new lay::ZoomService (this); } if ((m_options & LV_NoSelection) == 0) { - mp_selection_service = new lay::SelectionService (ui ()); + mp_selection_service = new lay::SelectionService (this); } if ((m_options & LV_NoMove) == 0) { - mp_move_service = new lay::MoveService (ui ()); + mp_move_service = new lay::MoveService (this); } create_plugins (); @@ -3207,14 +3223,14 @@ LayoutViewBase::box () const QWidget * LayoutViewBase::widget () { - tl_assert (false); + return mp_widget; } #endif LayoutView * LayoutViewBase::get_ui () { - tl_assert (false); + return mp_ui; } // @@@ needs to be called "as often as possible" diff --git a/src/laybasic/laybasic/layLayoutViewBase.h b/src/laybasic/laybasic/layLayoutViewBase.h index 16434c38e..d1bcaa412 100644 --- a/src/laybasic/laybasic/layLayoutViewBase.h +++ b/src/laybasic/laybasic/layLayoutViewBase.h @@ -183,12 +183,20 @@ public: /** * @brief Constructor */ - LayoutViewBase (db::Manager *mgr, bool editable, lay::Plugin *plugin_parent, unsigned int options = (unsigned int) LV_Normal); +#if defined(HAVE_QT) + LayoutViewBase (QWidget *widget, lay::LayoutView *ui, db::Manager *mgr, bool editable, lay::Plugin *plugin_parent, unsigned int options = (unsigned int) LV_Normal); +#else + LayoutViewBase (lay::LayoutView *ui, db::Manager *mgr, bool editable, lay::Plugin *plugin_parent, unsigned int options = (unsigned int) LV_Normal); +#endif /** * @brief Constructor (clone from another view) */ - LayoutViewBase (lay::LayoutViewBase *source, db::Manager *mgr, bool editable, lay::Plugin *plugin_parent, unsigned int options = (unsigned int) LV_Normal); +#if defined(HAVE_QT) + LayoutViewBase (QWidget *widget, lay::LayoutView *ui, lay::LayoutViewBase *source, db::Manager *mgr, bool editable, lay::Plugin *plugin_parent, unsigned int options = (unsigned int) LV_Normal); +#else + LayoutViewBase (lay::LayoutView *ui, lay::LayoutViewBase *source, db::Manager *mgr, bool editable, lay::Plugin *plugin_parent, unsigned int options = (unsigned int) LV_Normal); +#endif /** * @brief Destructor @@ -2504,7 +2512,7 @@ public: /** * @brief Gets the QWidget interface */ - virtual QWidget *widget (); + QWidget *widget (); #endif /** @@ -2536,6 +2544,10 @@ private: void signal_apply_technology (lay::LayoutHandle *layout_handle); private: +#if defined(HAVE_QT) + QWidget *mp_widget; +#endif + lay::LayoutView *mp_ui; bool m_editable; int m_disabled_edits; unsigned int m_options; diff --git a/src/laybasic/laybasic/layMouseTracker.cc b/src/laybasic/laybasic/layMouseTracker.cc index 73caa324b..f84a48779 100644 --- a/src/laybasic/laybasic/layMouseTracker.cc +++ b/src/laybasic/laybasic/layMouseTracker.cc @@ -28,7 +28,7 @@ namespace lay { -MouseTracker::MouseTracker (lay::LayoutView *view) +MouseTracker::MouseTracker (lay::LayoutViewBase *view) : lay::ViewService (view->view_object_widget ()), mp_view (view) { widget ()->grab_mouse (this, false); diff --git a/src/laybasic/laybasic/layMouseTracker.h b/src/laybasic/laybasic/layMouseTracker.h index 3e826606b..2eb5c33e5 100644 --- a/src/laybasic/laybasic/layMouseTracker.h +++ b/src/laybasic/laybasic/layMouseTracker.h @@ -31,17 +31,17 @@ class QMouseEvent; namespace lay { class LayoutCanvas; -class LayoutView; +class LayoutViewBase; class MouseTracker : public lay::ViewService { public: - MouseTracker (lay::LayoutView *view); + MouseTracker (lay::LayoutViewBase *view); virtual bool mouse_move_event (const db::DPoint &p, unsigned int buttons, bool prio); private: - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; }; } diff --git a/src/laybasic/laybasic/layMove.cc b/src/laybasic/laybasic/layMove.cc index 3d86338ad..9667ccb77 100644 --- a/src/laybasic/laybasic/layMove.cc +++ b/src/laybasic/laybasic/layMove.cc @@ -34,7 +34,7 @@ namespace lay // ------------------------------------------------------------- // MoveService implementation -MoveService::MoveService (lay::LayoutView *view) +MoveService::MoveService (lay::LayoutViewBase *view) : lay::ViewService (view->view_object_widget ()), m_dragging (false), m_dragging_transient (false), diff --git a/src/laybasic/laybasic/layMove.h b/src/laybasic/laybasic/layMove.h index 784630d5e..3908c6505 100644 --- a/src/laybasic/laybasic/layMove.h +++ b/src/laybasic/laybasic/layMove.h @@ -31,13 +31,13 @@ namespace lay { class Editables; -class LayoutView; +class LayoutViewBase; class MoveService : public lay::ViewService { public: - MoveService (lay::LayoutView *view); + MoveService (lay::LayoutViewBase *view); ~MoveService (); virtual bool configure (const std::string &name, const std::string &value); @@ -59,7 +59,7 @@ private: bool m_dragging; bool m_dragging_transient; lay::Editables *mp_editables; - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; double m_global_grid; db::DPoint m_shift; db::DPoint m_mouse_pos; diff --git a/src/laybasic/laybasic/laySelector.cc b/src/laybasic/laybasic/laySelector.cc index e1dea2f3b..029b1cbe1 100644 --- a/src/laybasic/laybasic/laySelector.cc +++ b/src/laybasic/laybasic/laySelector.cc @@ -37,7 +37,7 @@ namespace lay // ------------------------------------------------------------- // SelectionService implementation -SelectionService::SelectionService (lay::LayoutView *view) +SelectionService::SelectionService (lay::LayoutViewBase *view) : QObject (), lay::ViewService (view->view_object_widget ()), mp_view (view), diff --git a/src/laybasic/laybasic/laySelector.h b/src/laybasic/laybasic/laySelector.h index 69c3d4b25..ad81060b3 100644 --- a/src/laybasic/laybasic/laySelector.h +++ b/src/laybasic/laybasic/laySelector.h @@ -38,7 +38,7 @@ namespace lay { class RubberBox; -class LayoutView; +class LayoutViewBase; class LayoutCanvas; class LAYBASIC_PUBLIC SelectionService : @@ -52,7 +52,7 @@ Q_OBJECT #endif public: - SelectionService (lay::LayoutView *view); + SelectionService (lay::LayoutViewBase *view); ~SelectionService (); void set_colors (lay::Color background, lay::Color color); @@ -88,7 +88,7 @@ private: db::DPoint m_p1, m_p2; db::DPoint m_current_position; - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; lay::RubberBox *mp_box; unsigned int m_color; unsigned int m_buttons; diff --git a/src/laybasic/laybasic/layZoomBox.cc b/src/laybasic/laybasic/layZoomBox.cc index bef7e40f2..97f080aa5 100644 --- a/src/laybasic/laybasic/layZoomBox.cc +++ b/src/laybasic/laybasic/layZoomBox.cc @@ -31,7 +31,7 @@ namespace lay // ------------------------------------------------------------- // ZoomService implementation -ZoomService::ZoomService (lay::LayoutView *view) +ZoomService::ZoomService (lay::LayoutViewBase *view) : lay::ViewService (view->view_object_widget ()), mp_view (view), mp_box (0), diff --git a/src/laybasic/laybasic/layZoomBox.h b/src/laybasic/laybasic/layZoomBox.h index a0a497a83..7794c6473 100644 --- a/src/laybasic/laybasic/layZoomBox.h +++ b/src/laybasic/laybasic/layZoomBox.h @@ -30,7 +30,7 @@ namespace lay { -class LayoutView; +class LayoutViewBase; class LayoutCanvas; class RubberBox; @@ -38,7 +38,7 @@ class LAYBASIC_PUBLIC ZoomService : public lay::ViewService { public: - ZoomService (lay::LayoutView *view); + ZoomService (lay::LayoutViewBase *view); ~ZoomService (); void set_colors (lay::Color background, lay::Color text); @@ -55,7 +55,7 @@ private: db::DPoint m_p1, m_p2; db::DBox m_vp; - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; lay::RubberBox *mp_box; unsigned int m_color; }; diff --git a/src/laybasic/unit_tests/layLayoutViewTests.cc b/src/laybasic/unit_tests/layLayoutViewTests.cc new file mode 100644 index 000000000..311ee6f1a --- /dev/null +++ b/src/laybasic/unit_tests/layLayoutViewTests.cc @@ -0,0 +1,171 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 "layLayoutView.h" + +#include "tlUnitTest.h" +#include "tlTimer.h" + +#if defined(HAVE_QT) + +# include +# include + +static bool compare_images (const QImage &qimg, const std::string &au) +{ + QImage qimg2; + qimg2.load (tl::to_qstring (au)); + + if (qimg2.width () == (int) qimg.width () && qimg2.height () == (int) qimg.height ()) { + for (int j = 0; j < qimg.height (); ++j) { + for (int i = 0; i < qimg.width (); ++i) { + if (((const lay::color_t *) qimg.scanLine (j))[i] != ((const lay::color_t *) qimg2.scanLine (j))[i]) { + return false; + } + } + } + return true; + } else { + return false; + } +} + +static bool compare_images_mono (const QImage &qimg, const std::string &au) +{ + QImage qimg2; + qimg2.load (tl::to_qstring (au)); + + if (qimg2.width () == (int) qimg.width () && qimg2.height () == (int) qimg.height ()) { + // NOTE: slooooow ... + for (int j = 0; j < qimg.height (); ++j) { + for (int i = 0; i < qimg.width (); ++i) { + if ((qimg.scanLine (j)[i / 8] & (0x80 >> (i % 8))) != (qimg2.scanLine (j)[i / 8] & (0x80 >> (i % 8)))) { + return false; + } + } + } + return true; + } else { + return false; + } +} + +static bool compare_images (const lay::PixelBuffer &img, const lay::PixelBuffer &img2) +{ + if (img2.width () == img.width () && img2.height () == img.height ()) { + for (unsigned int j = 0; j < img.height (); ++j) { + for (unsigned int i = 0; i < img.width (); ++i) { + if (((const lay::color_t *) img.scan_line (j))[i] != ((const lay::color_t *) img2.scan_line (j))[i]) { + return false; + } + } + } + return true; + } else { + return false; + } +} + +static bool compare_images (const lay::BitmapBuffer &img, const lay::BitmapBuffer &img2) +{ + if (img2.width () == img.width () && img2.height () == img.height ()) { + for (unsigned int j = 0; j < img.height (); ++j) { + for (unsigned int i = 0; i < img.stride (); ++i) { + if (((const uint8_t *) img.scan_line (j))[i] != ((const uint8_t *) img2.scan_line (j))[i]) { + return false; + } + } + } + return true; + } else { + return false; + } +} + +#endif + +TEST(1) +{ + lay::LayoutView lv (0, false, 0); + lv.cell_box_color (lay::Color (0, 0, 0)); + + lv.load_layout (tl::testsrc () + "/testdata/gds/t10.gds", true); + + QImage qimg; + qimg = lv.get_image_with_options (500, 500, 1, 1, 1.0, lay::Color (255, 255, 255), lay::Color (0, 0, 0), lay::Color (128, 128, 128), db::DBox (), false); + + EXPECT_EQ (qimg.format () == QImage::Format_RGB32, true); + + std::string tmp = tmp_file ("test.png"); + qimg.save (tl::to_qstring (tmp)); + tl::info << "PNG file written to " << tmp; + + std::string au = tl::testsrc () + "/testdata/lay/au_lv1.png"; + tl::info << "PNG file read from " << au; + + EXPECT_EQ (compare_images (qimg, au), true); +} + +TEST(2) +{ + lay::LayoutView lv (0, false, 0); + lv.full_hier_new_cell (true); + + lv.load_layout (tl::testsrc () + "/testdata/gds/t10.gds", true); + + QImage qimg; + qimg = lv.get_image_with_options (500, 500, 1, 1, 1.0, lay::Color (255, 255, 255), lay::Color (0, 0, 0), lay::Color (128, 128, 128), db::DBox (), false); + + EXPECT_EQ (qimg.format () == QImage::Format_RGB32, true); + + std::string tmp = tmp_file ("test.png"); + qimg.save (tl::to_qstring (tmp)); + tl::info << "PNG file written to " << tmp; + + std::string au = tl::testsrc () + "/testdata/lay/au_lv2.png"; + tl::info << "PNG file read from " << au; + + EXPECT_EQ (compare_images (qimg, au), true); +} + +// monochrome +TEST(3) +{ + lay::LayoutView lv (0, false, 0); + lv.full_hier_new_cell (true); + + lv.load_layout (tl::testsrc () + "/testdata/gds/t10.gds", true); + + QImage qimg; + qimg = lv.get_image_with_options (500, 500, 1, 1, 1.0, lay::Color (255, 255, 255), lay::Color (0, 0, 0), lay::Color (128, 128, 128), db::DBox (), true); + + EXPECT_EQ (qimg.format () == QImage::Format_RGB32, true); + + std::string tmp = tmp_file ("test.png"); + qimg.save (tl::to_qstring (tmp)); + tl::info << "PNG file written to " << tmp; + + std::string au = tl::testsrc () + "/testdata/lay/au_lv3.png"; + tl::info << "PNG file read from " << au; + + EXPECT_EQ (compare_images (qimg, au), true); +} diff --git a/src/laybasic/unit_tests/unit_tests.pro b/src/laybasic/unit_tests/unit_tests.pro index 02ee4a7b4..0248f532a 100644 --- a/src/laybasic/unit_tests/unit_tests.pro +++ b/src/laybasic/unit_tests/unit_tests.pro @@ -14,6 +14,7 @@ SOURCES = \ layLayerProperties.cc \ layParsedLayerSource.cc \ layPixelBufferTests.cc \ + layLayoutViewTests.cc \ layRenderer.cc \ layNetlistBrowserModelTests.cc \ layNetlistBrowserTreeModelTests.cc \ diff --git a/testdata/lay/au_lv1.png b/testdata/lay/au_lv1.png new file mode 100644 index 0000000000000000000000000000000000000000..e3837aa1fd37c8febb5d3255d408d75f5edab6db GIT binary patch literal 3983 zcmd53n-e_+g+*d66854%4(QA?}gX!haJ--+7%1) z&}dit!ItE#P1_(#z#b^}(Ml}tE@5OB4!fo;ElAT|X3-}6i4lUzKrvK3J^#wZ0}h}PH~PxlPo*uR=h z?@#m$j?E=tlV}mEPXc8tfK+TwfRk@F0;kUc0!BDK0HXweRcbf^r%_m$DFhCT)E|mn z1Go^_L*T)$p#B&SQg)vh2M{*bY>h-#c)tV7^I2&g~K1zp0$@%jS}fQxtZ713BO zgL#6oFf8XbtmdaWtk`XO-lIjO>6s96Bf>!jrIs9+==?|vgK-==P_FK}$+~P*T5aQq z)!h1cl})kh69P6>39fHx0VV0L61C&NM9+f$V?wq=1}V=+Njsk7L^%F)j=!N5A_#WK}`ZSKL>!$7s(OH$GS^T*L`gbzPC|?fR+F*C`_$Hlke=#-4mTX=u z2Qy>6<^+fVQ^52g$uP1!%{OcD!l;!{sScywhD!(dAy)*7`4W1b%$;tim_H3xhh~8@ z@pBd4RW0=?j7X%u1g+_!Ns8rSe+hEo61(qOm#Xt!TwSalg`$BGYR_r`T%O~}?h%C{ z43WBlCM#Z0ps%V4MSJ_ii%=kfIw)dhA0~VzIU{xfB3FNd;cVE&wM$hs4%a?MbhdYH zU3MK8ke$tD74Z8HQRTe^L?BYH^^N1FGr6m8&E2!=YaB*VUls>ZDB(_4qcTbk#P-q( z-VCu#!Gq8Qd5IlQ#zu!F3;kiErN7T(OodLu($W~JWmjlUMk1^TVd{8pI<5d?(Y8iW*_1K7E35)FNi z0UB@mP(!gTfohLbbzG9bJnRIKb3BaKeKZ{TiK{lD4Bb!l9JC9cHX_m(p~lbj(bm_b zE3WBe{KIX4c6xwa^ z(IvH!MBn?*#!lvt4^!q}N7)oW>+w4p?J$MaDxVCe#^9mjivHD z-eb{lFLJL1iK8hdSvH{PfX>BZvTVeXwu72xDLrIS#C_&p7SUHmRX3|RK7y#d0XBzA zn(Sfy@1JjF6}RWcW80kFx2ej!{O_na?rLv0D9T#Ou!8HP)qVq4Ilwj3vGpir9;opz z*aD}nPjJ13Y{-NMXS)p!v_{>vSf=1VmVJcIKFc*4&femIeLiw5_hvB*Ne>sHM<|FB zwj#g^hLvDw-w#R2S=KK%!m>Td6uk=7oH)6fIjM!)N~@Uc)e(;lf5|8AnMgHIHjCKF h_%b-L1~3JNR)2cOqV%M19@wxU_YXJHueAR-!+L6CV+nG$FPnK2>)GNzdY1cZo~FvM;|W+EW7B#j8j z7@3I-IVuq5hzt=3L8beQQ^0 z@BK--dBgn3!P5stL`05QTA1Dv5!tix{qy%9gnuz@w3re8IB?&>87d-jwCnq4PqxZY zX%UfgB9^9CZ$EmmRy31AX{`^*(!G(opYmbzB}Q`mN^jh<-Q5v{(?~g6!uvrCm@1K{qiPinn8eacrgJRXuH)<~eyB!fvha2PV@xQ6=75RAnxvz+b!ISQ@ z!u7xY|5x7wDQ%s$-;B`@zeS`PAv1|uJ3uSV9a$^XJEhd;M!1!r>ow0a?L;Wm40>TyTSfLAo+jp``3s6f3dIV$w>FT z%ztUSKbYoT{Jqa7Z!~#T8JqY|y|3`TnX^Z@!}_(qTXgQIP+Vgq>E?L*n$IhQkNM5_ zS5A$Q_6WsRe^}(Fgqt}5|F`?TY5lJH%bY*k{SOm+?tA)A4?40D16z*9hRdi4z^5&Q|rv%AOM8M2;u{D5!k?km2w0q}PC^}h+Gg(v?@LW*cLSCn51Hl)@NC+c?svXQu z)H%Z5s2CO-i8_JoP6Xg|SOxbAF* zHQXmf=OFR$7v_Oa9JS9iX4J@4s&+`cbP9#Ab%W3?q{jMCBM--0fig{`!VKaR;fB7L z^qfr6q*OwcO4PfquR!u|{sW8%1ae_}Gg~E8&H_&~TOIzDI|GMx|$isF(-Jk}A5trfgI2pPEBm7)MZIn`k? z(A6nLQ%ps6NQXd40RUU094-nkvt;dhGLFIcUv!4* zfW{L>$+Nk$CaZd#x&)brW%`-aD94A`ip5xD&}P^fj`D2Gg*>BD$Nd;K!u3M@TYvM& zNjni4*qRPbGG^HQ;ry5!Jz#>lTdOh_!;E(2ws+#11POrL!o`soGTuc$R-O=9leJ%F zyAb!w0TB`Z@Zbd_mz=s41?Kdi@nMFw>ApIqr~Hl+Gsi^F`;{8V*&4b1AXXi2<@NL< zc6(P-8yD-e(MqZ8SkVay?ck;au$H^WcF)VGwFdNWtr#T zE&n&IFyW*2YxUi8Spc}6uZh+fn91iq&NwW41(&iLY}%E)EurhdG-)BizD%dQf*mK< z>|U| zUZ`&0%p8B@$G@Qh zU)-F=cNlnRMNU!G2Vf39yVgB2CVGa;w4yD7Y0q+uxOAFlo^dimMVag>_Tw5w}DyrRGS~xGlIyV`Xzlo_dv5Ue5 zSy6wPwatE!@4$6NqR)p9k(G|sZ;rOv&dIP#bbf{csr(Ob^=-z#PuiSTF_B-*4Fj^* zKkM@YK}{~;MpTG2M;`3w>Ooz6bX2y4264Y!PH8n*mz_KZA^|aWN#<;C5iZ z@w!oPKHq|78c<~2q_K&a1{?cgbxHOF2e>E`c$2rEe27iDZgUqsPITLFTzQ}$26)Xk z0f?_)Wk+Q~E9)w$emokb`_ai+$rJgr<})}~unK!ICMXw) zy4fh;QQ7n0YbYYcnGq>k*MNE@h=HjG!L;$vHXJPGLa0ny)GXMyJ(+O^&nRZ~x~c;! zmK$LY)Qo-~pl{b529f_R#Le}m?K^kte&9=`4L}6mimC+{5>-mZQJw4PI)S8z|D{O!`$2fDV=&~g|A88s^ z0g=KceY3H>Y;vv8bw^{T?dI#y_5OtMM>{d0*l^8^OA2`ByjyJf1B`@afGA<;c-X))q znt|p>s#JPZY($^J9-f;f*ccZ<8c=rhg8E8zKY1g-hK84EwcFE|ID0!}2)#S;N6_*C z*o5~rZk13vPM1m7Ku%4V^r)+ZGw36X!whhD;&7O8dM$6KRk4eKJxv&R6Mb4P?WybD zPw)_5(oFQl`M%6hvo-YyHtBrd^!*usep)0k9|rN$A~c~UuNp)0%ooCPZCSneh9!EY z<^t!sx^xdHjc~HoDI~n!n8|iyg$%W+NaS;F62?nQakjUq+H`BF+qi3Mss^na7cGmd zBbR91c9d_*$y)uds}kL7sAXQ&xdka13y++UY7@}liYJvT*c*=>*yb8$#QnZ@a{}c6 zTzj-YS+&0RO@*ifSv5UM{G_p&ht0_Z)1-8qnD?6Or|L1Nzk&yN$yicsJVoKgslsHT zSSt}(sU>RTQ1?VpkmY7&SYJJH(d!yWcZ()kc83rF4IU9Q0MBYLykE^ZpTR^8%f-0e z6G!jHWQ@aJb>%4_(uYf&P57M_r%F^-R_?v_w;MtreS4eKWv$lMM^(UOl%6` zLicaeWf<>1@!cSFD7T|Muf4XWqlmM85hT+Sn`c1~?9+;m`Fj%&+W=@m52l9tSjFO zMsqhtml;P-(y&>(Dw9T>1)V1!&JfP|CE+$XAM_ATn^*!2u<2U}!KKxVw|(dYOR5X< z`>vWMoj8%J8P~hCm{IFkvxuEK>4lJ1S!|;6d~itOf9#vZb3L^x7^iNrJ->pq#~d7eL3hIZvp zE8Xo)-UP*BrDSgn#I136%F#@+@s%|KyRA%k*x%7uY{$@{k!|%WT+%q)z?M$YcEYSe z(dNJu;!(s{?B#!Bivf_FTgw(Y)UShis8 zQsQpEvPBYvbG>V}vu7?zA;cJ9xTF+0><(hTPtCT&TU+SE4{A80&NG(l1KL`C9sFlA zXOgn#KqW^EN?d^#XCZ{y8oJ`Zv^gYG+HLru!U{vV^>~j$XI)bh&()IqfF!Bli7e`} zO6F=i7+cPpoDJo64&Eb`XocgOPB|l~Wcc4nrzU?rHExucga=8;!F;S(y^4crTx~JX zwqvhv`=^-%cr@J*nZqwR`_d&9MRyTo68hSelJtSdIm=)+Pz~R(O0SK{_au#^19iDl=;~A)~d!*<)RGJGfI*inJV3LAWE;)!{Z!yyF%>zx8Hn zHrkAL zX6qG=Z#JNwPqi7FsG%h7;lmM?=9Oziy!*B2IiLo-4vN)@yMY zF`6Y8x#Hr)o~M*jD!N*iW{i-FM#lzAK5bQUrR9$0nP&_iVYsauifIk75XmqPDNg&> z9m6UhK^RNCx|ki+xl)uHhKQBgSK*F@yffzL!}@LlGl9XApzhDf2tcElOB9n!LgMZb z9es|omQiul4nspsxk>2jxKplMkQt-!n^jg_OEO-gE3nD9-Y-MT2swqytZUY4Jve4v zZ}%3WV=7zglOV_lqteG4`Y;Lb_N3sJ%v<1d06`YF#4^_0rIYV_;U zb+Rkks5=_mUA^Rd!hWzy4d!8!cgwf}mHP8betX6>6irXjYY?MRXigEDN26?!_zSGD z!`BEoaY(upCVv?La-KENiU*3Hkly@ppPGb&W46Q7wtMlD_FSXc3 zXsLMl9zP)sEI4$_vaEn!{G+4u)JCFNY0I*GPfIjz@w%0cntsV6Egj0VkBz(^@9^`K zi&JW*W@Q1&gU8kUjP?d--RkWPyfb!!H#CruIn}QxJr4DDoa=6t?pxJ);vzhF-l&8H z$Rt(Nq<(l-yK1DGG^~edHZ`O5;a_j`RTQ6*%6&_2d9gQB?@`LO?l2YRalC|TjncH_ z?jMp1I>hSUwX$YqXE&ZRGc6-by)MP)!seN~D?p}Gc&W;((*{Rb7W!JH+nw`Yzl4ZB zI5|i+*)lxBQ)%gRt&7~gP&OV^2YfD>)akvTtvxMFHVjneo@>bZphl7NEy(TNJzbhjk8Gg%=$wGJm-k5vz$U+k{_n+aun2qRmnI8(9-|*fb1a z`4wPiej)7^5W@<60p7jElJ)4E@sEs1Q}WY)1a0BTd3Qh;Y%7?$fHF8jjx(wYdbaS?Z8KHCuUD& z307l|d$d1d%tb7e8n61L=A)(U-CRB>8mxT^4=zo+a%2b*8?k({?Qj17Fh##%qH&*O zo@?V?QaYWt?gf$>_^LUAyqs|~!@fuZKco@VT>xPnn_C@5WHz-hsB;I=GF3|lyqMIV z)Xt;2U%^G&Dr3UkjP;e+E#l~NJ&1`1jDh6AAKFn$e@_DNsuuLklTf5uB;wO7vJFYt zJ@M{W06Casv}6a9hzZBMEZ@<$kw7bW3eR^H233@zr#kg&HS{_X>FP=1IXv$d6PTPo z#@f#I34MXa0?xK9L5uq_*Jd48JI8=buXYp@DB5TIqidqg2{QP!l=RzMXkS}nlOT$m z#C+f(-%s4oRpw8vua8|`8GzI*UVRC!Pi?dYY)M4-?Iq)m#Z;Q31IEH)gfXdeqZA}w zCYUgMX$lfkmPC2Rbr_Dz6b`sCIxp(`s_o=flb>!satiK}Z1PgaUUbeo);TD42>ywE zY4F)4lp`qnD$>aoe0LQ|(@9Gvkc>Qf=k%y+L9~GD;B6??vF6+)IXxUINqnIeEF??W} z+hE~qkhJw$!0f8dp!Bjj)SL56-B94)EWPZUUKQKfM!l)ABaEh&foqH_=ki-pa&))% zk*}{ZZ}1`&%zP#jH_nG<0K9z*h60MvDY(##;d-G_bQS!rgqBb-QW=nm?%;!z`c=cT zrmJ{)$w**o3Q^2~cMBBiQ7(h|I2(*=pm465nh7I3_14BLYHv2+ETMG2vAXrH!iw=o z3G-tUF;3zk6U*2cZRc@}t@mcl2a6MyifS(zT?U0J4-1z<4I^e??}B2v2`NYplzBOgg zNPvA4hj=#k+88mXTL6(Y8^vKx{u41 z(y8LPirW$dE1)onh5W#7RU;tKM!rF)t>~&oTns?%fPH|#i`9#y^uXk`-BZOo%d1txl z>9Ss2NAEY!7e&FsY60n}@3jD{XhCw~?sn)KuIB^YaK=MPkR)sH@et=oq$Sdbg)32TRzIxY_k{h;yPZM(!sq^MVx2m|t5EJs@bw(N zH>mK@-Ca(-wnxYOnn|lIp)3qIB`882#Qx%CHXC>s>H{@F8je0Mg8yU&K+f`0$C}sC z89POUq8l^eWffCzIr$eZZ@keNVgSi#bVH3;?Pu9?Kzlvi8Yk_zXh5AB{jg=B_3oz8B`4NOW3PDkiz~vfwr**&-d(4>nLsR{ z19P_IU|a{Kv_D$5>B?D*=q;IhI1dJC*M)X8P^+dlE{u2#Y7 ztL~8J&;)}f6wNDh%S}RV4u3sCiS7xI6HG4GWJo<+bO1uGz3+lYzkdY6CnUiducrp$ zwAFWnar+tNGI7B*v=m2u;CXdzwRkthSMk_QZzo>5EdCG;Bm( zy5GDBS#kt&Mpb(FlHrC=_20gI%{z zUxoRpEvs=uRKQ69RwCT*vYeO+-^H6Er`CcwH~eup2)(^E8-xzuSPuhddBmLolqnAO zmd4ZveJl1a2oyoij@qDoK^4UbGoyn~cR@qd{$gDE`CWfixgt)XIZ6pGyp}n*x;~ig z4sl#-KZM+UvQiu*BXIj*3*1tVLZkMReF;);1+=E5ZF=&ngN(BV$)aEZnVZyNm{xu4m#Hc>Z!{gjYc znO+`n+V;WubFz{YR9TGH$P@rItuHuE@`xCBk$T#fH6pi14wg%jUY7{N_%`CY1M1S=Nx+to#QP)=mZ!{0O zVC5FzToDy=59e+(TfeisZBnhG5BNt>8bzVu*w%VLXnB>c_I;WgR5)3ia zyT!?^>USOY;AM*+w6$B7TpenY7 zKCNCBv}@BKM?mgyg^ErlW!XNxw{|P0HT(cZHvGNL=i1M2>7b$H;YTA^s}Zzs7sum074CAn7E#&zjZw4Is8^~nd1UDEc-#TV|uyV#&~ArH$y+TWQJA}*Vks6 zTU*8%LdD?BSa zZwkJ`aui0%FsZUVDq(@P=TQdWjaKWGpm5R(Y`*RAyhN3i5()Xeg&blDN_qwdu?uy zDQ6f4)S`duO0#nYw;D+#H7K}%#|^XMdiD5uejwCTM4U9|cB*`h399Om8T{T5*|KXG zF56HALnR$(9@r7nBJym@*WldDye4j(55RU*m=l~=Qydr}4wtC0T(~rTJgbQNb zHrNF+xl0r_{VRV=B}`BYK`VpQvuoUJ!j75ggPEHlB;VsBo+A!_^Vc1QN)UqhwM!SN z*iEAPWLqkID#rhYmJu6v+l}7k64`NY{PsZuxjec#Cj_29ZMLq-n*GZ#=^keqxtr z1)dd3zjig1Na@-Qez{qZS1P!jT9eo}m%mk*q}3@1N0occZ3SudX~yq4xQ*U&6&2=R zEm73iQbz8U1pr(_jaba6Nvu-!UhNCNz6$KP+=WM`kJ|UL`notJCO~y;-s)Rbw7D!3a)9AH z>wjp{P)c}5H6Xb2xq4NrX^XiB|HiUN8<_%H<#c{C3ciHxQ8G%dp{E=+>7|CFOpU># zjh;M0AOH1z4>t85hA1Zog0PT+|5ZjzhJ$E&;Uu`i9j;oLGQS0i&x*E772hB&!1deK zEoLz8qCJdu0=vRdAzRC;>-n6N;y=o0_RT0sp-@^9A|y+_K;M@FfE-**n8Gf*mQ zH(lhfzfN&wGf?g2UV_1r{<`c(fR7DO62_iipH6#DcS~R-NJw=}*#+xwX@*NNkten| z{x8YyX4}sidAlcB@(UcOBl92Z&>DFzG~v>F3M8KYA=Y7h7Dompr5Y>4-ct&obhQWP%3-QkKNemaDyTIDJg?rO9HnI2H&}V_#1_Zz%n{`UCy82s! z85>*@PD({PsfnVQbe77Yk>CYG&$GiYHRa^ZZs;=@gi?*K>d2wONlqJy5>h$*xV-S$ zVVn#ibr@1gbwT+z2g5vckUuy_Co{(Q>S)=Mx=7P`b9j;XCf2Ek=L#cXzCDXs-yT7J z>O{}Qj$>^ZJ25ecp!jQCWW@$70Ugi7($?Gs&SxI3L2-+ry?cqDs8*#%W|uc65?|9--_=F^9X;2A-{}a45F|5g;%#W*x>&#$_d{txV=oGd?j# zm_Qd+WMaC<0P8G;tspF+n5`%98exqfR0D3iy|AMI89F$<5<^wykf|Q+WVG?IoHcR* zomsZatD9%}F={KCfQjvSk+!~^n02+^+C9WKKAWbpB0FUuA@6oOSABLJg{eyTMnu}C z6P-{rO%RN5p=_=bE4F?<=S|N3KBLHm&_)6%2BAtLBfaYh9WJ_6MUgbd21PW~64j1+ zh4wikERVR8PUVtxcdFQTg%vl=$ouxZ^C6J8WH2?uZGg4LPQVnHdw@F$yhBvGtNtg! z!LnnFdVUH_SVI*>P0+OlQX zTybflOir70xuV=G5_l0*#ojNyF$ilY<^M)+p4Ye-ORvHht7@kjdsG`Iy3eWBm!jH4 z3FBPe#>$-BXoJzZY*j?NDr$X)xH>8}1(D`tZ;4a#xzaStk+qi8C_BPdZgRQl`5{Wl z;>exY^!_&+`br?<=5a=zIZVKv)3;b)eSo1bsZli{j+8}>-WwD4XA4xDm1ujAZVcS)t5HZ_+=Ihau$v<#te*?Y!nUo^`~L=F1AE!eY1oiyM}_?=v;aFq zsmDE2o7(c5WVf@C8N!*~L2~E5yx;Co6_~|HtYE7swQTXubFK#&s^ieKop-fk&_nPm z6Hp%Hhyx;*CO=c;TtTf|Lmpz&URAN~0xIxBa)e8^0%9se2kD5(N@i5MDQ2_9r-YRu zpBjQ=s4!ur|B>(2gN+iO)}xm3C)*Mv$t32tpxDZ9>RO#Vxh|lk56b+2*SdnAH%i9w zJ@D-a*|pn^GKQI)es9v*q_W5-7d+gH+?i-Bd2t+}myocy_6r{p2Z?!4F?L7OqTq%suTwcte_q)4nAQ-)JJ#ipNqEU%pK^$}*rly5(H9A%&|ib{UZF3;ne@Pw#@C(?-Y%DB07+DO~mO z{?Acu@RZcFJ?$XRb-i0O?Hkf%?mY5qAM1^Eg~fE={0_N@$fLpWKZ-o2KK;*H`QFjs z_-Yaqk^bLbRs9``nf_703fK?%Uh@n)TS6%Lu|(tLyj1F~zhVggg;RijCxQO` zoWlPT#^K-ESI8+`KKHL}_XpGb6^i+P3v5aGy<{I6`e#1mKPPt0x$Ms{&VSHb-$}23 zXI~){6I1vFVYK#zb}9y-@H>q4^Tze(z&N}Af+75sQ}`c%nfz`2t0~eov5_bjA^7&>cj)r!y@pfX zyEs>uML`>LugFiMjV?Kpv6DwdzWsX1IY<9ZJ=C9=EJO_7|C9Ez4T&G5)OSuOD()5F zRE$MLE)5Byn;y%FJFTR>dACo*%0=*w{Y$Rh2M;-C9|i_x=Yqvgz((CEvO?~?b0dwHrKPh;G2AK?SfRHpRF5u^~g7T zVv0}djZ1Fm@qMUEI3*+medH3cl@z2VCFHGhR<%7dN>ea0t)wmUGq}Cya5vsL0H$1N z`2rC-HSSWLkEYt0wc}&4V@P!ZEBec1g&p#|WfJXw766nz(z?BwIH_}Ka0_yS2~C=1 zz;`W|)ZwQoeWhwBvZqtO`?l7g6JvNt38kwQpLlt@N-fe=(AH*JJ3Fg(#lY@i`pwBu zGM_cmDuwA6Y*?H*=>M`SCehqXHWf3#7z@mEM)tmYZRwJecCM-r_3($ZKBA&xdTDNE zBMjF#KW|Z_XMt=c9`GyGKNK45th?E}@z9)*>(hxw)YSi7E+!l)b}%=S0b5TO;^3Sa zsl6-b9aU74kX~U1%s1E0u!B4G7XJ?LF*_^z44TxbHsODyD^Ni{J}uP$l*gL{E-Sd#9s75l8Va@HiOLVe?2sq^pzBrQM9XRH?R)`qplOD&KOp0~TPo-kElK7}Ps z!`K`hS-rMES?Ps^;anwX%j9-H6Ook;tC{sdk7pzMv>CITZkH8@12qShBh4?Kv-NjF z!|{p&2=aDZHAnXr+oNe6WV-`yFFt4bH-+j?-@3(ilz0bEy3@`vxRx1{VP|6ndOYJwVuG;-F%5JbgeS=sia|zE^8BGhYjr0yS<*jE!g{ zZ^UQ1O7I=YkJD!F_&Cx{rkU0o#9)MGZDcp$iqz}H4(0{d0W^oGB^|oIaZpblG9Qo6 z-%)d(2CF?Njpz?WN>+M>1n%9FCw`bk`^uO#-n_lSfTNNw+s8B^`z`o~O2tMc^6J3m z*7k5p59$T`hn~Wlk6?4|&9j1-1$2dW< zYxjzlxZY1ZpxFGRr;n5^UssG{yj9z2ivTy+f@XYF?K=3^;a-a3adJs zW@x#~Gq}3EeKy~MxD2lIB`Tk*`m#!Opa`>roK-iJ@?Q9{15bB_WQUkpWu*5XQe{S3 z8;AHBOv&IoJq06=ka@BR7{l^j5>lTbw5l-V72$FhWc!aCS>ZJ*le=e8cGA|5JyNAy zA9vSEO_OZmeZzg$om5uSgssqbFEOuKaG#|XHPzH~@BP}{;nzaYZ@C_24EZrb4dB4+ zr+<|Aw^jyamGC+_p4-=P+A#>!{CV#$*yTFuLD$cb^|D1jL9#$rSVSR7cItCtWP|Ix zks|)jouL9os1Ke7(ZueI;+;h)NgJ!CI2p_P)^9#>_vA5&l#o=0e&x461oT$A^^wpXIjY<5XfkV&L2AP2>8=S^$ zCdffvD!fC_#dOseVnqX}w`o3EF;!EGe`=Gkp;;Gy3v5wzmAV!Oxgj;3`Pw7XnSG$@Pm*3UdTuP7X>D_v0F`1*POL_-H`Ow_8lv-fNJG2LyTWaT0KeJpHpH3=(wq0Fpl+he~FCtrUze~K_Kt0 zb&?%p&<+p0x7xDm0-lDP&uO|;4`i2TztQ-lXjq8ypGMzMkWNQzRefyv`qHEDxq2=4 z-+8$jWvP~ngm?}?Q~B7X=^*by%O%jk@#byjaX*!~kLMYO-!z1L+K1l)0uj_FER*CR%a{7=4U1VH$YQX}rncmeZhf-RB9F=P?^{ zSGp?~0|fcz3e?&D-(Be2PMa*awY2xwNK!~DVR;lh%>oe6CKkZA%fX{o05Ggc(af0& zOlJIGliYYvES9csI^mBP-fkfI<^&5Ub*FKZiH=mD6h+7_pmE^cjd1|bzhpE%a~DQ5 ziaLUu-p7qo9cOr%G0XGl;-s_d-*>m~sE<``^*`9O2OgQuTY7tS0C?h@nCT3bS#3(?c-?DD!oXiKjZ_X95LqH_PZkrP|to&(RA3K~4^t{0R z?%N~m1BII#N!(X%L!}*j8#DPl0nh=gqCh%%`r2}00-#KY9iJrUgqM#h*|G4Bx*<>I zyYdd;xtIygc+;GC*n`Ar(CY?8(fpjHR$H*m%wEIdNu3oxY+=ur(IUU4Q_z-B2B^vA^idv}oM*>KLW ZLNmR}u1Eo^c5>{v9BiB+SS!EOe*wB5RMG$d literal 0 HcmV?d00001 From 51666eb4398f5fde22a2fcbb500ce2903b4df1c1 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Thu, 5 May 2022 23:44:47 +0200 Subject: [PATCH 27/88] Fixed non-Qt build --- src/laybasic/laybasic/layLayoutCanvas.cc | 12 +++++++++++- src/laybasic/unit_tests/layLayoutViewTests.cc | 2 ++ src/laybasic/unit_tests/layPixelBufferTests.cc | 4 ++-- src/tl/tl/tlCopyOnWrite.h | 1 + 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/laybasic/laybasic/layLayoutCanvas.cc b/src/laybasic/laybasic/layLayoutCanvas.cc index a69f4872d..56eefe300 100644 --- a/src/laybasic/laybasic/layLayoutCanvas.cc +++ b/src/laybasic/laybasic/layLayoutCanvas.cc @@ -277,10 +277,18 @@ invert (unsigned char *data, unsigned int width, unsigned int height) } } +#if defined(HAVE_QT) LayoutCanvas::LayoutCanvas (QWidget *parent, lay::LayoutViewBase *view, const char *name) : lay::ViewObjectWidget (parent, name), +#else +LayoutCanvas::LayoutCanvas (lay::LayoutViewBase *view) + : lay::ViewObjectWidget (), +#endif mp_view (view), - mp_image (0), mp_image_bg (0), mp_pixmap (0), + mp_image (0), mp_image_bg (0), +#if defined(HAVE_QT) + mp_pixmap (0), +#endif m_background (0), m_foreground (0), m_active (0), m_oversampling (1), m_dpr (1), @@ -447,10 +455,12 @@ LayoutCanvas::prepare_drawing () delete mp_image; } mp_image = new lay::PixelBuffer (m_viewport_l.width (), m_viewport_l.height ()); +#if defined(HAVE_QT) if (mp_pixmap) { delete mp_pixmap; mp_pixmap = 0; } +#endif } mp_image->fill (m_background); diff --git a/src/laybasic/unit_tests/layLayoutViewTests.cc b/src/laybasic/unit_tests/layLayoutViewTests.cc index 311ee6f1a..cafcf3156 100644 --- a/src/laybasic/unit_tests/layLayoutViewTests.cc +++ b/src/laybasic/unit_tests/layLayoutViewTests.cc @@ -103,6 +103,7 @@ static bool compare_images (const lay::BitmapBuffer &img, const lay::BitmapBuffe #endif +#if defined(HAVE_QT) // @@@ TEST(1) { lay::LayoutView lv (0, false, 0); @@ -169,3 +170,4 @@ TEST(3) EXPECT_EQ (compare_images (qimg, au), true); } +#endif diff --git a/src/laybasic/unit_tests/layPixelBufferTests.cc b/src/laybasic/unit_tests/layPixelBufferTests.cc index 9f79bc8f0..d7c2b545a 100644 --- a/src/laybasic/unit_tests/layPixelBufferTests.cc +++ b/src/laybasic/unit_tests/layPixelBufferTests.cc @@ -69,6 +69,8 @@ static bool compare_images_mono (const QImage &qimg, const std::string &au) } } +#endif + static bool compare_images (const lay::PixelBuffer &img, const lay::PixelBuffer &img2) { if (img2.width () == img.width () && img2.height () == img.height ()) { @@ -101,8 +103,6 @@ static bool compare_images (const lay::BitmapBuffer &img, const lay::BitmapBuffe } } -#endif - TEST(1) { lay::PixelBuffer img (15, 25); diff --git a/src/tl/tl/tlCopyOnWrite.h b/src/tl/tl/tlCopyOnWrite.h index ed1aabca7..984f52eec 100644 --- a/src/tl/tl/tlCopyOnWrite.h +++ b/src/tl/tl/tlCopyOnWrite.h @@ -26,6 +26,7 @@ #include "tlCommon.h" #include "tlThreads.h" +#include namespace tl { From a2b90d7a8e9de37b75eeadb1cf45cc8cdf462e27 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Fri, 6 May 2022 00:02:35 +0200 Subject: [PATCH 28/88] IMPORTANT (consider merging): fixed a potential segfault on LayoutView construction --- src/laybasic/laybasic/layLayerControlPanel.cc | 2 +- src/laybasic/laybasic/layLayerTreeModel.cc | 8 +++++++- src/laybasic/laybasic/layLayerTreeModel.h | 5 +++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/laybasic/laybasic/layLayerControlPanel.cc b/src/laybasic/laybasic/layLayerControlPanel.cc index 1de876250..28f6cdacd 100644 --- a/src/laybasic/laybasic/layLayerControlPanel.cc +++ b/src/laybasic/laybasic/layLayerControlPanel.cc @@ -301,8 +301,8 @@ LayerControlPanel::LayerControlPanel (lay::LayoutView *view, db::Manager *manage mp_model = new lay::LayerTreeModel (this, view); mp_layer_list = new LCPTreeWidget (this, mp_model, "layer_tree"); mp_layer_list->setUniformRowHeights (true); - mp_model->set_font (mp_layer_list->font ()); mp_layer_list->setIconSize (mp_model->icon_size ()); + mp_model->set_font_no_signal (mp_layer_list->font ()); l->addWidget (mp_layer_list); connect (mp_layer_list, SIGNAL (double_clicked (const QModelIndex &, Qt::KeyboardModifiers)), this, SLOT (double_clicked (const QModelIndex &, Qt::KeyboardModifiers))); diff --git a/src/laybasic/laybasic/layLayerTreeModel.cc b/src/laybasic/laybasic/layLayerTreeModel.cc index e88941da6..f478d96e6 100644 --- a/src/laybasic/laybasic/layLayerTreeModel.cc +++ b/src/laybasic/laybasic/layLayerTreeModel.cc @@ -203,7 +203,13 @@ LayerTreeModel::set_font (const QFont &font) signal_data_changed (); } -void +void +LayerTreeModel::set_font_no_signal (const QFont &font) +{ + m_font = font; +} + +void LayerTreeModel::set_text_color (QColor color) { m_text_color = color; diff --git a/src/laybasic/laybasic/layLayerTreeModel.h b/src/laybasic/laybasic/layLayerTreeModel.h index 6e39f2efd..28c0a8549 100644 --- a/src/laybasic/laybasic/layLayerTreeModel.h +++ b/src/laybasic/laybasic/layLayerTreeModel.h @@ -151,6 +151,11 @@ public: */ void set_font (const QFont &font); + /** + * @brief Set the font to use for text display (without emitting a signal) + */ + void set_font_no_signal (const QFont &font); + /** * @brief Set the text color to use for text display */ From 7291a3dc4798a1207e037558fb3d180becc7b589 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Fri, 6 May 2022 00:02:45 +0200 Subject: [PATCH 29/88] Fixed LayoutView tests --- src/laybasic/unit_tests/layLayoutViewTests.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/laybasic/unit_tests/layLayoutViewTests.cc b/src/laybasic/unit_tests/layLayoutViewTests.cc index cafcf3156..d4ec584e2 100644 --- a/src/laybasic/unit_tests/layLayoutViewTests.cc +++ b/src/laybasic/unit_tests/layLayoutViewTests.cc @@ -159,7 +159,7 @@ TEST(3) QImage qimg; qimg = lv.get_image_with_options (500, 500, 1, 1, 1.0, lay::Color (255, 255, 255), lay::Color (0, 0, 0), lay::Color (128, 128, 128), db::DBox (), true); - EXPECT_EQ (qimg.format () == QImage::Format_RGB32, true); + EXPECT_EQ (qimg.format () == QImage::Format_MonoLSB, true); std::string tmp = tmp_file ("test.png"); qimg.save (tl::to_qstring (tmp)); @@ -168,6 +168,6 @@ TEST(3) std::string au = tl::testsrc () + "/testdata/lay/au_lv3.png"; tl::info << "PNG file read from " << au; - EXPECT_EQ (compare_images (qimg, au), true); + EXPECT_EQ (compare_images_mono (qimg.convertToFormat (QImage::Format_Mono), au), true); } #endif From 067f59ab0adec1f488ce135a1096cbf8478b2943 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 7 May 2022 01:33:16 +0200 Subject: [PATCH 30/88] WIP: PNG support for Qt-less apps through libpng in lay::PixelBuffer --- src/klayout.pri | 9 + src/laybasic/laybasic/layPixelBuffer.cc | 256 ++++++++++++++++++ src/laybasic/laybasic/layPixelBuffer.h | 53 +++- .../unit_tests/layPixelBufferTests.cc | 136 ++++++++++ 4 files changed, 453 insertions(+), 1 deletion(-) diff --git a/src/klayout.pri b/src/klayout.pri index 1c11043ad..2bc555e29 100644 --- a/src/klayout.pri +++ b/src/klayout.pri @@ -72,6 +72,15 @@ equals(HAVE_CURL, "1") { DEFINES += HAVE_CURL } +equals(HAVE_PNG, "1") { + !isEmpty(BITS_PATH) { + include($$BITS_PATH/png/png.pri) + } else { + LIBS += -lpng + } + DEFINES += HAVE_PNG +} + equals(HAVE_EXPAT, "1") { !isEmpty(BITS_PATH) { include($$BITS_PATH/expat/expat.pri) diff --git a/src/laybasic/laybasic/layPixelBuffer.cc b/src/laybasic/laybasic/layPixelBuffer.cc index ad041d1bb..c2d5acbe8 100644 --- a/src/laybasic/laybasic/layPixelBuffer.cc +++ b/src/laybasic/laybasic/layPixelBuffer.cc @@ -22,10 +22,92 @@ #include "layPixelBuffer.h" #include "tlAssert.h" +#include "tlLog.h" + +#if defined(HAVE_PNG) +# include +#endif namespace lay { +// ----------------------------------------------------------------------------------------------------- +// Exceptions + +PixelBufferReadError::PixelBufferReadError (const char *msg) + : tl::Exception (tl::to_string (tr ("PNG read error: ")) + std::string (msg)) +{ + // .. nothing yet .. +} + +PixelBufferReadError::PixelBufferReadError (const std::string &msg) + : tl::Exception (tl::to_string (tr ("PNG read error: ")) + msg) +{ + // .. nothing yet .. +} + +PixelBufferWriteError::PixelBufferWriteError (const char *msg) + : tl::Exception (tl::to_string (tr ("PNG write error: ")) + std::string (msg)) +{ + // .. nothing yet .. +} + +PixelBufferWriteError::PixelBufferWriteError (const std::string &msg) + : tl::Exception (tl::to_string (tr ("PNG write error: ")) + msg) +{ + // .. nothing yet .. +} + +#if defined(HAVE_PNG) + +static void png_read_warn_f (png_structp /*png_ptr*/, png_const_charp error_message) +{ + tl::warn << tl::to_string (tr ("Warning reading PNG: ")) << error_message; +} + +static void png_read_error_f (png_structp /*png_ptr*/, png_const_charp error_message) +{ + throw PixelBufferReadError (error_message); +} + +static void png_write_warn_f (png_structp /*png_ptr*/, png_const_charp error_message) +{ + tl::warn << tl::to_string (tr ("Warning writing PNG: ")) << error_message; +} + +static void png_write_error_f (png_structp /*png_ptr*/, png_const_charp error_message) +{ + throw PixelBufferReadError (error_message); +} + +static void read_from_stream_f (png_structp png_ptr, png_bytep bytes, size_t length) +{ + tl::InputStream *stream = (tl::InputStream *) png_get_io_ptr (png_ptr); + try { + memcpy (bytes, stream->get (length), length); + } catch (tl::Exception &ex) { + png_error (png_ptr, ex.msg ().c_str ()); + } +} + +static void write_to_stream_f (png_structp png_ptr, png_bytep bytes, size_t length) +{ + tl::OutputStream *stream = (tl::OutputStream *) png_get_io_ptr (png_ptr); + try { + stream->put ((const char *) bytes, length); + } catch (tl::Exception &ex) { + png_error (png_ptr, ex.msg ().c_str ()); + } +} + +static void flush_stream_f (png_structp png_ptr) +{ + tl::OutputStream *stream = (tl::OutputStream *) png_get_io_ptr (png_ptr); + stream->flush (); +} + +#endif + // ----------------------------------------------------------------------------------------------------- // PixelBuffer implementation @@ -228,6 +310,103 @@ PixelBuffer::diff (const PixelBuffer &other) const return res; } +#if defined(HAVE_PNG) + +PixelBuffer +PixelBuffer::read_png (tl::InputStream &input) +{ + png_structp png_ptr = NULL; + png_infop info_ptr = NULL; + + png_ptr = png_create_read_struct (PNG_LIBPNG_VER_STRING, NULL, &png_read_error_f, &png_read_warn_f); + tl_assert (png_ptr != NULL); + + info_ptr = png_create_info_struct (png_ptr); + tl_assert (info_ptr != NULL); + + png_set_read_fn (png_ptr, (void *) &input, &read_from_stream_f); + png_set_bgr (png_ptr); // compatible with lay::color_t + + png_read_png (png_ptr, info_ptr, PNG_TRANSFORM_IDENTITY, NULL); + + PixelBuffer res (png_get_image_width (png_ptr, info_ptr), png_get_image_height (png_ptr, info_ptr)); + + unsigned int fmt = png_get_color_type (png_ptr, info_ptr); + unsigned int bd = png_get_bit_depth (png_ptr, info_ptr); + + if (fmt == PNG_COLOR_TYPE_RGBA && bd == 8) { + + tl_assert (png_get_rowbytes (png_ptr, info_ptr) == res.width () * sizeof (lay::color_t)); + + png_bytepp row_pointers = png_get_rows (png_ptr, info_ptr); + for (unsigned int i = 0; i < res.height (); ++i) { + memcpy ((void *) res.scan_line (i), (void *) row_pointers [i], sizeof (lay::color_t) * res.width ()); + } + + } else if (fmt == PNG_COLOR_TYPE_RGB && bd == 8) { + + // RGB has 3 bytes per pixel which need to be transformed into RGB32 + + unsigned int rb = png_get_rowbytes (png_ptr, info_ptr); + tl_assert (rb == res.width () * 3); + + png_bytepp row_pointers = png_get_rows (png_ptr, info_ptr); + for (unsigned int i = 0; i < res.height (); ++i) { + lay::color_t *c = res.scan_line (i); + const uint8_t *d = row_pointers [i]; + const uint8_t *dd = d + rb; + while (d < dd) { + uint8_t b = *d++; + uint8_t g = *d++; + uint8_t r = *d++; + *c++ = 0xff000000 | ((r << 8 | g) << 8) | b; + } + } + + } else { + + png_destroy_read_struct(&png_ptr, &info_ptr, NULL); + throw PixelBufferReadError (tl::sprintf (tl::to_string (tr ("PNG reader supports 32 bit RGB or RGBA only (file: %s, format is %d, bit depth is %d)")), input.filename (), fmt, bd)); + + } + + png_destroy_read_struct(&png_ptr, &info_ptr, NULL); + + return res; +} + +void +PixelBuffer::write_png (tl::OutputStream &output) +{ + png_structp png_ptr = NULL; + png_infop info_ptr = NULL; + + png_ptr = png_create_write_struct (PNG_LIBPNG_VER_STRING, NULL, &png_write_error_f, &png_write_warn_f); + tl_assert (png_ptr != NULL); + + info_ptr = png_create_info_struct (png_ptr); + tl_assert (info_ptr != NULL); + + png_set_write_fn (png_ptr, (void *) &output, &write_to_stream_f, &flush_stream_f); + png_set_bgr (png_ptr); // compatible with lay::color_t + + unsigned int bd = 8; // bit depth + unsigned int fmt = PNG_COLOR_TYPE_RGBA; + + png_set_IHDR (png_ptr, info_ptr, width (), height (), bd, fmt, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); + + png_write_info (png_ptr, info_ptr); + + for (unsigned int i = 0; i < height (); ++i) { + png_write_row (png_ptr, png_const_bytep (scan_line (i))); + } + + png_write_end (png_ptr, info_ptr); + png_destroy_write_struct(&png_ptr, &info_ptr); +} + +#endif + // ----------------------------------------------------------------------------------------------------- // BitmapBuffer implementation @@ -382,4 +561,81 @@ BitmapBuffer::to_image_copy () const } #endif +#if defined(HAVE_PNG) + +BitmapBuffer +BitmapBuffer::read_png (tl::InputStream &input) +{ + png_structp png_ptr = NULL; + png_infop info_ptr = NULL; + + png_ptr = png_create_read_struct (PNG_LIBPNG_VER_STRING, NULL, &png_read_error_f, &png_read_warn_f); + tl_assert (png_ptr != NULL); + + info_ptr = png_create_info_struct (png_ptr); + tl_assert (info_ptr != NULL); + + png_set_read_fn (png_ptr, (void *) &input, &read_from_stream_f); + + png_read_png (png_ptr, info_ptr, PNG_TRANSFORM_IDENTITY, NULL); + + BitmapBuffer res (png_get_image_width (png_ptr, info_ptr), png_get_image_height (png_ptr, info_ptr)); + + unsigned int fmt = png_get_color_type (png_ptr, info_ptr); + unsigned int bd = png_get_bit_depth (png_ptr, info_ptr); + + if (fmt == PNG_COLOR_TYPE_GRAY && bd == 1) { + + size_t rb = png_get_rowbytes (png_ptr, info_ptr); + tl_assert (rb == (res.width () + 7) / 8); + + png_bytepp row_pointers = png_get_rows (png_ptr, info_ptr); + for (unsigned int i = 0; i < res.height (); ++i) { + memcpy ((void *) res.scan_line (i), (void *) row_pointers [i], rb); + } + + } else { + + png_destroy_read_struct(&png_ptr, &info_ptr, NULL); + throw PixelBufferReadError (tl::sprintf (tl::to_string (tr ("PNG bitmap reader supports monochrome files only (file: %s, format is %d, bit depth is %d)")), input.filename (), fmt, bd)); + + } + + png_destroy_read_struct(&png_ptr, &info_ptr, NULL); + + return res; +} + +void +BitmapBuffer::write_png (tl::OutputStream &output) +{ + png_structp png_ptr = NULL; + png_infop info_ptr = NULL; + + png_ptr = png_create_write_struct (PNG_LIBPNG_VER_STRING, NULL, &png_write_error_f, &png_write_warn_f); + tl_assert (png_ptr != NULL); + + info_ptr = png_create_info_struct (png_ptr); + tl_assert (info_ptr != NULL); + + png_set_write_fn (png_ptr, (void *) &output, &write_to_stream_f, &flush_stream_f); + + unsigned int bd = 1; // bit depth + unsigned int fmt = PNG_COLOR_TYPE_GRAY; + + png_set_IHDR (png_ptr, info_ptr, width (), height (), bd, fmt, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); + + png_write_info (png_ptr, info_ptr); + + for (unsigned int i = 0; i < height (); ++i) { + png_write_row (png_ptr, png_const_bytep (scan_line (i))); + } + + png_write_end (png_ptr, info_ptr); + png_destroy_write_struct(&png_ptr, &info_ptr); +} + +#endif + + } diff --git a/src/laybasic/laybasic/layPixelBuffer.h b/src/laybasic/laybasic/layPixelBuffer.h index c78cfbf66..205307a1b 100644 --- a/src/laybasic/laybasic/layPixelBuffer.h +++ b/src/laybasic/laybasic/layPixelBuffer.h @@ -27,6 +27,8 @@ #include "laybasicCommon.h" #include "layColor.h" #include "tlCopyOnWrite.h" +#include "tlStream.h" +#include "tlException.h" #include #include @@ -38,13 +40,34 @@ namespace lay { +/** + * @brief An exception thrown when a PNG read error occurs + */ +class LAYBASIC_PUBLIC PixelBufferReadError + : public tl::Exception +{ +public: + PixelBufferReadError (const char *msg); + PixelBufferReadError (const std::string &msg); +}; + +/** + * @brief An exception thrown when a PNG write error occurs + */ +class LAYBASIC_PUBLIC PixelBufferWriteError + : public tl::Exception +{ +public: + PixelBufferWriteError (const char *msg); + PixelBufferWriteError (const std::string &msg); +}; + /** * @brief An 32bit RGB/RGBA image class * * This class substitutes QImage in Qt-less applications. * It provides 32bit RGBA pixels with the format used by lay::Color. */ - class LAYBASIC_PUBLIC PixelBuffer { public: @@ -183,6 +206,20 @@ public: QImage to_image_copy () const; #endif +#if defined(HAVE_PNG) + /** + * @brief Creates a PixelBuffer object from a PNG file + * Throws a PixelBufferReadError if an error occurs. + */ + static PixelBuffer read_png (tl::InputStream &input); + + /** + * @brief Writes the PixelBuffer object to a PNG file + * Throws a PixelBufferWriteError if an error occurs. + */ + void write_png (tl::OutputStream &output); +#endif + /** * @brief Overlays the other image with this one * @@ -379,6 +416,20 @@ public: QImage to_image_copy () const; #endif +#if defined(HAVE_PNG) + /** + * @brief Creates a PixelBuffer object from a PNG file + * Throws a PixelBufferReadError if an error occurs. + */ + static BitmapBuffer read_png (tl::InputStream &input); + + /** + * @brief Writes the PixelBuffer object to a PNG file + * Throws a PixelBufferWriteError if an error occurs. + */ + void write_png (tl::OutputStream &output); +#endif + private: class MonoImageData { diff --git a/src/laybasic/unit_tests/layPixelBufferTests.cc b/src/laybasic/unit_tests/layPixelBufferTests.cc index d7c2b545a..a3d1ff769 100644 --- a/src/laybasic/unit_tests/layPixelBufferTests.cc +++ b/src/laybasic/unit_tests/layPixelBufferTests.cc @@ -250,6 +250,95 @@ TEST(2) #endif +#if defined(HAVE_PNG) + +// libpng support +TEST(2b) +{ + lay::PixelBuffer img; + + std::string in = tl::testsrc () + "/testdata/lay/png1.png"; // ARGB32 + tl::info << "PNG file read (libpng) from " << in; + + { + tl::InputStream stream (in); + img = lay::PixelBuffer::read_png (stream); + } + + std::string tmp = tmp_file ("test.png"); + { + tl::OutputStream stream (tmp); + img.write_png (stream); + } + tl::info << "PNG file written to " << tmp; + + lay::PixelBuffer img2; + + { + tl::InputStream stream (tmp); + img2 = lay::PixelBuffer::read_png (stream); + } + + EXPECT_EQ (compare_images (img, img2), true); + + std::string tmp2 = tmp_file ("test2.png"); + { + tl::OutputStream stream (tmp2); + img2.write_png (stream); + } + tl::info << "PNG file written to " << tmp2; + +#if defined (HAVE_QT) + // Qt cross-check + std::string au = tl::testsrc () + "/testdata/lay/au.png"; + EXPECT_EQ (compare_images (img2.to_image (), au), true); +#endif +} + +TEST(2c) +{ + lay::PixelBuffer img; + + std::string in = tl::testsrc () + "/testdata/lay/png2.png"; // RGB32 + tl::info << "PNG file read (libpng) from " << in; + + { + tl::InputStream stream (in); + img = lay::PixelBuffer::read_png (stream); + } + + std::string tmp = tmp_file ("test.png"); + { + tl::OutputStream stream (tmp); + img.write_png (stream); + } + tl::info << "PNG file written to " << tmp; + + lay::PixelBuffer img2; + + { + tl::InputStream stream (tmp); + img2 = lay::PixelBuffer::read_png (stream); + } + + EXPECT_EQ (compare_images (img, img2), true); + + std::string tmp2 = tmp_file ("test2.png"); + { + tl::OutputStream stream (tmp2); + img2.write_png (stream); + } + tl::info << "PNG file written to " << tmp2; + +#if defined (HAVE_QT) + // Qt cross-check + std::string au = tl::testsrc () + "/testdata/lay/au.png"; + EXPECT_EQ (compare_images (img2.to_image (), au), true); +#endif +} + +#endif + TEST(3) { { @@ -449,3 +538,50 @@ TEST(12) } #endif + +#if defined(HAVE_PNG) + +// libpng support +TEST(12b) +{ + lay::BitmapBuffer img; + + std::string in = tl::testsrc () + "/testdata/lay/au_mono.png"; + tl::info << "PNG file read (libpng) from " << in; + + { + tl::InputStream stream (in); + img = lay::BitmapBuffer::read_png (stream); + } + + std::string tmp = tmp_file ("test.png"); + { + tl::OutputStream stream (tmp); + img.write_png (stream); + } + tl::info << "PNG file written to " << tmp; + + lay::BitmapBuffer img2; + + { + tl::InputStream stream (tmp); + img2 = lay::BitmapBuffer::read_png (stream); + } + + EXPECT_EQ (compare_images (img, img2), true); + + std::string tmp2 = tmp_file ("test2.png"); + { + tl::OutputStream stream (tmp2); + img2.write_png (stream); + } + tl::info << "PNG file written to " << tmp2; + +#if defined (HAVE_QT) + // Qt cross-check + std::string au = tl::testsrc () + "/testdata/lay/au_mono.png"; + EXPECT_EQ (compare_images (img2.to_image ().convertToFormat (QImage::Format_Mono), au), true); +#endif +} + +#endif From 0798c4de5132fdb58460f51546b6d2e13663712e Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 7 May 2022 02:14:08 +0200 Subject: [PATCH 31/88] Bugfixes and tests for PNG support --- src/laybasic/laybasic/layPixelBuffer.cc | 6 +++- .../unit_tests/layPixelBufferTests.cc | 34 ++++++++++--------- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/src/laybasic/laybasic/layPixelBuffer.cc b/src/laybasic/laybasic/layPixelBuffer.cc index c2d5acbe8..b445187ff 100644 --- a/src/laybasic/laybasic/layPixelBuffer.cc +++ b/src/laybasic/laybasic/layPixelBuffer.cc @@ -576,6 +576,7 @@ BitmapBuffer::read_png (tl::InputStream &input) tl_assert (info_ptr != NULL); png_set_read_fn (png_ptr, (void *) &input, &read_from_stream_f); + png_set_packswap (png_ptr); // compatible with BitmapBuffer png_read_png (png_ptr, info_ptr, PNG_TRANSFORM_IDENTITY, NULL); @@ -584,7 +585,9 @@ BitmapBuffer::read_png (tl::InputStream &input) unsigned int fmt = png_get_color_type (png_ptr, info_ptr); unsigned int bd = png_get_bit_depth (png_ptr, info_ptr); - if (fmt == PNG_COLOR_TYPE_GRAY && bd == 1) { + if ((fmt == PNG_COLOR_TYPE_GRAY || fmt == PNG_COLOR_TYPE_PALETTE) && bd == 1) { + + // TODO: evaluate palette? size_t rb = png_get_rowbytes (png_ptr, info_ptr); tl_assert (rb == (res.width () + 7) / 8); @@ -619,6 +622,7 @@ BitmapBuffer::write_png (tl::OutputStream &output) tl_assert (info_ptr != NULL); png_set_write_fn (png_ptr, (void *) &output, &write_to_stream_f, &flush_stream_f); + png_set_packswap (png_ptr); // compatible with BitmapBuffer unsigned int bd = 1; // bit depth unsigned int fmt = PNG_COLOR_TYPE_GRAY; diff --git a/src/laybasic/unit_tests/layPixelBufferTests.cc b/src/laybasic/unit_tests/layPixelBufferTests.cc index a3d1ff769..43a5c7484 100644 --- a/src/laybasic/unit_tests/layPixelBufferTests.cc +++ b/src/laybasic/unit_tests/layPixelBufferTests.cc @@ -53,12 +53,13 @@ static bool compare_images_mono (const QImage &qimg, const std::string &au) { QImage qimg2; qimg2.load (tl::to_qstring (au)); + qimg2 = qimg2.convertToFormat (QImage::Format_MonoLSB); // that's the format of BitmapBuffer .. if (qimg2.width () == (int) qimg.width () && qimg2.height () == (int) qimg.height ()) { // NOTE: slooooow ... for (int j = 0; j < qimg.height (); ++j) { for (int i = 0; i < qimg.width (); ++i) { - if ((qimg.scanLine (j)[i / 8] & (0x80 >> (i % 8))) != (qimg2.scanLine (j)[i / 8] & (0x80 >> (i % 8)))) { + if ((qimg.scanLine (j)[i / 8] & (0x01 << (i % 8))) != (qimg2.scanLine (j)[i / 8] & (0x01 << (i % 8)))) { return false; } } @@ -90,9 +91,10 @@ static bool compare_images (const lay::PixelBuffer &img, const lay::PixelBuffer static bool compare_images (const lay::BitmapBuffer &img, const lay::BitmapBuffer &img2) { if (img2.width () == img.width () && img2.height () == img.height ()) { + // NOTE: slooooow ... for (unsigned int j = 0; j < img.height (); ++j) { - for (unsigned int i = 0; i < img.stride (); ++i) { - if (((const uint8_t *) img.scan_line (j))[i] != ((const uint8_t *) img2.scan_line (j))[i]) { + for (unsigned int i = 0; i < img.width (); ++i) { + if ((img.scan_line (j)[i / 8] & (0x01 << (i % 8))) != (img2.scan_line (j)[i / 8] & (0x01 << (i % 8)))) { return false; } } @@ -253,7 +255,7 @@ TEST(2) #if defined(HAVE_PNG) // libpng support -TEST(2b) +TEST(3) { lay::PixelBuffer img; @@ -279,8 +281,6 @@ TEST(2b) img2 = lay::PixelBuffer::read_png (stream); } - EXPECT_EQ (compare_images (img, img2), true); - std::string tmp2 = tmp_file ("test2.png"); { tl::OutputStream stream (tmp2); @@ -288,6 +288,8 @@ TEST(2b) } tl::info << "PNG file written to " << tmp2; + EXPECT_EQ (compare_images (img, img2), true); + #if defined (HAVE_QT) // Qt cross-check std::string au = tl::testsrc () + "/testdata/lay/au.png"; @@ -295,7 +297,7 @@ TEST(2b) #endif } -TEST(2c) +TEST(4) { lay::PixelBuffer img; @@ -321,8 +323,6 @@ TEST(2c) img2 = lay::PixelBuffer::read_png (stream); } - EXPECT_EQ (compare_images (img, img2), true); - std::string tmp2 = tmp_file ("test2.png"); { tl::OutputStream stream (tmp2); @@ -330,6 +330,8 @@ TEST(2c) } tl::info << "PNG file written to " << tmp2; + EXPECT_EQ (compare_images (img, img2), true); + #if defined (HAVE_QT) // Qt cross-check std::string au = tl::testsrc () + "/testdata/lay/au.png"; @@ -339,7 +341,7 @@ TEST(2c) #endif -TEST(3) +TEST(5) { { tl::SelfTimer timer ("Run time - lay::Image copy, no write (should be very fast)"); @@ -525,7 +527,7 @@ TEST(12) std::string au = tl::testsrc () + "/testdata/lay/au_mono.png"; tl::info << "PNG file read from " << au; - EXPECT_EQ (compare_images_mono (qimg.convertToFormat (QImage::Format_Mono), au), true); + EXPECT_EQ (compare_images_mono (qimg, au), true); qimg = img.to_image_copy (); img.fill (false); @@ -534,7 +536,7 @@ TEST(12) qimg.save (tl::to_qstring (tmp)); tl::info << "PNG file written to " << tmp; - EXPECT_EQ (compare_images_mono (qimg.convertToFormat (QImage::Format_Mono), au), true); + EXPECT_EQ (compare_images_mono (qimg, au), true); } #endif @@ -542,7 +544,7 @@ TEST(12) #if defined(HAVE_PNG) // libpng support -TEST(12b) +TEST(13) { lay::BitmapBuffer img; @@ -568,8 +570,6 @@ TEST(12b) img2 = lay::BitmapBuffer::read_png (stream); } - EXPECT_EQ (compare_images (img, img2), true); - std::string tmp2 = tmp_file ("test2.png"); { tl::OutputStream stream (tmp2); @@ -577,10 +577,12 @@ TEST(12b) } tl::info << "PNG file written to " << tmp2; + EXPECT_EQ (compare_images (img, img2), true); + #if defined (HAVE_QT) // Qt cross-check std::string au = tl::testsrc () + "/testdata/lay/au_mono.png"; - EXPECT_EQ (compare_images (img2.to_image ().convertToFormat (QImage::Format_Mono), au), true); + EXPECT_EQ (compare_images_mono (img2.to_image (), au), true); #endif } From 32813b80f2809b64e568e153c7cd4533b3a5ac27 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 7 May 2022 12:53:00 +0200 Subject: [PATCH 32/88] GSI binding for PixelBuffer and tests --- .../laybasic/gsiDeclLayPixelBuffer.cc | 395 ++++++++++++++++++ src/laybasic/laybasic/layPixelBuffer.cc | 30 +- src/laybasic/laybasic/layPixelBuffer.h | 14 +- src/laybasic/laybasic/laybasic.pro | 1 + .../unit_tests/layPixelBufferTests.cc | 18 +- src/rba/unit_tests/rbaTests.cc | 1 + testdata/lay/png1.png | Bin 0 -> 2531 bytes testdata/lay/png2.png | Bin 0 -> 2477 bytes testdata/ruby/layPixelBuffer.rb | 203 +++++++++ 9 files changed, 652 insertions(+), 10 deletions(-) create mode 100644 src/laybasic/laybasic/gsiDeclLayPixelBuffer.cc create mode 100644 testdata/lay/png1.png create mode 100644 testdata/lay/png2.png create mode 100644 testdata/ruby/layPixelBuffer.rb diff --git a/src/laybasic/laybasic/gsiDeclLayPixelBuffer.cc b/src/laybasic/laybasic/gsiDeclLayPixelBuffer.cc new file mode 100644 index 000000000..81305e225 --- /dev/null +++ b/src/laybasic/laybasic/gsiDeclLayPixelBuffer.cc @@ -0,0 +1,395 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 "layPixelBuffer.h" + +#include + +namespace gsi +{ + +// ------------------------------------------------------------------------------------- +// lay::BitmapBuffer + +static lay::PixelBuffer *create_pixel_buffer (unsigned int w, unsigned int h) +{ + return new lay::PixelBuffer (w, h); +} + +#if defined(HAVE_QT) && defined(HAVE_QTBINDINGS) +static void fill_with_qcolor (lay::PixelBuffer *pb, QColor c) +{ + pb->fill (c.rgb ()); +} +#endif + +lay::color_t get_pixel_from_pixel_buffer (const lay::PixelBuffer *pb, unsigned int x, unsigned int y) +{ + if (x < pb->width () && y < pb->height ()) { + return pb->scan_line (y)[x]; + } else { + return lay::color_t (0); + } +} + +void set_pixel_in_pixel_buffer (lay::PixelBuffer *pb, unsigned int x, unsigned int y, lay::color_t c) +{ + if (! pb->transparent ()) { + c |= 0xff000000; // ensures that alpha is set properly even if not required + } + if (x < pb->width () && y < pb->height ()) { + pb->scan_line (y)[x] = c; + } +} + +static lay::PixelBuffer read_pixel_buffer (const std::string &file) +{ +#if defined(HAVE_PNG) + tl::InputStream stream (file); + return lay::PixelBuffer::read_png (stream); +#elif defined(HAVE_QT) && defined(HAVE_QTBINDINGS) + // QImage is fallback + QImage img; + img.load (tl::to_qstring (file), "PNG"); + return lay::PixelBuffer::from_image (img); +#else + throw tl::Exception (tl::to_string (tr ("No PNG support compiled in for PixelBuffer"))); + return lay::PixelBuffer (); +#endif +} + +// TODO: there should be some more efficient version of byte strings which avoid copies +static lay::PixelBuffer pixel_buffer_from_png (const std::vector &data) +{ +#if defined(HAVE_PNG) + tl::InputMemoryStream data_stream (data.begin ().operator-> (), data.size ()); + tl::InputStream stream (data_stream); + return lay::PixelBuffer::read_png (stream); +#elif defined(HAVE_QT) && defined(HAVE_QTBINDINGS) + // QImage is fallback + tl_assert (data.size () < std::numeric_limits::max ()); + QImage img = QImage::fromData ((const uchar *) data.begin ().operator-> (), int (data.size ())); + return lay::PixelBuffer::from_image (img); +#else + throw tl::Exception (tl::to_string (tr ("No PNG support compiled in for PixelBuffer"))); + return lay::PixelBuffer (); +#endif +} + +static void write_pixel_buffer (const lay::PixelBuffer *pb, const std::string &file) +{ +#if defined(HAVE_PNG) + tl::OutputStream stream (file); + pb->write_png (stream); +#elif defined(HAVE_QT) && defined(HAVE_QTBINDINGS) + // QImage is fallback + QImage img = pb->to_image (); + img.save (tl::to_qstring (file), "PNG"); +#else + throw tl::Exception (tl::to_string (tr ("No PNG support compiled in for PixelBuffer"))); +#endif +} + +// TODO: there should be some more efficient version of byte strings which avoid copies +static std::vector pixel_buffer_to_png (const lay::PixelBuffer *pb) +{ +#if defined(HAVE_PNG) + tl::OutputMemoryStream data_stream; + { + tl::OutputStream stream (data_stream); + pb->write_png (stream); + } + return std::vector (data_stream.data (), data_stream.data () + data_stream.size ()); +#elif defined(HAVE_QT) && defined(HAVE_QTBINDINGS) + // QImage is fallback + QImage img = pb->to_image (); + QBuffer data; + img.save (&data, "PNG"); + return std::vector (data.data ().constData (), data.data ().constEnd ()); +#else + throw tl::Exception (tl::to_string (tr ("No PNG support compiled in for PixelBuffer"))); +#endif +} + + +Class decl_PixelBuffer ("lay", "PixelBuffer", + gsi::constructor ("new", &create_pixel_buffer, gsi::arg ("width"), gsi::arg ("height"), + "@brief Creates a pixel buffer object\n" + "\n" + "@param width The width in pixels\n" + "@param height The height in pixels\n" + "\n" + "The pixels are basically uninitialized. You will need to use \\fill to initialize them to a certain value." + ) + + gsi::method ("transparent=", &lay::PixelBuffer::set_transparent, gsi::arg ("t"), + "@brief Sets a flag indicating whether the pixel buffer supports an alpha channel\n" + "\n" + "By default, the pixel buffer does not support an alpha channel.\n" + ) + + gsi::method ("transparent", &lay::PixelBuffer::transparent, + "@brief Gets a flag indicating whether the pixel buffer supports an alpha channel\n" + ) + + gsi::method ("fill", &lay::PixelBuffer::fill, gsi::arg ("color"), + "@brief Fills the pixel buffer with the given pixel value\n" + ) + +#if defined(HAVE_QT) + gsi::method_ext ("fill", &fill_with_qcolor, gsi::arg ("color"), + "@brief Fills the pixel buffer with the given QColor\n" + ) + +#endif + gsi::method ("swap", &lay::PixelBuffer::swap, gsi::arg ("other"), + "@brief Swaps data with another PixelBuffer object\n" + ) + + gsi::method ("width", &lay::PixelBuffer::width, + "@brief Gets the width of the pixel buffer in pixels\n" + ) + + gsi::method ("height", &lay::PixelBuffer::height, + "@brief Gets the height of the pixel buffer in pixels\n" + ) + + gsi::method_ext ("set_pixel", &set_pixel_in_pixel_buffer, gsi::arg ("x"), gsi::arg ("y"), gsi::arg ("c"), + "@brief Sets the value of the pixel at position x, y\n" + ) + + gsi::method_ext ("pixel", &get_pixel_from_pixel_buffer, gsi::arg ("x"), gsi::arg ("y"), + "@brief Gets the value of the pixel at position x, y\n" + ) + +#if defined(HAVE_QT) && defined(HAVE_QTBINDINGS) + gsi::method ("to_qimage", &lay::PixelBuffer::to_image_copy, + "@brief Converts the pixel buffer to a \\QImage object" + ) + + gsi::method ("from_qimage", &lay::PixelBuffer::from_image, gsi::arg ("qimage"), + "@brief Creates a pixel buffer object from a QImage object\n" + ) + +#endif + gsi::method ("read_png", &read_pixel_buffer, gsi::arg ("file"), + "@brief Reads the pixel buffer from a PNG file" + "\n" + "This method may not be available if PNG support is not compiled into KLayout." + ) + + gsi::method ("from_png_data", &pixel_buffer_from_png, gsi::arg ("data"), + "@brief Reads the pixel buffer from a PNG byte stream" + "\n" + "This method may not be available if PNG support is not compiled into KLayout." + ) + + gsi::method_ext ("write_png", &write_pixel_buffer, gsi::arg ("file"), + "@brief Writes the pixel buffer to a PNG file" + "\n" + "This method may not be available if PNG support is not compiled into KLayout." + ) + + gsi::method_ext ("to_png_data", &pixel_buffer_to_png, + "@brief Converts the pixel buffer to a PNG byte stream" + "\n" + "This method may not be available if PNG support is not compiled into KLayout." + ) + + gsi::method ("patch", &lay::PixelBuffer::patch, gsi::arg ("other"), + "@brief Patches another pixel buffer into this one\n" + "\n" + "This method is the inverse of \\diff - it will patch the difference image created by diff into this " + "pixel buffer. Note that this method will not do true alpha blending and requires the other pixel buffer " + "to have the same format than self. Self will be modified by this operation." + ) + + gsi::method ("diff", &lay::PixelBuffer::diff, gsi::arg ("other"), + "@brief Creates a difference image\n" + "\n" + "This method is provided to support transfer of image differences - i.e. small updates instead of full images. " + "It works for non-transparent images only and generates an image with transpareny enabled and with the new pixel values for pixels that have changed. " + "The alpha value will be 0 for identical images and 255 for pixels with different values. " + "This way, the difference image can be painted over the original image to generate the new image." + ), + "@brief A simplistic pixel buffer representing an image of ARGB32 or RGB32 values\n" + "\n" + "This object is mainly provided for offline rendering of layouts in Qt-less environments.\n" + "It supports a rectangular pixel space with color values encoded in 32bit integers. It supports " + "transparency through an optional alpha channel. The color format for a pixel is " + "\"0xAARRGGBB\" where 'AA' is the alpha value which is ignored in non-transparent mode.\n" + "\n" + "This class supports basic operations such as initialization, single-pixel access and I/O to PNG." +); + + +// ------------------------------------------------------------------------------------- +// lay::BitmapBuffer + +static lay::BitmapBuffer *create_bitmap_buffer (unsigned int w, unsigned int h) +{ + return new lay::BitmapBuffer (w, h); +} + +bool get_pixel_from_bitmap_buffer (const lay::BitmapBuffer *pb, unsigned int x, unsigned int y) +{ + if (x < pb->width () && y < pb->height ()) { + return (pb->scan_line (y)[x / 8] & (0x01 << (x % 8))) != 0; + } else { + return false; + } +} + +void set_pixel_in_bitmap_buffer (lay::BitmapBuffer *pb, unsigned int x, unsigned int y, bool c) +{ + if (x < pb->width () && y < pb->height ()) { + if (c) { + pb->scan_line (y)[x / 8] |= 0x01 << (x % 8); + } else { + pb->scan_line (y)[x / 8] &= ~(0x01 << (x % 8)); + } + } +} + +static lay::BitmapBuffer read_bitmap_buffer (const std::string &file) +{ +#if defined(HAVE_PNG) + tl::InputStream stream (file); + return lay::BitmapBuffer::read_png (stream); +#elif defined(HAVE_QT) && defined(HAVE_QTBINDINGS) + // QImage is fallback + QImage img; + img.load (tl::to_qstring (file), "PNG"); + return lay::BitmapBuffer::from_image (img); +#else + throw tl::Exception (tl::to_string (tr ("No PNG support compiled in for BitmapBuffer"))); + return lay::BitmapBuffer (); +#endif +} + +// TODO: there should be some more efficient version of byte strings which avoid copies +static lay::BitmapBuffer bitmap_buffer_from_png (const std::vector &data) +{ +#if defined(HAVE_PNG) + tl::InputMemoryStream data_stream (data.begin ().operator-> (), data.size ()); + tl::InputStream stream (data_stream); + return lay::BitmapBuffer::read_png (stream); +#elif defined(HAVE_QT) && defined(HAVE_QTBINDINGS) + // QImage is fallback + tl_assert (data.size () < std::numeric_limits::max ()); + QImage img = QImage::fromData ((const uchar *) data.begin ().operator-> (), int (data.size ())); + return lay::BitmapBuffer::from_image (img); +#else + throw tl::Exception (tl::to_string (tr ("No PNG support compiled in for BitmapBuffer"))); + return lay::BitmapBuffer (); +#endif +} + +static void write_bitmap_buffer (const lay::BitmapBuffer *pb, const std::string &file) +{ +#if defined(HAVE_PNG) + tl::OutputStream stream (file); + pb->write_png (stream); +#elif defined(HAVE_QT) && defined(HAVE_QTBINDINGS) + // QImage is fallback + QImage img = pb->to_image (); + img.save (tl::to_qstring (file), "PNG"); +#else + throw tl::Exception (tl::to_string (tr ("No PNG support compiled in for BitmapBuffer"))); +#endif +} + +// TODO: there should be some more efficient version of byte strings which avoid copies +static std::vector bitmap_buffer_to_png (const lay::BitmapBuffer *pb) +{ +#if defined(HAVE_PNG) + tl::OutputMemoryStream data_stream; + { + tl::OutputStream stream (data_stream); + pb->write_png (stream); + } + return std::vector (data_stream.data (), data_stream.data () + data_stream.size ()); +#elif defined(HAVE_QT) && defined(HAVE_QTBINDINGS) + // QImage is fallback + QImage img = pb->to_image (); + QBuffer data; + img.save (&data, "PNG"); + return std::vector (data.data ().constData (), data.data ().constEnd ()); +#else + throw tl::Exception (tl::to_string (tr ("No PNG support compiled in for BitmapBuffer"))); +#endif +} + + +Class decl_BitmapBuffer ("lay", "BitmapBuffer", + gsi::constructor ("new", &create_bitmap_buffer, gsi::arg ("width"), gsi::arg ("height"), + "@brief Creates a pixel buffer object\n" + "\n" + "@param width The width in pixels\n" + "@param height The height in pixels\n" + "\n" + "The pixels are basically uninitialized. You will need to use \\fill to initialize them to a certain value." + ) + + gsi::method ("fill", &lay::BitmapBuffer::fill, gsi::arg ("color"), + "@brief Fills the pixel buffer with the given pixel value\n" + ) + +#if defined(HAVE_QT) + gsi::method_ext ("fill", &fill_with_qcolor, gsi::arg ("color"), + "@brief Fills the pixel buffer with the given QColor\n" + ) + +#endif + gsi::method ("swap", &lay::BitmapBuffer::swap, gsi::arg ("other"), + "@brief Swaps data with another BitmapBuffer object\n" + ) + + gsi::method ("width", &lay::BitmapBuffer::width, + "@brief Gets the width of the pixel buffer in pixels\n" + ) + + gsi::method ("height", &lay::BitmapBuffer::height, + "@brief Gets the height of the pixel buffer in pixels\n" + ) + + gsi::method_ext ("set_pixel", &set_pixel_in_bitmap_buffer, gsi::arg ("x"), gsi::arg ("y"), gsi::arg ("c"), + "@brief Sets the value of the pixel at position x, y\n" + ) + + gsi::method_ext ("pixel", &get_pixel_from_bitmap_buffer, gsi::arg ("x"), gsi::arg ("y"), + "@brief Gets the value of the pixel at position x, y\n" + ) + +#if defined(HAVE_QT) && defined(HAVE_QTBINDINGS) + gsi::method ("to_qimage", &lay::BitmapBuffer::to_image_copy, + "@brief Converts the pixel buffer to a \\QImage object" + ) + + gsi::method ("from_qimage", &lay::BitmapBuffer::from_image, gsi::arg ("qimage"), + "@brief Creates a pixel buffer object from a QImage object\n" + ) + +#endif + gsi::method ("read_png", &read_bitmap_buffer, gsi::arg ("file"), + "@brief Reads the pixel buffer from a PNG file" + "\n" + "This method may not be available if PNG support is not compiled into KLayout." + ) + + gsi::method ("from_png_data", &bitmap_buffer_from_png, gsi::arg ("data"), + "@brief Reads the pixel buffer from a PNG byte stream" + "\n" + "This method may not be available if PNG support is not compiled into KLayout." + ) + + gsi::method_ext ("write_png", &write_bitmap_buffer, gsi::arg ("file"), + "@brief Writes the pixel buffer to a PNG file" + "\n" + "This method may not be available if PNG support is not compiled into KLayout." + ) + + gsi::method_ext ("to_png_data", &bitmap_buffer_to_png, + "@brief Converts the pixel buffer to a PNG byte stream" + "\n" + "This method may not be available if PNG support is not compiled into KLayout." + ), + "@brief A simplistic pixel buffer representing monochrome image\n" + "\n" + "This object is mainly provided for offline rendering of layouts in Qt-less environments.\n" + "It supports a rectangular pixel space with color values encoded in single bits.\n" + "\n" + "This class supports basic operations such as initialization, single-pixel access and I/O to PNG." +); + +} diff --git a/src/laybasic/laybasic/layPixelBuffer.cc b/src/laybasic/laybasic/layPixelBuffer.cc index b445187ff..d0e0f0d34 100644 --- a/src/laybasic/laybasic/layPixelBuffer.cc +++ b/src/laybasic/laybasic/layPixelBuffer.cc @@ -212,6 +212,10 @@ PixelBuffer::swap (PixelBuffer &other) void PixelBuffer::fill (lay::color_t c) { + if (! transparent ()) { + c |= 0xff000000; // ensures that alpha is properly set + } + color_t *d = data (); for (unsigned int i = 0; i < m_height; ++i) { for (unsigned int j = 0; j < m_width; ++j) { @@ -260,6 +264,17 @@ PixelBuffer::to_image_copy () const memcpy (img.bits (), data (), img.sizeInBytes ()); return img; } + +PixelBuffer +PixelBuffer::from_image (const QImage &img) +{ + if (img.format () != QImage::Format_ARGB32 && img.format () != QImage::Format_RGB32) { + QImage img_argb32 = img.convertToFormat (QImage::Format_ARGB32); + return PixelBuffer (img_argb32.width (), img_argb32.height (), (const lay::color_t *) img_argb32.bits ()); + } else { + return PixelBuffer (img.width (), img.height (), (const lay::color_t *) img.bits ()); + } +} #endif void @@ -376,7 +391,7 @@ PixelBuffer::read_png (tl::InputStream &input) } void -PixelBuffer::write_png (tl::OutputStream &output) +PixelBuffer::write_png (tl::OutputStream &output) const { png_structp png_ptr = NULL; png_infop info_ptr = NULL; @@ -559,6 +574,17 @@ BitmapBuffer::to_image_copy () const memcpy (img.bits (), data (), img.sizeInBytes ()); return img; } + +BitmapBuffer +BitmapBuffer::from_image (const QImage &img) +{ + if (img.format () != QImage::Format_MonoLSB) { + QImage img_monolsb = img.convertToFormat (QImage::Format_MonoLSB); + return BitmapBuffer (img_monolsb.width (), img_monolsb.height (), (const uint8_t *) img_monolsb.bits ()); + } else { + return BitmapBuffer (img.width (), img.height (), (const uint8_t *) img.bits ()); + } +} #endif #if defined(HAVE_PNG) @@ -610,7 +636,7 @@ BitmapBuffer::read_png (tl::InputStream &input) } void -BitmapBuffer::write_png (tl::OutputStream &output) +BitmapBuffer::write_png (tl::OutputStream &output) const { png_structp png_ptr = NULL; png_infop info_ptr = NULL; diff --git a/src/laybasic/laybasic/layPixelBuffer.h b/src/laybasic/laybasic/layPixelBuffer.h index 205307a1b..a5c811461 100644 --- a/src/laybasic/laybasic/layPixelBuffer.h +++ b/src/laybasic/laybasic/layPixelBuffer.h @@ -204,6 +204,11 @@ public: * PixelBuffer. */ QImage to_image_copy () const; + + /** + * @brief Creates a pixel buffer from a QImage object + */ + static PixelBuffer from_image (const QImage &img); #endif #if defined(HAVE_PNG) @@ -217,7 +222,7 @@ public: * @brief Writes the PixelBuffer object to a PNG file * Throws a PixelBufferWriteError if an error occurs. */ - void write_png (tl::OutputStream &output); + void write_png (tl::OutputStream &output) const; #endif /** @@ -414,6 +419,11 @@ public: * BitmapBuffer. */ QImage to_image_copy () const; + + /** + * @brief Creates a pixel buffer from a QImage object + */ + static BitmapBuffer from_image (const QImage &img); #endif #if defined(HAVE_PNG) @@ -427,7 +437,7 @@ public: * @brief Writes the PixelBuffer object to a PNG file * Throws a PixelBufferWriteError if an error occurs. */ - void write_png (tl::OutputStream &output); + void write_png (tl::OutputStream &output) const; #endif private: diff --git a/src/laybasic/laybasic/laybasic.pro b/src/laybasic/laybasic/laybasic.pro index c542dca47..f5a3c3334 100644 --- a/src/laybasic/laybasic/laybasic.pro +++ b/src/laybasic/laybasic/laybasic.pro @@ -242,6 +242,7 @@ SOURCES += \ gsiDeclLayLayoutView.cc \ gsiDeclLayMarker.cc \ gsiDeclLayPlugin.cc \ + gsiDeclLayPixelBuffer.cc \ layAnnotationShapes.cc \ layBitmap.cc \ layBitmapRenderer.cc \ diff --git a/src/laybasic/unit_tests/layPixelBufferTests.cc b/src/laybasic/unit_tests/layPixelBufferTests.cc index 43a5c7484..f2a294288 100644 --- a/src/laybasic/unit_tests/layPixelBufferTests.cc +++ b/src/laybasic/unit_tests/layPixelBufferTests.cc @@ -153,33 +153,33 @@ TEST(1) EXPECT_EQ (compare_images (img, img2), false); EXPECT_EQ (img.scan_line (5)[10], 0x332211); - EXPECT_EQ (img2.scan_line (5)[8], 0x010203); + EXPECT_EQ (img2.scan_line (5)[8], 0xff010203); img = std::move (img2); EXPECT_EQ (compare_images (img, img2), false); EXPECT_EQ (img.width (), 10); EXPECT_EQ (img.height (), 16); - EXPECT_EQ (img.scan_line (5)[8], 0x010203); + EXPECT_EQ (img.scan_line (5)[8], 0xff010203); lay::PixelBuffer img3 (img); EXPECT_EQ (compare_images (img, img3), true); EXPECT_EQ (img3.width (), 10); EXPECT_EQ (img3.height (), 16); - EXPECT_EQ (img3.scan_line (5)[8], 0x010203); + EXPECT_EQ (img3.scan_line (5)[8], 0xff010203); img.fill (0x102030); EXPECT_EQ (compare_images (img, img3), false); EXPECT_EQ (img3.width (), 10); EXPECT_EQ (img3.height (), 16); - EXPECT_EQ (img3.scan_line (5)[8], 0x010203); + EXPECT_EQ (img3.scan_line (5)[8], 0xff010203); EXPECT_EQ (img.width (), 10); EXPECT_EQ (img.height (), 16); - EXPECT_EQ (img.scan_line (5)[8], 0x102030); + EXPECT_EQ (img.scan_line (5)[8], 0xff102030); lay::PixelBuffer img4 (std::move (img)); EXPECT_EQ (img4.width (), 10); EXPECT_EQ (img4.height (), 16); - EXPECT_EQ (img4.scan_line (5)[8], 0x102030); + EXPECT_EQ (img4.scan_line (5)[8], 0xff102030); // other constructors EXPECT_EQ (compare_images (lay::PixelBuffer (img4.width (), img4.height (), (const lay::color_t *) img4.data ()), img4), true); @@ -215,6 +215,9 @@ TEST(2) EXPECT_EQ (compare_images (qimg, au), true); + lay::PixelBuffer img_returned = lay::PixelBuffer::from_image (qimg); + EXPECT_EQ (compare_images (img, img_returned), true); + lay::PixelBuffer img_saved (img); img.scan_line (52) [42] = 0xff000000; @@ -529,6 +532,9 @@ TEST(12) EXPECT_EQ (compare_images_mono (qimg, au), true); + lay::BitmapBuffer img_returned = lay::BitmapBuffer::from_image (qimg); + EXPECT_EQ (compare_images (img, img_returned), true); + qimg = img.to_image_copy (); img.fill (false); diff --git a/src/rba/unit_tests/rbaTests.cc b/src/rba/unit_tests/rbaTests.cc index d222d57f0..300637249 100644 --- a/src/rba/unit_tests/rbaTests.cc +++ b/src/rba/unit_tests/rbaTests.cc @@ -143,6 +143,7 @@ RUBYTEST (layLayoutView, "layLayoutView.rb") RUBYTEST (layMarkers, "layMarkers.rb") RUBYTEST (layMacro, "layMacro.rb") RUBYTEST (layMenuTest, "layMenuTest.rb") +RUBYTEST (layPixelBuffer, "layPixelBuffer.rb") RUBYTEST (laySession, "laySession.rb") RUBYTEST (layTechnologies, "layTechnologies.rb") RUBYTEST (laySaveLayoutOptions, "laySaveLayoutOptions.rb") diff --git a/testdata/lay/png1.png b/testdata/lay/png1.png new file mode 100644 index 0000000000000000000000000000000000000000..6c49d37b20901a52b089c9907f54c151893463de GIT binary patch literal 2531 zcma)-c{CJiAIC>CV;SoxX2>#(eQT6LQX^!G!!WXM8DhvXmU4-iFoR^@y2IGRFcM=g zO_qpgA`-G+Zs_vr)=={5kN3~_9KUluzwbHEpP%PB-zUY^#!L_*2>}2Af)?f`n4?@i zVvU#kXm83cx&Q#+xflnh2#j|$A~Zb2FCYkqh`1YyL*VWN_yGWSJ~Ex~Pg_(34rtgB zQAGF4@JzG!n_l@>xa{l#W_|@$Ys$iI>QQq*?U{#rT`xR;+C!i%VZP6pr1+2c45F-g z{grtJW<4snr+(ky?rrksKL1K};Dn(2`Zwatn;q69*==+SeISU5p70D3!fr|I$)zJY zq^F{4yO6Xgo{gb&TbSEFO{XuY9JqCkC!5#D_kJjqZq5~m?%TvE=H0sC0T%SJ?^$lb!w(astq0Hi9(6S*nkV!zT63M!V3dIucJ;D1-Lf>ta*r<%Z~z?(cF4&=-{_ zjW50tUB%rd%3;kP`ZZfPiY7v|nu?SQo#yOUnW)-6oc#2Ps3PrZer5;8x7fOM8u$7# z`DK%%1H1o}t6SNU)dy^jVQ}Ls;kqG)D%v)O#n*L z{YaIQPI>f4d>PbJ+!B?wAJN%Z?R;DRlr#^n4HSvL;r&$EAVcxTf?u7dnG?pZRmw0dF5E#*GAjWg6$#%Gc}dK0N1UR8Bv{;*X-A(-cf3zO>3$lbx6u53 z7Cs`ZBfP%he;X$GC=cEbHzT~#R}Piqr9Q6R5i4YP>u9M)IjYQ?>7;4t`D`1_q_ptd zZ<1j3sZj@^6}zD)Z!YsoddG|3R|bWm*B4g<@4Tr{7k=k4Kta4z1$?P1PH?Zpl3TX* zx#`*aX+AtB3W0G9$#YbcQ-g@w+hhc19PLOquh)UJ7`}m*wc2u?(QVg5cu|8U`X+NRZ$pp6da+={}0^hR& zzG$Vldw8v=wNTu)6lqBgGzNN^&Kl-?;)Y4F#XP6hBv6H`19Yk9x&EAIm&cGW5Aqk( zb6fA^>e7Pg^D9rT&a1_-&m?phpgi8&yxt|4Tu;S_iOSTiDKEX(SX$irN|5wSdaFDT z?2%|u)#h3?ma%)Pgpx3I{p}^)3-VqI8^YCD_jx%Zpl7NjObl~@6cF)-v@!gXyD_{s zPFcnyae-bA+I{-VmE9oZ4RSFoLO+WT+X?oNBC^hOgq_h1mmNFQPMZZ+jCV%PmtKEt z-)lh;9`yD;P1f_*cdna4W7UsfB<2oFA7*9Y!OMa9ihKH8 z3SB`009;7{#>Tc5#>W3E`lEWM#$_3r_oAixJzeppYC_^Yp@X)?8kAJMK(SO?xd}+a z#X`4zIh_D=jGGjAigaH#4a)=bcb9ep8*Kyo*h3a{N0(b^@eabL#RRV&xIIiMwp z>eJ#o7k4JAs|cTzA3iCs6rr8Wkc==|GGh#D^@M5ZZLSqTk;RXY4@LNs#PeMX#RT*2 zWb4({NUr`kr=?D9)1y~G@UuBRDC&5ALAwosmruhBDi0d0@d7G3QP_1^KJunN!h{b? zmtjMSIe6d$sa+N0q!kY9a3Q+Q@1D=BHRKg>AuTvw09fW;>cQOl=jIH91|a$`SmO7G z&wK6Xd=0culi`}1dC?zfpYuIoSi1DkqCj9M>x9n1-lgq(*XDDM;|b^kCmCpQ69~naaa6N@P(Q? z6953AzTa@=sSBMxI^>D4ur}rS3(PGJmxh0>WglJTHwzOZhdUp)##wv-gb0vj_~bDE zUvDUB1Z@sBcwh2*>ePlp^r@h+~~pa;L;|+kH-lgkoIv&h4%4M xj?FO@9H~NFJ1)m}g}8QX1;17Oe+7wWq#=Ub-tJek@_xS<3sV~t##JxUe*rDAH+ld7 literal 0 HcmV?d00001 diff --git a/testdata/lay/png2.png b/testdata/lay/png2.png new file mode 100644 index 0000000000000000000000000000000000000000..0bb1a8a006bada4e465600df7cf1ad34fb0ff6da GIT binary patch literal 2477 zcmdUw`8yPh7RP5S$qX9X7+ZGPmn@;hGBYt0V;JjL!jPGSu}8_szJ;+Bk>WBjLb6ms z_1Z$V$d)ZLWoVRoWyziHeeQ4f54iU{&pF@oob$`)Jm-1NNkiLO@`EHm004j=Wre`7 zb%pKpqa5t$dp(jL0N|d#=I9cRxfCTELJIZ|yn>evj|suc;-dro0f6Y478hdE6BWLL za_n0n+2=i^+m@3|??O|cy?x;9Z$h=EjF_)cX+Brm?ZaQsy1e!sK!Q&~{a&-y4}+;S5ug~;MHov1iuI4XTt2zR`>f9-0+6k0Y4^c!t06vc0>G^ zT$XIR^i*W+GllXgp7s7Lv>5JdqokqA0j^^_*{Ux7)pUh)GleheH50E?aM{^Su;yAN zDDKq8mucGZ1a|}0MFWR+A(F&Gq?nH)13_}#eMe({wG;cMyB!&^G$z9#C$X9sL<3S#3BruKCLD5e@JuM&>Kuy8D}*UQ|O5ZNUoBd zJShci8k<&U4XnlInL|rv&kpoK4E+5rLUbz$L9ZoZ{Mza&X(<{EiZe=(2-W2zR*P=B z_^nU1{;pKqG)5UB`-lDV4_^W8wBwB{C@!jbWD`3ZQ5X@Ymr2FFXc7g>+e{7VlUpAQ zYA5g1-lu-38@q6(OSW+GjnAr}JN0wj^f2rCMLAxr2%Zaqe+R)b9qVpB#)t=2g{0bA zujRT_boCj_gk0i&s9OwEBvfgT;XN~_;#d5dk%>^E-jp)5N9BtbPrkN9X?kQVpTPIJDpgu_5QTo!X5;| z5hXJ1?7i2e3DzQvX1Fq!p>F#^@+o!`qXd9_R%QUqv zU=~)-97C)dzz*HAv;`&djX4I%_ETXtHO&ZzRoeXhIraIjck1)3yCihgo;HQEaFaHR zXmO;sPm8!WKPIV(1bEekVb-p_Mj-gkeKDi7qrNCc}zDA z?Pq^j+(^6g5m;VGE%2&$a()yh95Il((L&o8ilMgDc7PIdId*5{1|0>RN@IG(8_uKa zl_3m0+jdC>+duSL!TdwknLe2h+E+@2+aO%S;}bie3sX80MIxuwDPI-tAjPC~cPcgz zGl|{PnchC4wyUY5F>Ps$TijWXO*6WMIgDhtStNt!Yoi4`f!e+Z$dU*kYSOk#Ym5qa z+mTAdq7IOaoWQpU=bW>|ZDDmzM@28gA#rPj`m&M4WMqJ+3BG`Kp9@Zj_gTi?es!0m z{PRqPWWu09+ESRIXF+H3Vu=|HS*j8g<=v@m1eK6o-mw0i5B8R{f)(%@(A)Pcr{{tj z;88HI8XdU9yFsP|$>n}rG{K*RH~N{@p+DHxixO zmpX-yX&>;rtw2iq)#Nr<-&b2W@Azd3RodAtD`D7`v~6;%laFVM9()h~9`rQfRP5(7 zkMMaJO!UB_+hDflIMZ8u#Qk%S$%;U?fNTaPOvWN`S)0^x8p3J(9zp=Y1>((AcrtzMZ)z43Ai0UpvgZgUpr>(PGHDAIc03v*d;r90GgVLo>51?PT? zki*bZU9(9Ig@ROY2{RpX4GGy`AZ3my`hRJzEWSnG=}5_Gh|<0H>H6l#Xw~Y4BRgEn z;?Z-7X6WNa|A41B7b0osemn~_7S}#MjjF|KiL4~qA3fT~F61330Sd_mY zI?sq&Bk^fZPfNYD)#y?p5>x1c;%UyV1Xl1u6+HP=TTxfgou zuwq55Un!r+nJM*M1)j9J(|x!Y)#`u4XYL}XH(@a&D4vh=zDI>;%f?sVSz0+DAz;y( zxI1Xzy_>&HaL70goS*G_6XB5m_sv1+ibGTpUw ex + # No PNG support + end + + if png + + assert_equal(png.size > 20 && png.size < 200, true) # some range because implementations may differ + pb_copy = RBA::PixelBuffer.from_png_data(png) + assert_equal(compare(pb, pb_copy), true) + + tmp = File::join($ut_testtmp, "tmp.png") + pb.write_png(tmp) + pb_copy = RBA::PixelBuffer.read_png(tmp) + assert_equal(compare(pb, pb_copy), true) + + end + + end + + def test_11 + + pb = RBA::BitmapBuffer::new + assert_equal(pb.width, 0) + assert_equal(pb.height, 0) + + pb = RBA::BitmapBuffer::new(10, 20) + assert_equal(pb.width, 10) + assert_equal(pb.height, 20) + + pb.fill(false) + assert_equal(pb.pixel(0, 0), false) + assert_equal(pb.pixel(1, 2), false) + + pb.set_pixel(1, 2, true) + assert_equal(pb.pixel(0, 0), false) + assert_equal(pb.pixel(1, 2), true) + + pb_copy = pb.dup + assert_equal(compare(pb_copy, pb), true) + pb.set_pixel(1, 3, true) + assert_equal(pb.pixel(0, 0), false) + assert_equal(pb.pixel(1, 2), true) + assert_equal(pb.pixel(1, 3), true) + assert_equal(pb_copy.pixel(1, 3), false) + + assert_equal(compare(pb_copy, pb), false) + + pb_copy.swap(pb) + assert_equal(pb.pixel(1, 3), false) + assert_equal(pb_copy.pixel(1, 3), true) + + end + + def test_12 + + pb = RBA::BitmapBuffer::new(10, 20) + pb.fill(false) + pb.set_pixel(2, 3, true) + + if pb.respond_to?(:to_qimage) + assert_equal(pb.to_qimage.pixel(0, 0), 0xff000000) + assert_equal(pb.to_qimage.pixel(2, 3), 0xffffffff) + pb_copy = RBA::BitmapBuffer::from_qimage(pb.to_qimage) + assert_equal(compare(pb, pb_copy), true) + end + + png = nil + begin + png = pb.to_png_data + rescue => ex + # No PNG support + end + + if png + + assert_equal(png.size > 20 && png.size < 200, true) # some range because implementations may differ + pb_copy = RBA::BitmapBuffer.from_png_data(png) + assert_equal(compare(pb, pb_copy), true) + + tmp = File::join($ut_testtmp, "tmp.png") + pb.write_png(tmp) + pb_copy = RBA::BitmapBuffer.read_png(tmp) + assert_equal(compare(pb, pb_copy), true) + + end + + end + +end + +load("test_epilogue.rb") From 3c11fe61c32325c89d76ed5164649d8de3c95592 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 7 May 2022 14:36:52 +0200 Subject: [PATCH 33/88] WIP: enabling PixelBuffer and BitmapBuffer for RBA::LayoutView --- src/lay/lay/layNavigator.cc | 2 +- src/laybasic/laybasic/gsiDeclLayLayoutView.cc | 68 +++++- .../laybasic/gsiDeclLayPixelBuffer.cc | 4 +- src/laybasic/laybasic/layColor.h | 8 + src/laybasic/laybasic/layLayoutCanvas.cc | 6 +- src/laybasic/laybasic/layLayoutCanvas.h | 2 +- src/laybasic/laybasic/layLayoutViewBase.cc | 212 +++++++++++++----- src/laybasic/laybasic/layLayoutViewBase.h | 48 +++- .../laybasic/layNetlistBrowserPage.cc | 2 +- src/laybasic/laybasic/laybasic.pro | 8 +- .../lay_plugin/layNetTracerDialog.cc | 2 +- .../view_25d/lay_plugin/layD25ViewWidget.cc | 8 +- 12 files changed, 296 insertions(+), 74 deletions(-) diff --git a/src/lay/lay/layNavigator.cc b/src/lay/lay/layNavigator.cc index 5855b403d..77b19d25a 100644 --- a/src/lay/lay/layNavigator.cc +++ b/src/lay/lay/layNavigator.cc @@ -80,7 +80,7 @@ public: } lay::Color contrast; - if (c.green () > 128) { + if (c.to_mono ()) { contrast = lay::Color (0, 0, 0); } else { contrast = lay::Color (255, 255, 255); diff --git a/src/laybasic/laybasic/gsiDeclLayLayoutView.cc b/src/laybasic/laybasic/gsiDeclLayLayoutView.cc index f76bc9c99..73a8e0350 100644 --- a/src/laybasic/laybasic/gsiDeclLayLayoutView.cc +++ b/src/laybasic/laybasic/gsiDeclLayLayoutView.cc @@ -327,18 +327,26 @@ static void save_as2 (lay::LayoutView *view, unsigned int index, const std::stri view->save_as (index, filename, tl::OutputStream::OM_Auto, options, true, 0); } -#if defined(HAVE_QTBINDINGS) // @@@ +#if defined(HAVE_QT) && defined(HAVE_QTBINDINGS) static QImage get_image_with_options (lay::LayoutView *view, unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, const db::DBox &target_box, bool monochrome) { return view->get_image_with_options (width, height, linewidth, oversampling, resolution, lay::Color (), lay::Color (), lay::Color (), target_box, monochrome); } #endif +static lay::PixelBuffer get_pixels_with_options (lay::LayoutView *view, unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, const db::DBox &target_box) +{ + return view->get_pixels_with_options (width, height, linewidth, oversampling, resolution, lay::Color (), lay::Color (), lay::Color (), target_box); +} + +static lay::BitmapBuffer get_pixels_with_options_mono (lay::LayoutView *view, unsigned int width, unsigned int height, int linewidth, const db::DBox &target_box) +{ + return view->get_pixels_with_options_mono (width, height, linewidth, lay::Color (), lay::Color (), lay::Color (), target_box); +} + static void save_image_with_options (lay::LayoutView *view, const std::string &fn, unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, const db::DBox &target_box, bool monochrome) { -#if defined(HAVE_QT) // @@@ view->save_image_with_options (fn, width, height, linewidth, oversampling, resolution, lay::Color (), lay::Color (), lay::Color (), target_box, monochrome); -#endif } static std::vector @@ -1128,7 +1136,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "Show the layout in full depth down to the deepest level of hierarchy. " "This method may cause a redraw." ) + -#if defined(HAVE_QTBINDINGS) +#if defined(HAVE_QT) && defined(HAVE_QTBINDINGS) gsi::method ("get_screenshot", &lay::LayoutView::get_screenshot, "@brief Gets a screenshot as a \\QImage\n" "\n" @@ -1157,12 +1165,61 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "@param monochrome If true, monochrome images will be produced.\n" "\n" "The image contains the current scene (layout, annotations etc.).\n" - "The image is written as a PNG file to the given file. " "The image is drawn synchronously with the given width and height. Drawing may take some time. " "Monochrome images don't have background or annotation objects currently.\n" "\n" "This method has been introduced in 0.23.10.\n" ) + +#endif + gsi::method ("get_screenshot_pixels", &lay::LayoutView::get_screenshot_pb, + "@brief Gets a screenshot as a \\PixelBuffer\n" + "\n" + "Getting the image requires the drawing to be complete. Ideally, synchronous mode is switched on " + "for the application to guarantee this condition. The image will have the size of the viewport " + "showing the current layout." + "\n" + "This method has been introduced in 0.28.\n" + ) + + gsi::method ("get_pixels", &lay::LayoutView::get_pixels, gsi::arg ("width"), gsi::arg ("height"), + "@brief Gets the layout image as a \\PixelBuffer\n" + "\n" + "@param width The width of the image to render in pixel.\n" + "@param height The height of the image to render in pixel.\n" + "\n" + "The image contains the current scene (layout, annotations etc.).\n" + "The image is drawn synchronously with the given width and height. Drawing may take some time. " + "\n" + "This method has been introduced in 0.28.\n" + ) + + gsi::method_ext ("get_pixels_with_options", &get_pixels_with_options, gsi::arg ("width"), gsi::arg ("height"), gsi::arg ("linewidth"), gsi::arg ("oversampling"), gsi::arg ("resolution"), gsi::arg ("target"), + "@brief Gets the layout image as a \\PixelBuffer (with options)\n" + "\n" + "@param width The width of the image to render in pixel.\n" + "@param height The height of the image to render in pixel.\n" + "@param linewidth The width of a line in pixels (usually 1) or 0 for default.\n" + "@param oversampling The oversampling factor (1..3) or 0 for default.\n" + "@param resolution The resolution (pixel size compared to a screen pixel size, i.e 1/oversampling) or 0 for default.\n" + "@param target_box The box to draw or an empty box for default.\n" + "\n" + "The image contains the current scene (layout, annotations etc.).\n" + "The image is drawn synchronously with the given width and height. Drawing may take some time. " + "\n" + "This method has been introduced in 0.28.\n" + ) + + gsi::method_ext ("get_pixels_with_options_mono", &get_pixels_with_options_mono, gsi::arg ("width"), gsi::arg ("height"), gsi::arg ("linewidth"), gsi::arg ("target"), + "@brief Gets the layout image as a \\PixelBuffer (with options)\n" + "\n" + "@param width The width of the image to render in pixel.\n" + "@param height The height of the image to render in pixel.\n" + "@param linewidth The width of a line in pixels (usually 1) or 0 for default.\n" + "@param target_box The box to draw or an empty box for default.\n" + "\n" + "The image contains the current scene (layout, annotations etc.).\n" + "The image is drawn synchronously with the given width and height. Drawing may take some time. " + "Monochrome images don't have background or annotation objects currently.\n" + "\n" + "This method has been introduced in 0.28.\n" + ) + gsi::method ("save_screenshot", &lay::LayoutView::save_screenshot, gsi::arg ("filename"), "@brief Saves a screenshot to the given file\n" "\n" @@ -1184,7 +1241,6 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "The image is written as a PNG file to the given file. " "The image is drawn synchronously with the given width and height. Drawing may take some time. " ) + -#endif gsi::method_ext ("save_image_with_options", &save_image_with_options, gsi::arg ("filename"), gsi::arg ("width"), gsi::arg ("height"), gsi::arg ("linewidth"), gsi::arg ("oversampling"), gsi::arg ("resolution"), gsi::arg ("target"), gsi::arg ("monochrome"), "@brief Saves the layout as an image to the given file (with options)\n" "\n" diff --git a/src/laybasic/laybasic/gsiDeclLayPixelBuffer.cc b/src/laybasic/laybasic/gsiDeclLayPixelBuffer.cc index 81305e225..7ee615853 100644 --- a/src/laybasic/laybasic/gsiDeclLayPixelBuffer.cc +++ b/src/laybasic/laybasic/gsiDeclLayPixelBuffer.cc @@ -23,7 +23,9 @@ #include "gsiDecl.h" #include "layPixelBuffer.h" -#include +#if defined(HAVE_QT) +# include +#endif namespace gsi { diff --git a/src/laybasic/laybasic/layColor.h b/src/laybasic/laybasic/layColor.h index 79725ecfb..1be4ae0b1 100644 --- a/src/laybasic/laybasic/layColor.h +++ b/src/laybasic/laybasic/layColor.h @@ -142,6 +142,14 @@ public: return (m_color & 0xff); } + /** + * @brief Converts the color into monochrome "on" value + */ + bool to_mono () const + { + return (m_color & 0x8000) != 0; + } + /** * @brief Gets the HSV color components * hue: 0..359 diff --git a/src/laybasic/laybasic/layLayoutCanvas.cc b/src/laybasic/laybasic/layLayoutCanvas.cc index 56eefe300..49ec4eb0d 100644 --- a/src/laybasic/laybasic/layLayoutCanvas.cc +++ b/src/laybasic/laybasic/layLayoutCanvas.cc @@ -933,12 +933,16 @@ LayoutCanvas::image_with_options (unsigned int width, unsigned int height, int l } lay::BitmapBuffer -LayoutCanvas::image_with_options_mono (unsigned int width, unsigned int height, int linewidth, bool background, bool foreground, bool active, const db::DBox &target_box) +LayoutCanvas::image_with_options_mono (unsigned int width, unsigned int height, int linewidth, lay::Color background_c, lay::Color foreground_c, lay::Color active_c, const db::DBox &target_box) { if (linewidth <= 0) { linewidth = 1; } + bool background = background_c.is_valid () ? background_c.to_mono () : background_color ().to_mono (); + bool foreground = foreground_c.is_valid () ? foreground_c.to_mono () : foreground_color ().to_mono (); + bool active = active_c.is_valid () ? active_c.to_mono () : active_color ().to_mono (); + // provide canvas objects for the layout bitmaps and the foreground/background objects BitmapRedrawThreadCanvas rd_canvas; DetachedViewObjectCanvasMono vo_canvas (background, foreground, active, width, height); diff --git a/src/laybasic/laybasic/layLayoutCanvas.h b/src/laybasic/laybasic/layLayoutCanvas.h index 2ce31f095..8e254a1fb 100644 --- a/src/laybasic/laybasic/layLayoutCanvas.h +++ b/src/laybasic/laybasic/layLayoutCanvas.h @@ -173,7 +173,7 @@ public: lay::PixelBuffer screenshot (); lay::PixelBuffer image (unsigned int width, unsigned int height); lay::PixelBuffer image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, lay::Color background, lay::Color foreground, lay::Color active_color, const db::DBox &target_box); - lay::BitmapBuffer image_with_options_mono (unsigned int width, unsigned int height, int linewidth, bool background, bool foreground, bool active_color, const db::DBox &target_box); + lay::BitmapBuffer image_with_options_mono (unsigned int width, unsigned int height, int linewidth, lay::Color background, lay::Color foreground, lay::Color active, const db::DBox &target_box); void update_image (); diff --git a/src/laybasic/laybasic/layLayoutViewBase.cc b/src/laybasic/laybasic/layLayoutViewBase.cc index 2e84b2b25..a8d8eed03 100644 --- a/src/laybasic/laybasic/layLayoutViewBase.cc +++ b/src/laybasic/laybasic/layLayoutViewBase.cc @@ -2468,7 +2468,7 @@ LayoutViewBase::init_layer_properties (LayerProperties &p, const LayerProperties p.set_marked (false); } -#if defined(HAVE_QT) // @@@ add methods without QImage!!!! +#if defined(HAVE_QT) QImage LayoutViewBase::get_screenshot () { @@ -2479,31 +2479,52 @@ LayoutViewBase::get_screenshot () return mp_canvas->screenshot ().to_image_copy (); } +#endif -void +lay::PixelBuffer +LayoutViewBase::get_screenshot_pb () +{ + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Save screenshot"))); + + // Execute all deferred methods - ensure there are no pending tasks + tl::DeferredMethodScheduler::execute (); + + return mp_canvas->screenshot (); +} + +static std::vector > +png_texts (const lay::LayoutViewBase *view, const db::DBox &box) +{ + std::vector > texts; + + // Unfortunately the PNG writer does not allow writing of long strings. + // We separate the description into a set of keys: + + for (unsigned int i = 0; i < view->cellviews (); ++i) { + if (view->cellview (i).is_valid ()) { + std::string name = view->cellview (i)->layout ().cell_name (view->cellview (i).cell_index ()); + texts.push_back (std::make_pair (std::string ("Cell") + tl::to_string (int (i) + 1), name)); + } + } + + texts.push_back (std::make_pair (std::string ("Rect"), box.to_string ())); + + return texts; +} + +#if defined(HAVE_QT) +void LayoutViewBase::save_screenshot (const std::string &fn) { tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Save screenshot"))); QImageWriter writer (tl::to_qstring (fn), QByteArray ("PNG")); - // Unfortunately the PNG writer does not allow writing of long strings. - // We separate the description into a set of keys: - - for (unsigned int i = 0; i < cellviews (); ++i) { - if (cellview (i).is_valid ()) { - std::string name = cellview (i)->layout ().cell_name (cellview (i).cell_index ()); - writer.setText (tl::to_qstring ("Cell" + tl::to_string (int (i) + 1)), tl::to_qstring (name)); - } + std::vector > texts = png_texts (this, box ()); + for (auto i = texts.begin (); i != texts.end (); ++i) { + writer.setText (tl::to_qstring (i->first), tl::to_qstring (i->second)); } - db::DBox b (box ()); - std::string desc; - desc += tl::micron_to_string (b.left ()) + "," + tl::micron_to_string (b.bottom ()); - desc += "/"; - desc += tl::micron_to_string (b.right ()) + "," + tl::micron_to_string (b.top ()); - writer.setText (QString::fromUtf8 ("Rect"), tl::to_qstring (desc)); - // Execute all deferred methods - ensure there are no pending tasks tl::DeferredMethodScheduler::execute (); @@ -2513,54 +2534,104 @@ LayoutViewBase::save_screenshot (const std::string &fn) tl::log << "Saved screen shot to " << fn; } +#else +void +LayoutViewBase::save_screenshot (const std::string &fn) +{ + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Save screenshot"))); -QImage + // Execute all deferred methods - ensure there are no pending tasks + tl::DeferredMethodScheduler::execute (); + + tl::OutputStream stream (fn); + // @@@ TODO: add texts + // @@@ mp_canvas->screenshot ().write_png (stream, png_texts (this, box ())); + mp_canvas->screenshot ().write_png (stream); + + tl::log << "Saved screen shot to " << fn; +} +#endif + +#if defined(HAVE_QT) +QImage LayoutViewBase::get_image (unsigned int width, unsigned int height) { - tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Save image"))); + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Get image"))); // Execute all deferred methods - ensure there are no pending tasks tl::DeferredMethodScheduler::execute (); return mp_canvas->image (width, height).to_image_copy (); } +#endif -QImage +lay::PixelBuffer +LayoutViewBase::get_pixels (unsigned int width, unsigned int height) +{ + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Get image"))); + + // Execute all deferred methods - ensure there are no pending tasks + tl::DeferredMethodScheduler::execute (); + + return mp_canvas->image (width, height); +} + +#if defined(HAVE_QT) +QImage LayoutViewBase::get_image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, lay::Color background, lay::Color foreground, lay::Color active, const db::DBox &target_box, bool monochrome) { - tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Save image"))); + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Get image"))); // Execute all deferred methods - ensure there are no pending tasks tl::DeferredMethodScheduler::execute (); if (monochrome) { - return mp_canvas->image_with_options_mono (width, height, linewidth, background.green () >= 128, foreground.green () >= 128, active.green () >= 128, target_box).to_image_copy (); + return mp_canvas->image_with_options_mono (width, height, linewidth, background, foreground, active, target_box).to_image_copy (); } else { return mp_canvas->image_with_options (width, height, linewidth, oversampling, resolution, background, foreground, active, target_box).to_image_copy (); } } +#endif -void +lay::PixelBuffer +LayoutViewBase::get_pixels_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, + lay::Color background, lay::Color foreground, lay::Color active, const db::DBox &target_box) +{ + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Get image"))); + + // Execute all deferred methods - ensure there are no pending tasks + tl::DeferredMethodScheduler::execute (); + + return mp_canvas->image_with_options (width, height, linewidth, oversampling, resolution, background, foreground, active, target_box); +} + +lay::BitmapBuffer +LayoutViewBase::get_pixels_with_options_mono (unsigned int width, unsigned int height, int linewidth, + lay::Color background, lay::Color foreground, lay::Color active, const db::DBox &target_box) +{ + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Get image"))); + + // Execute all deferred methods - ensure there are no pending tasks + tl::DeferredMethodScheduler::execute (); + + return mp_canvas->image_with_options_mono (width, height, linewidth, background, foreground, active, target_box); +} + +#if defined(HAVE_QT) +void LayoutViewBase::save_image (const std::string &fn, unsigned int width, unsigned int height) { tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Save image"))); QImageWriter writer (tl::to_qstring (fn), QByteArray ("PNG")); - // Unfortunately the PNG writer does not allow writing of long strings. - // We separate the description into a set of keys: - - for (unsigned int i = 0; i < cellviews (); ++i) { - if (cellview (i).is_valid ()) { - std::string name = cellview (i)->layout ().cell_name (cellview (i).cell_index ()); - writer.setText (tl::to_qstring ("Cell" + tl::to_string (int (i) + 1)), tl::to_qstring (name)); - } + lay::Viewport vp (width, height, mp_canvas->viewport ().target_box ()); + std::vector > texts = png_texts (this, vp.box ()); + for (auto i = texts.begin (); i != texts.end (); ++i) { + writer.setText (tl::to_qstring (i->first), tl::to_qstring (i->second)); } - lay::Viewport vp (width, height, mp_canvas->viewport ().target_box ()); - writer.setText (QString::fromUtf8 ("Rect"), tl::to_qstring (vp.box ().to_string ())); - // Execute all deferred methods - ensure there are no pending tasks tl::DeferredMethodScheduler::execute (); @@ -2568,36 +2639,48 @@ LayoutViewBase::save_image (const std::string &fn, unsigned int width, unsigned throw tl::Exception (tl::to_string (QObject::tr ("Unable to write screenshot to file: %s (%s)")), fn, tl::to_string (writer.errorString ())); } - tl::log << "Saved screen shot to " << fn; + tl::log << "Saved image to " << fn; } +#else +void +LayoutViewBase::save_image (const std::string &fn, unsigned int width, unsigned int height) +{ + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Save image"))); -void + lay::Viewport vp (width, height, mp_canvas->viewport ().target_box ()); + std::vector > texts = png_texts (this, vp.box ()); + + // Execute all deferred methods - ensure there are no pending tasks + tl::DeferredMethodScheduler::execute (); + + tl::OutputStream stream (fn); + mp_canvas->image (width, height).write_png (stream); + + tl::log << "Saved image to " << fn; +} +#endif + +#if defined(HAVE_QT) +void LayoutViewBase::save_image_with_options (const std::string &fn, - unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, - lay::Color background, lay::Color foreground, lay::Color active, const db::DBox &target_box, bool monochrome) + unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, + lay::Color background, lay::Color foreground, lay::Color active, const db::DBox &target_box, bool monochrome) { tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Save image"))); QImageWriter writer (tl::to_qstring (fn), QByteArray ("PNG")); - // Unfortunately the PNG writer does not allow writing of long strings. - // We separate the description into a set of keys: - - for (unsigned int i = 0; i < cellviews (); ++i) { - if (cellview (i).is_valid ()) { - std::string name = cellview (i)->layout ().cell_name (cellview (i).cell_index ()); - writer.setText (tl::to_qstring ("Cell" + tl::to_string (int (i) + 1)), tl::to_qstring (name)); - } + lay::Viewport vp (width, height, mp_canvas->viewport ().target_box ()); + std::vector > texts = png_texts (this, vp.box ()); + for (auto i = texts.begin (); i != texts.end (); ++i) { + writer.setText (tl::to_qstring (i->first), tl::to_qstring (i->second)); } - lay::Viewport vp (width, height, mp_canvas->viewport ().target_box ()); - writer.setText (QString::fromUtf8 ("Rect"), tl::to_qstring (vp.box ().to_string ())); - // Execute all deferred methods - ensure there are no pending tasks tl::DeferredMethodScheduler::execute (); if (monochrome) { - if (! writer.write (mp_canvas->image_with_options_mono (width, height, linewidth, background.green () >= 128, foreground.green () >= 128, active.green () >= 128, target_box).to_image ())) { + if (! writer.write (mp_canvas->image_with_options_mono (width, height, linewidth, background.to_mono (), foreground.to_mono (), active.to_mono (), target_box).to_image ())) { throw tl::Exception (tl::to_string (QObject::tr ("Unable to write screenshot to file: %s (%s)")), fn, tl::to_string (writer.errorString ())); } } else { @@ -2606,7 +2689,30 @@ LayoutViewBase::save_image_with_options (const std::string &fn, } } - tl::log << "Saved screen shot to " << fn; + tl::log << "Saved image to " << fn; +} +#else +void +LayoutViewBase::save_image_with_options (const std::string &fn, + unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, + lay::Color background, lay::Color foreground, lay::Color active, const db::DBox &target_box, bool monochrome) +{ + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Save image"))); + + lay::Viewport vp (width, height, mp_canvas->viewport ().target_box ()); + std::vector > texts = png_texts (this, vp.box ()); + + // Execute all deferred methods - ensure there are no pending tasks + tl::DeferredMethodScheduler::execute (); + + tl::OutputStream stream (fn); + if (monochrome) { + mp_canvas->image_with_options_mono (width, height, linewidth, background.to_mono (), foreground.to_mono (), active.to_mono (), target_box).write_png (stream); + } else { + mp_canvas->image_with_options (width, height, linewidth, oversampling, resolution, background, foreground, active, target_box).write_png (stream); + } + + tl::log << "Saved image to " << fn; } #endif @@ -3591,7 +3697,7 @@ LayoutViewBase::do_prop_changed () void LayoutViewBase::set_view_ops () { - bool bright_background = (mp_canvas->background_color ().green () > 128); + bool bright_background = (mp_canvas->background_color ().to_mono ()); int brightness_for_context = ((bright_background ? m_ctx_dimming : -m_ctx_dimming) * 256) / 100; int brightness_for_child_context = ((bright_background ? m_child_ctx_dimming : -m_child_ctx_dimming) * 256) / 100; @@ -4185,7 +4291,7 @@ LayoutViewBase::background_color (lay::Color c) } lay::Color contrast; - if (c.green () > 128) { + if (c.to_mono ()) { contrast = lay::Color (0, 0, 0); } else { contrast = lay::Color (255, 255, 255); diff --git a/src/laybasic/laybasic/layLayoutViewBase.h b/src/laybasic/laybasic/layLayoutViewBase.h index d1bcaa412..d2a91e26f 100644 --- a/src/laybasic/laybasic/layLayoutViewBase.h +++ b/src/laybasic/laybasic/layLayoutViewBase.h @@ -798,16 +798,22 @@ public: */ void load_layer_props (const std::string &fn, int cv_index, bool add_default); -#if defined(HAVE_QT) // @@@ /** * @brief Save the screen content to a file */ void save_screenshot (const std::string &fn); +#if defined(HAVE_QT) /** * @brief Get the screen content as a QImage object */ QImage get_screenshot (); +#endif + + /** + * @brief Gets the screen content as a lay::PixelBuffer object + */ + lay::PixelBuffer get_screenshot_pb (); /** * @brief Save an image file with the given width and height @@ -831,11 +837,19 @@ public: */ void save_image_with_options (const std::string &fn, unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, Color background, Color foreground, Color active_color, const db::DBox &target_box, bool monochrome); +#if defined(HAVE_QT) /** * @brief Get the screen content as a QImage object with the given width and height */ QImage get_image (unsigned int width, unsigned int height); +#endif + /** + * @brief Gets the screen content as a lay::PixelBuffer object + */ + lay::PixelBuffer get_pixels (unsigned int width, unsigned int height); + +#if defined(HAVE_QT) /** * @brief Get the screen content as a QImage object with the given width and height * @@ -853,6 +867,38 @@ public: QImage get_image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, lay::Color background, lay::Color foreground, lay::Color active_color, const db::DBox &target_box, bool monochrome); #endif + /** + * @brief Get the screen content as a lay::PixelBuffer object with the given width and height + * + * @param width The width of the image in pixels + * @param height The height of the image + * @param linewidth The width of a line in pixels (usually 1) or 0 for default + * @param oversampling The oversampling factor (1..3) or 0 for default + * @param resolution The resolution (pixel size compared to a screen pixel size, i.e 1/oversampling) or 0 for default + * @param background The background color or lay::Color() for default + * @param foreground The foreground color or lay::Color() for default + * @param active The active color or lay::Color() for default + * @param target_box The box to draw or db::DBox() for default + */ + lay::PixelBuffer get_pixels_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, lay::Color background, lay::Color foreground, lay::Color active_color, const db::DBox &target_box); + + /** + * @brief Get the screen content as a monochrome lay::BitmapBuffer object with the given options + * + * @param width The width of the image in pixels + * @param height The height of the image + * @param linewidth The width of a line in pixels (usually 1) or 0 for default + * @param oversampling The oversampling factor (1..3) or 0 for default + * @param resolution The resolution (pixel size compared to a screen pixel size, i.e 1/oversampling) or 0 for default + * @param background The background color or lay::Color() for default + * @param foreground The foreground color or lay::Color() for default + * @param active The active color or lay::Color() for default + * @param target_box The box to draw or db::DBox() for default + * + * The colors will are converted to "on" pixels with a green channel value >= 50%. + */ + lay::BitmapBuffer get_pixels_with_options_mono (unsigned int width, unsigned int height, int linewidth, lay::Color background, lay::Color foreground, lay::Color active_color, const db::DBox &target_box); + /** * @brief Hierarchy level selection setter */ diff --git a/src/laybasic/laybasic/layNetlistBrowserPage.cc b/src/laybasic/laybasic/layNetlistBrowserPage.cc index ef1fdc4f0..1909956f9 100644 --- a/src/laybasic/laybasic/layNetlistBrowserPage.cc +++ b/src/laybasic/laybasic/layNetlistBrowserPage.cc @@ -1099,7 +1099,7 @@ lay::Color NetlistBrowserPage::make_valid_color (const lay::Color &color) { if (! color.is_valid () && mp_view) { - return mp_view->background_color ().green () < 128 ? lay::Color (255, 255, 255) : lay::Color (0, 0, 0); + return mp_view->background_color ().to_mono () ? lay::Color (0, 0, 0) : lay::Color (255, 255, 255); } else { return color; } diff --git a/src/laybasic/laybasic/laybasic.pro b/src/laybasic/laybasic/laybasic.pro index f5a3c3334..1702e9fac 100644 --- a/src/laybasic/laybasic/laybasic.pro +++ b/src/laybasic/laybasic/laybasic.pro @@ -138,8 +138,6 @@ DEFINES += MAKE_LAYBASIC_LIBRARY layNetlistBrowserPage.cc \ layNetlistBrowserTreeModel.cc \ layNetlistCrossReferenceModel.cc \ - layPixelBuffer.cc \ - layPixelBufferPainter.cc \ layPluginConfigPage.cc \ layProperties.cc \ layPropertiesDialog.cc \ @@ -213,8 +211,6 @@ DEFINES += MAKE_LAYBASIC_LIBRARY layNetlistBrowserPage.h \ layNetlistBrowserTreeModel.h \ layNetlistCrossReferenceModel.h \ - layPixelBuffer.h \ - layPixelBufferPainter.h \ layPluginConfigPage.h \ layProperties.h \ layPropertiesDialog.h \ @@ -267,6 +263,8 @@ SOURCES += \ layNetColorizer.cc \ layObjectInstPath.cc \ layParsedLayerSource.cc \ + layPixelBuffer.cc \ + layPixelBufferPainter.cc \ layPlugin.cc \ layRedrawLayerInfo.cc \ layRedrawThread.cc \ @@ -308,6 +306,8 @@ HEADERS += \ layNetColorizer.h \ layObjectInstPath.h \ layParsedLayerSource.h \ + layPixelBuffer.h \ + layPixelBufferPainter.h \ layPlugin.h \ layRedrawLayerInfo.h \ layRedrawThread.h \ diff --git a/src/plugins/tools/net_tracer/lay_plugin/layNetTracerDialog.cc b/src/plugins/tools/net_tracer/lay_plugin/layNetTracerDialog.cc index 7bda1dbb2..d9b50d85a 100644 --- a/src/plugins/tools/net_tracer/lay_plugin/layNetTracerDialog.cc +++ b/src/plugins/tools/net_tracer/lay_plugin/layNetTracerDialog.cc @@ -1640,7 +1640,7 @@ NetTracerDialog::update_highlights () mp_markers.back ()->set_line_width (original->width (true)); mp_markers.back ()->set_vertex_size (1); mp_markers.back ()->set_dither_pattern (original->dither_pattern (true)); - if (view ()->background_color ().green () < 128) { + if (! view ()->background_color ().to_mono ()) { mp_markers.back ()->set_color (original->eff_fill_color_brighter (true, (m_marker_intensity * 255) / 100)); mp_markers.back ()->set_frame_color (original->eff_frame_color_brighter (true, (m_marker_intensity * 255) / 100)); } else { diff --git a/src/plugins/tools/view_25d/lay_plugin/layD25ViewWidget.cc b/src/plugins/tools/view_25d/lay_plugin/layD25ViewWidget.cc index 9fa1f77d6..45194bca0 100644 --- a/src/plugins/tools/view_25d/lay_plugin/layD25ViewWidget.cc +++ b/src/plugins/tools/view_25d/lay_plugin/layD25ViewWidget.cc @@ -1090,10 +1090,10 @@ D25ViewWidget::paintGL () glViewport (0, 0, width () * retina_scale, height () * retina_scale); lay::Color c = mp_view->background_color (); - float foreground_rgb = (c.green () > 128 ? 0.0f : 1.0f); - float ambient = (c.green () > 128 ? 0.8f : 0.25f); - float mist_factor = (c.green () > 128 ? 0.2f : 0.4f); - float mist_add = (c.green () > 128 ? 0.8f : 0.2f); + float foreground_rgb = (c.to_mono () ? 0.0f : 1.0f); + float ambient = (c.to_mono () ? 0.8f : 0.25f); + float mist_factor = (c.to_mono () ? 0.2f : 0.4f); + float mist_add = (c.to_mono () ? 0.8f : 0.2f); glClearColor (float (c.red ()) / 255.0f, float (c.green ()) / 255.0f, float (c.blue ()) / 255.0f, 1.0); glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); From e6061ff96ff5eea3f12e2d0eb6ef568e7e05e0a6 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 7 May 2022 18:39:56 +0200 Subject: [PATCH 34/88] CONSIDER MERGING: avoid a segfault due to early delete of a LayoutView object --- src/lay/lay/layMainWindow.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lay/lay/layMainWindow.cc b/src/lay/lay/layMainWindow.cc index d632ce26a..68b420586 100644 --- a/src/lay/lay/layMainWindow.cc +++ b/src/lay/lay/layMainWindow.cc @@ -2876,7 +2876,9 @@ MainWindow::close_view (int index) view_closed_event (int (index)); - delete view (index); + // delete the view later as it may still be needed by event handlers or similar + std::unique_ptr old_view (view (index)); + mp_views.erase (mp_views.begin () + index, mp_views.begin () + index + 1); if (index >= int (mp_views.size ())) { From 958e1f7c598feb9f71f5187c6bc37ad2b7b09ee7 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 7 May 2022 18:48:33 +0200 Subject: [PATCH 35/88] WIP: base class-implemented methods need to be qualified in GSI binding :( --- src/laybasic/laybasic/gsiDeclLayLayoutView.cc | 206 +++++++++--------- 1 file changed, 103 insertions(+), 103 deletions(-) diff --git a/src/laybasic/laybasic/gsiDeclLayLayoutView.cc b/src/laybasic/laybasic/gsiDeclLayLayoutView.cc index 73a8e0350..07ecd89a2 100644 --- a/src/laybasic/laybasic/gsiDeclLayLayoutView.cc +++ b/src/laybasic/laybasic/gsiDeclLayLayoutView.cc @@ -551,7 +551,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "This constant has been introduced in version 0.27.\n" ) + #if defined(HAVE_QTBINDINGS) - gsi::method ("layer_control_frame", &lay::LayoutView::layer_control_frame, + gsi::method ("layer_control_frame", static_cast (&lay::LayoutView::layer_control_frame), "@brief Gets the layer control side widget\n" "A 'side widget' is a widget attached to the view. It does not have a parent, so you can " "embed it into a different context. Please note that with embedding through 'setParent' it will be " @@ -561,26 +561,26 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This method has been introduced in version 0.27\n" ) + - gsi::method ("hierarchy_control_frame", &lay::LayoutView::hierarchy_control_frame, + gsi::method ("hierarchy_control_frame", static_cast (&lay::LayoutView::hierarchy_control_frame), "@brief Gets the cell view (hierarchy view) side widget\n" "For details about side widgets see \\layer_control_frame.\n" "\n" "This method has been introduced in version 0.27\n" ) + - gsi::method ("libraries_frame", &lay::LayoutView::libraries_frame, + gsi::method ("libraries_frame", static_cast (&lay::LayoutView::libraries_frame), "@brief Gets the library view side widget\n" "For details about side widgets see \\layer_control_frame.\n" "\n" "This method has been introduced in version 0.27\n" ) + - gsi::method ("bookmarks_frame", &lay::LayoutView::bookmarks_frame, + gsi::method ("bookmarks_frame", static_cast (&lay::LayoutView::bookmarks_frame), "@brief Gets the bookmarks side widget\n" "For details about side widgets see \\layer_control_frame.\n" "\n" "This method has been introduced in version 0.27\n" ) + #endif - gsi::method ("call_menu", &lay::LayoutView::menu_activated, + gsi::method ("call_menu", static_cast (&lay::LayoutView::menu_activated), "@brief Calls the menu item with the provided symbol.\n" "To obtain all symbols, use get_menu_symbols.\n" "\n" @@ -600,14 +600,14 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "This method has been introduced in version 0.23.\n" ) + #endif - gsi::method ("stop_redraw", &lay::LayoutView::stop_redraw, + gsi::method ("stop_redraw", static_cast (&lay::LayoutView::stop_redraw), "@brief Stops the redraw thread\n" "\n" "It is very important to stop the redraw thread before applying changes to the " "layout or the cell views and the LayoutView configuration. This is usually done automatically. " "For rare cases, where this is not the case, this method is provided.\n" ) + - gsi::method ("title=|#set_title", &lay::LayoutView::set_title, gsi::arg ("title"), + gsi::method ("title=|#set_title", static_cast (&lay::LayoutView::set_title), gsi::arg ("title"), "@brief Sets the title of the view\n" "\n" "@param title The title string to use\n" @@ -616,12 +616,12 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "the specified title string. The title string can be reset with \\reset_title to " "the standard title again." ) + - gsi::method ("reset_title", &lay::LayoutView::reset_title, + gsi::method ("reset_title", static_cast (&lay::LayoutView::reset_title), "@brief Resets the title to the standard title\n" "\n" "See \\set_title and \\title for a description about how titles are handled." ) + - gsi::method ("title", &lay::LayoutView::title, + gsi::method ("title", static_cast (&lay::LayoutView::title), "@brief Returns the view's title string\n" "\n" "@return The title string\n" @@ -629,19 +629,19 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "The title string is either a string composed of the file names loaded (in some " "\"readable\" manner) or a customized title string set by \\set_title." ) + - gsi::method ("save_layer_props", &lay::LayoutView::save_layer_props, gsi::arg ("fn"), + gsi::method ("save_layer_props", static_cast (&lay::LayoutView::save_layer_props), gsi::arg ("fn"), "@brief Saves the layer properties\n" "\n" "Save the layer properties to the file given in \"fn\"" ) + - gsi::method ("load_layer_props", (void (lay::LayoutView::*)(const std::string &)) &lay::LayoutView::load_layer_props, gsi::arg ("fn"), + gsi::method ("load_layer_props", static_cast (&lay::LayoutView::load_layer_props), gsi::arg ("fn"), "@brief Loads the layer properties\n" "\n" "@param fn The file name of the .lyp file to load\n" "\n" "Load the layer properties from the file given in \"fn\"" ) + - gsi::method ("load_layer_props", (void (lay::LayoutView::*)(const std::string &, bool)) &lay::LayoutView::load_layer_props, gsi::arg ("fn"), gsi::arg ("add_default"), + gsi::method ("load_layer_props", static_cast (&lay::LayoutView::load_layer_props), gsi::arg ("fn"), gsi::arg ("add_default"), "@brief Loads the layer properties with options\n" "\n" "@param fn The file name of the .lyp file to load\n" @@ -653,7 +653,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This variant has been added on version 0.21." ) + - gsi::method ("load_layer_props", (void (lay::LayoutView::*)(const std::string &, int, bool)) &lay::LayoutView::load_layer_props, gsi::arg ("fn"), gsi::arg ("cv_index"), gsi::arg ("add_default"), + gsi::method ("load_layer_props", static_cast (&lay::LayoutView::load_layer_props), gsi::arg ("fn"), gsi::arg ("cv_index"), gsi::arg ("add_default"), "@brief Loads the layer properties with options\n" "\n" "@param fn The file name of the .lyp file to load\n" @@ -671,7 +671,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This variant has been added on version 0.21." ) + - gsi::method ("min_hier_levels=", &lay::LayoutView::set_min_hier_levels, gsi::arg ("level"), + gsi::method ("min_hier_levels=", static_cast (&lay::LayoutView::set_min_hier_levels), gsi::arg ("level"), "@brief Sets the minimum hierarchy level at which to display geometries\n" "\n" "@param level The minimum level above which to display something\n" @@ -679,12 +679,12 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "This methods allows setting the minimum hierarchy level above which to display geometries." "This method may cause a redraw if required." ) + - gsi::method ("min_hier_levels", &lay::LayoutView::get_min_hier_levels, + gsi::method ("min_hier_levels", static_cast (&lay::LayoutView::get_min_hier_levels), "@brief Returns the minimum hierarchy level at which to display geometries\n" "\n" "@return The minimum level at which to display geometries" ) + - gsi::method ("max_hier_levels=", &lay::LayoutView::set_max_hier_levels, gsi::arg ("level"), + gsi::method ("max_hier_levels=", static_cast (&lay::LayoutView::set_max_hier_levels), gsi::arg ("level"), "@brief Sets the maximum hierarchy level up to which to display geometries\n" "\n" "@param level The maximum level below which to display something\n" @@ -692,12 +692,12 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "This methods allows setting the maximum hierarchy below which to display geometries." "This method may cause a redraw if required." ) + - gsi::method ("max_hier_levels", &lay::LayoutView::get_max_hier_levels, + gsi::method ("max_hier_levels", static_cast (&lay::LayoutView::get_max_hier_levels), "@brief Returns the maximum hierarchy level up to which to display geometries\n" "\n" "@return The maximum level up to which to display geometries" ) + - gsi::method ("enable_edits", &lay::LayoutView::enable_edits, gsi::arg ("enable"), + gsi::method ("enable_edits", static_cast (&lay::LayoutView::enable_edits), gsi::arg ("enable"), "@brief Enables or disables edits\n" "\n" "@param enable Enable edits if set to true\n" @@ -710,17 +710,17 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "In 0.25, this method has been moved from MainWindow to LayoutView.\n" ) + - gsi::method ("is_editable?", &lay::LayoutView::is_editable, + gsi::method ("is_editable?", static_cast (&lay::LayoutView::is_editable), "@brief Returns true if the view is in editable mode\n" "\n" "This read-only attribute has been added in version 0.27.5.\n" ) + - gsi::method ("reload_layout", &lay::LayoutView::reload_layout, gsi::arg ("cv"), + gsi::method ("reload_layout", static_cast (&lay::LayoutView::reload_layout), gsi::arg ("cv"), "@brief Reloads the given cellview\n" "\n" "@param cv The index of the cellview to reload" ) + - gsi::method ("create_layout", (unsigned int (lay::LayoutView::*) (bool)) &lay::LayoutView::create_layout, gsi::arg ("add_cellview"), + gsi::method ("create_layout", static_cast (&lay::LayoutView::create_layout), gsi::arg ("add_cellview"), "@brief Creates a new, empty layout\n" "\n" "The add_cellview parameter controls whether to create a new cellview (true)\n" @@ -730,7 +730,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "@return The index of the cellview created.\n" ) + - gsi::method ("create_layout", (unsigned int (lay::LayoutView::*) (const std::string &, bool)) &lay::LayoutView::create_layout, gsi::arg ("tech"), gsi::arg ("add_cellview"), + gsi::method ("create_layout", static_cast (&lay::LayoutView::create_layout), gsi::arg ("tech"), gsi::arg ("add_cellview"), "@brief Create a new, empty layout and associate it with the given technology\n" "\n" "The add_cellview parameter controls whether to create a new cellview (true)\n" @@ -740,7 +740,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This variant has been introduced in version 0.22.\n" ) + - gsi::method ("create_layout", (unsigned int (lay::LayoutView::*) (const std::string &, bool, bool)) &lay::LayoutView::create_layout, gsi::arg ("tech"), gsi::arg ("add_cellview"), gsi::arg ("init_layers"), + gsi::method ("create_layout", static_cast (&lay::LayoutView::create_layout), gsi::arg ("tech"), gsi::arg ("add_cellview"), gsi::arg ("init_layers"), "@brief Create a new, empty layout and associate it with the given technology\n" "\n" "The add_cellview parameter controls whether to create a new cellview (true)\n" @@ -798,12 +798,12 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This method has been introduced in version 0.22.\n" ) + - gsi::method ("erase_cellview", &lay::LayoutView::erase_cellview, gsi::arg ("index"), + gsi::method ("erase_cellview", static_cast (&lay::LayoutView::erase_cellview), gsi::arg ("index"), "@brief Erases the cellview with the given index\n" "\n" "This closes the given cellview and unloads the layout associated with it, unless referred to by another cellview." ) + - gsi::method ("rename_cellview", &lay::LayoutView::rename_cellview, gsi::arg ("name"), gsi::arg ("index"), + gsi::method ("rename_cellview", static_cast (&lay::LayoutView::rename_cellview), gsi::arg ("name"), gsi::arg ("index"), "@brief Renames the cellview with the given index\n" "\n" "If the name is not unique, a unique name will be constructed from the name given.\n" @@ -811,7 +811,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "If a layout is shared between multiple cellviews (which may happen due to a clone of the layout view\n" "for example), all cellviews are renamed.\n" ) + - gsi::method ("load_layout", (unsigned int (lay::LayoutView::*) (const std::string &, const db::LoadLayoutOptions &, const std::string &, bool)) &lay::LayoutView::load_layout, gsi::arg ("filename"), gsi::arg ("options"), gsi::arg ("technology"), gsi::arg ("add_cellview"), + gsi::method ("load_layout", static_cast (&lay::LayoutView::load_layout), gsi::arg ("filename"), gsi::arg ("options"), gsi::arg ("technology"), gsi::arg ("add_cellview"), "@brief Loads a (new) file into the layout view with the given technology\n" "\n" "Loads the file given by the \"filename\" parameter and associates it with the given technology.\n" @@ -823,7 +823,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This version has been introduced in version 0.22.\n" ) + - gsi::method ("load_layout", (unsigned int (lay::LayoutView::*) (const std::string &, const db::LoadLayoutOptions &, bool)) &lay::LayoutView::load_layout, gsi::arg ("filename"), gsi::arg ("options"), gsi::arg ("add_cellview"), + gsi::method ("load_layout", static_cast (&lay::LayoutView::load_layout), gsi::arg ("filename"), gsi::arg ("options"), gsi::arg ("add_cellview"), "@brief Loads a (new) file into the layout view\n" "\n" "Loads the file given by the \"filename\" parameter.\n" @@ -835,7 +835,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This method has been introduced in version 0.18.\n" ) + - gsi::method ("load_layout", (unsigned int (lay::LayoutView::*) (const std::string &, const std::string &, bool)) &lay::LayoutView::load_layout, gsi::arg ("filename"), gsi::arg ("technology"), gsi::arg ("add_cellview"), + gsi::method ("load_layout", static_cast (&lay::LayoutView::load_layout), gsi::arg ("filename"), gsi::arg ("technology"), gsi::arg ("add_cellview"), "@brief Loads a (new) file into the layout view with the given technology\n" "\n" "Loads the file given by the \"filename\" parameter and associates it with the given technology.\n" @@ -846,7 +846,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This version has been introduced in version 0.22.\n" ) + - gsi::method ("load_layout", (unsigned int (lay::LayoutView::*) (const std::string &filename, bool add_cellview)) &lay::LayoutView::load_layout, gsi::arg ("filename"), gsi::arg ("add_cellview"), + gsi::method ("load_layout", static_cast (&lay::LayoutView::load_layout), gsi::arg ("filename"), gsi::arg ("add_cellview"), "@brief Loads a (new) file into the layout view\n" "\n" "Loads the file given by the \"filename\" parameter.\n" @@ -855,7 +855,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "@return The index of the cellview loaded.\n" ) + - gsi::method ("active_cellview", &lay::LayoutView::active_cellview_ref, + gsi::method ("active_cellview", static_cast (&lay::LayoutView::active_cellview_ref), "@brief Gets the active cellview (shown in hierarchy browser)\n" "\n" "This is a convenience method which is equivalent to cellview(active_cellview_index()).\n" @@ -864,7 +864,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "Starting from version 0.25, the returned object can be manipulated which will have an immediate effect " "on the display." ) + - gsi::method ("active_cellview_index", &lay::LayoutView::active_cellview_index, + gsi::method ("active_cellview_index", static_cast (&lay::LayoutView::active_cellview_index), "@brief Gets the index of the active cellview (shown in hierarchy browser)\n" ) + gsi::method ("active_setview_index=|#set_active_cellview_index", &lay::LayoutView::set_active_cellview_index, gsi::arg ("index"), @@ -885,7 +885,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This method has be introduced in version 0.25.\n" ) + - gsi::method ("#get_current_cell_path", &lay::LayoutView::get_current_cell_path, gsi::arg ("cv_index"), + gsi::method ("#get_current_cell_path", static_cast (&lay::LayoutView::get_current_cell_path), gsi::arg ("cv_index"), "@brief Gets the cell path of the current cell\n" "\n" "The current cell is the one highlighted in the browser with the focus rectangle. The \n" @@ -896,7 +896,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This method is was deprecated in version 0.25 since from then, the \\CellView object can be used to obtain an manipulate the selected cell." ) + - gsi::method ("#set_current_cell_path", (void (lay::LayoutView::*) (int, const lay::LayoutView::cell_path_type &)) &lay::LayoutView::set_current_cell_path, gsi::arg ("cv_index"), gsi::arg ("cell_path"), + gsi::method ("#set_current_cell_path", static_cast (&lay::LayoutView::set_current_cell_path), gsi::arg ("cv_index"), gsi::arg ("cell_path"), "@brief Sets the path to the current cell\n" "\n" "The current cell is the one highlighted in the browser with the focus rectangle. The\n" @@ -908,10 +908,10 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This method is was deprecated in version 0.25 since from then, the \\CellView object can be used to obtain an manipulate the selected cell." ) + - gsi::method ("cellviews", &lay::LayoutView::cellviews, + gsi::method ("cellviews", static_cast (&lay::LayoutView::cellviews), "@brief Gets the number of cellviews\n" ) + - gsi::method ("cellview", &lay::LayoutView::cellview_ref, gsi::arg ("cv_index"), + gsi::method ("cellview", static_cast (&lay::LayoutView::cellview_ref), gsi::arg ("cv_index"), "@brief Gets the cellview object for a given index\n" "\n" "@param cv_index The cellview index for which to get the object for\n" @@ -919,43 +919,43 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "Starting with version 0.25, this method returns a \\CellView object that can be manipulated to directly reflect " "any changes in the display." ) + - gsi::method ("zoom_fit", &lay::LayoutView::zoom_fit, + gsi::method ("zoom_fit", static_cast (&lay::LayoutView::zoom_fit), "@brief Fits the contents of the current view into the window" ) + - gsi::method ("zoom_fit_sel", &lay::LayoutView::zoom_fit_sel, + gsi::method ("zoom_fit_sel", static_cast (&lay::LayoutView::zoom_fit_sel), "@brief Fits the contents of the current selection into the window\n" "\n" "This method has been introduced in version 0.25.\n" ) + - gsi::method ("zoom_box", &lay::LayoutView::zoom_box, gsi::arg ("box"), + gsi::method ("zoom_box", static_cast (&lay::LayoutView::zoom_box), gsi::arg ("box"), "@brief Sets the viewport to the given box\n" "\n" "@param box The box to which to set the view in micron coordinates\n" ) + - gsi::method ("zoom_in", &lay::LayoutView::zoom_in, + gsi::method ("zoom_in", static_cast (&lay::LayoutView::zoom_in), "@brief Zooms in somewhat" ) + - gsi::method ("zoom_out", &lay::LayoutView::zoom_out, + gsi::method ("zoom_out", static_cast (&lay::LayoutView::zoom_out), "@brief Zooms out somewhat" ) + - gsi::method ("pan_up", &lay::LayoutView::pan_up, + gsi::method ("pan_up", static_cast (&lay::LayoutView::pan_up), "@brief Pans upward" ) + - gsi::method ("pan_down", &lay::LayoutView::pan_down, + gsi::method ("pan_down", static_cast (&lay::LayoutView::pan_down), "@brief Pans down" ) + - gsi::method ("pan_left", &lay::LayoutView::pan_left, + gsi::method ("pan_left", static_cast (&lay::LayoutView::pan_left), "@brief Pans to the left" ) + - gsi::method ("pan_right", &lay::LayoutView::pan_right, + gsi::method ("pan_right", static_cast (&lay::LayoutView::pan_right), "@brief Pans to the right" ) + - gsi::method ("pan_center", &lay::LayoutView::pan_center, gsi::arg ("p"), + gsi::method ("pan_center", static_cast (&lay::LayoutView::pan_center), gsi::arg ("p"), "@brief Pans to the given point\n" "\n" "The window is positioned such that \"p\" becomes the new center" ) + - gsi::method ("box", &lay::LayoutView::box, + gsi::method ("box", static_cast (&lay::LayoutView::box), "@brief Returns the displayed box in micron space" ) + gsi::method_ext ("viewport_trans", &viewport_trans, @@ -974,17 +974,17 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "This method was introduced in version 0.18.\n" ) + #if defined(HAVE_QT) - gsi::method ("bookmark_view", &lay::LayoutView::bookmark_view, gsi::arg ("name"), + gsi::method ("bookmark_view", static_cast (&lay::LayoutView::bookmark_view), gsi::arg ("name"), "@brief Bookmarks the current view under the given name\n" "\n" "@param name The name under which to bookmark the current state" ) + #endif - gsi::method ("add_missing_layers", &lay::LayoutView::add_missing_layers, + gsi::method ("add_missing_layers", static_cast (&lay::LayoutView::add_missing_layers), "@brief Adds new layers to layer list\n" "This method was introduced in version 0.19.\n" ) + - gsi::method ("remove_unused_layers", &lay::LayoutView::remove_unused_layers, + gsi::method ("remove_unused_layers", static_cast (&lay::LayoutView::remove_unused_layers), "@brief Removes unused layers from layer list\n" "This method was introduced in version 0.19.\n" ) + @@ -1032,12 +1032,12 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This method has been introduced in version 0.27\n" ) + - gsi::method ("clear_transient_selection", &lay::LayoutView::clear_transient_selection, + gsi::method ("clear_transient_selection", static_cast (&lay::LayoutView::clear_transient_selection), "@brief Clears the transient selection (mouse-over hightlights) of all objects (shapes, annotations, images ...)\n" "\n" "This method has been introduced in version 0.26.2\n" ) + - gsi::method ("transient_to_selection", &lay::LayoutView::transient_to_selection, + gsi::method ("transient_to_selection", static_cast (&lay::LayoutView::transient_to_selection), "@brief Turns the transient selection into the actual selection\n" "\n" "The current selection is cleared before. All highlighted objects under the mouse will become selected. " @@ -1045,7 +1045,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This method has been introduced in version 0.26.2\n" ) + - gsi::method ("selection_bbox", &lay::LayoutView::selection_bbox, + gsi::method ("selection_bbox", static_cast (&lay::LayoutView::selection_bbox), "@brief Returns the bounding box of the current selection\n" "\n" "This method has been introduced in version 0.26.2\n" @@ -1060,7 +1060,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This method has been introduced in version 0.27\n" ) + - gsi::method ("stop", &lay::LayoutView::stop, + gsi::method ("stop", static_cast (&lay::LayoutView::stop), "@brief Stops redraw thread and close any browsers\n" "This method usually does not need to be called explicitly. The redraw thread is stopped automatically." ) + @@ -1085,7 +1085,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This method is was deprecated in version 0.25 since from then, the \\CellView object can be used to obtain an manipulate the selected cell." ) + - gsi::method ("descend", &lay::LayoutView::descend, gsi::arg ("path"), gsi::arg ("index"), + gsi::method ("descend", static_cast &, int)> (&lay::LayoutView::descend), gsi::arg ("path"), gsi::arg ("index"), "@brief Descends further into the hierarchy.\n" "\n" "Adds the given path (given as an array of InstElement objects) to the specific path of the " @@ -1095,21 +1095,21 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "The path is assumed to originate from the current cell and contain specific instances sorted from " "top to bottom." ) + - gsi::method ("ascend", &lay::LayoutView::ascend, gsi::arg ("index"), + gsi::method ("ascend", static_cast (&lay::LayoutView::ascend), gsi::arg ("index"), "@brief Ascends upwards in the hierarchy.\n" "\n" "Removes one element from the specific path of the cellview with the given index. Returns the element " "removed." ) + - gsi::method ("is_cell_hidden?", &lay::LayoutView::is_cell_hidden, gsi::arg ("cell_index"), gsi::arg ("cv_index"), + gsi::method ("is_cell_hidden?", static_cast (&lay::LayoutView::is_cell_hidden), gsi::arg ("cell_index"), gsi::arg ("cv_index"), "@brief Returns true, if the cell is hidden\n" "\n" "@return True, if the cell with \"cell_index\" is hidden for the cellview \"cv_index\"" ) + - gsi::method ("hide_cell", &lay::LayoutView::hide_cell, gsi::arg ("cell_index"), gsi::arg ("cv_index"), + gsi::method ("hide_cell", static_cast (&lay::LayoutView::hide_cell), gsi::arg ("cell_index"), gsi::arg ("cv_index"), "@brief Hides the given cell for the given cellview\n" ) + - gsi::method ("show_cell", &lay::LayoutView::show_cell, gsi::arg ("cell_index"), gsi::arg ("cv_index"), + gsi::method ("show_cell", static_cast (&lay::LayoutView::show_cell), gsi::arg ("cell_index"), gsi::arg ("cv_index"), "@brief Shows the given cell for the given cellview (cancel effect of \\hide_cell)\n" ) + gsi::method ("show_all_cells", (void (lay::LayoutView::*) ()) &lay::LayoutView::show_all_cells, @@ -1121,7 +1121,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This variant has been added in version 0.25." ) + - gsi::method ("update_content", &lay::LayoutView::force_update_content, + gsi::method ("update_content", static_cast (&lay::LayoutView::force_update_content), "@brief Updates the layout view to the current state\n" "\n" "This method triggers an update of the hierarchy tree and layer view tree. Usually, this " @@ -1130,21 +1130,21 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "Currently, this method should be called however, after the layer view tree has been changed by " "the \\insert_layer, \\replace_layer_node or \\delete_layer methods.\n" ) + - gsi::method ("max_hier", &lay::LayoutView::max_hier, + gsi::method ("max_hier", static_cast (&lay::LayoutView::max_hier), "@brief Selects all hierarchy levels available\n" "\n" "Show the layout in full depth down to the deepest level of hierarchy. " "This method may cause a redraw." ) + #if defined(HAVE_QT) && defined(HAVE_QTBINDINGS) - gsi::method ("get_screenshot", &lay::LayoutView::get_screenshot, + gsi::method ("get_screenshot", static_cast (&lay::LayoutView::get_screenshot), "@brief Gets a screenshot as a \\QImage\n" "\n" "Getting the image requires the drawing to be complete. Ideally, synchronous mode is switched on " "for the application to guarantee this condition. The image will have the size of the viewport " "showing the current layout." ) + - gsi::method ("get_image", &lay::LayoutView::get_image, gsi::arg ("width"), gsi::arg ("height"), + gsi::method ("get_image", static_cast (&lay::LayoutView::get_image), gsi::arg ("width"), gsi::arg ("height"), "@brief Gets the layout image as a \\QImage\n" "\n" "@param width The width of the image to render in pixel.\n" @@ -1171,7 +1171,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "This method has been introduced in 0.23.10.\n" ) + #endif - gsi::method ("get_screenshot_pixels", &lay::LayoutView::get_screenshot_pb, + gsi::method ("get_screenshot_pixels", static_cast (&lay::LayoutView::get_screenshot_pb), "@brief Gets a screenshot as a \\PixelBuffer\n" "\n" "Getting the image requires the drawing to be complete. Ideally, synchronous mode is switched on " @@ -1180,7 +1180,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This method has been introduced in 0.28.\n" ) + - gsi::method ("get_pixels", &lay::LayoutView::get_pixels, gsi::arg ("width"), gsi::arg ("height"), + gsi::method ("get_pixels", static_cast (&lay::LayoutView::get_pixels), gsi::arg ("width"), gsi::arg ("height"), "@brief Gets the layout image as a \\PixelBuffer\n" "\n" "@param width The width of the image to render in pixel.\n" @@ -1220,7 +1220,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This method has been introduced in 0.28.\n" ) + - gsi::method ("save_screenshot", &lay::LayoutView::save_screenshot, gsi::arg ("filename"), + gsi::method ("save_screenshot", static_cast (&lay::LayoutView::save_screenshot), gsi::arg ("filename"), "@brief Saves a screenshot to the given file\n" "\n" "@param filename The file to which to write the screenshot to.\n" @@ -1230,7 +1230,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "for the application to guarantee this condition. The image will have the size of the viewport " "showing the current layout." ) + - gsi::method ("save_image", &lay::LayoutView::save_image, gsi::arg ("filename"), gsi::arg ("width"), gsi::arg ("height"), + gsi::method ("save_image", static_cast (&lay::LayoutView::save_image), gsi::arg ("filename"), gsi::arg ("width"), gsi::arg ("height"), "@brief Saves the layout as an image to the given file\n" "\n" "@param filename The file to which to write the screenshot to.\n" @@ -1291,13 +1291,13 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "If the file name ends with a suffix \".gz\" or \".gzip\", the file is compressed with the zlib " "algorithm.\n" ) + - gsi::method ("set_layer_properties", (void (lay::LayoutView::*) (const lay::LayerPropertiesConstIterator &, const lay::LayerProperties &)) &lay::LayoutView::set_properties, gsi::arg ("iter"), gsi::arg ("props"), + gsi::method ("set_layer_properties", static_cast (&lay::LayoutView::set_properties), gsi::arg ("iter"), gsi::arg ("props"), "@brief Sets the layer properties of the layer pointed to by the iterator\n" "\n" "This method replaces the layer properties of the element pointed to by \"iter\" by the properties " "given by \"props\". It will not change the hierarchy but just the properties of the given node." ) + - gsi::method ("set_layer_properties", (void (lay::LayoutView::*) (unsigned int index, const lay::LayerPropertiesConstIterator &, const lay::LayerProperties &)) &lay::LayoutView::set_properties, gsi::arg ("index"), gsi::arg ("iter"), gsi::arg ("props"), + gsi::method ("set_layer_properties", static_cast (&lay::LayoutView::set_properties), gsi::arg ("index"), gsi::arg ("iter"), gsi::arg ("props"), "@brief Sets the layer properties of the layer pointed to by the iterator\n" "\n" "This method replaces the layer properties of the element pointed to by \"iter\" by the properties " @@ -1467,19 +1467,19 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "the new list.\n" "This method has been introduced in version 0.21.\n" ) + - gsi::method ("num_layer_lists", &lay::LayoutView::layer_lists, + gsi::method ("num_layer_lists", static_cast (&lay::LayoutView::layer_lists), "@brief Gets the number of layer properties tabs present\n" "This method has been introduced in version 0.23.\n" ) + - gsi::method ("current_layer_list", &lay::LayoutView::current_layer_list, + gsi::method ("current_layer_list", static_cast (&lay::LayoutView::current_layer_list), "@brief Gets the index of the currently selected layer properties tab\n" "This method has been introduced in version 0.21.\n" ) + - gsi::method ("current_layer_list=|#set_current_layer_list", &lay::LayoutView::set_current_layer_list, gsi::arg ("index"), + gsi::method ("current_layer_list=|#set_current_layer_list", static_cast (&lay::LayoutView::set_current_layer_list), gsi::arg ("index"), "@brief Sets the index of the currently selected layer properties tab\n" "This method has been introduced in version 0.21.\n" ) + - gsi::method ("rename_layer_list", &lay::LayoutView::rename_properties, gsi::arg ("index"), gsi::arg ("name"), + gsi::method ("rename_layer_list", static_cast (&lay::LayoutView::rename_properties), gsi::arg ("index"), gsi::arg ("name"), "@brief Sets the title of the given layer properties tab\n" "This method has been introduced in version 0.21.\n" ) + @@ -1569,26 +1569,26 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This method has been introduced in version 0.25." ) + - gsi::method ("current_layer", &lay::LayoutView::current_layer, + gsi::method ("current_layer", static_cast (&lay::LayoutView::current_layer), "@brief Gets the current layer view\n" "\n" "Returns the \\LayerPropertiesIterator pointing to the current layer view (the one that has the focus). " "If no layer view is active currently, a null iterator is returned.\n" ) + - gsi::method ("current_layer=", (void (lay::LayoutView::*) (const lay::LayerPropertiesConstIterator &l)) &lay::LayoutView::set_current_layer, gsi::arg ("iter"), + gsi::method ("current_layer=", static_cast (&lay::LayoutView::set_current_layer), gsi::arg ("iter"), "@brief Sets the current layer view\n" "\n" "Specifies an \\LayerPropertiesIterator pointing to the new current layer view.\n" "\n" "This method has been introduced in version 0.23.\n" ) + - gsi::method ("selected_layers", &lay::LayoutView::selected_layers, + gsi::method ("selected_layers", static_cast (lay::LayoutView::*) () const> (&lay::LayoutView::selected_layers), "@brief Gets the selected layers\n" "\n" "Returns an array of \\LayerPropertiesIterator objects pointing to the currently selected layers. " "If no layer view is selected currently, an empty array is returned.\n" ) + - gsi::event ("on_active_cellview_changed", &lay::LayoutView::active_cellview_changed_event, + gsi::event ("on_active_cellview_changed", static_cast (&lay::LayoutView::active_cellview_changed_event), "@brief An event indicating that the active cellview has changed\n" "\n" "If the active cellview is changed by selecting a new one from the drop-down list, this event is triggered.\n" @@ -1597,7 +1597,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "Before version 0.25 this event was based on the observer pattern obsolete now. The corresponding methods " "(add_active_cellview_changed/remove_active_cellview_changed) have been removed in 0.25.\n" ) + - gsi::event ("on_cellviews_changed", &lay::LayoutView::cellviews_changed_event, + gsi::event ("on_cellviews_changed", static_cast (&lay::LayoutView::cellviews_changed_event), "@brief An event indicating that the cellview collection has changed\n" "\n" "If new cellviews are added or cellviews are removed, this event is triggered.\n" @@ -1606,7 +1606,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "Before version 0.25 this event was based on the observer pattern obsolete now. The corresponding methods " "(add_cellview_list_observer/remove_cellview_list_observer) have been removed in 0.25.\n" ) + - gsi::event ("on_cellview_changed", &lay::LayoutView::cellview_changed_event, gsi::arg ("cellview_index"), + gsi::event ("on_cellview_changed", static_cast (lay::LayoutView::*)> (&lay::LayoutView::cellview_changed_event), gsi::arg ("cellview_index"), "@brief An event indicating that a cellview has changed\n" "\n" "If a cellview is modified, this event is triggered.\n" @@ -1616,7 +1616,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "Before version 0.25 this event was based on the observer pattern obsolete now. The corresponding methods " "(add_cellview_observer/remove_cellview_observer) have been removed in 0.25.\n" ) + - gsi::event ("on_file_open", &lay::LayoutView::file_open_event, + gsi::event ("on_file_open", static_cast (&lay::LayoutView::file_open_event), "@brief An event indicating that a file was opened\n" "\n" "If a file is loaded, this event is triggered.\n" @@ -1627,25 +1627,25 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "(add_file_open_observer/remove_file_open_observer) have been removed in 0.25.\n" ) + #if defined(HAVE_QT) - gsi::event ("on_close", &lay::LayoutView::close_event, + gsi::event ("on_close", static_cast (&lay::LayoutView::close_event), "@brief A event indicating that the view is about to close\n" "\n" "This event is triggered when the view is going to be closed entirely.\n" "\n" "It has been added in version 0.25." ) + - gsi::event ("on_show", &lay::LayoutView::show_event, + gsi::event ("on_show", static_cast (&lay::LayoutView::show_event), "@brief A event indicating that the view is going to become visible\n" "\n" "It has been added in version 0.25." ) + - gsi::event ("on_hide", &lay::LayoutView::hide_event, + gsi::event ("on_hide", static_cast (&lay::LayoutView::hide_event), "@brief A event indicating that the view is going to become invisible\n" "\n" "It has been added in version 0.25." ) + #endif - gsi::event ("on_viewport_changed", &lay::LayoutView::viewport_changed_event, + gsi::event ("on_viewport_changed", static_cast (&lay::LayoutView::viewport_changed_event), "@brief An event indicating that the viewport (the visible rectangle) has changed\n" "\n" "This event is triggered after a new display rectangle was chosen - for example, because the user " @@ -1654,7 +1654,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "Before version 0.25 this event was based on the observer pattern obsolete now. The corresponding methods " "(add_viewport_changed_observer/remove_viewport_changed_observer) have been removed in 0.25.\n" ) + - gsi::event ("on_layer_list_changed", &lay::LayoutView::layer_list_changed_event, gsi::arg ("flags"), + gsi::event ("on_layer_list_changed", static_cast (lay::LayoutView::*)> (&lay::LayoutView::layer_list_changed_event), gsi::arg ("flags"), "@brief An event indicating that the layer list has changed\n" "\n" "This event is triggered after the layer list has changed it's configuration.\n" @@ -1665,7 +1665,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "Before version 0.25 this event was based on the observer pattern obsolete now. The corresponding methods " "(add_layer_list_observer/remove_layer_list_observer) have been removed in 0.25.\n" ) + - gsi::event ("on_layer_list_inserted", &lay::LayoutView::layer_list_inserted_event, gsi::arg ("index"), + gsi::event ("on_layer_list_inserted", static_cast (lay::LayoutView::*)> (&lay::LayoutView::layer_list_inserted_event), gsi::arg ("index"), "@brief An event indicating that a layer list (a tab) has been inserted\n" "@param index The index of the layer list that was inserted\n" "\n" @@ -1673,7 +1673,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This event was introduced in version 0.25.\n" ) + - gsi::event ("on_layer_list_deleted", &lay::LayoutView::layer_list_deleted_event, gsi::arg ("index"), + gsi::event ("on_layer_list_deleted", static_cast (lay::LayoutView::*)> (&lay::LayoutView::layer_list_deleted_event), gsi::arg ("index"), "@brief An event indicating that a layer list (a tab) has been removed\n" "@param index The index of the layer list that was removed\n" "\n" @@ -1681,7 +1681,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This event was introduced in version 0.25.\n" ) + - gsi::event ("on_current_layer_list_changed", &lay::LayoutView::current_layer_list_changed_event, gsi::arg ("index"), + gsi::event ("on_current_layer_list_changed", static_cast (lay::LayoutView::*)> (&lay::LayoutView::current_layer_list_changed_event), gsi::arg ("index"), "@brief An event indicating the current layer list (the selected tab) has changed\n" "@param index The index of the new current layer list\n" "\n" @@ -1689,7 +1689,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This event was introduced in version 0.25.\n" ) + - gsi::event ("on_cell_visibility_changed", &lay::LayoutView::cell_visibility_changed_event, + gsi::event ("on_cell_visibility_changed", static_cast (&lay::LayoutView::cell_visibility_changed_event), "@brief An event indicating that the visibility of one or more cells has changed\n" "\n" "This event is triggered after the visibility of one or more cells has changed.\n" @@ -1716,26 +1716,26 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This event was translated from the Observer pattern to an event in version 0.25." ) + - gsi::event ("on_rdb_list_changed", &lay::LayoutView::rdb_list_changed_event, + gsi::event ("on_rdb_list_changed", static_cast (&lay::LayoutView::rdb_list_changed_event), "@brief An event that is triggered the list of report databases is changed\n" "\n" "If a report database is added or removed, this event is triggered.\n" "\n" "This event was translated from the Observer pattern to an event in version 0.25." ) + - gsi::method ("num_rdbs", &lay::LayoutView::num_rdbs, + gsi::method ("num_rdbs", static_cast (&lay::LayoutView::num_rdbs), "@brief Gets the number of report databases loaded into this view\n" "@return The number of \\ReportDatabase objects present in this view\n" ) + - gsi::method ("remove_rdb", &lay::LayoutView::remove_rdb, gsi::arg ("index"), + gsi::method ("remove_rdb", static_cast (&lay::LayoutView::remove_rdb), gsi::arg ("index"), "@brief Removes a report database with the given index\n" "@param The index of the report database to remove from this view" ) + - gsi::method ("rdb", (rdb::Database *(lay::LayoutView::*) (int index)) &lay::LayoutView::get_rdb, gsi::arg ("index"), + gsi::method ("rdb", static_cast (&lay::LayoutView::get_rdb), gsi::arg ("index"), "@brief Gets the report database with the given index\n" "@return The \\ReportDatabase object or nil if the index is not valid" ) + - gsi::method ("add_rdb", &lay::LayoutView::add_rdb, gsi::arg ("db"), + gsi::method ("add_rdb", static_cast (&lay::LayoutView::add_rdb), gsi::arg ("db"), "@brief Adds the given report database to the view\n" "\n" "This method will add an existing database to the view. It will then appear in the marker database browser.\n" @@ -1745,7 +1745,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This method has been added in version 0.26." ) + - gsi::method ("replace_rdb", &lay::LayoutView::replace_rdb, gsi::arg ("db_index"), gsi::arg ("db"), + gsi::method ("replace_rdb", static_cast (&lay::LayoutView::replace_rdb), gsi::arg ("db_index"), gsi::arg ("db"), "@brief Replaces the report database with the given index\n" "\n" "If the index is not valid, the database will be added to the view (see \\add_rdb).\n" @@ -1763,38 +1763,38 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "The name will be replaced by the file name when a file is loaded into the report database.\n" ) + #if defined(HAVE_QT) - gsi::method ("show_rdb", &lay::LayoutView::open_rdb_browser, gsi::arg ("rdb_index"), gsi::arg ("cv_index"), + gsi::method ("show_rdb", static_cast (&lay::LayoutView::open_rdb_browser), gsi::arg ("rdb_index"), gsi::arg ("cv_index"), "@brief Shows a report database in the marker browser on a certain layout\n" "The marker browser is opened showing the report database with the index given by \"rdb_index\".\n" "It will be attached (i.e. navigate to) the layout with the given cellview index in \"cv_index\".\n" ) + #endif - gsi::event ("on_l2ndb_list_changed", &lay::LayoutView::l2ndb_list_changed_event, + gsi::event ("on_l2ndb_list_changed", static_cast (&lay::LayoutView::l2ndb_list_changed_event), "@brief An event that is triggered the list of netlist databases is changed\n" "\n" "If a netlist database is added or removed, this event is triggered.\n" "\n" "This method has been added in version 0.26." ) + - gsi::method ("num_l2ndbs", &lay::LayoutView::num_l2ndbs, + gsi::method ("num_l2ndbs", static_cast (&lay::LayoutView::num_l2ndbs), "@brief Gets the number of netlist databases loaded into this view\n" "@return The number of \\LayoutToNetlist objects present in this view\n" "\n" "This method has been added in version 0.26." ) + - gsi::method ("remove_l2ndb", &lay::LayoutView::remove_l2ndb, gsi::arg ("index"), + gsi::method ("remove_l2ndb", static_cast (&lay::LayoutView::remove_l2ndb), gsi::arg ("index"), "@brief Removes a netlist database with the given index\n" "@param The index of the netlist database to remove from this view" "\n" "This method has been added in version 0.26." ) + - gsi::method ("l2ndb", (db::LayoutToNetlist *(lay::LayoutView::*) (int index)) &lay::LayoutView::get_l2ndb, gsi::arg ("index"), + gsi::method ("l2ndb", static_cast (&lay::LayoutView::get_l2ndb), gsi::arg ("index"), "@brief Gets the netlist database with the given index\n" "@return The \\LayoutToNetlist object or nil if the index is not valid" "\n" "This method has been added in version 0.26." ) + - gsi::method ("add_l2ndb", &lay::LayoutView::add_l2ndb, gsi::arg ("db"), + gsi::method ("add_l2ndb", static_cast (&lay::LayoutView::add_l2ndb), gsi::arg ("db"), "@brief Adds the given netlist database to the view\n" "\n" "This method will add an existing database to the view. It will then appear in the netlist database browser.\n" @@ -1804,7 +1804,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This method has been added in version 0.26." ) + - gsi::method ("replace_l2ndb", &lay::LayoutView::replace_l2ndb, gsi::arg ("db_index"), gsi::arg ("db"), + gsi::method ("replace_l2ndb", static_cast (&lay::LayoutView::replace_l2ndb), gsi::arg ("db_index"), gsi::arg ("db"), "@brief Replaces the netlist database with the given index\n" "\n" "If the index is not valid, the database will be added to the view (see \\add_lvsdb).\n" @@ -1824,7 +1824,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "This method has been added in version 0.26." ) + #if defined(HAVE_QT) - gsi::method ("show_l2ndb", &lay::LayoutView::open_l2ndb_browser, gsi::arg ("l2ndb_index"), gsi::arg ("cv_index"), + gsi::method ("show_l2ndb", static_cast (&lay::LayoutView::open_l2ndb_browser), gsi::arg ("l2ndb_index"), gsi::arg ("cv_index"), "@brief Shows a netlist database in the marker browser on a certain layout\n" "The netlist browser is opened showing the netlist database with the index given by \"l2ndb_index\".\n" "It will be attached (i.e. navigate to) the layout with the given cellview index in \"cv_index\".\n" @@ -1868,7 +1868,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "This method has been added in version 0.26." ) + #if defined(HAVE_QT) - gsi::method ("show_lvsdb", &lay::LayoutView::open_l2ndb_browser, gsi::arg ("lvsdb_index"), gsi::arg ("cv_index"), + gsi::method ("show_lvsdb", static_cast (&lay::LayoutView::open_l2ndb_browser), gsi::arg ("lvsdb_index"), gsi::arg ("cv_index"), "@brief Shows a netlist database in the marker browser on a certain layout\n" "The netlist browser is opened showing the netlist database with the index given by \"lvsdb_index\".\n" "It will be attached (i.e. navigate to) the layout with the given cellview index in \"cv_index\".\n" From 101544ab78d37b4290dc3cd2479e134081d4fdd8 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 7 May 2022 18:48:45 +0200 Subject: [PATCH 36/88] Equality operator in PixelBuffer --- .../laybasic/gsiDeclLayPixelBuffer.cc | 20 ++++++- src/laybasic/laybasic/layPixelBuffer.cc | 53 +++++++++++++++++++ src/laybasic/laybasic/layPixelBuffer.h | 26 +++++++++ .../unit_tests/layPixelBufferTests.cc | 27 +--------- testdata/ruby/layPixelBuffer.rb | 38 +++++++++++-- 5 files changed, 134 insertions(+), 30 deletions(-) diff --git a/src/laybasic/laybasic/gsiDeclLayPixelBuffer.cc b/src/laybasic/laybasic/gsiDeclLayPixelBuffer.cc index 7ee615853..7019aee2c 100644 --- a/src/laybasic/laybasic/gsiDeclLayPixelBuffer.cc +++ b/src/laybasic/laybasic/gsiDeclLayPixelBuffer.cc @@ -143,6 +143,12 @@ Class decl_PixelBuffer ("lay", "PixelBuffer", "\n" "The pixels are basically uninitialized. You will need to use \\fill to initialize them to a certain value." ) + + gsi::method ("==", &lay::PixelBuffer::operator==, gsi::arg ("other"), + "@brief Returns a value indicating whether self is identical to the other image\n" + ) + + gsi::method ("!=", &lay::PixelBuffer::operator!=, gsi::arg ("other"), + "@brief Returns a value indicating whether self is not identical to the other image\n" + ) + gsi::method ("transparent=", &lay::PixelBuffer::set_transparent, gsi::arg ("t"), "@brief Sets a flag indicating whether the pixel buffer supports an alpha channel\n" "\n" @@ -224,7 +230,9 @@ Class decl_PixelBuffer ("lay", "PixelBuffer", "transparency through an optional alpha channel. The color format for a pixel is " "\"0xAARRGGBB\" where 'AA' is the alpha value which is ignored in non-transparent mode.\n" "\n" - "This class supports basic operations such as initialization, single-pixel access and I/O to PNG." + "This class supports basic operations such as initialization, single-pixel access and I/O to PNG.\n" + "\n" + "This class has been introduced in version 0.28." ); @@ -335,6 +343,12 @@ Class decl_BitmapBuffer ("lay", "BitmapBuffer", "\n" "The pixels are basically uninitialized. You will need to use \\fill to initialize them to a certain value." ) + + gsi::method ("==", &lay::BitmapBuffer::operator==, gsi::arg ("other"), + "@brief Returns a value indicating whether self is identical to the other image\n" + ) + + gsi::method ("!=", &lay::BitmapBuffer::operator!=, gsi::arg ("other"), + "@brief Returns a value indicating whether self is not identical to the other image\n" + ) + gsi::method ("fill", &lay::BitmapBuffer::fill, gsi::arg ("color"), "@brief Fills the pixel buffer with the given pixel value\n" ) + @@ -391,7 +405,9 @@ Class decl_BitmapBuffer ("lay", "BitmapBuffer", "This object is mainly provided for offline rendering of layouts in Qt-less environments.\n" "It supports a rectangular pixel space with color values encoded in single bits.\n" "\n" - "This class supports basic operations such as initialization, single-pixel access and I/O to PNG." + "This class supports basic operations such as initialization, single-pixel access and I/O to PNG.\n" + "\n" + "This class has been introduced in version 0.28." ); } diff --git a/src/laybasic/laybasic/layPixelBuffer.cc b/src/laybasic/laybasic/layPixelBuffer.cc index d0e0f0d34..05aa56111 100644 --- a/src/laybasic/laybasic/layPixelBuffer.cc +++ b/src/laybasic/laybasic/layPixelBuffer.cc @@ -169,6 +169,31 @@ PixelBuffer::~PixelBuffer () // .. nothing yet .. } +bool +PixelBuffer::operator== (const PixelBuffer &other) const +{ + if (width () != other.width () || height () != other.height ()) { + return false; + } + if (transparent () != other.transparent ()) { + return false; + } + + lay::color_t m = transparent () ? 0xffffffff : 0xffffff; + for (unsigned int i = 0; i < other.height (); ++i) { + const lay::color_t *d = scan_line (i); + const lay::color_t *de = d + width (); + const lay::color_t *dd = other.scan_line (i); + while (d != de) { + if (((*d++ ^ *dd++) & m) != 0) { + return false; + } + } + } + + return true; +} + PixelBuffer & PixelBuffer::operator= (const PixelBuffer &other) { @@ -485,6 +510,34 @@ BitmapBuffer::~BitmapBuffer () // .. nothing yet .. } +bool +BitmapBuffer::operator== (const BitmapBuffer &other) const +{ + if (width () != other.width () || height () != other.height ()) { + return false; + } + + for (unsigned int i = 0; i < other.height (); ++i) { + const uint8_t *d = scan_line (i); + const uint8_t *dd = other.scan_line (i); + unsigned int bits_left = width (); + while (bits_left >= 8) { + if (*d++ != *dd++) { + return false; + } + bits_left -= 8; + } + if (bits_left > 0) { + unsigned int m = (0x01 << bits_left) - 1; + if (((*d ^ *dd) & m) != 0) { + return false; + } + } + } + + return true; +} + BitmapBuffer & BitmapBuffer::operator= (const BitmapBuffer &other) { diff --git a/src/laybasic/laybasic/layPixelBuffer.h b/src/laybasic/laybasic/layPixelBuffer.h index a5c811461..1a095f7c0 100644 --- a/src/laybasic/laybasic/layPixelBuffer.h +++ b/src/laybasic/laybasic/layPixelBuffer.h @@ -111,6 +111,19 @@ public: */ ~PixelBuffer (); + /** + * @brief Equality + */ + bool operator== (const PixelBuffer &other) const; + + /** + * @brief Inequality + */ + bool operator!= (const PixelBuffer &other) const + { + return !operator== (other); + } + /** * @brief Assignment */ @@ -334,6 +347,19 @@ public: */ BitmapBuffer (BitmapBuffer &&other); + /** + * @brief Equality + */ + bool operator== (const BitmapBuffer &other) const; + + /** + * @brief Inequality + */ + bool operator!= (const BitmapBuffer &other) const + { + return !operator== (other); + } + /** * @brief Destructor */ diff --git a/src/laybasic/unit_tests/layPixelBufferTests.cc b/src/laybasic/unit_tests/layPixelBufferTests.cc index f2a294288..b02ecc53d 100644 --- a/src/laybasic/unit_tests/layPixelBufferTests.cc +++ b/src/laybasic/unit_tests/layPixelBufferTests.cc @@ -74,35 +74,12 @@ static bool compare_images_mono (const QImage &qimg, const std::string &au) static bool compare_images (const lay::PixelBuffer &img, const lay::PixelBuffer &img2) { - if (img2.width () == img.width () && img2.height () == img.height ()) { - for (unsigned int j = 0; j < img.height (); ++j) { - for (unsigned int i = 0; i < img.width (); ++i) { - if (((const lay::color_t *) img.scan_line (j))[i] != ((const lay::color_t *) img2.scan_line (j))[i]) { - return false; - } - } - } - return true; - } else { - return false; - } + return img == img2; } static bool compare_images (const lay::BitmapBuffer &img, const lay::BitmapBuffer &img2) { - if (img2.width () == img.width () && img2.height () == img.height ()) { - // NOTE: slooooow ... - for (unsigned int j = 0; j < img.height (); ++j) { - for (unsigned int i = 0; i < img.width (); ++i) { - if ((img.scan_line (j)[i / 8] & (0x01 << (i % 8))) != (img2.scan_line (j)[i / 8] & (0x01 << (i % 8)))) { - return false; - } - } - } - return true; - } else { - return false; - } + return img == img2; } TEST(1) diff --git a/testdata/ruby/layPixelBuffer.rb b/testdata/ruby/layPixelBuffer.rb index eccaab81e..400df1338 100644 --- a/testdata/ruby/layPixelBuffer.rb +++ b/testdata/ruby/layPixelBuffer.rb @@ -41,17 +41,21 @@ class LAYPixelBuffer_TestClass < TestBase def test_1 - pb = RBA::PixelBuffer::new - assert_equal(pb.width, 0) - assert_equal(pb.height, 0) + pb_null = RBA::PixelBuffer::new + assert_equal(pb_null.width, 0) + assert_equal(pb_null.height, 0) pb = RBA::PixelBuffer::new(10, 20) + assert_equal(compare(pb_null, pb), false) + assert_equal(pb_null == pb, false) assert_equal(pb.width, 10) assert_equal(pb.height, 20) assert_equal(pb.transparent, false) + pb_copy = pb.dup pb.transparent = true assert_equal(pb.transparent, true) + assert_equal(pb_copy == pb, false) pb.fill(0xf0010203) assert_equal(pb.pixel(0, 0), 0xf0010203) @@ -66,12 +70,14 @@ class LAYPixelBuffer_TestClass < TestBase pb_copy = pb.dup assert_equal(compare(pb_copy, pb), true) + assert_equal(pb_copy == pb, true) pb.set_pixel(1, 2, 0x112233) assert_equal(pb.pixel(0, 0), 0xf0010203) assert_equal(pb.pixel(1, 2), 0xff112233) assert_equal(pb_copy.pixel(1, 2), 0xff102030) assert_equal(compare(pb_copy, pb), false) + assert_equal(pb_copy == pb, false) pb_copy.swap(pb) assert_equal(pb_copy.pixel(1, 2), 0xff112233) @@ -88,14 +94,40 @@ class LAYPixelBuffer_TestClass < TestBase pb.set_pixel(1, 2, 0x112233) assert_equal(compare(pb1, pb), false) + assert_equal(pb1 == pb, false) diff = pb1.diff(pb) pb1.patch(diff) assert_equal(compare(pb1, pb), true) + assert_equal(pb1 == pb, true) end def test_3 + + pb = RBA::PixelBuffer::new(10, 20) + pb.fill(0xf0010203) + + pb1 = pb.dup + pb.set_pixel(1, 2, 0x112233) + + pb1 = pb.dup + pb.set_pixel(1, 2, 0xf0112233) + assert_equal(compare(pb1, pb), true) + assert_equal(pb1 == pb, true) # not transparent -> alpha is ignored + + pb1.transparent = true + pb.transparent = true + assert_equal(compare(pb1, pb), true) + assert_equal(pb1 == pb, true) + + pb.set_pixel(1, 2, 0xf0112233) + assert_equal(compare(pb1, pb), false) + assert_equal(pb1 == pb, false) # now, alpha matters + + end + + def test_4 pb = RBA::PixelBuffer::new(10, 20) pb.transparent = true From 585ab0f3102a6f6e90fe08b131aeb79f5801a664 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 7 May 2022 18:57:33 +0200 Subject: [PATCH 37/88] Fixed tests --- src/laybasic/unit_tests/layLayoutViewTests.cc | 115 ++++++++++++++---- testdata/ruby/layLayoutView.rb | 7 ++ 2 files changed, 97 insertions(+), 25 deletions(-) diff --git a/src/laybasic/unit_tests/layLayoutViewTests.cc b/src/laybasic/unit_tests/layLayoutViewTests.cc index d4ec584e2..464954af7 100644 --- a/src/laybasic/unit_tests/layLayoutViewTests.cc +++ b/src/laybasic/unit_tests/layLayoutViewTests.cc @@ -71,39 +71,17 @@ static bool compare_images_mono (const QImage &qimg, const std::string &au) static bool compare_images (const lay::PixelBuffer &img, const lay::PixelBuffer &img2) { - if (img2.width () == img.width () && img2.height () == img.height ()) { - for (unsigned int j = 0; j < img.height (); ++j) { - for (unsigned int i = 0; i < img.width (); ++i) { - if (((const lay::color_t *) img.scan_line (j))[i] != ((const lay::color_t *) img2.scan_line (j))[i]) { - return false; - } - } - } - return true; - } else { - return false; - } + return img == img2; } static bool compare_images (const lay::BitmapBuffer &img, const lay::BitmapBuffer &img2) { - if (img2.width () == img.width () && img2.height () == img.height ()) { - for (unsigned int j = 0; j < img.height (); ++j) { - for (unsigned int i = 0; i < img.stride (); ++i) { - if (((const uint8_t *) img.scan_line (j))[i] != ((const uint8_t *) img2.scan_line (j))[i]) { - return false; - } - } - } - return true; - } else { - return false; - } + return img == img2; } #endif -#if defined(HAVE_QT) // @@@ +#if defined(HAVE_QT) TEST(1) { lay::LayoutView lv (0, false, 0); @@ -171,3 +149,90 @@ TEST(3) EXPECT_EQ (compare_images_mono (qimg.convertToFormat (QImage::Format_Mono), au), true); } #endif + +#if defined(HAVE_PNG) +TEST(11) +{ + lay::LayoutView lv (0, false, 0); + lv.cell_box_color (lay::Color (0, 0, 0)); + + lv.load_layout (tl::testsrc () + "/testdata/gds/t10.gds", true); + + lay::PixelBuffer img; + img = lv.get_pixels_with_options (500, 500, 1, 1, 1.0, lay::Color (255, 255, 255), lay::Color (0, 0, 0), lay::Color (128, 128, 128), db::DBox ()); + + std::string tmp = tmp_file ("test.png"); + { + tl::OutputStream stream (tmp); + img.write_png (stream); + } + tl::info << "PNG file written to " << tmp; + + std::string au = tl::testsrc () + "/testdata/lay/au_lv1.png"; + lay::PixelBuffer au_img; + { + tl::InputStream stream (au); + au_img = lay::PixelBuffer::read_png (stream); + } + tl::info << "PNG file read from " << au; + + EXPECT_EQ (compare_images (img, au_img), true); +} + +TEST(12) +{ + lay::LayoutView lv (0, false, 0); + lv.full_hier_new_cell (true); + + lv.load_layout (tl::testsrc () + "/testdata/gds/t10.gds", true); + + lay::PixelBuffer img; + img = lv.get_pixels_with_options (500, 500, 1, 1, 1.0, lay::Color (255, 255, 255), lay::Color (0, 0, 0), lay::Color (128, 128, 128), db::DBox ()); + + std::string tmp = tmp_file ("test.png"); + { + tl::OutputStream stream (tmp); + img.write_png (stream); + } + tl::info << "PNG file written to " << tmp; + + std::string au = tl::testsrc () + "/testdata/lay/au_lv2.png"; + lay::PixelBuffer au_img; + { + tl::InputStream stream (au); + au_img = lay::PixelBuffer::read_png (stream); + } + tl::info << "PNG file read from " << au; + + EXPECT_EQ (compare_images (img, au_img), true); +} + +// monochrome +TEST(13) +{ + lay::LayoutView lv (0, false, 0); + lv.full_hier_new_cell (true); + + lv.load_layout (tl::testsrc () + "/testdata/gds/t10.gds", true); + + lay::BitmapBuffer img; + img = lv.get_pixels_with_options_mono (500, 500, 1, lay::Color (255, 255, 255), lay::Color (0, 0, 0), lay::Color (128, 128, 128), db::DBox ()); + + std::string tmp = tmp_file ("test.png"); + { + tl::OutputStream stream (tmp); + img.write_png (stream); + } + tl::info << "PNG file written to " << tmp; + + std::string au = tl::testsrc () + "/testdata/lay/au_lv3.png"; + lay::BitmapBuffer au_img; + { + tl::InputStream stream (au); + au_img = lay::BitmapBuffer::read_png (stream); + } + tl::info << "PNG file read from " << au; + + EXPECT_EQ (compare_images (img, au_img), true); +} +#endif diff --git a/testdata/ruby/layLayoutView.rb b/testdata/ruby/layLayoutView.rb index 0a2a69d21..1193688cc 100644 --- a/testdata/ruby/layLayoutView.rb +++ b/testdata/ruby/layLayoutView.rb @@ -423,6 +423,13 @@ class LAYLayoutView_TestClass < TestBase end + def test_4 + + # standalone view image generation + lv = RBA::LayoutView::new + + end + end load("test_epilogue.rb") From 41cbef1e5ad5256ad946f144d16bc88cdb4b0973 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 7 May 2022 19:13:01 +0200 Subject: [PATCH 38/88] Tests for new LayoutView features --- src/laybasic/laybasic/gsiDeclLayLayoutView.cc | 8 +++--- testdata/ruby/layLayoutView.rb | 26 ++++++++++++++++++- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/laybasic/laybasic/gsiDeclLayLayoutView.cc b/src/laybasic/laybasic/gsiDeclLayLayoutView.cc index 07ecd89a2..862744309 100644 --- a/src/laybasic/laybasic/gsiDeclLayLayoutView.cc +++ b/src/laybasic/laybasic/gsiDeclLayLayoutView.cc @@ -1153,7 +1153,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "The image contains the current scene (layout, annotations etc.).\n" "The image is drawn synchronously with the given width and height. Drawing may take some time. " ) + - gsi::method_ext ("get_image_with_options", &get_image_with_options, gsi::arg ("width"), gsi::arg ("height"), gsi::arg ("linewidth"), gsi::arg ("oversampling"), gsi::arg ("resolution"), gsi::arg ("target"), gsi::arg ("monochrome"), + gsi::method_ext ("get_image_with_options", &get_image_with_options, gsi::arg ("width"), gsi::arg ("height"), gsi::arg ("linewidth", 0), gsi::arg ("oversampling", 0), gsi::arg ("resolution", 0.0), gsi::arg ("target", db::DBox (), "current"), gsi::arg ("monochrome", false), "@brief Gets the layout image as a \\QImage (with options)\n" "\n" "@param width The width of the image to render in pixel.\n" @@ -1191,7 +1191,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This method has been introduced in 0.28.\n" ) + - gsi::method_ext ("get_pixels_with_options", &get_pixels_with_options, gsi::arg ("width"), gsi::arg ("height"), gsi::arg ("linewidth"), gsi::arg ("oversampling"), gsi::arg ("resolution"), gsi::arg ("target"), + gsi::method_ext ("get_pixels_with_options", &get_pixels_with_options, gsi::arg ("width"), gsi::arg ("height"), gsi::arg ("linewidth", 0), gsi::arg ("oversampling", 0), gsi::arg ("resolution", 0.0), gsi::arg ("target", db::DBox (), "current"), "@brief Gets the layout image as a \\PixelBuffer (with options)\n" "\n" "@param width The width of the image to render in pixel.\n" @@ -1206,7 +1206,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This method has been introduced in 0.28.\n" ) + - gsi::method_ext ("get_pixels_with_options_mono", &get_pixels_with_options_mono, gsi::arg ("width"), gsi::arg ("height"), gsi::arg ("linewidth"), gsi::arg ("target"), + gsi::method_ext ("get_pixels_with_options_mono", &get_pixels_with_options_mono, gsi::arg ("width"), gsi::arg ("height"), gsi::arg ("linewidth", 0), gsi::arg ("target", db::DBox (), "current"), "@brief Gets the layout image as a \\PixelBuffer (with options)\n" "\n" "@param width The width of the image to render in pixel.\n" @@ -1241,7 +1241,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "The image is written as a PNG file to the given file. " "The image is drawn synchronously with the given width and height. Drawing may take some time. " ) + - gsi::method_ext ("save_image_with_options", &save_image_with_options, gsi::arg ("filename"), gsi::arg ("width"), gsi::arg ("height"), gsi::arg ("linewidth"), gsi::arg ("oversampling"), gsi::arg ("resolution"), gsi::arg ("target"), gsi::arg ("monochrome"), + gsi::method_ext ("save_image_with_options", &save_image_with_options, gsi::arg ("filename"), gsi::arg ("width"), gsi::arg ("height"), gsi::arg ("linewidth", 0), gsi::arg ("oversampling", 0), gsi::arg ("resolution", 0.0), gsi::arg ("target", db::DBox (), "current"), gsi::arg ("monochrome", false), "@brief Saves the layout as an image to the given file (with options)\n" "\n" "@param filename The file to which to write the screenshot to.\n" diff --git a/testdata/ruby/layLayoutView.rb b/testdata/ruby/layLayoutView.rb index 1193688cc..e3d44b36f 100644 --- a/testdata/ruby/layLayoutView.rb +++ b/testdata/ruby/layLayoutView.rb @@ -425,8 +425,32 @@ class LAYLayoutView_TestClass < TestBase def test_4 - # standalone view image generation + # standalone image generation (see C++ tests) lv = RBA::LayoutView::new + lv.set_config("inst-color", "#000000") + lv.set_config("background-color", "#ffffff") + lv.load_layout(File.join($ut_testsrc, "testdata/gds/t10.gds"), true) + + img = lv.get_pixels_with_options(500, 500, 1, 1, 1.0, RBA::DBox::new) + au = RBA::PixelBuffer.read_png(File.join($ut_testsrc, "testdata/lay/au_lv1.png")) + if au + assert_equal(au == img, true) + end + + lv.set_config("full-hierarchy-new-cell", "true") + lv.load_layout(File.join($ut_testsrc, "testdata/gds/t10.gds"), false) + + img = lv.get_pixels_with_options(500, 500, 1, 1, 1.0, RBA::DBox::new) + au = RBA::PixelBuffer.read_png(File.join($ut_testsrc, "testdata/lay/au_lv2.png")) + if au + assert_equal(au == img, true) + end + + img = lv.get_pixels_with_options_mono(500, 500, 1, RBA::DBox::new) + au = RBA::BitmapBuffer.read_png(File.join($ut_testsrc, "testdata/lay/au_lv3.png")) + if au + assert_equal(au == img, true) + end end From 0198c7cd692a08bc0b5ba4f37e2c0763c87f1eb8 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 7 May 2022 19:57:34 +0200 Subject: [PATCH 39/88] WIP --- src/laybasic/laybasic/layLayoutCanvas.cc | 8 +- src/laybasic/laybasic/layLayoutViewBase.cc | 39 ++++++--- src/laybasic/laybasic/layPixelBuffer.cc | 22 +++++ src/laybasic/laybasic/layPixelBuffer.h | 42 +++++++++ src/laybasic/unit_tests/layLayoutViewTests.cc | 87 +++++++++++++++++++ 5 files changed, 181 insertions(+), 17 deletions(-) diff --git a/src/laybasic/laybasic/layLayoutCanvas.cc b/src/laybasic/laybasic/layLayoutCanvas.cc index 49ec4eb0d..ea9eb5e1c 100644 --- a/src/laybasic/laybasic/layLayoutCanvas.cc +++ b/src/laybasic/laybasic/layLayoutCanvas.cc @@ -566,7 +566,7 @@ LayoutCanvas::update_image () void LayoutCanvas::free_resources () { -#if defined(HAVE_QT) // @@@ +#if defined(HAVE_QT) if (mp_pixmap) { delete mp_pixmap; mp_pixmap = 0; @@ -574,7 +574,7 @@ LayoutCanvas::free_resources () #endif } -#if defined(HAVE_QT) // @@@ +#if defined(HAVE_QT) void LayoutCanvas::paintEvent (QPaintEvent *) { @@ -1006,7 +1006,7 @@ LayoutCanvas::screenshot () return img; } -#if defined(HAVE_QT) +#if defined(HAVE_QT) // @@@ void LayoutCanvas::resizeEvent (QResizeEvent *) { @@ -1090,7 +1090,7 @@ LayoutCanvas::do_update_image () update_image (); } -#if defined(HAVE_QT) // @@@ +#if defined(HAVE_QT) bool LayoutCanvas::event (QEvent *e) { diff --git a/src/laybasic/laybasic/layLayoutViewBase.cc b/src/laybasic/laybasic/layLayoutViewBase.cc index a8d8eed03..e427b4ef7 100644 --- a/src/laybasic/laybasic/layLayoutViewBase.cc +++ b/src/laybasic/laybasic/layLayoutViewBase.cc @@ -64,6 +64,9 @@ # include #endif +// Enable this if you have both Qt and libpng and want to use libpng for saving images: +// #define PREFER_LIBPNG_FOR_SAVE 1 + #include namespace lay @@ -2512,7 +2515,7 @@ png_texts (const lay::LayoutViewBase *view, const db::DBox &box) return texts; } -#if defined(HAVE_QT) +#if defined(HAVE_QT) && !defined(PREFER_LIBPNG_FOR_SAVE) void LayoutViewBase::save_screenshot (const std::string &fn) { @@ -2544,9 +2547,9 @@ LayoutViewBase::save_screenshot (const std::string &fn) tl::DeferredMethodScheduler::execute (); tl::OutputStream stream (fn); - // @@@ TODO: add texts - // @@@ mp_canvas->screenshot ().write_png (stream, png_texts (this, box ())); - mp_canvas->screenshot ().write_png (stream); + lay::PixelBuffer img = mp_canvas->screenshot (); + img.set_texts (png_texts (this, box ())); + img.write_png (stream); tl::log << "Saved screen shot to " << fn; } @@ -2596,7 +2599,7 @@ LayoutViewBase::get_image_with_options (unsigned int width, unsigned int height, lay::PixelBuffer LayoutViewBase::get_pixels_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, - lay::Color background, lay::Color foreground, lay::Color active, const db::DBox &target_box) + lay::Color background, lay::Color foreground, lay::Color active, const db::DBox &target_box) { tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Get image"))); @@ -2608,7 +2611,7 @@ LayoutViewBase::get_pixels_with_options (unsigned int width, unsigned int height lay::BitmapBuffer LayoutViewBase::get_pixels_with_options_mono (unsigned int width, unsigned int height, int linewidth, - lay::Color background, lay::Color foreground, lay::Color active, const db::DBox &target_box) + lay::Color background, lay::Color foreground, lay::Color active, const db::DBox &target_box) { tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Get image"))); @@ -2618,7 +2621,7 @@ LayoutViewBase::get_pixels_with_options_mono (unsigned int width, unsigned int h return mp_canvas->image_with_options_mono (width, height, linewidth, background, foreground, active, target_box); } -#if defined(HAVE_QT) +#if defined(HAVE_QT) && !defined(PREFER_LIBPNG_FOR_SAVE) void LayoutViewBase::save_image (const std::string &fn, unsigned int width, unsigned int height) { @@ -2648,19 +2651,21 @@ LayoutViewBase::save_image (const std::string &fn, unsigned int width, unsigned tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Save image"))); lay::Viewport vp (width, height, mp_canvas->viewport ().target_box ()); - std::vector > texts = png_texts (this, vp.box ()); // Execute all deferred methods - ensure there are no pending tasks tl::DeferredMethodScheduler::execute (); tl::OutputStream stream (fn); - mp_canvas->image (width, height).write_png (stream); + lay::PixelBuffer img = mp_canvas->image (width, height); + std::vector > texts = png_texts (this, vp.box ()); + img.set_texts (texts); + img.write_png (stream); tl::log << "Saved image to " << fn; } #endif -#if defined(HAVE_QT) +#if defined(HAVE_QT) && !defined(PREFER_LIBPNG_FOR_SAVE) void LayoutViewBase::save_image_with_options (const std::string &fn, unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, @@ -2680,7 +2685,7 @@ LayoutViewBase::save_image_with_options (const std::string &fn, tl::DeferredMethodScheduler::execute (); if (monochrome) { - if (! writer.write (mp_canvas->image_with_options_mono (width, height, linewidth, background.to_mono (), foreground.to_mono (), active.to_mono (), target_box).to_image ())) { + if (! writer.write (mp_canvas->image_with_options_mono (width, height, linewidth, background, foreground, active, target_box).to_image ())) { throw tl::Exception (tl::to_string (QObject::tr ("Unable to write screenshot to file: %s (%s)")), fn, tl::to_string (writer.errorString ())); } } else { @@ -2707,9 +2712,17 @@ LayoutViewBase::save_image_with_options (const std::string &fn, tl::OutputStream stream (fn); if (monochrome) { - mp_canvas->image_with_options_mono (width, height, linewidth, background.to_mono (), foreground.to_mono (), active.to_mono (), target_box).write_png (stream); + + lay::BitmapBuffer img = mp_canvas->image_with_options_mono (width, height, linewidth, background, foreground, active, target_box); + img.set_texts (texts); + img.write_png (stream); + } else { - mp_canvas->image_with_options (width, height, linewidth, oversampling, resolution, background, foreground, active, target_box).write_png (stream); + + lay::PixelBuffer img = mp_canvas->image_with_options (width, height, linewidth, oversampling, resolution, background, foreground, active, target_box); + img.set_texts (texts); + img.write_png (stream); + } tl::log << "Saved image to " << fn; diff --git a/src/laybasic/laybasic/layPixelBuffer.cc b/src/laybasic/laybasic/layPixelBuffer.cc index 05aa56111..9a1320353 100644 --- a/src/laybasic/laybasic/layPixelBuffer.cc +++ b/src/laybasic/laybasic/layPixelBuffer.cc @@ -202,6 +202,7 @@ PixelBuffer::operator= (const PixelBuffer &other) m_height = other.m_height; m_data = other.m_data; m_transparent = other.m_transparent; + m_texts = other.m_texts; } return *this; } @@ -232,6 +233,7 @@ PixelBuffer::swap (PixelBuffer &other) std::swap (m_height, other.m_height); std::swap (m_transparent, other.m_transparent); m_data.swap (other.m_data); + m_texts.swap (other.m_texts); } void @@ -435,6 +437,15 @@ PixelBuffer::write_png (tl::OutputStream &output) const png_set_IHDR (png_ptr, info_ptr, width (), height (), bd, fmt, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); + std::vector tptrs; + for (auto i = m_texts.begin (); i != m_texts.end (); ++i) { + tptrs.push_back (png_text ()); + tptrs.back ().compression = PNG_TEXT_COMPRESSION_NONE; + tptrs.back ().key = const_cast (i->first.c_str ()); + tptrs.back ().text = const_cast (i->second.c_str ()); + } + png_set_text (png_ptr, info_ptr, tptrs.begin ().operator-> (), m_texts.size ()); + png_write_info (png_ptr, info_ptr); for (unsigned int i = 0; i < height (); ++i) { @@ -546,6 +557,7 @@ BitmapBuffer::operator= (const BitmapBuffer &other) m_height = other.m_height; m_stride = other.m_stride; m_data = other.m_data; + m_texts = other.m_texts; } return *this; } @@ -570,6 +582,7 @@ BitmapBuffer::swap (BitmapBuffer &other) std::swap (m_height, other.m_height); std::swap (m_stride, other.m_stride); m_data.swap (other.m_data); + m_texts.swap (other.m_texts); } void @@ -708,6 +721,15 @@ BitmapBuffer::write_png (tl::OutputStream &output) const png_set_IHDR (png_ptr, info_ptr, width (), height (), bd, fmt, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); + std::vector tptrs; + for (auto i = m_texts.begin (); i != m_texts.end (); ++i) { + tptrs.push_back (png_text ()); + tptrs.back ().compression = PNG_TEXT_COMPRESSION_NONE; + tptrs.back ().key = const_cast (i->first.c_str ()); + tptrs.back ().text = const_cast (i->second.c_str ()); + } + png_set_text (png_ptr, info_ptr, tptrs.begin ().operator-> (), m_texts.size ()); + png_write_info (png_ptr, info_ptr); for (unsigned int i = 0; i < height (); ++i) { diff --git a/src/laybasic/laybasic/layPixelBuffer.h b/src/laybasic/laybasic/layPixelBuffer.h index 1a095f7c0..943d445c0 100644 --- a/src/laybasic/laybasic/layPixelBuffer.h +++ b/src/laybasic/laybasic/layPixelBuffer.h @@ -258,6 +258,26 @@ public: */ PixelBuffer diff (const PixelBuffer &other) const; + /** + * @brief Gets the texts + * + * Texts are annotations which can be stored to PNG and back. + */ + const std::vector > &texts () const + { + return m_texts; + } + + /** + * @brief Sets the texts + * + * Texts are annotations which can be stored to PNG and back. + */ + void set_texts (const std::vector > &texts) + { + m_texts = texts; + } + private: class ImageData { @@ -301,6 +321,7 @@ private: unsigned int m_width, m_height; bool m_transparent; tl::copy_on_write_ptr m_data; + std::vector > m_texts; }; /** @@ -466,6 +487,26 @@ public: void write_png (tl::OutputStream &output) const; #endif + /** + * @brief Gets the texts + * + * Texts are annotations which can be stored to PNG and back. + */ + const std::vector > &texts () const + { + return m_texts; + } + + /** + * @brief Sets the texts + * + * Texts are annotations which can be stored to PNG and back. + */ + void set_texts (const std::vector > &texts) + { + m_texts = texts; + } + private: class MonoImageData { @@ -509,6 +550,7 @@ private: unsigned int m_width, m_height; unsigned int m_stride; tl::copy_on_write_ptr m_data; + std::vector > m_texts; }; } diff --git a/src/laybasic/unit_tests/layLayoutViewTests.cc b/src/laybasic/unit_tests/layLayoutViewTests.cc index 464954af7..806026609 100644 --- a/src/laybasic/unit_tests/layLayoutViewTests.cc +++ b/src/laybasic/unit_tests/layLayoutViewTests.cc @@ -236,3 +236,90 @@ TEST(13) EXPECT_EQ (compare_images (img, au_img), true); } #endif + +#if defined(HAVE_PNG) || defined(HAVE_QT) +TEST(21) +{ + lay::LayoutView lv (0, false, 0); + lv.cell_box_color (lay::Color (0, 0, 0)); + + lv.load_layout (tl::testsrc () + "/testdata/gds/t10.gds", true); + + std::string tmp = tmp_file ("test.png"); + lv.save_image_with_options (tmp, 500, 500, 1, 1, 1.0, lay::Color (255, 255, 255), lay::Color (0, 0, 0), lay::Color (128, 128, 128), db::DBox (), false); + + lay::PixelBuffer img; + { + tl::InputStream stream (tmp); + img = lay::PixelBuffer::read_png (stream); + } + tl::info << "PNG file read from " << tmp; + + std::string au = tl::testsrc () + "/testdata/lay/au_lv1.png"; + lay::PixelBuffer au_img; + { + tl::InputStream stream (au); + au_img = lay::PixelBuffer::read_png (stream); + } + tl::info << "PNG file read from " << au; + + EXPECT_EQ (compare_images (img, au_img), true); +} + +TEST(22) +{ + lay::LayoutView lv (0, false, 0); + lv.full_hier_new_cell (true); + + lv.load_layout (tl::testsrc () + "/testdata/gds/t10.gds", true); + + std::string tmp = tmp_file ("test.png"); + lv.save_image_with_options (tmp, 500, 500, 1, 1, 1.0, lay::Color (255, 255, 255), lay::Color (0, 0, 0), lay::Color (128, 128, 128), db::DBox (), false); + + lay::PixelBuffer img; + { + tl::InputStream stream (tmp); + img = lay::PixelBuffer::read_png (stream); + } + tl::info << "PNG file read from " << tmp; + + std::string au = tl::testsrc () + "/testdata/lay/au_lv2.png"; + lay::PixelBuffer au_img; + { + tl::InputStream stream (au); + au_img = lay::PixelBuffer::read_png (stream); + } + tl::info << "PNG file read from " << au; + + EXPECT_EQ (compare_images (img, au_img), true); +} + +// monochrome +TEST(23) +{ + lay::LayoutView lv (0, false, 0); + lv.full_hier_new_cell (true); + + lv.load_layout (tl::testsrc () + "/testdata/gds/t10.gds", true); + + std::string tmp = tmp_file ("test.png"); + lv.save_image_with_options (tmp, 500, 500, 1, 1, 1.0, lay::Color (255, 255, 255), lay::Color (0, 0, 0), lay::Color (128, 128, 128), db::DBox (), true); + + lay::BitmapBuffer img; + { + tl::InputStream stream (tmp); + img = lay::BitmapBuffer::read_png (stream); + } + tl::info << "PNG file read from " << tmp; + + std::string au = tl::testsrc () + "/testdata/lay/au_lv3.png"; + lay::BitmapBuffer au_img; + { + tl::InputStream stream (au); + au_img = lay::BitmapBuffer::read_png (stream); + } + tl::info << "PNG file read from " << au; + + EXPECT_EQ (compare_images (img, au_img), true); +} +#endif From 7b85bf7de23b51754b09da59c791b979b829a403 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 7 May 2022 20:41:46 +0200 Subject: [PATCH 40/88] Enabled Qt-less builds, tests passing --- src/laybasic/laybasic/layConverters.cc | 4 +++ src/laybasic/laybasic/layLayoutCanvas.cc | 20 ++++++++++- src/laybasic/laybasic/layLayoutCanvas.h | 3 ++ src/laybasic/laybasic/layLayoutViewBase.cc | 36 +++++++++---------- src/laybasic/laybasic/laySelector.cc | 33 +++++++++++++---- src/laybasic/laybasic/laybasic.pro | 16 ++++----- src/laybasic/unit_tests/layLayoutViewTests.cc | 4 +-- 7 files changed, 80 insertions(+), 36 deletions(-) diff --git a/src/laybasic/laybasic/layConverters.cc b/src/laybasic/laybasic/layConverters.cc index 3a5f0497a..9aababc46 100644 --- a/src/laybasic/laybasic/layConverters.cc +++ b/src/laybasic/laybasic/layConverters.cc @@ -31,6 +31,7 @@ namespace lay // ---------------------------------------------------------------- // ColorConverter implementation +#if defined(HAVE_QT) std::string ColorConverter::to_string (const QColor &c) const { @@ -40,6 +41,7 @@ ColorConverter::to_string (const QColor &c) const return tl::to_string (c.name ()); } } +#endif std::string ColorConverter::to_string (const lay::Color &c) const @@ -51,6 +53,7 @@ ColorConverter::to_string (const lay::Color &c) const } } +#if defined(HAVE_QT) void ColorConverter::from_string (const std::string &s, QColor &c) const { @@ -61,6 +64,7 @@ ColorConverter::from_string (const std::string &s, QColor &c) const c = QColor (t.c_str ()); } } +#endif void ColorConverter::from_string (const std::string &s, lay::Color &c) const diff --git a/src/laybasic/laybasic/layLayoutCanvas.cc b/src/laybasic/laybasic/layLayoutCanvas.cc index ea9eb5e1c..8d830b78a 100644 --- a/src/laybasic/laybasic/layLayoutCanvas.cc +++ b/src/laybasic/laybasic/layLayoutCanvas.cc @@ -1006,7 +1006,8 @@ LayoutCanvas::screenshot () return img; } -#if defined(HAVE_QT) // @@@ +#if defined(HAVE_QT) + void LayoutCanvas::resizeEvent (QResizeEvent *) { @@ -1020,6 +1021,23 @@ LayoutCanvas::resizeEvent (QResizeEvent *) do_redraw_all (true); viewport_changed_event (); } + +#else + +void +LayoutCanvas::resize (unsigned int width, unsigned int height) +{ + // clear the image cache + m_image_cache.clear (); + + // set the viewport to the new size + m_viewport.set_size (width * m_dpr, height * m_dpr); + m_viewport_l.set_size (width * m_oversampling * m_dpr, height * m_oversampling * m_dpr); + mouse_event_trans (db::DCplxTrans (1.0 / double (m_dpr)) * m_viewport.trans ()); + do_redraw_all (true); + viewport_changed_event (); +} + #endif void diff --git a/src/laybasic/laybasic/layLayoutCanvas.h b/src/laybasic/laybasic/layLayoutCanvas.h index 8e254a1fb..8af843e87 100644 --- a/src/laybasic/laybasic/layLayoutCanvas.h +++ b/src/laybasic/laybasic/layLayoutCanvas.h @@ -396,7 +396,10 @@ private: virtual void paintEvent (QPaintEvent *); virtual void resizeEvent (QResizeEvent *); virtual bool event (QEvent *e); +#else + void resize (unsigned int width, unsigned int height); #endif + virtual void key_event (unsigned int key, unsigned int buttons); // implementation of the lay::Drawings interface diff --git a/src/laybasic/laybasic/layLayoutViewBase.cc b/src/laybasic/laybasic/layLayoutViewBase.cc index e427b4ef7..8901d20bd 100644 --- a/src/laybasic/laybasic/layLayoutViewBase.cc +++ b/src/laybasic/laybasic/layLayoutViewBase.cc @@ -354,7 +354,7 @@ LayoutViewBase::init (db::Manager *mgr) m_no_stipples = false; m_stipple_offset = true; m_fit_new_cell = true; - m_full_hier_new_cell = true; + m_full_hier_new_cell = false; m_clear_ruler_new_cell = false; m_dbu_coordinates = false; m_absolute_coordinates = false; @@ -2475,7 +2475,7 @@ LayoutViewBase::init_layer_properties (LayerProperties &p, const LayerProperties QImage LayoutViewBase::get_screenshot () { - tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Save screenshot"))); + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Save screenshot"))); // Execute all deferred methods - ensure there are no pending tasks tl::DeferredMethodScheduler::execute (); @@ -2487,7 +2487,7 @@ LayoutViewBase::get_screenshot () lay::PixelBuffer LayoutViewBase::get_screenshot_pb () { - tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Save screenshot"))); + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Save screenshot"))); // Execute all deferred methods - ensure there are no pending tasks tl::DeferredMethodScheduler::execute (); @@ -2519,7 +2519,7 @@ png_texts (const lay::LayoutViewBase *view, const db::DBox &box) void LayoutViewBase::save_screenshot (const std::string &fn) { - tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Save screenshot"))); + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Save screenshot"))); QImageWriter writer (tl::to_qstring (fn), QByteArray ("PNG")); @@ -2532,7 +2532,7 @@ LayoutViewBase::save_screenshot (const std::string &fn) tl::DeferredMethodScheduler::execute (); if (! writer.write (mp_canvas->screenshot ().to_image ())) { - throw tl::Exception (tl::to_string (QObject::tr ("Unable to write screenshot to file: %s (%s)")), fn, tl::to_string (writer.errorString ())); + throw tl::Exception (tl::to_string (tr ("Unable to write screenshot to file: %s (%s)")), fn, tl::to_string (writer.errorString ())); } tl::log << "Saved screen shot to " << fn; @@ -2541,7 +2541,7 @@ LayoutViewBase::save_screenshot (const std::string &fn) void LayoutViewBase::save_screenshot (const std::string &fn) { - tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Save screenshot"))); + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Save screenshot"))); // Execute all deferred methods - ensure there are no pending tasks tl::DeferredMethodScheduler::execute (); @@ -2559,7 +2559,7 @@ LayoutViewBase::save_screenshot (const std::string &fn) QImage LayoutViewBase::get_image (unsigned int width, unsigned int height) { - tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Get image"))); + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Get image"))); // Execute all deferred methods - ensure there are no pending tasks tl::DeferredMethodScheduler::execute (); @@ -2571,7 +2571,7 @@ LayoutViewBase::get_image (unsigned int width, unsigned int height) lay::PixelBuffer LayoutViewBase::get_pixels (unsigned int width, unsigned int height) { - tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Get image"))); + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Get image"))); // Execute all deferred methods - ensure there are no pending tasks tl::DeferredMethodScheduler::execute (); @@ -2584,7 +2584,7 @@ QImage LayoutViewBase::get_image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, lay::Color background, lay::Color foreground, lay::Color active, const db::DBox &target_box, bool monochrome) { - tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Get image"))); + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Get image"))); // Execute all deferred methods - ensure there are no pending tasks tl::DeferredMethodScheduler::execute (); @@ -2601,7 +2601,7 @@ lay::PixelBuffer LayoutViewBase::get_pixels_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, lay::Color background, lay::Color foreground, lay::Color active, const db::DBox &target_box) { - tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Get image"))); + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Get image"))); // Execute all deferred methods - ensure there are no pending tasks tl::DeferredMethodScheduler::execute (); @@ -2613,7 +2613,7 @@ lay::BitmapBuffer LayoutViewBase::get_pixels_with_options_mono (unsigned int width, unsigned int height, int linewidth, lay::Color background, lay::Color foreground, lay::Color active, const db::DBox &target_box) { - tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Get image"))); + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Get image"))); // Execute all deferred methods - ensure there are no pending tasks tl::DeferredMethodScheduler::execute (); @@ -2625,7 +2625,7 @@ LayoutViewBase::get_pixels_with_options_mono (unsigned int width, unsigned int h void LayoutViewBase::save_image (const std::string &fn, unsigned int width, unsigned int height) { - tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Save image"))); + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Save image"))); QImageWriter writer (tl::to_qstring (fn), QByteArray ("PNG")); @@ -2639,7 +2639,7 @@ LayoutViewBase::save_image (const std::string &fn, unsigned int width, unsigned tl::DeferredMethodScheduler::execute (); if (! writer.write (mp_canvas->image (width, height).to_image ())) { - throw tl::Exception (tl::to_string (QObject::tr ("Unable to write screenshot to file: %s (%s)")), fn, tl::to_string (writer.errorString ())); + throw tl::Exception (tl::to_string (tr ("Unable to write screenshot to file: %s (%s)")), fn, tl::to_string (writer.errorString ())); } tl::log << "Saved image to " << fn; @@ -2648,7 +2648,7 @@ LayoutViewBase::save_image (const std::string &fn, unsigned int width, unsigned void LayoutViewBase::save_image (const std::string &fn, unsigned int width, unsigned int height) { - tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Save image"))); + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Save image"))); lay::Viewport vp (width, height, mp_canvas->viewport ().target_box ()); @@ -2671,7 +2671,7 @@ LayoutViewBase::save_image_with_options (const std::string &fn, unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, lay::Color background, lay::Color foreground, lay::Color active, const db::DBox &target_box, bool monochrome) { - tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Save image"))); + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Save image"))); QImageWriter writer (tl::to_qstring (fn), QByteArray ("PNG")); @@ -2686,11 +2686,11 @@ LayoutViewBase::save_image_with_options (const std::string &fn, if (monochrome) { if (! writer.write (mp_canvas->image_with_options_mono (width, height, linewidth, background, foreground, active, target_box).to_image ())) { - throw tl::Exception (tl::to_string (QObject::tr ("Unable to write screenshot to file: %s (%s)")), fn, tl::to_string (writer.errorString ())); + throw tl::Exception (tl::to_string (tr ("Unable to write screenshot to file: %s (%s)")), fn, tl::to_string (writer.errorString ())); } } else { if (! writer.write (mp_canvas->image_with_options (width, height, linewidth, oversampling, resolution, background, foreground, active, target_box).to_image ())) { - throw tl::Exception (tl::to_string (QObject::tr ("Unable to write screenshot to file: %s (%s)")), fn, tl::to_string (writer.errorString ())); + throw tl::Exception (tl::to_string (tr ("Unable to write screenshot to file: %s (%s)")), fn, tl::to_string (writer.errorString ())); } } @@ -2702,7 +2702,7 @@ LayoutViewBase::save_image_with_options (const std::string &fn, unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, lay::Color background, lay::Color foreground, lay::Color active, const db::DBox &target_box, bool monochrome) { - tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Save image"))); + tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Save image"))); lay::Viewport vp (width, height, mp_canvas->viewport ().target_box ()); std::vector > texts = png_texts (this, vp.box ()); diff --git a/src/laybasic/laybasic/laySelector.cc b/src/laybasic/laybasic/laySelector.cc index 029b1cbe1..a6bd77b4d 100644 --- a/src/laybasic/laybasic/laySelector.cc +++ b/src/laybasic/laybasic/laySelector.cc @@ -28,8 +28,10 @@ #include "tlLog.h" #include "tlException.h" -#include -#include +#if defined(HAVE_QT) +# include +# include +#endif namespace lay { @@ -37,8 +39,10 @@ namespace lay // ------------------------------------------------------------- // SelectionService implementation -SelectionService::SelectionService (lay::LayoutViewBase *view) - : QObject (), +SelectionService::SelectionService (lay::LayoutViewBase *view) : +#if defined(HAVE_QT) + QObject (), +#endif lay::ViewService (view->view_object_widget ()), mp_view (view), mp_box (0), @@ -48,9 +52,11 @@ SelectionService::SelectionService (lay::LayoutViewBase *view) m_hover_wait (false), m_mouse_in_window (false) { +#if defined(HAVE_QT) m_timer.setInterval (100 /*hover time*/); m_timer.setSingleShot (true); connect (&m_timer, SIGNAL (timeout ()), this, SLOT (timeout ())); +#endif } SelectionService::~SelectionService () @@ -81,7 +87,9 @@ void SelectionService::hover_reset () { if (m_hover_wait) { +#if defined(HAVE_QT) m_timer.stop (); +#endif m_hover_wait = false; } if (m_hover) { @@ -90,6 +98,7 @@ SelectionService::hover_reset () } } +#if defined(HAVE_QT) void SelectionService::timeout () { @@ -98,6 +107,7 @@ SelectionService::timeout () mp_view->clear_transient_selection (); mp_view->transient_select (m_hover_point); } +#endif void SelectionService::reset_box () @@ -155,7 +165,9 @@ SelectionService::mouse_move_event (const db::DPoint &p, unsigned int buttons, b mp_box->set_points (m_p1, m_p2); } else if (m_mouse_in_window && mp_view->transient_selection_mode ()) { m_hover_wait = true; +#if defined(HAVE_QT) m_timer.start (); +#endif m_hover_point = p; } @@ -173,10 +185,12 @@ SelectionService::mouse_double_click_event (const db::DPoint & /*p*/, unsigned i reset_box (); } +#if defined(HAVE_QT) if (prio && (buttons & lay::LeftButton) != 0) { mp_view->show_properties (QApplication::activeWindow ()); return true; } +#endif return false; } @@ -230,13 +244,17 @@ SelectionService::mouse_click_event (const db::DPoint &p, unsigned int buttons, // add a transient selection trigger to capture the "next" selection. if (mp_view->transient_selection_mode ()) { m_hover_wait = true; +#if defined(HAVE_QT) m_timer.start (); +#endif m_hover_point = p; } } catch (tl::Exception &ex) { tl::error << ex.msg (); - QMessageBox::critical (0, QObject::tr ("Error"), tl::to_qstring (ex.msg ())); +#if defined(HAVE_QT) + QMessageBox::critical (0, tr ("Error"), tl::to_qstring (ex.msg ())); +#endif // clear selection mp_view->select (db::DBox (), lay::Editable::Reset); } @@ -273,7 +291,9 @@ SelectionService::mouse_release_event (const db::DPoint & /*p*/, unsigned int /* mp_view->select (db::DBox (m_p1, m_p2), mode); } catch (tl::Exception &ex) { tl::error << ex.msg (); - QMessageBox::critical (0, QObject::tr ("Error"), tl::to_qstring (ex.msg ())); +#if defined(HAVE_QT) + QMessageBox::critical (0, tr ("Error"), tl::to_qstring (ex.msg ())); +#endif // clear selection mp_view->select (db::DBox (), lay::Editable::Reset); } @@ -301,4 +321,3 @@ SelectionService::begin (const db::DPoint &pos) } } - diff --git a/src/laybasic/laybasic/laybasic.pro b/src/laybasic/laybasic/laybasic.pro index 1702e9fac..81e2fceb3 100644 --- a/src/laybasic/laybasic/laybasic.pro +++ b/src/laybasic/laybasic/laybasic.pro @@ -90,7 +90,6 @@ DEFINES += MAKE_LAYBASIC_LIBRARY gtf.cc \ layAbstractMenu.cc \ layBackgroundAwareTreeStyle.cc \ - layBitmapsToImage.cc \ layBookmarkList.cc \ layBookmarkManagementForm.cc \ layBookmarksView.cc \ @@ -103,7 +102,6 @@ DEFINES += MAKE_LAYBASIC_LIBRARY layCellSelectionForm.cc \ layCellTreeModel.cc \ layConfigurationDialog.cc \ - layConverters.cc \ layCursor.cc \ layDialogs.cc \ layEditLineStyleWidget.cc \ @@ -146,12 +144,10 @@ DEFINES += MAKE_LAYBASIC_LIBRARY laySelectCellViewForm.cc \ laySelectLineStyleForm.cc \ laySelectStippleForm.cc \ - laySelector.cc \ layStream.cc \ layTechnology.cc \ layTipDialog.cc \ layWidgets.cc \ - layZoomBox.cc \ rdbInfoWidget.cc \ rdbMarkerBrowser.cc \ rdbMarkerBrowserDialog.cc \ @@ -162,7 +158,6 @@ DEFINES += MAKE_LAYBASIC_LIBRARY layAbstractMenu.h \ layBackgroundAwareTreeStyle.h \ layBitmap.h \ - layBitmapsToImage.h \ layBookmarkList.h \ layBookmarkManagementForm.h \ layBookmarksView.h \ @@ -175,7 +170,6 @@ DEFINES += MAKE_LAYBASIC_LIBRARY layCellSelectionForm.h \ layCellTreeModel.h \ layConfigurationDialog.h \ - layConverters.h \ layColor.h \ layCursor.h \ layDialogs.h \ @@ -219,12 +213,10 @@ DEFINES += MAKE_LAYBASIC_LIBRARY laySelectCellViewForm.h \ laySelectLineStyleForm.h \ laySelectStippleForm.h \ - laySelector.h \ layStream.h \ layTechnology.h \ layTipDialog.h \ layWidgets.h \ - layZoomBox.h \ laybasicConfig.h \ rdbInfoWidget.h \ rdbMarkerBrowser.h \ @@ -242,9 +234,11 @@ SOURCES += \ layAnnotationShapes.cc \ layBitmap.cc \ layBitmapRenderer.cc \ + layBitmapsToImage.cc \ layCellView.cc \ layColor.cc \ layColorPalette.cc \ + layConverters.cc \ layDispatcher.cc \ layDisplayState.cc \ layDitherPattern.cc \ @@ -272,6 +266,7 @@ SOURCES += \ layRedrawThreadWorker.cc \ layRenderer.cc \ layRubberBox.cc \ + laySelector.cc \ laySnap.cc \ layStipplePalette.cc \ layCanvasPlane.cc \ @@ -280,13 +275,16 @@ SOURCES += \ layViewObject.cc \ layViewOp.cc \ layViewport.cc \ + layZoomBox.cc \ HEADERS += \ layAnnotationShapes.h \ layBitmap.h \ layBitmapRenderer.h \ + layBitmapsToImage.h \ layCellView.h \ layColorPalette.h \ + layConverters.h \ layDispatcher.h \ layDisplayState.h \ layDitherPattern.h \ @@ -315,6 +313,7 @@ HEADERS += \ layRedrawThreadWorker.h \ layRenderer.h \ layRubberBox.h \ + laySelector.h \ laySnap.h \ layStipplePalette.h \ layLayerProperties.h \ @@ -322,6 +321,7 @@ HEADERS += \ layViewObject.h \ layViewOp.h \ layViewport.h \ + layZoomBox.h \ laybasicCommon.h \ diff --git a/src/laybasic/unit_tests/layLayoutViewTests.cc b/src/laybasic/unit_tests/layLayoutViewTests.cc index 806026609..3e0936add 100644 --- a/src/laybasic/unit_tests/layLayoutViewTests.cc +++ b/src/laybasic/unit_tests/layLayoutViewTests.cc @@ -69,6 +69,8 @@ static bool compare_images_mono (const QImage &qimg, const std::string &au) } } +#endif + static bool compare_images (const lay::PixelBuffer &img, const lay::PixelBuffer &img2) { return img == img2; @@ -79,8 +81,6 @@ static bool compare_images (const lay::BitmapBuffer &img, const lay::BitmapBuffe return img == img2; } -#endif - #if defined(HAVE_QT) TEST(1) { From 42f0a79deedb2e51126599dafd4b351cad3e0e7d Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 7 May 2022 22:12:36 +0200 Subject: [PATCH 41/88] Resize method and tests --- src/laybasic/laybasic/gsiDeclLayLayoutView.cc | 5 ++ src/laybasic/laybasic/layLayoutCanvas.cc | 51 +++++++++++-------- src/laybasic/laybasic/layLayoutCanvas.h | 10 ++-- src/laybasic/laybasic/layLayoutView.h | 8 +++ src/laybasic/laybasic/layLayoutViewBase.cc | 5 ++ src/laybasic/laybasic/layLayoutViewBase.h | 5 ++ src/laybasic/unit_tests/layLayoutViewTests.cc | 23 +++++++++ testdata/ruby/layLayoutView.rb | 17 +++++++ 8 files changed, 100 insertions(+), 24 deletions(-) diff --git a/src/laybasic/laybasic/gsiDeclLayLayoutView.cc b/src/laybasic/laybasic/gsiDeclLayLayoutView.cc index 862744309..10b39367d 100644 --- a/src/laybasic/laybasic/gsiDeclLayLayoutView.cc +++ b/src/laybasic/laybasic/gsiDeclLayLayoutView.cc @@ -1136,6 +1136,11 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "Show the layout in full depth down to the deepest level of hierarchy. " "This method may cause a redraw." ) + + gsi::method ("resize", static_cast (&lay::LayoutView::resize), + "@brief Resizes the layout view to the given dimension\n" + "\n" + "This method has been made available in all builds in 0.28.\n" + ) + #if defined(HAVE_QT) && defined(HAVE_QTBINDINGS) gsi::method ("get_screenshot", static_cast (&lay::LayoutView::get_screenshot), "@brief Gets a screenshot as a \\QImage\n" diff --git a/src/laybasic/laybasic/layLayoutCanvas.cc b/src/laybasic/laybasic/layLayoutCanvas.cc index 8d830b78a..7f533ff30 100644 --- a/src/laybasic/laybasic/layLayoutCanvas.cc +++ b/src/laybasic/laybasic/layLayoutCanvas.cc @@ -1007,38 +1007,47 @@ LayoutCanvas::screenshot () } #if defined(HAVE_QT) - void LayoutCanvas::resizeEvent (QResizeEvent *) { - // clear the image cache - m_image_cache.clear (); - - // set the viewport to the new size - m_viewport.set_size (width () * m_dpr, height () * m_dpr); - m_viewport_l.set_size (width () * m_oversampling * m_dpr, height () * m_oversampling * m_dpr); - mouse_event_trans (db::DCplxTrans (1.0 / double (m_dpr)) * m_viewport.trans ()); - do_redraw_all (true); - viewport_changed_event (); + do_resize (width (), height ()); } - -#else +#endif void LayoutCanvas::resize (unsigned int width, unsigned int height) { - // clear the image cache - m_image_cache.clear (); + // don't wait until the layout system informs us - which may never take place when + // the widget isn't shown. + do_resize (width, height); - // set the viewport to the new size - m_viewport.set_size (width * m_dpr, height * m_dpr); - m_viewport_l.set_size (width * m_oversampling * m_dpr, height * m_oversampling * m_dpr); - mouse_event_trans (db::DCplxTrans (1.0 / double (m_dpr)) * m_viewport.trans ()); - do_redraw_all (true); - viewport_changed_event (); +#if defined(HAVE_QT) + QWidget::resize (width, height); +#endif } -#endif +void +LayoutCanvas::do_resize (unsigned int width, unsigned int height) +{ + unsigned int w = width * m_dpr, h = height * m_dpr; + unsigned int wl = width * m_oversampling * m_dpr, hl = height * m_oversampling * m_dpr; + + if (m_viewport.width () != w || m_viewport.height () != h || + m_viewport_l.width () != wl || m_viewport_l.height () != hl) { + + // clear the image cache + m_image_cache.clear (); + + // set the viewport to the new size + m_viewport.set_size (width * m_dpr, height * m_dpr); + m_viewport_l.set_size (width * m_oversampling * m_dpr, height * m_oversampling * m_dpr); + + mouse_event_trans (db::DCplxTrans (1.0 / double (m_dpr)) * m_viewport.trans ()); + do_redraw_all (true); + viewport_changed_event (); + + } +} void LayoutCanvas::update_viewport () diff --git a/src/laybasic/laybasic/layLayoutCanvas.h b/src/laybasic/laybasic/layLayoutCanvas.h index 8af843e87..574abf17d 100644 --- a/src/laybasic/laybasic/layLayoutCanvas.h +++ b/src/laybasic/laybasic/layLayoutCanvas.h @@ -341,6 +341,11 @@ public: return m_viewport; } + /** + * @brief Resizes the canvas object in the Qt-less case + */ + void resize (unsigned int width, unsigned int height); + /** * @brief An event indicating that the viewport was changed. * If the viewport (the rectangle that is shown) changes, this event is fired. @@ -361,7 +366,7 @@ private: lay::LayoutViewBase *mp_view; lay::PixelBuffer *mp_image; lay::PixelBuffer *mp_image_bg; -#if defined(HAVE_QT) // @@@ +#if defined(HAVE_QT) QPixmap *mp_pixmap; #endif db::DBox m_precious_box; @@ -396,8 +401,6 @@ private: virtual void paintEvent (QPaintEvent *); virtual void resizeEvent (QResizeEvent *); virtual bool event (QEvent *e); -#else - void resize (unsigned int width, unsigned int height); #endif virtual void key_event (unsigned int key, unsigned int buttons); @@ -411,6 +414,7 @@ private: void do_update_image (); void do_end_of_drawing (); void do_redraw_all (bool force_redraw = true); + void do_resize (unsigned int width, unsigned int height); void prepare_drawing (); }; diff --git a/src/laybasic/laybasic/layLayoutView.h b/src/laybasic/laybasic/layLayoutView.h index 20a399634..3766b4e1c 100644 --- a/src/laybasic/laybasic/layLayoutView.h +++ b/src/laybasic/laybasic/layLayoutView.h @@ -413,6 +413,14 @@ public: return mp_editor_options_frame; } + /** + * @brief Resizes the view to the given width and height in pixels + */ + void resize (unsigned int width, unsigned int height) + { + LayoutViewBase::resize (width, height); + } + /** * @brief Copies to clipboard * diff --git a/src/laybasic/laybasic/layLayoutViewBase.cc b/src/laybasic/laybasic/layLayoutViewBase.cc index 8901d20bd..c5b448825 100644 --- a/src/laybasic/laybasic/layLayoutViewBase.cc +++ b/src/laybasic/laybasic/layLayoutViewBase.cc @@ -485,6 +485,11 @@ LayoutViewBase::~LayoutViewBase () mp_canvas = 0; } +void LayoutViewBase::resize (unsigned int width, unsigned int height) +{ + mp_canvas->resize (width, height); +} + void LayoutViewBase::update_event_handlers () { tl::Object::detach_from_all_events (); diff --git a/src/laybasic/laybasic/layLayoutViewBase.h b/src/laybasic/laybasic/layLayoutViewBase.h index d2a91e26f..91022595e 100644 --- a/src/laybasic/laybasic/layLayoutViewBase.h +++ b/src/laybasic/laybasic/layLayoutViewBase.h @@ -1637,6 +1637,11 @@ public: return mp_canvas->viewport (); } + /** + * @brief Resizes the view to the given width and height in pixels + */ + void resize (unsigned int width, unsigned int height); + /** * @brief Background color property */ diff --git a/src/laybasic/unit_tests/layLayoutViewTests.cc b/src/laybasic/unit_tests/layLayoutViewTests.cc index 3e0936add..5d9018461 100644 --- a/src/laybasic/unit_tests/layLayoutViewTests.cc +++ b/src/laybasic/unit_tests/layLayoutViewTests.cc @@ -24,6 +24,7 @@ #include "tlUnitTest.h" #include "tlTimer.h" +#include "tlSleep.h" #if defined(HAVE_QT) @@ -150,6 +151,28 @@ TEST(3) } #endif +TEST(4) +{ + lay::LayoutView lv (0, false, 0); + lv.set_drawing_workers (2); + lv.cell_box_color (lay::Color (0, 0, 0)); + + lv.load_layout (tl::testsrc () + "/testdata/gds/t10.gds", true); + + lv.resize (42, 117); + tl::msleep (250); + + lay::PixelBuffer img = lv.get_screenshot_pb (); + EXPECT_EQ (img.width (), 42); + EXPECT_EQ (img.height (), 117); + + lv.resize (142, 217); + + img = lv.get_screenshot_pb (); + EXPECT_EQ (img.width (), 142); + EXPECT_EQ (img.height (), 217); +} + #if defined(HAVE_PNG) TEST(11) { diff --git a/testdata/ruby/layLayoutView.rb b/testdata/ruby/layLayoutView.rb index e3d44b36f..28c59f72a 100644 --- a/testdata/ruby/layLayoutView.rb +++ b/testdata/ruby/layLayoutView.rb @@ -454,6 +454,23 @@ class LAYLayoutView_TestClass < TestBase end + def test_5 + + lv = RBA::LayoutView::new + lv.load_layout(File.join($ut_testsrc, "testdata/gds/t10.gds"), true) + + lv.resize(42, 117) + img = lv.get_screenshot_pixels + assert_equal(img.width, 42) + assert_equal(img.height, 117) + + lv.resize(142, 217) + img = lv.get_screenshot_pixels + assert_equal(img.width, 142) + assert_equal(img.height, 217) + + end + end load("test_epilogue.rb") From 1ad9dd2c11ea09ad1dfffbdbc85a2b8a00f9ac8c Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 7 May 2022 23:44:08 +0200 Subject: [PATCH 42/88] WIP: preparations for a non-Qt event loop protocol --- src/laybasic/laybasic/gsiDeclLayLayoutView.cc | 28 +++++++ src/laybasic/laybasic/gsiDeclLayPlugin.cc | 46 +++++++++++- src/laybasic/laybasic/layCellView.cc | 4 +- src/laybasic/laybasic/layLayoutCanvas.cc | 34 ++++++--- src/laybasic/laybasic/layLayoutCanvas.h | 6 ++ src/laybasic/laybasic/layLayoutView.cc | 20 +++++ src/laybasic/laybasic/layLayoutView.h | 15 ++++ src/laybasic/laybasic/layLayoutViewBase.cc | 3 +- src/laybasic/laybasic/layLayoutViewBase.h | 5 ++ src/laybasic/laybasic/layMove.cc | 10 +-- src/laybasic/laybasic/layViewObject.cc | 45 ++++++++--- src/laybasic/laybasic/layViewObject.h | 75 +++++++++++++++++-- 12 files changed, 252 insertions(+), 39 deletions(-) diff --git a/src/laybasic/laybasic/gsiDeclLayLayoutView.cc b/src/laybasic/laybasic/gsiDeclLayLayoutView.cc index 10b39367d..5e204847a 100644 --- a/src/laybasic/laybasic/gsiDeclLayLayoutView.cc +++ b/src/laybasic/laybasic/gsiDeclLayLayoutView.cc @@ -1593,6 +1593,34 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "Returns an array of \\LayerPropertiesIterator objects pointing to the currently selected layers. " "If no layer view is selected currently, an empty array is returned.\n" ) + +#if !defined(HAVE_QT) + gsi::event ("on_image_updated_event", static_cast (&lay::LayoutView::image_updated_event), + "@brief An event indicating that the image (\"screenshot\") was updated\n" + "\n" + "This event is triggered when calling \\timer." + "\n" + "This event has been introduced in version 0.28." + ) + + gsi::event ("on_drawing_finished_event", static_cast (&lay::LayoutView::drawing_finished_event), + "@brief An event indicating that the image is fully drawn\n" + "\n" + "This event is triggered when calling \\timer. " + "Before this event is issue, a final \\on_image_updated_event may be issued.\n" + "\n" + "This event has been introduced in version 0.28." + ) + + gsi::method ("timer", static_cast (&lay::LayoutView::timer), + "@brief A callback required to be called regularily in the non-Qt case.\n" + "\n" + "This callback eventually implements the event loop in the non-Qt case. The main task " + "is to indicate new versions of the layout image while it is drawn. " + "When a new image has arrived, this method will issue an \\on_image_updated_event. " + "In the implementation of the latter, \"screenshot\" may be called to retrieve the current image.\n" + "When drawing has finished, the \\on_drawing_finished_event will be triggered.\n" + "\n" + "This method has been introduced in version 0.28." + ) + +#endif gsi::event ("on_active_cellview_changed", static_cast (&lay::LayoutView::active_cellview_changed_event), "@brief An event indicating that the active cellview has changed\n" "\n" diff --git a/src/laybasic/laybasic/gsiDeclLayPlugin.cc b/src/laybasic/laybasic/gsiDeclLayPlugin.cc index d1b1f5d6b..f45415cf9 100644 --- a/src/laybasic/laybasic/gsiDeclLayPlugin.cc +++ b/src/laybasic/laybasic/gsiDeclLayPlugin.cc @@ -912,7 +912,51 @@ Class decl_ButtonState ("lay", "ButtonState", "This class has been introduced in version 0.22.\n" ); -static std::vector +class KeyCodesNamespace { }; + +static int const_KeyEscape() { return (int) lay::KeyEscape; } +static int const_KeyTab() { return (int) lay::KeyTab; } +static int const_KeyBacktab() { return (int) lay::KeyBacktab; } +static int const_KeyBackspace() { return (int) lay::KeyBackspace; } +static int const_KeyReturn() { return (int) lay::KeyReturn; } +static int const_KeyEnter() { return (int) lay::KeyEnter; } +static int const_KeyInsert() { return (int) lay::KeyInsert; } +static int const_KeyDelete() { return (int) lay::KeyDelete; } +static int const_KeyHome() { return (int) lay::KeyHome; } +static int const_KeyEnd() { return (int) lay::KeyEnd; } +static int const_KeyDown() { return (int) lay::KeyDown; } +static int const_KeyUp() { return (int) lay::KeyUp; } +static int const_KeyLeft() { return (int) lay::KeyLeft; } +static int const_KeyRight() { return (int) lay::KeyRight; } +static int const_KeyPageUp() { return (int) lay::KeyPageUp; } +static int const_KeyPageDown() { return (int) lay::KeyPageDown; } + +Class decl_KeyCode ("lay", "KeyCode", + method ("Escape", &const_KeyEscape, "@brief Indicates the Escape key") + + method ("Tab", &const_KeyTab, "@brief Indicates the Tab key") + + method ("Backtab", &const_KeyBacktab, "@brief Indicates the Backtab key") + + method ("Backspace", &const_KeyBackspace, "@brief Indicates the Backspace key") + + method ("Return", &const_KeyReturn, "@brief Indicates the Return key") + + method ("Enter", &const_KeyEnter, "@brief Indicates the Enter key") + + method ("Insert", &const_KeyInsert, "@brief Indicates the Insert key") + + method ("Delete", &const_KeyDelete, "@brief Indicates the Delete key") + + method ("Home", &const_KeyHome, "@brief Indicates the Home key") + + method ("End", &const_KeyEnd, "@brief Indicates the End key") + + method ("Down", &const_KeyDown, "@brief Indicates the Down key") + + method ("Up", &const_KeyUp, "@brief Indicates the Up key") + + method ("Left", &const_KeyLeft, "@brief Indicates the Left key") + + method ("Right", &const_KeyRight, "@brief Indicates the Right key") + + method ("PageUp", &const_KeyPageUp, "@brief Indicates the PageUp key") + + method ("PageDown", &const_KeyPageDown, "@brief Indicates the PageDown key"), + "@brief The namespace for the some key codes.\n" + "This namespace defines some key codes understood by built-in \\LayoutView components. " + "When compiling with Qt, these codes are compatible with Qt's key codes.\n" + "The key codes are intended to be used when directly interfacing with \\LayoutView in non-Qt-based environments.\n" + "\n" + "This class has been introduced in version 0.28.\n" +); + +static std::vector get_config_names (lay::Dispatcher *dispatcher) { std::vector names; diff --git a/src/laybasic/laybasic/layCellView.cc b/src/laybasic/laybasic/layCellView.cc index 1fa389ca9..f71e1e512 100644 --- a/src/laybasic/laybasic/layCellView.cc +++ b/src/laybasic/laybasic/layCellView.cc @@ -23,7 +23,7 @@ #include "layCellView.h" #include "layLayoutView.h" -#if defined(HAVE_QT) // @@@ +#if defined(HAVE_QT) # include "layStream.h" #endif #include "dbLayout.h" @@ -292,7 +292,7 @@ LayoutHandle::set_save_options (const db::SaveLayoutOptions &options, bool valid void LayoutHandle::update_save_options (db::SaveLayoutOptions &options) { -#if defined(HAVE_QT) // @@@ +#if defined(HAVE_QT) for (tl::Registrar::iterator cls = tl::Registrar::begin (); cls != tl::Registrar::end (); ++cls) { const lay::StreamWriterPluginDeclaration *decl = dynamic_cast (&*cls); diff --git a/src/laybasic/laybasic/layLayoutCanvas.cc b/src/laybasic/laybasic/layLayoutCanvas.cc index 7f533ff30..1838a26e1 100644 --- a/src/laybasic/laybasic/layLayoutCanvas.cc +++ b/src/laybasic/laybasic/layLayoutCanvas.cc @@ -296,6 +296,7 @@ LayoutCanvas::LayoutCanvas (lay::LayoutViewBase *view) m_redraw_clearing (false), m_redraw_force_update (true), m_update_image (true), + m_drawing_finished (false), m_do_update_image_dm (this, &LayoutCanvas::do_update_image), m_do_end_of_drawing_dm (this, &LayoutCanvas::do_end_of_drawing), m_image_cache_size (1) @@ -358,23 +359,23 @@ LayoutCanvas::key_event (unsigned int key, unsigned int buttons) { #if defined(HAVE_QT) // @@@ if (! (buttons & lay::ShiftButton)) { - if (int (key) == Qt::Key_Down) { + if (int (key) == lay::KeyDown) { emit down_arrow_key_pressed (); - } else if (int (key) == Qt::Key_Up) { + } else if (int (key) == lay::KeyUp) { emit up_arrow_key_pressed (); - } else if (int (key) == Qt::Key_Left) { + } else if (int (key) == lay::KeyLeft) { emit left_arrow_key_pressed (); - } else if (int (key) == Qt::Key_Right) { + } else if (int (key) == lay::KeyRight) { emit right_arrow_key_pressed (); } } else { - if (int (key) == Qt::Key_Down) { + if (int (key) == lay::KeyDown) { emit down_arrow_key_pressed_with_shift (); - } else if (int (key) == Qt::Key_Up) { + } else if (int (key) == lay::KeyUp) { emit up_arrow_key_pressed_with_shift (); - } else if (int (key) == Qt::Key_Left) { + } else if (int (key) == lay::KeyLeft) { emit left_arrow_key_pressed_with_shift (); - } else if (int (key) == Qt::Key_Right) { + } else if (int (key) == lay::KeyRight) { emit right_arrow_key_pressed_with_shift (); } } @@ -1017,13 +1018,12 @@ LayoutCanvas::resizeEvent (QResizeEvent *) void LayoutCanvas::resize (unsigned int width, unsigned int height) { + // pass down to the basic view object canvas + lay::ViewObjectWidget::resize (width, height); + // don't wait until the layout system informs us - which may never take place when // the widget isn't shown. do_resize (width, height); - -#if defined(HAVE_QT) - QWidget::resize (width, height); -#endif } void @@ -1093,6 +1093,14 @@ LayoutCanvas::zoom_trans (const db::DCplxTrans &trans) update_viewport (); } +bool +LayoutCanvas::drawing_finished () +{ + bool f = m_drawing_finished; + m_drawing_finished = false; + return f; +} + void LayoutCanvas::do_end_of_drawing () { @@ -1109,6 +1117,8 @@ LayoutCanvas::do_end_of_drawing () } set_default_cursor (lay::Cursor::none); + + m_drawing_finished = true; } void diff --git a/src/laybasic/laybasic/layLayoutCanvas.h b/src/laybasic/laybasic/layLayoutCanvas.h index 574abf17d..2083745da 100644 --- a/src/laybasic/laybasic/layLayoutCanvas.h +++ b/src/laybasic/laybasic/layLayoutCanvas.h @@ -346,6 +346,11 @@ public: */ void resize (unsigned int width, unsigned int height); + /** + * @brief Gets (and resets) a flag indicating that drawing has finished + */ + bool drawing_finished (); + /** * @brief An event indicating that the viewport was changed. * If the viewport (the rectangle that is shown) changes, this event is fired. @@ -385,6 +390,7 @@ private: bool m_redraw_clearing; bool m_redraw_force_update; bool m_update_image; + bool m_drawing_finished; std::vector m_need_redraw_layer; std::vector m_layers; diff --git a/src/laybasic/laybasic/layLayoutView.cc b/src/laybasic/laybasic/layLayoutView.cc index 11dedc436..9ad09fe7b 100644 --- a/src/laybasic/laybasic/layLayoutView.cc +++ b/src/laybasic/laybasic/layLayoutView.cc @@ -1128,6 +1128,26 @@ LayoutView::LayoutView (lay::LayoutView *source, db::Manager *mgr, bool editable // .. nothing yet .. } +// NOTE: this methods needs to be called "frequently" +void +LayoutView::timer () +{ + LayoutViewBase::timer (); + + // Without Qt, this is also the opportunity to execute deferred methods + tl::DeferredMethodScheduler::execute (); + + // We also issue the "image_updated" event if the image ("screenshot") has been updated + if (canvas ()->image_updated ()) { + image_updated_event (); + } + + // And also the drawing_finished event + if (canvas ()->drawing_finished ()) { + drawing_finished_event (); + } +} + } // namespace lay #endif diff --git a/src/laybasic/laybasic/layLayoutView.h b/src/laybasic/laybasic/layLayoutView.h index 3766b4e1c..0ce115255 100644 --- a/src/laybasic/laybasic/layLayoutView.h +++ b/src/laybasic/laybasic/layLayoutView.h @@ -794,6 +794,21 @@ public: */ LayoutView (lay::LayoutView *source, db::Manager *mgr, bool editable, lay::Plugin *plugin_parent, unsigned int options = (unsigned int) LV_Normal); + /** + * @brief This event is triggered in the "timer" callback when the image ("screenshot") was updated. + */ + tl::Event image_updated_event; + + /** + * @brief This event is triggered in the "timer" callback when the drawing thread has finished. + */ + tl::Event drawing_finished_event; + + /** + * @brief A callback that needs to be called "frequently" + */ + void timer (); + protected: /** * @brief Gets the LayoutView interface diff --git a/src/laybasic/laybasic/layLayoutViewBase.cc b/src/laybasic/laybasic/layLayoutViewBase.cc index c5b448825..4b0487e19 100644 --- a/src/laybasic/laybasic/layLayoutViewBase.cc +++ b/src/laybasic/laybasic/layLayoutViewBase.cc @@ -34,6 +34,7 @@ #include "tlLog.h" #include "tlAssert.h" #include "tlExceptions.h" +#include "tlDeferredExecution.h" #include "layLayoutViewBase.h" #include "layViewOp.h" #include "layViewObject.h" @@ -3357,7 +3358,7 @@ LayoutViewBase::get_ui () return mp_ui; } -// @@@ needs to be called "as often as possible" +// NOTE: this methods needs to be called "frequently" void LayoutViewBase::timer () { diff --git a/src/laybasic/laybasic/layLayoutViewBase.h b/src/laybasic/laybasic/layLayoutViewBase.h index 91022595e..742f3fccc 100644 --- a/src/laybasic/laybasic/layLayoutViewBase.h +++ b/src/laybasic/laybasic/layLayoutViewBase.h @@ -2762,6 +2762,11 @@ protected: virtual LayoutView *get_ui (); + lay::LayoutCanvas *canvas () + { + return mp_canvas; + } + bool configure (const std::string &name, const std::string &value); void config_finalize (); diff --git a/src/laybasic/laybasic/layMove.cc b/src/laybasic/laybasic/layMove.cc index 9667ccb77..da4264da4 100644 --- a/src/laybasic/laybasic/layMove.cc +++ b/src/laybasic/laybasic/layMove.cc @@ -89,17 +89,15 @@ bool MoveService::key_event (unsigned int key, unsigned int /*buttons*/) { double dx = 0.0, dy = 0.0; -#if defined(HAVE_QT) // @@@ - if (int (key) == Qt::Key_Down) { + if (int (key) == lay::KeyDown) { dy = -1.0; - } else if (int (key) == Qt::Key_Up) { + } else if (int (key) == lay::KeyUp) { dy = 1.0; - } else if (int (key) == Qt::Key_Left) { + } else if (int (key) == lay::KeyLeft) { dx = -1.0; - } else if (int (key) == Qt::Key_Right) { + } else if (int (key) == lay::KeyRight) { dx = 1.0; } -#endif if (! m_dragging && fabs (dx + dy) > 0.0 && mp_editables->has_selection ()) { diff --git a/src/laybasic/laybasic/layViewObject.cc b/src/laybasic/laybasic/layViewObject.cc index 528b3e689..8a881c321 100644 --- a/src/laybasic/laybasic/layViewObject.cc +++ b/src/laybasic/laybasic/layViewObject.cc @@ -232,9 +232,7 @@ ViewObject::redraw () if (m_static) { widget ()->touch (); } else { -#if defined(HAVE_QT) - widget ()->update (); // @@@ -#endif + widget ()->update (); } } } @@ -287,9 +285,9 @@ ViewService::set_cursor (lay::Cursor::cursor_shape cursor) } // --------------------------------------------------------------- -// ViewObject implementation +// ViewObjectWidget implementation -#if defined(HAVE_QT) // @@@ +#if defined(HAVE_QT) ViewObjectWidget::ViewObjectWidget (QWidget *parent, const char *name) : QWidget (parent), m_view_objects_dismissed (false), @@ -301,7 +299,10 @@ ViewObjectWidget::ViewObjectWidget (QWidget *parent, const char *name) m_in_mouse_move (false), m_mouse_inside (false), m_cursor (lay::Cursor::none), - m_default_cursor (lay::Cursor::none) + m_default_cursor (lay::Cursor::none), + m_widget_width (0), + m_widget_height (0), + m_image_updated (false) { setMouseTracking (true); setObjectName (QString::fromUtf8 (name)); @@ -320,7 +321,10 @@ ViewObjectWidget::ViewObjectWidget () m_in_mouse_move (false), m_mouse_inside (false), m_cursor (lay::Cursor::none), - m_default_cursor (lay::Cursor::none) + m_default_cursor (lay::Cursor::none), + m_widget_width (500), + m_widget_height (500), + m_image_updated (false) { m_objects.changed ().add (this, &ViewObjectWidget::objects_changed); } @@ -395,7 +399,7 @@ ViewObjectWidget::set_cursor (lay::Cursor::cursor_shape cursor) void ViewObjectWidget::set_default_cursor (lay::Cursor::cursor_shape cursor) { -#if defined(HAVE_QT) // @@@ +#if defined(HAVE_QT) if (cursor != m_default_cursor) { m_default_cursor = cursor; if (m_cursor == lay::Cursor::none) { @@ -920,13 +924,23 @@ END_PROTECTED } #endif +void +ViewObjectWidget::resize (unsigned int w, unsigned int h) +{ + m_widget_width = w; + m_widget_height = h; +#if defined(HAVE_QT) + QWidget::resize (w, h); +#endif +} + int ViewObjectWidget::widget_height () const { #if defined(HAVE_QT) return height (); #else - return 500; // @@@ + return m_widget_height; #endif } @@ -936,7 +950,7 @@ ViewObjectWidget::widget_width () const #if defined(HAVE_QT) return width (); #else - return 800; // @@@ + return m_widget_width; #endif } @@ -1078,7 +1092,16 @@ ViewObjectWidget::thaw (ViewObject *obj) void ViewObjectWidget::update () { - // @@@ + // NOTE: this does not need to be thread-safe as we make sure (as in Qt) that update() is always called from the main thread. + m_image_updated = true; +} + +bool +ViewObjectWidget::image_updated () +{ + bool f = m_image_updated; + m_image_updated = false; + return f; } #endif diff --git a/src/laybasic/laybasic/layViewObject.h b/src/laybasic/laybasic/layViewObject.h index bd1350dff..dfd24623d 100644 --- a/src/laybasic/laybasic/layViewObject.h +++ b/src/laybasic/laybasic/layViewObject.h @@ -638,12 +638,53 @@ private: * @brief Describes the button state (supposed to be ored) */ enum ButtonState { - ShiftButton = 1, + ShiftButton = 1, ControlButton = 2, - AltButton = 4, - LeftButton = 8, - MidButton = 16, - RightButton = 32 + AltButton = 4, + LeftButton = 8, + MidButton = 16, + RightButton = 32 +}; + +/** + * @brief Key codes for keys understood by the standard components + */ +enum KeyCodes { +#if defined(HAVE_QT) + KeyEscape = int(Qt::Key_Escape), + KeyTab = int(Qt::Key_Tab), + KeyBacktab = int(Qt::Key_Backtab), + KeyBackspace = int(Qt::Key_Backspace), + KeyReturn = int(Qt::Key_Return), + KeyEnter = int(Qt::Key_Enter), + KeyInsert = int(Qt::Key_Insert), + KeyDelete = int(Qt::Key_Delete), + KeyHome = int(Qt::Key_Home), + KeyEnd = int(Qt::Key_End), + KeyDown = int(Qt::Key_Down), + KeyUp = int(Qt::Key_Up), + KeyLeft = int(Qt::Key_Left), + KeyRight = int(Qt::Key_Right), + KeyPageUp = int(Qt::Key_PageUp), + KeyPageDown = int(Qt::Key_PageDown) +#else + KeyEscape = 0x01000000, + KeyTab = 0x01000001, + KeyBacktab = 0x01000002, + KeyBackspace = 0x01000003, + KeyReturn = 0x01000004, + KeyEnter = 0x01000005, + KeyInsert = 0x01000006, + KeyDelete = 0x01000007, + KeyHome = 0x01000010, + KeyEnd = 0x01000011, + KeyLeft = 0x01000012, + KeyUp = 0x01000013, + KeyRight = 0x01000014, + KeyDown = 0x01000015, + KeyPageUp = 0x01000016, + KeyPageDown = 0x01000017 +#endif }; /** @@ -1031,6 +1072,15 @@ public: return m_mouse_inside; } +#if !defined(HAVE_QT) + /** + * @brief Gets a value indicating that the image data has been updated + * + * This method will return true once after "update" was called. + */ + bool image_updated (); +#endif + protected: #if defined(HAVE_QT) // @@@ /** @@ -1103,7 +1153,13 @@ protected: void wheelEvent (QWheelEvent *e); #endif -#if !defined(HAVE_QT) // @@@ +#if !defined(HAVE_QT) + /** + * @brief Emulates the update() method in the non-Qt case + * + * After calling this method, the next image_updated() call will return true while also resetting the + * update needed flag. + */ void update (); #endif @@ -1112,6 +1168,11 @@ protected: */ void mouse_event_trans (const db::DCplxTrans &trans); + /** + * @brief Resizes the widget + */ + void resize (unsigned int w, unsigned int h); + private: friend class lay::ViewObject; friend class lay::ViewService; @@ -1133,6 +1194,8 @@ private: bool m_in_mouse_move; bool m_mouse_inside; lay::Cursor::cursor_shape m_cursor, m_default_cursor; + unsigned int m_widget_width, m_widget_height; + bool m_image_updated; void ensure_entered (); void do_mouse_move (); From c8be882785df908f028658129f421baf6b8bfc83 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 7 May 2022 23:56:48 +0200 Subject: [PATCH 43/88] Removed some more Qt dependencies --- src/laybasic/laybasic/layLayoutCanvas.cc | 18 ++++++++---------- src/laybasic/laybasic/layLineStyles.cc | 15 +-------------- src/laybasic/laybasic/layLineStyles.h | 15 --------------- 3 files changed, 9 insertions(+), 39 deletions(-) diff --git a/src/laybasic/laybasic/layLayoutCanvas.cc b/src/laybasic/laybasic/layLayoutCanvas.cc index 1838a26e1..dfab18f02 100644 --- a/src/laybasic/laybasic/layLayoutCanvas.cc +++ b/src/laybasic/laybasic/layLayoutCanvas.cc @@ -357,29 +357,27 @@ LayoutCanvas::~LayoutCanvas () void LayoutCanvas::key_event (unsigned int key, unsigned int buttons) { -#if defined(HAVE_QT) // @@@ if (! (buttons & lay::ShiftButton)) { if (int (key) == lay::KeyDown) { - emit down_arrow_key_pressed (); + down_arrow_key_pressed (); } else if (int (key) == lay::KeyUp) { - emit up_arrow_key_pressed (); + up_arrow_key_pressed (); } else if (int (key) == lay::KeyLeft) { - emit left_arrow_key_pressed (); + left_arrow_key_pressed (); } else if (int (key) == lay::KeyRight) { - emit right_arrow_key_pressed (); + right_arrow_key_pressed (); } } else { if (int (key) == lay::KeyDown) { - emit down_arrow_key_pressed_with_shift (); + down_arrow_key_pressed_with_shift (); } else if (int (key) == lay::KeyUp) { - emit up_arrow_key_pressed_with_shift (); + up_arrow_key_pressed_with_shift (); } else if (int (key) == lay::KeyLeft) { - emit left_arrow_key_pressed_with_shift (); + left_arrow_key_pressed_with_shift (); } else if (int (key) == lay::KeyRight) { - emit right_arrow_key_pressed_with_shift (); + right_arrow_key_pressed_with_shift (); } } -#endif } void diff --git a/src/laybasic/laybasic/layLineStyles.cc b/src/laybasic/laybasic/layLineStyles.cc index c7c0e9adb..e086f19ae 100644 --- a/src/laybasic/laybasic/layLineStyles.cc +++ b/src/laybasic/laybasic/layLineStyles.cc @@ -163,7 +163,7 @@ LineStyleInfo::is_bit_set (unsigned int n) const return (pattern () [(n / 32) % pattern_stride ()] & (1 << (n % 32))) != 0; } -#if defined(HAVE_QT) // @@@ +#if defined(HAVE_QT) QBitmap LineStyleInfo::get_bitmap (int width, int height) const { @@ -355,9 +355,6 @@ struct ReplaceLineStyleOp }; LineStyles::LineStyles () : -#if defined(HAVE_QT) - QObject (), -#endif db::Object (0) { for (unsigned int d = 0; d < sizeof (style_strings) / sizeof (style_strings [0]); d += 2) { @@ -368,9 +365,6 @@ LineStyles::LineStyles () : } LineStyles::LineStyles (const LineStyles &p) : -#if defined(HAVE_QT) - QObject (), -#endif db::Object (0) { m_styles = p.m_styles; @@ -424,13 +418,6 @@ LineStyles::replace_style (unsigned int i, const LineStyleInfo &p) m_styles [i] = p; chg = true; } - - // if something has changed emit the signal - if (chg) { -#if defined(HAVE_QT) // @@@ - emit changed (); -#endif - } } unsigned int diff --git a/src/laybasic/laybasic/layLineStyles.h b/src/laybasic/laybasic/layLineStyles.h index 2ffa00824..5cd760f3a 100644 --- a/src/laybasic/laybasic/layLineStyles.h +++ b/src/laybasic/laybasic/layLineStyles.h @@ -220,15 +220,8 @@ private: * cannot be changed. */ class LAYBASIC_PUBLIC LineStyles : -#if defined(HAVE_QT) - public QObject, -#endif public db::Object { -#if defined(HAVE_QT) -Q_OBJECT -#endif - public: typedef std::vector pattern_vector; typedef pattern_vector::const_iterator iterator; @@ -361,14 +354,6 @@ public: */ static const LineStyles &default_style (); -#if defined(HAVE_QT) -signals: - /** - * @brief This signal is emitted if a style is changed - */ - void changed (); -#endif - private: std::vector m_styles; }; From aea861f9b4d31d13e21faf9256a4322a4293de17 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 8 May 2022 18:33:40 +0200 Subject: [PATCH 44/88] WIP: preparing synthetic events for LayoutView in non-Qt case --- src/edt/edt/edtMainService.cc | 2 +- src/edt/edt/edtServiceImpl.cc | 1 + src/laybasic/laybasic/gsiDeclLayLayoutView.cc | 110 +++ src/laybasic/laybasic/layCellTreeModel.cc | 1 + .../laybasic/layLayoutViewFunctions.cc | 282 +++---- src/laybasic/laybasic/layPlugin.cc | 12 +- src/laybasic/laybasic/layPlugin.h | 20 +- src/laybasic/laybasic/layViewObject.cc | 759 +++++++++--------- src/laybasic/laybasic/layViewObject.h | 185 ++--- src/laybasic/laybasic/laybasic.pro | 2 + src/laybasic/unit_tests/layLayoutViewTests.cc | 8 +- .../layNetlistBrowserTreeModelTests.cc | 3 - src/laybasic/unit_tests/unit_tests.pro | 10 +- 13 files changed, 724 insertions(+), 671 deletions(-) diff --git a/src/edt/edt/edtMainService.cc b/src/edt/edt/edtMainService.cc index efd898f53..beeefcdab 100644 --- a/src/edt/edt/edtMainService.cc +++ b/src/edt/edt/edtMainService.cc @@ -2113,7 +2113,7 @@ MainService::cm_tap () int icon_size = menu->style ()->pixelMetric (QStyle::PM_ButtonIconSize); - db::Point mp_local = view ()->view_object_widget ()->mouse_position (); + db::DPoint mp_local = view ()->view_object_widget ()->mouse_position (); QPoint mp = view ()->view_object_widget ()->mapToGlobal (QPoint (mp_local.x (), mp_local.y ())); for (std::vector::const_iterator l = tapped_layers.begin (); l != tapped_layers.end (); ++l) { diff --git a/src/edt/edt/edtServiceImpl.cc b/src/edt/edt/edtServiceImpl.cc index b22360339..0e118257b 100644 --- a/src/edt/edt/edtServiceImpl.cc +++ b/src/edt/edt/edtServiceImpl.cc @@ -37,6 +37,7 @@ #include "layLayerProperties.h" #include "layLayoutView.h" #include "layTipDialog.h" +#include "layDragDropData.h" #include #include diff --git a/src/laybasic/laybasic/gsiDeclLayLayoutView.cc b/src/laybasic/laybasic/gsiDeclLayLayoutView.cc index 5e204847a..612b28827 100644 --- a/src/laybasic/laybasic/gsiDeclLayLayoutView.cc +++ b/src/laybasic/laybasic/gsiDeclLayLayoutView.cc @@ -357,6 +357,54 @@ get_config_names (lay::LayoutView *view) return names; } +static void +send_key_press_event (lay::LayoutView *view, unsigned int key, unsigned int buttons) +{ + view->view_object_widget ()->send_key_press_event (key, buttons); +} + +static void +send_mouse_move_event (lay::LayoutView *view, const db::DPoint &pt, unsigned int buttons) +{ + view->view_object_widget ()->send_mouse_move_event (pt, buttons); +} + +static void +send_leave_event (lay::LayoutView *view) +{ + view->view_object_widget ()->send_leave_event (); +} + +static void +send_enter_event (lay::LayoutView *view) +{ + view->view_object_widget ()->send_enter_event (); +} + +static void +send_mouse_press_event (lay::LayoutView *view, const db::DPoint &pt, unsigned int buttons) +{ + view->view_object_widget ()->send_mouse_press_event (pt, buttons); +} + +static void +send_mouse_double_clicked_event (lay::LayoutView *view, const db::DPoint &pt, unsigned int buttons) +{ + view->view_object_widget ()->send_mouse_double_clicked_event (pt, buttons); +} + +static void +send_mouse_release_event (lay::LayoutView *view, const db::DPoint &pt, unsigned int buttons) +{ + view->view_object_widget ()->send_mouse_release_event (pt, buttons); +} + +static void +send_wheel_event (lay::LayoutView *view, int delta, bool horizontal, const db::DPoint &pt, unsigned int buttons) +{ + view->view_object_widget ()->send_wheel_event (delta, horizontal, pt, buttons); +} + namespace { /** @@ -2007,6 +2055,68 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "invalid results." "\n" "This method was introduced in version 0.16." + ) + + gsi::method_ext ("send_key_press_event", &send_key_press_event, gsi::arg ("key"), gsi::arg ("buttons"), + "@brief Sends a key press event\n" + "\n" + "This method is intended to emulate the key press events sent by Qt normally in environments where Qt is not present. " + "The arguments follow the conventions used within \\Plugin#key_event for example.\n" + "\n" + "This method was introduced in version 0.28." + ) + + gsi::method_ext ("send_mouse_move_event", &send_mouse_move_event, gsi::arg ("pt"), gsi::arg ("buttons"), + "@brief Sends a mouse move event\n" + "\n" + "This method is intended to emulate the mouse move events sent by Qt normally in environments where Qt is not present. " + "The arguments follow the conventions used within \\Plugin#mouse_move_event for example.\n" + "\n" + "This method was introduced in version 0.28." + ) + + gsi::method_ext ("send_mouse_press_event", &send_mouse_press_event, gsi::arg ("pt"), gsi::arg ("buttons"), + "@brief Sends a mouse button press event\n" + "\n" + "This method is intended to emulate the mouse button press events sent by Qt normally in environments where Qt is not present. " + "The arguments follow the conventions used within \\Plugin#mouse_move_event for example.\n" + "\n" + "This method was introduced in version 0.28." + ) + + gsi::method_ext ("send_mouse_double_clicked_event", &send_mouse_double_clicked_event, gsi::arg ("pt"), gsi::arg ("buttons"), + "@brief Sends a mouse button double-click event\n" + "\n" + "This method is intended to emulate the mouse button double-click events sent by Qt normally in environments where Qt is not present. " + "The arguments follow the conventions used within \\Plugin#mouse_move_event for example.\n" + "\n" + "This method was introduced in version 0.28." + ) + + gsi::method_ext ("send_mouse_release_event", &send_mouse_release_event, gsi::arg ("pt"), gsi::arg ("buttons"), + "@brief Sends a mouse button release event\n" + "\n" + "This method is intended to emulate the mouse button release events sent by Qt normally in environments where Qt is not present. " + "The arguments follow the conventions used within \\Plugin#mouse_move_event for example.\n" + "\n" + "This method was introduced in version 0.28." + ) + + gsi::method_ext ("send_leave_event", &send_leave_event, + "@brief Sends a mouse window leave event\n" + "\n" + "This method is intended to emulate the mouse mouse window leave events sent by Qt normally in environments where Qt is not present. " + "\n" + "This method was introduced in version 0.28." + ) + + gsi::method_ext ("send_enter_event", &send_enter_event, + "@brief Sends a mouse window leave event\n" + "\n" + "This method is intended to emulate the mouse mouse window leave events sent by Qt normally in environments where Qt is not present. " + "\n" + "This method was introduced in version 0.28." + ) + + gsi::method_ext ("send_wheel_event", &send_wheel_event, gsi::arg ("delta"), gsi::arg ("horizontal"), gsi::arg ("pt"), gsi::arg ("buttons"), + "@brief Sends a mouse wheel event\n" + "\n" + "This method is intended to emulate the mouse wheel events sent by Qt normally in environments where Qt is not present. " + "The arguments follow the conventions used within \\Plugin#wheel_event for example.\n" + "\n" + "This method was introduced in version 0.28." ), "@brief The view object presenting one or more layout objects\n" "\n" diff --git a/src/laybasic/laybasic/layCellTreeModel.cc b/src/laybasic/laybasic/layCellTreeModel.cc index d8e4ca573..3f501eff9 100644 --- a/src/laybasic/laybasic/layCellTreeModel.cc +++ b/src/laybasic/laybasic/layCellTreeModel.cc @@ -23,6 +23,7 @@ #include "layCellTreeModel.h" #include "layLayoutView.h" +#include "layDragDropData.h" #include "tlGlobPattern.h" #include "dbPCellHeader.h" #include "dbPCellVariant.h" diff --git a/src/laybasic/laybasic/layLayoutViewFunctions.cc b/src/laybasic/laybasic/layLayoutViewFunctions.cc index 5ae02957d..36bd854f3 100644 --- a/src/laybasic/laybasic/layLayoutViewFunctions.cc +++ b/src/laybasic/laybasic/layLayoutViewFunctions.cc @@ -433,7 +433,7 @@ LayoutViewFunctions::cm_cell_user_properties () lay::UserPropertiesForm props_form (view ()); if (props_form.show (view (), cv_index, prop_id)) { - view ()->transaction (tl::to_string (QObject::tr ("Edit cell's user properties"))); + view ()->transaction (tl::to_string (tr ("Edit cell's user properties"))); cell.prop_id (prop_id); view ()->commit (); @@ -456,7 +456,7 @@ LayoutViewFunctions::cm_cell_replace () if (cv_index >= 0 && paths.size () > 0) { if (paths.size () > 1) { - throw tl::Exception (tl::to_string (QObject::tr ("Replace cell cannot be used when multiple cells are selected"))); + throw tl::Exception (tl::to_string (tr ("Replace cell cannot be used when multiple cells are selected"))); } db::Layout &layout = view ()->cellview (cv_index)->layout (); @@ -487,7 +487,7 @@ LayoutViewFunctions::cm_cell_replace () view ()->clear_selection (); - view ()->transaction (tl::to_string (QObject::tr ("Replace cells"))); + view ()->transaction (tl::to_string (tr ("Replace cells"))); // replace instances of the target cell with the new cell @@ -555,7 +555,7 @@ LayoutViewFunctions::cm_lay_convert_to_static () db::Layout &layout = view ()->cellview (cv_index)->layout (); - view ()->transaction (tl::to_string (QObject::tr ("Convert all cells to static"))); + view ()->transaction (tl::to_string (tr ("Convert all cells to static"))); std::vector cells; for (db::Layout::const_iterator c = layout.begin (); c != layout.end (); ++c) { @@ -611,7 +611,7 @@ LayoutViewFunctions::cm_cell_convert_to_static () view ()->clear_selection (); - view ()->transaction (tl::to_string (QObject::tr ("Convert cells to static"))); + view ()->transaction (tl::to_string (tr ("Convert cells to static"))); std::map cell_map; @@ -697,7 +697,7 @@ LayoutViewFunctions::cm_cell_delete () } } - view ()->transaction (tl::to_string (QObject::tr ("Delete cells"))); + view ()->transaction (tl::to_string (tr ("Delete cells"))); if (mode == 0 || mode == 2) { layout.delete_cells (cells_to_delete); @@ -730,7 +730,7 @@ void LayoutViewFunctions::cm_layer_cut () { if (view ()->control_panel ()) { - db::Transaction trans (manager (), tl::to_string (QObject::tr ("Cut Layers"))); + db::Transaction trans (manager (), tl::to_string (tr ("Cut Layers"))); view ()->control_panel ()->cut (); } } @@ -739,7 +739,7 @@ void LayoutViewFunctions::cm_layer_paste () { if (view ()->control_panel ()) { - db::Transaction trans (manager (), tl::to_string (QObject::tr ("Paste Layers"))); + db::Transaction trans (manager (), tl::to_string (tr ("Paste Layers"))); view ()->control_panel ()->paste (); } } @@ -758,7 +758,7 @@ void LayoutViewFunctions::cm_cell_paste () { if (view ()->hierarchy_panel ()) { - db::Transaction trans (manager (), tl::to_string (QObject::tr ("Paste Cells"))); + db::Transaction trans (manager (), tl::to_string (tr ("Paste Cells"))); view ()->hierarchy_panel ()->paste (); } } @@ -789,12 +789,12 @@ LayoutViewFunctions::cm_cell_flatten () std::vector paths; view ()->hierarchy_panel ()->selected_cells (cv_index, paths); if (paths.empty ()) { - throw tl::Exception (tl::to_string (QObject::tr ("No cells selected for flattening"))); + throw tl::Exception (tl::to_string (tr ("No cells selected for flattening"))); } for (std::vector::const_iterator p = paths.begin (); p != paths.end (); ++p) { if (p->size () > 0 && cv->layout ().cell (p->back ()).is_proxy ()) { - throw tl::Exception (tl::to_string (QObject::tr ("Cannot use this function on a PCell or library cell"))); + throw tl::Exception (tl::to_string (tr ("Cannot use this function on a PCell or library cell"))); } } @@ -809,7 +809,7 @@ LayoutViewFunctions::cm_cell_flatten () if (manager () && manager ()->is_enabled ()) { lay::TipDialog td (QApplication::activeWindow (), - tl::to_string (QObject::tr ("Undo buffering for the following operation can be memory and time consuming.\nChoose \"Yes\" to use undo buffering or \"No\" for no undo buffering. Warning: in the latter case, the undo history will be lost.\n\nChoose undo buffering?")), + tl::to_string (tr ("Undo buffering for the following operation can be memory and time consuming.\nChoose \"Yes\" to use undo buffering or \"No\" for no undo buffering. Warning: in the latter case, the undo history will be lost.\n\nChoose undo buffering?")), "flatten-undo-buffering", lay::TipDialog::yesnocancel_buttons); @@ -832,7 +832,7 @@ LayoutViewFunctions::cm_cell_flatten () if (! supports_undo) { manager ()->clear (); } else { - manager ()->transaction (tl::to_string (QObject::tr ("Flatten cell"))); + manager ()->transaction (tl::to_string (tr ("Flatten cell"))); } } @@ -890,7 +890,7 @@ LayoutViewFunctions::cm_cell_rename () std::string name (layout.cell_name (path.back ())); if (name_dialog.exec_dialog (layout, name)) { - view ()->transaction (tl::to_string (QObject::tr ("Rename cell"))); + view ()->transaction (tl::to_string (tr ("Rename cell"))); layout.rename_cell (path.back (), name.c_str ()); view ()->commit (); @@ -921,7 +921,7 @@ LayoutViewFunctions::cm_cell_hide () std::vector paths; view ()->hierarchy_panel ()->selected_cells (view ()->active_cellview_index (), paths); - view ()->transaction (tl::to_string (QObject::tr ("Hide cell"))); + view ()->transaction (tl::to_string (tr ("Hide cell"))); for (std::vector::const_iterator p = paths.begin (); p != paths.end (); ++p) { if (! p->empty ()) { @@ -942,7 +942,7 @@ LayoutViewFunctions::cm_cell_show () std::vector paths; view ()->hierarchy_panel ()->selected_cells (view ()->active_cellview_index (), paths); - view ()->transaction (tl::to_string (QObject::tr ("Show cell"))); + view ()->transaction (tl::to_string (tr ("Show cell"))); for (std::vector::const_iterator p = paths.begin (); p != paths.end (); ++p) { if (! p->empty ()) { @@ -959,7 +959,7 @@ void LayoutViewFunctions::cm_cell_show_all () { if (view ()->hierarchy_panel ()) { - view ()->transaction (tl::to_string (QObject::tr ("Show all cells"))); + view ()->transaction (tl::to_string (tr ("Show all cells"))); view ()->show_all_cells (); view ()->commit (); } @@ -1270,7 +1270,7 @@ LayoutViewFunctions::cm_reload () if (view ()->cellviews () > 1) { - lay::SelectCellViewForm form (0, view (), tl::to_string (QObject::tr ("Select Layouts To Reload"))); + lay::SelectCellViewForm form (0, view (), tl::to_string (tr ("Select Layouts To Reload"))); form.select_all (); if (form.exec () == QDialog::Accepted) { @@ -1308,10 +1308,10 @@ LayoutViewFunctions::cm_reload () if (dirty_layouts != 0) { QMessageBox mbox (view ()); - mbox.setText (tl::to_qstring (tl::to_string (QObject::tr ("The following layouts need saving:\n\n")) + dirty_files + "\n\nPress 'Reload Without Saving' to reload anyhow and discard changes.")); - mbox.setWindowTitle (QObject::tr ("Save Needed")); + mbox.setText (tl::to_qstring (tl::to_string (tr ("The following layouts need saving:\n\n")) + dirty_files + "\n\nPress 'Reload Without Saving' to reload anyhow and discard changes.")); + mbox.setWindowTitle (tr ("Save Needed")); mbox.setIcon (QMessageBox::Warning); - QAbstractButton *yes_button = mbox.addButton (QObject::tr ("Reload Without Saving"), QMessageBox::YesRole); + QAbstractButton *yes_button = mbox.addButton (tr ("Reload Without Saving"), QMessageBox::YesRole); mbox.addButton (QMessageBox::Cancel); mbox.exec (); @@ -1352,7 +1352,7 @@ LayoutViewFunctions::transform_layout (const db::DCplxTrans &tr_mic) db::Layout &layout = view ()->cellview (cv_index)->layout (); - db::ICplxTrans tr (db::DCplxTrans (1.0 / layout.dbu ()) * tr_mic * db::DCplxTrans (layout.dbu ())); + db::ICplxTrans trans (db::DCplxTrans (1.0 / layout.dbu ()) * tr_mic * db::DCplxTrans (layout.dbu ())); bool has_proxy = false; for (db::Layout::const_iterator c = layout.begin (); ! has_proxy && c != layout.end (); ++c) { @@ -1361,19 +1361,19 @@ LayoutViewFunctions::transform_layout (const db::DCplxTrans &tr_mic) if (has_proxy && QMessageBox::question (view (), - QObject::tr ("Transforming PCells Or Library Cells"), - QObject::tr ("The layout contains PCells or library cells or both.\n" - "Any changes to such cells may be lost when their layout is refreshed later.\n" - "Consider using 'Convert all cells to static' before transforming the layout.\n" - "\n" - "Would you like to continue?\n" - "Choose 'Yes' to continue anyway. Choose 'No' to cancel."), + tr ("Transforming PCells Or Library Cells"), + tr ("The layout contains PCells or library cells or both.\n" + "Any changes to such cells may be lost when their layout is refreshed later.\n" + "Consider using 'Convert all cells to static' before transforming the layout.\n" + "\n" + "Would you like to continue?\n" + "Choose 'Yes' to continue anyway. Choose 'No' to cancel."), QMessageBox::Yes | QMessageBox::No) != QMessageBox::Yes) { return; } - view ()->transaction (tl::to_string (QObject::tr ("Transform layout"))); - layout.transform (tr); + view ()->transaction (tl::to_string (tr ("Transform layout"))); + layout.transform (trans); view ()->commit (); } @@ -1409,8 +1409,8 @@ LayoutViewFunctions::cm_lay_free_rot () { bool ok = false; QString s = QInputDialog::getText (QApplication::activeWindow (), - QObject::tr ("Free rotation"), - QObject::tr ("Rotation angle in degree (counterclockwise)"), + tr ("Free rotation"), + tr ("Rotation angle in degree (counterclockwise)"), QLineEdit::Normal, QString::fromUtf8 ("0.0"), &ok); @@ -1429,8 +1429,8 @@ LayoutViewFunctions::cm_lay_scale () { bool ok = false; QString s = QInputDialog::getText (QApplication::activeWindow (), - QObject::tr ("Scaling"), - QObject::tr ("Scaling factor"), + tr ("Scaling"), + tr ("Scaling factor"), QLineEdit::Normal, QString::fromUtf8 ("1.0"), &ok); @@ -1502,8 +1502,8 @@ LayoutViewFunctions::cm_sel_free_rot () { bool ok = false; QString s = QInputDialog::getText (QApplication::activeWindow (), - QObject::tr ("Free rotation"), - QObject::tr ("Rotation angle in degree (counterclockwise)"), + tr ("Free rotation"), + tr ("Rotation angle in degree (counterclockwise)"), QLineEdit::Normal, QString::fromUtf8 ("0.0"), &ok); @@ -1527,8 +1527,8 @@ LayoutViewFunctions::cm_sel_scale () { bool ok = false; QString s = QInputDialog::getText (QApplication::activeWindow (), - QObject::tr ("Scaling"), - QObject::tr ("Scaling factor"), + tr ("Scaling"), + tr ("Scaling factor"), QLineEdit::Normal, QString::fromUtf8 ("1.0"), &ok); @@ -1560,7 +1560,7 @@ LayoutViewFunctions::cm_sel_move_to () { db::DBox sel_bbox (view ()->lay::Editables::selection_bbox ()); if (sel_bbox.empty ()) { - throw tl::Exception (tl::to_string (QObject::tr ("Nothing selected to move"))); + throw tl::Exception (tl::to_string (tr ("Nothing selected to move"))); } double x = sel_bbox.left () + (sel_bbox.width () * (1 + m_move_to_origin_mode_x) * 0.5); @@ -1623,7 +1623,7 @@ LayoutViewFunctions::cm_copy_layer () if (manager () && manager ()->is_enabled ()) { lay::TipDialog td (QApplication::activeWindow (), - tl::to_string (QObject::tr ("Undo buffering for the following operation can be memory and time consuming.\nChoose \"Yes\" to use undo buffering or \"No\" for no undo buffering. Warning: in the latter case, the undo history will be lost.\n\nChoose undo buffering?")), + tl::to_string (tr ("Undo buffering for the following operation can be memory and time consuming.\nChoose \"Yes\" to use undo buffering or \"No\" for no undo buffering. Warning: in the latter case, the undo history will be lost.\n\nChoose undo buffering?")), "copy-layer-undo-buffering", lay::TipDialog::yesnocancel_buttons); @@ -1645,7 +1645,7 @@ LayoutViewFunctions::cm_copy_layer () if (! supports_undo) { manager ()->clear (); } else { - manager ()->transaction (tl::to_string (QObject::tr ("Duplicate layer"))); + manager ()->transaction (tl::to_string (tr ("Duplicate layer"))); } } @@ -1653,7 +1653,7 @@ LayoutViewFunctions::cm_copy_layer () bool same_layout = (&view ()->cellview (m_copy_cvr)->layout () == &view ()->cellview (m_copy_cva)->layout ()); if (same_layout && m_copy_layera == m_copy_layerr) { - throw tl::Exception (tl::to_string (QObject::tr ("Source and target layer must not be identical for duplicate operation"))); + throw tl::Exception (tl::to_string (tr ("Source and target layer must not be identical for duplicate operation"))); } if (m_duplicate_hier_mode == 0) { @@ -1780,11 +1780,11 @@ LayoutViewFunctions::cm_new_layer () for (unsigned int l = 0; l < cv->layout ().layers (); ++l) { if (cv->layout ().is_valid_layer (l) && cv->layout ().get_properties (l).log_equal (m_new_layer_props)) { - throw tl::Exception (tl::to_string (QObject::tr ("A layer with that signature already exists: ")) + m_new_layer_props.to_string ()); + throw tl::Exception (tl::to_string (tr ("A layer with that signature already exists: ")) + m_new_layer_props.to_string ()); } } - view ()->transaction (tl::to_string (QObject::tr ("New layer"))); + view ()->transaction (tl::to_string (tr ("New layer"))); unsigned int l = cv->layout ().insert_layer (m_new_layer_props); std::vector nl; @@ -1810,7 +1810,7 @@ LayoutViewFunctions::cm_align_cell_origin () return; } if (cell->is_proxy ()) { - throw tl::Exception (tl::to_string (QObject::tr ("Cannot use this function on a PCell or library cell"))); + throw tl::Exception (tl::to_string (tr ("Cannot use this function on a PCell or library cell"))); } lay::AlignCellOptionsDialog dialog (view ()); @@ -1818,7 +1818,7 @@ LayoutViewFunctions::cm_align_cell_origin () view ()->clear_selection (); - view ()->transaction (tl::to_string (QObject::tr ("Align cell origin"))); + view ()->transaction (tl::to_string (tr ("Align cell origin"))); db::Box bbox; @@ -1900,12 +1900,12 @@ LayoutViewFunctions::cm_edit_layer () { lay::LayerPropertiesConstIterator sel = view ()->current_layer (); if (sel.is_null ()) { - throw tl::Exception (tl::to_string (QObject::tr ("No layer selected for editing it's properties"))); + throw tl::Exception (tl::to_string (tr ("No layer selected for editing it's properties"))); } int index = sel->cellview_index (); if (sel->has_children () || index < 0 || int (view ()->cellviews ()) <= index || sel->layer_index () < 0) { - throw tl::Exception (tl::to_string (QObject::tr ("No valid layer selected for editing it's properties"))); + throw tl::Exception (tl::to_string (tr ("No valid layer selected for editing it's properties"))); } const lay::CellView &cv = view ()->cellview (index); @@ -1917,11 +1917,11 @@ LayoutViewFunctions::cm_edit_layer () for (unsigned int l = 0; l < cv->layout ().layers (); ++l) { if (cv->layout ().is_valid_layer (l) && int (l) != sel->layer_index () && cv->layout ().get_properties (l).log_equal (layer_props)) { - throw tl::Exception (tl::to_string (QObject::tr ("A layer with that signature already exists: ")) + layer_props.to_string ()); + throw tl::Exception (tl::to_string (tr ("A layer with that signature already exists: ")) + layer_props.to_string ()); } } - view ()->transaction (tl::to_string (QObject::tr ("Edit layer"))); + view ()->transaction (tl::to_string (tr ("Edit layer"))); cv->layout ().set_properties (sel->layer_index (), layer_props); @@ -1963,13 +1963,13 @@ LayoutViewFunctions::cm_delete_layer () } if (valid_sel.empty ()) { - throw tl::Exception (tl::to_string (QObject::tr ("No or no valid layer selected for deleting them"))); + throw tl::Exception (tl::to_string (tr ("No or no valid layer selected for deleting them"))); } view ()->cancel_edits (); view ()->clear_selection (); - view ()->transaction (tl::to_string (QObject::tr ("Delete layers"))); + view ()->transaction (tl::to_string (tr ("Delete layers"))); // Hint: delete_layer must come before the layers are actually deleted in because // for undo this must be the last thing to do (otherwise the layout is not propertly set up) @@ -2002,7 +2002,7 @@ LayoutViewFunctions::cm_clear_layer () { std::vector sel = view ()->selected_layers (); if (sel.empty ()) { - throw tl::Exception (tl::to_string (QObject::tr ("No layer selected for clearing"))); + throw tl::Exception (tl::to_string (tr ("No layer selected for clearing"))); } lay::ClearLayerModeDialog mode_dialog (view ()); @@ -2011,7 +2011,7 @@ LayoutViewFunctions::cm_clear_layer () view ()->cancel_edits (); view ()->clear_selection (); - view ()->transaction (tl::to_string (QObject::tr ("Clear layer"))); + view ()->transaction (tl::to_string (tr ("Clear layer"))); for (std::vector::const_iterator si = sel.begin (); si != sel.end (); ++si) { @@ -2058,153 +2058,153 @@ public: // secret menu entries at = "@secrets.end"; - menu_entries.push_back (lay::menu_item ("cm_paste_interactive", "paste_interactive:edit", at, tl::to_string (QObject::tr ("Paste Interactive")))); - menu_entries.push_back (lay::menu_item ("cm_duplicate_interactive", "duplicate_interactive:edit", at, tl::to_string (QObject::tr ("Duplicate Interactive")))); - menu_entries.push_back (lay::menu_item ("cm_sel_move_interactive", "sel_move_interactive:edit", at, tl::to_string (QObject::tr ("Move Interactive")))); - menu_entries.push_back (lay::menu_item ("cm_select_next_item", "select_next_item:edit", at, tl::to_string (QObject::tr ("Select Next Item(Space)")))); - menu_entries.push_back (lay::menu_item ("cm_select_next_item_add", "select_next_item_add:edit", at, tl::to_string (QObject::tr ("Select Next Item too(Shift+Space)")))); + menu_entries.push_back (lay::menu_item ("cm_paste_interactive", "paste_interactive:edit", at, tl::to_string (tr ("Paste Interactive")))); + menu_entries.push_back (lay::menu_item ("cm_duplicate_interactive", "duplicate_interactive:edit", at, tl::to_string (tr ("Duplicate Interactive")))); + menu_entries.push_back (lay::menu_item ("cm_sel_move_interactive", "sel_move_interactive:edit", at, tl::to_string (tr ("Move Interactive")))); + menu_entries.push_back (lay::menu_item ("cm_select_next_item", "select_next_item:edit", at, tl::to_string (tr ("Select Next Item(Space)")))); + menu_entries.push_back (lay::menu_item ("cm_select_next_item_add", "select_next_item_add:edit", at, tl::to_string (tr ("Select Next Item too(Shift+Space)")))); at = "edit_menu.edit_options_group"; - menu_entries.push_back (lay::menu_item ("cm_undo", "undo:edit", at, tl::to_string (QObject::tr ("Undo(Ctrl+Z)")))); - menu_entries.push_back (lay::menu_item ("cm_redo", "redo:edit", at, tl::to_string (QObject::tr ("Redo(Ctrl+Y)")))); + menu_entries.push_back (lay::menu_item ("cm_undo", "undo:edit", at, tl::to_string (tr ("Undo(Ctrl+Z)")))); + menu_entries.push_back (lay::menu_item ("cm_redo", "redo:edit", at, tl::to_string (tr ("Redo(Ctrl+Y)")))); menu_entries.push_back (lay::separator ("basic_group", at)); - menu_entries.push_back (lay::submenu ("layout_menu:edit:edit_mode", at, tl::to_string (QObject::tr ("Layout")))); + menu_entries.push_back (lay::submenu ("layout_menu:edit:edit_mode", at, tl::to_string (tr ("Layout")))); { std::string at = "edit_menu.layout_menu.end"; - menu_entries.push_back (lay::menu_item ("cm_lay_flip_x", "lay_flip_x:edit_mode", at, tl::to_string (QObject::tr ("Flip Horizontally")))); - menu_entries.push_back (lay::menu_item ("cm_lay_flip_y", "lay_flip_y:edit_mode", at, tl::to_string (QObject::tr ("Flip Vertically")))); - menu_entries.push_back (lay::menu_item ("cm_lay_rot_cw", "lay_rot_cw:edit_mode", at, tl::to_string (QObject::tr ("Rotate Clockwise")))); - menu_entries.push_back (lay::menu_item ("cm_lay_rot_ccw", "lay_rot_ccw:edit_mode", at, tl::to_string (QObject::tr ("Rotate Counterclockwise")))); - menu_entries.push_back (lay::menu_item ("cm_lay_free_rot", "lay_free_rot:edit_mode", at, tl::to_string (QObject::tr ("Rotation By Angle")))); - menu_entries.push_back (lay::menu_item ("cm_lay_scale", "lay_scale:edit_mode", at, tl::to_string (QObject::tr ("Scale")))); - menu_entries.push_back (lay::menu_item ("cm_lay_move", "lay_move:edit_mode", at, tl::to_string (QObject::tr ("Move By")))); + menu_entries.push_back (lay::menu_item ("cm_lay_flip_x", "lay_flip_x:edit_mode", at, tl::to_string (tr ("Flip Horizontally")))); + menu_entries.push_back (lay::menu_item ("cm_lay_flip_y", "lay_flip_y:edit_mode", at, tl::to_string (tr ("Flip Vertically")))); + menu_entries.push_back (lay::menu_item ("cm_lay_rot_cw", "lay_rot_cw:edit_mode", at, tl::to_string (tr ("Rotate Clockwise")))); + menu_entries.push_back (lay::menu_item ("cm_lay_rot_ccw", "lay_rot_ccw:edit_mode", at, tl::to_string (tr ("Rotate Counterclockwise")))); + menu_entries.push_back (lay::menu_item ("cm_lay_free_rot", "lay_free_rot:edit_mode", at, tl::to_string (tr ("Rotation By Angle")))); + menu_entries.push_back (lay::menu_item ("cm_lay_scale", "lay_scale:edit_mode", at, tl::to_string (tr ("Scale")))); + menu_entries.push_back (lay::menu_item ("cm_lay_move", "lay_move:edit_mode", at, tl::to_string (tr ("Move By")))); menu_entries.push_back (lay::separator ("cellop_group", at)); - menu_entries.push_back (lay::menu_item ("cm_lay_convert_to_static", "lay_convert_to_static:edit_mode", at, tl::to_string (QObject::tr ("Convert All Cells To Static")))); + menu_entries.push_back (lay::menu_item ("cm_lay_convert_to_static", "lay_convert_to_static:edit_mode", at, tl::to_string (tr ("Convert All Cells To Static")))); } - menu_entries.push_back (lay::submenu ("cell_menu:edit:edit_mode", at, tl::to_string (QObject::tr ("Cell")))); + menu_entries.push_back (lay::submenu ("cell_menu:edit:edit_mode", at, tl::to_string (tr ("Cell")))); { std::string at = "edit_menu.cell_menu.end"; - menu_entries.push_back (lay::menu_item ("cm_new_cell", "new_cell:edit:edit_mode", at, tl::to_string (QObject::tr ("New Cell")))); - menu_entries.push_back (lay::menu_item ("cm_cell_delete", "delete_cell:edit:edit_mode", at, tl::to_string (QObject::tr ("Delete Cell")))); - menu_entries.push_back (lay::menu_item ("cm_cell_rename", "rename_cell:edit:edit_mode", at, tl::to_string (QObject::tr ("Rename Cell")))); - menu_entries.push_back (lay::menu_item ("cm_cell_replace", "replace_cell:edit:edit_mode", at, tl::to_string (QObject::tr ("Replace Cell")))); - menu_entries.push_back (lay::menu_item ("cm_cell_flatten", "flatten_cell:edit:edit_mode", at, tl::to_string (QObject::tr ("Flatten Cell")))); + menu_entries.push_back (lay::menu_item ("cm_new_cell", "new_cell:edit:edit_mode", at, tl::to_string (tr ("New Cell")))); + menu_entries.push_back (lay::menu_item ("cm_cell_delete", "delete_cell:edit:edit_mode", at, tl::to_string (tr ("Delete Cell")))); + menu_entries.push_back (lay::menu_item ("cm_cell_rename", "rename_cell:edit:edit_mode", at, tl::to_string (tr ("Rename Cell")))); + menu_entries.push_back (lay::menu_item ("cm_cell_replace", "replace_cell:edit:edit_mode", at, tl::to_string (tr ("Replace Cell")))); + menu_entries.push_back (lay::menu_item ("cm_cell_flatten", "flatten_cell:edit:edit_mode", at, tl::to_string (tr ("Flatten Cell")))); menu_entries.push_back (lay::separator ("ops_group", at)); - menu_entries.push_back (lay::menu_item ("cm_adjust_origin", "adjust_cell_origin:edit:edit_mode", at, tl::to_string (QObject::tr ("Adjust Origin")))); - menu_entries.push_back (lay::menu_item ("cm_cell_convert_to_static", "convert_cell_to_static:edit_mode", at, tl::to_string (QObject::tr ("Convert Cell To Static")))); + menu_entries.push_back (lay::menu_item ("cm_adjust_origin", "adjust_cell_origin:edit:edit_mode", at, tl::to_string (tr ("Adjust Origin")))); + menu_entries.push_back (lay::menu_item ("cm_cell_convert_to_static", "convert_cell_to_static:edit_mode", at, tl::to_string (tr ("Convert Cell To Static")))); menu_entries.push_back (lay::separator ("props_group", at)); - menu_entries.push_back (lay::menu_item ("cm_cell_user_properties", "user_properties", at, tl::to_string (QObject::tr ("User Properties")))); + menu_entries.push_back (lay::menu_item ("cm_cell_user_properties", "user_properties", at, tl::to_string (tr ("User Properties")))); } - menu_entries.push_back (lay::submenu ("layer_menu:edit:edit_mode", at, tl::to_string (QObject::tr ("Layer")))); + menu_entries.push_back (lay::submenu ("layer_menu:edit:edit_mode", at, tl::to_string (tr ("Layer")))); { std::string at = "edit_menu.layer_menu.end"; - menu_entries.push_back (lay::menu_item ("cm_new_layer", "new_layer:edit:edit_mode", at, tl::to_string (QObject::tr ("New Layer")))); - menu_entries.push_back (lay::menu_item ("cm_clear_layer", "clear_layer:edit:edit_mode", at, tl::to_string (QObject::tr ("Clear Layer")))); - menu_entries.push_back (lay::menu_item ("cm_delete_layer", "delete_layer:edit:edit_mode", at, tl::to_string (QObject::tr ("Delete Layer")))); - menu_entries.push_back (lay::menu_item ("cm_copy_layer", "copy_layer:edit:edit_mode", at, tl::to_string (QObject::tr ("Copy Layer")))); - menu_entries.push_back (lay::menu_item ("cm_edit_layer", "edit_layer:edit:edit_mode", at, tl::to_string (QObject::tr ("Edit Layer Specification")))); + menu_entries.push_back (lay::menu_item ("cm_new_layer", "new_layer:edit:edit_mode", at, tl::to_string (tr ("New Layer")))); + menu_entries.push_back (lay::menu_item ("cm_clear_layer", "clear_layer:edit:edit_mode", at, tl::to_string (tr ("Clear Layer")))); + menu_entries.push_back (lay::menu_item ("cm_delete_layer", "delete_layer:edit:edit_mode", at, tl::to_string (tr ("Delete Layer")))); + menu_entries.push_back (lay::menu_item ("cm_copy_layer", "copy_layer:edit:edit_mode", at, tl::to_string (tr ("Copy Layer")))); + menu_entries.push_back (lay::menu_item ("cm_edit_layer", "edit_layer:edit:edit_mode", at, tl::to_string (tr ("Edit Layer Specification")))); } - menu_entries.push_back (lay::submenu ("selection_menu:edit", at, tl::to_string (QObject::tr ("Selection")))); + menu_entries.push_back (lay::submenu ("selection_menu:edit", at, tl::to_string (tr ("Selection")))); { std::string at = "edit_menu.selection_menu.end"; - menu_entries.push_back (lay::menu_item ("cm_sel_flip_x", "sel_flip_x", at, tl::to_string (QObject::tr ("Flip Horizontally")))); - menu_entries.push_back (lay::menu_item ("cm_sel_flip_y", "sel_flip_y", at, tl::to_string (QObject::tr ("Flip Vertically")))); - menu_entries.push_back (lay::menu_item ("cm_sel_rot_cw", "sel_rot_cw", at, tl::to_string (QObject::tr ("Rotate Clockwise")))); - menu_entries.push_back (lay::menu_item ("cm_sel_rot_ccw", "sel_rot_ccw", at, tl::to_string (QObject::tr ("Rotate Counterclockwise")))); - menu_entries.push_back (lay::menu_item ("cm_sel_free_rot", "sel_free_rot", at, tl::to_string (QObject::tr ("Rotation By Angle")))); - menu_entries.push_back (lay::menu_item ("cm_sel_scale", "sel_scale", at, tl::to_string (QObject::tr ("Scale")))); - menu_entries.push_back (lay::menu_item ("cm_sel_move", "sel_move", at, tl::to_string (QObject::tr ("Move By")))); - menu_entries.push_back (lay::menu_item ("cm_sel_move_to", "sel_move_to", at, tl::to_string (QObject::tr ("Move To")))); + menu_entries.push_back (lay::menu_item ("cm_sel_flip_x", "sel_flip_x", at, tl::to_string (tr ("Flip Horizontally")))); + menu_entries.push_back (lay::menu_item ("cm_sel_flip_y", "sel_flip_y", at, tl::to_string (tr ("Flip Vertically")))); + menu_entries.push_back (lay::menu_item ("cm_sel_rot_cw", "sel_rot_cw", at, tl::to_string (tr ("Rotate Clockwise")))); + menu_entries.push_back (lay::menu_item ("cm_sel_rot_ccw", "sel_rot_ccw", at, tl::to_string (tr ("Rotate Counterclockwise")))); + menu_entries.push_back (lay::menu_item ("cm_sel_free_rot", "sel_free_rot", at, tl::to_string (tr ("Rotation By Angle")))); + menu_entries.push_back (lay::menu_item ("cm_sel_scale", "sel_scale", at, tl::to_string (tr ("Scale")))); + menu_entries.push_back (lay::menu_item ("cm_sel_move", "sel_move", at, tl::to_string (tr ("Move By")))); + menu_entries.push_back (lay::menu_item ("cm_sel_move_to", "sel_move_to", at, tl::to_string (tr ("Move To")))); } menu_entries.push_back (lay::separator ("utils_group", at)); - menu_entries.push_back (lay::submenu ("utils_menu:edit:edit_mode", at, tl::to_string (QObject::tr ("Utilities")))); + menu_entries.push_back (lay::submenu ("utils_menu:edit:edit_mode", at, tl::to_string (tr ("Utilities")))); menu_entries.push_back (lay::separator ("misc_group", at)); - menu_entries.push_back (lay::menu_item ("cm_delete", "delete:edit", at, tl::to_string (QObject::tr ("Delete(Del)")))); - menu_entries.push_back (lay::menu_item ("cm_show_properties", "show_properties:edit", at, tl::to_string (QObject::tr ("Properties(Q)")))); + menu_entries.push_back (lay::menu_item ("cm_delete", "delete:edit", at, tl::to_string (tr ("Delete(Del)")))); + menu_entries.push_back (lay::menu_item ("cm_show_properties", "show_properties:edit", at, tl::to_string (tr ("Properties(Q)")))); menu_entries.push_back (lay::separator ("cpc_group", at)); - menu_entries.push_back (lay::menu_item ("cm_copy", "copy:edit", at, tl::to_string (QObject::tr ("Copy(Ctrl+C)")))); - menu_entries.push_back (lay::menu_item ("cm_cut", "cut:edit", at, tl::to_string (QObject::tr ("Cut(Ctrl+X)")))); - menu_entries.push_back (lay::menu_item ("cm_paste", "paste:edit", at, tl::to_string (QObject::tr ("Paste(Ctrl+V)")))); - menu_entries.push_back (lay::menu_item ("cm_duplicate", "duplicate:edit", at, tl::to_string (QObject::tr ("Duplicate(Ctrl+B)")))); + menu_entries.push_back (lay::menu_item ("cm_copy", "copy:edit", at, tl::to_string (tr ("Copy(Ctrl+C)")))); + menu_entries.push_back (lay::menu_item ("cm_cut", "cut:edit", at, tl::to_string (tr ("Cut(Ctrl+X)")))); + menu_entries.push_back (lay::menu_item ("cm_paste", "paste:edit", at, tl::to_string (tr ("Paste(Ctrl+V)")))); + menu_entries.push_back (lay::menu_item ("cm_duplicate", "duplicate:edit", at, tl::to_string (tr ("Duplicate(Ctrl+B)")))); menu_entries.push_back (lay::separator ("modes_group", at)); - menu_entries.push_back (lay::submenu ("mode_menu", at, tl::to_string (QObject::tr ("Mode")))); + menu_entries.push_back (lay::submenu ("mode_menu", at, tl::to_string (tr ("Mode")))); - menu_entries.push_back (lay::submenu ("select_menu", at, tl::to_string (QObject::tr ("Select")))); + menu_entries.push_back (lay::submenu ("select_menu", at, tl::to_string (tr ("Select")))); { std::string at = "edit_menu.select_menu.end"; - menu_entries.push_back (lay::menu_item ("cm_select_all", "select_all", at, tl::to_string (QObject::tr ("Select All")))); - menu_entries.push_back (lay::menu_item ("cm_unselect_all", "unselect_all", at, tl::to_string (QObject::tr ("Unselect All")))); + menu_entries.push_back (lay::menu_item ("cm_select_all", "select_all", at, tl::to_string (tr ("Select All")))); + menu_entries.push_back (lay::menu_item ("cm_unselect_all", "unselect_all", at, tl::to_string (tr ("Unselect All")))); menu_entries.push_back (lay::separator ("edit_select_basic_group", at)); - menu_entries.push_back (lay::menu_item ("lv:enable_all", "enable_all", at, tl::to_string (QObject::tr ("Enable All")))); - menu_entries.push_back (lay::menu_item ("lv:disable_all", "disable_all", at, tl::to_string (QObject::tr ("Disable All")))); + menu_entries.push_back (lay::menu_item ("lv:enable_all", "enable_all", at, tl::to_string (tr ("Enable All")))); + menu_entries.push_back (lay::menu_item ("lv:disable_all", "disable_all", at, tl::to_string (tr ("Disable All")))); menu_entries.push_back (lay::separator ("edit_select_individual_group", at)); }; menu_entries.push_back (lay::separator ("cancel_group", at)); - menu_entries.push_back (lay::menu_item ("cm_cancel", "cancel", at, tl::to_string (QObject::tr ("Cancel(Esc)")))); + menu_entries.push_back (lay::menu_item ("cm_cancel", "cancel", at, tl::to_string (tr ("Cancel(Esc)")))); at = "bookmark_menu.end"; - menu_entries.push_back (lay::submenu ("goto_bookmark_menu", at, tl::to_string (QObject::tr ("Goto Bookmark")))); - menu_entries.push_back (lay::menu_item ("cm_bookmark_view", "bookmark_view", at, tl::to_string (QObject::tr ("Bookmark This View")))); + menu_entries.push_back (lay::submenu ("goto_bookmark_menu", at, tl::to_string (tr ("Goto Bookmark")))); + menu_entries.push_back (lay::menu_item ("cm_bookmark_view", "bookmark_view", at, tl::to_string (tr ("Bookmark This View")))); menu_entries.push_back (lay::separator ("bookmark_mgm_group", at)); - menu_entries.push_back (lay::menu_item ("cm_manage_bookmarks", "manage_bookmarks", at, tl::to_string (QObject::tr ("Manage Bookmarks")))); - menu_entries.push_back (lay::menu_item ("cm_load_bookmarks", "load_bookmarks", at, tl::to_string (QObject::tr ("Load Bookmarks")))); - menu_entries.push_back (lay::menu_item ("cm_save_bookmarks", "save_bookmarks", at, tl::to_string (QObject::tr ("Save Bookmarks")))); - menu_entries.push_back (lay::submenu ("open_recent_menu_bookmarks", at, tl::to_string (QObject::tr ("Recent Bookmark Files")))); + menu_entries.push_back (lay::menu_item ("cm_manage_bookmarks", "manage_bookmarks", at, tl::to_string (tr ("Manage Bookmarks")))); + menu_entries.push_back (lay::menu_item ("cm_load_bookmarks", "load_bookmarks", at, tl::to_string (tr ("Load Bookmarks")))); + menu_entries.push_back (lay::menu_item ("cm_save_bookmarks", "save_bookmarks", at, tl::to_string (tr ("Save Bookmarks")))); + menu_entries.push_back (lay::submenu ("open_recent_menu_bookmarks", at, tl::to_string (tr ("Recent Bookmark Files")))); at = "zoom_menu.end"; - menu_entries.push_back (lay::submenu ("global_trans", at, tl::to_string (QObject::tr ("Global Transformation")))); + menu_entries.push_back (lay::submenu ("global_trans", at, tl::to_string (tr ("Global Transformation")))); { std::string at = "zoom_menu.global_trans.end"; - menu_entries.push_back (lay::config_menu_item ("r0", at, tl::to_string (QObject::tr ("\\(r0\\)<:/r0.png>")), cfg_global_trans, "?r0 *1 0,0")); - menu_entries.push_back (lay::config_menu_item ("r90", at, tl::to_string (QObject::tr ("\\(r90\\)<:/r90.png>")), cfg_global_trans, "?r90 *1 0,0")); - menu_entries.push_back (lay::config_menu_item ("r180", at, tl::to_string (QObject::tr ("\\(r180\\)<:/r180.png>")), cfg_global_trans, "?r180 *1 0,0")); - menu_entries.push_back (lay::config_menu_item ("r270", at, tl::to_string (QObject::tr ("\\(r270\\)<:/r270.png>")), cfg_global_trans, "?r270 *1 0,0")); - menu_entries.push_back (lay::config_menu_item ("m0", at, tl::to_string (QObject::tr ("\\(m0\\)<:/m0.png>")), cfg_global_trans, "?m0 *1 0,0")); - menu_entries.push_back (lay::config_menu_item ("m45", at, tl::to_string (QObject::tr ("\\(m45\\)<:/m45.png>")), cfg_global_trans, "?m45 *1 0,0")); - menu_entries.push_back (lay::config_menu_item ("m90", at, tl::to_string (QObject::tr ("\\(m90\\)<:/m90.png>")), cfg_global_trans, "?m90 *1 0,0")); - menu_entries.push_back (lay::config_menu_item ("m135", at, tl::to_string (QObject::tr ("\\(m135\\)<:/m135.png>")), cfg_global_trans, "?m135 *1 0,0")); + menu_entries.push_back (lay::config_menu_item ("r0", at, tl::to_string (tr ("\\(r0\\)<:/r0.png>")), cfg_global_trans, "?r0 *1 0,0")); + menu_entries.push_back (lay::config_menu_item ("r90", at, tl::to_string (tr ("\\(r90\\)<:/r90.png>")), cfg_global_trans, "?r90 *1 0,0")); + menu_entries.push_back (lay::config_menu_item ("r180", at, tl::to_string (tr ("\\(r180\\)<:/r180.png>")), cfg_global_trans, "?r180 *1 0,0")); + menu_entries.push_back (lay::config_menu_item ("r270", at, tl::to_string (tr ("\\(r270\\)<:/r270.png>")), cfg_global_trans, "?r270 *1 0,0")); + menu_entries.push_back (lay::config_menu_item ("m0", at, tl::to_string (tr ("\\(m0\\)<:/m0.png>")), cfg_global_trans, "?m0 *1 0,0")); + menu_entries.push_back (lay::config_menu_item ("m45", at, tl::to_string (tr ("\\(m45\\)<:/m45.png>")), cfg_global_trans, "?m45 *1 0,0")); + menu_entries.push_back (lay::config_menu_item ("m90", at, tl::to_string (tr ("\\(m90\\)<:/m90.png>")), cfg_global_trans, "?m90 *1 0,0")); + menu_entries.push_back (lay::config_menu_item ("m135", at, tl::to_string (tr ("\\(m135\\)<:/m135.png>")), cfg_global_trans, "?m135 *1 0,0")); } menu_entries.push_back (lay::separator ("hier_group", at)); - menu_entries.push_back (lay::menu_item ("cm_max_hier", "max_hier", at, tl::to_string (QObject::tr ("Full Hierarchy(*)")))); - menu_entries.push_back (lay::menu_item ("cm_max_hier_0", "max_hier_0", at, tl::to_string (QObject::tr ("Box Only(0)")))); - menu_entries.push_back (lay::menu_item ("cm_max_hier_1", "max_hier_1", at, tl::to_string (QObject::tr ("Top Level Only(1)")))); - menu_entries.push_back (lay::menu_item ("cm_inc_max_hier", "inc_max_hier", at, tl::to_string (QObject::tr ("Increment Hierarchy(+)")))); - menu_entries.push_back (lay::menu_item ("cm_dec_max_hier", "dec_max_hier", at, tl::to_string (QObject::tr ("Decrement Hierarchy(-)")))); + menu_entries.push_back (lay::menu_item ("cm_max_hier", "max_hier", at, tl::to_string (tr ("Full Hierarchy(*)")))); + menu_entries.push_back (lay::menu_item ("cm_max_hier_0", "max_hier_0", at, tl::to_string (tr ("Box Only(0)")))); + menu_entries.push_back (lay::menu_item ("cm_max_hier_1", "max_hier_1", at, tl::to_string (tr ("Top Level Only(1)")))); + menu_entries.push_back (lay::menu_item ("cm_inc_max_hier", "inc_max_hier", at, tl::to_string (tr ("Increment Hierarchy(+)")))); + menu_entries.push_back (lay::menu_item ("cm_dec_max_hier", "dec_max_hier", at, tl::to_string (tr ("Decrement Hierarchy(-)")))); menu_entries.push_back (lay::separator ("zoom_group", at)); - menu_entries.push_back (lay::menu_item ("cm_zoom_fit", "zoom_fit", at, tl::to_string (QObject::tr ("Zoom Fit(F2)")))); - menu_entries.push_back (lay::menu_item ("cm_zoom_fit_sel", "zoom_fit_sel", at, tl::to_string (QObject::tr ("Zoom Fit Selection(Shift+F2)")))); - menu_entries.push_back (lay::menu_item ("cm_zoom_in", "zoom_in", at, tl::to_string (QObject::tr ("Zoom In(Ctrl++)")))); - menu_entries.push_back (lay::menu_item ("cm_zoom_out", "zoom_out", at, tl::to_string (QObject::tr ("Zoom Out(Ctrl+-)")))); + menu_entries.push_back (lay::menu_item ("cm_zoom_fit", "zoom_fit", at, tl::to_string (tr ("Zoom Fit(F2)")))); + menu_entries.push_back (lay::menu_item ("cm_zoom_fit_sel", "zoom_fit_sel", at, tl::to_string (tr ("Zoom Fit Selection(Shift+F2)")))); + menu_entries.push_back (lay::menu_item ("cm_zoom_in", "zoom_in", at, tl::to_string (tr ("Zoom In(Ctrl++)")))); + menu_entries.push_back (lay::menu_item ("cm_zoom_out", "zoom_out", at, tl::to_string (tr ("Zoom Out(Ctrl+-)")))); /* disabled because that interferes with the use of the arrow keys for moving the selection MenuLayoutEntry::separator ("pan_group"); - menu_entries.push_back (lay::menu_item ("cm_pan_up", "pan_up", at, tl::to_string (QObject::tr ("Pan Up(Up)")))); - menu_entries.push_back (lay::menu_item ("cm_pan_down", "pan_down", at, tl::to_string (QObject::tr ("Pan Down(Down)")))); - menu_entries.push_back (lay::menu_item ("cm_pan_left", "pan_left", at, tl::to_string (QObject::tr ("Pan Left(Left)")))); - menu_entries.push_back (lay::menu_item ("cm_pan_right", "pan_right", at, tl::to_string (QObject::tr ("Pan Right(Right)")))); + menu_entries.push_back (lay::menu_item ("cm_pan_up", "pan_up", at, tl::to_string (tr ("Pan Up(Up)")))); + menu_entries.push_back (lay::menu_item ("cm_pan_down", "pan_down", at, tl::to_string (tr ("Pan Down(Down)")))); + menu_entries.push_back (lay::menu_item ("cm_pan_left", "pan_left", at, tl::to_string (tr ("Pan Left(Left)")))); + menu_entries.push_back (lay::menu_item ("cm_pan_right", "pan_right", at, tl::to_string (tr ("Pan Right(Right)")))); */ menu_entries.push_back (lay::separator ("redraw_group", at)); - menu_entries.push_back (lay::menu_item ("cm_redraw", "redraw", at, tl::to_string (QObject::tr ("Redraw")))); + menu_entries.push_back (lay::menu_item ("cm_redraw", "redraw", at, tl::to_string (tr ("Redraw")))); menu_entries.push_back (lay::separator ("state_group", at)); menu_entries.push_back (lay::menu_item_copy ("cm_prev_display_state", "prev_display_state", at, "@toolbar.prev_display_state")); menu_entries.push_back (lay::menu_item_copy ("cm_next_display_state", "next_display_state", at, "@toolbar.next_display_state")); menu_entries.push_back (lay::separator ("select_group", at)); - menu_entries.push_back (lay::menu_item ("cm_select_cell", "select_cell:edit", at, tl::to_string (QObject::tr ("Select Cell")))); - menu_entries.push_back (lay::menu_item ("cm_select_current_cell", "select_current_cell", at, tl::to_string (QObject::tr ("Show As New Top(Ctrl+S)")))); - menu_entries.push_back (lay::menu_item ("cm_goto_position", "goto_position", at, tl::to_string (QObject::tr ("Goto Position(Ctrl+G)")))); + menu_entries.push_back (lay::menu_item ("cm_select_cell", "select_cell:edit", at, tl::to_string (tr ("Select Cell")))); + menu_entries.push_back (lay::menu_item ("cm_select_current_cell", "select_current_cell", at, tl::to_string (tr ("Show As New Top(Ctrl+S)")))); + menu_entries.push_back (lay::menu_item ("cm_goto_position", "goto_position", at, tl::to_string (tr ("Goto Position(Ctrl+G)")))); // Add a hook for inserting new items after the modes menu_entries.push_back (lay::separator ("end_modes", "@toolbar.end")); diff --git a/src/laybasic/laybasic/layPlugin.cc b/src/laybasic/laybasic/layPlugin.cc index 0cea0604a..819d2c131 100644 --- a/src/laybasic/laybasic/layPlugin.cc +++ b/src/laybasic/laybasic/layPlugin.cc @@ -62,6 +62,7 @@ PluginDeclaration::~PluginDeclaration () } } +#if defined(HAVE_QT) void PluginDeclaration::toggle_editable_enabled () { @@ -69,6 +70,7 @@ PluginDeclaration::toggle_editable_enabled () set_editable_enabled (! editable_enabled ()); END_PROTECTED } +#endif std::vector PluginDeclaration::menu_symbols () @@ -95,6 +97,7 @@ PluginDeclaration::menu_symbols () } #if defined(HAVE_QT) + namespace { class GenericMenuAction @@ -144,12 +147,10 @@ private: }; } -#endif void PluginDeclaration::init_menu (lay::Dispatcher *dispatcher) { -#if defined(HAVE_QT) // @@@ lay::AbstractMenu &menu = *dispatcher->menu (); mp_editable_mode_action.reset ((Action *) 0); @@ -259,13 +260,11 @@ PluginDeclaration::init_menu (lay::Dispatcher *dispatcher) menu.insert_item (m->second.first, name + ":mode_group", mp_mouse_mode_action.get ()); } -#endif } void PluginDeclaration::remove_menu_items (Dispatcher *dispatcher) { -#if defined(HAVE_QT) // @@@ lay::AbstractMenu *menu = dispatcher->menu (); menu->delete_items (mp_editable_mode_action.get ()); menu->delete_items (mp_mouse_mode_action.get ()); @@ -280,15 +279,16 @@ PluginDeclaration::remove_menu_items (Dispatcher *dispatcher) menu->delete_items (*a); } m_menu_actions.clear (); -#endif } +#endif + void PluginDeclaration::set_editable_enabled (bool f) { if (f != m_editable_enabled) { m_editable_enabled = f; -#if defined(HAVE_QT) // @@@ +#if defined(HAVE_QT) if (mp_editable_mode_action.get ()) { mp_editable_mode_action->set_checked (f); } diff --git a/src/laybasic/laybasic/layPlugin.h b/src/laybasic/laybasic/layPlugin.h index fc83a478b..8d95da611 100644 --- a/src/laybasic/laybasic/layPlugin.h +++ b/src/laybasic/laybasic/layPlugin.h @@ -386,6 +386,14 @@ public: return m_id; } + /** + * @brief Gets the available menu symbols from all plugins + * + * This does not mean all symbols will be available. + */ + static std::vector menu_symbols (); + +#if defined(HAVE_QT) /** * @brief Creates the menu resources for this plugin * @@ -395,17 +403,11 @@ public: */ void init_menu (lay::Dispatcher *dispatcher); - /** - * @brief Gets the available menu symbols from all plugins - * - * This does not mean all symbols will be available. - */ - static std::vector menu_symbols (); - /** * @brief Removes the menu resources associated with this plugin */ void remove_menu_items (lay::Dispatcher *dispatcher); +#endif /** * @brief Enables this editable part of the plugin @@ -455,10 +457,8 @@ public: #if defined(HAVE_QT) private slots: -#else -private: -#endif void toggle_editable_enabled (); +#endif private: int m_id; diff --git a/src/laybasic/laybasic/layViewObject.cc b/src/laybasic/laybasic/layViewObject.cc index 8a881c321..be11f9220 100644 --- a/src/laybasic/laybasic/layViewObject.cc +++ b/src/laybasic/laybasic/layViewObject.cc @@ -31,6 +31,9 @@ #include "layViewObject.h" #include "layCanvasPlane.h" #include "layBitmap.h" +#if defined(HAVE_QT) +# include "layDragDropData.h" +#endif #include "tlException.h" #include "tlAlgorithm.h" #include "tlExceptions.h" @@ -44,87 +47,6 @@ namespace lay // event rather than a single click event: const int click_tolerance = 5; -// --------------------------------------------------------------- -// Implementation of DragDropDataBase - -const char *drag_drop_mime_type () -{ - return "application/klayout-ddd"; -} - -#if defined(HAVE_QT) // @@@ -QMimeData * -DragDropDataBase::to_mime_data () const -{ - QMimeData *mimeData = new QMimeData(); - mimeData->setData (QString::fromUtf8 (drag_drop_mime_type ()), serialized ()); - return mimeData; -} -#endif - -// --------------------------------------------------------------- -// Implementation of CellDragDropData - -#if defined(HAVE_QT) // @@@ -QByteArray -CellDragDropData::serialized () const -{ - QByteArray data; - QDataStream stream (&data, QIODevice::WriteOnly); - - stream << QString::fromUtf8 ("CellDragDropData"); - stream << (quintptr) mp_layout; - stream << (quintptr) mp_library; - stream << m_cell_index; - stream << m_is_pcell; - stream << int (m_pcell_params.size ()); - for (std::vector::const_iterator i = m_pcell_params.begin (); i != m_pcell_params.end (); ++i) { - stream << tl::to_qstring (i->to_parsable_string ()); - } - - return data; -} - -bool -CellDragDropData::deserialize (const QByteArray &ba) -{ - QDataStream stream (const_cast (&ba), QIODevice::ReadOnly); - - QString tag; - stream >> tag; - - if (tag == QString::fromUtf8 ("CellDragDropData")) { - - quintptr p = 0; - stream >> p; - mp_layout = reinterpret_cast (p); - stream >> p; - mp_library = reinterpret_cast (p); - stream >> m_cell_index; - stream >> m_is_pcell; - - m_pcell_params.clear (); - int n = 0; - stream >> n; - while (n-- > 0) { - QString s; - stream >> s; - std::string stl_s = tl::to_string (s); - tl::Extractor ex (stl_s.c_str ()); - m_pcell_params.push_back (tl::Variant ()); - ex.read (m_pcell_params.back ()); - } - - return true; - - } else { - - return false; - - } -} -#endif - // --------------------------------------------------------------- // A helper function to convert a Qt modifier/buttons to klayout buttons @@ -399,9 +321,9 @@ ViewObjectWidget::set_cursor (lay::Cursor::cursor_shape cursor) void ViewObjectWidget::set_default_cursor (lay::Cursor::cursor_shape cursor) { -#if defined(HAVE_QT) if (cursor != m_default_cursor) { m_default_cursor = cursor; +#if defined(HAVE_QT) if (m_cursor == lay::Cursor::none) { if (m_default_cursor == lay::Cursor::none) { unsetCursor (); @@ -409,18 +331,16 @@ ViewObjectWidget::set_default_cursor (lay::Cursor::cursor_shape cursor) setCursor (lay::Cursor::qcursor (m_default_cursor)); } } - } #endif + } } void ViewObjectWidget::ensure_entered () { -#if defined(HAVE_QT) // @@@ if (! m_mouse_inside) { - enterEvent (0); + send_enter_event (); } -#endif } void @@ -432,7 +352,7 @@ ViewObjectWidget::begin_mouse_event (lay::Cursor::cursor_shape cursor) void ViewObjectWidget::end_mouse_event () { -#if defined(HAVE_QT) // @@@ +#if defined(HAVE_QT) if (m_cursor == lay::Cursor::none) { if (m_default_cursor == lay::Cursor::none) { unsetCursor (); @@ -445,7 +365,347 @@ ViewObjectWidget::end_mouse_event () #endif } -#if defined(HAVE_QT) // @@@ +void +ViewObjectWidget::send_key_press_event (unsigned int key, unsigned int buttons) +{ + bool done = false; + if (mp_active_service) { + done = (mp_active_service->enabled () && mp_active_service->key_event (key, buttons)); + } + + if (! done) { + key_event (key, buttons); + } +} + +void +ViewObjectWidget::do_mouse_move () +{ + m_in_mouse_move = true; + + if (m_mouse_pressed_state && + (abs (m_mouse_pos.x () - m_mouse_pressed.x ()) > click_tolerance || abs (m_mouse_pos.y () - m_mouse_pressed.y ()) > click_tolerance)) { + + begin_mouse_event (lay::Cursor::none); + + m_mouse_pressed_state = false; + + bool done = false; + + db::DPoint p = pixel_to_um (m_mouse_pressed); + + for (std::list::iterator g = m_grabbed.begin (); !done && g != m_grabbed.end (); ) { + std::list::iterator gg = g; + ++gg; + done = ((*g)->enabled () && (*g)->mouse_press_event (p, m_mouse_buttons, true)); + g = gg; + } + + if (! done && mp_active_service) { + done = (mp_active_service->enabled () && mp_active_service->mouse_press_event (p, m_mouse_buttons, true)); + } + + service_iterator svc = begin_services (); + while (svc != end_services () && !done) { + service_iterator next = svc; + ++next; + done = ((*svc)->enabled () && (*svc)->mouse_press_event (p, m_mouse_buttons, false)); + svc = next; + } + + if (! done) { + mouse_press_event (p, m_mouse_buttons); + } + + end_mouse_event (); + + } + + if (! m_mouse_pressed_state) { + + begin_mouse_event (lay::Cursor::none); + + bool done = false; + + db::DPoint p = pixel_to_um (m_mouse_pos); + + for (std::list::iterator g = m_grabbed.begin (); !done && g != m_grabbed.end (); ) { + std::list::iterator gg = g; + ++gg; + done = ((*g)->enabled () && (*g)->mouse_move_event (p, m_mouse_buttons, true)); + g = gg; + } + + if (! done && mp_active_service) { + done = (mp_active_service->enabled () && mp_active_service->mouse_move_event (p, m_mouse_buttons, true)); + } + + service_iterator svc = begin_services (); + while (svc != end_services () && !done) { + service_iterator next = svc; + ++next; + done = ((*svc)->enabled () && (*svc)->mouse_move_event (p, m_mouse_buttons, false)); + svc = next; + } + + if (! done) { + mouse_move_event (p, m_mouse_buttons); + } + + end_mouse_event (); + + } + + m_in_mouse_move = false; +} + +void +ViewObjectWidget::send_mouse_move_event (const db::DPoint &pt, unsigned int buttons) +{ + ensure_entered (); + m_mouse_pos = pt; + m_mouse_buttons = buttons; + do_mouse_move (); +} + +void +ViewObjectWidget::send_leave_event () +{ + try { + + bool done = false; + + for (std::list::iterator g = m_grabbed.begin (); !done && g != m_grabbed.end (); ) { + std::list::iterator gg = g; + ++gg; + done = ((*g)->enabled () && (*g)->leave_event (true)); + g = gg; + } + + if (! done && mp_active_service) { + done = (mp_active_service->enabled () && mp_active_service->leave_event (true)); + } + + service_iterator svc = begin_services (); + while (svc != end_services () && !done) { + service_iterator next = svc; + ++next; + done = ((*svc)->enabled () && (*svc)->leave_event (false)); + svc = next; + } + + if (! done) { + leave_event (); + } + + end_mouse_event (); + + m_mouse_inside = false; + + } catch (...) { + m_mouse_inside = false; + throw; + } +} + +void +ViewObjectWidget::send_enter_event () +{ + m_mouse_inside = true; + + begin_mouse_event (); + + bool done = false; + + for (std::list::iterator g = m_grabbed.begin (); !done && g != m_grabbed.end (); ) { + std::list::iterator gg = g; + ++gg; + done = ((*g)->enabled () && (*g)->enter_event (true)); + g = gg; + } + + if (! done && mp_active_service) { + done = (mp_active_service->enabled () && mp_active_service->enter_event (true)); + } + + service_iterator svc = begin_services (); + while (svc != end_services () && !done) { + service_iterator next = svc; + ++next; + done = ((*svc)->enabled () && (*svc)->enter_event (false)); + svc = next; + } + + if (! done) { + enter_event (); + } + + end_mouse_event (); +} + +void +ViewObjectWidget::send_mouse_press_event (const db::DPoint &pt, unsigned int buttons) +{ + ensure_entered (); +#if defined(HAVE_QT) + setFocus (); +#endif + + m_mouse_pos = pt; + m_mouse_pressed = m_mouse_pos; + + m_mouse_buttons = buttons; + + m_mouse_pressed_state = true; +} + +void +ViewObjectWidget::send_mouse_double_clicked_event (const db::DPoint &pt, unsigned int buttons) +{ + ensure_entered (); + begin_mouse_event (lay::Cursor::none); + +#if defined(HAVE_QT) + setFocus (); +#endif + + bool done = false; + + m_mouse_pos = pt; + m_mouse_pressed = m_mouse_pos; + m_mouse_pressed_state = false; + + db::DPoint p = pixel_to_um (m_mouse_pos); + + for (std::list::iterator g = m_grabbed.begin (); !done && g != m_grabbed.end (); ) { + std::list::iterator gg = g; + ++gg; + done = ((*g)->m_enabled && (*g)->mouse_double_click_event (p, buttons, true)); + g = gg; + } + + if (! done && mp_active_service) { + done = (mp_active_service->enabled () && mp_active_service->mouse_double_click_event (p, buttons, true)); + } + + service_iterator svc = begin_services (); + while (svc != end_services () && !done) { + service_iterator next = svc; + ++next; + done = ((*svc)->enabled () && (*svc)->mouse_double_click_event (p, buttons, false)); + svc = next; + } + + if (! done) { + mouse_double_click_event (p, buttons); + } + + end_mouse_event (); +} + +void +ViewObjectWidget::send_mouse_release_event (const db::DPoint &pt, unsigned int /*buttons*/) +{ + try { + + ensure_entered (); + begin_mouse_event (); + + bool done = false; + + m_mouse_pos = pt; + db::DPoint p = pixel_to_um (m_mouse_pos); + + for (std::list::iterator g = m_grabbed.begin (); !done && g != m_grabbed.end (); ) { + std::list::iterator gg = g; + ++gg; + if (m_mouse_pressed_state) { + done = (*g)->enabled () && (*g)->mouse_click_event (p, m_mouse_buttons, true); + } else { + done = (*g)->enabled () && (*g)->mouse_release_event (p, m_mouse_buttons, true); + } + g = gg; + } + + if (! done && mp_active_service && mp_active_service->enabled ()) { + if (m_mouse_pressed_state) { + done = mp_active_service->mouse_click_event (p, m_mouse_buttons, true); + } else { + done = mp_active_service->mouse_release_event (p, m_mouse_buttons, true); + } + } + + service_iterator svc = begin_services (); + while (svc != end_services () && !done) { + service_iterator next = svc; + ++next; + if ((*svc)->enabled ()) { + if (m_mouse_pressed_state) { + done = (*svc)->mouse_click_event (p, m_mouse_buttons, false); + } else { + done = (*svc)->mouse_release_event (p, m_mouse_buttons, false); + } + } + svc = next; + } + + if (! done) { + if (m_mouse_pressed_state) { + mouse_click_event (p, m_mouse_buttons); + } else { + mouse_release_event (p, m_mouse_buttons); + } + } + + end_mouse_event (); + + m_mouse_pressed_state = false; + + } catch (...) { + m_mouse_pressed_state = false; + throw; + } +} + +void +ViewObjectWidget::send_wheel_event (int delta, bool horizontal, const db::DPoint &pt, unsigned int buttons) +{ + ensure_entered (); + begin_mouse_event (); + + db::DPoint p = pixel_to_um (pt); + + bool done = false; + + for (std::list::iterator g = m_grabbed.begin (); !done && g != m_grabbed.end (); ) { + std::list::iterator gg = g; + ++gg; + done = ((*g)->enabled () && (*g)->wheel_event (delta, horizontal, p, buttons, true)); + g = gg; + } + + if (! done && mp_active_service) { + done = (mp_active_service->enabled () && mp_active_service->wheel_event (delta, horizontal, p, buttons, true)); + } + + service_iterator svc = begin_services (); + while (svc != end_services () && !done) { + service_iterator next = svc; + ++next; + done = ((*svc)->enabled () && (*svc)->wheel_event (delta, horizontal, p, buttons, false)); + svc = next; + } + + if (! done) { + wheel_event (delta, horizontal, p, buttons); + } + + end_mouse_event (); +} + + +#if defined(HAVE_QT) + bool ViewObjectWidget::focusNextPrevChild (bool /*next*/) { @@ -456,18 +716,8 @@ void ViewObjectWidget::keyPressEvent (QKeyEvent *e) { BEGIN_PROTECTED - unsigned int buttons = qt_to_buttons (Qt::MouseButtons (), e->modifiers ()); - - bool done = false; - if (mp_active_service) { - done = (mp_active_service->enabled () && mp_active_service->key_event ((unsigned int) e->key(), buttons)); - } - - if (! done) { - key_event ((unsigned int) e->key (), buttons); - } - + send_key_press_event ((unsigned int) e->key (), buttons); END_PROTECTED } @@ -586,139 +836,33 @@ void ViewObjectWidget::mouseMoveEvent (QMouseEvent *e) { BEGIN_PROTECTED - ensure_entered (); - m_mouse_pos = db::Point (e->pos ().x (), e->pos ().y ()); - m_mouse_buttons = qt_to_buttons (e->buttons (), e->modifiers ()); - do_mouse_move (); -END_PROTECTED -} + + db::DPoint p; +#if QT_VERSION < 0x60000 + p = db::DPoint (e->pos ().x (), e->pos ().y ()); +#else + p = db::DPoint (e->position ().x (), e->position ().y ()); #endif -void -ViewObjectWidget::do_mouse_move () -{ - m_in_mouse_move = true; + send_mouse_move_event (p, qt_to_buttons (e->buttons (), e->modifiers ())); - if (m_mouse_pressed_state && - (abs (m_mouse_pos.x () - m_mouse_pressed.x ()) > click_tolerance || abs (m_mouse_pos.y () - m_mouse_pressed.y ()) > click_tolerance)) { - - begin_mouse_event (lay::Cursor::none); - - m_mouse_pressed_state = false; - - bool done = false; - - db::DPoint p = pixel_to_um (m_mouse_pressed); - - for (std::list::iterator g = m_grabbed.begin (); !done && g != m_grabbed.end (); ) { - std::list::iterator gg = g; - ++gg; - done = ((*g)->enabled () && (*g)->mouse_press_event (p, m_mouse_buttons, true)); - g = gg; - } - - if (! done && mp_active_service) { - done = (mp_active_service->enabled () && mp_active_service->mouse_press_event (p, m_mouse_buttons, true)); - } - - service_iterator svc = begin_services (); - while (svc != end_services () && !done) { - service_iterator next = svc; - ++next; - done = ((*svc)->enabled () && (*svc)->mouse_press_event (p, m_mouse_buttons, false)); - svc = next; - } - - if (! done) { - mouse_press_event (p, m_mouse_buttons); - } - - end_mouse_event (); - - } - - if (! m_mouse_pressed_state) { - - begin_mouse_event (lay::Cursor::none); - - bool done = false; - - db::DPoint p = pixel_to_um (m_mouse_pos); - - for (std::list::iterator g = m_grabbed.begin (); !done && g != m_grabbed.end (); ) { - std::list::iterator gg = g; - ++gg; - done = ((*g)->enabled () && (*g)->mouse_move_event (p, m_mouse_buttons, true)); - g = gg; - } - - if (! done && mp_active_service) { - done = (mp_active_service->enabled () && mp_active_service->mouse_move_event (p, m_mouse_buttons, true)); - } - - service_iterator svc = begin_services (); - while (svc != end_services () && !done) { - service_iterator next = svc; - ++next; - done = ((*svc)->enabled () && (*svc)->mouse_move_event (p, m_mouse_buttons, false)); - svc = next; - } - - if (! done) { - mouse_move_event (p, m_mouse_buttons); - } - - end_mouse_event (); - - } - - m_in_mouse_move = false; +END_PROTECTED } -#if defined(HAVE_QT) // @@@ void ViewObjectWidget::mouseDoubleClickEvent (QMouseEvent *e) { BEGIN_PROTECTED - ensure_entered (); - begin_mouse_event (lay::Cursor::none); - setFocus (); + db::DPoint p; +#if QT_VERSION < 0x60000 + p = db::DPoint (e->pos ().x (), e->pos ().y ()); +#else + p = db::DPoint (e->position ().x (), e->position ().y ()); +#endif - bool done = false; + send_mouse_double_clicked_event (p, qt_to_buttons (e->buttons (), e->modifiers ())); - m_mouse_pos = db::Point (e->pos ().x (), e->pos ().y ()); - m_mouse_pressed = m_mouse_pos; - m_mouse_pressed_state = false; - - unsigned int buttons = qt_to_buttons (e->buttons (), e->modifiers ()); - - db::DPoint p = pixel_to_um (m_mouse_pos); - - for (std::list::iterator g = m_grabbed.begin (); !done && g != m_grabbed.end (); ) { - std::list::iterator gg = g; - ++gg; - done = ((*g)->m_enabled && (*g)->mouse_double_click_event (p, buttons, true)); - g = gg; - } - - if (! done && mp_active_service) { - done = (mp_active_service->enabled () && mp_active_service->mouse_double_click_event (p, buttons, true)); - } - - service_iterator svc = begin_services (); - while (svc != end_services () && !done) { - service_iterator next = svc; - ++next; - done = ((*svc)->enabled () && (*svc)->mouse_double_click_event (p, buttons, false)); - svc = next; - } - - if (! done) { - mouse_double_click_event (p, buttons); - } - - end_mouse_event (); END_PROTECTED } @@ -730,198 +874,75 @@ ViewObjectWidget::enterEvent (QEvent * /*event*/) #endif { BEGIN_PROTECTED - m_mouse_inside = true; - - begin_mouse_event (); - - bool done = false; - - for (std::list::iterator g = m_grabbed.begin (); !done && g != m_grabbed.end (); ) { - std::list::iterator gg = g; - ++gg; - done = ((*g)->enabled () && (*g)->enter_event (true)); - g = gg; - } - - if (! done && mp_active_service) { - done = (mp_active_service->enabled () && mp_active_service->enter_event (true)); - } - - service_iterator svc = begin_services (); - while (svc != end_services () && !done) { - service_iterator next = svc; - ++next; - done = ((*svc)->enabled () && (*svc)->enter_event (false)); - svc = next; - } - - if (! done) { - enter_event (); - } - - end_mouse_event (); + send_enter_event (); END_PROTECTED } -void +void ViewObjectWidget::leaveEvent (QEvent * /*event*/) { -BEGIN_PROTECTED +BEGIN_PROTECTED begin_mouse_event (); - - bool done = false; - - for (std::list::iterator g = m_grabbed.begin (); !done && g != m_grabbed.end (); ) { - std::list::iterator gg = g; - ++gg; - done = ((*g)->enabled () && (*g)->leave_event (true)); - g = gg; - } - - if (! done && mp_active_service) { - done = (mp_active_service->enabled () && mp_active_service->leave_event (true)); - } - - service_iterator svc = begin_services (); - while (svc != end_services () && !done) { - service_iterator next = svc; - ++next; - done = ((*svc)->enabled () && (*svc)->leave_event (false)); - svc = next; - } - - if (! done) { - leave_event (); - } - - end_mouse_event (); END_PROTECTED - - m_mouse_inside = false; } void ViewObjectWidget::wheelEvent (QWheelEvent *e) { -BEGIN_PROTECTED - ensure_entered (); - begin_mouse_event (); +BEGIN_PROTECTED + db::DPoint p; #if QT_VERSION < 0x60000 int delta = e->delta (); - db::DPoint p = pixel_to_um (db::Point (e->pos ().x (), e->pos ().y ())); + p = db::DPoint (e->pos ().x (), e->pos ().y ()); bool horizontal = (e->orientation () == Qt::Horizontal); #else int delta = e->angleDelta ().y (); - db::DPoint p = pixel_to_um (e->position ()); + p = db::DPoint (e->position ().x (), e->position ().y ()); bool horizontal = false; #endif e->ignore (); - bool done = false; + send_wheel_event (delta, horizontal, p, qt_to_buttons (e->buttons (), e->modifiers ())); - unsigned int buttons = qt_to_buttons (e->buttons (), e->modifiers ()); - - for (std::list::iterator g = m_grabbed.begin (); !done && g != m_grabbed.end (); ) { - std::list::iterator gg = g; - ++gg; - done = ((*g)->enabled () && (*g)->wheel_event (delta, horizontal, p, buttons, true)); - g = gg; - } - - if (! done && mp_active_service) { - done = (mp_active_service->enabled () && mp_active_service->wheel_event (delta, horizontal, p, buttons, true)); - } - - service_iterator svc = begin_services (); - while (svc != end_services () && !done) { - service_iterator next = svc; - ++next; - done = ((*svc)->enabled () && (*svc)->wheel_event (delta, horizontal, p, buttons, false)); - svc = next; - } - - if (! done) { - wheel_event (delta, horizontal, p, buttons); - } - - end_mouse_event (); END_PROTECTED } void ViewObjectWidget::mousePressEvent (QMouseEvent *e) { - ensure_entered (); - setFocus (); +BEGIN_PROTECTED - m_mouse_pos = db::Point (e->pos ().x (), e->pos ().y ()); - m_mouse_pressed = m_mouse_pos; + db::DPoint p; +#if QT_VERSION < 0x60000 + p = db::DPoint (e->pos ().x (), e->pos ().y ()); +#else + p = db::DPoint (e->position ().x (), e->position ().y ()); +#endif - m_mouse_buttons = qt_to_buttons (e->buttons (), e->modifiers ()); - - m_mouse_pressed_state = true; + send_mouse_press_event (p, qt_to_buttons (e->buttons (), e->modifiers ())); + +END_PROTECTED } void ViewObjectWidget::mouseReleaseEvent (QMouseEvent *e) { BEGIN_PROTECTED - ensure_entered (); - begin_mouse_event (); - bool done = false; + db::DPoint p; +#if QT_VERSION < 0x60000 + p = db::DPoint (e->pos ().x (), e->pos ().y ()); +#else + p = db::DPoint (e->position ().x (), e->position ().y ()); +#endif - m_mouse_pos = db::Point (e->pos ().x (), e->pos ().y ()); - db::DPoint p = pixel_to_um (m_mouse_pos); + send_mouse_press_event (p, qt_to_buttons (e->buttons (), e->modifiers ())); - for (std::list::iterator g = m_grabbed.begin (); !done && g != m_grabbed.end (); ) { - std::list::iterator gg = g; - ++gg; - if (m_mouse_pressed_state) { - done = (*g)->enabled () && (*g)->mouse_click_event (p, m_mouse_buttons, true); - } else { - done = (*g)->enabled () && (*g)->mouse_release_event (p, m_mouse_buttons, true); - } - g = gg; - } - - if (! done && mp_active_service && mp_active_service->enabled ()) { - if (m_mouse_pressed_state) { - done = mp_active_service->mouse_click_event (p, m_mouse_buttons, true); - } else { - done = mp_active_service->mouse_release_event (p, m_mouse_buttons, true); - } - } - - service_iterator svc = begin_services (); - while (svc != end_services () && !done) { - service_iterator next = svc; - ++next; - if ((*svc)->enabled ()) { - if (m_mouse_pressed_state) { - done = (*svc)->mouse_click_event (p, m_mouse_buttons, false); - } else { - done = (*svc)->mouse_release_event (p, m_mouse_buttons, false); - } - } - svc = next; - } - - if (! done) { - if (m_mouse_pressed_state) { - mouse_click_event (p, m_mouse_buttons); - } else { - mouse_release_event (p, m_mouse_buttons); - } - } - - end_mouse_event (); END_PROTECTED - - m_mouse_pressed_state = false; } + #endif void diff --git a/src/laybasic/laybasic/layViewObject.h b/src/laybasic/laybasic/layViewObject.h index dfd24623d..1df6d04b0 100644 --- a/src/laybasic/laybasic/layViewObject.h +++ b/src/laybasic/laybasic/layViewObject.h @@ -73,138 +73,9 @@ class Bitmap; class PixelBuffer; class BitmapBuffer; -LAYBASIC_PUBLIC const char *drag_drop_mime_type (); - -/** - * @brief A helper class required to store the drag/drop data - * - * Drag/drop data is basically a collection of key/value pairs. - * A category string is provided to identify the kind of data. - */ - -class LAYBASIC_PUBLIC DragDropDataBase -{ -public: - /** - * @brief Default constructor - */ - DragDropDataBase () { } - - /** - * @brief Dtor - */ - virtual ~DragDropDataBase () { } - -#if defined(HAVE_QT) // @@@ - /** - * @brief Serializes itself to an QByteArray - */ - virtual QByteArray serialized () const = 0; - - /** - * @brief Try deserialization from an QByteArray - * - * Returns false, if deserialization failed. - */ - virtual bool deserialize (const QByteArray &ba) = 0; - - /** - * @brief Create a QMimeData object from the object - */ - QMimeData *to_mime_data () const; +#if defined(HAVE_QT) +class DragDropDataBase; #endif -}; - -/** - * @brief Drag/drop data for a cell - */ - -class LAYBASIC_PUBLIC CellDragDropData - : public DragDropDataBase -{ -public: - /** - * @brief Default ctor - */ - CellDragDropData () - : mp_layout (0), mp_library (0), m_cell_index (0), m_is_pcell (false) - { - // .. nothing yet .. - } - - /** - * @brief Specifies drag & drop of a cell - * - * @param layout the layout where the cell lives in - * @param cell_index The index of the cell - */ - CellDragDropData (const db::Layout *layout, const db::Library *library, db::cell_index_type cell_or_pcell_index, bool is_pcell, const std::vector &pcell_params = std::vector ()) - : mp_layout (layout), mp_library (library), m_cell_index (cell_or_pcell_index), m_is_pcell (is_pcell), m_pcell_params (pcell_params) - { - // .. nothing yet .. - } - - /** - * @brief Gets the layout object where the cell lives in - */ - const db::Layout *layout () const - { - return mp_layout; - } - - /** - * @brief Gets the layout object where the cell lives in - */ - const db::Library *library () const - { - return mp_library; - } - - /** - * @brief PCell parameters - */ - const std::vector &pcell_params () const - { - return m_pcell_params; - } - - /** - * @brief Gets the index of the cell - */ - db::cell_index_type cell_index () const - { - return m_cell_index; - } - - /** - * @brief Gets a value indicating whether the cell is a pcell - */ - bool is_pcell () const - { - return m_is_pcell; - } - -#if defined(HAVE_QT) // @@@ - /** - * @brief Serializes itself to an QByteArray - */ - virtual QByteArray serialized () const; - - /** - * @brief Try deserialization from an QByteArray - * - * Returns false, if deserialization failed. - */ - bool deserialize (const QByteArray &ba); -#endif - -private: - const db::Layout *mp_layout; - const db::Library *mp_library; - db::cell_index_type m_cell_index; - bool m_is_pcell; - std::vector m_pcell_params; -}; /** * @brief A view service @@ -243,6 +114,7 @@ public: */ virtual bool key_event (unsigned int /*key*/, unsigned int /*buttons*/) { return false; } +#if defined(HAVE_QT) /** * @brief The drag enter event * @@ -267,6 +139,7 @@ public: * @brief The drop event */ virtual bool drop_event (const db::DPoint & /*p*/, const DragDropDataBase * /*data*/) { return false; } +#endif /** * @brief Mouse press event handler @@ -914,6 +787,7 @@ public: */ virtual void key_event (unsigned int /*key*/, unsigned int /*buttons*/) { } +#if defined(HAVE_QT) /** * @brief The drag enter event * @@ -938,6 +812,7 @@ public: * @brief The drop event */ virtual bool drop_event (const db::DPoint & /*p*/, const DragDropDataBase * /*data*/) { return false; } +#endif /** * @brief Remaining mouse double click event handler @@ -1041,7 +916,7 @@ public: /** * @brief Gets the current mouse position */ - db::Point mouse_position () const + db::DPoint mouse_position () const { return m_mouse_pos; } @@ -1081,8 +956,48 @@ public: bool image_updated (); #endif + /** + * @brief External entry point for key press event generation + */ + void send_key_press_event (unsigned int key, unsigned int buttons); + + /** + * @brief External entry point for mouse move event generation + */ + void send_mouse_move_event (const db::DPoint &pt, unsigned int buttons); + + /** + * @brief External entry point for leave event generation + */ + void send_leave_event (); + + /** + * @brief External entry point for enter event generation + */ + void send_enter_event (); + + /** + * @brief External entry point for mouse button press event generation + */ + void send_mouse_press_event (const db::DPoint &pt, unsigned int buttons); + + /** + * @brief External entry point for mouse button double-click event generation + */ + void send_mouse_double_clicked_event (const db::DPoint &pt, unsigned int buttons); + + /** + * @brief External entry point for mouse button release event generation + */ + void send_mouse_release_event (const db::DPoint &pt, unsigned int buttons); + + /** + * @brief External entry point for mouse wheel event generation + */ + void send_wheel_event (int delta, bool horizontal, const db::DPoint &pt, unsigned int buttons); + protected: -#if defined(HAVE_QT) // @@@ +#if defined(HAVE_QT) /** * @brief Qt focus event handler */ @@ -1187,8 +1102,8 @@ private: bool m_needs_update_bg; lay::ViewService *mp_active_service; db::DCplxTrans m_trans; - db::Point m_mouse_pos; - db::Point m_mouse_pressed; + db::DPoint m_mouse_pos; + db::DPoint m_mouse_pressed; bool m_mouse_pressed_state; unsigned int m_mouse_buttons; bool m_in_mouse_move; diff --git a/src/laybasic/laybasic/laybasic.pro b/src/laybasic/laybasic/laybasic.pro index 81e2fceb3..6ec570a0f 100644 --- a/src/laybasic/laybasic/laybasic.pro +++ b/src/laybasic/laybasic/laybasic.pro @@ -104,6 +104,7 @@ DEFINES += MAKE_LAYBASIC_LIBRARY layConfigurationDialog.cc \ layCursor.cc \ layDialogs.cc \ + layDragDropData.cc \ layEditLineStyleWidget.cc \ layEditLineStylesForm.cc \ layEditStippleWidget.cc \ @@ -173,6 +174,7 @@ DEFINES += MAKE_LAYBASIC_LIBRARY layColor.h \ layCursor.h \ layDialogs.h \ + layDragDropData.h \ layEditLineStyleWidget.h \ layEditLineStylesForm.h \ layEditStippleWidget.h \ diff --git a/src/laybasic/unit_tests/layLayoutViewTests.cc b/src/laybasic/unit_tests/layLayoutViewTests.cc index 5d9018461..5ce061274 100644 --- a/src/laybasic/unit_tests/layLayoutViewTests.cc +++ b/src/laybasic/unit_tests/layLayoutViewTests.cc @@ -163,14 +163,14 @@ TEST(4) tl::msleep (250); lay::PixelBuffer img = lv.get_screenshot_pb (); - EXPECT_EQ (img.width (), 42); - EXPECT_EQ (img.height (), 117); + EXPECT_EQ ((int) img.width (), 42); + EXPECT_EQ ((int) img.height (), 117); lv.resize (142, 217); img = lv.get_screenshot_pb (); - EXPECT_EQ (img.width (), 142); - EXPECT_EQ (img.height (), 217); + EXPECT_EQ ((int) img.width (), 142); + EXPECT_EQ ((int) img.height (), 217); } #if defined(HAVE_PNG) diff --git a/src/laybasic/unit_tests/layNetlistBrowserTreeModelTests.cc b/src/laybasic/unit_tests/layNetlistBrowserTreeModelTests.cc index f87df3f2f..0cedf039f 100644 --- a/src/laybasic/unit_tests/layNetlistBrowserTreeModelTests.cc +++ b/src/laybasic/unit_tests/layNetlistBrowserTreeModelTests.cc @@ -20,8 +20,6 @@ */ -#if defined(HAVE_QT) // @@@ - #include "layNetlistBrowserTreeModel.h" #include "tlUnitTest.h" @@ -106,4 +104,3 @@ TEST (2) EXPECT_EQ (model->parent (model->index (1, 0, inv2PairIndex)).internalId () == inv2PairIndex.internalId (), true); } -#endif diff --git a/src/laybasic/unit_tests/unit_tests.pro b/src/laybasic/unit_tests/unit_tests.pro index 0248f532a..2fd4d74af 100644 --- a/src/laybasic/unit_tests/unit_tests.pro +++ b/src/laybasic/unit_tests/unit_tests.pro @@ -16,11 +16,17 @@ SOURCES = \ layPixelBufferTests.cc \ layLayoutViewTests.cc \ layRenderer.cc \ - layNetlistBrowserModelTests.cc \ - layNetlistBrowserTreeModelTests.cc \ layAbstractMenuTests.cc \ laySnapTests.cc +!equals(HAVE_QT, "0") { + + SOURCES += \ + layNetlistBrowserModelTests.cc \ + layNetlistBrowserTreeModelTests.cc \ + +} + INCLUDEPATH += $$TL_INC $$LAYBASIC_INC $$DB_INC $$GSI_INC $$OUT_PWD/../laybasic DEPENDPATH += $$TL_INC $$LAYBASIC_INC $$DB_INC $$GSI_INC $$OUT_PWD/../laybasic From 37a42b70db6d95fc8b0713b4be5252b10729ea90 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 8 May 2022 19:44:14 +0200 Subject: [PATCH 45/88] WIP: edt enabled for Qt-less --- src/edt/edt/edt.pro | 92 ++-- src/edt/edt/edtConfig.cc | 2 +- src/edt/edt/edtMainService.cc | 439 ++++++++++-------- src/edt/edt/edtMainService.h | 4 + src/edt/edt/edtPartialService.cc | 39 +- src/edt/edt/edtPartialService.h | 18 +- src/edt/edt/edtPlugin.cc | 154 ++++-- src/edt/edt/edtService.cc | 91 ++-- src/edt/edt/edtService.h | 8 +- src/edt/edt/edtServiceImpl.cc | 94 ++-- src/edt/edt/edtServiceImpl.h | 12 + src/edt/edt/edtUtils.h | 2 - src/klayout.pro | 20 +- src/laybasic/laybasic/layEditorServiceBase.cc | 13 + src/laybasic/laybasic/layEditorServiceBase.h | 5 + src/laybasic/laybasic/laybasic.pro | 4 +- 16 files changed, 594 insertions(+), 403 deletions(-) diff --git a/src/edt/edt/edt.pro b/src/edt/edt/edt.pro index 5515e57c8..6f2e989af 100644 --- a/src/edt/edt/edt.pro +++ b/src/edt/edt/edt.pro @@ -6,62 +6,70 @@ include($$PWD/../../lib.pri) DEFINES += MAKE_EDT_LIBRARY -HEADERS = \ - edtConfig.h \ - edtDialogs.h \ - edtEditorOptionsPages.h \ - edtInstPropertiesPage.h \ - edtMainService.h \ - edtPartialService.h \ - edtPCellParametersPage.h \ - edtPlugin.h \ - edtPropertiesPages.h \ - edtPropertiesPageUtils.h \ - edtService.h \ - edtServiceImpl.h \ - edtUtils.h \ - edtCommon.h \ - edtDistribute.h \ +!equals(HAVE_QT, "0") { + + HEADERS = \ + edtDialogs.h \ + edtEditorOptionsPages.h \ + edtInstPropertiesPage.h \ + edtPCellParametersPage.h \ + edtPropertiesPages.h \ + edtPropertiesPageUtils.h \ edtRecentConfigurationPage.h -FORMS = \ - AlignOptionsDialog.ui \ - BoxPropertiesPage.ui \ - CopyModeDialog.ui \ - ChangeLayerOptionsDialog.ui \ - EditablePathPropertiesPage.ui \ - EditorOptionsGeneric.ui \ - EditorOptionsInst.ui \ - EditorOptionsPath.ui \ - EditorOptionsText.ui \ - InstantiationForm.ui \ - InstPropertiesPage.ui \ - MakeArrayOptionsDialog.ui \ - MakeCellOptionsDialog.ui \ - PathPropertiesPage.ui \ - PolygonPropertiesPage.ui \ - RoundCornerOptionsDialog.ui \ - TextPropertiesPage.ui \ + FORMS = \ + AlignOptionsDialog.ui \ + BoxPropertiesPage.ui \ + CopyModeDialog.ui \ + ChangeLayerOptionsDialog.ui \ + EditablePathPropertiesPage.ui \ + EditorOptionsGeneric.ui \ + EditorOptionsInst.ui \ + EditorOptionsPath.ui \ + EditorOptionsText.ui \ + InstantiationForm.ui \ + InstPropertiesPage.ui \ + MakeArrayOptionsDialog.ui \ + MakeCellOptionsDialog.ui \ + PathPropertiesPage.ui \ + PolygonPropertiesPage.ui \ + RoundCornerOptionsDialog.ui \ + TextPropertiesPage.ui \ DistributeOptionsDialog.ui \ EditorOptionsInstPCellParam.ui + SOURCES = \ + edtDialogs.cc \ + edtEditorOptionsPages.cc \ + edtInstPropertiesPage.cc \ + edtPCellParametersPage.cc \ + edtPropertiesPages.cc \ + edtPropertiesPageUtils.cc \ + edtRecentConfigurationPage.cc + +} + +HEADERS = \ + edtConfig.h \ + edtMainService.h \ + edtPartialService.h \ + edtPlugin.h \ + edtService.h \ + edtServiceImpl.h \ + edtUtils.h \ + edtCommon.h \ + edtDistribute.h \ + SOURCES = \ edtConfig.cc \ - edtDialogs.cc \ - edtEditorOptionsPages.cc \ - edtInstPropertiesPage.cc \ edtMainService.cc \ edtPartialService.cc \ - edtPCellParametersPage.cc \ edtPlugin.cc \ - edtPropertiesPages.cc \ - edtPropertiesPageUtils.cc \ edtService.cc \ edtServiceImpl.cc \ edtUtils.cc \ gsiDeclEdt.cc \ - edtDistribute.cc \ - edtRecentConfigurationPage.cc + edtDistribute.cc \ INCLUDEPATH += $$TL_INC $$GSI_INC $$LAYBASIC_INC $$DB_INC DEPENDPATH += $$TL_INC $$GSI_INC $$LAYBASIC_INC $$DB_INC diff --git a/src/edt/edt/edtConfig.cc b/src/edt/edt/edtConfig.cc index 782c7718e..b33601771 100644 --- a/src/edt/edt/edtConfig.cc +++ b/src/edt/edt/edtConfig.cc @@ -289,7 +289,7 @@ EditGridConverter::from_string_picky (const std::string &s, db::DVector &eg) y = x; } if (x < 1e-6 || y < 1e-6) { - throw tl::Exception (tl::to_string (QObject::tr ("The grid must be larger than zero"))); + throw tl::Exception (tl::to_string (tr ("The grid must be larger than zero"))); } eg = db::DVector (x, y); } diff --git a/src/edt/edt/edtMainService.cc b/src/edt/edt/edtMainService.cc index beeefcdab..99a39e017 100644 --- a/src/edt/edt/edtMainService.cc +++ b/src/edt/edt/edtMainService.cc @@ -21,33 +21,37 @@ */ -#include - #include "dbEdgeProcessor.h" #include "dbPolygonTools.h" #include "dbLibrary.h" #include "dbLibraryManager.h" #include "tlExceptions.h" #include "layLayoutView.h" -#include "layDialogs.h" #include "laySelector.h" -#include "layCellSelectionForm.h" #include "layFinder.h" #include "layLayerProperties.h" -#include "layLayerTreeModel.h" #include "tlProgress.h" #include "edtPlugin.h" #include "edtMainService.h" #include "edtService.h" #include "edtServiceImpl.h" #include "edtConfig.h" -#include "edtDialogs.h" -#include "edtEditorOptionsPages.h" #include "edtDistribute.h" -#include -#include -#include +#if defined(HAVE_QT) +# include "layDialogs.h" +# include "layLayerTreeModel.h" +# include "layCellSelectionForm.h" +# include "edtDialogs.h" +# include "edtEditorOptionsPages.h" +#endif + +#if defined(HAVE_QT) +# include +# include +# include +# include +#endif namespace edt { @@ -73,15 +77,16 @@ MainService::MainService (db::Manager *manager, lay::LayoutView *view, lay::Disp m_origin_mode_x (-1), m_origin_mode_y (-1), m_origin_visible_layers_for_bbox (false), m_array_a (0.0, 1.0), m_array_b (1.0, 0.0), m_array_na (1), m_array_nb (1), - m_router (0.0), m_rinner (0.0), m_npoints (64), m_undo_before_apply (true), - mp_round_corners_dialog (0), - mp_align_options_dialog (0), - mp_distribute_options_dialog (0), - mp_flatten_inst_options_dialog (0), - mp_make_cell_options_dialog (0), - mp_make_array_options_dialog (0) + m_router (0.0), m_rinner (0.0), m_npoints (64), m_undo_before_apply (true) { - // .. nothing yet .. +#if defined(HAVE_QT) + mp_round_corners_dialog = 0; + mp_align_options_dialog = 0; + mp_distribute_options_dialog = 0; + mp_flatten_inst_options_dialog = 0; + mp_make_cell_options_dialog = 0; + mp_make_array_options_dialog = 0; +#endif } MainService::~MainService () @@ -89,6 +94,8 @@ MainService::~MainService () // .. nothing yet .. } +#if defined(HAVE_QT) + edt::RoundCornerOptionsDialog * MainService::round_corners_dialog () { @@ -143,6 +150,8 @@ MainService::make_array_options_dialog () return mp_make_array_options_dialog; } +#endif + void MainService::menu_activated (const std::string &symbol) { @@ -298,10 +307,10 @@ MainService::cm_descend () } if (! common_inst.anything ()) { - throw tl::Exception (tl::to_string (QObject::tr ("Select an object to determine into which instance to descend"))); + throw tl::Exception (tl::to_string (tr ("Select an object to determine into which instance to descend"))); } if (! common_inst.valid () || common_inst.ambiguous ()) { - throw tl::Exception (tl::to_string (QObject::tr ("Selection is ambiguous - cannot determine into which instance to descend"))); + throw tl::Exception (tl::to_string (tr ("Selection is ambiguous - cannot determine into which instance to descend"))); } // remove the common path and create a new set of selections @@ -391,56 +400,58 @@ MainService::cm_flatten_insts () tl_assert (view ()->is_editable ()); check_no_guiding_shapes (); - if (flatten_inst_options_dialog ()->exec_dialog (m_flatten_insts_levels, m_flatten_prune) && m_flatten_insts_levels != 0) { +#if defined(HAVE_QT) + if (! (flatten_inst_options_dialog ()->exec_dialog (m_flatten_insts_levels, m_flatten_prune) && m_flatten_insts_levels != 0)) { + return + } +#endif - view ()->cancel_edits (); + view ()->cancel_edits (); - manager ()->transaction (tl::to_string (QObject::tr ("Flatten instances"))); + manager ()->transaction (tl::to_string (tr ("Flatten instances"))); - std::set needs_cleanup; + std::set needs_cleanup; - std::vector edt_services = view ()->get_plugins (); - for (std::vector::const_iterator es = edt_services.begin (); es != edt_services.end (); ++es) { + std::vector edt_services = view ()->get_plugins (); + for (std::vector::const_iterator es = edt_services.begin (); es != edt_services.end (); ++es) { - for (edt::Service::objects::const_iterator r = (*es)->selection ().begin (); r != (*es)->selection ().end (); ++r) { + for (edt::Service::objects::const_iterator r = (*es)->selection ().begin (); r != (*es)->selection ().end (); ++r) { - const lay::CellView &cv = view ()->cellview (r->cv_index ()); - if (cv.is_valid ()) { + const lay::CellView &cv = view ()->cellview (r->cv_index ()); + if (cv.is_valid ()) { - db::Cell &target_cell = cv->layout ().cell (r->cell_index ()); - if (r->is_cell_inst () && target_cell.is_valid (r->back ().inst_ptr)) { - - // because we select whole arrays in editable mode, we can iterator over them - db::CellInstArray cell_inst = r->back ().inst_ptr.cell_inst (); - for (db::CellInstArray::iterator a = cell_inst.begin (); ! a.at_end (); ++a) { - cv->layout ().flatten (cv->layout ().cell (r->cell_index_tot ()), target_cell, cell_inst.complex_trans (*a), m_flatten_insts_levels < 0 ? m_flatten_insts_levels : m_flatten_insts_levels - 1); - } - - if (cv->layout ().cell (r->back ().inst_ptr.cell_index ()).is_proxy ()) { - needs_cleanup.insert (& cv->layout ()); - } - - target_cell.erase (r->back ().inst_ptr); + db::Cell &target_cell = cv->layout ().cell (r->cell_index ()); + if (r->is_cell_inst () && target_cell.is_valid (r->back ().inst_ptr)) { + // because we select whole arrays in editable mode, we can iterator over them + db::CellInstArray cell_inst = r->back ().inst_ptr.cell_inst (); + for (db::CellInstArray::iterator a = cell_inst.begin (); ! a.at_end (); ++a) { + cv->layout ().flatten (cv->layout ().cell (r->cell_index_tot ()), target_cell, cell_inst.complex_trans (*a), m_flatten_insts_levels < 0 ? m_flatten_insts_levels : m_flatten_insts_levels - 1); } + if (cv->layout ().cell (r->back ().inst_ptr.cell_index ()).is_proxy ()) { + needs_cleanup.insert (& cv->layout ()); + } + + target_cell.erase (r->back ().inst_ptr); + } } } - // clean up the layouts that need to do so. - for (std::set::const_iterator l = needs_cleanup.begin (); l != needs_cleanup.end (); ++l) { - (*l)->cleanup (); - } - - // The selection is no longer valid - view ()->clear_selection (); - - manager ()->commit (); - } + + // clean up the layouts that need to do so. + for (std::set::const_iterator l = needs_cleanup.begin (); l != needs_cleanup.end (); ++l) { + (*l)->cleanup (); + } + + // The selection is no longer valid + view ()->clear_selection (); + + manager ()->commit (); } void @@ -449,7 +460,7 @@ MainService::cm_move_hier_up () view ()->cancel_edits (); check_no_guiding_shapes (); - manager ()->transaction (tl::to_string (QObject::tr ("Move up in hierarchy"))); + manager ()->transaction (tl::to_string (tr ("Move up in hierarchy"))); std::vector edt_services = view ()->get_plugins (); for (std::vector::const_iterator es = edt_services.begin (); es != edt_services.end (); ++es) { @@ -691,7 +702,7 @@ MainService::cm_make_cell_variants () if (cv_index < 0) { cv_index = r->cv_index (); } else if (cv_index != int (r->cv_index ())) { - throw tl::Exception (tl::to_string (QObject::tr ("The selection must not contain objects from different layouts for 'make cell variants'"))); + throw tl::Exception (tl::to_string (tr ("The selection must not contain objects from different layouts for 'make cell variants'"))); } } } @@ -705,7 +716,7 @@ MainService::cm_make_cell_variants () view ()->cancel_edits (); - manager ()->transaction (tl::to_string (QObject::tr ("Make cell variants for selection"))); + manager ()->transaction (tl::to_string (tr ("Make cell variants for selection"))); std::vector new_selection; for (std::vector::const_iterator es = edt_services.begin (); es != edt_services.end (); ++es) { @@ -716,7 +727,7 @@ MainService::cm_make_cell_variants () // TODO: the algorithm is basically O(2) in the number of selected items. A first // step to mitigate that problem is to provide a progress and hence a way to cancel it. - tl::RelativeProgress progress (tl::to_string (QObject::tr ("Make cell variants for selection")), num_sel, 1); + tl::RelativeProgress progress (tl::to_string (tr ("Make cell variants for selection")), num_sel, 1); for (size_t nsel = 0; nsel < num_sel; ++nsel) { @@ -901,7 +912,7 @@ MainService::cm_resolve_arefs () cv_index = r->cv_index (); } else if (cv_index != int (r->cv_index ())) { // TODO: this limitation is not really necessary, but makes the code somewhat simpler - throw tl::Exception (tl::to_string (QObject::tr ("The selection must not contain objects from different layouts for 'resolve array references'"))); + throw tl::Exception (tl::to_string (tr ("The selection must not contain objects from different layouts for 'resolve array references'"))); } insts_to_resolve.push_back (*r); } @@ -917,7 +928,7 @@ MainService::cm_resolve_arefs () std::vector new_selection; - manager ()->transaction (tl::to_string (QObject::tr ("Resolve array references"))); + manager ()->transaction (tl::to_string (tr ("Resolve array references"))); for (std::vector::const_iterator p = insts_to_resolve.begin (); p != insts_to_resolve.end (); ++p) { @@ -972,7 +983,7 @@ MainService::cm_make_cell () if (cv_index < 0) { cv_index = r->cv_index (); } else if (cv_index != int (r->cv_index ())) { - throw tl::Exception (tl::to_string (QObject::tr ("The selection must not contain objects from different layouts for 'make cell'"))); + throw tl::Exception (tl::to_string (tr ("The selection must not contain objects from different layouts for 'make cell'"))); } } } @@ -981,80 +992,82 @@ MainService::cm_make_cell () const lay::CellView &cv = view ()->cellview (cv_index); - if (make_cell_options_dialog ()->exec_dialog (cv->layout (), m_make_cell_name, m_origin_mode_x, m_origin_mode_y)) { +#if defined(HAVE_QT) + if (! make_cell_options_dialog ()->exec_dialog (cv->layout (), m_make_cell_name, m_origin_mode_x, m_origin_mode_y)) { + return; + } + #endif - // Compute the selection's bbox to establish a good origin for the new cell - db::Box selection_bbox; - db::box_convert bc (cv->layout ()); - for (std::vector::const_iterator es = edt_services.begin (); es != edt_services.end (); ++es) { - for (edt::Service::objects::const_iterator r = (*es)->selection ().begin (); r != (*es)->selection ().end (); ++r) { - if (r->is_cell_inst ()) { - selection_bbox += db::ICplxTrans (r->trans ()) * r->back ().bbox (bc); - } else { - selection_bbox += db::ICplxTrans (r->trans ()) * r->shape ().bbox (); - } + // Compute the selection's bbox to establish a good origin for the new cell + db::Box selection_bbox; + db::box_convert bc (cv->layout ()); + for (std::vector::const_iterator es = edt_services.begin (); es != edt_services.end (); ++es) { + for (edt::Service::objects::const_iterator r = (*es)->selection ().begin (); r != (*es)->selection ().end (); ++r) { + if (r->is_cell_inst ()) { + selection_bbox += db::ICplxTrans (r->trans ()) * r->back ().bbox (bc); + } else { + selection_bbox += db::ICplxTrans (r->trans ()) * r->shape ().bbox (); } } + } - if (selection_bbox.empty ()) { - throw tl::Exception (tl::to_string (QObject::tr ("The selection is empty. Cannot create a cell from an empty selection."))); - } + if (selection_bbox.empty ()) { + throw tl::Exception (tl::to_string (tr ("The selection is empty. Cannot create a cell from an empty selection."))); + } - view ()->cancel_edits (); + view ()->cancel_edits (); - manager ()->transaction (tl::to_string (QObject::tr ("Make cell from selection"))); + manager ()->transaction (tl::to_string (tr ("Make cell from selection"))); - db::cell_index_type target_ci = cv->layout ().add_cell (m_make_cell_name.c_str ()); - // create target cell - db::Cell &target_cell = cv->layout ().cell (target_ci); + db::cell_index_type target_ci = cv->layout ().add_cell (m_make_cell_name.c_str ()); + // create target cell + db::Cell &target_cell = cv->layout ().cell (target_ci); - // create target cell instance - db::Vector ref; - if (m_origin_mode_x >= -1) { - ref = db::Vector (selection_bbox.left () + ((m_origin_mode_x + 1) * selection_bbox.width ()) / 2, selection_bbox.bottom () + ((m_origin_mode_y + 1) * selection_bbox.height ()) / 2); - } + // create target cell instance + db::Vector ref; + if (m_origin_mode_x >= -1) { + ref = db::Vector (selection_bbox.left () + ((m_origin_mode_x + 1) * selection_bbox.width ()) / 2, selection_bbox.bottom () + ((m_origin_mode_y + 1) * selection_bbox.height ()) / 2); + } - db::Instance target_cell_inst = cv.cell ()->insert (db::CellInstArray (db::CellInst (target_ci), db::Trans (ref))); - db::ICplxTrans to = db::ICplxTrans (db::Trans (-ref)); + db::Instance target_cell_inst = cv.cell ()->insert (db::CellInstArray (db::CellInst (target_ci), db::Trans (ref))); + db::ICplxTrans to = db::ICplxTrans (db::Trans (-ref)); - for (std::vector::const_iterator es = edt_services.begin (); es != edt_services.end (); ++es) { + for (std::vector::const_iterator es = edt_services.begin (); es != edt_services.end (); ++es) { - for (edt::Service::objects::const_iterator r = (*es)->selection ().begin (); r != (*es)->selection ().end (); ++r) { + for (edt::Service::objects::const_iterator r = (*es)->selection ().begin (); r != (*es)->selection ().end (); ++r) { - if (r->is_cell_inst ()) { + if (r->is_cell_inst ()) { - db::Instance new_inst = target_cell.insert (r->back ().inst_ptr); - target_cell.transform (new_inst, to * db::ICplxTrans (r->trans ())); + db::Instance new_inst = target_cell.insert (r->back ().inst_ptr); + target_cell.transform (new_inst, to * db::ICplxTrans (r->trans ())); - } else { + } else { - db::Shapes &target_shapes = target_cell.shapes (r->layer ()); - db::Shape new_shape = target_shapes.insert (r->shape ()); - target_shapes.transform (new_shape, to * db::ICplxTrans (r->trans ())); - - } + db::Shapes &target_shapes = target_cell.shapes (r->layer ()); + db::Shape new_shape = target_shapes.insert (r->shape ()); + target_shapes.transform (new_shape, to * db::ICplxTrans (r->trans ())); } - // delete all the objects currently selected and set the new selection - (*es)->del_selected (); - - // establish the new instance as selection for the instance service - std::vector new_selection; - if ((*es)->flags () == db::ShapeIterator::Nothing) { - new_selection.push_back (lay::ObjectInstPath ()); - new_selection.back ().set_topcell (cv.cell_index ()); - new_selection.back ().set_cv_index (cv_index); - new_selection.back ().add_path (db::InstElement (target_cell_inst)); - } - (*es)->set_selection (new_selection.begin (), new_selection.end ()); - } - manager ()->commit (); + // delete all the objects currently selected and set the new selection + (*es)->del_selected (); + + // establish the new instance as selection for the instance service + std::vector new_selection; + if ((*es)->flags () == db::ShapeIterator::Nothing) { + new_selection.push_back (lay::ObjectInstPath ()); + new_selection.back ().set_topcell (cv.cell_index ()); + new_selection.back ().set_cv_index (cv_index); + new_selection.back ().add_path (db::InstElement (target_cell_inst)); + } + (*es)->set_selection (new_selection.begin (), new_selection.end ()); } + manager ()->commit (); + } } @@ -1069,7 +1082,7 @@ MainService::cm_convert_to_cell () try { - manager ()->transaction (tl::to_string (QObject::tr ("Convert to static cell"))); + manager ()->transaction (tl::to_string (tr ("Convert to static cell"))); std::vector edt_services = view ()->get_plugins (); @@ -1110,7 +1123,7 @@ MainService::cm_convert_to_cell () } if (needs_cleanup.empty ()) { - throw tl::Exception (tl::to_string (QObject::tr ("No instance of a PCell or library cell selected - nothing to convert"))); + throw tl::Exception (tl::to_string (tr ("No instance of a PCell or library cell selected - nothing to convert"))); } // clean up the layouts that need to do so. @@ -1132,6 +1145,7 @@ MainService::cm_convert_to_cell () void MainService::cm_convert_to_pcell () { +#if defined(HAVE_QT) // @@@ tl_assert (view ()->is_editable ()); check_no_guiding_shapes (); @@ -1143,7 +1157,7 @@ MainService::cm_convert_to_pcell () num_selected += (*es)->selection ().size (); for (edt::Service::obj_iterator s = (*es)->selection ().begin (); s != (*es)->selection ().end (); ++s) { if (s->is_cell_inst ()) { - throw tl::Exception (tl::to_string (QObject::tr ("Selection contains instances - they cannot be converted to PCells."))); + throw tl::Exception (tl::to_string (tr ("Selection contains instances - they cannot be converted to PCells."))); } } } @@ -1189,8 +1203,8 @@ MainService::cm_convert_to_pcell () bool ok = false; QString item = QInputDialog::getItem (view ()->widget (), - QObject::tr ("Select Target PCell"), - QObject::tr ("Select the PCell the shape should be converted into"), + tr ("Select Target PCell"), + tr ("Select the PCell the shape should be converted into"), items, 0, false, &ok); if (! ok) { return; @@ -1210,7 +1224,7 @@ MainService::cm_convert_to_pcell () try { - manager ()->transaction (tl::to_string (QObject::tr ("Convert to PCell"))); + manager ()->transaction (tl::to_string (tr ("Convert to PCell"))); std::vector to_delete; std::vector new_selection; @@ -1219,7 +1233,7 @@ MainService::cm_convert_to_pcell () bool any_converted = false; { - tl::RelativeProgress progress (tl::to_string (QObject::tr ("Convert to PCell")), num_selected, 1000); + tl::RelativeProgress progress (tl::to_string (tr ("Convert to PCell")), num_selected, 1000); // convert the shapes which can be converted for (std::vector::const_iterator es = edt_services.begin (); es != edt_services.end (); ++es) { @@ -1267,7 +1281,7 @@ MainService::cm_convert_to_pcell () } if (! any_converted) { - throw tl::Exception (tl::to_string (QObject::tr ("None of the shapes could be converted to the desired PCell"))); + throw tl::Exception (tl::to_string (tr ("None of the shapes could be converted to the desired PCell"))); } // Delete the shapes which have been converted @@ -1290,7 +1304,7 @@ MainService::cm_convert_to_pcell () } if (any_non_converted) { - QMessageBox::warning (view ()->widget (), QObject::tr ("Warning"), QObject::tr ("Some of the shapes could not be converted to the desired PCell")); + QMessageBox::warning (view ()->widget (), tr ("Warning"), tr ("Some of the shapes could not be converted to the desired PCell")); } manager ()->commit (); @@ -1299,6 +1313,7 @@ MainService::cm_convert_to_pcell () manager ()->commit (); throw; } +#endif } static bool extract_rad (std::vector &poly, double &rinner, double &router, unsigned int &n) @@ -1361,12 +1376,12 @@ MainService::cm_round_corners () if (! s->is_cell_inst () && (s->shape ().is_polygon () || s->shape ().is_path () || s->shape ().is_box ())) { if (cv_index >= 0 && cv_index != int (s->cv_index ())) { - throw tl::Exception (tl::to_string (QObject::tr ("Selection originates from different layouts - cannot compute result in this case."))); + throw tl::Exception (tl::to_string (tr ("Selection originates from different layouts - cannot compute result in this case."))); } cv_index = int (s->cv_index ()); if (layer_index >= 0 && layer_index != int (s->layer ())) { - throw tl::Exception (tl::to_string (QObject::tr ("Selection originates from different layers - cannot compute result in this case."))); + throw tl::Exception (tl::to_string (tr ("Selection originates from different layers - cannot compute result in this case."))); } layer_index = int (s->layer ()); @@ -1380,7 +1395,7 @@ MainService::cm_round_corners () } if (cv_index < 0 || layer_index < 0) { - throw tl::Exception (tl::to_string (QObject::tr ("Selection does not contain polygons"))); + throw tl::Exception (tl::to_string (tr ("Selection does not contain polygons"))); } // prepare: merge to remove cutlines and smooth to remove effects of cutlines @@ -1403,9 +1418,11 @@ MainService::cm_round_corners () rinner *= dbu; router *= dbu; +#if defined(HAVE_QT) if (! round_corners_dialog ()->exec_dialog (cv->layout (), m_router, m_rinner, m_npoints, m_undo_before_apply, router, rinner, n, has_extracted)) { return; } +#endif if (! m_undo_before_apply || ! has_extracted) { out.swap (in); @@ -1420,7 +1437,7 @@ MainService::cm_round_corners () ep.merge (out, primary, 0 /*min_wc*/, true /*resolve holes*/, true /*min coherence*/); view ()->cancel_edits (); - manager ()->transaction (tl::to_string (QObject::tr ("Corner rounding operation on selection"))); + manager ()->transaction (tl::to_string (tr ("Corner rounding operation on selection"))); // Delete the current selection for (std::vector::const_iterator es = edt_services.begin (); es != edt_services.end (); ++es) { @@ -1466,6 +1483,7 @@ MainService::cm_round_corners () void MainService::cm_size () { +#if defined(HAVE_QT) // @@@ tl_assert (view ()->is_editable ()); check_no_guiding_shapes (); @@ -1483,12 +1501,12 @@ MainService::cm_size () if (! s->is_cell_inst () && (s->shape ().is_polygon () || s->shape ().is_path () || s->shape ().is_box ())) { if (cv_index >= 0 && cv_index != int (s->cv_index ())) { - throw tl::Exception (tl::to_string (QObject::tr ("Selection originates from different layouts - cannot compute result in this case."))); + throw tl::Exception (tl::to_string (tr ("Selection originates from different layouts - cannot compute result in this case."))); } cv_index = int (s->cv_index ()); if (layer_index >= 0 && layer_index != int (s->layer ())) { - throw tl::Exception (tl::to_string (QObject::tr ("Selection originates from different layers - cannot compute result in this case."))); + throw tl::Exception (tl::to_string (tr ("Selection originates from different layers - cannot compute result in this case."))); } layer_index = int (s->layer ()); @@ -1502,13 +1520,13 @@ MainService::cm_size () } if (cv_index < 0 || layer_index < 0) { - throw tl::Exception (tl::to_string (QObject::tr ("Selection does not contain polygons"))); + throw tl::Exception (tl::to_string (tr ("Selection does not contain polygons"))); } bool ok = false; QString s = QInputDialog::getText (view ()->widget (), - QObject::tr ("Sizing"), - QObject::tr ("Sizing (in micron, positive or negative). Two values (dx, dy) for anisotropic sizing."), + tr ("Sizing"), + tr ("Sizing (in micron, positive or negative). Two values (dx, dy) for anisotropic sizing."), QLineEdit::Normal, QString::fromUtf8 ("0.0"), &ok); @@ -1536,7 +1554,7 @@ MainService::cm_size () ep.size (primary, idx, idy, out, 2 /*mode, TODO: make variable*/, true /*resolve holes*/, true /*min coherence*/); view ()->cancel_edits (); - manager ()->transaction (tl::to_string (QObject::tr ("Sizing operation on selection"))); + manager ()->transaction (tl::to_string (tr ("Sizing operation on selection"))); // Delete the current selection for (std::vector::const_iterator es = edt_services.begin (); es != edt_services.end (); ++es) { @@ -1577,6 +1595,7 @@ MainService::cm_size () } manager ()->commit (); +#endif } void @@ -1599,12 +1618,12 @@ MainService::boolean_op (int mode) if (s->seq () == 0 && ! s->is_cell_inst () && (s->shape ().is_polygon () || s->shape ().is_path () || s->shape ().is_box ())) { if (cv_index >= 0 && cv_index != int (s->cv_index ())) { - throw tl::Exception (tl::to_string (QObject::tr ("Primary selection originates from different layouts - cannot compute result in this case."))); + throw tl::Exception (tl::to_string (tr ("Primary selection originates from different layouts - cannot compute result in this case."))); } cv_index = int (s->cv_index ()); if (layer_index >= 0 && layer_index != int (s->layer ())) { - throw tl::Exception (tl::to_string (QObject::tr ("Primary selection originates from different layers - cannot compute result in this case."))); + throw tl::Exception (tl::to_string (tr ("Primary selection originates from different layers - cannot compute result in this case."))); } layer_index = int (s->layer ()); @@ -1618,7 +1637,7 @@ MainService::boolean_op (int mode) } if (cv_index < 0 || layer_index < 0) { - throw tl::Exception (tl::to_string (QObject::tr ("Primary selection does not contain polygons"))); + throw tl::Exception (tl::to_string (tr ("Primary selection does not contain polygons"))); } std::vector secondary; @@ -1656,7 +1675,7 @@ MainService::boolean_op (int mode) } view ()->cancel_edits (); - manager ()->transaction (tl::to_string (QObject::tr ("Boolean operation on selection"))); + manager ()->transaction (tl::to_string (tr ("Boolean operation on selection"))); // Delete the current selection // NOTE: we delete only those shapes from the primary layer and keep shapes from other layers. @@ -1780,9 +1799,11 @@ MainService::cm_align () std::vector edt_services = view ()->get_plugins (); +#if defined(HAVE_QT) if (! align_options_dialog ()->exec_dialog (m_align_hmode, m_align_vmode, m_align_visible_layers)) { return; } +#endif db::DBox prim_box; bool has_secondary = false; @@ -1812,7 +1833,7 @@ MainService::cm_align () if (! prim_box.empty ()) { view ()->cancel_edits (); - manager ()->transaction (tl::to_string (QObject::tr ("Alignment"))); + manager ()->transaction (tl::to_string (tr ("Alignment"))); // do the alignment for (std::vector::const_iterator es = edt_services.begin (); es != edt_services.end (); ++es) { @@ -1866,11 +1887,13 @@ MainService::cm_distribute () std::vector edt_services = view ()->get_plugins (); +#if defined(HAVE_QT) if (! distribute_options_dialog ()->exec_dialog (m_hdistribute, m_distribute_hmode, m_distribute_hpitch, m_distribute_hspace, m_vdistribute, m_distribute_vmode, m_distribute_vpitch, m_distribute_vspace, m_distribute_visible_layers)) { return; } +#endif if (! m_hdistribute && ! m_vdistribute) { return; @@ -1946,7 +1969,7 @@ MainService::cm_distribute () { view ()->cancel_edits (); - manager ()->transaction (tl::to_string (QObject::tr ("Distribution"))); + manager ()->transaction (tl::to_string (tr ("Distribution"))); // do the distribution for (std::vector::const_iterator es = edt_services.begin (); es != edt_services.end (); ++es) { @@ -1981,97 +2004,100 @@ MainService::cm_make_array () } if (n == 0) { - throw tl::Exception (tl::to_string (QObject::tr ("Nothing selected to make arrays of"))); + throw tl::Exception (tl::to_string (tr ("Nothing selected to make arrays of"))); } - if (make_array_options_dialog ()->exec_dialog (m_array_a, m_array_na, m_array_b, m_array_nb)) { +#if defined(HAVE_QT) + if (! make_array_options_dialog ()->exec_dialog (m_array_a, m_array_na, m_array_b, m_array_nb)) { + return; + } +#endif - view ()->cancel_edits (); + view ()->cancel_edits (); - // undo support for small arrays only - bool has_undo = (m_array_na * m_array_nb < 1000); + // undo support for small arrays only + bool has_undo = (m_array_na * m_array_nb < 1000); - // No undo support currently - the undo buffering is pretty inefficient right now. - if (! has_undo) { - manager ()->clear (); - } else { - manager ()->transaction (tl::to_string (QObject::tr ("Make array"))); - } + // No undo support currently - the undo buffering is pretty inefficient right now. + if (! has_undo) { + manager ()->clear (); + } else { + manager ()->transaction (tl::to_string (tr ("Make array"))); + } - tl::RelativeProgress progress (tl::to_string (QObject::tr ("Make array")), (size_t (m_array_na) * size_t (m_array_nb) - 1) * n, 1000); + tl::RelativeProgress progress (tl::to_string (tr ("Make array")), (size_t (m_array_na) * size_t (m_array_nb) - 1) * n, 1000); - for (std::vector::const_iterator es = edt_services.begin (); es != edt_services.end (); ++es) { + for (std::vector::const_iterator es = edt_services.begin (); es != edt_services.end (); ++es) { - for (edt::Service::obj_iterator s = (*es)->selection ().begin (); s != (*es)->selection ().end (); ++s) { + for (edt::Service::obj_iterator s = (*es)->selection ().begin (); s != (*es)->selection ().end (); ++s) { + + const lay::CellView &cv = view ()->cellview (s->cv_index ()); + if (! cv.is_valid ()) { + continue; + } + + db::Cell &target_cell = cv->layout ().cell (s->cell_index ()); + + if (s->is_cell_inst ()) { + + for (unsigned int ia = 0; ia < m_array_na; ++ia) { + for (unsigned int ib = 0; ib < m_array_nb; ++ib) { + + // don't create a copy + if (ia == 0 && ib == 0) { + continue; + } + + db::DCplxTrans dtrans (m_array_a * double (ia) + m_array_b * double (ib)); + db::ICplxTrans itrans (db::DCplxTrans (s->trans ()).inverted () * db::DCplxTrans (1.0 / cv->layout ().dbu ()) * dtrans * db::DCplxTrans (cv->layout ().dbu ()) * db::DCplxTrans (s->trans ())); + + db::Instance new_inst = target_cell.insert (s->back ().inst_ptr); + target_cell.transform (new_inst, itrans); + + ++progress; + + } - const lay::CellView &cv = view ()->cellview (s->cv_index ()); - if (! cv.is_valid ()) { - continue; } - db::Cell &target_cell = cv->layout ().cell (s->cell_index ()); + } else { - if (s->is_cell_inst ()) { + db::Shapes &target_shapes = target_cell.shapes (s->layer ()); - for (unsigned int ia = 0; ia < m_array_na; ++ia) { - for (unsigned int ib = 0; ib < m_array_nb; ++ib) { - - // don't create a copy - if (ia == 0 && ib == 0) { - continue; - } - - db::DCplxTrans dtrans (m_array_a * double (ia) + m_array_b * double (ib)); - db::ICplxTrans itrans (db::DCplxTrans (s->trans ()).inverted () * db::DCplxTrans (1.0 / cv->layout ().dbu ()) * dtrans * db::DCplxTrans (cv->layout ().dbu ()) * db::DCplxTrans (s->trans ())); - - db::Instance new_inst = target_cell.insert (s->back ().inst_ptr); - target_cell.transform (new_inst, itrans); - - ++progress; + for (unsigned int ia = 0; ia < m_array_na; ++ia) { + for (unsigned int ib = 0; ib < m_array_nb; ++ib) { + // don't create a copy + if (ia == 0 && ib == 0) { + continue; } + db::DCplxTrans dtrans (m_array_a * double (ia) + m_array_b * double (ib)); + db::ICplxTrans itrans (db::DCplxTrans (s->trans ()).inverted () * db::DCplxTrans (1.0 / cv->layout ().dbu ()) * dtrans * db::DCplxTrans (cv->layout ().dbu ()) * db::DCplxTrans (s->trans ())); + + db::Shape new_shape = target_shapes.insert (s->shape ()); + target_shapes.transform (new_shape, itrans); + + ++progress; + } - - } else { - - db::Shapes &target_shapes = target_cell.shapes (s->layer ()); - - for (unsigned int ia = 0; ia < m_array_na; ++ia) { - for (unsigned int ib = 0; ib < m_array_nb; ++ib) { - - // don't create a copy - if (ia == 0 && ib == 0) { - continue; - } - - db::DCplxTrans dtrans (m_array_a * double (ia) + m_array_b * double (ib)); - db::ICplxTrans itrans (db::DCplxTrans (s->trans ()).inverted () * db::DCplxTrans (1.0 / cv->layout ().dbu ()) * dtrans * db::DCplxTrans (cv->layout ().dbu ()) * db::DCplxTrans (s->trans ())); - - db::Shape new_shape = target_shapes.insert (s->shape ()); - target_shapes.transform (new_shape, itrans); - - ++progress; - - } - } - } } } - if (has_undo) { - manager ()->commit (); - } + } + if (has_undo) { + manager ()->commit (); } } void MainService::cm_tap () { +#if defined(HAVE_QT) // @@@ if (! view ()->view_object_widget ()->mouse_in_window ()) { return; } @@ -2134,6 +2160,7 @@ MainService::cm_tap () } } +#endif } void @@ -2147,7 +2174,7 @@ MainService::cm_change_layer () // get (common) cellview index of the selected shapes for (SelectionIterator s (view ()); ! s.at_end (); ++s) { if (cv_index >= 0 && cv_index != int (s->cv_index ())) { - throw tl::Exception (tl::to_string (QObject::tr ("Selections originate from different layouts - cannot switch layer in this case."))); + throw tl::Exception (tl::to_string (tr ("Selections originate from different layouts - cannot switch layer in this case."))); } cv_index = int (s->cv_index ()); } @@ -2159,24 +2186,24 @@ MainService::cm_change_layer () lay::LayerPropertiesConstIterator cl = view ()->current_layer (); if (cl.is_null ()) { - throw tl::Exception (tl::to_string (QObject::tr ("Please select a layer first")).c_str ()); + throw tl::Exception (tl::to_string (tr ("Please select a layer first")).c_str ()); } if (cv_index != cl->cellview_index ()) { - throw tl::Exception (tl::to_string (QObject::tr ("Shapes cannot be moved to a different layout")).c_str ()); + throw tl::Exception (tl::to_string (tr ("Shapes cannot be moved to a different layout")).c_str ()); } const lay::CellView &cv = view ()->cellview (cv_index); int layer = cl->layer_index (); if (! cv.is_valid ()) { - throw tl::Exception (tl::to_string (QObject::tr ("Please select a cell first")).c_str ()); + throw tl::Exception (tl::to_string (tr ("Please select a cell first")).c_str ()); } if (layer < 0 || ! cv->layout ().is_valid_layer ((unsigned int) layer)) { if (cl->has_children ()) { - throw tl::Exception (tl::to_string (QObject::tr ("Please select a valid drawing layer first")).c_str ()); + throw tl::Exception (tl::to_string (tr ("Please select a valid drawing layer first")).c_str ()); } else { // create this layer now @@ -2205,7 +2232,7 @@ MainService::cm_change_layer () view ()->cancel_edits (); - manager ()->transaction (tl::to_string (QObject::tr ("Change layer"))); + manager ()->transaction (tl::to_string (tr ("Change layer"))); db::Layout &layout = view ()->cellview (cv_index)->layout (); @@ -2266,7 +2293,7 @@ MainService::cm_change_layer () manager ()->commit (); } else { - throw tl::Exception (tl::to_string (QObject::tr ("Nothing selected to switch layers for"))); + throw tl::Exception (tl::to_string (tr ("Nothing selected to switch layers for"))); } } @@ -2279,7 +2306,7 @@ MainService::check_no_guiding_shapes () for (edt::Service::obj_iterator s = (*es)->selection ().begin (); s != (*es)->selection ().end (); ++s) { if (! s->is_cell_inst ()) { if (s->layer () == view ()->cellview (s->cv_index ())->layout ().guiding_shape_layer ()) { - throw tl::Exception (tl::to_string (QObject::tr ("This function cannot be applied to PCell guiding shapes"))); + throw tl::Exception (tl::to_string (tr ("This function cannot be applied to PCell guiding shapes"))); } } } @@ -2376,7 +2403,7 @@ MainService::paste () if (value) { if (! cv.is_valid ()) { - throw tl::Exception (tl::to_string (QObject::tr ("No cell selected to paste something into"))); + throw tl::Exception (tl::to_string (tr ("No cell selected to paste something into"))); } std::vector nl = value->get ().insert (cv->layout (), cv.context_trans ().inverted (), &cv->layout ().cell (cv.cell_index ()), 0 /*new_tops*/, &insert_notification); diff --git a/src/edt/edt/edtMainService.h b/src/edt/edt/edtMainService.h index 60c8c4a8f..87d74e307 100644 --- a/src/edt/edt/edtMainService.h +++ b/src/edt/edt/edtMainService.h @@ -221,21 +221,25 @@ private: double m_router, m_rinner; unsigned int m_npoints; bool m_undo_before_apply; +#if defined(HAVE_QT) edt::RoundCornerOptionsDialog *mp_round_corners_dialog; edt::AlignOptionsDialog *mp_align_options_dialog; edt::DistributeOptionsDialog *mp_distribute_options_dialog; lay::FlattenInstOptionsDialog *mp_flatten_inst_options_dialog; edt::MakeCellOptionsDialog *mp_make_cell_options_dialog; edt::MakeArrayOptionsDialog *mp_make_array_options_dialog; +#endif void boolean_op (int mode); void check_no_guiding_shapes (); +#if defined(HAVE_QT) edt::RoundCornerOptionsDialog *round_corners_dialog (); edt::AlignOptionsDialog *align_options_dialog (); edt::DistributeOptionsDialog *distribute_options_dialog (); lay::FlattenInstOptionsDialog *flatten_inst_options_dialog (); edt::MakeCellOptionsDialog *make_cell_options_dialog (); edt::MakeArrayOptionsDialog *make_array_options_dialog (); +#endif }; } diff --git a/src/edt/edt/edtPartialService.cc b/src/edt/edt/edtPartialService.cc index a22882651..91bd17582 100644 --- a/src/edt/edt/edtPartialService.cc +++ b/src/edt/edt/edtPartialService.cc @@ -21,8 +21,6 @@ */ -#include - #include "dbVector.h" #include "layLayoutView.h" #include "laySnap.h" @@ -31,9 +29,12 @@ #include "edtPartialService.h" #include "edtService.h" #include "edtConfig.h" -#include "edtDialogs.h" #include "edtPlugin.h" -#include "edtEditorOptionsPages.h" + +#if defined(HAVE_QT) +# include "edtDialogs.h" +# include "edtEditorOptionsPages.h" +#endif #include @@ -1010,8 +1011,10 @@ PartialShapeFinder::visit_cell (const db::Cell &cell, const db::Box &search_box, // ----------------------------------------------------------------------------- // Main Service implementation -PartialService::PartialService (db::Manager *manager, lay::LayoutView *view, lay::Dispatcher *root) - : QObject (), +PartialService::PartialService (db::Manager *manager, lay::LayoutView *view, lay::Dispatcher *root) : +#if defined(HAVE_QT) + QObject (), +#endif lay::EditorServiceBase (view), db::Object (manager), mp_view (view), @@ -1027,9 +1030,11 @@ PartialService::PartialService (db::Manager *manager, lay::LayoutView *view, lay m_hover (false), m_hover_wait (false) { +#if defined(HAVE_QT) m_timer.setInterval (100 /*hover time*/); m_timer.setSingleShot (true); connect (&m_timer, SIGNAL (timeout ()), this, SLOT (timeout ())); +#endif } PartialService::~PartialService () @@ -1077,7 +1082,9 @@ void PartialService::hover_reset () { if (m_hover_wait) { +#if defined(HAVE_QT) m_timer.stop (); +#endif m_hover_wait = false; } if (m_hover) { @@ -1086,7 +1093,9 @@ PartialService::hover_reset () } } -void +// TODO: should receive timer calls from regular timer update +#if defined(HAVE_QT) +void PartialService::timeout () { m_hover_wait = false; @@ -1209,6 +1218,7 @@ PartialService::timeout () resize_inst_markers (n_inst_marker, true); } +#endif void PartialService::clear_partial_transient_selection () @@ -1571,7 +1581,9 @@ PartialService::mouse_move_event (const db::DPoint &p, unsigned int buttons, boo } else if (view ()->transient_selection_mode ()) { m_hover_wait = true; +#if defined(HAVE_QT) m_timer.start (); +#endif m_hover_point = p; } @@ -1622,8 +1634,7 @@ PartialService::mouse_press_event (const db::DPoint &p, unsigned int buttons, bo try { partial_select (db::DBox (p, p), lay::Editable::Replace); } catch (tl::Exception &ex) { - tl::error << ex.msg (); - QMessageBox::critical (0, QObject::tr ("Error"), tl::to_qstring (ex.msg ())); + show_error (ex); // clear selection partial_select (db::DBox (), lay::Editable::Reset); } @@ -1703,7 +1714,7 @@ PartialService::mouse_click_event (const db::DPoint &p, unsigned int buttons, bo // stop dragging widget ()->ungrab_mouse (this); - manager ()->transaction (tl::to_string (QObject::tr ("Partial move"))); + manager ()->transaction (tl::to_string (tr ("Partial move"))); // heuristically, if there is just one edge selected: do not confine to the movement // angle constraint - the edge usually is confined enough @@ -1862,8 +1873,7 @@ PartialService::mouse_click_event (const db::DPoint &p, unsigned int buttons, bo selection_to_view (); } catch (tl::Exception &ex) { - tl::error << ex.msg (); - QMessageBox::critical (0, QObject::tr ("Error"), tl::to_qstring (ex.msg ())); + show_error (ex); // clear selection partial_select (db::DBox (), lay::Editable::Reset); } @@ -1901,7 +1911,7 @@ PartialService::mouse_double_click_event (const db::DPoint &p, unsigned int butt partial_objects::iterator r = m_selection.begin (); // we assert above that we have at least one selected element if (! r->first.is_cell_inst ()) { - manager ()->transaction (tl::to_string (QObject::tr ("Insert point"))); + manager ()->transaction (tl::to_string (tr ("Insert point"))); // snap the point db::DPoint new_point_d = snap (p); @@ -2018,8 +2028,7 @@ PartialService::mouse_release_event (const db::DPoint &p, unsigned int buttons, try { partial_select (db::DBox (m_p1, m_p2), mode); } catch (tl::Exception &ex) { - tl::error << ex.msg (); - QMessageBox::critical (0, QObject::tr ("Error"), tl::to_qstring (ex.msg ())); + show_error (ex); // clear selection partial_select (db::DBox (), lay::Editable::Reset); } diff --git a/src/edt/edt/edtPartialService.h b/src/edt/edt/edtPartialService.h index 0781dcf81..9e59b3b1f 100644 --- a/src/edt/edt/edtPartialService.h +++ b/src/edt/edt/edtPartialService.h @@ -34,8 +34,10 @@ #include "edtUtils.h" #include "edtConfig.h" -#include -#include +#if defined(HAVE_QT) +# include +# include +#endif namespace db { class Manager; @@ -136,12 +138,16 @@ struct EdgeWithIndex /** * @brief The partial selection and manipulation service */ -class PartialService - : public QObject, +class PartialService : +#if defined(HAVE_QT) + public QObject, +#endif public lay::EditorServiceBase, public db::Object { +#if defined(HAVE_QT) Q_OBJECT +#endif public: typedef std::map > partial_objects; @@ -289,8 +295,10 @@ public: */ virtual void edit_cancel (); +#if defined(HAVE_QT) public slots: void timeout (); +#endif protected: lay::angle_constraint_type connect_ac () const; @@ -324,7 +332,9 @@ private: std::vector m_inst_markers; std::vector m_transient_inst_markers; +#if defined(HAVE_QT) QTimer m_timer; +#endif bool m_hover; bool m_hover_wait; db::DPoint m_hover_point; diff --git a/src/edt/edt/edtPlugin.cc b/src/edt/edt/edtPlugin.cc index 1169490ca..939c4843c 100644 --- a/src/edt/edt/edtPlugin.cc +++ b/src/edt/edt/edtPlugin.cc @@ -21,8 +21,11 @@ */ -#include "layTipDialog.h" -#include "layEditorOptionsPages.h" +#if defined(HAVE_QT) +# include "layTipDialog.h" +# include "layEditorOptionsPages.h" +#endif + #include "layDispatcher.h" #include "layLayoutView.h" #include "edtPlugin.h" @@ -31,26 +34,36 @@ #include "edtServiceImpl.h" #include "edtMainService.h" #include "edtPartialService.h" -#include "edtEditorOptionsPages.h" -#include "edtRecentConfigurationPage.h" +#if defined(HAVE_QT) +# include "edtEditorOptionsPages.h" +# include "edtRecentConfigurationPage.h" +#endif -#include -#include +#if defined(HAVE_QT) +# include +# include +#endif namespace edt { +#if defined(HAVE_QT) edt::RecentConfigurationPage::ConfigurationDescriptor shape_cfg_descriptors[] = { edt::RecentConfigurationPage::ConfigurationDescriptor ("", tl::to_string (tr ("Layer")), edt::RecentConfigurationPage::Layer), }; +#endif +#if defined(HAVE_QT) static void get_shape_editor_options_pages (std::vector &ret, lay::LayoutView *view, lay::Dispatcher *dispatcher) { ret.push_back (new RecentConfigurationPage (view, dispatcher, "edit-recent-shape-param", &shape_cfg_descriptors[0], &shape_cfg_descriptors[sizeof (shape_cfg_descriptors) / sizeof (shape_cfg_descriptors[0])])); } +#else +static void get_shape_editor_options_pages () { } +#endif static void get_text_options (std::vector < std::pair > &options) @@ -61,6 +74,7 @@ void get_text_options (std::vector < std::pair > &opti options.push_back (std::pair (cfg_edit_text_valign, "bottom")); } +#if defined(HAVE_QT) static void get_text_editor_options_pages (std::vector &ret, lay::LayoutView *view, lay::Dispatcher *dispatcher) { @@ -77,6 +91,9 @@ void get_text_editor_options_pages (std::vector &ret, &text_cfg_descriptors[0], &text_cfg_descriptors[sizeof (text_cfg_descriptors) / sizeof (text_cfg_descriptors[0])])); ret.push_back (new edt::EditorOptionsText (view, dispatcher)); } +#else +static void get_text_editor_options_pages () { } +#endif static void get_path_options (std::vector < std::pair > &options) @@ -87,6 +104,7 @@ void get_path_options (std::vector < std::pair > &opti options.push_back (std::pair (cfg_edit_path_ext_var_end, "0.0")); } +#if defined(HAVE_QT) static void get_path_editor_options_pages (std::vector &ret, lay::LayoutView *view, lay::Dispatcher *dispatcher) { @@ -103,6 +121,9 @@ void get_path_editor_options_pages (std::vector &ret, &path_cfg_descriptors[0], &path_cfg_descriptors[sizeof (path_cfg_descriptors) / sizeof (path_cfg_descriptors[0])])); ret.push_back (new EditorOptionsPath (view, dispatcher)); } +#else +static void get_path_editor_options_pages () { } +#endif static void get_inst_options (std::vector < std::pair > &options) @@ -123,6 +144,7 @@ void get_inst_options (std::vector < std::pair > &opti options.push_back (std::pair (cfg_edit_show_shapes_of_instances, "true")); } +#if defined(HAVE_QT) static void get_inst_editor_options_pages (std::vector &ret, lay::LayoutView *view, lay::Dispatcher *dispatcher) { @@ -148,12 +170,16 @@ void get_inst_editor_options_pages (std::vector &ret, ret.push_back (new EditorOptionsInstPCellParam (view, dispatcher)); ret.push_back (new EditorOptionsInst (view, dispatcher)); } +#else +static void get_inst_editor_options_pages () { } +#endif template class PluginDeclaration : public PluginDeclarationBase { public: +#if defined(HAVE_QT) PluginDeclaration (const std::string &title, const std::string &mouse_mode, void (*option_get_f) (std::vector < std::pair > &) = 0, void (*pages_f) (std::vector &, lay::LayoutView *, lay::Dispatcher *) = 0) @@ -161,6 +187,15 @@ public: { // .. nothing yet .. } +#else + PluginDeclaration (const std::string &title, const std::string &mouse_mode, + void (*option_get_f) (std::vector < std::pair > &) = 0, + void (*pages_f) () = 0) + : m_title (title), m_mouse_mode (mouse_mode), mp_option_get_f (option_get_f), mp_pages_f (pages_f) + { + // .. nothing yet .. + } +#endif virtual void get_options (std::vector < std::pair > &options) const { @@ -169,16 +204,19 @@ public: } } +#if defined(HAVE_QT) virtual lay::ConfigPage *config_page (QWidget * /*parent*/, std::string & /*title*/) const { return 0; } +#endif virtual void get_menu_entries (std::vector & /*menu_entries*/) const { // .. nothing yet .. } +#if defined(HAVE_QT) virtual void get_editor_options_pages (std::vector &pages, lay::LayoutView *view, lay::Dispatcher *root) const { if (mp_pages_f != 0) { @@ -189,6 +227,7 @@ public: } } } +#endif virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *, lay::LayoutView *view) const { @@ -214,31 +253,35 @@ private: std::string m_mouse_mode; void (*mp_option_get_f) (std::vector < std::pair > &options); +#if defined(HAVE_QT) void (*mp_pages_f) (std::vector &, lay::LayoutView *, lay::Dispatcher *); +#else + void (*mp_pages_f) (); +#endif }; static tl::RegisteredClass config_decl1 ( - new edt::PluginDeclaration (tl::to_string (QObject::tr ("Polygons")), "polygon:edit_mode\t" + tl::to_string (QObject::tr ("Polygon")) + "<:polygon.png>" + tl::to_string (QObject::tr ("{Create a polygon}")), 0, &get_shape_editor_options_pages), + new edt::PluginDeclaration (tl::to_string (tr ("Polygons")), "polygon:edit_mode\t" + tl::to_string (tr ("Polygon")) + "<:polygon.png>" + tl::to_string (tr ("{Create a polygon}")), 0, &get_shape_editor_options_pages), 4010, "edt::Service(Polygons)" ); static tl::RegisteredClass config_decl2 ( - new edt::PluginDeclaration (tl::to_string (QObject::tr ("Boxes")), "box:edit_mode\t" + tl::to_string (QObject::tr ("Box")) + "\t<:box.png>" + tl::to_string (QObject::tr ("{Create a box}")), 0, &get_shape_editor_options_pages), + new edt::PluginDeclaration (tl::to_string (tr ("Boxes")), "box:edit_mode\t" + tl::to_string (tr ("Box")) + "\t<:box.png>" + tl::to_string (tr ("{Create a box}")), 0, &get_shape_editor_options_pages), 4011, "edt::Service(Boxes)" ); static tl::RegisteredClass config_decl3 ( - new edt::PluginDeclaration (tl::to_string (QObject::tr ("Texts")), "text:edit_mode\t" + tl::to_string (QObject::tr ("Text")) + "\t<:text.png>" + tl::to_string (QObject::tr ("{Create a text object}")), &get_text_options, &get_text_editor_options_pages), + new edt::PluginDeclaration (tl::to_string (tr ("Texts")), "text:edit_mode\t" + tl::to_string (tr ("Text")) + "\t<:text.png>" + tl::to_string (tr ("{Create a text object}")), &get_text_options, &get_text_editor_options_pages), 4012, "edt::Service(Texts)" ); static tl::RegisteredClass config_decl4 ( - new edt::PluginDeclaration (tl::to_string (QObject::tr ("Paths")), "path:edit_mode\t" + tl::to_string (QObject::tr ("Path")) + "\t<:path.png>" + tl::to_string (QObject::tr ("{Create a path}")), &get_path_options, &get_path_editor_options_pages), + new edt::PluginDeclaration (tl::to_string (tr ("Paths")), "path:edit_mode\t" + tl::to_string (tr ("Path")) + "\t<:path.png>" + tl::to_string (tr ("{Create a path}")), &get_path_options, &get_path_editor_options_pages), 4013, "edt::Service(Paths)" ); static tl::RegisteredClass config_decl5 ( - new edt::PluginDeclaration (tl::to_string (QObject::tr ("Instances")), "instance:edit_mode\t" + tl::to_string (QObject::tr ("Instance")) + "\t<:instance.png>" + tl::to_string (QObject::tr ("{Create a cell instance}")), &get_inst_options, &get_inst_editor_options_pages), + new edt::PluginDeclaration (tl::to_string (tr ("Instances")), "instance:edit_mode\t" + tl::to_string (tr ("Instance")) + "\t<:instance.png>" + tl::to_string (tr ("{Create a cell instance}")), &get_inst_options, &get_inst_editor_options_pages), 4020, "edt::Service(CellInstances)" ); @@ -264,41 +307,43 @@ public: options.push_back (std::pair (cfg_edit_combine_mode, "add")); } +#if defined(HAVE_QT) virtual lay::ConfigPage *config_page (QWidget * /*parent*/, std::string & /*title*/) const { return 0; } +#endif virtual void get_menu_entries (std::vector &menu_entries) const { lay::PluginDeclaration::get_menu_entries (menu_entries); menu_entries.push_back (lay::separator ("edt::hier_group", "zoom_menu.end")); - menu_entries.push_back (lay::menu_item ("edt::descend", "descend", "zoom_menu.end", tl::to_string (QObject::tr ("Descend")) + "(Ctrl+D)")); - menu_entries.push_back (lay::menu_item ("edt::ascend", "ascend", "zoom_menu.end", tl::to_string (QObject::tr ("Ascend")) + "(Ctrl+A)")); + menu_entries.push_back (lay::menu_item ("edt::descend", "descend", "zoom_menu.end", tl::to_string (tr ("Descend")) + "(Ctrl+D)")); + menu_entries.push_back (lay::menu_item ("edt::ascend", "ascend", "zoom_menu.end", tl::to_string (tr ("Ascend")) + "(Ctrl+A)")); - menu_entries.push_back (lay::menu_item ("edt::sel_make_array", "make_array:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Make Array")))); + menu_entries.push_back (lay::menu_item ("edt::sel_make_array", "make_array:edit_mode", "edit_menu.selection_menu.end", tl::to_string (tr ("Make Array")))); menu_entries.push_back (lay::separator ("selection_group:edit_mode", "edit_menu.selection_menu.end")); - menu_entries.push_back (lay::menu_item ("edt::sel_change_layer", "change_layer:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Change Layer")))); - menu_entries.push_back (lay::menu_item ("edt::sel_tap", "tap", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Tap")) + "(T)")); - menu_entries.push_back (lay::menu_item ("edt::sel_align", "align:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Align")))); - menu_entries.push_back (lay::menu_item ("edt::sel_distribute", "distribute:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Distribute")))); - menu_entries.push_back (lay::menu_item ("edt::sel_round_corners", "round_corners:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Round Corners")))); - menu_entries.push_back (lay::menu_item ("edt::sel_size", "size:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Size Shapes")))); - menu_entries.push_back (lay::menu_item ("edt::sel_union", "union:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Merge Shapes")))); - menu_entries.push_back (lay::menu_item ("edt::sel_intersection", "intersection:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Intersection - Others With First")))); - menu_entries.push_back (lay::menu_item ("edt::sel_difference", "difference:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Subtraction - Others From First")))); - menu_entries.push_back (lay::menu_item ("edt::sel_separate", "separate:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Separate - First into Inside/Outside Others")))); + menu_entries.push_back (lay::menu_item ("edt::sel_change_layer", "change_layer:edit_mode", "edit_menu.selection_menu.end", tl::to_string (tr ("Change Layer")))); + menu_entries.push_back (lay::menu_item ("edt::sel_tap", "tap", "edit_menu.selection_menu.end", tl::to_string (tr ("Tap")) + "(T)")); + menu_entries.push_back (lay::menu_item ("edt::sel_align", "align:edit_mode", "edit_menu.selection_menu.end", tl::to_string (tr ("Align")))); + menu_entries.push_back (lay::menu_item ("edt::sel_distribute", "distribute:edit_mode", "edit_menu.selection_menu.end", tl::to_string (tr ("Distribute")))); + menu_entries.push_back (lay::menu_item ("edt::sel_round_corners", "round_corners:edit_mode", "edit_menu.selection_menu.end", tl::to_string (tr ("Round Corners")))); + menu_entries.push_back (lay::menu_item ("edt::sel_size", "size:edit_mode", "edit_menu.selection_menu.end", tl::to_string (tr ("Size Shapes")))); + menu_entries.push_back (lay::menu_item ("edt::sel_union", "union:edit_mode", "edit_menu.selection_menu.end", tl::to_string (tr ("Merge Shapes")))); + menu_entries.push_back (lay::menu_item ("edt::sel_intersection", "intersection:edit_mode", "edit_menu.selection_menu.end", tl::to_string (tr ("Intersection - Others With First")))); + menu_entries.push_back (lay::menu_item ("edt::sel_difference", "difference:edit_mode", "edit_menu.selection_menu.end", tl::to_string (tr ("Subtraction - Others From First")))); + menu_entries.push_back (lay::menu_item ("edt::sel_separate", "separate:edit_mode", "edit_menu.selection_menu.end", tl::to_string (tr ("Separate - First into Inside/Outside Others")))); menu_entries.push_back (lay::separator ("hier_group:edit_mode", "edit_menu.selection_menu.end")); - menu_entries.push_back (lay::menu_item ("edt::sel_flatten_insts", "flatten_insts:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Flatten Instances")))); - menu_entries.push_back (lay::menu_item ("edt::sel_resolve_arefs", "resolve_arefs:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Resolve Arrays")))); - menu_entries.push_back (lay::menu_item ("edt::sel_move_hier_up", "move_hier_up:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Move Up In Hierarchy")))); - menu_entries.push_back (lay::menu_item ("edt::sel_make_cell", "make_cell:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Make Cell")))); - menu_entries.push_back (lay::menu_item ("edt::sel_make_cell_variants", "make_cell_variants:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Make Cell Variants")))); - menu_entries.push_back (lay::menu_item ("edt::sel_convert_to_pcell", "convert_to_pcell:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Convert To PCell")))); - menu_entries.push_back (lay::menu_item ("edt::sel_convert_to_cell", "convert_to_cell:edit_mode", "edit_menu.selection_menu.end", tl::to_string (QObject::tr ("Convert To Static Cell")))); + menu_entries.push_back (lay::menu_item ("edt::sel_flatten_insts", "flatten_insts:edit_mode", "edit_menu.selection_menu.end", tl::to_string (tr ("Flatten Instances")))); + menu_entries.push_back (lay::menu_item ("edt::sel_resolve_arefs", "resolve_arefs:edit_mode", "edit_menu.selection_menu.end", tl::to_string (tr ("Resolve Arrays")))); + menu_entries.push_back (lay::menu_item ("edt::sel_move_hier_up", "move_hier_up:edit_mode", "edit_menu.selection_menu.end", tl::to_string (tr ("Move Up In Hierarchy")))); + menu_entries.push_back (lay::menu_item ("edt::sel_make_cell", "make_cell:edit_mode", "edit_menu.selection_menu.end", tl::to_string (tr ("Make Cell")))); + menu_entries.push_back (lay::menu_item ("edt::sel_make_cell_variants", "make_cell_variants:edit_mode", "edit_menu.selection_menu.end", tl::to_string (tr ("Make Cell Variants")))); + menu_entries.push_back (lay::menu_item ("edt::sel_convert_to_pcell", "convert_to_pcell:edit_mode", "edit_menu.selection_menu.end", tl::to_string (tr ("Convert To PCell")))); + menu_entries.push_back (lay::menu_item ("edt::sel_convert_to_cell", "convert_to_cell:edit_mode", "edit_menu.selection_menu.end", tl::to_string (tr ("Convert To Static Cell")))); - menu_entries.push_back (lay::menu_item ("edt::combine_mode", "combine_mode:edit_mode", "@toolbar.end_modes", tl::to_string (QObject::tr ("Combine{Select background combination mode}")))); + menu_entries.push_back (lay::menu_item ("edt::combine_mode", "combine_mode:edit_mode", "@toolbar.end_modes", tl::to_string (tr ("Combine{Select background combination mode}")))); } bool configure (const std::string &name, const std::string &value) @@ -327,12 +372,14 @@ public: return false; } +#if defined(HAVE_QT) virtual void get_editor_options_pages (std::vector &pages, lay::LayoutView *view, lay::Dispatcher *dispatcher) const { // NOTE: we do not set plugin_declaration which makes the page unspecific EditorOptionsGeneric *generic_opt = new EditorOptionsGeneric (view, dispatcher); pages.push_back (generic_opt); } +#endif virtual void initialize (lay::Dispatcher *root) { @@ -343,18 +390,21 @@ public: mp_root = root; +#if defined(HAVE_QT) // add entries to the combine mode dialog - mp->menu ()->insert_item ("@toolbar.combine_mode.end", "combine_mode_add", new lay::ConfigureAction (tl::to_string (QObject::tr ("Add<:/cm_add.png>{Add shapes}")), cfg_edit_combine_mode, CMConverter ().to_string (CM_Add))); - mp->menu ()->insert_item ("@toolbar.combine_mode.end", "combine_mode_merge", new lay::ConfigureAction (tl::to_string (QObject::tr ("Merge<:/cm_merge.png>{Merge shapes with background}")), cfg_edit_combine_mode, CMConverter ().to_string (CM_Merge))); - mp->menu ()->insert_item ("@toolbar.combine_mode.end", "combine_mode_erase", new lay::ConfigureAction (tl::to_string (QObject::tr ("Erase<:/cm_erase.png>{Erase shape from background}")), cfg_edit_combine_mode, CMConverter ().to_string (CM_Erase))); - mp->menu ()->insert_item ("@toolbar.combine_mode.end", "combine_mode_mask", new lay::ConfigureAction (tl::to_string (QObject::tr ("Mask<:/cm_mask.png>{Mask background with shape}")), cfg_edit_combine_mode, CMConverter ().to_string (CM_Mask))); - mp->menu ()->insert_item ("@toolbar.combine_mode.end", "combine_mode_diff", new lay::ConfigureAction (tl::to_string (QObject::tr ("Diff<:/cm_diff.png>{Compute difference of shape with background}")), cfg_edit_combine_mode, CMConverter ().to_string (CM_Diff))); + mp->menu ()->insert_item ("@toolbar.combine_mode.end", "combine_mode_add", new lay::ConfigureAction (tl::to_string (tr ("Add<:/cm_add.png>{Add shapes}")), cfg_edit_combine_mode, CMConverter ().to_string (CM_Add))); + mp->menu ()->insert_item ("@toolbar.combine_mode.end", "combine_mode_merge", new lay::ConfigureAction (tl::to_string (tr ("Merge<:/cm_merge.png>{Merge shapes with background}")), cfg_edit_combine_mode, CMConverter ().to_string (CM_Merge))); + mp->menu ()->insert_item ("@toolbar.combine_mode.end", "combine_mode_erase", new lay::ConfigureAction (tl::to_string (tr ("Erase<:/cm_erase.png>{Erase shape from background}")), cfg_edit_combine_mode, CMConverter ().to_string (CM_Erase))); + mp->menu ()->insert_item ("@toolbar.combine_mode.end", "combine_mode_mask", new lay::ConfigureAction (tl::to_string (tr ("Mask<:/cm_mask.png>{Mask background with shape}")), cfg_edit_combine_mode, CMConverter ().to_string (CM_Mask))); + mp->menu ()->insert_item ("@toolbar.combine_mode.end", "combine_mode_diff", new lay::ConfigureAction (tl::to_string (tr ("Diff<:/cm_diff.png>{Compute difference of shape with background}")), cfg_edit_combine_mode, CMConverter ().to_string (CM_Diff))); update_menu (CM_Add); +#endif } void update_menu (combine_mode_type cm) { +#if defined(HAVE_QT) lay::Dispatcher *mp = lay::Dispatcher::instance (); if (! mp || ! mp->has_ui ()) { return; @@ -363,21 +413,22 @@ public: lay::Action *combine_menu = mp->menu ()->action ("@toolbar.combine_mode"); if (cm == CM_Add) { - combine_menu->set_title (tl::to_string (QObject::tr ("Add"))); + combine_menu->set_title (tl::to_string (tr ("Add"))); combine_menu->set_icon (":/cm_add.png"); } else if (cm == CM_Merge) { - combine_menu->set_title (tl::to_string (QObject::tr ("Merge"))); + combine_menu->set_title (tl::to_string (tr ("Merge"))); combine_menu->set_icon (":/cm_merge.png"); } else if (cm == CM_Erase) { - combine_menu->set_title (tl::to_string (QObject::tr ("Erase"))); + combine_menu->set_title (tl::to_string (tr ("Erase"))); combine_menu->set_icon (":/cm_erase.png"); } else if (cm == CM_Mask) { - combine_menu->set_title (tl::to_string (QObject::tr ("Mask"))); + combine_menu->set_title (tl::to_string (tr ("Mask"))); combine_menu->set_icon (":/cm_mask.png"); } else if (cm == CM_Diff) { - combine_menu->set_title (tl::to_string (QObject::tr ("Diff"))); + combine_menu->set_title (tl::to_string (tr ("Diff"))); combine_menu->set_icon (":/cm_diff.png"); } +#endif } void initialized (lay::Dispatcher *root) @@ -387,22 +438,27 @@ public: return; } - lay::Action *combine_menu = mp->menu ()->action ("@toolbar.combine_mode"); +#if defined(HAVE_QT) - // Do some more initialization here. + // generate a warning if the combine mode isn't "Add" combine_mode_type cm = CM_Add; root->config_get (cfg_edit_combine_mode, cm, CMConverter ()); + + lay::Action *combine_menu = mp->menu ()->action ("@toolbar.combine_mode"); + if (cm != CM_Add && combine_menu->is_visible ()) { lay::TipDialog td (QApplication::activeWindow (), - tl::to_string (QObject::tr ("The background combination mode of the shape editor is set to some other mode than 'Add'.\n" - "This can be confusing, because a shape may not be drawn as expected.\n\nTo switch back to normal mode, choose 'Add' for the background combination mode in the toolbar.")), + tl::to_string (tr ("The background combination mode of the shape editor is set to some other mode than 'Add'.\n" + "This can be confusing, because a shape may not be drawn as expected.\n\nTo switch back to normal mode, choose 'Add' for the background combination mode in the toolbar.")), "has-non-add-edit-combine-mode"); if (td.exec_dialog ()) { // Don't bother the user with more dialogs. return; } } + +#endif } private: @@ -410,11 +466,12 @@ private: std::string m_title; }; -static tl::RegisteredClass config_decl_main (new edt::MainPluginDeclaration (tl::to_string (QObject::tr ("Instances and shapes"))), 4000, "edt::MainService"); +static tl::RegisteredClass config_decl_main (new edt::MainPluginDeclaration (tl::to_string (tr ("Instances and shapes"))), 4000, "edt::MainService"); void commit_recent (lay::LayoutView *view) { +#if defined(HAVE_QT) lay::EditorOptionsPages *eo_pages = view->editor_options_pages (); if (!eo_pages) { return; @@ -425,6 +482,7 @@ commit_recent (lay::LayoutView *view) (*op)->commit_recent (view); } } +#endif } class PartialPluginDeclaration @@ -470,7 +528,7 @@ private: }; static tl::RegisteredClass config_decl30 ( - new edt::PartialPluginDeclaration (tl::to_string (QObject::tr ("Partial shapes")), "partial:edit_mode\t" + tl::to_string (QObject::tr ("Partial{Edit points and edges of shapes}")) + "<:partial.png>"), + new edt::PartialPluginDeclaration (tl::to_string (tr ("Partial shapes")), "partial:edit_mode\t" + tl::to_string (tr ("Partial{Edit points and edges of shapes}")) + "<:partial.png>"), 4030, "edt::PartialService" ); diff --git a/src/edt/edt/edtService.cc b/src/edt/edt/edtService.cc index de51c832f..dd439ebed 100644 --- a/src/edt/edt/edtService.cc +++ b/src/edt/edt/edtService.cc @@ -26,8 +26,10 @@ #include "dbLibrary.h" #include "edtPlugin.h" #include "edtService.h" -#include "edtEditorOptionsPages.h" -#include "edtDialogs.h" +#if defined(HAVE_QT) +# include "edtEditorOptionsPages.h" +# include "edtDialogs.h" +#endif #include "layFinder.h" #include "layLayoutView.h" #include "laySnap.h" @@ -312,6 +314,7 @@ Service::copy () void Service::copy_selected () { +#if defined(HAVE_QT) edt::CopyModeDialog mode_dialog (view ()->widget ()); bool need_to_ask_for_copy_mode = false; @@ -340,33 +343,49 @@ Service::copy_selected () dispatcher ()->config_end (); } - // create one ClipboardData object per cv_index because, this one assumes that there is - // only one source layout object. - std::set cv_indices; + copy_selected (inst_mode); + + } +#else + + unsigned int inst_mode = 0; + if (m_hier_copy_mode >= 0) { + inst_mode = int (m_hier_copy_mode); + } + + copy_selected (inst_mode); + +#endif +} + +void +Service::copy_selected (unsigned int inst_mode) +{ + // create one ClipboardData object per cv_index because, this one assumes that there is + // only one source layout object. + std::set cv_indices; + for (objects::const_iterator r = m_selection.begin (); r != m_selection.end (); ++r) { + cv_indices.insert (r->cv_index ()); + } + + for (std::set ::const_iterator cvi = cv_indices.begin (); cvi != cv_indices.end (); ++cvi) { + + db::ClipboardValue *cd = new db::ClipboardValue (); + + // add the selected objects to the clipboard data objects. + const lay::CellView &cv = view ()->cellview (*cvi); for (objects::const_iterator r = m_selection.begin (); r != m_selection.end (); ++r) { - cv_indices.insert (r->cv_index ()); - } - - for (std::set ::const_iterator cvi = cv_indices.begin (); cvi != cv_indices.end (); ++cvi) { - - db::ClipboardValue *cd = new db::ClipboardValue (); - - // add the selected objects to the clipboard data objects. - const lay::CellView &cv = view ()->cellview (*cvi); - for (objects::const_iterator r = m_selection.begin (); r != m_selection.end (); ++r) { - if (r->cv_index () == *cvi) { - if (! r->is_cell_inst ()) { - cd->get ().add (cv->layout (), r->layer (), r->shape (), cv.context_trans () * r->trans ()); - } else { - cd->get ().add (cv->layout (), r->back ().inst_ptr, inst_mode, cv.context_trans () * r->trans ()); - } + if (r->cv_index () == *cvi) { + if (! r->is_cell_inst ()) { + cd->get ().add (cv->layout (), r->layer (), r->shape (), cv.context_trans () * r->trans ()); + } else { + cd->get ().add (cv->layout (), r->back ().inst_ptr, inst_mode, cv.context_trans () * r->trans ()); } } - - db::Clipboard::instance () += cd; - } + db::Clipboard::instance () += cd; + } } @@ -799,7 +818,7 @@ Service::mouse_click_event (const db::DPoint &p, unsigned int buttons, bool prio bool Service::key_event (unsigned int key, unsigned int buttons) { - if (view ()->is_editable () && m_editing && buttons == 0 && key == Qt::Key_Backspace) { + if (view ()->is_editable () && m_editing && buttons == 0 && key == lay::KeyBackspace) { do_delete (); return true; } else { @@ -1141,7 +1160,7 @@ Service::display_status (bool transient) std::string msg; if (! transient) { - msg = tl::to_string (QObject::tr ("selected: ")); + msg = tl::to_string (tr ("selected: ")); } db::Instance inst = r->back ().inst_ptr; @@ -1149,12 +1168,12 @@ Service::display_status (bool transient) db::Vector a, b; unsigned long amax = 0, bmax = 0; if (! inst.is_regular_array (a, b, amax, bmax)) { - msg += tl::sprintf (tl::to_string (QObject::tr ("instance(\"%s\" %s)")), layout.display_name (inst.cell_index ()), inst.complex_trans ().to_string ()); + msg += tl::sprintf (tl::to_string (tr ("instance(\"%s\" %s)")), layout.display_name (inst.cell_index ()), inst.complex_trans ().to_string ()); } else { - msg += tl::sprintf (tl::to_string (QObject::tr ("instance(\"%s\" %s %ldx%ld)")), layout.display_name (inst.cell_index ()), inst.complex_trans ().to_string (), amax, bmax); + msg += tl::sprintf (tl::to_string (tr ("instance(\"%s\" %s %ldx%ld)")), layout.display_name (inst.cell_index ()), inst.complex_trans ().to_string (), amax, bmax); } - msg += tl::to_string (QObject::tr (" in ")); + msg += tl::to_string (tr (" in ")); msg += path_to_string (layout, *r); view ()->message (msg, transient ? 10 : 10000); @@ -1163,31 +1182,31 @@ Service::display_status (bool transient) std::string msg; if (! transient) { - msg = tl::to_string (QObject::tr ("selected: ")); + msg = tl::to_string (tr ("selected: ")); } if (r->shape ().is_box ()) { db::Box b (r->shape ().bbox ()); - msg += tl::sprintf (tl::to_string (QObject::tr ("box(%d,%d %d,%d)")), int (b.left ()), int (b.bottom ()), int (b.right ()), int (b.top ())); + msg += tl::sprintf (tl::to_string (tr ("box(%d,%d %d,%d)")), int (b.left ()), int (b.bottom ()), int (b.right ()), int (b.top ())); } else if (r->shape ().is_text ()) { - msg += tl::sprintf (tl::to_string (QObject::tr ("text(\"%s\" %s)")), tl::escape_string (r->shape ().text_string ()), r->shape ().text_trans ().to_string ()); + msg += tl::sprintf (tl::to_string (tr ("text(\"%s\" %s)")), tl::escape_string (r->shape ().text_string ()), r->shape ().text_trans ().to_string ()); } else if (r->shape ().is_polygon ()) { size_t npoints = 0; for (db::Shape::polygon_edge_iterator e = r->shape ().begin_edge (); ! e.at_end (); ++e) { ++npoints; } - msg += tl::sprintf (tl::to_string (QObject::tr ("polygon(#points=%lu)")), npoints); + msg += tl::sprintf (tl::to_string (tr ("polygon(#points=%lu)")), npoints); } else if (r->shape ().is_path ()) { size_t npoints = 0; for (db::Shape::point_iterator p = r->shape ().begin_point (); p != r->shape ().end_point (); ++p) { ++npoints; } - msg += tl::sprintf (tl::to_string (QObject::tr ("path(w=%d #points=%lu)")), int (r->shape ().path_width ()), npoints); + msg += tl::sprintf (tl::to_string (tr ("path(w=%d #points=%lu)")), int (r->shape ().path_width ()), npoints); } if (! msg.empty ()) { - msg += tl::to_string (QObject::tr (" on ")); + msg += tl::to_string (tr (" on ")); std::string ln = layout.get_properties (r->layer ()).to_string (); for (lay::LayerPropertiesConstIterator lp = view ()->begin_layers (); ! lp.at_end (); ++lp) { @@ -1198,7 +1217,7 @@ Service::display_status (bool transient) } msg += ln; - msg += tl::to_string (QObject::tr (" in ")); + msg += tl::to_string (tr (" in ")); msg += path_to_string (layout, *r); view ()->message (msg, transient ? 10 : 10000); diff --git a/src/edt/edt/edtService.h b/src/edt/edt/edtService.h index 2dc67d46a..15121657a 100644 --- a/src/edt/edt/edtService.h +++ b/src/edt/edt/edtService.h @@ -32,6 +32,7 @@ #include "layMarker.h" #include "laySnap.h" #include "layObjectInstPath.h" +#include "layColor.h" #include "dbLayout.h" #include "dbShape.h" #include "edtUtils.h" @@ -219,7 +220,7 @@ public: /** * @brief Color accessor */ - QColor color () const + lay::Color color () const { return m_color; } @@ -592,7 +593,7 @@ private: db::ShapeIterator::flags_type m_flags; // The look of the markers - QColor m_color; + lay::Color m_color; // The current transformation on movement db::DTrans m_move_trans; @@ -644,6 +645,9 @@ private: * @brief Display the status bar message for the given selection */ void display_status (bool transient); + +private: + void copy_selected (unsigned int inst_mode); }; } diff --git a/src/edt/edt/edtServiceImpl.cc b/src/edt/edt/edtServiceImpl.cc index 0e118257b..ba5605954 100644 --- a/src/edt/edt/edtServiceImpl.cc +++ b/src/edt/edt/edtServiceImpl.cc @@ -23,8 +23,10 @@ #include "edtMainService.h" #include "edtServiceImpl.h" -#include "edtPropertiesPages.h" -#include "edtInstPropertiesPage.h" +#if defined(HAVE_QT) +# include "edtPropertiesPages.h" +# include "edtInstPropertiesPage.h" +#endif #include "edtService.h" #include "edtPlugin.h" #include "dbEdge.h" @@ -36,11 +38,15 @@ #include "layMarker.h" #include "layLayerProperties.h" #include "layLayoutView.h" -#include "layTipDialog.h" -#include "layDragDropData.h" -#include -#include +#if defined(HAVE_QT) +# include "layTipDialog.h" +# include "layDragDropData.h" +#endif + +#if defined(HAVE_QT) +# include +#endif namespace edt { @@ -72,7 +78,7 @@ ShapeEditService::get_edit_layer () lay::LayerPropertiesConstIterator cl = view ()->current_layer (); if (cl.is_null ()) { - throw tl::Exception (tl::to_string (QObject::tr ("Please select a layer first"))); + throw tl::Exception (tl::to_string (tr ("Please select a layer first"))); } int cv_index = cl->cellview_index (); @@ -80,20 +86,22 @@ ShapeEditService::get_edit_layer () int layer = cl->layer_index (); if (cv_index < 0 || ! cv.is_valid ()) { - throw tl::Exception (tl::to_string (QObject::tr ("Please select a cell first"))); + throw tl::Exception (tl::to_string (tr ("Please select a cell first"))); } +#if defined(HAVE_QT) if (! cl->visible (true)) { lay::TipDialog td (QApplication::activeWindow (), - tl::to_string (QObject::tr ("You are about to draw on a hidden layer. The result won't be visible.")), + tl::to_string (tr ("You are about to draw on a hidden layer. The result won't be visible.")), "drawing-on-invisible-layer"); td.exec_dialog (); } +#endif if (layer < 0 || ! cv->layout ().is_valid_layer ((unsigned int) layer)) { if (cl->has_children ()) { - throw tl::Exception (tl::to_string (QObject::tr ("Please select a valid drawing layer first"))); + throw tl::Exception (tl::to_string (tr ("Please select a valid drawing layer first"))); } else { // create this layer now @@ -126,7 +134,7 @@ ShapeEditService::get_edit_layer () mp_cell = &(mp_layout->cell (cv.cell_index ())); if (mp_cell->is_proxy ()) { - throw tl::Exception (tl::to_string (QObject::tr ("Cannot put a shape into a PCell or library cell"))); + throw tl::Exception (tl::to_string (tr ("Cannot put a shape into a PCell or library cell"))); } } @@ -153,12 +161,14 @@ ShapeEditService::update_edit_layer (const lay::LayerPropertiesConstIterator &cl return; } +#if defined(HAVE_QT) if (! cl->visible (true)) { lay::TipDialog td (QApplication::activeWindow (), - tl::to_string (QObject::tr ("You are now drawing on a hidden layer. The result won't be visible.")), + tl::to_string (tr ("You are now drawing on a hidden layer. The result won't be visible.")), "drawing-on-invisible-layer"); td.exec_dialog (); } +#endif if (layer < 0 || ! cv->layout ().is_valid_layer ((unsigned int) layer)) { @@ -256,7 +266,7 @@ ShapeEditService::deliver_shape (const db::Polygon &poly) { if (m_combine_mode == CM_Add) { - manager ()->transaction (tl::to_string (QObject::tr ("Create polygon"))); + manager ()->transaction (tl::to_string (tr ("Create polygon"))); cell ().shapes (layer ()).insert (poly); manager ()->commit (); @@ -316,7 +326,7 @@ ShapeEditService::deliver_shape (const db::Polygon &poly) result = input; } - manager ()->transaction (tl::to_string (QObject::tr ("Combine shape with background"))); + manager ()->transaction (tl::to_string (tr ("Combine shape with background"))); // Erase existing shapes for (std::vector::const_iterator s = shapes.begin (); s != shapes.end (); ++s) { @@ -340,7 +350,7 @@ void ShapeEditService::deliver_shape (const db::Path &path) { if (m_combine_mode == CM_Add) { - manager ()->transaction (tl::to_string (QObject::tr ("Create path"))); + manager ()->transaction (tl::to_string (tr ("Create path"))); cell ().shapes (layer ()).insert (path); manager ()->commit (); } else { @@ -352,7 +362,7 @@ void ShapeEditService::deliver_shape (const db::Box &box) { if (m_combine_mode == CM_Add) { - manager ()->transaction (tl::to_string (QObject::tr ("Create box"))); + manager ()->transaction (tl::to_string (tr ("Create box"))); cell ().shapes (layer ()).insert (box); manager ()->commit (); } else { @@ -370,11 +380,13 @@ PolygonService::PolygonService (db::Manager *manager, lay::LayoutView *view) // .. nothing yet .. } +#if defined(HAVE_QT) lay::PropertiesPage * PolygonService::properties_page (db::Manager *manager, QWidget *parent) { return new edt::PolygonPropertiesPage (this, manager, parent); } +#endif void PolygonService::do_begin_edit (const db::DPoint &p) @@ -469,7 +481,7 @@ PolygonService::get_polygon () const db::Polygon poly; if (m_points.size () < 4) { - throw tl::Exception (tl::to_string (QObject::tr ("A polygon must have at least 3 points"))); + throw tl::Exception (tl::to_string (tr ("A polygon must have at least 3 points"))); } std::vector points_dbu; @@ -486,7 +498,7 @@ PolygonService::get_polygon () const poly.assign_hull (points_dbu.begin (), points_dbu.end (), true, true /*remove reflected*/); if (poly.hull ().size () < 3) { - throw tl::Exception (tl::to_string (QObject::tr ("A polygon must have at least 3 effective points"))); + throw tl::Exception (tl::to_string (tr ("A polygon must have at least 3 effective points"))); } return poly; @@ -699,11 +711,13 @@ BoxService::BoxService (db::Manager *manager, lay::LayoutView *view) // .. nothing yet .. } +#if defined(HAVE_QT) lay::PropertiesPage * BoxService::properties_page (db::Manager *manager, QWidget *parent) { return new edt::BoxPropertiesPage (this, manager, parent); } +#endif void BoxService::do_begin_edit (const db::DPoint &p) @@ -797,11 +811,13 @@ TextService::~TextService () // .. nothing yet .. } +#if defined(HAVE_QT) lay::PropertiesPage * TextService::properties_page (db::Manager *manager, QWidget *parent) { return new edt::TextPropertiesPage (this, manager, parent); } +#endif void TextService::do_begin_edit (const db::DPoint &p) @@ -890,16 +906,17 @@ TextService::do_finish_edit () { get_edit_layer (); - manager ()->transaction (tl::to_string (QObject::tr ("Create text"))); + manager ()->transaction (tl::to_string (tr ("Create text"))); cell ().shapes (layer ()).insert (get_text ()); manager ()->commit (); commit_recent (view ()); +#if defined(HAVE_QT) if (! view ()->text_visible ()) { lay::TipDialog td (QApplication::activeWindow (), - tl::to_string (QObject::tr ("A text object is created but texts are disabled for drawing and are not visible. Do you want to enable drawing of texts?\n\nChoose \"Yes\" to enable text drawing now.")), + tl::to_string (tr ("A text object is created but texts are disabled for drawing and are not visible. Do you want to enable drawing of texts?\n\nChoose \"Yes\" to enable text drawing now.")), "text-created-but-not-visible", lay::TipDialog::yesno_buttons); @@ -910,6 +927,7 @@ TextService::do_finish_edit () } } +#endif } void @@ -985,6 +1003,7 @@ PathService::~PathService () // .. nothing yet .. } +#if defined(HAVE_QT) lay::PropertiesPage * PathService::properties_page (db::Manager *manager, QWidget *parent) { @@ -994,6 +1013,7 @@ PathService::properties_page (db::Manager *manager, QWidget *parent) return new edt::PathPropertiesPage (this, manager, parent); } } +#endif void PathService::do_begin_edit (const db::DPoint &p) @@ -1084,7 +1104,7 @@ PathService::do_finish_edit () { // one point is reserved for the "current one" if (m_points.size () < 3) { - throw tl::Exception (tl::to_string (QObject::tr ("A path must have at least 2 points"))); + throw tl::Exception (tl::to_string (tr ("A path must have at least 2 points"))); } m_points.pop_back (); @@ -1225,11 +1245,13 @@ InstService::InstService (db::Manager *manager, lay::LayoutView *view) // .. nothing yet .. } +#if defined(HAVE_QT) lay::PropertiesPage * InstService::properties_page (db::Manager *manager, QWidget *parent) { return new edt::InstPropertiesPage (this, manager, parent); } +#endif bool InstService::do_activated () @@ -1254,6 +1276,7 @@ InstService::get_default_layer_for_pcell () return tl::Variant (); } +#if defined(HAVE_QT) bool InstService::drag_enter_event (const db::DPoint &p, const lay::DragDropDataBase *data) { @@ -1324,7 +1347,7 @@ InstService::drag_enter_event (const db::DPoint &p, const lay::DragDropDataBase return false; } -bool +bool InstService::drag_move_event (const db::DPoint &p, const lay::DragDropDataBase * /*data*/) { if (m_in_drag_drop) { @@ -1344,19 +1367,20 @@ InstService::drag_leave_event () } } +bool +InstService::drop_event (const db::DPoint & /*p*/, const lay::DragDropDataBase * /*data*/) +{ + m_in_drag_drop = false; + return false; +} +#endif + bool InstService::selection_applies (const lay::ObjectInstPath &sel) const { return sel.is_cell_inst (); } -bool -InstService::drop_event (const db::DPoint & /*p*/, const lay::DragDropDataBase * /*data*/) -{ - m_in_drag_drop = false; - return false; -} - void InstService::sync_to_config () { @@ -1384,7 +1408,7 @@ InstService::do_begin_edit (const db::DPoint &p) } if (cv.cell ()->is_proxy ()) { - throw tl::Exception (tl::to_string (QObject::tr ("Cannot put an instance into a PCell or library cell"))); + throw tl::Exception (tl::to_string (tr ("Cannot put an instance into a PCell or library cell"))); } m_trans = cv.context_trans (); @@ -1430,7 +1454,7 @@ InstService::make_cell (const lay::CellView &cv) // NOTE: do this at the beginning: creating a transaction might delete transactions behind the // head transaction, hence releasing (thus: deleting) cells. To prevert interference, create // the transaction at the beginning. - db::Transaction tr (manager (), tl::to_string (QObject::tr ("Create reference cell")), m_reference_transaction_id); + db::Transaction transaction (manager (), tl::to_string (tr ("Create reference cell")), m_reference_transaction_id); lay::LayerState layer_state = view ()->layer_snapshot (); @@ -1498,8 +1522,8 @@ InstService::make_cell (const lay::CellView &cv) m_has_valid_cell = true; m_current_cell = inst_cell_index; - if (! tr.is_empty ()) { - m_reference_transaction_id = tr.id (); + if (! transaction.is_empty ()) { + m_reference_transaction_id = transaction.id (); } return std::pair (true, inst_cell_index); @@ -1597,10 +1621,10 @@ InstService::do_finish_edit () std::vector intersection; std::set_intersection (called.begin (), called.end (), callers.begin (), callers.end (), std::back_inserter (intersection)); if (! intersection.empty ()) { - throw tl::Exception (tl::to_string (QObject::tr ("Inserting this instance would create a recursive hierarchy"))); + throw tl::Exception (tl::to_string (tr ("Inserting this instance would create a recursive hierarchy"))); } - manager ()->transaction (tl::to_string (QObject::tr ("Create instance")), m_reference_transaction_id); + manager ()->transaction (tl::to_string (tr ("Create instance")), m_reference_transaction_id); m_reference_transaction_id = 0; db::Instance i = cv->layout ().cell (cv.cell_index ()).insert (inst); cv->layout ().cleanup (); diff --git a/src/edt/edt/edtServiceImpl.h b/src/edt/edt/edtServiceImpl.h index c3caf4383..9d9ebc2f8 100644 --- a/src/edt/edt/edtServiceImpl.h +++ b/src/edt/edt/edtServiceImpl.h @@ -88,7 +88,9 @@ class PolygonService public: PolygonService (db::Manager *manager, lay::LayoutView *view); +#if defined(HAVE_QT) virtual lay::PropertiesPage *properties_page (db::Manager *manager, QWidget *parent); +#endif virtual void do_delete (); virtual void do_begin_edit (const db::DPoint &p); virtual void do_mouse_move (const db::DPoint &p); @@ -119,7 +121,9 @@ class BoxService public: BoxService (db::Manager *manager, lay::LayoutView *view); +#if defined(HAVE_QT) virtual lay::PropertiesPage *properties_page (db::Manager *manager, QWidget *parent); +#endif virtual void do_begin_edit (const db::DPoint &p); virtual void do_mouse_move (const db::DPoint &p); virtual void do_mouse_move_inactive (const db::DPoint &p); @@ -145,7 +149,9 @@ public: TextService (db::Manager *manager, lay::LayoutView *view); ~TextService (); +#if defined(HAVE_QT) virtual lay::PropertiesPage *properties_page (db::Manager *manager, QWidget *parent); +#endif virtual void do_begin_edit (const db::DPoint &p); virtual void do_mouse_transform (const db::DPoint &p, db::DFTrans trans); virtual void do_mouse_move (const db::DPoint &p); @@ -177,7 +183,9 @@ public: PathService (db::Manager *manager, lay::LayoutView *view); ~PathService (); +#if defined(HAVE_QT) virtual lay::PropertiesPage *properties_page (db::Manager *manager, QWidget *parent); +#endif virtual void do_begin_edit (const db::DPoint &p); virtual void do_mouse_move (const db::DPoint &p); virtual bool do_mouse_click (const db::DPoint &p); @@ -213,7 +221,9 @@ class InstService public: InstService (db::Manager *manager, lay::LayoutView *view); +#if defined(HAVE_QT) virtual lay::PropertiesPage *properties_page (db::Manager *manager, QWidget *parent); +#endif virtual void do_begin_edit (const db::DPoint &p); virtual void do_mouse_move_inactive (const db::DPoint &p); virtual void do_mouse_move (const db::DPoint &p); @@ -222,10 +232,12 @@ public: virtual void do_finish_edit (); virtual void do_cancel_edit (); virtual bool do_activated (); +#if defined(HAVE_QT) virtual bool drag_enter_event (const db::DPoint &p, const lay::DragDropDataBase *data); virtual bool drag_move_event (const db::DPoint &p, const lay::DragDropDataBase *data); virtual void drag_leave_event (); virtual bool drop_event (const db::DPoint &p, const lay::DragDropDataBase *data); +#endif virtual bool selection_applies (const lay::ObjectInstPath &sel) const; protected: diff --git a/src/edt/edt/edtUtils.h b/src/edt/edt/edtUtils.h index af9a81999..83189a84d 100644 --- a/src/edt/edt/edtUtils.h +++ b/src/edt/edt/edtUtils.h @@ -29,8 +29,6 @@ #include #include -#include - #include "layObjectInstPath.h" #include "dbInstElement.h" diff --git a/src/klayout.pro b/src/klayout.pro index 11e00817d..1c6045181 100644 --- a/src/klayout.pro +++ b/src/klayout.pro @@ -14,6 +14,9 @@ SUBDIRS = \ buddies \ lym \ laybasic \ + ant \ + img \ + edt \ equals(HAVE_RUBY, "1") { SUBDIRS += drc lvs @@ -25,9 +28,6 @@ equals(HAVE_RUBY, "1") { SUBDIRS += \ klayout_main \ lay \ - ant \ - img \ - edt \ fontgen \ } @@ -62,12 +62,16 @@ db.depends += gsi rdb.depends += db lib.depends += db -plugins.depends += lib rdb db - buddies.depends += plugins lym $$LANG_DEPENDS lym.depends += gsi $$LANG_DEPENDS laybasic.depends += rdb lym +ant.depends += laybasic +img.depends += laybasic +edt.depends += laybasic + +plugins.depends += lib rdb db ant + equals(HAVE_RUBY, "1") { MAIN_DEPENDS += drc lvs drc.depends += rdb lym @@ -93,11 +97,7 @@ equals(HAVE_RUBY, "1") { } - plugins.depends += lay ant - - ant.depends += laybasic - img.depends += laybasic - edt.depends += laybasic + plugins.depends += lay lay.depends += laybasic ant img edt diff --git a/src/laybasic/laybasic/layEditorServiceBase.cc b/src/laybasic/laybasic/layEditorServiceBase.cc index 925f7a82e..74a751b8b 100644 --- a/src/laybasic/laybasic/layEditorServiceBase.cc +++ b/src/laybasic/laybasic/layEditorServiceBase.cc @@ -26,6 +26,10 @@ #include "laybasicConfig.h" #include "layConverters.h" +#if defined(HAVE_QT) +# include +#endif + namespace lay { @@ -298,4 +302,13 @@ EditorServiceBase::deactivated () clear_mouse_cursors (); } +void +EditorServiceBase::show_error (tl::Exception &ex) +{ + tl::error << ex.msg (); +#if defined(HAVE_QT) + QMessageBox::critical (0, tr ("Error"), tl::to_qstring (ex.msg ())); +#endif +} + } diff --git a/src/laybasic/laybasic/layEditorServiceBase.h b/src/laybasic/laybasic/layEditorServiceBase.h index 276f1a66a..de44983ea 100644 --- a/src/laybasic/laybasic/layEditorServiceBase.h +++ b/src/laybasic/laybasic/layEditorServiceBase.h @@ -121,6 +121,11 @@ public: return m_tracking_position; } + /** + * @brief Shows an error where an exception is not applicable + */ + void show_error (tl::Exception &ex); + protected: virtual bool configure (const std::string &name, const std::string &value); virtual void deactivated (); diff --git a/src/laybasic/laybasic/laybasic.pro b/src/laybasic/laybasic/laybasic.pro index 6ec570a0f..421298aa9 100644 --- a/src/laybasic/laybasic/laybasic.pro +++ b/src/laybasic/laybasic/laybasic.pro @@ -112,7 +112,6 @@ DEFINES += MAKE_LAYBASIC_LIBRARY layEditorOptionsFrame.cc \ layEditorOptionsPage.cc \ layEditorOptionsPages.cc \ - layEditorServiceBase.cc \ layFileDialog.cc \ layGenericSyntaxHighlighter.cc \ layGridNetConfigPage.cc \ @@ -182,7 +181,6 @@ DEFINES += MAKE_LAYBASIC_LIBRARY layEditorOptionsFrame.h \ layEditorOptionsPage.h \ layEditorOptionsPages.h \ - layEditorServiceBase.h \ layFileDialog.h \ layGenericSyntaxHighlighter.h \ layGridNetConfigPage.h \ @@ -246,6 +244,7 @@ SOURCES += \ layDitherPattern.cc \ layDrawing.cc \ layEditable.cc \ + layEditorServiceBase.cc \ layFinder.cc \ layGridNet.cc \ layFixedFont.cc \ @@ -292,6 +291,7 @@ HEADERS += \ layDitherPattern.h \ layDrawing.h \ layEditable.h \ + layEditorServiceBase.h \ layLayoutCanvas.h \ layLayoutView.h \ layFinder.h \ From f65c3d5fd706311b0e5268f033671b5973a560f6 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 8 May 2022 22:27:39 +0200 Subject: [PATCH 46/88] Enabled edt, ant and img for Qt-less builds, added missing files --- src/ant/ant/ant.pro | 34 +++-- src/ant/ant/antObject.cc | 2 +- src/ant/ant/antPlugin.cc | 56 +++++--- src/ant/ant/antPlugin.h | 6 + src/ant/ant/antService.cc | 22 +-- src/ant/ant/antService.h | 2 + src/ant/ant/antTemplate.cc | 2 +- src/ant/ant/gsiDeclAnt.cc | 2 +- src/edt/edt/edt.pro | 4 +- src/edt/edt/edtMainService.cc | 2 +- src/img/img/gsiDeclImg.cc | 8 +- src/img/img/img.pro | 38 +++-- src/img/img/imgObject.cc | 87 +++++++++++- src/img/img/imgPlugin.cc | 15 +- src/img/img/imgService.cc | 37 +++-- src/img/img/imgService.h | 2 + src/laybasic/laybasic/layColor.h | 8 ++ src/laybasic/laybasic/layDragDropData.cc | 108 ++++++++++++++ src/laybasic/laybasic/layDragDropData.h | 171 +++++++++++++++++++++++ 19 files changed, 518 insertions(+), 88 deletions(-) create mode 100644 src/laybasic/laybasic/layDragDropData.cc create mode 100644 src/laybasic/laybasic/layDragDropData.h diff --git a/src/ant/ant/ant.pro b/src/ant/ant/ant.pro index 033a687ac..6232bc294 100644 --- a/src/ant/ant/ant.pro +++ b/src/ant/ant/ant.pro @@ -6,16 +6,7 @@ include($$PWD/../../lib.pri) DEFINES += MAKE_ANT_LIBRARY -HEADERS = \ - antConfig.h \ - antConfigPage.h \ - antObject.h \ - antPlugin.h \ - antPropertiesPage.h \ - antService.h \ - antTemplate.h \ - antForceLink.h \ - antCommon.h +!equals(HAVE_QT, "0") { FORMS = \ RulerConfigPage.ui \ @@ -24,16 +15,33 @@ FORMS = \ RulerConfigPage4.ui \ RulerPropertiesPage.ui \ +HEADERS = \ + antConfigPage.h \ + antPropertiesPage.h \ + SOURCES = \ - antConfig.cc \ antConfigPage.cc \ + antPropertiesPage.cc \ + +} + +HEADERS += \ + antConfig.h \ + antObject.h \ + antPlugin.h \ + antService.h \ + antTemplate.h \ + antForceLink.h \ + antCommon.h + +SOURCES += \ + antConfig.cc \ antObject.cc \ antPlugin.cc \ - antPropertiesPage.cc \ antService.cc \ antTemplate.cc \ gsiDeclAnt.cc \ - antForceLink.cc + antForceLink.cc INCLUDEPATH += $$TL_INC $$GSI_INC $$LAYBASIC_INC $$DB_INC DEPENDPATH += $$TL_INC $$GSI_INC $$LAYBASIC_INC $$DB_INC diff --git a/src/ant/ant/antObject.cc b/src/ant/ant/antObject.cc index 6f421383b..43bdf736b 100644 --- a/src/ant/ant/antObject.cc +++ b/src/ant/ant/antObject.cc @@ -284,7 +284,7 @@ public: void execute (const tl::ExpressionParserContext &context, tl::Variant &out, const std::vector &vv) const { if (vv.size () != 0) { - throw tl::EvalError (tl::to_string (QObject::tr ("Annotation function must not have arguments")), context); + throw tl::EvalError (tl::to_string (tr ("Annotation function must not have arguments")), context); } const Object &obj = mp_eval->obj (); diff --git a/src/ant/ant/antPlugin.cc b/src/ant/ant/antPlugin.cc index 330442a94..1aecb0792 100644 --- a/src/ant/ant/antPlugin.cc +++ b/src/ant/ant/antPlugin.cc @@ -22,15 +22,22 @@ #include "layPlugin.h" -#include "layAbstractMenu.h" #include "layConverters.h" -#include "layConfigurationDialog.h" #include "layDispatcher.h" -#include "antConfigPage.h" +#include "layColor.h" +#if defined(HAVE_QT) +# include "layConfigurationDialog.h" +# include "layAbstractMenu.h" +#endif #include "antConfig.h" +#if defined(HAVE_QT) +# include "antConfigPage.h" +#endif #include "antPlugin.h" -#include +#if defined(HAVE_QT) +# include +#endif namespace ant { @@ -60,7 +67,7 @@ PluginDeclaration::get_options (std::vector < std::pair (cfg_max_number_of_rulers, "-1")); options.push_back (std::pair (cfg_ruler_snap_range, "8")); - options.push_back (std::pair (cfg_ruler_color, lay::ColorConverter ().to_string (QColor ()))); + options.push_back (std::pair (cfg_ruler_color, lay::ColorConverter ().to_string (lay::Color ()))); options.push_back (std::pair (cfg_ruler_halo, "true")); options.push_back (std::pair (cfg_ruler_snap_mode, ACConverter ().to_string (lay::AC_Any))); options.push_back (std::pair (cfg_ruler_obj_snap, tl::to_string (true))); @@ -70,24 +77,26 @@ PluginDeclaration::get_options (std::vector < std::pair > PluginDeclaration::config_pages (QWidget *parent) const { std::vector > pages; - pages.push_back (std::make_pair (tl::to_string (QObject::tr ("Rulers And Annotations|Snapping")), new ant::ConfigPage (parent))); - pages.push_back (std::make_pair (tl::to_string (QObject::tr ("Rulers And Annotations|Appearance")), new ant::ConfigPage2 (parent))); - pages.push_back (std::make_pair (tl::to_string (QObject::tr ("Rulers And Annotations|Angle")), new ant::ConfigPage3 (parent))); - pages.push_back (std::make_pair (tl::to_string (QObject::tr ("Rulers And Annotations|Templates")), new ant::ConfigPage4 (parent))); + pages.push_back (std::make_pair (tl::to_string (tr ("Rulers And Annotations|Snapping")), new ant::ConfigPage (parent))); + pages.push_back (std::make_pair (tl::to_string (tr ("Rulers And Annotations|Appearance")), new ant::ConfigPage2 (parent))); + pages.push_back (std::make_pair (tl::to_string (tr ("Rulers And Annotations|Angle")), new ant::ConfigPage3 (parent))); + pages.push_back (std::make_pair (tl::to_string (tr ("Rulers And Annotations|Templates")), new ant::ConfigPage4 (parent))); return pages; } +#endif void PluginDeclaration::get_menu_entries (std::vector &menu_entries) const { lay::PluginDeclaration::get_menu_entries (menu_entries); menu_entries.push_back (lay::separator ("rulers_group", "edit_menu.end")); - menu_entries.push_back (lay::menu_item ("ant::clear_all_rulers", "clear_all_rulers:edit", "edit_menu.end", tl::to_string (QObject::tr ("Clear All Rulers And Annotations(Ctrl+K)")))); - menu_entries.push_back (lay::menu_item ("ant::configure", "configure_rulers", "edit_menu.end", tl::to_string (QObject::tr ("Ruler And Annotation Setup")))); + menu_entries.push_back (lay::menu_item ("ant::clear_all_rulers", "clear_all_rulers:edit", "edit_menu.end", tl::to_string (tr ("Clear All Rulers And Annotations(Ctrl+K)")))); + menu_entries.push_back (lay::menu_item ("ant::configure", "configure_rulers", "edit_menu.end", tl::to_string (tr ("Ruler And Annotation Setup")))); } lay::Plugin * @@ -101,9 +110,11 @@ PluginDeclaration::menu_activated (const std::string &symbol) const { if (symbol == "ant::configure") { +#if defined(HAVE_QT) lay::ConfigurationDialog config_dialog (QApplication::activeWindow (), lay::Dispatcher::instance (), "ant::Plugin"); config_dialog.exec (); - +#endif + return true; } else { @@ -114,14 +125,14 @@ PluginDeclaration::menu_activated (const std::string &symbol) const bool PluginDeclaration::implements_editable (std::string &title) const { - title = tl::to_string (QObject::tr ("Rulers And Annotations")); + title = tl::to_string (tr ("Rulers And Annotations")); return true; } bool PluginDeclaration::implements_mouse_mode (std::string &title) const { - title = "ruler:ruler_mode_group:ruler_templates_group\t" + tl::to_string (QObject::tr ("Ruler{Add rulers and annotations}")) + "<:ruler.png>"; + title = "ruler:ruler_mode_group:ruler_templates_group\t" + tl::to_string (tr ("Ruler{Add rulers and annotations}")) + "<:ruler.png>"; return true; } @@ -182,17 +193,17 @@ PluginDeclaration::initialized (lay::Dispatcher *root) // Set up the templates we want to see (plus some non-categorized templates) - m_templates.push_back (ant::Template (tl::to_string (QObject::tr ("Ruler")), "$X", "$Y", "$D", ant::Object::STY_ruler, ant::Object::OL_diag, true, lay::AC_Global, "_ruler")); + m_templates.push_back (ant::Template (tl::to_string (tr ("Ruler")), "$X", "$Y", "$D", ant::Object::STY_ruler, ant::Object::OL_diag, true, lay::AC_Global, "_ruler")); - m_templates.push_back (ant::Template (tl::to_string (QObject::tr ("Cross")), "", "", "$U,$V", ant::Object::STY_cross_both, ant::Object::OL_diag, true, lay::AC_Global, "_cross")); + m_templates.push_back (ant::Template (tl::to_string (tr ("Cross")), "", "", "$U,$V", ant::Object::STY_cross_both, ant::Object::OL_diag, true, lay::AC_Global, "_cross")); m_templates.back ().set_mode (ant::Template::RulerSingleClick); - m_templates.push_back (ant::Template (tl::to_string (QObject::tr ("Measure")), "$X", "$Y", "$D", ant::Object::STY_ruler, ant::Object::OL_diag, true, lay::AC_Global, "_measure")); + m_templates.push_back (ant::Template (tl::to_string (tr ("Measure")), "$X", "$Y", "$D", ant::Object::STY_ruler, ant::Object::OL_diag, true, lay::AC_Global, "_measure")); m_templates.back ().set_mode (ant::Template::RulerAutoMetric); - m_templates.push_back (ant::Template (tl::to_string (QObject::tr ("Ellipse")), "W=$(abs(X))", "H=$(abs(Y))", "", ant::Object::STY_line, ant::Object::OL_ellipse, true, lay::AC_Global, std::string ())); + m_templates.push_back (ant::Template (tl::to_string (tr ("Ellipse")), "W=$(abs(X))", "H=$(abs(Y))", "", ant::Object::STY_line, ant::Object::OL_ellipse, true, lay::AC_Global, std::string ())); - m_templates.push_back (ant::Template (tl::to_string (QObject::tr ("Box")), "W=$(abs(X))", "H=$(abs(Y))", "", ant::Object::STY_line, ant::Object::OL_box, true, lay::AC_Global, std::string ())); + m_templates.push_back (ant::Template (tl::to_string (tr ("Box")), "W=$(abs(X))", "H=$(abs(Y))", "", ant::Object::STY_line, ant::Object::OL_box, true, lay::AC_Global, std::string ())); root->config_set (cfg_ruler_templates, ant::TemplatesConverter ().to_string (m_templates)); root->config_end (); @@ -203,12 +214,15 @@ PluginDeclaration::initialized (lay::Dispatcher *root) void PluginDeclaration::uninitialize (lay::Dispatcher *) { +#if defined(HAVE_QT) m_actions.clear (); +#endif } void PluginDeclaration::update_current_template () { +#if defined(HAVE_QT) lay::Dispatcher *mp = lay::Dispatcher::instance (); if (! mp || ! mp->has_ui ()) { return; @@ -234,11 +248,13 @@ PluginDeclaration::update_current_template () } } +#endif } void PluginDeclaration::update_menu () { +#if defined(HAVE_QT) lay::Dispatcher *mp = lay::Dispatcher::instance (); if (! mp || ! mp->has_ui ()) { return; @@ -278,7 +294,7 @@ PluginDeclaration::update_menu () } } } - +#endif } void diff --git a/src/ant/ant/antPlugin.h b/src/ant/ant/antPlugin.h index 6d65c03e6..9e7e5e943 100644 --- a/src/ant/ant/antPlugin.h +++ b/src/ant/ant/antPlugin.h @@ -31,6 +31,8 @@ namespace ant { +class Template; + class PluginDeclaration : public lay::PluginDeclaration { @@ -44,7 +46,9 @@ public: virtual bool implements_editable (std::string &title) const; virtual bool implements_mouse_mode (std::string &title) const; virtual bool configure (const std::string &name, const std::string &value); +#if defined(HAVE_QT) virtual std::vector > config_pages (QWidget *parent) const; +#endif virtual void config_finalize (); virtual void initialized (lay::Dispatcher *); virtual void uninitialize (lay::Dispatcher *); @@ -60,7 +64,9 @@ private: std::vector m_templates; int m_current_template; +#if defined(HAVE_QT) tl::weak_collection m_actions; +#endif bool m_current_template_updated; bool m_templates_updated; }; diff --git a/src/ant/ant/antService.cc b/src/ant/ant/antService.cc index 5c6db1ec2..3208df850 100644 --- a/src/ant/ant/antService.cc +++ b/src/ant/ant/antService.cc @@ -32,9 +32,13 @@ #include "laybasicConfig.h" #include "layConverters.h" #include "layLayoutCanvas.h" -#include "layProperties.h" +#if defined(HAVE_QT) +# include "layProperties.h" +#endif #include "antService.h" -#include "antPropertiesPage.h" +#if defined(HAVE_QT) +# include "antPropertiesPage.h" +#endif #include "antConfig.h" namespace ant @@ -1525,7 +1529,7 @@ Service::mouse_click_event (const db::DPoint &p, unsigned int buttons, bool prio // begin the transaction tl_assert (! manager ()->transacting ()); - manager ()->transaction (tl::to_string (QObject::tr ("Create ruler"))); + manager ()->transaction (tl::to_string (tr ("Create ruler"))); m_current = ant::Object (pt, pt, 0, tpl); show_message (); @@ -1562,7 +1566,7 @@ Service::mouse_click_event (const db::DPoint &p, unsigned int buttons, bool prio // begin the transaction tl_assert (! manager ()->transacting ()); - manager ()->transaction (tl::to_string (QObject::tr ("Create ruler"))); + manager ()->transaction (tl::to_string (tr ("Create ruler"))); m_current = ant::Object (ee.first, ee.second, 0, tpl); show_message (); @@ -1598,7 +1602,7 @@ Service::mouse_click_event (const db::DPoint &p, unsigned int buttons, bool prio // begin the transaction tl_assert (! manager ()->transacting ()); - manager ()->transaction (tl::to_string (QObject::tr ("Create ruler"))); + manager ()->transaction (tl::to_string (tr ("Create ruler"))); show_message (); @@ -2160,19 +2164,21 @@ Service::display_status (bool transient) std::string msg; if (! transient) { - msg = tl::to_string (QObject::tr ("selected: ")); + msg = tl::to_string (tr ("selected: ")); } - msg += tl::sprintf (tl::to_string (QObject::tr ("annotation(d=%s x=%s y=%s)")), ruler->text (), ruler->text_x (), ruler->text_y ()); + msg += tl::sprintf (tl::to_string (tr ("annotation(d=%s x=%s y=%s)")), ruler->text (), ruler->text_x (), ruler->text_y ()); view ()->message (msg); } } +#if defined(HAVE_QT) lay::PropertiesPage * Service::properties_page (db::Manager *manager, QWidget *parent) { return new PropertiesPage (this, manager, parent); } +#endif void Service::get_selection (std::vector &sel) const @@ -2248,7 +2254,7 @@ Service::menu_activated (const std::string &symbol) if (symbol == "ant::clear_all_rulers_internal") { clear_rulers (); } else if (symbol == "ant::clear_all_rulers") { - manager ()->transaction (tl::to_string (QObject::tr ("Clear all rulers"))); + manager ()->transaction (tl::to_string (tr ("Clear all rulers"))); clear_rulers (); manager ()->commit (); } else { diff --git a/src/ant/ant/antService.h b/src/ant/ant/antService.h index e289800fc..d6b3f30b3 100644 --- a/src/ant/ant/antService.h +++ b/src/ant/ant/antService.h @@ -346,10 +346,12 @@ public: */ virtual void transform (const db::DCplxTrans &trans); +#if defined(HAVE_QT) /** * @brief Create the properties page */ virtual lay::PropertiesPage *properties_page (db::Manager *manager, QWidget *parent); +#endif /** * @brief Get the selection for the properties page diff --git a/src/ant/ant/antTemplate.cc b/src/ant/ant/antTemplate.cc index e47f523c7..390a4b8a9 100644 --- a/src/ant/ant/antTemplate.cc +++ b/src/ant/ant/antTemplate.cc @@ -31,7 +31,7 @@ namespace ant { Template::Template () - : m_title (tl::to_string (QObject::tr ("Ruler"))), + : m_title (tl::to_string (tr ("Ruler"))), m_fmt_x ("$X"), m_fmt_y ("$Y"), m_fmt ("$D"), m_style (ant::Object::STY_ruler), m_outline (ant::Object::OL_diag), m_snap (true), m_angle_constraint (lay::AC_Global), diff --git a/src/ant/ant/gsiDeclAnt.cc b/src/ant/ant/gsiDeclAnt.cc index a6f28c1a9..325867bc0 100644 --- a/src/ant/ant/gsiDeclAnt.cc +++ b/src/ant/ant/gsiDeclAnt.cc @@ -171,7 +171,7 @@ static void clear_annotations (lay::LayoutView *view) static void insert_annotation (lay::LayoutView *view, AnnotationRef *obj) { if (obj->is_valid ()) { - throw tl::Exception (tl::to_string (QObject::tr ("The object is already inserted into a view - detach the object first or create a different object."))); + throw tl::Exception (tl::to_string (tr ("The object is already inserted into a view - detach the object first or create a different object."))); } ant::Service *ant_service = view->get_plugin (); diff --git a/src/edt/edt/edt.pro b/src/edt/edt/edt.pro index 6f2e989af..50ab9a827 100644 --- a/src/edt/edt/edt.pro +++ b/src/edt/edt/edt.pro @@ -49,7 +49,7 @@ DEFINES += MAKE_EDT_LIBRARY } -HEADERS = \ +HEADERS += \ edtConfig.h \ edtMainService.h \ edtPartialService.h \ @@ -60,7 +60,7 @@ HEADERS = \ edtCommon.h \ edtDistribute.h \ -SOURCES = \ +SOURCES += \ edtConfig.cc \ edtMainService.cc \ edtPartialService.cc \ diff --git a/src/edt/edt/edtMainService.cc b/src/edt/edt/edtMainService.cc index 99a39e017..955af10f5 100644 --- a/src/edt/edt/edtMainService.cc +++ b/src/edt/edt/edtMainService.cc @@ -402,7 +402,7 @@ MainService::cm_flatten_insts () #if defined(HAVE_QT) if (! (flatten_inst_options_dialog ()->exec_dialog (m_flatten_insts_levels, m_flatten_prune) && m_flatten_insts_levels != 0)) { - return + return; } #endif diff --git a/src/img/img/gsiDeclImg.cc b/src/img/img/gsiDeclImg.cc index 0033c38ec..13413edfb 100644 --- a/src/img/img/gsiDeclImg.cc +++ b/src/img/img/gsiDeclImg.cc @@ -1103,7 +1103,7 @@ static void show_image (lay::LayoutView *view, size_t id, bool visible) const img::Object *img = img_service->object_by_id (id); if (img == 0) { - throw tl::Exception (tl::to_string (QObject::tr ("The image Id is not valid"))); + throw tl::Exception (tl::to_string (tr ("The image Id is not valid"))); } img::Object new_img (*img); @@ -1121,7 +1121,7 @@ void replace_image_base (lay::LayoutView *view, size_t id, ImageRef &new_obj) const img::Object *img = img_service->object_by_id (id); if (img == 0) { - throw tl::Exception (tl::to_string (QObject::tr ("The image Id is not valid"))); + throw tl::Exception (tl::to_string (tr ("The image Id is not valid"))); } img_service->change_image_by_id (id, new_obj); @@ -1141,7 +1141,7 @@ void erase_image_base (lay::LayoutView *view, size_t id) const img::Object *img = img_service->object_by_id (id); if (img == 0) { - throw tl::Exception (tl::to_string (QObject::tr ("The image Id is not valid"))); + throw tl::Exception (tl::to_string (tr ("The image Id is not valid"))); } img_service->erase_image_by_id (id); @@ -1157,7 +1157,7 @@ static void erase_image (lay::LayoutView *view, size_t id) static void insert_image (lay::LayoutView *view, ImageRef &obj) { if (obj.is_valid ()) { - throw tl::Exception (tl::to_string (QObject::tr ("The object is already inserted into a view - detach the object first or create a different object."))); + throw tl::Exception (tl::to_string (tr ("The object is already inserted into a view - detach the object first or create a different object."))); } img::Service *img_service = view->get_plugin (); diff --git a/src/img/img/img.pro b/src/img/img/img.pro index c5337e156..13eb01db9 100644 --- a/src/img/img/img.pro +++ b/src/img/img/img.pro @@ -6,34 +6,42 @@ include($$PWD/../../lib.pri) DEFINES += MAKE_IMG_LIBRARY -HEADERS = \ - imgLandmarksDialog.h \ - imgNavigator.h \ - imgObject.h \ - imgPlugin.h \ - imgPropertiesPage.h \ - imgService.h \ - imgWidgets.h \ - imgForceLink.h \ - imgCommon.h \ - imgStream.h +!equals(HAVE_QT, "0") { FORMS = \ AddNewImageDialog.ui \ ImageLandmarksDialog.ui \ ImagePropertiesPage.ui \ +HEADERS = \ + imgLandmarksDialog.h \ + imgNavigator.h \ + imgPropertiesPage.h \ + imgWidgets.h \ + SOURCES = \ - gsiDeclImg.cc \ imgLandmarksDialog.cc \ imgNavigator.cc \ + imgPropertiesPage.cc \ + imgWidgets.cc \ + +} + +HEADERS += \ + imgObject.h \ + imgPlugin.h \ + imgService.h \ + imgForceLink.h \ + imgCommon.h \ + imgStream.h + +SOURCES += \ + gsiDeclImg.cc \ imgObject.cc \ imgPlugin.cc \ - imgPropertiesPage.cc \ imgService.cc \ - imgWidgets.cc \ imgForceLink.cc \ - imgStream.cc + imgStream.cc INCLUDEPATH += $$TL_INC $$DB_INC $$GSI_INC $$LAYBASIC_INC $$DB_INC DEPENDPATH += $$TL_INC $$DB_INC $$GSI_INC $$LAYBASIC_INC $$DB_INC diff --git a/src/img/img/imgObject.cc b/src/img/img/imgObject.cc index 7f265252c..333789e86 100644 --- a/src/img/img/imgObject.cc +++ b/src/img/img/imgObject.cc @@ -22,12 +22,12 @@ #include "imgObject.h" -#include "imgWidgets.h" // for interpolate_color() #include "imgStream.h" #include "tlLog.h" #include "tlTimer.h" #include "layPlugin.h" #include "layConverters.h" +#include "layPixelBuffer.h" #include "dbPolygonTools.h" #include "tlFileUtils.h" #include "tlUri.h" @@ -40,7 +40,9 @@ #include #include -#include +#if defined(HAVE_QT) +# include +#endif namespace img { @@ -1557,6 +1559,8 @@ Object::read_file () // continue with other formats ... } +#if defined(HAVE_QT) + QImage qimage (tl::to_qstring (m_filename)); if (! qimage.isNull ()) { @@ -1617,6 +1621,85 @@ Object::read_file () } } + +#elif defined(HAVE_PNG) + + lay::PixelBuffer img; + + { + tl::InputStream stream (m_filename); + img = lay::PixelBuffer::read_png (stream); + } + + bool is_color = false; + for (unsigned int i = 0; i < img.height () && ! is_color; ++i) { + const lay::color_t *d = img.scan_line (i); + const lay::color_t *dd = d + img.width (); + while (! is_color && d != dd) { + lay::color_t c = *d++; + is_color = (((c >> 8) ^ c) & 0xffff) != 0; + } + } + + if (! m_min_value_set) { + m_min_value = 0.0; + } + + if (! m_max_value_set) { + m_max_value = 255.0; + } + + m_min_value_set = true; + m_max_value_set = true; + + unsigned int w = img.width (), h = img.height (); + + mp_data = new DataHeader (w, h, is_color, true); + mp_data->add_ref (); + + if (is_color) { + + unsigned char *red = mp_data->byte_data (0); + unsigned char *green = mp_data->byte_data (1); + unsigned char *blue = mp_data->byte_data (2); + unsigned char *msk = img.transparent () ? mp_data->set_mask () : 0; + + for (unsigned int y = 0; y < h; ++y) { + const lay::color_t *d = img.scan_line (h - y - 1); + const lay::color_t *dd = d + img.width (); + while (d != dd) { + lay::color_t rgb = *d++; + *red++ = lay::red (rgb); + *green++ = lay::green (rgb); + *blue++ = lay::blue (rgb); + if (msk) { + *msk++ = lay::alpha (rgb) > 128; + } + } + } + + } else { + + unsigned char *mono = mp_data->byte_data (); + unsigned char *msk = img.transparent () ? mp_data->set_mask () : 0; + + for (unsigned int y = 0; y < h; ++y) { + const lay::color_t *d = img.scan_line (h - y - 1); + const lay::color_t *dd = d + img.width (); + while (d != dd) { + lay::color_t rgb = *d++; + *mono++ = lay::green (rgb); + if (msk) { + *msk++ = lay::alpha (rgb) > 128; + } + } + } + + } + +#else + throw tl::Exception (tl::to_string ("No PNG support compiled in - cannot load PNG files")); +#endif } void diff --git a/src/img/img/imgPlugin.cc b/src/img/img/imgPlugin.cc index 74d710786..4936406f0 100644 --- a/src/img/img/imgPlugin.cc +++ b/src/img/img/imgPlugin.cc @@ -22,7 +22,6 @@ #include "layPlugin.h" -#include "layAbstractMenu.h" #include "imgService.h" #include "imgPlugin.h" @@ -36,12 +35,12 @@ PluginDeclaration::get_menu_entries (std::vector &menu_entries) { lay::PluginDeclaration::get_menu_entries (menu_entries); menu_entries.push_back (lay::separator ("image_group", "edit_menu.end")); - menu_entries.push_back (lay::menu_item ("img::add_image", "add_image:edit", "edit_menu.end", tl::to_string (QObject::tr ("Add Image")))); - menu_entries.push_back (lay::submenu ("img::image_menu", "image_menu:edit", "edit_menu.end", tl::to_string (QObject::tr ("Images")))); - menu_entries.push_back (lay::menu_item ("img::bring_to_front", "bring_to_front:edit", "edit_menu.image_menu.end", tl::to_string (QObject::tr ("Image Stack: Selected Images to Front")))); - menu_entries.push_back (lay::menu_item ("img::bring_to_back", "bring_to_back:edit", "edit_menu.image_menu.end", tl::to_string (QObject::tr ("Image Stack: Selected Images to Back")))); - menu_entries.push_back (lay::menu_item ("img::clear_all_images", "clear_all_images:edit", "edit_menu.image_menu.end", tl::to_string (QObject::tr ("Clear All Images")))); - menu_entries.push_back (lay::config_menu_item ("show_images", "view_menu.layout_group+", tl::to_string (QObject::tr ("Show Images")), cfg_images_visible, "?")); + menu_entries.push_back (lay::menu_item ("img::add_image", "add_image:edit", "edit_menu.end", tl::to_string (tr ("Add Image")))); + menu_entries.push_back (lay::submenu ("img::image_menu", "image_menu:edit", "edit_menu.end", tl::to_string (tr ("Images")))); + menu_entries.push_back (lay::menu_item ("img::bring_to_front", "bring_to_front:edit", "edit_menu.image_menu.end", tl::to_string (tr ("Image Stack: Selected Images to Front")))); + menu_entries.push_back (lay::menu_item ("img::bring_to_back", "bring_to_back:edit", "edit_menu.image_menu.end", tl::to_string (tr ("Image Stack: Selected Images to Back")))); + menu_entries.push_back (lay::menu_item ("img::clear_all_images", "clear_all_images:edit", "edit_menu.image_menu.end", tl::to_string (tr ("Clear All Images")))); + menu_entries.push_back (lay::config_menu_item ("show_images", "view_menu.layout_group+", tl::to_string (tr ("Show Images")), cfg_images_visible, "?")); } lay::Plugin * @@ -53,7 +52,7 @@ PluginDeclaration::create_plugin (db::Manager *manager, lay::Dispatcher *, lay:: bool PluginDeclaration::implements_editable (std::string &title) const { - title = tl::to_string (QObject::tr ("Images")); + title = tl::to_string (tr ("Images")); return true; } diff --git a/src/img/img/imgService.cc b/src/img/img/imgService.cc index 68fcb1a9f..4ae8ff5ac 100644 --- a/src/img/img/imgService.cc +++ b/src/img/img/imgService.cc @@ -32,22 +32,28 @@ #include "laySnap.h" #include "layLayoutView.h" #include "laybasicConfig.h" -#include "layLayoutCanvas.h" -#include "layProperties.h" -#include "layTipDialog.h" +#if defined(HAVE_QT) +# include "layProperties.h" +# include "layTipDialog.h" +#endif #include "tlExceptions.h" #include "imgService.h" #include "imgPlugin.h" -#include "ui_AddNewImageDialog.h" +#if defined(HAVE_QT) +# include "ui_AddNewImageDialog.h" +#endif -#include +#if defined(HAVE_QT) +# include +#endif namespace img { // ------------------------------------------------------------- -class AddNewImageDialog +#if defined(HAVE_QT) +class AddNewImageDialog : public QDialog, public Ui::AddNewImageDialog { @@ -68,7 +74,7 @@ public: properties_frame->apply (); if (mp_image_object->is_empty ()) { - throw tl::Exception (tl::to_string (QObject::tr ("No data loaded for that image"))); + throw tl::Exception (tl::to_string (tr ("No data loaded for that image"))); } QDialog::accept (); @@ -79,6 +85,7 @@ public: private: img::Object *mp_image_object; }; +#endif // ------------------------------------------------------------- @@ -1361,19 +1368,21 @@ Service::display_status (bool transient) std::string msg; if (! transient) { - msg = tl::to_string (QObject::tr ("selected: ")); + msg = tl::to_string (tr ("selected: ")); } - msg += tl::sprintf (tl::to_string (QObject::tr ("image(%dx%d)")), image->width (), image->height ()); + msg += tl::sprintf (tl::to_string (tr ("image(%dx%d)")), image->width (), image->height ()); view ()->message (msg); } } +#if defined(HAVE_QT) lay::PropertiesPage * Service::properties_page (db::Manager *manager, QWidget *parent) { return new img::PropertiesPage (this, manager, parent); } +#endif void Service::get_selection (std::vector &sel) const @@ -1463,15 +1472,16 @@ Service::menu_activated (const std::string &symbol) { if (symbol == "img::clear_all_images") { - manager ()->transaction (tl::to_string (QObject::tr ("Clear all images"))); + manager ()->transaction (tl::to_string (tr ("Clear all images"))); clear_images (); manager ()->commit (); } else if (symbol == "img::add_image") { +#if defined(HAVE_QT) if (! images_visible ()) { lay::TipDialog td (QApplication::activeWindow (), - tl::to_string (QObject::tr ("Images are not visible. If you add an image you will not see it.\n\n" + tl::to_string (tr ("Images are not visible. If you add an image you will not see it.\n\n" "Choose 'View/Show Images' to make images visible.")), "add-image-while-not-visible", lay::TipDialog::okcancel_buttons); @@ -1482,6 +1492,7 @@ Service::menu_activated (const std::string &symbol) return; } } +#endif add_image (); @@ -1573,6 +1584,7 @@ Service::top_z_position () const void Service::add_image () { +#if defined(HAVE_QT) img::Object *new_image = new img::Object (); AddNewImageDialog dialog (QApplication::activeWindow (), new_image); @@ -1580,7 +1592,7 @@ Service::add_image () clear_selection (); - manager ()->transaction (tl::to_string (QObject::tr ("Add image"))); + manager ()->transaction (tl::to_string (tr ("Add image"))); new_image->set_z_position (top_z_position ()); mp_view->annotation_shapes ().insert (db::DUserObject (new_image)); manager ()->commit (); @@ -1588,6 +1600,7 @@ Service::add_image () } else { delete new_image; } +#endif } void diff --git a/src/img/img/imgService.h b/src/img/img/imgService.h index 65e7bfa70..56f70fda6 100644 --- a/src/img/img/imgService.h +++ b/src/img/img/imgService.h @@ -369,10 +369,12 @@ public: */ virtual void transform (const db::DCplxTrans &trans); +#if defined(HAVE_QT) /** * @brief Create the properties page */ virtual lay::PropertiesPage *properties_page (db::Manager *manager, QWidget *parent); +#endif /** * @brief Get the selection for the properties page diff --git a/src/laybasic/laybasic/layColor.h b/src/laybasic/laybasic/layColor.h index 1be4ae0b1..48766d3e0 100644 --- a/src/laybasic/laybasic/layColor.h +++ b/src/laybasic/laybasic/layColor.h @@ -37,6 +37,14 @@ namespace lay */ typedef uint32_t color_t; +/** + * @brief Gets the color components from a color_t + */ +inline unsigned int alpha (color_t c) { return (c >> 24) & 0xff; } +inline unsigned int red (color_t c) { return (c >> 16) & 0xff; } +inline unsigned int green (color_t c) { return (c >> 8) & 0xff; } +inline unsigned int blue (color_t c) { return c & 0xff; } + /** * @brief A wrapper for a color value * diff --git a/src/laybasic/laybasic/layDragDropData.cc b/src/laybasic/laybasic/layDragDropData.cc new file mode 100644 index 000000000..76ceadf80 --- /dev/null +++ b/src/laybasic/laybasic/layDragDropData.cc @@ -0,0 +1,108 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 "layDragDropData.h" + +#include +#include + +namespace lay +{ + +// --------------------------------------------------------------- +// Implementation of DragDropDataBase + +const char *drag_drop_mime_type () +{ + return "application/klayout-ddd"; +} + +QMimeData * +DragDropDataBase::to_mime_data () const +{ + QMimeData *mimeData = new QMimeData(); + mimeData->setData (QString::fromUtf8 (drag_drop_mime_type ()), serialized ()); + return mimeData; +} + +// --------------------------------------------------------------- +// Implementation of CellDragDropData + +QByteArray +CellDragDropData::serialized () const +{ + QByteArray data; + QDataStream stream (&data, QIODevice::WriteOnly); + + stream << QString::fromUtf8 ("CellDragDropData"); + stream << (quintptr) mp_layout; + stream << (quintptr) mp_library; + stream << m_cell_index; + stream << m_is_pcell; + stream << int (m_pcell_params.size ()); + for (std::vector::const_iterator i = m_pcell_params.begin (); i != m_pcell_params.end (); ++i) { + stream << tl::to_qstring (i->to_parsable_string ()); + } + + return data; +} + +bool +CellDragDropData::deserialize (const QByteArray &ba) +{ + QDataStream stream (const_cast (&ba), QIODevice::ReadOnly); + + QString tag; + stream >> tag; + + if (tag == QString::fromUtf8 ("CellDragDropData")) { + + quintptr p = 0; + stream >> p; + mp_layout = reinterpret_cast (p); + stream >> p; + mp_library = reinterpret_cast (p); + stream >> m_cell_index; + stream >> m_is_pcell; + + m_pcell_params.clear (); + int n = 0; + stream >> n; + while (n-- > 0) { + QString s; + stream >> s; + std::string stl_s = tl::to_string (s); + tl::Extractor ex (stl_s.c_str ()); + m_pcell_params.push_back (tl::Variant ()); + ex.read (m_pcell_params.back ()); + } + + return true; + + } else { + + return false; + + } +} + +} diff --git a/src/laybasic/laybasic/layDragDropData.h b/src/laybasic/laybasic/layDragDropData.h new file mode 100644 index 000000000..c830debe3 --- /dev/null +++ b/src/laybasic/laybasic/layDragDropData.h @@ -0,0 +1,171 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 + +*/ + + +#ifndef HDR_layDragDropData +#define HDR_layDragDropData + +#include "laybasicCommon.h" + +#include "dbLayout.h" +#include "dbLibrary.h" + +#include +#include + +#include + +namespace lay +{ + +LAYBASIC_PUBLIC const char *drag_drop_mime_type (); + +/** + * @brief A helper class required to store the drag/drop data + * + * Drag/drop data is basically a collection of key/value pairs. + * A category string is provided to identify the kind of data. + */ + +class LAYBASIC_PUBLIC DragDropDataBase +{ +public: + /** + * @brief Default constructor + */ + DragDropDataBase () { } + + /** + * @brief Dtor + */ + virtual ~DragDropDataBase () { } + + /** + * @brief Serializes itself to an QByteArray + */ + virtual QByteArray serialized () const = 0; + + /** + * @brief Try deserialization from an QByteArray + * + * Returns false, if deserialization failed. + */ + virtual bool deserialize (const QByteArray &ba) = 0; + + /** + * @brief Create a QMimeData object from the object + */ + QMimeData *to_mime_data () const; +}; + +/** + * @brief Drag/drop data for a cell + */ + +class LAYBASIC_PUBLIC CellDragDropData + : public DragDropDataBase +{ +public: + /** + * @brief Default ctor + */ + CellDragDropData () + : mp_layout (0), mp_library (0), m_cell_index (0), m_is_pcell (false) + { + // .. nothing yet .. + } + + /** + * @brief Specifies drag & drop of a cell + * + * @param layout the layout where the cell lives in + * @param cell_index The index of the cell + */ + CellDragDropData (const db::Layout *layout, const db::Library *library, db::cell_index_type cell_or_pcell_index, bool is_pcell, const std::vector &pcell_params = std::vector ()) + : mp_layout (layout), mp_library (library), m_cell_index (cell_or_pcell_index), m_is_pcell (is_pcell), m_pcell_params (pcell_params) + { + // .. nothing yet .. + } + + /** + * @brief Gets the layout object where the cell lives in + */ + const db::Layout *layout () const + { + return mp_layout; + } + + /** + * @brief Gets the layout object where the cell lives in + */ + const db::Library *library () const + { + return mp_library; + } + + /** + * @brief PCell parameters + */ + const std::vector &pcell_params () const + { + return m_pcell_params; + } + + /** + * @brief Gets the index of the cell + */ + db::cell_index_type cell_index () const + { + return m_cell_index; + } + + /** + * @brief Gets a value indicating whether the cell is a pcell + */ + bool is_pcell () const + { + return m_is_pcell; + } + + /** + * @brief Serializes itself to an QByteArray + */ + virtual QByteArray serialized () const; + + /** + * @brief Try deserialization from an QByteArray + * + * Returns false, if deserialization failed. + */ + bool deserialize (const QByteArray &ba); + +private: + const db::Layout *mp_layout; + const db::Library *mp_library; + db::cell_index_type m_cell_index; + bool m_is_pcell; + std::vector m_pcell_params; +}; + +} + +#endif From a737b80b6514559348b65ebb5fd5e532fb678a8a Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 8 May 2022 23:58:19 +0200 Subject: [PATCH 47/88] Some cleanup + added TODO comments --- src/edt/edt/edtMainService.cc | 77 +++++++++++++++++++++++++++++++---- 1 file changed, 68 insertions(+), 9 deletions(-) diff --git a/src/edt/edt/edtMainService.cc b/src/edt/edt/edtMainService.cc index 955af10f5..0e54aa364 100644 --- a/src/edt/edt/edtMainService.cc +++ b/src/edt/edt/edtMainService.cc @@ -397,10 +397,15 @@ MainService::cm_ascend () void MainService::cm_flatten_insts () { +#if ! defined(HAVE_QT) + tl_assert (false); // see TODO +#endif + tl_assert (view ()->is_editable ()); check_no_guiding_shapes (); #if defined(HAVE_QT) + // TODO: make parameters persistent so we can set them externally if (! (flatten_inst_options_dialog ()->exec_dialog (m_flatten_insts_levels, m_flatten_prune) && m_flatten_insts_levels != 0)) { return; } @@ -973,6 +978,10 @@ MainService::cm_resolve_arefs () void MainService::cm_make_cell () { +#if ! defined(HAVE_QT) + tl_assert (false); // see TODO +#endif + tl_assert (view ()->is_editable ()); check_no_guiding_shapes (); @@ -993,6 +1002,7 @@ MainService::cm_make_cell () const lay::CellView &cv = view ()->cellview (cv_index); #if defined(HAVE_QT) + // TODO: make parameters persistent so we can set them externally if (! make_cell_options_dialog ()->exec_dialog (cv->layout (), m_make_cell_name, m_origin_mode_x, m_origin_mode_y)) { return; } @@ -1145,7 +1155,10 @@ MainService::cm_convert_to_cell () void MainService::cm_convert_to_pcell () { -#if defined(HAVE_QT) // @@@ +#if ! defined(HAVE_QT) + tl_assert (false); // see TODO +#endif + tl_assert (view ()->is_editable ()); check_no_guiding_shapes (); @@ -1163,7 +1176,7 @@ MainService::cm_convert_to_pcell () } // Collected items - QStringList items; + std::vector pcell_items; // Collect the libraries and PCells within these libraries that are candidates here std::vector > pcells; @@ -1190,7 +1203,7 @@ MainService::cm_convert_to_pcell () // We have positive hit if (pc_decl) { pcells.push_back (std::make_pair (lib, pc->second)); - items.push_back (tl::to_qstring (lib->get_name () + "." + pc_decl->name ())); + pcell_items.push_back (lib->get_name () + "." + pc_decl->name ()); } } catch (...) { @@ -1201,6 +1214,19 @@ MainService::cm_convert_to_pcell () } + if (pcell_items.empty ()) { + throw tl::Exception (tl::to_string (tr ("No PCell found that accepts the selected shapes for conversion."))); + } + + int index = 0; + +#if defined(HAVE_QT) + // TODO: In Qt-less case keep selection persistent so we can set it externally + QStringList items; + for (auto i = pcell_items.begin (); i != pcell_items.end (); ++i) { + items.push_back (tl::to_qstring (*i)); + } + bool ok = false; QString item = QInputDialog::getItem (view ()->widget (), tr ("Select Target PCell"), @@ -1210,10 +1236,11 @@ MainService::cm_convert_to_pcell () return; } - int index = items.indexOf (item); + index = items.indexOf (item); if (index < 0) { return; } +#endif db::Library *lib = pcells [index].first; db::pcell_id_type pcid = pcells [index].second; @@ -1313,7 +1340,6 @@ MainService::cm_convert_to_pcell () manager ()->commit (); throw; } -#endif } static bool extract_rad (std::vector &poly, double &rinner, double &router, unsigned int &n) @@ -1359,6 +1385,10 @@ static bool extract_rad (std::vector &poly, double &rinner, double void MainService::cm_round_corners () { +#if ! defined(HAVE_QT) + tl_assert (false); // see TODO +#endif + tl_assert (view ()->is_editable ()); check_no_guiding_shapes (); @@ -1419,6 +1449,7 @@ MainService::cm_round_corners () router *= dbu; #if defined(HAVE_QT) + // TODO: make parameters persistent so we can set them externally if (! round_corners_dialog ()->exec_dialog (cv->layout (), m_router, m_rinner, m_npoints, m_undo_before_apply, router, rinner, n, has_extracted)) { return; } @@ -1483,7 +1514,10 @@ MainService::cm_round_corners () void MainService::cm_size () { -#if defined(HAVE_QT) // @@@ +#if ! defined(HAVE_QT) + tl_assert (false); // see TODO +#endif + tl_assert (view ()->is_editable ()); check_no_guiding_shapes (); @@ -1523,6 +1557,10 @@ MainService::cm_size () throw tl::Exception (tl::to_string (tr ("Selection does not contain polygons"))); } + std::string sl ("0.0"); + +#if defined(HAVE_QT) + // TODO: keep the value persistent so we can set it externally in the Qt-less case bool ok = false; QString s = QInputDialog::getText (view ()->widget (), tr ("Sizing"), @@ -1534,8 +1572,10 @@ MainService::cm_size () return; } + sl = tl::to_string (s); +#endif + double dx = 0.0, dy = 0.0; - std::string sl (tl::to_string (s)); tl::Extractor ex (sl.c_str ()); ex.read (dx); if (ex.test (",")) { @@ -1595,7 +1635,6 @@ MainService::cm_size () } manager ()->commit (); -#endif } void @@ -1794,12 +1833,17 @@ inst_bbox (const db::CplxTrans &tr, lay::LayoutView *view, int cv_index, const d void MainService::cm_align () { +#if ! defined(HAVE_QT) + tl_assert (false); // see TODO +#endif + tl_assert (view ()->is_editable ()); check_no_guiding_shapes (); std::vector edt_services = view ()->get_plugins (); #if defined(HAVE_QT) + // TODO: make parameters persistent so we can set them externally if (! align_options_dialog ()->exec_dialog (m_align_hmode, m_align_vmode, m_align_visible_layers)) { return; } @@ -1882,12 +1926,17 @@ MainService::cm_align () void MainService::cm_distribute () { +#if ! defined(HAVE_QT) + tl_assert (false); // see TODO +#endif + tl_assert (view ()->is_editable ()); check_no_guiding_shapes (); std::vector edt_services = view ()->get_plugins (); #if defined(HAVE_QT) + // TODO: make parameters persistent so we can set them externally if (! distribute_options_dialog ()->exec_dialog (m_hdistribute, m_distribute_hmode, m_distribute_hpitch, m_distribute_hspace, m_vdistribute, m_distribute_vmode, m_distribute_vpitch, m_distribute_vspace, m_distribute_visible_layers)) { @@ -1992,6 +2041,10 @@ MainService::cm_distribute () void MainService::cm_make_array () { +#if ! defined(HAVE_QT) + tl_assert (false); // see TODO +#endif + size_t n = 0; check_no_guiding_shapes (); @@ -2008,6 +2061,7 @@ MainService::cm_make_array () } #if defined(HAVE_QT) + // TODO: make parameters persistent so we can set them externally if (! make_array_options_dialog ()->exec_dialog (m_array_a, m_array_na, m_array_b, m_array_nb)) { return; } @@ -2097,7 +2151,10 @@ MainService::cm_make_array () void MainService::cm_tap () { -#if defined(HAVE_QT) // @@@ +#if ! defined(HAVE_QT) + tl_assert (false); // see TODO +#endif + if (! view ()->view_object_widget ()->mouse_in_window ()) { return; } @@ -2134,6 +2191,8 @@ MainService::cm_tap () // List the layers under the cursor as pop up a menu +#if defined(HAVE_QT) + // TODO: what to do here in Qt-less case? Store results in configuration so they can be retrieved externally? std::unique_ptr menu (new QMenu (view ()->widget ())); menu->show (); From 7fe0e95eee284f172459e0d0cbd91d1be6db7e64 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Mon, 9 May 2022 00:16:48 +0200 Subject: [PATCH 48/88] WIP: first debugging --- src/laybasic/laybasic/layLayoutView.cc | 7 +++++-- src/laybasic/laybasic/layLayoutViewBase.cc | 2 -- src/laybasic/laybasic/layViewObject.cc | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/laybasic/laybasic/layLayoutView.cc b/src/laybasic/laybasic/layLayoutView.cc index 9ad09fe7b..0eca02e84 100644 --- a/src/laybasic/laybasic/layLayoutView.cc +++ b/src/laybasic/laybasic/layLayoutView.cc @@ -173,6 +173,7 @@ LayoutView::init_ui () QVBoxLayout *vbl = new QVBoxLayout (this); vbl->setContentsMargins (0, 0, 0, 0); vbl->setSpacing (0); + vbl->addWidget (view_object_widget ()); if ((options () & LV_NoHierarchyPanel) == 0 && (options () & LV_Naked) == 0) { @@ -283,6 +284,8 @@ LayoutView::init_ui () } + config_setup (); + mp_timer = new QTimer (this); connect (mp_timer, SIGNAL (timeout ()), this, SLOT (timer ())); mp_timer->start (timer_interval); @@ -1119,13 +1122,13 @@ namespace lay LayoutView::LayoutView (db::Manager *mgr, bool editable, lay::Plugin *plugin_parent, unsigned int options) : LayoutViewBase (this, mgr, editable, plugin_parent, options) { - // .. nothing yet .. + config_setup (); } LayoutView::LayoutView (lay::LayoutView *source, db::Manager *mgr, bool editable, lay::Plugin *plugin_parent, unsigned int options) : LayoutViewBase (this, source, mgr, editable, plugin_parent, options) { - // .. nothing yet .. + config_setup (); } // NOTE: this methods needs to be called "frequently" diff --git a/src/laybasic/laybasic/layLayoutViewBase.cc b/src/laybasic/laybasic/layLayoutViewBase.cc index 4b0487e19..50c118920 100644 --- a/src/laybasic/laybasic/layLayoutViewBase.cc +++ b/src/laybasic/laybasic/layLayoutViewBase.cc @@ -421,8 +421,6 @@ LayoutViewBase::init (db::Manager *mgr) } create_plugins (); - - config_setup (); } LayoutViewBase::~LayoutViewBase () diff --git a/src/laybasic/laybasic/layViewObject.cc b/src/laybasic/laybasic/layViewObject.cc index be11f9220..bd4694ab5 100644 --- a/src/laybasic/laybasic/layViewObject.cc +++ b/src/laybasic/laybasic/layViewObject.cc @@ -882,7 +882,7 @@ void ViewObjectWidget::leaveEvent (QEvent * /*event*/) { BEGIN_PROTECTED - begin_mouse_event (); + send_leave_event (); END_PROTECTED } @@ -938,7 +938,7 @@ BEGIN_PROTECTED p = db::DPoint (e->position ().x (), e->position ().y ()); #endif - send_mouse_press_event (p, qt_to_buttons (e->buttons (), e->modifiers ())); + send_mouse_release_event (p, qt_to_buttons (e->buttons (), e->modifiers ())); END_PROTECTED } From f827e693ef98c0fefd80cfaf15c9560ae739d4fe Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Mon, 9 May 2022 00:29:48 +0200 Subject: [PATCH 49/88] Fixed Qt-less build --- src/edt/edt/edtMainService.cc | 5 ++++- src/laybasic/laybasic/layEditorServiceBase.cc | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/edt/edt/edtMainService.cc b/src/edt/edt/edtMainService.cc index 0e54aa364..73957aebd 100644 --- a/src/edt/edt/edtMainService.cc +++ b/src/edt/edt/edtMainService.cc @@ -1331,7 +1331,10 @@ MainService::cm_convert_to_pcell () } if (any_non_converted) { - QMessageBox::warning (view ()->widget (), tr ("Warning"), tr ("Some of the shapes could not be converted to the desired PCell")); + tl::warn << tl::to_string (tr ("Some of the shapes could not be converted to the desired PCell")); +#if defined(HAVE_QT) + QMessageBox::warning (view (), tr ("Warning"), tr ("Some of the shapes could not be converted to the desired PCell")); +#endif } manager ()->commit (); diff --git a/src/laybasic/laybasic/layEditorServiceBase.cc b/src/laybasic/laybasic/layEditorServiceBase.cc index 74a751b8b..55b9c44f2 100644 --- a/src/laybasic/laybasic/layEditorServiceBase.cc +++ b/src/laybasic/laybasic/layEditorServiceBase.cc @@ -307,7 +307,7 @@ EditorServiceBase::show_error (tl::Exception &ex) { tl::error << ex.msg (); #if defined(HAVE_QT) - QMessageBox::critical (0, tr ("Error"), tl::to_qstring (ex.msg ())); + QMessageBox::critical (widget (), tr ("Error"), tl::to_qstring (ex.msg ())); #endif } From d0f566f84e064e1c386da68bfeee3ea307935adc Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Mon, 9 May 2022 01:05:15 +0200 Subject: [PATCH 50/88] Fixed a memory bug --- src/laybasic/laybasic/layLayoutCanvas.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/laybasic/laybasic/layLayoutCanvas.cc b/src/laybasic/laybasic/layLayoutCanvas.cc index dfab18f02..f067eb4ae 100644 --- a/src/laybasic/laybasic/layLayoutCanvas.cc +++ b/src/laybasic/laybasic/layLayoutCanvas.cc @@ -640,7 +640,7 @@ LayoutCanvas::paintEvent (QPaintEvent *) // render the foreground parts .. if (m_oversampling == 1) { - QImage img = full_image.to_image (); + QImage img = full_image.to_image_copy (); // NOTE: seems like it's required to create a copy as QPixmap stores a reference to the image #if QT_VERSION > 0x050000 img.setDevicePixelRatio (double (m_dpr)); #endif @@ -649,7 +649,7 @@ LayoutCanvas::paintEvent (QPaintEvent *) lay::PixelBuffer subsampled_image (m_viewport.width (), m_viewport.height ()); subsampled_image.set_transparent (mp_image->transparent ()); subsample (full_image, subsampled_image, m_oversampling, m_gamma); - QImage img = subsampled_image.to_image (); + QImage img = subsampled_image.to_image_copy (); // NOTE: seems like it's required to create a copy as QPixmap stores a reference to the image #if QT_VERSION > 0x050000 img.setDevicePixelRatio (double (m_dpr)); #endif @@ -658,7 +658,7 @@ LayoutCanvas::paintEvent (QPaintEvent *) } else if (m_oversampling == 1) { - QImage img = mp_image->to_image (); + QImage img = mp_image->to_image_copy (); // NOTE: seems like it's required to create a copy as QPixmap stores a reference to the image #if QT_VERSION > 0x050000 img.setDevicePixelRatio (double (m_dpr)); #endif @@ -669,7 +669,7 @@ LayoutCanvas::paintEvent (QPaintEvent *) lay::PixelBuffer subsampled_image (m_viewport.width (), m_viewport.height ()); subsampled_image.set_transparent (mp_image->transparent ()); subsample (*mp_image, subsampled_image, m_oversampling, m_gamma); - QImage img = subsampled_image.to_image (); + QImage img = subsampled_image.to_image_copy (); // NOTE: seems like it's required to create a copy as QPixmap stores a reference to the image #if QT_VERSION > 0x050000 img.setDevicePixelRatio (double (m_dpr)); #endif From fd8407b35b036bf902dec516e1465cd6b36c7eac Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Mon, 9 May 2022 01:15:14 +0200 Subject: [PATCH 51/88] Code simplification and less image copies --- src/laybasic/laybasic/layLayoutCanvas.cc | 83 +++++++++--------------- src/laybasic/laybasic/layLayoutCanvas.h | 4 +- 2 files changed, 31 insertions(+), 56 deletions(-) diff --git a/src/laybasic/laybasic/layLayoutCanvas.cc b/src/laybasic/laybasic/layLayoutCanvas.cc index f067eb4ae..482c5806f 100644 --- a/src/laybasic/laybasic/layLayoutCanvas.cc +++ b/src/laybasic/laybasic/layLayoutCanvas.cc @@ -22,11 +22,8 @@ #if defined(HAVE_QT) # include -# include -# include # include # include -# include # include #endif @@ -286,9 +283,7 @@ LayoutCanvas::LayoutCanvas (lay::LayoutViewBase *view) #endif mp_view (view), mp_image (0), mp_image_bg (0), -#if defined(HAVE_QT) - mp_pixmap (0), -#endif + mp_image_fg (0), m_background (0), m_foreground (0), m_active (0), m_oversampling (1), m_dpr (1), @@ -340,12 +335,10 @@ LayoutCanvas::~LayoutCanvas () delete mp_image_bg; mp_image_bg = 0; } -#if defined(HAVE_QT) - if (mp_pixmap) { - delete mp_pixmap; - mp_pixmap = 0; + if (mp_image_fg) { + delete mp_image_fg; + mp_image_fg = 0; } -#endif if (mp_redraw_thread) { delete mp_redraw_thread; mp_redraw_thread = 0; @@ -454,12 +447,10 @@ LayoutCanvas::prepare_drawing () delete mp_image; } mp_image = new lay::PixelBuffer (m_viewport_l.width (), m_viewport_l.height ()); -#if defined(HAVE_QT) - if (mp_pixmap) { - delete mp_pixmap; - mp_pixmap = 0; + if (mp_image_fg) { + delete mp_image_fg; + mp_image_fg = 0; } -#endif } mp_image->fill (m_background); @@ -565,12 +556,10 @@ LayoutCanvas::update_image () void LayoutCanvas::free_resources () { -#if defined(HAVE_QT) - if (mp_pixmap) { - delete mp_pixmap; - mp_pixmap = 0; + if (mp_image_fg) { + delete mp_image_fg; + mp_image_fg = 0; } -#endif } #if defined(HAVE_QT) @@ -608,9 +597,9 @@ LayoutCanvas::paintEvent (QPaintEvent *) // render the main bitmaps to_image (m_view_ops, dither_pattern (), line_styles (), background_color (), foreground_color (), active_color (), this, *mp_image, m_viewport_l.width (), m_viewport_l.height ()); - if (mp_pixmap) { - delete mp_pixmap; - mp_pixmap = 0; + if (mp_image_fg) { + delete mp_image_fg; + mp_image_fg = 0; } m_update_image = false; @@ -620,18 +609,18 @@ LayoutCanvas::paintEvent (QPaintEvent *) // create a base pixmap consisting of the layout with background // and static foreground objects - if (! mp_pixmap || needs_update_static () || - int (mp_image->width ()) != mp_pixmap->size ().width () * int (m_oversampling) || - int (mp_image->height ()) != mp_pixmap->size ().height () * int (m_oversampling)) { + if (! mp_image_fg || needs_update_static () || + int (mp_image->width ()) != (int) mp_image_fg->width () * int (m_oversampling) || + int (mp_image->height ()) != (int) mp_image_fg->height () * int (m_oversampling)) { - if (mp_pixmap) { - delete mp_pixmap; + if (mp_image_fg) { + delete mp_image_fg; } clear_fg_bitmaps (); do_render (m_viewport_l, *this, true); - mp_pixmap = new QPixmap (); + mp_image_fg = new lay::PixelBuffer (); if (fg_bitmaps () > 0) { @@ -640,40 +629,24 @@ LayoutCanvas::paintEvent (QPaintEvent *) // render the foreground parts .. if (m_oversampling == 1) { - QImage img = full_image.to_image_copy (); // NOTE: seems like it's required to create a copy as QPixmap stores a reference to the image -#if QT_VERSION > 0x050000 - img.setDevicePixelRatio (double (m_dpr)); -#endif - *mp_pixmap = QPixmap::fromImage (img); // Qt 4.6.0 workaround + *mp_image_fg = full_image; } else { lay::PixelBuffer subsampled_image (m_viewport.width (), m_viewport.height ()); subsampled_image.set_transparent (mp_image->transparent ()); subsample (full_image, subsampled_image, m_oversampling, m_gamma); - QImage img = subsampled_image.to_image_copy (); // NOTE: seems like it's required to create a copy as QPixmap stores a reference to the image -#if QT_VERSION > 0x050000 - img.setDevicePixelRatio (double (m_dpr)); -#endif - *mp_pixmap = QPixmap::fromImage (img); // Qt 4.6.0 workaround + *mp_image_fg = subsampled_image; } } else if (m_oversampling == 1) { - QImage img = mp_image->to_image_copy (); // NOTE: seems like it's required to create a copy as QPixmap stores a reference to the image -#if QT_VERSION > 0x050000 - img.setDevicePixelRatio (double (m_dpr)); -#endif - *mp_pixmap = QPixmap::fromImage (img); + *mp_image_fg = *mp_image; } else { lay::PixelBuffer subsampled_image (m_viewport.width (), m_viewport.height ()); subsampled_image.set_transparent (mp_image->transparent ()); subsample (*mp_image, subsampled_image, m_oversampling, m_gamma); - QImage img = subsampled_image.to_image_copy (); // NOTE: seems like it's required to create a copy as QPixmap stores a reference to the image -#if QT_VERSION > 0x050000 - img.setDevicePixelRatio (double (m_dpr)); -#endif - *mp_pixmap = QPixmap::fromImage (img); + *mp_image_fg = subsampled_image; } @@ -687,7 +660,11 @@ LayoutCanvas::paintEvent (QPaintEvent *) // produce the pixmap first and then overdraw with dynamic content. QPainter painter (this); - painter.drawPixmap (QPoint (0, 0), *mp_pixmap); + QImage img = mp_image_fg->to_image (); +#if QT_VERSION > 0x050000 + img.setDevicePixelRatio (double (m_dpr)); +#endif + painter.drawImage (QPoint (0, 0), img); if (fg_bitmaps () > 0) { @@ -703,7 +680,7 @@ LayoutCanvas::paintEvent (QPaintEvent *) #if QT_VERSION > 0x050000 img.setDevicePixelRatio (double (m_dpr)); #endif - painter.drawPixmap (QPoint (0, 0), QPixmap::fromImage (img)); + painter.drawImage (QPoint (0, 0), img); } else { lay::PixelBuffer subsampled_image (m_viewport.width (), m_viewport.height ()); subsampled_image.set_transparent (true); @@ -712,7 +689,7 @@ LayoutCanvas::paintEvent (QPaintEvent *) #if QT_VERSION > 0x050000 img.setDevicePixelRatio (double (m_dpr)); #endif - painter.drawPixmap (QPoint (0, 0), QPixmap::fromImage (img)); + painter.drawImage (QPoint (0, 0), img); } } diff --git a/src/laybasic/laybasic/layLayoutCanvas.h b/src/laybasic/laybasic/layLayoutCanvas.h index 2083745da..67466068b 100644 --- a/src/laybasic/laybasic/layLayoutCanvas.h +++ b/src/laybasic/laybasic/layLayoutCanvas.h @@ -371,9 +371,7 @@ private: lay::LayoutViewBase *mp_view; lay::PixelBuffer *mp_image; lay::PixelBuffer *mp_image_bg; -#if defined(HAVE_QT) - QPixmap *mp_pixmap; -#endif + lay::PixelBuffer *mp_image_fg; db::DBox m_precious_box; lay::Viewport m_viewport, m_viewport_l; lay::color_t m_background; From 7bb3e0daf33f5778e1d642c787be7f67f1fac433 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Mon, 9 May 2022 21:21:45 +0200 Subject: [PATCH 52/88] Bugfix for color interpolation (asserted) --- src/img/img/imgObject.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/img/img/imgObject.cc b/src/img/img/imgObject.cc index 333789e86..e2912b2d1 100644 --- a/src/img/img/imgObject.cc +++ b/src/img/img/imgObject.cc @@ -200,8 +200,12 @@ DataMapping::create_data_mapping (bool monochrome, double xmin, double xmax, uns unsigned int h2, s2, v2; false_color_nodes [i].second.first.get_hsv (h2, s2, v2); + int dh = int (h1) - int (h2); + int ds = int (s1) - int (s2); + int dv = int (v1) - int (v2); + // The number of steps is chosen such that the full HSV band divides into approximately 200 steps - double nsteps = 0.5 * sqrt (double (h1 - h2) * double (h1 - h2) + double (s1 - s2) * double (s1 - s2) + double (v1 - v2) * double (v1 - v2)); + double nsteps = 0.5 * sqrt (double (dh * dh) + double (ds * ds) + double (dv * dv)); int n = int (floor (nsteps + 1.0)); double dx = (false_color_nodes [i].first - false_color_nodes [i - 1].first) / n; double x = false_color_nodes [i - 1].first; @@ -302,9 +306,9 @@ interpolated_color (const DataMapping::false_color_nodes_type &nodes, double x) unsigned int h2 = 0, s2 = 0, v2 = 0; p->second.first.get_hsv (h2, s2, v2); - int h = int (0.5 + h1 + double(x - x1) * double (h2 - h1) / double(x2 - x1)); - int s = int (0.5 + s1 + double(x - x1) * double (s2 - s1) / double(x2 - x1)); - int v = int (0.5 + v1 + double(x - x1) * double (v2 - v1) / double(x2 - x1)); + int h = int (0.5 + h1 + double(x - x1) * double (int (h2) - int (h1)) / double(x2 - x1)); + int s = int (0.5 + s1 + double(x - x1) * double (int (s2) - int (s1)) / double(x2 - x1)); + int v = int (0.5 + v1 + double(x - x1) * double (int (v2) - int (v1)) / double(x2 - x1)); return lay::Color::from_hsv ((unsigned int) h, (unsigned int) s, (unsigned int) v); From 128afc43cf108cc26f3c131436e7ac77655a8ade Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Mon, 9 May 2022 22:13:35 +0200 Subject: [PATCH 53/88] Support for grayscale formats in PNG reader for PixelBuffer, writing non-alpha RGB versions from non-transparent PixelBuffers --- src/laybasic/laybasic/layPixelBuffer.cc | 80 ++++++++++++++-- .../unit_tests/layPixelBufferTests.cc | 86 +++++++++++++++++- testdata/lay/au_gs.png | Bin 0 -> 5697 bytes testdata/lay/png3.png | Bin 0 -> 5694 bytes testdata/lay/png4.png | Bin 0 -> 5198 bytes 5 files changed, 158 insertions(+), 8 deletions(-) create mode 100644 testdata/lay/au_gs.png create mode 100644 testdata/lay/png3.png create mode 100644 testdata/lay/png4.png diff --git a/src/laybasic/laybasic/layPixelBuffer.cc b/src/laybasic/laybasic/layPixelBuffer.cc index 9a1320353..90d7eafdd 100644 --- a/src/laybasic/laybasic/layPixelBuffer.cc +++ b/src/laybasic/laybasic/layPixelBuffer.cc @@ -28,6 +28,8 @@ # include #endif +#include + namespace lay { @@ -385,6 +387,8 @@ PixelBuffer::read_png (tl::InputStream &input) memcpy ((void *) res.scan_line (i), (void *) row_pointers [i], sizeof (lay::color_t) * res.width ()); } + res.set_transparent (true); + } else if (fmt == PNG_COLOR_TYPE_RGB && bd == 8) { // RGB has 3 bytes per pixel which need to be transformed into RGB32 @@ -398,17 +402,56 @@ PixelBuffer::read_png (tl::InputStream &input) const uint8_t *d = row_pointers [i]; const uint8_t *dd = d + rb; while (d < dd) { - uint8_t b = *d++; - uint8_t g = *d++; - uint8_t r = *d++; + lay::color_t b = *d++; + lay::color_t g = *d++; + lay::color_t r = *d++; *c++ = 0xff000000 | ((r << 8 | g) << 8) | b; } } + } else if (fmt == PNG_COLOR_TYPE_GRAY_ALPHA && bd == 8) { + + // GA format has 2 bytes per pixel (alpha, gray) which need to be transformed into ARGB + + unsigned int rb = png_get_rowbytes (png_ptr, info_ptr); + tl_assert (rb == res.width () * 2); + + png_bytepp row_pointers = png_get_rows (png_ptr, info_ptr); + for (unsigned int i = 0; i < res.height (); ++i) { + lay::color_t *c = res.scan_line (i); + const uint8_t *d = row_pointers [i]; + const uint8_t *dd = d + rb; + while (d < dd) { + lay::color_t g = *d++; + lay::color_t a = *d++; + *c++ = (a << 24) | ((g << 8 | g) << 8) | g; + } + } + + res.set_transparent (true); + + } else if (fmt == PNG_COLOR_TYPE_GRAY && bd == 8) { + + // G format has 1 byte per pixel (gray) which need to be transformed into ARGB + + unsigned int rb = png_get_rowbytes (png_ptr, info_ptr); + tl_assert (rb == res.width ()); + + png_bytepp row_pointers = png_get_rows (png_ptr, info_ptr); + for (unsigned int i = 0; i < res.height (); ++i) { + lay::color_t *c = res.scan_line (i); + const uint8_t *d = row_pointers [i]; + const uint8_t *dd = d + rb; + while (d < dd) { + lay::color_t g = *d++; + *c++ = 0xff000000 | ((g << 8 | g) << 8) | g; + } + } + } else { png_destroy_read_struct(&png_ptr, &info_ptr, NULL); - throw PixelBufferReadError (tl::sprintf (tl::to_string (tr ("PNG reader supports 32 bit RGB or RGBA only (file: %s, format is %d, bit depth is %d)")), input.filename (), fmt, bd)); + throw PixelBufferReadError (tl::sprintf (tl::to_string (tr ("PNG reader supports 8 bit G, GA, RGB or RGBA files only (file: %s, format is %d, bit depth is %d)")), input.filename (), fmt, bd)); } @@ -433,7 +476,7 @@ PixelBuffer::write_png (tl::OutputStream &output) const png_set_bgr (png_ptr); // compatible with lay::color_t unsigned int bd = 8; // bit depth - unsigned int fmt = PNG_COLOR_TYPE_RGBA; + unsigned int fmt = transparent () ? PNG_COLOR_TYPE_RGBA : PNG_COLOR_TYPE_RGB; png_set_IHDR (png_ptr, info_ptr, width (), height (), bd, fmt, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT); @@ -448,8 +491,31 @@ PixelBuffer::write_png (tl::OutputStream &output) const png_write_info (png_ptr, info_ptr); - for (unsigned int i = 0; i < height (); ++i) { - png_write_row (png_ptr, png_const_bytep (scan_line (i))); + if (transparent ()) { + + for (unsigned int i = 0; i < height (); ++i) { + png_write_row (png_ptr, png_const_bytep (scan_line (i))); + } + + } else { + + std::unique_ptr buffer (new uint8_t [width () * 3]); + + for (unsigned int i = 0; i < height (); ++i) { + uint8_t *d = buffer.get (); + const lay::color_t *s = scan_line (i); + const lay::color_t *se = s + width (); + while (s != se) { + lay::color_t c = *s++; + *d++ = c & 0xff; + c >>= 8; + *d++ = c & 0xff; + c >>= 8; + *d++ = c & 0xff; + } + png_write_row (png_ptr, png_const_bytep (buffer.get ())); + } + } png_write_end (png_ptr, info_ptr); diff --git a/src/laybasic/unit_tests/layPixelBufferTests.cc b/src/laybasic/unit_tests/layPixelBufferTests.cc index b02ecc53d..fe57b7545 100644 --- a/src/laybasic/unit_tests/layPixelBufferTests.cc +++ b/src/laybasic/unit_tests/layPixelBufferTests.cc @@ -319,9 +319,93 @@ TEST(4) #endif } +TEST(5) +{ + lay::PixelBuffer img; + + std::string in = tl::testsrc () + "/testdata/lay/png3.png"; // GA + tl::info << "PNG file read (libpng) from " << in; + + { + tl::InputStream stream (in); + img = lay::PixelBuffer::read_png (stream); + } + + std::string tmp = tmp_file ("test.png"); + { + tl::OutputStream stream (tmp); + img.write_png (stream); + } + tl::info << "PNG file written to " << tmp; + + lay::PixelBuffer img2; + + { + tl::InputStream stream (tmp); + img2 = lay::PixelBuffer::read_png (stream); + } + + std::string tmp2 = tmp_file ("test2.png"); + { + tl::OutputStream stream (tmp2); + img2.write_png (stream); + } + tl::info << "PNG file written to " << tmp2; + + EXPECT_EQ (compare_images (img, img2), true); + +#if defined (HAVE_QT) + // Qt cross-check + std::string au = tl::testsrc () + "/testdata/lay/au_gs.png"; + EXPECT_EQ (compare_images (img2.to_image (), au), true); +#endif +} + +TEST(6) +{ + lay::PixelBuffer img; + + std::string in = tl::testsrc () + "/testdata/lay/png4.png"; // G + tl::info << "PNG file read (libpng) from " << in; + + { + tl::InputStream stream (in); + img = lay::PixelBuffer::read_png (stream); + } + + std::string tmp = tmp_file ("test.png"); + { + tl::OutputStream stream (tmp); + img.write_png (stream); + } + tl::info << "PNG file written to " << tmp; + + lay::PixelBuffer img2; + + { + tl::InputStream stream (tmp); + img2 = lay::PixelBuffer::read_png (stream); + } + + std::string tmp2 = tmp_file ("test2.png"); + { + tl::OutputStream stream (tmp2); + img2.write_png (stream); + } + tl::info << "PNG file written to " << tmp2; + + EXPECT_EQ (compare_images (img, img2), true); + +#if defined (HAVE_QT) + // Qt cross-check + std::string au = tl::testsrc () + "/testdata/lay/au_gs.png"; + EXPECT_EQ (compare_images (img2.to_image (), au), true); +#endif +} + #endif -TEST(5) +TEST(7) { { tl::SelfTimer timer ("Run time - lay::Image copy, no write (should be very fast)"); diff --git a/testdata/lay/au_gs.png b/testdata/lay/au_gs.png new file mode 100644 index 0000000000000000000000000000000000000000..427b121bd8d645e74d3676e3b9badcf1d4357a00 GIT binary patch literal 5697 zcmXAtdpy(q`^UTQ?mH?fM7Mk$=9mrLZ4POXbK8ho8#Z*n9OhJn#JD>+pN})gXv1cX zvkFmnX`wYaEQdm&oM|!V!|&t%{V{tyJa~Vu>vcU}uWRqcU$(s{e(2<(ef#!_BM}y8 z;C&o;O^O}>e$FX=!|&TCBZ{;z#oR5Jcln&-1UYiY^ZRa8*bh*z&pG#p{@9EgS5F%! ztG@E>1lJZU3D+Zbmev(pTU(7UoY^sYTDA3ZH(!t^-`wlGxH)G~q`%TX8Fg2AL^L_| zZC3)~CDSnY4XJo@j67HRCO+|MbaT#PTUJt`z6I9m1tmA}88dx_^cw2sF3DU=Of394 zyCf()L9sAhCdC&#Z04Q440|H&qA-`zvw|Y(KtD~TCw;mfwQ=DsY8x~O} zfpR(8^kMS%#D%Wa6Tdbswf{;)w|wM}zx-39h6RCz;L~h_1Y?g@Z~Xgtq(){pO@e)S z?$4K#+zZdi#*-%8q@4HUB#}NpsXO^yZ(F^De9j?_BG_r2$g$H^ER0w0z!Dz=Rt&s9AOqY2-i;dG@Lq~TDsZQX#2`V#29t>ZHquw zwl=?Qm?9SNJYxOeVu4Ham=+pYBRe4YW_?y*&7t-t%r z@GnQES}9E#wTEr*ogTia6T4LU-kg9M4d>12?f5%JPM;=NTKs7%v%ncR++4VN>>twf zqRYNM!lm!uyW(YU_lwJ05<0GZKD`YeX-Ju}daZMIy2X7g?({b6y=BYqMA(RMD1*r~r)?O!g}w0e`q33eyuwys?! z8<$+)aB3a;Y4cZbSns!A<+C1ekcxe3>g(ljD@e(UHj~Hu2R){)Ip69Q`F`E6psB7Y zv)0;*8M(tB-)$TB1J6ial-uns?;Ue|Rj^y_^V&+-^!V@}&M$|4ZaC`uh6aWdkBYg} z5BksM{3g)Hc4nkA|7!F$TIU4+kL7e-q==U)jh`98>s%FZa%3)%UZSiha#d zpNL++nM3&BiHHv8xfzl5N6%VD4cvt16#}kS1!6N8pOCoCA?fC{T5J8;9+AVlU&@sI z9WEAESj_8;HVkMlEw+w$)%L4wb@@Bik7<$(@$S5u&6AiX_Z0F3G*1m z_v+kYlJJ{RhYdp;=S)`yzf(NA9@^h``;cH4=R7l)FzoM4Az6L&Gd}rhhtAQV{?D!H zLe_AA^P=IBY|$!o`(So-+({*5{0r|EgKE#4o|G-Q+a5_CZ#CS98&XKaa{XJaqsuqz z%sMGo@N?mmhi~PO18OQ(8;`e^c3>9uWzn|+R3@v*#-eu$$s)Bd6)2=sZN_`z1=-jU zT`k|7;&qol2(;LcVo zJB7x^MKqihlnLcl3kF5fhWZ2nF&NV87Oud}Kr$peGKmQ;lC5e>YPa{v_vAjy26r>Kgr`p^s?n zEIHVp+4N}o?m8>6Z~haxFLu2$xm-U6!!DB0&d;hV={8^%8h;3d2ZYR9n@v@UYw{pi z+L4T}Or%DKb5EJpk1zHrKucP-1`mTA#5Q4yJ%Sfil2f%AzGV8j0! z#Bb(x_92`s7*;<@>TnU%0T%?`aMXoILEN3B?eJrsYAa(U#(n&r9R2lFYZF~IuJ+Mi zb?>bYh}X+*_G~mL~bnJr}^gU0eBjgYl|+ z14?6r+NSRmyPh-Viea2LUeN5OfHUOG8TjuN9!nPbj-Jzh{YxhsBOa?QEY_LAy`nL~ zBmz)V1L=;2cWl@~$cVd8FPomTg3! zU-$4=Ui7*6W$8!L>1Q@1;yXk zWSc@ZjK&D|wRUQYUEhZz>%mMY3R@)~On3V?1($Fi^($EIn}M_RS(po+H0VpDd@z|Gr@F5JbM}Rwv?qmR=%D$MiC&fMxvT+ev^=<@T$VKf z`1NT8#*$#^=i4VE$lkaMH-twxhH)NYzjA%E(R_201A_C=98+Fz`_MEA^y66dE8L)N zeV@67crH##?TX$F|Aqy!mdm72s=e_!VWxATBQ0);N@z_Fa_iIIxC1H=;WGPEZtx`V z_hBqtocj6`8c{~GTQ=xZ)MWAt6=*+J`>L8^4TilnY|8LJVA>8mpI9yl95w@n*sNi` zpo$HJ8;po;7@T9iJNwkStU96|Ms;AIf~+zm)!g*l@O9&jA0DJE`sj;X{WE1^eE5|O zoj5Jh{nUxmkkU;E3N7rHY6y}fFv>Eu=qEqqC^WORiE^B$9YJsZPc!~IYI-H5SB_GNU6d#lx~28*2kVCa0G^=t47 z13yXh?oFu_3iiqyYKNP#ct3$B`iamJ)W6PvycE(da+Ev5kVJF$Z5yD(3)VT$(bxbM zU>H#|my8{8&OHn=KC7NkC|mW@-IA_&$u}!Y zVf0K)HQuXq+!iszW61(heaNVWC{gRe%N3nMk)dd#^LZEMCtq<_-a4BeQ)rbc(hM0gV> zdyX%O-G3lm2e}&)Y}5zE_6|BxiI4uN6nUuZtm+08z4JP3;o#INJBvP)0--VtoKSHd zmn`i2&SReHeo#$npbxrNpA3CedD(gVeGWrG&Wxd4U#c7Pj?)QHZi}nRhhWeRQ;hzc{+b7@&*+9 zD?AZnnZ_LZGG(fMllsArL`WSstpG|4&A{+e^jI)Nd`?|+8Z042Hg`|^a2jzUpv+h3 zZmFu-4OEs?cX#%;Ws`yBYy;G=$by%uv@ZP!t)z2?rwE|)(IiIQ)n4|cj5)`za znaSzKQlN&EGYI7~yqoZUwXf>!NB|Avc8dmqHJxWJg0AmMmTfbPX0q1v-DkQ?QtilM z)6uJ1@m_mcD2(EK)vu`5hlCaWh6WC1`8GkY-|MbW-95QD#byFa>=B^hjss)H^+lam zJma^F%Vg?qY~y9;*(e5vy}Y>n_}6l*azX5IG3AzYDoy$Gn1aFF;*YGIsebxJxdV zlFAKhuWRld8xIIw9{W$+QRuv*eK9d`LD@+AAL#_2h$m=06t@Dy=Adrl;SaN}jNOaS z4*I#mh9TcXkLBe8nUk+gGxUnMg6nNgp+KMJ6|js$mFT##NaJu6HdP#iWsmdb5Qcdm zH=|aTeTkdRc)@H}RfD)Gci<>| z=7dX24=}z+2|7_I=yWW@SW4C6OYgPcSH*|~TBThB0EEG)pZcxq5p&-EVI&q9qM^yW z>@4L5`o=7zfQ%IN5rad?SzfYEmw32hmv)pkAU#h1in_!VpldfzbSddPP@4K}Mmv5F zXcYoI$9L%Y5i~ZDh^~jJ*QZY94mlkB2vlbS1RWCdC)A;~l7OXyP&JNeWVU)0F-`K3FJS>9n#ZEd|z7!RX6)UKwN>~ zhF^OAPb6tAIFk|Qs|f;Q)xt&4_abc7%XRgufIRt(W$=94eWzs)XG_B~d&c1$r49-b zeYfPf`T~ltfUC>PVkX7MWpB8q=>m5^AFZp5(s-OEmc>%e%#w$edD@N`tB|f91_IK7 zvBAk3Y)&>jGi48ovXi-li9yrsC z(FJLFNK+Qb})(0z?r-W7BtRbzXn*{Ee1E!~BkbqI}QM3E| zGNepxQj;~EjHrD>vcS%jBRK*StDNs03MB#&v6zg;!dE&SRON%LJ(&SM6nz=2qj5yWHQg(<72tR4~*$B$FZPYUx@@@NGL`TH$p)%j~va(&TRh zk9Hz`W`5M%B;benGOaGzcrK|!sl3l~Eh=I>{-Uv#eN5ICj0#qPpjK?DOm1#bwyp4FB4cgYzZ|Iu(99=N_7ziIX293D9NJ$1cJpuSHw&(;0 zS{3QdttNe1OF>I#gK+iyp5k}@e&!pg`VC1Rls&1b4Q98K7d6q?@z@+jWg~HJ81erw zBY;LN0pD}}rh)Tw<9xmE)1o}=-P0s30g^4+sy7~-NN{qsOJl&CH0bA+2<)(JZBj^k zZjoWtu{{qs)ALSaVWLxN1P56sQ`<}%c@gss&y1h+c@#f5U-#%Gtv5de(>~>6sAq}J#DPLde9tF|tJ_Ah7I^qQVq?(5V9o$k=F+3Er ztmt=Y%!9x!uKSxpEX*SRvv)BPb`C7;rJ)Ky= zBz7p!9Heb}5^!AtTibiK`=f*PPgJ!$$eJR#%D)+}OuoOJ8gPEwnGW6r-2i!o03cMN zOYwj6)P%*vzKzf{hJCT9w_fBRI`~KaAg7^(WOe;$%@p9c0T&wBoP$T^m|lj&pRa?b zWmwv-Ey`AHyCbpcXQ~8tPvf}pZ6#Eq`?WzTGp#N!ciHTA)rEvdtdOG;RdW5Af3hQO z1{v%pFmD-6oN;#&a`(jBs=D^KscD((&orFytcqufR`zoysN=UO6I!PMlK{R$C|ik6 zCf9M!uv}#{wFSV37@;=cpN&N&tWnQOM+`Sdl%7{8ElZtKc4IH0_Q1g+_%mX3!R#q) z_aDo~*C&eN*DTtR>x!dyHyY8{mHZME1GQpP) zaB^>EX>4U6ba`-PAZ2)IW&i+q+O1bvlI$uD{bv=u1Q7FbFqnwm!CQVG32@pR6NqYQc`83+er~I9Ej+uMEI^!H5 zbn&D)F_t;Mpx=KUSbLb`-mlUep)?no18YIcI}^UNJxKJ^=r?XIl+W=c4EdP@&xO@4`wDl<5oJ=)?kQ=;p*Lo-D zMshzUv?u%5w+H!DX1{%K8P-DKeZcs4@`d7UV>`bobl(QfbP4lCa_=qmehzfS1uz<> zql9d;mcc|Ic2*t>xFY^NzDKz-uB3~uki6-t4_wt`Lr|qF<4iNfbaTqRnu-t|ofL5= zs$``v*+`ix^f3?zm+2I3w#_E!R_RpMqMNQ*jO?3bziJY8ZU$4yU@;?N|8S|_2LI+# zy;r8l=rnmcSYTpbBMerKKQRk}m_Bv$Lh!n#{Ce{btO^Ca(9G%;eT*dzZ$93#qO-+3 zkNZd=qhgy2fFkVe5sa}=KnG*J2}VbvXbgBv5U3z>vW^ZYV7#Y>Ajw%9NJUD-d*hjC zWG;CM#NDV(5W?GFBeco3KrH7x{1aV*hl;n}dGCXdJ}IAl2{yRkLkKZ&kt@+g7kvyd z#uRfb$tIV43Mrh=xfD_b8x^coFu$PZpu-;S@JBe}k&b+n3j0)7 zeGN6%RC6tjnr$c(EwtED%dMP7ov0M2JN+5Xc&0O-rNe98cGrCmJ@(XdFPCa&rtS0k z3)Re2jYKJ)7cbS&t72SB7%nHCHG^X03>1&701Qp6nNG$zV&zyfoe4?d2|;?+Mm58V zK|*&L^4(n8eU$qn-IPy%q#OM|&8|2yzNCe`>0|3OwvG+FTby>5bFM^=sBn}LB)d?;GOF^IyqZGXB7Nc2TTJxW zGp7-fR^2?=xQRckqnT~S<1g_A4~FJs7!n(Q4d2U->OpID;1R zgRbgd+^%*%n@}OUVbCN1HRrF>W;t9BfK${{?oEs0cw?*Yk}oy}q?N%;L;W_LE^0IU zPRB<>ELqx+cvE;v_{{#h5yc;8mMq4Q^{IGZMmSE(Ydrk@0j#wMtmw{waS2cobDxCk zKQ(~*H9u&>^ja-14G(o67M^Z?fW)P(@&IvJhQ=ZFKslmV3vM`jL8~9d`?R?H&M3U8 zE)IQFKM-#oFlt%imgi|E_8sz-YfHxE2%f5*wr%0<(MJg%&#p%qa8d(t*5?f|4s6!i zZ-7PGiBCW9Vv@QTxsv`PW4#BaUkq@ylmK=QNDl*u#E**jD2P$5GPMJq3TM1yLQQ)J zWc=JYFTCfpv;Y(MY6zSL;PZ_D9%SHc23jPhne>cb*ib*wu_t}~1N{}f>wnDia#gXd zY9Ua`;J6`hp$xGL0l_T&9D$ z%5>y)+g)%sa+xVu0>atccokgq)T4-3Io5~QFU9#y?y7P85^?HB&fi~j-s-_O9qOH( zy(QL=B+jEu!@}lc>Dg2R@#rd3!6yMD$H!~SPx#eN!1W^YsQTwc2(44@ZgI5K&o%FM z1g2Y6J8y^&E?eqex3;ov2mH$dNq@hoY-L>OPg$!E*YEAEtm}bsk+cfi;^-UoRucLn zCmx3&yGgk#&!@9_oo;9GLd*VO?MG9k4=eh27G4gsZCpK4eRIN++RwLv5ju^6+-gfdmQqQ^ZEU_UdNaFIkl(r@p}AS%)ejYZh#-UPeRmF z>9^|F-fKTsYo>>PI(3EL&sqHsfLA{cuEAnz0003aX+uL$Nkc;*aB^>EX>4Tx0C=38 zkiSa9P!z_0ssBYMi-R~sa4oo)$)zfUf?BOf`8`Ops&M`8;Bs(fFTJtA3T=INg0RfHo_9jy`FzDP z`qD98&2xXA#V9UA=}eV{c~OCNAa$KdOI->A?kNeS39))p%~afoN;$b4iuxkm zrXg>u&hwNql*d?JCgF}$o+c0Tf4|p0&gxBTbCw51P`Bn(tH6RtzqptE$r;g{jqfX?kVoc;L6%d(IOW62 z$e*4ubgunhmX}iz>o5Jv?Z9jla&SH^$n4L1iThVb*+qYAY9JfskdGrD5hyT>l5pV@ zs^+uI51fs%F*wy@^=pj^CmdZ>^ZWHz7;&Q`qeA#~xG%HOSIz!hGMQu|KF8r+_?rqb zbTa;iokfkH^+stJZ_gyOB^GDO9Pe8-9bvSra7f^$O8Id3oFEg>IQN##ubK~Y(%E}(tcyV{uLBe*-SZPa0oxMF8&e5dK)4M zAt}Z_Ns!9FePUoa)}Oz7A-;Z_Uj9Q>*5-i9>ECA-P6}R|6+?$mUed3z;*b zo)v?1-q2-(yOVchx?tQ61>j*pzE7e)UBkd=aRfpEvich$dZP+;m zXCVVeZM32QStssVl+ss4UtwteUqKYm70ymU=Xea<%jhr36S=2{yzbPpwAj@OU@UB%;kjoRq{V!ruorsy4?Oi#+h9(^E zA6V^00W5!bws+-8?zNm@h=+0>q^tI>yw9ocZgo^vaTKsdhI0f$V{qJjnHR;J9#y4 ztd~`^$J|y4=XlrJ5N<@(FROMk6!opkVQlgmChNhS3g97q8OftMoOxZIZ|(Q4y30eB ztTL$1RNvaa)c~AuL}isrb!45&T(hPhx_j~sM^^KwPM3F`WqefN5aK&Kx~NXJZ=LB~ z--xPBR*{2{xKt-*Y-HU(@cyht=bu+A7Q$U^%tHZLMkim4E2)oZ!r_xu35RlKQ)H)i z{rzg)-_Dq|cg?EW~({3seiudIqIl&AUD?nP(CT%&IvvWM#A_||#MbuDJ)RAj2| zkyW9g02b8|()UF3qxKL+Wi^5V=2phs@a_JVqPLPIt1BGJ^TL_$T@{l(o~%kZl(=vG z9Pg@@8@X#iwl_XTs7@cCo9A5>w;q<-xYAHSJ4F*tj4L1KLkC#mEm30 zHXW#u)fm+|#kVrek6LDQURm|zqO8-p=<32J%n1iBtCqt%a}I%+6<>{f*3{#LsK&@DTUN8G<22?P2X~6zCT~V&qkw1^ z-I?C?_vce=q>DKt<9i_OC?E^av3zUZqOx z7}Yt+x1!gpb|{uDtIKdL5vntNDq^`dMe0nJtS&e=v#HMM-c>C($9}v+J__Jdoi5)R zdVV81x}(QCWTAlE)kvm!$y{_+?17pQS?xjrnO$`KzV+|Vu%$Rvvbs`2`8?nH`kEEL zExEGlLjfq&d5&)d4^*-F$0@S<>AqFbDr1+`8p2xXTjw%YwTx-c867MXkVAF2O_7!F z5vDkvj9kuK6lW-Vc7ODFR<%wyvSbx)w#u!Jr}YZ_T(d6I%|P0#c(R&Z9nUa2h=M3y zQ>tY(pX$s6be`)_Y^-+3s&)RjLYe6YbX8&7?l#Vn)yTq?Jr^w}2QZCJ)X*@@kXk-+ zWHY%{R$24Mh;NmYjLOJnMaQfVGqMW>c=GQI-)g2fz9-Bfvg*mjI;u0t!DCO+2 zik#TNL;*Qer`x;g{YQx&3g~aM%0dA(tC1C9{qy}54PfM19WhzWLjg6u)#6>f4U>v| z5Jr1djjS@L&WT1xcjIujtY%W3lZ=ky0j!l(49itgoi#Y5L5dUEFc-_kda5&baT!44 z{j!SWVkOn#0lE@V92b?S|d;v>-_tIrg;#7hTM|Dl*pQ%4!t~ z=rcMXQ?<6jM>YdQx>tKq0IQ2`9L2#avJX@~y%M zBS%)_`;aqNJEABc*SAK)8lX6y-N)Xi=tP>WGO11`ptEesQFMecWpxkdBC_g30Wqpm z4e0)1s@Cw?LTG(B8Dq7BIe*MqjpQ4h5XFhNS6O6rZR_M5s#6W<6u-E*tlGO*?K8(& zRHq8i0cbqdA;;Ymz#yz0REGoTT%sCzWNnwM&Y(J35_${cY& zGh}rd)v+6$1gC13)mTPGWfegIJya(j(CIRYg|9M3HU;bh8$Vdrjsj}B=v*f_PLWlQ zxMm!zJFkoGU0BujthP*9wQts$(%>Pht0~ge;Fv3`_Pp#x0o>{s^Q|x%pD(NVD4>e! zID2ujWi`Gj0Fl*v6d|s02&F}2s~4BU6eqTbjJH_{7~c54D<2BrQyoi4)p7xza~-|=knOUXyYH%ZHF6hH zCmNq5s}_qR#-TcKHS#6J5$N`?WHquWAZ~GHP#vbx`PEW2LsoeQA$6btzHfDH#p##T zMU&MI6p-6Rw+-W`$Z91DsP?U4isPGb*n(Ius~uD);#&h~oVOVOuZ@+mDl6;c0KRWk zcotW zF6b698;|h~bCH9P{3w7o1bR!=(`2;^1>m8qqB`5@f4;2dcdurkfZd;WchSLUyh~Om zqk!GLsOzFr0mt=oWL2o4tnsb8SEx07ybig!vYJnI*hWXK>CKvORLZJt>VFE=`E{TQ zKC*qX$}~DTDBygm<3Qu*$g0KSoK1C1XuL;OdkHHK1#qd(%P{)p1YXa(LRSs$_LO)q$6d`LfE($VsxwZ}4FFRvN|mBw6L7 zfT+1iqk8r?0x_bmSdv;Zgo^I!|`><`7#oPb1W2)Lv^f@YKesd zjWZjM>twYP1+c5*cJF^}<8gFnhXno^w>*_pXJ>R&3}WP^INa?yxw1Nw>g&M+F!lU2^bmF0XnPcHVLfPZSEzbe+qD!Y3% zgRo|!0C3*uwFfL&&D|6blhqy+V6BdZtvF}^pCqewC;+XFZ|02=H2!>9okw+U=Zy?m kt!b~ylvP$P)>EDT0o=$O#qSB@r2qf`07*qoM6N<$f`#)P82|tP literal 0 HcmV?d00001 diff --git a/testdata/lay/png4.png b/testdata/lay/png4.png new file mode 100644 index 0000000000000000000000000000000000000000..c22aa09ccc74265610ba6bfee00efee40d39357c GIT binary patch literal 5198 zcmV-U6tU}xP) zaB^>EX>4U6ba`-PAZ2)IW&i+q+O1bUp zLbhJZ&_qIPjXdV*3iR*jdyp&96;)P+B(JKdgRY{JMpC7Nwz}%9yKZtXx=@G~8wR=~ z7BtcqO~8bO^wGxhr8@?bOf`{oE7-so>c%q`E&C?fujoiSS4~q<(_&i0{&K-jgMV^C z?}aJSDo&mb78u#r6b38DpEQdE(S7RXgy3~e`PJqhvMMR)gl1MRt79y2IDL7`h|Y%Q zIl7M&(h%xgfGDE99R;HeDWJSIPJ68aV$hm+j3iK|$kA9lNCE8}RtgfWF&-gcMBba8 z30mf&Lyz1|wTXmq#+yLeB$G)jYaRI~*hn7A&N%Cw^DejuF1hTDx88a0gXbcbg9$dc z;6n&8q>!VDHoE9zh%u&^6DC77&?TQjiYcX>5i)I*X{}82GxZ#Jn8P0K@JBe}k&ax* zKE)PSd|^ns1@SmRj!QwQjoYuKON(?5XEdH9gbz zdHsQEda8z^6weE%YSarMtR*y;6UUm7VrVrf9#{b~G_qzYYHN{|W6e}TN(zS*q+@NM zYF3OSv`wSy`qb`H?pL~ji@(wh|4TVw>HZJpfTa7>?M1c9=UfrRMiw%s%24)oK9dfx z!~>zAX+h->+hMCFx~h+g2}hM?g((vaXw7X;-V5xE~U*6 zAFqH+S!^sa&aH$ExYHri$JTLd9V+o|=(IDOb2)HCnWK~-*@Y68hQeRcY6@|S^o3V# zG2vs+6h}x3x_+{86MtAoG24vCo#G1~8k&>IkhJl~@STl0yvalh6WQG|1ZOkH3(oK< zOhuoiPRv5&NExf*_Z@0avSRk})>@Fs8Vy0{Id(#1ZW1)YfV;vF+*8oY?(!(8edV`Y z;S5^L54wtbaXajO*1nMJnn9xgRGhz7>E&=W08UYx+^Z7B>5Z+tOTO3`kX8mW4dv5x zD#K>@osLUGS~Axm@uu*U@R|L0BZ@y-k}Ren<6?G%nZmJ3UgOE%7ht7CV8A;A+D3vB znfoYQ|JDHTV}9U<>9ty(8Xj;T7M^Z?Ac=Eb<$=Uy87ha=J*Gg#T5yxI7qoII-lxUo zcShz-RkqYu)C2M60S(I%w>*zCvG0)2Tw5|ONAOg5+P3<)M;|48Ji8ucz!3)Gq}mNJ z9oVe3+W?ES6Q6qErAcryawh#HW4Q;WUJP)yKmgkZq=x}S;zvb%6vP0lOznWD!inB7 zNlkMIWcs<&PP}beT7U_B7y`!uxV;g;gABaRK(oX&lb-Pl8}N;eJ?YCY^ap&`|Cs0H zs$yH!qCh2s!-hDJYHdR1*L1FEKPNd3=YO{0$Flba4uH@4uvPhSPG5d--zA1b5U0j| z0zBd=@prs=I(j)Co|bQG0y{ph$RZaz;bYJEy#@8O@jlq+i`OsRK-9qXhCpSSlB{x> z_WCT-f!D2f!R^RpreFz3&gRCe;G(A*MZCzdKD>S^&Tn#OjpLVyrXD$ef6;lX2cLAn zJ3D(ztRYF9MwuoH>&w!!2?O!y%2UB70VBu9Ys)wMuoG~;$ULfkI|;#c%H1taE%;vZ zZbx9eRke0Qd~n%cu~uIvG$`0@nS{&%)-lIwvEFh)i)3kX8QTcSeLi0+{2K6oX_va^*X-n_tc)wr`O}pV*dF8cLV&;eG&ps zrQfPweXspot(hMF>C}OKKPUJXRxCdaRJ6_a0003aX+uL$Nkc;*aB^>EX>4Tx0C=38 zkiSa9P!z_0ssBYMi-R~sa4oo)$)zfUf?BOf`8`Ops&M`8;Bs(fFTJtA3T=INg0RfHo_9jy`FzDP z`qD98&2xXA#V9UA=}eV{c~OCNAa$KdOI->A?kNeS39))p%~afoN;$b4iuxkm zrXg>u&hwNql*d?JCgF}$o+c0Tf4|p0&gxBTbCw51P`Bn(t*7D;dYMI{dNtX<1*l|Hgk4iT6G?6ATZ$Dq;v zEKqh#;wzqencoVkI&5FqAwDwJk7&Pe_|0y;niqq=s5!lL2f|Cmk2hzP$;m6jN!K{b zfp@b`) zJFsU9N1Btkz6-YLlx?R&cn3Vy!huWt(L=q?;dFCmwQ|WFSncLa+puatcwkuH)>a0S zgP=Nc35|z_6{)Yv=khUIeqiuYKVh+W_0?Ck!aS&hT`}!gEO}AaXNm9TIAPB_iaV%FZ&r-JF*duX4PD0|qN6np2U9 zHRYW>gFQqCem{C7fOA`o=>1dn5B6SwBqV^*`QQCj)JpbUeA3v}>A_3W{ zb4++B_Twj(o5N@|B!0$V-R9Jf5)!dSd$4?UD}={?=lk5@iq)JdQ8Cc-gy&l9WtDgr z>-(ve*mzp@I!?HPpYS<%*kU#2$mO6Eb4j`nRHNa*k-*S)o?BvGLWoru-s#mD*0;nz zYFa0F5~!Hwg28qskxO#1N|ASBqgggsqHJUCc)RsFA_2w{4;w5c-AjTRP~@HG4VLvChlz%?7Y6o;N2^_IkS>zwJ+Yu6rHEhUvo%LO4q*^uRj!djc zLt?+xQKHOfh?WUAbwh2#hGfAY;PRu*Re21Er zhX$+C5NpmmoAx^1La^qJOspjD;3U6RrVy37SWCQv{eYlqKMJctbL(TmJ5_sKG}u?I zI%2&aOd@%QCc2|b=s){b_X85r`E9-oaN5_P_m(qFANQJ4gAI zXit@*SkdF1L;Om$ryA}UY%2S_Q?S=HekGUCdY{>Sv4SB1hIc@G?irB!w^}7)MTK{^ zKT2B&mR2dTN{M$i>nt0rN>i+0cxT0S#s;hQMSiBqD3Ab%&5%b8R!#q~`%x++AXF;3 z#ILczYE)rGtSRqE&tMk_Po1ftA=ZRF#4`qq53NRlxhdA1 z1hTa5puxW8Ii^^hG+BBiP@y`;UQ0`8h0tR4&wAADwP~=e236t3TEtdjIVq1Athzi_ z6|1;ZhoiQWziuicvC0PToHkg6FIMDHYfb_*?@a79x&KilqJZFLGm->~%Sp~)YD;J} zZsd%`Iw65tS~s@We}2M^b2?&`8t*(}uP@JRa!ysO0SVw+_6nQHEsNX`>$mMyy?5#I zc6VB0E!*oVzuKG=9P(gDpujt1D%tyvlym%%lwcSUR5{oT8JVkkQ%6Ot?(g5>8xjZk zRV5Q^61B>RcjUamerk0p)-vxbQl0-CYP_s{v3hf)G}5}B!CH?}DTy^+W4XhKw!P*@ z(Q_kGDT!4=u`+Wcrkf#kdsT78nvLXy1mvMqGUlA%emXd(KC#6+%l4{5i8b06aL#&E zmy>H$cY6+%l30Zjt3Zj>04s>kC$>Y4 zu+2Hyo`5aZ80f;cT0Uw!7U!ffYb@3R3E+Wcv)q}S*}#g=dT=CA;GL<#s=XQtlPfp9 zs*pfqIa#mu&-bhO_9Gxi(h_Tl1X^hw=ueNyiR7vw)|_|F*^bItvDSF!jP0l_idEvH zJ3Q~~E}JvXiTCM}VQllx>azLHlstjqI@^RvKGl z63ElK1bxd`{JJi8k?^A=f1Z;{Ghj^!LI~w!^65BD3>$H;(x*;2tsk@-iIV;u<35;yV;#Db$)ku?Lv35v+ zN$b`)$9~5$`1=Clnd>_5R7^)D6Kg(_uoRjMqa)Rpy&|uX5No=rTw8r)Bv4N4K%HML zh&8=`Cl0V`yn{h188JC2R;h_KAORGYlf_+im&u(9y_?NY2(Y3#5(hRz63$7JD_g9R z1Xw-Z=~A7^Ik{NfsMVbymw2Z`b$2FDvN>{JAjj4|?+{cMXf?j|b|TgV-l<6RgXMB4 zUl8jC@3d{lVDb}U-QpeBc6eWnp}a5FDB3CWPMPXdXt8D^=@pwE;stSBfKBUybB`Nh zrLeU@0XX1MtqYl)7ppL0?UMjTn;|zQe?+W366o4%$~nQ@;gr}GYoB*wdySc# z+7mGQu_snkjtkKCdS~*MSfwIXVi-Zk=L`dQZo`PRvWW$jcXracJSUH!yeC%i1FSjk zB(|eMh&5hcy_Sg5_PL}-mHFjlU^_mOH^P8StXzOqnnW1eQ5lMridu^S)+EL9?wcEm zHIG`$0oIgv0tVO;>jJjUdFRFeWwDl{)-txbBv4K3)R{}$V%;SH*+}cu{q4}F#R{&< zhP^uP6WGk=R>fN89oBYKDq=02fbhgB&+*Q`XIK1RVio=P%ytSSaGZC1CO;z9EWkR# zI}Vc%#5%-QiUdgB37C8)R^h}tA_4LpG5%!$pUKaPwM+uiwpWkI!??pwt~z2}=N)s6 zOpBEo$sMuM$wzLl6z6 Date: Mon, 9 May 2022 22:36:08 +0200 Subject: [PATCH 54/88] Code cleanup --- src/laybasic/laybasic/layDitherPattern.cc | 17 ----------------- src/laybasic/laybasic/layDitherPattern.h | 15 --------------- 2 files changed, 32 deletions(-) diff --git a/src/laybasic/laybasic/layDitherPattern.cc b/src/laybasic/laybasic/layDitherPattern.cc index 243f8a5e0..ede9eee47 100644 --- a/src/laybasic/laybasic/layDitherPattern.cc +++ b/src/laybasic/laybasic/layDitherPattern.cc @@ -777,9 +777,6 @@ struct ReplaceDitherPatternOp }; DitherPattern::DitherPattern () : -#if defined(HAVE_QT) - QObject (), -#endif db::Object (0) { for (unsigned int d = 0; d < sizeof (dither_strings) / sizeof (dither_strings [0]); d += 2) { @@ -795,9 +792,6 @@ DitherPattern::~DitherPattern () } DitherPattern::DitherPattern (const DitherPattern &p) : -#if defined(HAVE_QT) - QObject (), -#endif db::Object (0) { m_pattern = p.m_pattern; @@ -844,11 +838,8 @@ DitherPattern::pattern (unsigned int i) const void DitherPattern::replace_pattern (unsigned int i, const DitherPatternInfo &p) { - bool chg = false; - while (i >= count ()) { m_pattern.push_back (DitherPatternInfo ()); - chg = true; } if (m_pattern [i] != p) { @@ -856,14 +847,6 @@ DitherPattern::replace_pattern (unsigned int i, const DitherPatternInfo &p) manager ()->queue (this, new ReplaceDitherPatternOp (i, m_pattern [i], p)); } m_pattern [i] = p; - chg = true; - } - - // if something has changed emit the signal - if (chg) { -#if defined(HAVE_QT) - emit changed (); -#endif } } diff --git a/src/laybasic/laybasic/layDitherPattern.h b/src/laybasic/laybasic/layDitherPattern.h index de1e88ca8..9c86eb2e1 100644 --- a/src/laybasic/laybasic/layDitherPattern.h +++ b/src/laybasic/laybasic/layDitherPattern.h @@ -230,15 +230,8 @@ private: * cannot be changed. */ class LAYBASIC_PUBLIC DitherPattern : -#if defined(HAVE_QT) - public QObject, -#endif public db::Object { -#if defined(HAVE_QT) -Q_OBJECT -#endif - public: typedef std::vector pattern_vector; typedef pattern_vector::const_iterator iterator; @@ -384,14 +377,6 @@ public: */ static const DitherPattern &default_pattern (); -#if defined(HAVE_QT) -signals: - /** - * @brief This signal is emitted if a pattern is changed - */ - void changed (); -#endif - private: std::vector m_pattern; }; From fbc31fd854c335a3c0a80799bc88ca7c122cf197 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Mon, 9 May 2022 23:07:40 +0200 Subject: [PATCH 55/88] Navigation keys work again, fixed a segfault when showing the navigator window --- src/laybasic/laybasic/layLayoutView.cc | 14 ++++++++++++++ src/laybasic/laybasic/layLayoutViewBase.cc | 17 ++++++++--------- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/laybasic/laybasic/layLayoutView.cc b/src/laybasic/laybasic/layLayoutView.cc index 0eca02e84..1fd60ba08 100644 --- a/src/laybasic/laybasic/layLayoutView.cc +++ b/src/laybasic/laybasic/layLayoutView.cc @@ -170,6 +170,20 @@ LayoutView::init_ui () m_always_show_ld = true; m_always_show_layout_index = false; + mp_timer = 0; + mp_left_frame = 0; + mp_control_panel = 0; + mp_hierarchy_panel = 0; + mp_libraries_view = 0; + mp_bookmarks_view = 0; + mp_control_frame = 0; + mp_hierarchy_frame = 0; + mp_libraries_frame = 0; + mp_bookmarks_frame = 0; + mp_editor_options_frame = 0; + mp_min_hier_spbx = 0; + mp_max_hier_spbx = 0; + QVBoxLayout *vbl = new QVBoxLayout (this); vbl->setContentsMargins (0, 0, 0, 0); vbl->setSpacing (0); diff --git a/src/laybasic/laybasic/layLayoutViewBase.cc b/src/laybasic/laybasic/layLayoutViewBase.cc index 50c118920..b1d183639 100644 --- a/src/laybasic/laybasic/layLayoutViewBase.cc +++ b/src/laybasic/laybasic/layLayoutViewBase.cc @@ -396,15 +396,6 @@ LayoutViewBase::init (db::Manager *mgr) mp_canvas = new lay::LayoutCanvas (this); #endif - mp_canvas->left_arrow_key_pressed.add (this, &LayoutViewBase::pan_left); - mp_canvas->up_arrow_key_pressed.add (this, &LayoutViewBase::pan_up); - mp_canvas->right_arrow_key_pressed.add (this, &LayoutViewBase::pan_right); - mp_canvas->down_arrow_key_pressed.add (this, &LayoutViewBase::pan_down); - mp_canvas->left_arrow_key_pressed_with_shift.add (this, &LayoutViewBase::pan_left_fast); - mp_canvas->up_arrow_key_pressed_with_shift.add (this, &LayoutViewBase::pan_up_fast); - mp_canvas->right_arrow_key_pressed_with_shift.add (this, &LayoutViewBase::pan_right_fast); - mp_canvas->down_arrow_key_pressed_with_shift.add (this, &LayoutViewBase::pan_down_fast); - // occupy services and editables: // these services get deleted by the canvas destructor automatically: if ((m_options & LV_NoTracker) == 0) { @@ -511,6 +502,14 @@ void LayoutViewBase::update_event_handlers () annotation_shapes ().bboxes_changed_any_event.add (this, &LayoutViewBase::signal_annotations_changed); mp_canvas->viewport_changed_event.add (this, &LayoutViewBase::viewport_changed); + mp_canvas->left_arrow_key_pressed.add (this, &LayoutViewBase::pan_left); + mp_canvas->up_arrow_key_pressed.add (this, &LayoutViewBase::pan_up); + mp_canvas->right_arrow_key_pressed.add (this, &LayoutViewBase::pan_right); + mp_canvas->down_arrow_key_pressed.add (this, &LayoutViewBase::pan_down); + mp_canvas->left_arrow_key_pressed_with_shift.add (this, &LayoutViewBase::pan_left_fast); + mp_canvas->up_arrow_key_pressed_with_shift.add (this, &LayoutViewBase::pan_up_fast); + mp_canvas->right_arrow_key_pressed_with_shift.add (this, &LayoutViewBase::pan_right_fast); + mp_canvas->down_arrow_key_pressed_with_shift.add (this, &LayoutViewBase::pan_down_fast); } void LayoutViewBase::viewport_changed () From f57f1cc228d3d3a1dfce45ce92ec090c1871b007 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Mon, 9 May 2022 23:20:46 +0200 Subject: [PATCH 56/88] Fixed a segfault on second open --- src/laybasic/laybasic/layLayoutView.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/laybasic/laybasic/layLayoutView.cc b/src/laybasic/laybasic/layLayoutView.cc index 1fd60ba08..3101d5c65 100644 --- a/src/laybasic/laybasic/layLayoutView.cc +++ b/src/laybasic/laybasic/layLayoutView.cc @@ -309,6 +309,10 @@ LayoutView::~LayoutView () { close_event (); + if (ms_current == this) { + ms_current = 0; + } + if (mp_control_frame) { delete mp_control_frame; } From b2b5e5ad55a44c4612f97c6036dc687b184c301e Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Thu, 12 May 2022 01:53:16 +0200 Subject: [PATCH 57/88] Modifications to enable building of Qt-less canvas in setup.py --- setup.py | 188 +++++++++++++++++- src/ant/ant/ant.pro | 6 +- src/ant/ant/antConfigPage.cc | 3 + src/ant/ant/antConfigPage.h | 4 +- src/ant/ant/antForceLink.cc | 1 - src/ant/ant/antForceLink.h | 2 +- src/ant/ant/antPropertiesPage.cc | 2 + src/ant/ant/antPropertiesPage.h | 3 + src/edt/edt/edt.pro | 26 ++- src/edt/edt/edtDialogs.cc | 4 + src/edt/edt/edtDialogs.h | 3 + src/edt/edt/edtEditorOptionsPages.cc | 2 + src/edt/edt/edtEditorOptionsPages.h | 2 + src/edt/edt/edtForceLink.cc | 32 +++ src/edt/edt/edtForceLink.h | 40 ++++ src/edt/edt/edtInstPropertiesPage.cc | 2 + src/edt/edt/edtInstPropertiesPage.h | 2 + src/edt/edt/edtPCellParametersPage.cc | 3 +- src/edt/edt/edtPCellParametersPage.h | 3 + src/edt/edt/edtPropertiesPageUtils.cc | 2 + src/edt/edt/edtPropertiesPageUtils.h | 2 + src/edt/edt/edtPropertiesPages.cc | 2 + src/edt/edt/edtPropertiesPages.h | 3 + src/edt/edt/edtRecentConfigurationPage.cc | 4 + src/edt/edt/edtRecentConfigurationPage.h | 2 + src/img/img/img.pro | 6 +- src/img/img/imgForceLink.cc | 3 +- src/img/img/imgForceLink.h | 4 +- src/img/img/imgLandmarksDialog.cc | 2 + src/img/img/imgLandmarksDialog.h | 3 + src/img/img/imgNavigator.cc | 2 + src/img/img/imgNavigator.h | 2 + src/img/img/imgPropertiesPage.cc | 2 + src/img/img/imgPropertiesPage.h | 3 + src/img/img/imgWidgets.cc | 3 + src/img/img/imgWidgets.h | 3 + src/laybasic/laybasic/gsiDeclLayDialogs.cc | 4 + src/laybasic/laybasic/gsiDeclLayMenu.cc | 3 + .../gsiDeclLayNetlistBrowserDialog.cc | 5 +- src/laybasic/laybasic/gsiDeclLayStream.cc | 3 + src/laybasic/laybasic/gtf.cc | 2 + src/laybasic/laybasic/gtf.h | 4 +- src/laybasic/laybasic/gtfdummy.cc | 2 + src/laybasic/laybasic/layAbstractMenu.cc | 3 + src/laybasic/laybasic/layAbstractMenu.h | 3 +- .../laybasic/layBackgroundAwareTreeStyle.cc | 5 + .../laybasic/layBackgroundAwareTreeStyle.h | 2 + src/laybasic/laybasic/layBitmap.h | 3 - src/laybasic/laybasic/layBookmarkList.cc | 3 + src/laybasic/laybasic/layBookmarkList.h | 2 + .../laybasic/layBookmarkManagementForm.cc | 3 +- .../laybasic/layBookmarkManagementForm.h | 2 + src/laybasic/laybasic/layBookmarksView.cc | 3 + src/laybasic/laybasic/layBookmarksView.h | 2 + .../laybasic/layBrowseInstancesForm.cc | 3 + .../laybasic/layBrowseInstancesForm.h | 2 + src/laybasic/laybasic/layBrowseShapesForm.cc | 3 + src/laybasic/laybasic/layBrowseShapesForm.h | 2 + src/laybasic/laybasic/layBrowser.cc | 3 + src/laybasic/laybasic/layBrowser.h | 2 + src/laybasic/laybasic/layBrowserDialog.cc | 3 + src/laybasic/laybasic/layBrowserDialog.h | 2 + src/laybasic/laybasic/layBrowserPanel.cc | 2 + src/laybasic/laybasic/layBrowserPanel.h | 2 + src/laybasic/laybasic/layBusy.cc | 4 + src/laybasic/laybasic/layBusy.h | 3 + src/laybasic/laybasic/layCellSelectionForm.cc | 3 +- src/laybasic/laybasic/layCellSelectionForm.h | 2 + src/laybasic/laybasic/layCellTreeModel.cc | 4 + src/laybasic/laybasic/layCellTreeModel.h | 2 + src/laybasic/laybasic/layColor.h | 1 - .../laybasic/layConfigurationDialog.cc | 2 + .../laybasic/layConfigurationDialog.h | 2 + src/laybasic/laybasic/layCursor.cc | 2 + src/laybasic/laybasic/layCursor.h | 7 +- src/laybasic/laybasic/layDialogs.cc | 2 + src/laybasic/laybasic/layDialogs.h | 3 +- src/laybasic/laybasic/layDragDropData.cc | 4 + src/laybasic/laybasic/layDragDropData.h | 3 + .../laybasic/layEditLineStyleWidget.cc | 2 + .../laybasic/layEditLineStyleWidget.h | 3 + .../laybasic/layEditLineStylesForm.cc | 3 +- src/laybasic/laybasic/layEditLineStylesForm.h | 2 + src/laybasic/laybasic/layEditStippleWidget.cc | 2 + src/laybasic/laybasic/layEditStippleWidget.h | 2 + src/laybasic/laybasic/layEditStipplesForm.cc | 3 +- src/laybasic/laybasic/layEditStipplesForm.h | 2 + .../laybasic/layEditorOptionsFrame.cc | 4 + src/laybasic/laybasic/layEditorOptionsFrame.h | 4 + src/laybasic/laybasic/layEditorOptionsPage.cc | 3 + src/laybasic/laybasic/layEditorOptionsPage.h | 4 + .../laybasic/layEditorOptionsPages.cc | 2 + src/laybasic/laybasic/layEditorOptionsPages.h | 2 + src/laybasic/laybasic/layFileDialog.cc | 2 + src/laybasic/laybasic/layFileDialog.h | 2 + .../laybasic/layGenericSyntaxHighlighter.cc | 3 +- .../laybasic/layGenericSyntaxHighlighter.h | 2 + src/laybasic/laybasic/layGridNetConfigPage.cc | 2 + src/laybasic/laybasic/layGridNetConfigPage.h | 2 + .../laybasic/layHierarchyControlPanel.cc | 3 + .../laybasic/layHierarchyControlPanel.h | 2 + .../laybasic/layIndexedNetlistModel.cc | 3 + .../laybasic/layIndexedNetlistModel.h | 3 + src/laybasic/laybasic/layItemDelegates.cc | 4 + src/laybasic/laybasic/layItemDelegates.h | 4 + src/laybasic/laybasic/layLayerControlPanel.cc | 3 + src/laybasic/laybasic/layLayerControlPanel.h | 2 + .../laybasic/layLayerMappingWidget.cc | 2 + src/laybasic/laybasic/layLayerMappingWidget.h | 2 + src/laybasic/laybasic/layLayerToolbox.cc | 2 + src/laybasic/laybasic/layLayerToolbox.h | 2 + src/laybasic/laybasic/layLayerTreeModel.cc | 3 + src/laybasic/laybasic/layLayerTreeModel.h | 2 + src/laybasic/laybasic/layLayoutCanvas.h | 1 + .../laybasic/layLayoutPropertiesForm.cc | 4 +- .../laybasic/layLayoutPropertiesForm.h | 2 + .../laybasic/layLayoutStatisticsForm.cc | 4 +- .../laybasic/layLayoutStatisticsForm.h | 2 + .../laybasic/layLayoutViewConfigPages.cc | 2 + .../laybasic/layLayoutViewConfigPages.h | 2 + .../laybasic/layLayoutViewFunctions.cc | 4 + .../laybasic/layLayoutViewFunctions.h | 2 + src/laybasic/laybasic/layLibrariesView.cc | 3 + src/laybasic/laybasic/layLibrariesView.h | 2 + .../laybasic/layLoadLayoutOptionsDialog.cc | 3 +- .../laybasic/layLoadLayoutOptionsDialog.h | 3 +- src/laybasic/laybasic/layNetExportDialog.cc | 4 + src/laybasic/laybasic/layNetExportDialog.h | 2 + src/laybasic/laybasic/layNetInfoDialog.cc | 4 + src/laybasic/laybasic/layNetInfoDialog.h | 2 + src/laybasic/laybasic/layNetlistBrowser.cc | 2 + src/laybasic/laybasic/layNetlistBrowser.h | 2 + .../laybasic/layNetlistBrowserDialog.cc | 2 + .../laybasic/layNetlistBrowserDialog.h | 2 + .../laybasic/layNetlistBrowserModel.cc | 2 + .../laybasic/layNetlistBrowserModel.h | 2 + .../laybasic/layNetlistBrowserPage.cc | 2 + src/laybasic/laybasic/layNetlistBrowserPage.h | 2 + .../laybasic/layNetlistBrowserTreeModel.cc | 3 + .../laybasic/layNetlistBrowserTreeModel.h | 2 + .../laybasic/layNetlistCrossReferenceModel.cc | 3 + .../laybasic/layNetlistCrossReferenceModel.h | 3 + src/laybasic/laybasic/layPluginConfigPage.cc | 3 + src/laybasic/laybasic/layPluginConfigPage.h | 2 + src/laybasic/laybasic/layProperties.cc | 2 + src/laybasic/laybasic/layProperties.h | 2 + src/laybasic/laybasic/layPropertiesDialog.cc | 2 + src/laybasic/laybasic/layPropertiesDialog.h | 2 + src/laybasic/laybasic/layQtTools.cc | 2 + src/laybasic/laybasic/layQtTools.h | 2 + .../laybasic/layRedrawThreadWorker.cc | 1 + .../laybasic/laySaveLayoutOptionsDialog.cc | 2 + .../laybasic/laySaveLayoutOptionsDialog.h | 2 + .../laybasic/laySelectCellViewForm.cc | 2 + src/laybasic/laybasic/laySelectCellViewForm.h | 2 + .../laybasic/laySelectLineStyleForm.cc | 3 +- .../laybasic/laySelectLineStyleForm.h | 2 + src/laybasic/laybasic/laySelectStippleForm.cc | 3 +- src/laybasic/laybasic/laySelectStippleForm.h | 2 + src/laybasic/laybasic/layStream.cc | 2 + src/laybasic/laybasic/layStream.h | 2 + src/laybasic/laybasic/layTechnology.cc | 3 + src/laybasic/laybasic/layTechnology.h | 2 + src/laybasic/laybasic/layTipDialog.cc | 2 + src/laybasic/laybasic/layTipDialog.h | 2 + src/laybasic/laybasic/layWidgets.cc | 3 + src/laybasic/laybasic/layWidgets.h | 2 + src/laybasic/laybasic/laybasic.pro | 16 +- src/laybasic/laybasic/laybasicConfig.h | 2 - src/laybasic/laybasic/laybasicForceLink.cc | 32 +++ src/laybasic/laybasic/laybasicForceLink.h | 40 ++++ src/laybasic/laybasic/rdbInfoWidget.cc | 3 + src/laybasic/laybasic/rdbInfoWidget.h | 3 +- src/laybasic/laybasic/rdbMarkerBrowser.cc | 3 +- src/laybasic/laybasic/rdbMarkerBrowser.h | 2 + .../laybasic/rdbMarkerBrowserDialog.cc | 2 + .../laybasic/rdbMarkerBrowserDialog.h | 2 + src/laybasic/laybasic/rdbMarkerBrowserPage.cc | 2 + src/laybasic/laybasic/rdbMarkerBrowserPage.h | 2 + src/lym/lym/lymForceLink.cc | 32 +++ src/lym/lym/lymForceLink.h | 40 ++++ src/pymod/__init__.py.qtless | 2 +- src/pymod/ant/ant.pro | 12 ++ src/pymod/ant/antMain.cc | 28 +++ .../distutils_src/klayout/lay/__init__.py | 12 ++ src/pymod/edt/edt.pro | 12 ++ src/pymod/edt/edtMain.cc | 28 +++ src/pymod/edt/lay.pro | 12 ++ src/pymod/edt/layMain.cc | 37 ++++ src/pymod/img/img.pro | 12 ++ src/pymod/img/imgMain.cc | 28 +++ src/pymod/img/lay.pro | 12 ++ src/pymod/img/layMain.cc | 37 ++++ src/pymod/lay/layMain.cc | 13 +- src/pymod/lym/lym.pro | 12 ++ src/pymod/lym/lymMain.cc | 28 +++ src/pymod/pymod.pro | 7 +- 197 files changed, 1123 insertions(+), 63 deletions(-) create mode 100644 src/edt/edt/edtForceLink.cc create mode 100644 src/edt/edt/edtForceLink.h create mode 100644 src/laybasic/laybasic/laybasicForceLink.cc create mode 100644 src/laybasic/laybasic/laybasicForceLink.h create mode 100644 src/lym/lym/lymForceLink.cc create mode 100644 src/lym/lym/lymForceLink.h create mode 100644 src/pymod/ant/ant.pro create mode 100644 src/pymod/ant/antMain.cc create mode 100644 src/pymod/distutils_src/klayout/lay/__init__.py create mode 100644 src/pymod/edt/edt.pro create mode 100644 src/pymod/edt/edtMain.cc create mode 100644 src/pymod/edt/lay.pro create mode 100644 src/pymod/edt/layMain.cc create mode 100644 src/pymod/img/img.pro create mode 100644 src/pymod/img/imgMain.cc create mode 100644 src/pymod/img/lay.pro create mode 100644 src/pymod/img/layMain.cc create mode 100644 src/pymod/lym/lym.pro create mode 100644 src/pymod/lym/lymMain.cc diff --git a/setup.py b/setup.py index a2631a25a..595d035f1 100644 --- a/setup.py +++ b/setup.py @@ -28,6 +28,7 @@ The standalone libraries are basically extension modules. Build requirements are: * curl library * expat library + * png library The main challenge is to map KLayout's shared object architecture. The structure consists of the Python extension libraries and a bunch @@ -269,6 +270,7 @@ class Config(object): if bits: return [quote_path("-I" + os.path.join(bits, "zlib", "include")), quote_path("-I" + os.path.join(bits, "ptw", "include")), + quote_path("-I" + os.path.join(bits, "png", "include")), quote_path("-I" + os.path.join(bits, "expat", "include")), quote_path("-I" + os.path.join(bits, "curl", "include"))] else: @@ -285,9 +287,13 @@ class Config(object): if platform.system() == "Windows": if mod == "_tl": return [ "libcurl", "expat", "pthreadVCE2", "zlib", "wsock32" ] + elif mod == "_lay": + return [ "libpng" ] else: if mod == "_tl": return ['curl', 'expat'] + elif mod == "_lay": + return [ 'png' ] return [] def link_args(self, mod): @@ -300,6 +306,7 @@ class Config(object): if bits: args += [quote_path("/LIBPATH:" + os.path.join(bits, "zlib", "libraries")), quote_path("/LIBPATH:" + os.path.join(bits, "ptw", "libraries")), + quote_path("/LIBPATH:" + os.path.join(bits, "png", "libraries")), quote_path("/LIBPATH:" + os.path.join(bits, "expat", "libraries")), quote_path("/LIBPATH:" + os.path.join(bits, "curl", "libraries"))] return args @@ -334,7 +341,7 @@ class Config(object): """ Returns the macros to use for building """ - return [('HAVE_CURL', 1), ('HAVE_EXPAT', 1), ('KLAYOUT_MAJOR_VERSION', self.major_version()), ('KLAYOUT_MINOR_VERSION', self.minor_version())] + return [('HAVE_PNG', 1), ('HAVE_CURL', 1), ('HAVE_EXPAT', 1), ('KLAYOUT_MAJOR_VERSION', self.major_version()), ('KLAYOUT_MINOR_VERSION', self.minor_version())] def minor_version(self): """ @@ -425,6 +432,7 @@ _gsi = Library(config.root + '._gsi', include_dirs=[_tl_path], extra_objects=[config.path_of('_tl', _tl_path)], language='c++', + libraries=config.libraries('_gsi'), extra_link_args=config.link_args('_gsi'), extra_compile_args=config.compile_args('_gsi'), sources=list(_gsi_sources)) @@ -441,11 +449,29 @@ _pya = Library(config.root + '._pya', include_dirs=[_tl_path, _gsi_path], extra_objects=[config.path_of('_tl', _tl_path), config.path_of('_gsi', _gsi_path)], language='c++', + libraries=config.libraries('_pya'), extra_link_args=config.link_args('_pya'), extra_compile_args=config.compile_args('_pya'), sources=list(_pya_sources)) config.add_extension(_pya) +# ------------------------------------------------------------------ +# _rba dependency library (dummy) + +_rba_path = os.path.join("src", "rbastub") +_rba_sources = set(glob.glob(os.path.join(_rba_path, "*.cc"))) + +_rba = Library(config.root + '._rba', + define_macros=config.macros() + [('MAKE_RBA_LIBRARY', 1)], + include_dirs=[_tl_path, _gsi_path], + extra_objects=[config.path_of('_tl', _tl_path), config.path_of('_gsi', _gsi_path)], + language='c++', + libraries=config.libraries('_rba'), + extra_link_args=config.link_args('_rba'), + extra_compile_args=config.compile_args('_rba'), + sources=list(_rba_sources)) +config.add_extension(_rba) + # ------------------------------------------------------------------ # _db dependency library @@ -457,6 +483,7 @@ _db = Library(config.root + '._db', include_dirs=[_tl_path, _gsi_path, _db_path], extra_objects=[config.path_of('_tl', _tl_path), config.path_of('_gsi', _gsi_path)], language='c++', + libraries=config.libraries('_db'), extra_link_args=config.link_args('_db'), extra_compile_args=config.compile_args('_db'), sources=list(_db_sources)) @@ -473,6 +500,7 @@ _lib = Library(config.root + '._lib', include_dirs=[_tl_path, _gsi_path, _db_path, _lib_path], extra_objects=[config.path_of('_tl', _tl_path), config.path_of('_gsi', _gsi_path), config.path_of('_db', _db_path)], language='c++', + libraries=config.libraries('_lib'), extra_link_args=config.link_args('_lib'), extra_compile_args=config.compile_args('_lib'), sources=list(_lib_sources)) @@ -489,11 +517,97 @@ _rdb = Library(config.root + '._rdb', include_dirs=[_db_path, _tl_path, _gsi_path], extra_objects=[config.path_of('_tl', _tl_path), config.path_of('_gsi', _gsi_path), config.path_of('_db', _db_path)], language='c++', + libraries=config.libraries('_rdb'), extra_link_args=config.link_args('_rdb'), extra_compile_args=config.compile_args('_rdb'), sources=list(_rdb_sources)) config.add_extension(_rdb) +# ------------------------------------------------------------------ +# _lym dependency library + +_lym_path = os.path.join("src", "lym", "lym") +_lym_sources = set(glob.glob(os.path.join(_lym_path, "*.cc"))) + +_lym = Library(config.root + '._lym', + define_macros=config.macros() + [('MAKE_LYM_LIBRARY', 1)], + include_dirs=[_pya_path, _rba_path, _tl_path, _gsi_path], + extra_objects=[config.path_of('_rba', _rba_path), config.path_of('_pya', _pya_path), config.path_of('_tl', _tl_path), config.path_of('_gsi', _gsi_path)], + language='c++', + libraries=config.libraries('_lym'), + extra_link_args=config.link_args('_lym'), + extra_compile_args=config.compile_args('_lym'), + sources=list(_lym_sources)) +config.add_extension(_lym) + +# ------------------------------------------------------------------ +# _lay dependency library + +_lay_path = os.path.join("src", "laybasic", "laybasic") +_lay_sources = set(glob.glob(os.path.join(_lay_path, "*.cc"))) + +_lay = Library(config.root + '._lay', + define_macros=config.macros() + [('MAKE_LAYBASIC_LIBRARY', 1)], + include_dirs=[_lym_path, _rdb_path, _db_path, _tl_path, _gsi_path], + extra_objects=[config.path_of('_lym', _lym_path), config.path_of('_rdb', _rdb_path), config.path_of('_tl', _tl_path), config.path_of('_gsi', _gsi_path), config.path_of('_db', _db_path)], + language='c++', + libraries=config.libraries('_lay'), + extra_link_args=config.link_args('_lay'), + extra_compile_args=config.compile_args('_lay'), + sources=list(_lay_sources)) +config.add_extension(_lay) + +# ------------------------------------------------------------------ +# _ant dependency library + +_ant_path = os.path.join("src", "ant", "ant") +_ant_sources = set(glob.glob(os.path.join(_ant_path, "*.cc"))) + +_ant = Library(config.root + '._ant', + define_macros=config.macros() + [('MAKE_ANT_LIBRARY', 1)], + include_dirs=[_lay_path, _rdb_path, _db_path, _tl_path, _gsi_path], + extra_objects=[config.path_of('_lay', _lay_path), config.path_of('_rdb', _rdb_path), config.path_of('_tl', _tl_path), config.path_of('_gsi', _gsi_path), config.path_of('_db', _db_path)], + language='c++', + libraries=config.libraries('_ant'), + extra_link_args=config.link_args('_ant'), + extra_compile_args=config.compile_args('_ant'), + sources=list(_ant_sources)) +config.add_extension(_ant) + +# ------------------------------------------------------------------ +# _img dependency library + +_img_path = os.path.join("src", "img", "img") +_img_sources = set(glob.glob(os.path.join(_img_path, "*.cc"))) + +_img = Library(config.root + '._img', + define_macros=config.macros() + [('MAKE_ANT_LIBRARY', 1)], + include_dirs=[_lay_path, _rdb_path, _db_path, _tl_path, _gsi_path], + extra_objects=[config.path_of('_lay', _lay_path), config.path_of('_rdb', _rdb_path), config.path_of('_tl', _tl_path), config.path_of('_gsi', _gsi_path), config.path_of('_db', _db_path)], + language='c++', + libraries=config.libraries('_img'), + extra_link_args=config.link_args('_img'), + extra_compile_args=config.compile_args('_img'), + sources=list(_img_sources)) +config.add_extension(_img) + +# ------------------------------------------------------------------ +# _edt dependency library + +_edt_path = os.path.join("src", "edt", "edt") +_edt_sources = set(glob.glob(os.path.join(_edt_path, "*.cc"))) + +_edt = Library(config.root + '._edt', + define_macros=config.macros() + [('MAKE_ANT_LIBRARY', 1)], + include_dirs=[_lay_path, _rdb_path, _db_path, _tl_path, _gsi_path], + extra_objects=[config.path_of('_lay', _lay_path), config.path_of('_rdb', _rdb_path), config.path_of('_tl', _tl_path), config.path_of('_gsi', _gsi_path), config.path_of('_db', _db_path)], + language='c++', + libraries=config.libraries('_edt'), + extra_link_args=config.link_args('_edt'), + extra_compile_args=config.compile_args('_edt'), + sources=list(_edt_sources)) +config.add_extension(_edt) + # ------------------------------------------------------------------ # dependency libraries from db_plugins @@ -577,6 +691,76 @@ rdb = Extension(config.root + '.rdbcore', extra_compile_args=config.compile_args('rdbcore'), sources=list(rdb_sources)) +# ------------------------------------------------------------------ +# lay extension library + +lay_path = os.path.join("src", "pymod", "lay") +lay_sources = set(glob.glob(os.path.join(lay_path, "*.cc"))) + +lay = Extension(config.root + '.laycore', + define_macros=config.macros(), + include_dirs=[_lay_path, _tl_path, _gsi_path, _pya_path], + extra_objects=[config.path_of('_lay', _lay_path), config.path_of('_tl', _tl_path), config.path_of('_gsi', _gsi_path), config.path_of('_pya', _pya_path)], + extra_link_args=config.link_args('laycore'), + extra_compile_args=config.compile_args('laycore'), + sources=list(lay_sources)) + +# ------------------------------------------------------------------ +# ant extension library + +ant_path = os.path.join("src", "pymod", "ant") +ant_sources = set(glob.glob(os.path.join(ant_path, "*.cc"))) + +ant = Extension(config.root + '.antcore', + define_macros=config.macros(), + include_dirs=[_ant_path, _tl_path, _gsi_path, _pya_path], + extra_objects=[config.path_of('_ant', _ant_path), config.path_of('_tl', _tl_path), config.path_of('_gsi', _gsi_path), config.path_of('_pya', _pya_path)], + extra_link_args=config.link_args('antcore'), + extra_compile_args=config.compile_args('antcore'), + sources=list(ant_sources)) + +# ------------------------------------------------------------------ +# edt extension library + +edt_path = os.path.join("src", "pymod", "edt") +edt_sources = set(glob.glob(os.path.join(edt_path, "*.cc"))) + +edt = Extension(config.root + '.edtcore', + define_macros=config.macros(), + include_dirs=[_edt_path, _tl_path, _gsi_path, _pya_path], + extra_objects=[config.path_of('_edt', _edt_path), config.path_of('_tl', _tl_path), config.path_of('_gsi', _gsi_path), config.path_of('_pya', _pya_path)], + extra_link_args=config.link_args('edtcore'), + extra_compile_args=config.compile_args('edtcore'), + sources=list(edt_sources)) + +# ------------------------------------------------------------------ +# img extension library + +img_path = os.path.join("src", "pymod", "img") +img_sources = set(glob.glob(os.path.join(img_path, "*.cc"))) + +img = Extension(config.root + '.imgcore', + define_macros=config.macros(), + include_dirs=[_img_path, _tl_path, _gsi_path, _pya_path], + extra_objects=[config.path_of('_img', _img_path), config.path_of('_tl', _tl_path), config.path_of('_gsi', _gsi_path), config.path_of('_pya', _pya_path)], + extra_link_args=config.link_args('imgcore'), + extra_compile_args=config.compile_args('imgcore'), + sources=list(img_sources)) + +# ------------------------------------------------------------------ +# lym extension library + +lym_path = os.path.join("src", "pymod", "lym") +lym_sources = set(glob.glob(os.path.join(lym_path, "*.cc"))) + +lym = Extension(config.root + '.lymcore', + define_macros=config.macros(), + include_dirs=[_lym_path, _tl_path, _gsi_path, _pya_path], + extra_objects=[config.path_of('_lym', _lym_path), config.path_of('_tl', _tl_path), config.path_of('_gsi', _gsi_path), config.path_of('_pya', _pya_path)], + extra_link_args=config.link_args('lymcore'), + extra_compile_args=config.compile_args('lymcore'), + sources=list(lym_sources)) + # ------------------------------------------------------------------ # Core setup function @@ -602,4 +786,4 @@ if __name__ == '__main__': url='https://github.com/klayout/klayout', packages=find_packages('src/pymod/distutils_src'), package_dir={'': 'src/pymod/distutils_src'}, # https://github.com/pypa/setuptools/issues/230 - ext_modules=[_tl, _gsi, _pya, _db, _lib, _rdb] + db_plugins + [tl, db, lib, rdb]) + ext_modules=[_tl, _gsi, _pya, _rba, _db, _lib, _rdb, _lym, _lay, _ant, _edt, _img] + db_plugins + [tl, db, lib, rdb, lay, ant, edt, img, lym]) diff --git a/src/ant/ant/ant.pro b/src/ant/ant/ant.pro index 6232bc294..079b34e75 100644 --- a/src/ant/ant/ant.pro +++ b/src/ant/ant/ant.pro @@ -15,6 +15,10 @@ FORMS = \ RulerConfigPage4.ui \ RulerPropertiesPage.ui \ +} + +# Disabled without Qt: + HEADERS = \ antConfigPage.h \ antPropertiesPage.h \ @@ -23,7 +27,7 @@ SOURCES = \ antConfigPage.cc \ antPropertiesPage.cc \ -} +# Enabled without Qt: HEADERS += \ antConfig.h \ diff --git a/src/ant/ant/antConfigPage.cc b/src/ant/ant/antConfigPage.cc index 2d3e2247e..bf3ef673b 100644 --- a/src/ant/ant/antConfigPage.cc +++ b/src/ant/ant/antConfigPage.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "antConfigPage.h" #include "ui_RulerConfigPage.h" @@ -417,3 +418,5 @@ ConfigPage4::commit () } } // namespace ant + +#endif diff --git a/src/ant/ant/antConfigPage.h b/src/ant/ant/antConfigPage.h index b032c254a..6c588e88f 100644 --- a/src/ant/ant/antConfigPage.h +++ b/src/ant/ant/antConfigPage.h @@ -20,7 +20,7 @@ */ - +#if defined(HAVE_QT) #ifndef HDR_antConfigPage #define HDR_antConfigPage @@ -134,3 +134,5 @@ private: #endif +#endif + diff --git a/src/ant/ant/antForceLink.cc b/src/ant/ant/antForceLink.cc index 4a96a1893..41d78f078 100644 --- a/src/ant/ant/antForceLink.cc +++ b/src/ant/ant/antForceLink.cc @@ -20,7 +20,6 @@ */ - #include "antForceLink.h" namespace ant diff --git a/src/ant/ant/antForceLink.h b/src/ant/ant/antForceLink.h index 4821171a1..4a1323c39 100644 --- a/src/ant/ant/antForceLink.h +++ b/src/ant/ant/antForceLink.h @@ -33,7 +33,7 @@ namespace ant { ANT_PUBLIC int _force_link_f (); - int _force_link_target = _force_link_f (); + static int _force_link_target = _force_link_f (); } #endif diff --git a/src/ant/ant/antPropertiesPage.cc b/src/ant/ant/antPropertiesPage.cc index 565bf182e..99f8f4056 100644 --- a/src/ant/ant/antPropertiesPage.cc +++ b/src/ant/ant/antPropertiesPage.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "antPropertiesPage.h" #include "layLayoutView.h" @@ -365,3 +366,4 @@ PropertiesPage::apply () } +#endif diff --git a/src/ant/ant/antPropertiesPage.h b/src/ant/ant/antPropertiesPage.h index cd3253129..8e50f4dc4 100644 --- a/src/ant/ant/antPropertiesPage.h +++ b/src/ant/ant/antPropertiesPage.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_antPropertiesPage #define HDR_antPropertiesPage @@ -70,3 +71,5 @@ private: } #endif + +#endif diff --git a/src/edt/edt/edt.pro b/src/edt/edt/edt.pro index 50ab9a827..5e4b7a3fe 100644 --- a/src/edt/edt/edt.pro +++ b/src/edt/edt/edt.pro @@ -8,15 +8,6 @@ DEFINES += MAKE_EDT_LIBRARY !equals(HAVE_QT, "0") { - HEADERS = \ - edtDialogs.h \ - edtEditorOptionsPages.h \ - edtInstPropertiesPage.h \ - edtPCellParametersPage.h \ - edtPropertiesPages.h \ - edtPropertiesPageUtils.h \ - edtRecentConfigurationPage.h - FORMS = \ AlignOptionsDialog.ui \ BoxPropertiesPage.ui \ @@ -38,7 +29,20 @@ DEFINES += MAKE_EDT_LIBRARY DistributeOptionsDialog.ui \ EditorOptionsInstPCellParam.ui - SOURCES = \ +} + +# Disabled without Qt: + +HEADERS = \ + edtDialogs.h \ + edtEditorOptionsPages.h \ + edtInstPropertiesPage.h \ + edtPCellParametersPage.h \ + edtPropertiesPages.h \ + edtPropertiesPageUtils.h \ + edtRecentConfigurationPage.h + +SOURCES = \ edtDialogs.cc \ edtEditorOptionsPages.cc \ edtInstPropertiesPage.cc \ @@ -47,7 +51,7 @@ DEFINES += MAKE_EDT_LIBRARY edtPropertiesPageUtils.cc \ edtRecentConfigurationPage.cc -} +# Enabled without Qt: HEADERS += \ edtConfig.h \ diff --git a/src/edt/edt/edtDialogs.cc b/src/edt/edt/edtDialogs.cc index 3cd05ea3f..37f6cef49 100644 --- a/src/edt/edt/edtDialogs.cc +++ b/src/edt/edt/edtDialogs.cc @@ -20,6 +20,8 @@ */ +#if defined(HAVE_QT) + #include "dbBox.h" #include "dbLayout.h" @@ -683,3 +685,5 @@ END_PROTECTED; } +#endif + diff --git a/src/edt/edt/edtDialogs.h b/src/edt/edt/edtDialogs.h index f700e01d4..b0ee473a9 100644 --- a/src/edt/edt/edtDialogs.h +++ b/src/edt/edt/edtDialogs.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_edtDialogs @@ -208,3 +209,5 @@ private: #endif +#endif + diff --git a/src/edt/edt/edtEditorOptionsPages.cc b/src/edt/edt/edtEditorOptionsPages.cc index 3f33fd310..ff6b298d8 100644 --- a/src/edt/edt/edtEditorOptionsPages.cc +++ b/src/edt/edt/edtEditorOptionsPages.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "tlInternational.h" #include "dbLibrary.h" @@ -890,3 +891,4 @@ EditorOptionsInstPCellParam::update_pcell_parameters (const std::vector &pa } - +#endif diff --git a/src/edt/edt/edtPCellParametersPage.h b/src/edt/edt/edtPCellParametersPage.h index f148c7c1c..aa5a6ef38 100644 --- a/src/edt/edt/edtPCellParametersPage.h +++ b/src/edt/edt/edtPCellParametersPage.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_edtPCellParametersPage #define HDR_edtPCellParametersPage @@ -157,3 +158,5 @@ private: } #endif + +#endif diff --git a/src/edt/edt/edtPropertiesPageUtils.cc b/src/edt/edt/edtPropertiesPageUtils.cc index f6df8fc63..abd3c4afe 100644 --- a/src/edt/edt/edtPropertiesPageUtils.cc +++ b/src/edt/edt/edtPropertiesPageUtils.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "edtPropertiesPageUtils.h" @@ -870,3 +871,4 @@ coords_to_string (const db::DPoint &dp, double dbu, bool du, const char *sep) } +#endif diff --git a/src/edt/edt/edtPropertiesPageUtils.h b/src/edt/edt/edtPropertiesPageUtils.h index e20e76db7..b66eba7b6 100644 --- a/src/edt/edt/edtPropertiesPageUtils.h +++ b/src/edt/edt/edtPropertiesPageUtils.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_edtPropertiesPageUtils #define HDR_edtPropertiesPageUtils @@ -522,3 +523,4 @@ db::Coord coord_from_string (const char *txt, double dbu, bool du, const db::VCp #endif +#endif diff --git a/src/edt/edt/edtPropertiesPages.cc b/src/edt/edt/edtPropertiesPages.cc index 5943d609a..7a34c1981 100644 --- a/src/edt/edt/edtPropertiesPages.cc +++ b/src/edt/edt/edtPropertiesPages.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "edtPropertiesPages.h" #include "edtPropertiesPageUtils.h" @@ -1183,3 +1184,4 @@ EditablePathPropertiesPage::type_selected (int t) } +#endif diff --git a/src/edt/edt/edtPropertiesPages.h b/src/edt/edt/edtPropertiesPages.h index 39e0b6fb5..0172cd1c5 100644 --- a/src/edt/edt/edtPropertiesPages.h +++ b/src/edt/edt/edtPropertiesPages.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_edtPropertiesPages @@ -207,3 +208,5 @@ private: } #endif + +#endif diff --git a/src/edt/edt/edtRecentConfigurationPage.cc b/src/edt/edt/edtRecentConfigurationPage.cc index 3781aeffc..09c4a50ed 100644 --- a/src/edt/edt/edtRecentConfigurationPage.cc +++ b/src/edt/edt/edtRecentConfigurationPage.cc @@ -20,6 +20,8 @@ */ +#if defined(HAVE_QT) + #include "edtRecentConfigurationPage.h" #include "edtUtils.h" #include "layDispatcher.h" @@ -428,3 +430,5 @@ RecentConfigurationPage::commit_recent (lay::Dispatcher *root) } } + +#endif diff --git a/src/edt/edt/edtRecentConfigurationPage.h b/src/edt/edt/edtRecentConfigurationPage.h index e43352ec3..ab8c88800 100644 --- a/src/edt/edt/edtRecentConfigurationPage.h +++ b/src/edt/edt/edtRecentConfigurationPage.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_edtRecentConfigurationPage #define HDR_edtRecentConfigurationPage @@ -112,3 +113,4 @@ private: #endif +#endif diff --git a/src/img/img/img.pro b/src/img/img/img.pro index 13eb01db9..4bfd510ab 100644 --- a/src/img/img/img.pro +++ b/src/img/img/img.pro @@ -13,6 +13,10 @@ FORMS = \ ImageLandmarksDialog.ui \ ImagePropertiesPage.ui \ +} + +# Disabled without Qt: + HEADERS = \ imgLandmarksDialog.h \ imgNavigator.h \ @@ -25,7 +29,7 @@ SOURCES = \ imgPropertiesPage.cc \ imgWidgets.cc \ -} +# Enabled without Qt: HEADERS += \ imgObject.h \ diff --git a/src/img/img/imgForceLink.cc b/src/img/img/imgForceLink.cc index 2dbd66143..86247ea5c 100644 --- a/src/img/img/imgForceLink.cc +++ b/src/img/img/imgForceLink.cc @@ -10,7 +10,7 @@ (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 + but WITHOUT ANY WARRANTY; without even the implied warrimgy of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. @@ -20,7 +20,6 @@ */ - #include "imgForceLink.h" namespace img diff --git a/src/img/img/imgForceLink.h b/src/img/img/imgForceLink.h index 1dfc4e901..a86fd3b88 100644 --- a/src/img/img/imgForceLink.h +++ b/src/img/img/imgForceLink.h @@ -10,7 +10,7 @@ (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 + but WITHOUT ANY WARRANTY; without even the implied warrimgy of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. @@ -33,7 +33,7 @@ namespace img { IMG_PUBLIC int _force_link_f (); - int _force_link_target = _force_link_f (); + static int _force_link_target = _force_link_f (); } #endif diff --git a/src/img/img/imgLandmarksDialog.cc b/src/img/img/imgLandmarksDialog.cc index 16d9142cf..25bb29e0d 100644 --- a/src/img/img/imgLandmarksDialog.cc +++ b/src/img/img/imgLandmarksDialog.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "imgLandmarksDialog.h" #include "imgService.h" @@ -499,3 +500,4 @@ LandmarksDialog::landmarks_updated () } +#endif diff --git a/src/img/img/imgLandmarksDialog.h b/src/img/img/imgLandmarksDialog.h index cad11fbfe..8c0d099e9 100644 --- a/src/img/img/imgLandmarksDialog.h +++ b/src/img/img/imgLandmarksDialog.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_imgLandmarksDialog #define HDR_imgLandmarksDialog @@ -65,3 +66,5 @@ private: } #endif + +#endif diff --git a/src/img/img/imgNavigator.cc b/src/img/img/imgNavigator.cc index b6640e070..634b8bd1e 100644 --- a/src/img/img/imgNavigator.cc +++ b/src/img/img/imgNavigator.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "laybasicConfig.h" #include "layMarker.h" @@ -113,3 +114,4 @@ Navigator::background_color (QColor c) } +#endif diff --git a/src/img/img/imgNavigator.h b/src/img/img/imgNavigator.h index 6e5922b3f..013d9a530 100644 --- a/src/img/img/imgNavigator.h +++ b/src/img/img/imgNavigator.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_imgNavigator #define HDR_imgNavigator @@ -70,3 +71,4 @@ private: #endif +#endif diff --git a/src/img/img/imgPropertiesPage.cc b/src/img/img/imgPropertiesPage.cc index aec31b1b0..c53d36d77 100644 --- a/src/img/img/imgPropertiesPage.cc +++ b/src/img/img/imgPropertiesPage.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "imgPropertiesPage.h" #include "imgLandmarksDialog.h" @@ -1003,3 +1004,4 @@ PropertiesPage::define_landmarks_pressed () } +#endif diff --git a/src/img/img/imgPropertiesPage.h b/src/img/img/imgPropertiesPage.h index c3b139b85..797bedd86 100644 --- a/src/img/img/imgPropertiesPage.h +++ b/src/img/img/imgPropertiesPage.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_imgPropertiesPage #define HDR_imgPropertiesPage @@ -105,3 +106,5 @@ private: } #endif + +#endif diff --git a/src/img/img/imgWidgets.cc b/src/img/img/imgWidgets.cc index 92952dac5..32d85fdae 100644 --- a/src/img/img/imgWidgets.cc +++ b/src/img/img/imgWidgets.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "imgWidgets.h" @@ -452,3 +453,5 @@ ColorBar::paintEvent (QPaintEvent *) } +#endif + diff --git a/src/img/img/imgWidgets.h b/src/img/img/imgWidgets.h index 06cef78ef..b44a8e0b0 100644 --- a/src/img/img/imgWidgets.h +++ b/src/img/img/imgWidgets.h @@ -20,6 +20,8 @@ */ +#if defined(HAVE_QT) + #ifndef HDR_imgWidgets #define HDR_imgWidgets @@ -138,3 +140,4 @@ private: #endif +#endif diff --git a/src/laybasic/laybasic/gsiDeclLayDialogs.cc b/src/laybasic/laybasic/gsiDeclLayDialogs.cc index 9cf0bc960..61a598926 100644 --- a/src/laybasic/laybasic/gsiDeclLayDialogs.cc +++ b/src/laybasic/laybasic/gsiDeclLayDialogs.cc @@ -20,6 +20,8 @@ */ +#if defined(HAVE_QT) + #include "gsiDecl.h" #include "gsiDeclBasic.h" #include "layBrowserDialog.h" @@ -1186,3 +1188,5 @@ Class decl_MessageBox (QT_EXTERNAL_BASE (QMainWindow) "lay", "Messag ); } + +#endif diff --git a/src/laybasic/laybasic/gsiDeclLayMenu.cc b/src/laybasic/laybasic/gsiDeclLayMenu.cc index 80f7c58b9..9bf185495 100644 --- a/src/laybasic/laybasic/gsiDeclLayMenu.cc +++ b/src/laybasic/laybasic/gsiDeclLayMenu.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "gsiDecl.h" #include "gsiSignals.h" @@ -410,3 +411,5 @@ Class decl_Action (decl_ActionBase, "lay", "Action", ); } + +#endif diff --git a/src/laybasic/laybasic/gsiDeclLayNetlistBrowserDialog.cc b/src/laybasic/laybasic/gsiDeclLayNetlistBrowserDialog.cc index b19e2ddf9..0190f3890 100644 --- a/src/laybasic/laybasic/gsiDeclLayNetlistBrowserDialog.cc +++ b/src/laybasic/laybasic/gsiDeclLayNetlistBrowserDialog.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "gsiDecl.h" #include "gsiDeclBasic.h" @@ -219,7 +220,7 @@ gsi::ClassExt decl_ext_layout_view ( ) ); - - } +#endif + diff --git a/src/laybasic/laybasic/gsiDeclLayStream.cc b/src/laybasic/laybasic/gsiDeclLayStream.cc index 403cef728..b0ce8c418 100644 --- a/src/laybasic/laybasic/gsiDeclLayStream.cc +++ b/src/laybasic/laybasic/gsiDeclLayStream.cc @@ -20,6 +20,8 @@ */ +#if defined(HAVE_QT) + #include "gsiDecl.h" #include "dbReader.h" #include "layTechnology.h" @@ -46,4 +48,5 @@ gsi::ClassExt layout_reader_decl ( } +#endif diff --git a/src/laybasic/laybasic/gtf.cc b/src/laybasic/laybasic/gtf.cc index a5b2534ae..d5eb5797e 100644 --- a/src/laybasic/laybasic/gtf.cc +++ b/src/laybasic/laybasic/gtf.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "gtf.h" #include "tlException.h" @@ -1928,4 +1929,5 @@ GtfXmlHandler::warning (const QXmlParseException &ex) } +#endif diff --git a/src/laybasic/laybasic/gtf.h b/src/laybasic/laybasic/gtf.h index c0fd84c7a..98f58a099 100644 --- a/src/laybasic/laybasic/gtf.h +++ b/src/laybasic/laybasic/gtf.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_gtf #define HDR_gtf @@ -569,5 +570,4 @@ LAYBASIC_PUBLIC tl::Variant image_to_variant (const QImage &image); #endif - - +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/gtfdummy.cc b/src/laybasic/laybasic/gtfdummy.cc index ce531c855..e1acdb547 100644 --- a/src/laybasic/laybasic/gtfdummy.cc +++ b/src/laybasic/laybasic/gtfdummy.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "gtf.h" @@ -35,4 +36,5 @@ void Recorder::errlog_puts (const char *s) { } } +#endif diff --git a/src/laybasic/laybasic/layAbstractMenu.cc b/src/laybasic/laybasic/layAbstractMenu.cc index 61a91e89d..e7b587f9a 100644 --- a/src/laybasic/laybasic/layAbstractMenu.cc +++ b/src/laybasic/laybasic/layAbstractMenu.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "layAbstractMenu.h" #include "layDispatcher.h" @@ -1702,3 +1703,5 @@ AbstractMenu::get_shortcuts (const std::string &root, std::map @@ -108,3 +110,6 @@ BackgroundAwareTreeStyle::drawPrimitive (QStyle::PrimitiveElement pe, const QSty } } + +#endif + diff --git a/src/laybasic/laybasic/layBackgroundAwareTreeStyle.h b/src/laybasic/laybasic/layBackgroundAwareTreeStyle.h index 18b8bd642..03ec99000 100644 --- a/src/laybasic/laybasic/layBackgroundAwareTreeStyle.h +++ b/src/laybasic/laybasic/layBackgroundAwareTreeStyle.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layBackgroundAwareTreeStyle #define HDR_layBackgroundAwareTreeStyle @@ -50,3 +51,4 @@ public: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layBitmap.h b/src/laybasic/laybasic/layBitmap.h index dc9303899..ff2b69df3 100644 --- a/src/laybasic/laybasic/layBitmap.h +++ b/src/laybasic/laybasic/layBitmap.h @@ -20,8 +20,6 @@ */ - - #ifndef HDR_layBitmap #define HDR_layBitmap @@ -396,4 +394,3 @@ Bitmap::scanline (unsigned n) const } // namespace lay #endif - diff --git a/src/laybasic/laybasic/layBookmarkList.cc b/src/laybasic/laybasic/layBookmarkList.cc index 595ac8b7a..dcffe8e15 100644 --- a/src/laybasic/laybasic/layBookmarkList.cc +++ b/src/laybasic/laybasic/layBookmarkList.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "layBookmarkList.h" #include "tlXMLParser.h" @@ -118,3 +119,5 @@ BookmarkList::propose_new_bookmark_name () const } +#endif + diff --git a/src/laybasic/laybasic/layBookmarkList.h b/src/laybasic/laybasic/layBookmarkList.h index 839530a93..9d4090d53 100644 --- a/src/laybasic/laybasic/layBookmarkList.h +++ b/src/laybasic/laybasic/layBookmarkList.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layBookmarkList #define HDR_layBookmarkList @@ -208,3 +209,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layBookmarkManagementForm.cc b/src/laybasic/laybasic/layBookmarkManagementForm.cc index e582bbc4d..51b9358d1 100644 --- a/src/laybasic/laybasic/layBookmarkManagementForm.cc +++ b/src/laybasic/laybasic/layBookmarkManagementForm.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "layBookmarkManagementForm.h" #include "dbCellInst.h" @@ -109,5 +110,5 @@ BookmarkManagementForm::accept () } - +#endif diff --git a/src/laybasic/laybasic/layBookmarkManagementForm.h b/src/laybasic/laybasic/layBookmarkManagementForm.h index 0d80e0941..0b419c181 100644 --- a/src/laybasic/laybasic/layBookmarkManagementForm.h +++ b/src/laybasic/laybasic/layBookmarkManagementForm.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layBookmarkManagementForm #define HDR_layBookmarkManagementForm @@ -63,3 +64,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layBookmarksView.cc b/src/laybasic/laybasic/layBookmarksView.cc index 4c104316c..88d359385 100644 --- a/src/laybasic/laybasic/layBookmarksView.cc +++ b/src/laybasic/laybasic/layBookmarksView.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "layBookmarksView.h" #include "layLayoutView.h" @@ -211,3 +212,5 @@ static tl::RegisteredClass config_decl (new BookmarksVie } +#endif + diff --git a/src/laybasic/laybasic/layBookmarksView.h b/src/laybasic/laybasic/layBookmarksView.h index 70c6958a6..3a4f78a63 100644 --- a/src/laybasic/laybasic/layBookmarksView.h +++ b/src/laybasic/laybasic/layBookmarksView.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layBookmarksView #define HDR_layBookmarksView @@ -75,3 +76,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layBrowseInstancesForm.cc b/src/laybasic/laybasic/layBrowseInstancesForm.cc index 0b1214d6f..f64695169 100644 --- a/src/laybasic/laybasic/layBrowseInstancesForm.cc +++ b/src/laybasic/laybasic/layBrowseInstancesForm.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include #include @@ -912,3 +913,5 @@ BrowseInstancesForm::prev_inst () } +#endif + diff --git a/src/laybasic/laybasic/layBrowseInstancesForm.h b/src/laybasic/laybasic/layBrowseInstancesForm.h index ae4d5e2b0..8cb36254e 100644 --- a/src/laybasic/laybasic/layBrowseInstancesForm.h +++ b/src/laybasic/laybasic/layBrowseInstancesForm.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layBrowseInstancesForm #define HDR_layBrowseInstancesForm @@ -132,3 +133,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layBrowseShapesForm.cc b/src/laybasic/laybasic/layBrowseShapesForm.cc index d733ac1a2..01df4fc13 100644 --- a/src/laybasic/laybasic/layBrowseShapesForm.cc +++ b/src/laybasic/laybasic/layBrowseShapesForm.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include #include @@ -1179,3 +1180,5 @@ BrowseShapesForm::prev_inst () } +#endif + diff --git a/src/laybasic/laybasic/layBrowseShapesForm.h b/src/laybasic/laybasic/layBrowseShapesForm.h index c13b6b4e3..9e79ff62a 100644 --- a/src/laybasic/laybasic/layBrowseShapesForm.h +++ b/src/laybasic/laybasic/layBrowseShapesForm.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layBrowseShapesForm #define HDR_layBrowseShapesForm @@ -134,3 +135,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layBrowser.cc b/src/laybasic/laybasic/layBrowser.cc index 8a9fcc241..049076bf5 100644 --- a/src/laybasic/laybasic/layBrowser.cc +++ b/src/laybasic/laybasic/layBrowser.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include @@ -95,3 +96,5 @@ Browser::accept () } +#endif + diff --git a/src/laybasic/laybasic/layBrowser.h b/src/laybasic/laybasic/layBrowser.h index 24bafc8e4..b5ae1b70d 100644 --- a/src/laybasic/laybasic/layBrowser.h +++ b/src/laybasic/laybasic/layBrowser.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layBrowser #define HDR_layBrowser @@ -143,3 +144,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layBrowserDialog.cc b/src/laybasic/laybasic/layBrowserDialog.cc index 2e4862562..9fcdccdc1 100644 --- a/src/laybasic/laybasic/layBrowserDialog.cc +++ b/src/laybasic/laybasic/layBrowserDialog.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "layBrowserPanel.h" #include "layBrowserDialog.h" @@ -128,3 +129,5 @@ BrowserDialog::accept () } +#endif + diff --git a/src/laybasic/laybasic/layBrowserDialog.h b/src/laybasic/laybasic/layBrowserDialog.h index 6329d2c95..80bd01b41 100644 --- a/src/laybasic/laybasic/layBrowserDialog.h +++ b/src/laybasic/laybasic/layBrowserDialog.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layBrowserDialog #define HDR_layBrowserDialog @@ -132,3 +133,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layBrowserPanel.cc b/src/laybasic/laybasic/layBrowserPanel.cc index 7a05aba0d..75d0a0a08 100644 --- a/src/laybasic/laybasic/layBrowserPanel.cc +++ b/src/laybasic/laybasic/layBrowserPanel.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "layBrowserPanel.h" #include "layDispatcher.h" @@ -831,4 +832,5 @@ BrowserSource::attach (lay::BrowserPanel *d) } +#endif diff --git a/src/laybasic/laybasic/layBrowserPanel.h b/src/laybasic/laybasic/layBrowserPanel.h index 3dd593327..e97851b3d 100644 --- a/src/laybasic/laybasic/layBrowserPanel.h +++ b/src/laybasic/laybasic/layBrowserPanel.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layBrowserPanel #define HDR_layBrowserPanel @@ -487,3 +488,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layBusy.cc b/src/laybasic/laybasic/layBusy.cc index bfd7cda31..ea03d3f44 100644 --- a/src/laybasic/laybasic/layBusy.cc +++ b/src/laybasic/laybasic/layBusy.cc @@ -20,6 +20,8 @@ */ +#if defined(HAVE_QT) + #include "layBusy.h" #include "tlThreads.h" @@ -80,3 +82,5 @@ BusySection::is_busy () // ---------------------------------------------------------------------------------------------------------- } + +#endif diff --git a/src/laybasic/laybasic/layBusy.h b/src/laybasic/laybasic/layBusy.h index ed9597c33..9996faef9 100644 --- a/src/laybasic/laybasic/layBusy.h +++ b/src/laybasic/laybasic/layBusy.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layBusy #define HDR_layBusy @@ -63,3 +64,5 @@ private: } #endif + +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layCellSelectionForm.cc b/src/laybasic/laybasic/layCellSelectionForm.cc index 0bd3ff519..80011e089 100644 --- a/src/laybasic/laybasic/layCellSelectionForm.cc +++ b/src/laybasic/laybasic/layCellSelectionForm.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include #include @@ -876,4 +877,4 @@ LibraryCellSelectionForm::name_changed (const QString &s) } - +#endif diff --git a/src/laybasic/laybasic/layCellSelectionForm.h b/src/laybasic/laybasic/layCellSelectionForm.h index adc0a5cc7..0c3fd9027 100644 --- a/src/laybasic/laybasic/layCellSelectionForm.h +++ b/src/laybasic/laybasic/layCellSelectionForm.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layCellSelectionForm #define HDR_layCellSelectionForm @@ -201,3 +202,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layCellTreeModel.cc b/src/laybasic/laybasic/layCellTreeModel.cc index 3f501eff9..0c45b929b 100644 --- a/src/laybasic/laybasic/layCellTreeModel.cc +++ b/src/laybasic/laybasic/layCellTreeModel.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "layCellTreeModel.h" #include "layLayoutView.h" @@ -1296,3 +1297,6 @@ CellTreeModel::locate (const char *name, bool glob_pattern, bool case_sensitive, } } // namespace lay + +#endif + diff --git a/src/laybasic/laybasic/layCellTreeModel.h b/src/laybasic/laybasic/layCellTreeModel.h index 30608ee97..590f3dfb0 100644 --- a/src/laybasic/laybasic/layCellTreeModel.h +++ b/src/laybasic/laybasic/layCellTreeModel.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layCellTreeModel #define HDR_layCellTreeModel @@ -349,3 +350,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layColor.h b/src/laybasic/laybasic/layColor.h index 48766d3e0..e8d4c3d2a 100644 --- a/src/laybasic/laybasic/layColor.h +++ b/src/laybasic/laybasic/layColor.h @@ -20,7 +20,6 @@ */ - #ifndef HDR_layColor #define HDR_layColor diff --git a/src/laybasic/laybasic/layConfigurationDialog.cc b/src/laybasic/laybasic/layConfigurationDialog.cc index 6a10774ac..46de6b29f 100644 --- a/src/laybasic/laybasic/layConfigurationDialog.cc +++ b/src/laybasic/laybasic/layConfigurationDialog.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include #include @@ -144,3 +145,4 @@ ConfigurationDialog::ok_clicked () } +#endif diff --git a/src/laybasic/laybasic/layConfigurationDialog.h b/src/laybasic/laybasic/layConfigurationDialog.h index 2e800ca47..95627bf07 100644 --- a/src/laybasic/laybasic/layConfigurationDialog.h +++ b/src/laybasic/laybasic/layConfigurationDialog.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layConfigurationDialog #define HDR_layConfigurationDialog @@ -69,3 +70,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layCursor.cc b/src/laybasic/laybasic/layCursor.cc index b718e62fc..b3b2b8b97 100644 --- a/src/laybasic/laybasic/layCursor.cc +++ b/src/laybasic/laybasic/layCursor.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "layCursor.h" @@ -77,3 +78,4 @@ Cursor::qcursor (cursor_shape cursor) } +#endif diff --git a/src/laybasic/laybasic/layCursor.h b/src/laybasic/laybasic/layCursor.h index a3bc01ca5..43002bc37 100644 --- a/src/laybasic/laybasic/layCursor.h +++ b/src/laybasic/laybasic/layCursor.h @@ -20,13 +20,14 @@ */ - #ifndef HDR_layCursor #define HDR_layCursor #include "laybasicCommon.h" +#if defined(HAVE_QT) class QCursor; +#endif namespace lay { @@ -64,13 +65,15 @@ struct LAYBASIC_PUBLIC Cursor closed_hand = 18 }; +#if defined(HAVE_QT) /** * @brief Get the QCursor from the lay::cursor_shape enum */ static QCursor qcursor (cursor_shape cursor); +#endif + }; } #endif - diff --git a/src/laybasic/laybasic/layDialogs.cc b/src/laybasic/laybasic/layDialogs.cc index 0c89906fc..1a93cf670 100644 --- a/src/laybasic/laybasic/layDialogs.cc +++ b/src/laybasic/laybasic/layDialogs.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "layDialogs.h" @@ -1411,3 +1412,4 @@ END_PROTECTED } +#endif diff --git a/src/laybasic/laybasic/layDialogs.h b/src/laybasic/laybasic/layDialogs.h index c338e6a48..0e35fb555 100644 --- a/src/laybasic/laybasic/layDialogs.h +++ b/src/laybasic/laybasic/layDialogs.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layDialogs #define HDR_layDialogs @@ -468,4 +469,4 @@ public: #endif - +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layDragDropData.cc b/src/laybasic/laybasic/layDragDropData.cc index 76ceadf80..e145c0c9a 100644 --- a/src/laybasic/laybasic/layDragDropData.cc +++ b/src/laybasic/laybasic/layDragDropData.cc @@ -20,6 +20,8 @@ */ +#if defined(HAVE_QT) + #include "layDragDropData.h" #include @@ -106,3 +108,5 @@ CellDragDropData::deserialize (const QByteArray &ba) } } + +#endif diff --git a/src/laybasic/laybasic/layDragDropData.h b/src/laybasic/laybasic/layDragDropData.h index c830debe3..78bc31fa0 100644 --- a/src/laybasic/laybasic/layDragDropData.h +++ b/src/laybasic/laybasic/layDragDropData.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layDragDropData #define HDR_layDragDropData @@ -169,3 +170,5 @@ private: } #endif + +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layEditLineStyleWidget.cc b/src/laybasic/laybasic/layEditLineStyleWidget.cc index ea6fdf748..0f119b33a 100644 --- a/src/laybasic/laybasic/layEditLineStyleWidget.cc +++ b/src/laybasic/laybasic/layEditLineStyleWidget.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "layEditLineStyleWidget.h" @@ -422,3 +423,4 @@ EditLineStyleWidget::redo (db::Op *op) } +#endif diff --git a/src/laybasic/laybasic/layEditLineStyleWidget.h b/src/laybasic/laybasic/layEditLineStyleWidget.h index 1deaef97f..14f369c62 100644 --- a/src/laybasic/laybasic/layEditLineStyleWidget.h +++ b/src/laybasic/laybasic/layEditLineStyleWidget.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layEditLineStyleWidget #define HDR_layEditLineStyleWidget @@ -100,3 +101,5 @@ private: } #endif + +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layEditLineStylesForm.cc b/src/laybasic/laybasic/layEditLineStylesForm.cc index f8e804b83..a0cca3f00 100644 --- a/src/laybasic/laybasic/layEditLineStylesForm.cc +++ b/src/laybasic/laybasic/layEditLineStylesForm.cc @@ -20,7 +20,7 @@ */ - +#if defined(HAVE_QT) #include "layEditLineStylesForm.h" #include "ui_EditLineStylesForm.h" @@ -556,3 +556,4 @@ EditLineStylesForm::redo (db::Op *op) } +#endif diff --git a/src/laybasic/laybasic/layEditLineStylesForm.h b/src/laybasic/laybasic/layEditLineStylesForm.h index 25cc35d9c..a7e94a3a3 100644 --- a/src/laybasic/laybasic/layEditLineStylesForm.h +++ b/src/laybasic/laybasic/layEditLineStylesForm.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layEditLineStylesForm #define HDR_layEditLineStylesForm @@ -107,3 +108,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layEditStippleWidget.cc b/src/laybasic/laybasic/layEditStippleWidget.cc index 1bb613e2e..a87b9870a 100644 --- a/src/laybasic/laybasic/layEditStippleWidget.cc +++ b/src/laybasic/laybasic/layEditStippleWidget.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "layEditStippleWidget.h" @@ -529,3 +530,4 @@ EditStippleWidget::redo (db::Op *op) } +#endif diff --git a/src/laybasic/laybasic/layEditStippleWidget.h b/src/laybasic/laybasic/layEditStippleWidget.h index e94d4228a..b3944f3d4 100644 --- a/src/laybasic/laybasic/layEditStippleWidget.h +++ b/src/laybasic/laybasic/layEditStippleWidget.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layEditStippleWidget #define HDR_layEditStippleWidget @@ -109,3 +110,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layEditStipplesForm.cc b/src/laybasic/laybasic/layEditStipplesForm.cc index 19cc4616d..6005880ce 100644 --- a/src/laybasic/laybasic/layEditStipplesForm.cc +++ b/src/laybasic/laybasic/layEditStipplesForm.cc @@ -20,7 +20,7 @@ */ - +#if defined(HAVE_QT) #include "layEditStipplesForm.h" #include "ui_EditStipplesForm.h" @@ -623,3 +623,4 @@ EditStipplesForm::redo (db::Op *op) } +#endif diff --git a/src/laybasic/laybasic/layEditStipplesForm.h b/src/laybasic/laybasic/layEditStipplesForm.h index 5fe4fc0f0..e8ca40ce8 100644 --- a/src/laybasic/laybasic/layEditStipplesForm.h +++ b/src/laybasic/laybasic/layEditStipplesForm.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layEditStipplesForm #define HDR_layEditStipplesForm @@ -111,3 +112,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layEditorOptionsFrame.cc b/src/laybasic/laybasic/layEditorOptionsFrame.cc index dd593f9e4..d7db2e458 100644 --- a/src/laybasic/laybasic/layEditorOptionsFrame.cc +++ b/src/laybasic/laybasic/layEditorOptionsFrame.cc @@ -20,6 +20,8 @@ */ +#if defined(HAVE_QT) + #include "layEditorOptionsFrame.h" #include "layEditorOptionsPage.h" #include "layEditorOptionsPages.h" @@ -68,3 +70,5 @@ EditorOptionsFrame::populate (LayoutView *view) } } + +#endif diff --git a/src/laybasic/laybasic/layEditorOptionsFrame.h b/src/laybasic/laybasic/layEditorOptionsFrame.h index fff1f7d40..396f0d9b7 100644 --- a/src/laybasic/laybasic/layEditorOptionsFrame.h +++ b/src/laybasic/laybasic/layEditorOptionsFrame.h @@ -20,6 +20,8 @@ */ +#if defined(HAVE_QT) + #ifndef HDR_layEditorOptionsFrame #define HDR_layEditorOptionsFrame @@ -53,3 +55,5 @@ public: } #endif + +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layEditorOptionsPage.cc b/src/laybasic/laybasic/layEditorOptionsPage.cc index f2f893da0..ba8dadb2d 100644 --- a/src/laybasic/laybasic/layEditorOptionsPage.cc +++ b/src/laybasic/laybasic/layEditorOptionsPage.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "tlInternational.h" #include "layEditorOptionsPage.h" @@ -88,3 +89,5 @@ EditorOptionsPage::activate (bool active) } } + +#endif diff --git a/src/laybasic/laybasic/layEditorOptionsPage.h b/src/laybasic/laybasic/layEditorOptionsPage.h index fb752ffaa..36356dcf3 100644 --- a/src/laybasic/laybasic/layEditorOptionsPage.h +++ b/src/laybasic/laybasic/layEditorOptionsPage.h @@ -20,6 +20,8 @@ */ +#if defined(HAVE_QT) + #ifndef HDR_layEditorOptionsPage #define HDR_layEditorOptionsPage @@ -99,3 +101,5 @@ private: } #endif + +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layEditorOptionsPages.cc b/src/laybasic/laybasic/layEditorOptionsPages.cc index a17d518b8..2c8d443fa 100644 --- a/src/laybasic/laybasic/layEditorOptionsPages.cc +++ b/src/laybasic/laybasic/layEditorOptionsPages.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "tlInternational.h" #include "layEditorOptionsPages.h" @@ -214,3 +215,4 @@ static void configure_from_line_edit (lay::Dispatcher *dispatcher, QLineEdit *le } +#endif diff --git a/src/laybasic/laybasic/layEditorOptionsPages.h b/src/laybasic/laybasic/layEditorOptionsPages.h index a65e3c100..a21f82fd0 100644 --- a/src/laybasic/laybasic/layEditorOptionsPages.h +++ b/src/laybasic/laybasic/layEditorOptionsPages.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layEditorOptionsPages #define HDR_layEditorOptionsPages @@ -83,3 +84,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layFileDialog.cc b/src/laybasic/laybasic/layFileDialog.cc index 79c04addd..9630fd471 100644 --- a/src/laybasic/laybasic/layFileDialog.cc +++ b/src/laybasic/laybasic/layFileDialog.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include #include @@ -303,3 +304,4 @@ FileDialog::get_save (std::string &fp, const std::string &title) } // namespace lay +#endif diff --git a/src/laybasic/laybasic/layFileDialog.h b/src/laybasic/laybasic/layFileDialog.h index 54f320265..2ec220dd2 100644 --- a/src/laybasic/laybasic/layFileDialog.h +++ b/src/laybasic/laybasic/layFileDialog.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layFileDialog #define HDR_layFileDialog @@ -98,3 +99,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layGenericSyntaxHighlighter.cc b/src/laybasic/laybasic/layGenericSyntaxHighlighter.cc index 4aaa01596..1705d86bf 100644 --- a/src/laybasic/laybasic/layGenericSyntaxHighlighter.cc +++ b/src/laybasic/laybasic/layGenericSyntaxHighlighter.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "layGenericSyntaxHighlighter.h" @@ -1726,4 +1727,4 @@ GenericSyntaxHighlighter::highlightBlock(const QString &text) } - +#endif diff --git a/src/laybasic/laybasic/layGenericSyntaxHighlighter.h b/src/laybasic/laybasic/layGenericSyntaxHighlighter.h index c73d0c22d..cbc0f684f 100644 --- a/src/laybasic/laybasic/layGenericSyntaxHighlighter.h +++ b/src/laybasic/laybasic/layGenericSyntaxHighlighter.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layGenericSyntaxHighlighter #define HDR_layGenericSyntaxHighlighter @@ -735,3 +736,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layGridNetConfigPage.cc b/src/laybasic/laybasic/layGridNetConfigPage.cc index 07866fd48..2538f6129 100644 --- a/src/laybasic/laybasic/layGridNetConfigPage.cc +++ b/src/laybasic/laybasic/layGridNetConfigPage.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "laybasicConfig.h" #include "layGridNetConfigPage.h" @@ -111,3 +112,4 @@ GridNetConfigPage::commit (lay::Dispatcher *root) } // namespace lay +#endif diff --git a/src/laybasic/laybasic/layGridNetConfigPage.h b/src/laybasic/laybasic/layGridNetConfigPage.h index 1e6599131..585bd6a7e 100644 --- a/src/laybasic/laybasic/layGridNetConfigPage.h +++ b/src/laybasic/laybasic/layGridNetConfigPage.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layGridNetConfigPage #define HDR_layGridNetConfigPage @@ -58,3 +59,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layHierarchyControlPanel.cc b/src/laybasic/laybasic/layHierarchyControlPanel.cc index 947b2f3c7..59293709d 100644 --- a/src/laybasic/laybasic/layHierarchyControlPanel.cc +++ b/src/laybasic/laybasic/layHierarchyControlPanel.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include @@ -1243,3 +1244,5 @@ public: static tl::RegisteredClass config_decl (new HierarchyControlPanelPluginDeclaration (), -8, "HierarchyControlPanelPlugin"); } // namespace lay + +#endif diff --git a/src/laybasic/laybasic/layHierarchyControlPanel.h b/src/laybasic/laybasic/layHierarchyControlPanel.h index be6c29db8..b5dab0ebc 100644 --- a/src/laybasic/laybasic/layHierarchyControlPanel.h +++ b/src/laybasic/laybasic/layHierarchyControlPanel.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layHierarchyControlPanel #define HDR_layHierarchyControlPanel @@ -340,3 +341,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layIndexedNetlistModel.cc b/src/laybasic/laybasic/layIndexedNetlistModel.cc index 8c9fd6788..35c1f67a4 100644 --- a/src/laybasic/laybasic/layIndexedNetlistModel.cc +++ b/src/laybasic/laybasic/layIndexedNetlistModel.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "layIndexedNetlistModel.h" #include "dbNetlist.h" @@ -463,3 +464,5 @@ SingleIndexedNetlistModel::subcircuit_index (const subcircuit_pair &subcircuits) } } + +#endif diff --git a/src/laybasic/laybasic/layIndexedNetlistModel.h b/src/laybasic/laybasic/layIndexedNetlistModel.h index 6e6c35610..188a732af 100644 --- a/src/laybasic/laybasic/layIndexedNetlistModel.h +++ b/src/laybasic/laybasic/layIndexedNetlistModel.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layIndexedNetlistModel #define HDR_layIndexedNetlistModel @@ -205,3 +206,5 @@ private: } #endif + +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layItemDelegates.cc b/src/laybasic/laybasic/layItemDelegates.cc index 6d3e230c6..dd5e8f112 100644 --- a/src/laybasic/laybasic/layItemDelegates.cc +++ b/src/laybasic/laybasic/layItemDelegates.cc @@ -20,6 +20,8 @@ */ +#if defined(HAVE_QT) + #include "layItemDelegates.h" #include @@ -206,3 +208,5 @@ HTMLItemDelegate::editorEvent (QEvent *event, QAbstractItemModel * /*model*/, co } } + +#endif diff --git a/src/laybasic/laybasic/layItemDelegates.h b/src/laybasic/laybasic/layItemDelegates.h index 6c860b2c2..ab0db7116 100644 --- a/src/laybasic/laybasic/layItemDelegates.h +++ b/src/laybasic/laybasic/layItemDelegates.h @@ -20,6 +20,8 @@ */ +#if defined(HAVE_QT) + #ifndef HDR_layItemDelegates #define HDR_layItemDelegates @@ -103,3 +105,5 @@ private: } #endif + +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layLayerControlPanel.cc b/src/laybasic/laybasic/layLayerControlPanel.cc index 28f6cdacd..5be142020 100644 --- a/src/laybasic/laybasic/layLayerControlPanel.cc +++ b/src/laybasic/laybasic/layLayerControlPanel.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include @@ -2340,3 +2341,5 @@ public: static tl::RegisteredClass config_decl (new LayerControlPanelPluginDeclaration (), -9, "LayerControlPanelPlugin"); } // namespace lay + +#endif diff --git a/src/laybasic/laybasic/layLayerControlPanel.h b/src/laybasic/laybasic/layLayerControlPanel.h index d3b322c88..8a7d6904a 100644 --- a/src/laybasic/laybasic/layLayerControlPanel.h +++ b/src/laybasic/laybasic/layLayerControlPanel.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layLayerControlPanel #define HDR_layLayerControlPanel @@ -379,3 +380,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layLayerMappingWidget.cc b/src/laybasic/laybasic/layLayerMappingWidget.cc index e1f75ef47..1ec214ba4 100644 --- a/src/laybasic/laybasic/layLayerMappingWidget.cc +++ b/src/laybasic/laybasic/layLayerMappingWidget.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "layLayerMappingWidget.h" #include "tlExceptions.h" @@ -259,3 +260,4 @@ LayerMappingWidget::current_tab_changed (int index) } +#endif diff --git a/src/laybasic/laybasic/layLayerMappingWidget.h b/src/laybasic/laybasic/layLayerMappingWidget.h index 2690b7a8a..b0898381e 100644 --- a/src/laybasic/laybasic/layLayerMappingWidget.h +++ b/src/laybasic/laybasic/layLayerMappingWidget.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layLayerMappingWidget #define HDR_layLayerMappingWidget @@ -98,3 +99,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layLayerToolbox.cc b/src/laybasic/laybasic/layLayerToolbox.cc index 4ceb5cf89..0be03095e 100644 --- a/src/laybasic/laybasic/layLayerToolbox.cc +++ b/src/laybasic/laybasic/layLayerToolbox.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "layLayerToolbox.h" @@ -1467,3 +1468,4 @@ LayerToolbox::set_palette (const lay::LineStylePalette &p) } +#endif diff --git a/src/laybasic/laybasic/layLayerToolbox.h b/src/laybasic/laybasic/layLayerToolbox.h index fa65510a5..b9fd59d6e 100644 --- a/src/laybasic/laybasic/layLayerToolbox.h +++ b/src/laybasic/laybasic/layLayerToolbox.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layLayerToolbox #define HDR_layLayerToolbox @@ -351,3 +352,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layLayerTreeModel.cc b/src/laybasic/laybasic/layLayerTreeModel.cc index f478d96e6..741f26957 100644 --- a/src/laybasic/laybasic/layLayerTreeModel.cc +++ b/src/laybasic/laybasic/layLayerTreeModel.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "layLayerTreeModel.h" #include "layLayoutView.h" @@ -931,3 +932,5 @@ LayerTreeModel::index (lay::LayerPropertiesConstIterator iter, int column) const } } // namespace lay + +#endif diff --git a/src/laybasic/laybasic/layLayerTreeModel.h b/src/laybasic/laybasic/layLayerTreeModel.h index 28c0a8549..8eab10b20 100644 --- a/src/laybasic/laybasic/layLayerTreeModel.h +++ b/src/laybasic/laybasic/layLayerTreeModel.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layLayerTreeModel #define HDR_layLayerTreeModel @@ -282,3 +283,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layLayoutCanvas.h b/src/laybasic/laybasic/layLayoutCanvas.h index 67466068b..9e6a2f169 100644 --- a/src/laybasic/laybasic/layLayoutCanvas.h +++ b/src/laybasic/laybasic/layLayoutCanvas.h @@ -35,6 +35,7 @@ #include "layViewOp.h" #include "layViewObject.h" #include "layBitmap.h" +#include "layColor.h" #include "layDrawing.h" #include "layDitherPattern.h" #include "layLineStyles.h" diff --git a/src/laybasic/laybasic/layLayoutPropertiesForm.cc b/src/laybasic/laybasic/layLayoutPropertiesForm.cc index ad5eaf135..00eeff068 100644 --- a/src/laybasic/laybasic/layLayoutPropertiesForm.cc +++ b/src/laybasic/laybasic/layLayoutPropertiesForm.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "layLayoutPropertiesForm.h" #include "layLayoutView.h" @@ -206,5 +207,4 @@ END_PROTECTED } - - +#endif diff --git a/src/laybasic/laybasic/layLayoutPropertiesForm.h b/src/laybasic/laybasic/layLayoutPropertiesForm.h index 992ac207c..5a033616d 100644 --- a/src/laybasic/laybasic/layLayoutPropertiesForm.h +++ b/src/laybasic/laybasic/layLayoutPropertiesForm.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layLayoutPropertiesForm #define HDR_layLayoutPropertiesForm @@ -62,3 +63,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layLayoutStatisticsForm.cc b/src/laybasic/laybasic/layLayoutStatisticsForm.cc index e671fa0e5..a3e847ab5 100644 --- a/src/laybasic/laybasic/layLayoutStatisticsForm.cc +++ b/src/laybasic/laybasic/layLayoutStatisticsForm.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "layLayoutStatisticsForm.h" #include "layLayoutView.h" @@ -848,5 +849,4 @@ LayoutStatisticsForm::layout_selected (int index) } - - +#endif diff --git a/src/laybasic/laybasic/layLayoutStatisticsForm.h b/src/laybasic/laybasic/layLayoutStatisticsForm.h index f85afb598..f8ee0835c 100644 --- a/src/laybasic/laybasic/layLayoutStatisticsForm.h +++ b/src/laybasic/laybasic/layLayoutStatisticsForm.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layLayoutStatisticsForm #define HDR_layLayoutStatisticsForm @@ -56,3 +57,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layLayoutViewConfigPages.cc b/src/laybasic/laybasic/layLayoutViewConfigPages.cc index 8463a6a5e..314abe80f 100644 --- a/src/laybasic/laybasic/layLayoutViewConfigPages.cc +++ b/src/laybasic/laybasic/layLayoutViewConfigPages.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "layLayoutViewConfigPages.h" #include "laybasicConfig.h" @@ -1631,3 +1632,4 @@ static tl::RegisteredClass config_decl (new LayoutViewCo } +#endif diff --git a/src/laybasic/laybasic/layLayoutViewConfigPages.h b/src/laybasic/laybasic/layLayoutViewConfigPages.h index 04eb8ec4c..b2bae947e 100644 --- a/src/laybasic/laybasic/layLayoutViewConfigPages.h +++ b/src/laybasic/laybasic/layLayoutViewConfigPages.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layLayoutViewConfigPages #define HDR_layLayoutViewConfigPages @@ -358,3 +359,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layLayoutViewFunctions.cc b/src/laybasic/laybasic/layLayoutViewFunctions.cc index 36bd854f3..0596afaed 100644 --- a/src/laybasic/laybasic/layLayoutViewFunctions.cc +++ b/src/laybasic/laybasic/layLayoutViewFunctions.cc @@ -20,6 +20,8 @@ */ +#if defined(HAVE_QT) + #include "layLayoutViewFunctions.h" #include "layLayoutView.h" #include "layCellSelectionForm.h" @@ -2253,3 +2255,5 @@ public: static tl::RegisteredClass config_decl (new LayoutViewPluginDeclaration (), -10, "LayoutViewPlugin"); } // namespace lay + +#endif diff --git a/src/laybasic/laybasic/layLayoutViewFunctions.h b/src/laybasic/laybasic/layLayoutViewFunctions.h index 37fdeb676..6f25e5eb7 100644 --- a/src/laybasic/laybasic/layLayoutViewFunctions.h +++ b/src/laybasic/laybasic/layLayoutViewFunctions.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layLayoutViewFunctions #define HDR_layLayoutViewFunctions @@ -169,3 +170,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layLibrariesView.cc b/src/laybasic/laybasic/layLibrariesView.cc index 0849a306b..2aac160a3 100644 --- a/src/laybasic/laybasic/layLibrariesView.cc +++ b/src/laybasic/laybasic/layLibrariesView.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include @@ -847,3 +848,5 @@ public: static tl::RegisteredClass config_decl (new LibraryViewPluginDeclaration (), -7, "LibraryViewPlugin"); } // namespace lay + +#endif diff --git a/src/laybasic/laybasic/layLibrariesView.h b/src/laybasic/laybasic/layLibrariesView.h index 48b650583..537556044 100644 --- a/src/laybasic/laybasic/layLibrariesView.h +++ b/src/laybasic/laybasic/layLibrariesView.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layLibrariesView #define HDR_layLibrariesView @@ -274,3 +275,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layLoadLayoutOptionsDialog.cc b/src/laybasic/laybasic/layLoadLayoutOptionsDialog.cc index 6d3835299..08dbf35b0 100644 --- a/src/laybasic/laybasic/layLoadLayoutOptionsDialog.cc +++ b/src/laybasic/laybasic/layLoadLayoutOptionsDialog.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "layLayoutView.h" #include "layLoadLayoutOptionsDialog.h" @@ -361,4 +362,4 @@ END_PROTECTED } - +#endif diff --git a/src/laybasic/laybasic/layLoadLayoutOptionsDialog.h b/src/laybasic/laybasic/layLoadLayoutOptionsDialog.h index 2ea91d1a5..2ac954128 100644 --- a/src/laybasic/laybasic/layLoadLayoutOptionsDialog.h +++ b/src/laybasic/laybasic/layLoadLayoutOptionsDialog.h @@ -20,7 +20,7 @@ */ - +#if defined(HAVE_QT) #ifndef HDR_layLoadLayoutOptionsDialog #define HDR_layLoadLayoutOptionsDialog @@ -118,3 +118,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layNetExportDialog.cc b/src/laybasic/laybasic/layNetExportDialog.cc index 6838810c5..dc38fd9c8 100644 --- a/src/laybasic/laybasic/layNetExportDialog.cc +++ b/src/laybasic/laybasic/layNetExportDialog.cc @@ -20,6 +20,8 @@ */ +#if defined(HAVE_QT) + #include "layNetExportDialog.h" #include "layPlugin.h" #include "layDispatcher.h" @@ -213,3 +215,5 @@ NetExportDialog::exec_dialog (lay::Dispatcher *plugin_root) } } + +#endif diff --git a/src/laybasic/laybasic/layNetExportDialog.h b/src/laybasic/laybasic/layNetExportDialog.h index ee46befd4..d0ced5975 100644 --- a/src/laybasic/laybasic/layNetExportDialog.h +++ b/src/laybasic/laybasic/layNetExportDialog.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layNetExportDialog #define HDR_layNetExportDialog @@ -87,3 +88,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layNetInfoDialog.cc b/src/laybasic/laybasic/layNetInfoDialog.cc index bd326b193..056bc2214 100644 --- a/src/laybasic/laybasic/layNetInfoDialog.cc +++ b/src/laybasic/laybasic/layNetInfoDialog.cc @@ -20,6 +20,8 @@ */ +#if defined(HAVE_QT) + #include "layNetInfoDialog.h" #include "tlXMLWriter.h" @@ -486,3 +488,5 @@ void NetInfoDialog::update_info_text () } } + +#endif diff --git a/src/laybasic/laybasic/layNetInfoDialog.h b/src/laybasic/laybasic/layNetInfoDialog.h index 3c3353125..dee3a88e7 100644 --- a/src/laybasic/laybasic/layNetInfoDialog.h +++ b/src/laybasic/laybasic/layNetInfoDialog.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layNetInfoDialog #define HDR_layNetInfoDialog @@ -73,3 +74,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layNetlistBrowser.cc b/src/laybasic/laybasic/layNetlistBrowser.cc index d43501a38..33d312f3f 100644 --- a/src/laybasic/laybasic/layNetlistBrowser.cc +++ b/src/laybasic/laybasic/layNetlistBrowser.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "laybasicCommon.h" #include "layNetlistBrowserDialog.h" @@ -386,3 +387,4 @@ static tl::RegisteredClass config_decl (new NetlistBrows } +#endif diff --git a/src/laybasic/laybasic/layNetlistBrowser.h b/src/laybasic/laybasic/layNetlistBrowser.h index 96f333ce7..8e848d669 100644 --- a/src/laybasic/laybasic/layNetlistBrowser.h +++ b/src/laybasic/laybasic/layNetlistBrowser.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layNetlistBrowser #define HDR_layNetlistBrowser @@ -90,3 +91,4 @@ public: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layNetlistBrowserDialog.cc b/src/laybasic/laybasic/layNetlistBrowserDialog.cc index 820ebdf32..7247effd1 100644 --- a/src/laybasic/laybasic/layNetlistBrowserDialog.cc +++ b/src/laybasic/laybasic/layNetlistBrowserDialog.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "layNetlistBrowserDialog.h" #include "tlProgress.h" @@ -838,3 +839,4 @@ NetlistBrowserDialog::menu_activated (const std::string &symbol) } +#endif diff --git a/src/laybasic/laybasic/layNetlistBrowserDialog.h b/src/laybasic/laybasic/layNetlistBrowserDialog.h index ebebe1c14..e63d91957 100644 --- a/src/laybasic/laybasic/layNetlistBrowserDialog.h +++ b/src/laybasic/laybasic/layNetlistBrowserDialog.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layNetlistBrowserDialog #define HDR_layNetlistBrowserDialog @@ -151,3 +152,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layNetlistBrowserModel.cc b/src/laybasic/laybasic/layNetlistBrowserModel.cc index 67e15af1a..cd1696a7b 100644 --- a/src/laybasic/laybasic/layNetlistBrowserModel.cc +++ b/src/laybasic/laybasic/layNetlistBrowserModel.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "layNetlistBrowserModel.h" #include "layIndexedNetlistModel.h" @@ -3020,3 +3021,4 @@ NetlistBrowserModel::set_item_visibility (QTreeView *view, bool show_all, bool w } +#endif diff --git a/src/laybasic/laybasic/layNetlistBrowserModel.h b/src/laybasic/laybasic/layNetlistBrowserModel.h index 6a43c954c..8a86696ba 100644 --- a/src/laybasic/laybasic/layNetlistBrowserModel.h +++ b/src/laybasic/laybasic/layNetlistBrowserModel.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layNetlistBrowserModel #define HDR_layNetlistBrowserModel @@ -343,3 +344,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layNetlistBrowserPage.cc b/src/laybasic/laybasic/layNetlistBrowserPage.cc index 1909956f9..1085d4c1e 100644 --- a/src/laybasic/laybasic/layNetlistBrowserPage.cc +++ b/src/laybasic/laybasic/layNetlistBrowserPage.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "layNetlistBrowserPage.h" #include "layNetlistBrowserModel.h" @@ -1458,3 +1459,4 @@ NetlistBrowserPage::export_nets (const std::vector *nets) } +#endif diff --git a/src/laybasic/laybasic/layNetlistBrowserPage.h b/src/laybasic/laybasic/layNetlistBrowserPage.h index c268baaa5..ac135245d 100644 --- a/src/laybasic/laybasic/layNetlistBrowserPage.h +++ b/src/laybasic/laybasic/layNetlistBrowserPage.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layNetlistBrowserPage #define HDR_layNetlistBrowserPage @@ -269,3 +270,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layNetlistBrowserTreeModel.cc b/src/laybasic/laybasic/layNetlistBrowserTreeModel.cc index c88954df6..cc13503c0 100644 --- a/src/laybasic/laybasic/layNetlistBrowserTreeModel.cc +++ b/src/laybasic/laybasic/layNetlistBrowserTreeModel.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "layNetlistBrowserTreeModel.h" #include "layIndexedNetlistModel.h" @@ -447,3 +448,5 @@ NetlistBrowserTreeModel::rowCount (const QModelIndex &parent) const } } + +#endif diff --git a/src/laybasic/laybasic/layNetlistBrowserTreeModel.h b/src/laybasic/laybasic/layNetlistBrowserTreeModel.h index d17c0bff2..19fdf20b4 100644 --- a/src/laybasic/laybasic/layNetlistBrowserTreeModel.h +++ b/src/laybasic/laybasic/layNetlistBrowserTreeModel.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layNetlistBrowserTreeModel #define HDR_layNetlistBrowserTreeModel @@ -103,3 +104,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layNetlistCrossReferenceModel.cc b/src/laybasic/laybasic/layNetlistCrossReferenceModel.cc index 17ced1c64..ca0a4682b 100644 --- a/src/laybasic/laybasic/layNetlistCrossReferenceModel.cc +++ b/src/laybasic/laybasic/layNetlistCrossReferenceModel.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "layNetlistCrossReferenceModel.h" @@ -800,3 +801,5 @@ std::string NetlistCrossReferenceModel::subcircuit_status_hint (const circuit_pa } } + +#endif diff --git a/src/laybasic/laybasic/layNetlistCrossReferenceModel.h b/src/laybasic/laybasic/layNetlistCrossReferenceModel.h index 8ad542411..01475b35b 100644 --- a/src/laybasic/laybasic/layNetlistCrossReferenceModel.h +++ b/src/laybasic/laybasic/layNetlistCrossReferenceModel.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layNetlistCrossReference #define HDR_layNetlistCrossReference @@ -119,3 +120,5 @@ public: } #endif + +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layPluginConfigPage.cc b/src/laybasic/laybasic/layPluginConfigPage.cc index 680e76f01..2cc95aa98 100644 --- a/src/laybasic/laybasic/layPluginConfigPage.cc +++ b/src/laybasic/laybasic/layPluginConfigPage.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "laybasicCommon.h" @@ -31,3 +32,5 @@ namespace lay // .. nothing yet .. } + +#endif diff --git a/src/laybasic/laybasic/layPluginConfigPage.h b/src/laybasic/laybasic/layPluginConfigPage.h index e190ac15a..fa3362281 100644 --- a/src/laybasic/laybasic/layPluginConfigPage.h +++ b/src/laybasic/laybasic/layPluginConfigPage.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layPluginConfigPage #define HDR_layPluginConfigPage @@ -80,3 +81,4 @@ public: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layProperties.cc b/src/laybasic/laybasic/layProperties.cc index 8f9696e13..fa3ca2360 100644 --- a/src/laybasic/laybasic/layProperties.cc +++ b/src/laybasic/laybasic/layProperties.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "layProperties.h" @@ -41,3 +42,4 @@ PropertiesPage::~PropertiesPage () } +#endif diff --git a/src/laybasic/laybasic/layProperties.h b/src/laybasic/laybasic/layProperties.h index 36124cc7d..07c6ffe98 100644 --- a/src/laybasic/laybasic/layProperties.h +++ b/src/laybasic/laybasic/layProperties.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layProperties #define HDR_layProperties @@ -237,3 +238,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layPropertiesDialog.cc b/src/laybasic/laybasic/layPropertiesDialog.cc index b42d3c367..09d8a697b 100644 --- a/src/laybasic/laybasic/layPropertiesDialog.cc +++ b/src/laybasic/laybasic/layPropertiesDialog.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "layPropertiesDialog.h" @@ -349,3 +350,4 @@ PropertiesDialog::reject () } +#endif diff --git a/src/laybasic/laybasic/layPropertiesDialog.h b/src/laybasic/laybasic/layPropertiesDialog.h index 4aad302c6..85faaf991 100644 --- a/src/laybasic/laybasic/layPropertiesDialog.h +++ b/src/laybasic/laybasic/layPropertiesDialog.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layPropertiesDialog #define HDR_layPropertiesDialog @@ -103,3 +104,4 @@ protected: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layQtTools.cc b/src/laybasic/laybasic/layQtTools.cc index 70a0f6b22..66ac0ee61 100644 --- a/src/laybasic/laybasic/layQtTools.cc +++ b/src/laybasic/laybasic/layQtTools.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "layQtTools.h" #include "tlString.h" @@ -219,3 +220,4 @@ SignalBlocker::~SignalBlocker () } +#endif diff --git a/src/laybasic/laybasic/layQtTools.h b/src/laybasic/laybasic/layQtTools.h index fe0a65557..7b49c8aff 100644 --- a/src/laybasic/laybasic/layQtTools.h +++ b/src/laybasic/laybasic/layQtTools.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layQtTools #define HDR_layQtTools @@ -114,3 +115,4 @@ typedef QSignalBlocker SignalBlocker; #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layRedrawThreadWorker.cc b/src/laybasic/laybasic/layRedrawThreadWorker.cc index da0905be8..2a7614177 100644 --- a/src/laybasic/laybasic/layRedrawThreadWorker.cc +++ b/src/laybasic/laybasic/layRedrawThreadWorker.cc @@ -23,6 +23,7 @@ #include "layRedrawThreadWorker.h" #include "layRedrawThread.h" +#include "layBitmap.h" namespace lay { diff --git a/src/laybasic/laybasic/laySaveLayoutOptionsDialog.cc b/src/laybasic/laybasic/laySaveLayoutOptionsDialog.cc index c1fc62cb4..ff5b28002 100644 --- a/src/laybasic/laybasic/laySaveLayoutOptionsDialog.cc +++ b/src/laybasic/laybasic/laySaveLayoutOptionsDialog.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "layLayoutView.h" #include "laySaveLayoutOptionsDialog.h" @@ -553,3 +554,4 @@ SaveLayoutAsOptionsDialog::fmt_cbx_changed (int index) } +#endif diff --git a/src/laybasic/laybasic/laySaveLayoutOptionsDialog.h b/src/laybasic/laybasic/laySaveLayoutOptionsDialog.h index a482e90f5..a8dcb6554 100644 --- a/src/laybasic/laybasic/laySaveLayoutOptionsDialog.h +++ b/src/laybasic/laybasic/laySaveLayoutOptionsDialog.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_laySaveLayoutOptionsDialog #define HDR_laySaveLayoutOptionsDialog @@ -103,3 +104,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/laySelectCellViewForm.cc b/src/laybasic/laybasic/laySelectCellViewForm.cc index 7ef98e984..1ae4b1da7 100644 --- a/src/laybasic/laybasic/laySelectCellViewForm.cc +++ b/src/laybasic/laybasic/laySelectCellViewForm.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "laySelectCellViewForm.h" #include "layCellView.h" @@ -134,3 +135,4 @@ SelectCellViewForm::select_all () } +#endif diff --git a/src/laybasic/laybasic/laySelectCellViewForm.h b/src/laybasic/laybasic/laySelectCellViewForm.h index 9dd053bc4..5abd7efe2 100644 --- a/src/laybasic/laybasic/laySelectCellViewForm.h +++ b/src/laybasic/laybasic/laySelectCellViewForm.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_SelectCellViewForm #define HDR_SelectCellViewForm @@ -90,3 +91,4 @@ public slots: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/laySelectLineStyleForm.cc b/src/laybasic/laybasic/laySelectLineStyleForm.cc index df64c51b9..cb32fd06b 100644 --- a/src/laybasic/laybasic/laySelectLineStyleForm.cc +++ b/src/laybasic/laybasic/laySelectLineStyleForm.cc @@ -20,7 +20,7 @@ */ - +#if defined(HAVE_QT) #include "laySelectLineStyleForm.h" #include "ui_SelectLineStyleForm.h" @@ -133,3 +133,4 @@ SelectLineStyleForm::sel_changed (QListWidgetItem *citem, QListWidgetItem *) } +#endif diff --git a/src/laybasic/laybasic/laySelectLineStyleForm.h b/src/laybasic/laybasic/laySelectLineStyleForm.h index 971e244aa..9cb159e2a 100644 --- a/src/laybasic/laybasic/laySelectLineStyleForm.h +++ b/src/laybasic/laybasic/laySelectLineStyleForm.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_laySelectLineStyleForm #define HDR_laySelectLineStyleForm @@ -72,3 +73,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/laySelectStippleForm.cc b/src/laybasic/laybasic/laySelectStippleForm.cc index 97e954faf..76f9354a4 100644 --- a/src/laybasic/laybasic/laySelectStippleForm.cc +++ b/src/laybasic/laybasic/laySelectStippleForm.cc @@ -20,7 +20,7 @@ */ - +#if defined(HAVE_QT) #include "laySelectStippleForm.h" #include "ui_SelectStippleForm.h" @@ -133,3 +133,4 @@ SelectStippleForm::sel_changed (QListWidgetItem *citem, QListWidgetItem *) } +#endif diff --git a/src/laybasic/laybasic/laySelectStippleForm.h b/src/laybasic/laybasic/laySelectStippleForm.h index a6432e460..4769914fc 100644 --- a/src/laybasic/laybasic/laySelectStippleForm.h +++ b/src/laybasic/laybasic/laySelectStippleForm.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_laySelectStippleForm #define HDR_laySelectStippleForm @@ -72,3 +73,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layStream.cc b/src/laybasic/laybasic/layStream.cc index 64a59d6c6..0da6346ec 100644 --- a/src/laybasic/laybasic/layStream.cc +++ b/src/laybasic/laybasic/layStream.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "layStream.h" #include "layPlugin.h" @@ -84,3 +85,4 @@ const StreamWriterPluginDeclaration *StreamWriterPluginDeclaration::plugin_for_f } +#endif diff --git a/src/laybasic/laybasic/layStream.h b/src/laybasic/laybasic/layStream.h index 55d4fde00..c6ba13660 100644 --- a/src/laybasic/laybasic/layStream.h +++ b/src/laybasic/laybasic/layStream.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layStream_h #define HDR_layStream_h @@ -267,3 +268,4 @@ public: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layTechnology.cc b/src/laybasic/laybasic/layTechnology.cc index 5f03acdce..a7f8de11b 100644 --- a/src/laybasic/laybasic/layTechnology.cc +++ b/src/laybasic/laybasic/layTechnology.cc @@ -20,7 +20,10 @@ */ +#if defined(HAVE_QT) #include "layTechnology.h" // .. nothing yet .. + +#endif diff --git a/src/laybasic/laybasic/layTechnology.h b/src/laybasic/laybasic/layTechnology.h index a4d25fccc..c7168b313 100644 --- a/src/laybasic/laybasic/layTechnology.h +++ b/src/laybasic/laybasic/layTechnology.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layTechnology #define HDR_layTechnology @@ -137,3 +138,4 @@ public: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layTipDialog.cc b/src/laybasic/laybasic/layTipDialog.cc index fd9c27493..c7c86a923 100644 --- a/src/laybasic/laybasic/layTipDialog.cc +++ b/src/laybasic/laybasic/layTipDialog.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "layTipDialog.h" #include "laybasicConfig.h" @@ -217,3 +218,4 @@ TipDialog::~TipDialog () } +#endif diff --git a/src/laybasic/laybasic/layTipDialog.h b/src/laybasic/laybasic/layTipDialog.h index dabc68318..fc6ffaf27 100644 --- a/src/laybasic/laybasic/layTipDialog.h +++ b/src/laybasic/laybasic/layTipDialog.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layTipDialog #define HDR_layTipDialog @@ -110,3 +111,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layWidgets.cc b/src/laybasic/laybasic/layWidgets.cc index 3335861a2..aa31b339a 100644 --- a/src/laybasic/laybasic/layWidgets.cc +++ b/src/laybasic/laybasic/layWidgets.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include #include @@ -1314,3 +1315,5 @@ InteractiveListWidget::refresh_flags () } } + +#endif diff --git a/src/laybasic/laybasic/layWidgets.h b/src/laybasic/laybasic/layWidgets.h index 6020c78a9..eb3ef708f 100644 --- a/src/laybasic/laybasic/layWidgets.h +++ b/src/laybasic/laybasic/layWidgets.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layWidgets #define HDR_layWidgets @@ -524,3 +525,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/laybasic.pro b/src/laybasic/laybasic/laybasic.pro index 421298aa9..b0750a4e6 100644 --- a/src/laybasic/laybasic/laybasic.pro +++ b/src/laybasic/laybasic/laybasic.pro @@ -82,7 +82,11 @@ DEFINES += MAKE_LAYBASIC_LIBRARY laybasicResources.qrc \ layLayoutStatistics.qrc \ - SOURCES = \ +} + +# Disabled without Qt: + +SOURCES = \ gsiDeclLayDialogs.cc \ gsiDeclLayMenu.cc \ gsiDeclLayNetlistBrowserDialog.cc \ @@ -153,7 +157,9 @@ DEFINES += MAKE_LAYBASIC_LIBRARY rdbMarkerBrowserDialog.cc \ rdbMarkerBrowserPage.cc \ - HEADERS = \ +# Disabled without Qt: + +HEADERS = \ gtf.h \ layAbstractMenu.h \ layBackgroundAwareTreeStyle.h \ @@ -223,7 +229,7 @@ DEFINES += MAKE_LAYBASIC_LIBRARY rdbMarkerBrowserDialog.h \ rdbMarkerBrowserPage.h \ -} +# Enabled without Qt: SOURCES += \ gsiDeclLayLayers.cc \ @@ -231,6 +237,7 @@ SOURCES += \ gsiDeclLayMarker.cc \ gsiDeclLayPlugin.cc \ gsiDeclLayPixelBuffer.cc \ + laybasicForceLink.cc \ layAnnotationShapes.cc \ layBitmap.cc \ layBitmapRenderer.cc \ @@ -278,7 +285,10 @@ SOURCES += \ layViewport.cc \ layZoomBox.cc \ +# Enabled without Qt: + HEADERS += \ + laybasicForceLink.h \ layAnnotationShapes.h \ layBitmap.h \ layBitmapRenderer.h \ diff --git a/src/laybasic/laybasic/laybasicConfig.h b/src/laybasic/laybasic/laybasicConfig.h index d9e7bd5ad..0b84bf38f 100644 --- a/src/laybasic/laybasic/laybasicConfig.h +++ b/src/laybasic/laybasic/laybasicConfig.h @@ -20,7 +20,6 @@ */ - #ifndef HDR_laybasicConfig #define HDR_laybasicConfig @@ -147,4 +146,3 @@ static const std::string cfg_guiding_shape_vertex_size ("guiding-shape-vertex-si } #endif - diff --git a/src/laybasic/laybasic/laybasicForceLink.cc b/src/laybasic/laybasic/laybasicForceLink.cc new file mode 100644 index 000000000..9db8fe64f --- /dev/null +++ b/src/laybasic/laybasic/laybasicForceLink.cc @@ -0,0 +1,32 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 "laybasicForceLink.h" + +namespace laybasic +{ + int _force_link_f () + { + return 0; + } +} + diff --git a/src/laybasic/laybasic/laybasicForceLink.h b/src/laybasic/laybasic/laybasicForceLink.h new file mode 100644 index 000000000..1f84613ce --- /dev/null +++ b/src/laybasic/laybasic/laybasicForceLink.h @@ -0,0 +1,40 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 + +*/ + + +#ifndef HDR_laybasicForceLink +#define HDR_laybasicForceLink + +#include "laybasicCommon.h" + +/** + * @file Include this function to force linking of the lay module + */ + +namespace laybasic +{ + LAYBASIC_PUBLIC int _force_link_f (); + static int _force_link_target = _force_link_f (); +} + +#endif + diff --git a/src/laybasic/laybasic/rdbInfoWidget.cc b/src/laybasic/laybasic/rdbInfoWidget.cc index f692ab093..f702c0ed8 100644 --- a/src/laybasic/laybasic/rdbInfoWidget.cc +++ b/src/laybasic/laybasic/rdbInfoWidget.cc @@ -21,6 +21,8 @@ */ +#if defined(HAVE_QT) + #include "rdbInfoWidget.h" #include @@ -63,3 +65,4 @@ InfoWidget::loadResource (int type, const QUrl &name) } +#endif diff --git a/src/laybasic/laybasic/rdbInfoWidget.h b/src/laybasic/laybasic/rdbInfoWidget.h index b9198970b..447978656 100644 --- a/src/laybasic/laybasic/rdbInfoWidget.h +++ b/src/laybasic/laybasic/rdbInfoWidget.h @@ -20,7 +20,7 @@ */ - +#if defined(HAVE_QT) #ifndef HDR_rdbInfoWidget #define HDR_rdbInfoWidget @@ -52,3 +52,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/rdbMarkerBrowser.cc b/src/laybasic/laybasic/rdbMarkerBrowser.cc index 2a7e9928a..b0093decf 100644 --- a/src/laybasic/laybasic/rdbMarkerBrowser.cc +++ b/src/laybasic/laybasic/rdbMarkerBrowser.cc @@ -20,7 +20,7 @@ */ - +#if defined(HAVE_QT) #include "rdbMarkerBrowserDialog.h" @@ -312,3 +312,4 @@ static tl::RegisteredClass config_decl (new MarkerBrowse } +#endif diff --git a/src/laybasic/laybasic/rdbMarkerBrowser.h b/src/laybasic/laybasic/rdbMarkerBrowser.h index b2a14a25b..fd39a132e 100644 --- a/src/laybasic/laybasic/rdbMarkerBrowser.h +++ b/src/laybasic/laybasic/rdbMarkerBrowser.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_rdbMarkerBrowser #define HDR_rdbMarkerBrowser @@ -86,3 +87,4 @@ public: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/rdbMarkerBrowserDialog.cc b/src/laybasic/laybasic/rdbMarkerBrowserDialog.cc index c85b40024..644d0c089 100644 --- a/src/laybasic/laybasic/rdbMarkerBrowserDialog.cc +++ b/src/laybasic/laybasic/rdbMarkerBrowserDialog.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "rdbMarkerBrowserDialog.h" #include "rdb.h" @@ -902,3 +903,4 @@ MarkerBrowserDialog::menu_activated (const std::string &symbol) } +#endif diff --git a/src/laybasic/laybasic/rdbMarkerBrowserDialog.h b/src/laybasic/laybasic/rdbMarkerBrowserDialog.h index 5e0bd782e..a8c6703d1 100644 --- a/src/laybasic/laybasic/rdbMarkerBrowserDialog.h +++ b/src/laybasic/laybasic/rdbMarkerBrowserDialog.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_rdbMarkerBrowserDialog #define HDR_rdbMarkerBrowserDialog @@ -99,3 +100,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/rdbMarkerBrowserPage.cc b/src/laybasic/laybasic/rdbMarkerBrowserPage.cc index df28158db..2efedbc0f 100644 --- a/src/laybasic/laybasic/rdbMarkerBrowserPage.cc +++ b/src/laybasic/laybasic/rdbMarkerBrowserPage.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "rdbMarkerBrowserPage.h" #include "rdb.h" @@ -3163,3 +3164,4 @@ MarkerBrowserPage::eventFilter (QObject *watched, QEvent *event) } +#endif diff --git a/src/laybasic/laybasic/rdbMarkerBrowserPage.h b/src/laybasic/laybasic/rdbMarkerBrowserPage.h index f879884a6..2982cb045 100644 --- a/src/laybasic/laybasic/rdbMarkerBrowserPage.h +++ b/src/laybasic/laybasic/rdbMarkerBrowserPage.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_rdbMarkerBrowserPage #define HDR_rdbMarkerBrowserPage @@ -225,3 +226,4 @@ private: #endif +#endif // defined(HAVE_QT) diff --git a/src/lym/lym/lymForceLink.cc b/src/lym/lym/lymForceLink.cc new file mode 100644 index 000000000..2f1b61cf7 --- /dev/null +++ b/src/lym/lym/lymForceLink.cc @@ -0,0 +1,32 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 warrlymy 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 "lymForceLink.h" + +namespace lym +{ + int _force_link_f () + { + return 0; + } +} + diff --git a/src/lym/lym/lymForceLink.h b/src/lym/lym/lymForceLink.h new file mode 100644 index 000000000..f47b70955 --- /dev/null +++ b/src/lym/lym/lymForceLink.h @@ -0,0 +1,40 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 warrlymy 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 + +*/ + + +#ifndef HDR_lymForceLink +#define HDR_lymForceLink + +#include "lymCommon.h" + +/** + * @file Include this function to force linking of the lym module + */ + +namespace lym +{ + LYM_PUBLIC int _force_link_f (); + static int _force_link_target = _force_link_f (); +} + +#endif + diff --git a/src/pymod/__init__.py.qtless b/src/pymod/__init__.py.qtless index 776d25ace..782df0624 100644 --- a/src/pymod/__init__.py.qtless +++ b/src/pymod/__init__.py.qtless @@ -1,4 +1,4 @@ # klayout library definition file -__all__ = [ "tl", "db", "lib", "rdb" ] +__all__ = [ "tl", "db", "lib", "rdb", "lay" ] diff --git a/src/pymod/ant/ant.pro b/src/pymod/ant/ant.pro new file mode 100644 index 000000000..6df7c0d5a --- /dev/null +++ b/src/pymod/ant/ant.pro @@ -0,0 +1,12 @@ + +TARGET = ant + +include($$PWD/../pymod.pri) + +SOURCES = \ + antMain.cc \ + +HEADERS += \ + +LIBS += -lklayout_ant + diff --git a/src/pymod/ant/antMain.cc b/src/pymod/ant/antMain.cc new file mode 100644 index 000000000..1ec947f0d --- /dev/null +++ b/src/pymod/ant/antMain.cc @@ -0,0 +1,28 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 "../pymodHelper.h" + +// to force linking of the ant module +# include "../../ant/ant/antForceLink.h" + +DEFINE_PYMOD(antcore, "ant", "KLayout core module 'ant'") diff --git a/src/pymod/distutils_src/klayout/lay/__init__.py b/src/pymod/distutils_src/klayout/lay/__init__.py new file mode 100644 index 000000000..ee976c13d --- /dev/null +++ b/src/pymod/distutils_src/klayout/lay/__init__.py @@ -0,0 +1,12 @@ +import klayout.laycore +import klayout.antcore +import klayout.edtcore +import klayout.imgcore +import klayout.lymcore +from klayout.laycore import * +from klayout.antcore import * +from klayout.edtcore import * +from klayout.imgcore import * +from klayout.laycore import * + +__all__ = klayout.laycore.__all__ + klayout.antcore.__all__ + klayout.edtcore.__all__ + klayout.imgcore.__all__ + klayout.laycore.__all__ diff --git a/src/pymod/edt/edt.pro b/src/pymod/edt/edt.pro new file mode 100644 index 000000000..f2b8fe8b4 --- /dev/null +++ b/src/pymod/edt/edt.pro @@ -0,0 +1,12 @@ + +TARGET = edt + +include($$PWD/../pymod.pri) + +SOURCES = \ + edtMain.cc \ + +HEADERS += \ + +LIBS += -lklayout_edt + diff --git a/src/pymod/edt/edtMain.cc b/src/pymod/edt/edtMain.cc new file mode 100644 index 000000000..5ae69e64b --- /dev/null +++ b/src/pymod/edt/edtMain.cc @@ -0,0 +1,28 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 warrlymy 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 "../pymodHelper.h" + +// to force linking of the edt module +# include "../../edt/edt/edtForceLink.h" + +DEFINE_PYMOD(edtcore, "edt", "KLayout core module 'edt'") diff --git a/src/pymod/edt/lay.pro b/src/pymod/edt/lay.pro new file mode 100644 index 000000000..5555294e0 --- /dev/null +++ b/src/pymod/edt/lay.pro @@ -0,0 +1,12 @@ + +TARGET = lay + +include($$PWD/../pymod.pri) + +SOURCES = \ + layMain.cc \ + +HEADERS += \ + +LIBS += -lklayout_lay + diff --git a/src/pymod/edt/layMain.cc b/src/pymod/edt/layMain.cc new file mode 100644 index 000000000..b68e22169 --- /dev/null +++ b/src/pymod/edt/layMain.cc @@ -0,0 +1,37 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 "../pymodHelper.h" + +#if defined(HAVE_QT) +// to force linking of the lay module +# include "../../lay/lay/layForceLink.h" +#else +// to force linking of the laybasic module +// NOTE: without Qt we can only utilize the core view classes from laybasic +# include "../../laybasic/laybasic/laybasicForceLink.h" +#endif + +// NOTE: img, ant, edt and rdb don't need to be force-linked +// as they are hard-linked by lay + +DEFINE_PYMOD(laycore, "lay", "KLayout core module 'lay'") diff --git a/src/pymod/img/img.pro b/src/pymod/img/img.pro new file mode 100644 index 000000000..ca520540a --- /dev/null +++ b/src/pymod/img/img.pro @@ -0,0 +1,12 @@ + +TARGET = img + +include($$PWD/../pymod.pri) + +SOURCES = \ + imgMain.cc \ + +HEADERS += \ + +LIBS += -lklayout_img + diff --git a/src/pymod/img/imgMain.cc b/src/pymod/img/imgMain.cc new file mode 100644 index 000000000..db7eb4d79 --- /dev/null +++ b/src/pymod/img/imgMain.cc @@ -0,0 +1,28 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 warrimgy 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 "../pymodHelper.h" + +// to force linking of the img module +# include "../../img/img/imgForceLink.h" + +DEFINE_PYMOD(imgcore, "img", "KLayout core module 'img'") diff --git a/src/pymod/img/lay.pro b/src/pymod/img/lay.pro new file mode 100644 index 000000000..5555294e0 --- /dev/null +++ b/src/pymod/img/lay.pro @@ -0,0 +1,12 @@ + +TARGET = lay + +include($$PWD/../pymod.pri) + +SOURCES = \ + layMain.cc \ + +HEADERS += \ + +LIBS += -lklayout_lay + diff --git a/src/pymod/img/layMain.cc b/src/pymod/img/layMain.cc new file mode 100644 index 000000000..b68e22169 --- /dev/null +++ b/src/pymod/img/layMain.cc @@ -0,0 +1,37 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 "../pymodHelper.h" + +#if defined(HAVE_QT) +// to force linking of the lay module +# include "../../lay/lay/layForceLink.h" +#else +// to force linking of the laybasic module +// NOTE: without Qt we can only utilize the core view classes from laybasic +# include "../../laybasic/laybasic/laybasicForceLink.h" +#endif + +// NOTE: img, ant, edt and rdb don't need to be force-linked +// as they are hard-linked by lay + +DEFINE_PYMOD(laycore, "lay", "KLayout core module 'lay'") diff --git a/src/pymod/lay/layMain.cc b/src/pymod/lay/layMain.cc index 6d13a6ab0..1e1de16bc 100644 --- a/src/pymod/lay/layMain.cc +++ b/src/pymod/lay/layMain.cc @@ -22,10 +22,13 @@ #include "../pymodHelper.h" +#if defined(HAVE_QT) // to force linking of the lay module -#include "../../lay/lay/layForceLink.h" +# include "../../lay/lay/layForceLink.h" +#else +// to force linking of the laybasic module +// NOTE: without Qt we can only utilize the core view classes from laybasic +# include "../../laybasic/laybasic/laybasicForceLink.h" +#endif -// NOTE: img, ant, edt and rdb don't need to be force-linked -// as they are hard-linked by lay - -DEFINE_PYMOD(lay, "lay", "KLayout core module 'lay'") +DEFINE_PYMOD(laycore, "lay", "KLayout core module 'lay'") diff --git a/src/pymod/lym/lym.pro b/src/pymod/lym/lym.pro new file mode 100644 index 000000000..4e1e5983e --- /dev/null +++ b/src/pymod/lym/lym.pro @@ -0,0 +1,12 @@ + +TARGET = lym + +include($$PWD/../pymod.pri) + +SOURCES = \ + lymMain.cc \ + +HEADERS += \ + +LIBS += -lklayout_lym + diff --git a/src/pymod/lym/lymMain.cc b/src/pymod/lym/lymMain.cc new file mode 100644 index 000000000..0d34f46ca --- /dev/null +++ b/src/pymod/lym/lymMain.cc @@ -0,0 +1,28 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 warrlymy 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 "../pymodHelper.h" + +// to force linking of the lym module +# include "../../lym/lym/lymForceLink.h" + +DEFINE_PYMOD(lymcore, "lym", "KLayout core module 'lym'") diff --git a/src/pymod/pymod.pro b/src/pymod/pymod.pro index cb205bcdb..5b2debe92 100644 --- a/src/pymod/pymod.pro +++ b/src/pymod/pymod.pro @@ -7,11 +7,14 @@ SUBDIRS = \ tl \ rdb \ lib \ + lay \ + lym \ + ant \ + edt \ + img \ !equals(HAVE_QT, "0") { - SUBDIRS += lay - equals(HAVE_QTBINDINGS, "1") { SUBDIRS += \ From d01ea4924690668836bf9b1a279428253730dc88 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Thu, 12 May 2022 23:42:06 +0200 Subject: [PATCH 58/88] [CONSIDER MERGING] fixed a typo in gsiDeclBasic.cc which might cause a duplicate GSI class duplicatge registration assertion --- src/gsi/gsi/gsiDeclBasic.cc | 2 +- src/pymod/edt/layMain.cc | 37 ------------------------------------- src/pymod/img/layMain.cc | 37 ------------------------------------- 3 files changed, 1 insertion(+), 75 deletions(-) delete mode 100644 src/pymod/edt/layMain.cc delete mode 100644 src/pymod/img/layMain.cc diff --git a/src/gsi/gsi/gsiDeclBasic.cc b/src/gsi/gsi/gsiDeclBasic.cc index 15f7a18fb..b38f25968 100644 --- a/src/gsi/gsi/gsiDeclBasic.cc +++ b/src/gsi/gsi/gsiDeclBasic.cc @@ -102,7 +102,7 @@ static gsi::Interpreter *ruby_interpreter () return interpreter_by_name ("rba"); } -Class decl_Macro ("tl", "Interpreter", +Class decl_Interpreter ("tl", "Interpreter", gsi::method ("load_file", &Interpreter::load_file, gsi::arg ("path"), "@brief Loads the given file into the interpreter\n" "This will execute the code inside the file.\n" diff --git a/src/pymod/edt/layMain.cc b/src/pymod/edt/layMain.cc deleted file mode 100644 index b68e22169..000000000 --- a/src/pymod/edt/layMain.cc +++ /dev/null @@ -1,37 +0,0 @@ - -/* - - KLayout Layout Viewer - Copyright (C) 2006-2022 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 "../pymodHelper.h" - -#if defined(HAVE_QT) -// to force linking of the lay module -# include "../../lay/lay/layForceLink.h" -#else -// to force linking of the laybasic module -// NOTE: without Qt we can only utilize the core view classes from laybasic -# include "../../laybasic/laybasic/laybasicForceLink.h" -#endif - -// NOTE: img, ant, edt and rdb don't need to be force-linked -// as they are hard-linked by lay - -DEFINE_PYMOD(laycore, "lay", "KLayout core module 'lay'") diff --git a/src/pymod/img/layMain.cc b/src/pymod/img/layMain.cc deleted file mode 100644 index b68e22169..000000000 --- a/src/pymod/img/layMain.cc +++ /dev/null @@ -1,37 +0,0 @@ - -/* - - KLayout Layout Viewer - Copyright (C) 2006-2022 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 "../pymodHelper.h" - -#if defined(HAVE_QT) -// to force linking of the lay module -# include "../../lay/lay/layForceLink.h" -#else -// to force linking of the laybasic module -// NOTE: without Qt we can only utilize the core view classes from laybasic -# include "../../laybasic/laybasic/laybasicForceLink.h" -#endif - -// NOTE: img, ant, edt and rdb don't need to be force-linked -// as they are hard-linked by lay - -DEFINE_PYMOD(laycore, "lay", "KLayout core module 'lay'") From 5facc418cb7d9d12444e64959cc605d0719a37e5 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Thu, 12 May 2022 23:42:21 +0200 Subject: [PATCH 59/88] WIP: futher improvements on Python module for Qt-less case --- MANIFEST.in | 12 ++++-- setup.py | 38 +++++++++---------- src/klayout.pro | 3 +- src/laybasic/laybasic/laybasic.pro | 6 +-- src/pya/pya/pyaModule.cc | 5 +++ .../distutils_src/klayout/lay/__init__.py | 11 +----- src/pymod/lay/layMain.cc | 8 ++++ 7 files changed, 48 insertions(+), 35 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index 531a510b2..42f956cba 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,10 +1,16 @@ -recursive-include src/tl/tl *.cc *.h +recursive-include src/ant/ant *.cc *.h recursive-include src/db/db *.cc *.cc_gen *.h +recursive-include src/edt/edt *.cc *.h recursive-include src/gsi/gsi *.cc *.h -recursive-include src/rdb/rdb *.cc *.h -recursive-include src/pya/pya *.cc *.h +recursive-include src/img/img *.cc *.h +recursive-include src/laybasic/laybasic *.cc *.h recursive-include src/lib/lib *.cc *.h +recursive-include src/lym/lym *.cc *.h +recursive-include src/pya/pya *.cc *.h recursive-include src/pymod *.cc *.h +recursive-include src/rbastub *.cc *.h +recursive-include src/rdb/rdb *.cc *.h +recursive-include src/tl/tl *.cc *.h include src/plugins/*/db_plugin/*.cc include src/plugins/*/*/db_plugin/*.cc include src/plugins/*/db_plugin/*.h diff --git a/setup.py b/setup.py index 595d035f1..bf826a911 100644 --- a/setup.py +++ b/setup.py @@ -523,6 +523,23 @@ _rdb = Library(config.root + '._rdb', sources=list(_rdb_sources)) config.add_extension(_rdb) +# ------------------------------------------------------------------ +# _lay dependency library + +_lay_path = os.path.join("src", "laybasic", "laybasic") +_lay_sources = set(glob.glob(os.path.join(_lay_path, "*.cc"))) + +_lay = Library(config.root + '._lay', + define_macros=config.macros() + [('MAKE_LAYBASIC_LIBRARY', 1)], + include_dirs=[_rdb_path, _db_path, _tl_path, _gsi_path], + extra_objects=[config.path_of('_rdb', _rdb_path), config.path_of('_tl', _tl_path), config.path_of('_gsi', _gsi_path), config.path_of('_db', _db_path)], + language='c++', + libraries=config.libraries('_lay'), + extra_link_args=config.link_args('_lay'), + extra_compile_args=config.compile_args('_lay'), + sources=list(_lay_sources)) +config.add_extension(_lay) + # ------------------------------------------------------------------ # _lym dependency library @@ -540,23 +557,6 @@ _lym = Library(config.root + '._lym', sources=list(_lym_sources)) config.add_extension(_lym) -# ------------------------------------------------------------------ -# _lay dependency library - -_lay_path = os.path.join("src", "laybasic", "laybasic") -_lay_sources = set(glob.glob(os.path.join(_lay_path, "*.cc"))) - -_lay = Library(config.root + '._lay', - define_macros=config.macros() + [('MAKE_LAYBASIC_LIBRARY', 1)], - include_dirs=[_lym_path, _rdb_path, _db_path, _tl_path, _gsi_path], - extra_objects=[config.path_of('_lym', _lym_path), config.path_of('_rdb', _rdb_path), config.path_of('_tl', _tl_path), config.path_of('_gsi', _gsi_path), config.path_of('_db', _db_path)], - language='c++', - libraries=config.libraries('_lay'), - extra_link_args=config.link_args('_lay'), - extra_compile_args=config.compile_args('_lay'), - sources=list(_lay_sources)) -config.add_extension(_lay) - # ------------------------------------------------------------------ # _ant dependency library @@ -699,8 +699,8 @@ lay_sources = set(glob.glob(os.path.join(lay_path, "*.cc"))) lay = Extension(config.root + '.laycore', define_macros=config.macros(), - include_dirs=[_lay_path, _tl_path, _gsi_path, _pya_path], - extra_objects=[config.path_of('_lay', _lay_path), config.path_of('_tl', _tl_path), config.path_of('_gsi', _gsi_path), config.path_of('_pya', _pya_path)], + include_dirs=[_lay_path, _img_path, _ant_path, _edt_path, _lym_path, _tl_path, _gsi_path, _pya_path], + extra_objects=[config.path_of('_lay', _lay_path), config.path_of('_img', _img_path), config.path_of('_ant', _ant_path), config.path_of('_edt', _edt_path), config.path_of('_lym', _lym_path), config.path_of('_tl', _tl_path), config.path_of('_gsi', _gsi_path), config.path_of('_pya', _pya_path)], extra_link_args=config.link_args('laycore'), extra_compile_args=config.compile_args('laycore'), sources=list(lay_sources)) diff --git a/src/klayout.pro b/src/klayout.pro index 1c6045181..c682bb064 100644 --- a/src/klayout.pro +++ b/src/klayout.pro @@ -64,7 +64,8 @@ lib.depends += db buddies.depends += plugins lym $$LANG_DEPENDS lym.depends += gsi $$LANG_DEPENDS -laybasic.depends += rdb lym + +laybasic.depends += rdb ant.depends += laybasic img.depends += laybasic diff --git a/src/laybasic/laybasic/laybasic.pro b/src/laybasic/laybasic/laybasic.pro index b0750a4e6..95ac373fa 100644 --- a/src/laybasic/laybasic/laybasic.pro +++ b/src/laybasic/laybasic/laybasic.pro @@ -337,9 +337,9 @@ HEADERS += \ laybasicCommon.h \ -INCLUDEPATH += $$TL_INC $$GSI_INC $$DB_INC $$RDB_INC $$LYM_INC -DEPENDPATH += $$TL_INC $$GSI_INC $$DB_INC $$RDB_INC $$LYM_INC -LIBS += -L$$DESTDIR -lklayout_tl -lklayout_gsi -lklayout_db -lklayout_rdb -lklayout_lym +INCLUDEPATH += $$TL_INC $$GSI_INC $$DB_INC $$RDB_INC +DEPENDPATH += $$TL_INC $$GSI_INC $$DB_INC $$RDB_INC +LIBS += -L$$DESTDIR -lklayout_tl -lklayout_gsi -lklayout_db -lklayout_rdb INCLUDEPATH += $$QTBASIC_INC DEPENDPATH += $$QTBASIC_INC diff --git a/src/pya/pya/pyaModule.cc b/src/pya/pya/pyaModule.cc index 0f962fa7e..5eff6c85d 100644 --- a/src/pya/pya/pyaModule.cc +++ b/src/pya/pya/pyaModule.cc @@ -2403,6 +2403,11 @@ public: PyTypeObject *make_class (const gsi::ClassBase *cls, bool as_static) { + // drop non-standard names + if (tl::verbosity () >= 40) { + tl::info << tl::sprintf (tl::to_string (tr ("Creating class %s.%s")), PyModule_GetName (mp_module->module ()), cls->name ()); + } + // NOTE: with as_static = true, this method produces a mixin. This is a class entirely consisting // of static constants and child classes only. It can be mixed into an existing class for emulation // additional base classes. diff --git a/src/pymod/distutils_src/klayout/lay/__init__.py b/src/pymod/distutils_src/klayout/lay/__init__.py index ee976c13d..3f8edad9e 100644 --- a/src/pymod/distutils_src/klayout/lay/__init__.py +++ b/src/pymod/distutils_src/klayout/lay/__init__.py @@ -1,12 +1,5 @@ import klayout.laycore -import klayout.antcore -import klayout.edtcore -import klayout.imgcore -import klayout.lymcore -from klayout.laycore import * -from klayout.antcore import * -from klayout.edtcore import * -from klayout.imgcore import * + from klayout.laycore import * -__all__ = klayout.laycore.__all__ + klayout.antcore.__all__ + klayout.edtcore.__all__ + klayout.imgcore.__all__ + klayout.laycore.__all__ +__all__ = klayout.laycore.__all__ diff --git a/src/pymod/lay/layMain.cc b/src/pymod/lay/layMain.cc index 1e1de16bc..0547098ca 100644 --- a/src/pymod/lay/layMain.cc +++ b/src/pymod/lay/layMain.cc @@ -31,4 +31,12 @@ # include "../../laybasic/laybasic/laybasicForceLink.h" #endif +// Force-include other dependencies +// NOTE: these libraries contribute to the "lay" module space. Hence we have to include them. +#include "../../ant/ant/antForceLink.h" +#include "../../img/img/imgForceLink.h" +#include "../../edt/edt/edtForceLink.h" +#include "../../lym/lym/lymForceLink.h" + DEFINE_PYMOD(laycore, "lay", "KLayout core module 'lay'") + From 26dbb4003ed4e6879955005eed50976dccd8a2fa Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Fri, 13 May 2022 23:20:58 +0200 Subject: [PATCH 60/88] Better error messages on missing module imports in Python modules --- src/pya/pya/pyaConvert.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/pya/pya/pyaConvert.cc b/src/pya/pya/pyaConvert.cc index e7f536bcd..09fccb5e7 100644 --- a/src/pya/pya/pyaConvert.cc +++ b/src/pya/pya/pyaConvert.cc @@ -455,7 +455,9 @@ object_to_python (void *obj, PYAObjectBase *self, const gsi::ClassBase *cls, boo // of the exposed property. Hence copying is safer. PyTypeObject *type = PythonModule::type_for_cls (clsact); - tl_assert (type != NULL); + if (!type) { + throw tl::Exception (tl::sprintf (tl::to_string (tr ("Requested type %s.%s is not bound to a Python class (did you load the '%s' module?)")), clsact->module (), clsact->name (), clsact->module ())); + } // create a instance and copy the value PyObject *new_pyobject = type->tp_alloc (type, 0); @@ -477,7 +479,9 @@ object_to_python (void *obj, PYAObjectBase *self, const gsi::ClassBase *cls, boo } else { PyTypeObject *type = PythonModule::type_for_cls (clsact); - tl_assert (type != NULL); + if (!type) { + throw tl::Exception (tl::sprintf (tl::to_string (tr ("Requested type %s.%s is not bound to a Python class (did you load the '%s' module?)")), clsact->module (), clsact->name (), clsact->module ())); + } // create a instance and copy the value PyObject *new_pyobject = type->tp_alloc (type, 0); From 684ece41d1de92e9eb1ddefb4cf51638a829fc25 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 14 May 2022 00:00:35 +0200 Subject: [PATCH 61/88] Fixed qmake-based builds after changing setup.py --- src/ant/ant/ant.pro | 2 ++ src/edt/edt/edt.pro | 2 ++ src/lym/lym/lym.pro | 2 ++ src/pymod/lay/lay.pro | 12 ++++++++++-- src/pymod/pymod.pro | 4 ---- src/pymod/unit_tests/pymod_tests.cc | 10 +++++----- 6 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/ant/ant/ant.pro b/src/ant/ant/ant.pro index 079b34e75..7a5a1705c 100644 --- a/src/ant/ant/ant.pro +++ b/src/ant/ant/ant.pro @@ -30,6 +30,7 @@ SOURCES = \ # Enabled without Qt: HEADERS += \ + antForceLink.h \ antConfig.h \ antObject.h \ antPlugin.h \ @@ -39,6 +40,7 @@ HEADERS += \ antCommon.h SOURCES += \ + antForceLink.cc \ antConfig.cc \ antObject.cc \ antPlugin.cc \ diff --git a/src/edt/edt/edt.pro b/src/edt/edt/edt.pro index 5e4b7a3fe..087503794 100644 --- a/src/edt/edt/edt.pro +++ b/src/edt/edt/edt.pro @@ -54,6 +54,7 @@ SOURCES = \ # Enabled without Qt: HEADERS += \ + edtForceLink.h \ edtConfig.h \ edtMainService.h \ edtPartialService.h \ @@ -65,6 +66,7 @@ HEADERS += \ edtDistribute.h \ SOURCES += \ + edtForceLink.cc \ edtConfig.cc \ edtMainService.cc \ edtPartialService.cc \ diff --git a/src/lym/lym/lym.pro b/src/lym/lym/lym.pro index 9a87d4c8b..0284fb201 100644 --- a/src/lym/lym/lym.pro +++ b/src/lym/lym/lym.pro @@ -8,12 +8,14 @@ DEFINES += MAKE_LYM_LIBRARY SOURCES = \ gsiDeclLymMacro.cc \ + lymForceLink.cc \ lymMacroInterpreter.cc \ lymMacroCollection.cc \ lymMacro.cc \ HEADERS = \ lymCommon.h \ + lymForceLink.h \ lymInclude.h \ lymMacroInterpreter.h \ lymMacroCollection.h \ diff --git a/src/pymod/lay/lay.pro b/src/pymod/lay/lay.pro index 5555294e0..789393308 100644 --- a/src/pymod/lay/lay.pro +++ b/src/pymod/lay/lay.pro @@ -1,5 +1,6 @@ -TARGET = lay +TARGET = laycore +REALMODULE = lay include($$PWD/../pymod.pri) @@ -8,5 +9,12 @@ SOURCES = \ HEADERS += \ -LIBS += -lklayout_lay +equals(HAVE_QT, "0") { + LIBS += -lklayout_laybasic +} else { + LIBS += -lklayout_lay +} + +# hard linked as they contribute GSI classes to "lay" module: +LIBS += -lklayout_img -lklayout_edt -lklayout_ant -lklayout_lym diff --git a/src/pymod/pymod.pro b/src/pymod/pymod.pro index 5b2debe92..b8f7744ea 100644 --- a/src/pymod/pymod.pro +++ b/src/pymod/pymod.pro @@ -8,10 +8,6 @@ SUBDIRS = \ rdb \ lib \ lay \ - lym \ - ant \ - edt \ - img \ !equals(HAVE_QT, "0") { diff --git a/src/pymod/unit_tests/pymod_tests.cc b/src/pymod/unit_tests/pymod_tests.cc index 441bcae6d..8f4b352f9 100644 --- a/src/pymod/unit_tests/pymod_tests.cc +++ b/src/pymod/unit_tests/pymod_tests.cc @@ -89,8 +89,12 @@ PYMODTEST (import_db, "import_db.py") PYMODTEST (import_rdb, "import_rdb.py") #if defined(HAVE_QT) && defined(HAVE_QTBINDINGS) - PYMODTEST (import_lay, "import_lay.py") +#else +PYMODTEST (import_lay, "import_lay_noqt.py") +#endif + +#if defined(HAVE_QT) && defined(HAVE_QTBINDINGS) PYMODTEST (import_QtCore, "import_QtCore.py") #if QT_VERSION >= 0x60000 @@ -146,8 +150,4 @@ PYMODTEST (import_QtCore5Compat, "import_QtCore5Compat.py") PYMODTEST (import_pya, "pya_tests.py") -#elif defined(HAVE_QT) - -PYMODTEST (import_lay, "import_lay_noqt.py") - #endif From 585aa4667f3aa8c025c1687b55556cd4abb7e02c Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sat, 14 May 2022 01:48:59 +0200 Subject: [PATCH 62/88] Fixed non-Qt-binding case --- src/ant/ant/ant.pro | 2 -- src/laybasic/laybasic/gsiDeclLayPixelBuffer.cc | 4 ++-- src/laybasic/unit_tests/layLayoutViewTests.cc | 2 +- testdata/ruby/layLayoutView.rb | 10 ++++++++++ 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/ant/ant/ant.pro b/src/ant/ant/ant.pro index 7a5a1705c..079b34e75 100644 --- a/src/ant/ant/ant.pro +++ b/src/ant/ant/ant.pro @@ -30,7 +30,6 @@ SOURCES = \ # Enabled without Qt: HEADERS += \ - antForceLink.h \ antConfig.h \ antObject.h \ antPlugin.h \ @@ -40,7 +39,6 @@ HEADERS += \ antCommon.h SOURCES += \ - antForceLink.cc \ antConfig.cc \ antObject.cc \ antPlugin.cc \ diff --git a/src/laybasic/laybasic/gsiDeclLayPixelBuffer.cc b/src/laybasic/laybasic/gsiDeclLayPixelBuffer.cc index 7019aee2c..c40fd39be 100644 --- a/src/laybasic/laybasic/gsiDeclLayPixelBuffer.cc +++ b/src/laybasic/laybasic/gsiDeclLayPixelBuffer.cc @@ -160,7 +160,7 @@ Class decl_PixelBuffer ("lay", "PixelBuffer", gsi::method ("fill", &lay::PixelBuffer::fill, gsi::arg ("color"), "@brief Fills the pixel buffer with the given pixel value\n" ) + -#if defined(HAVE_QT) +#if defined(HAVE_QT) && defined(HAVE_QTBINDINGS) gsi::method_ext ("fill", &fill_with_qcolor, gsi::arg ("color"), "@brief Fills the pixel buffer with the given QColor\n" ) + @@ -352,7 +352,7 @@ Class decl_BitmapBuffer ("lay", "BitmapBuffer", gsi::method ("fill", &lay::BitmapBuffer::fill, gsi::arg ("color"), "@brief Fills the pixel buffer with the given pixel value\n" ) + -#if defined(HAVE_QT) +#if defined(HAVE_QT) && defined(HAVE_QTBINDINGS) gsi::method_ext ("fill", &fill_with_qcolor, gsi::arg ("color"), "@brief Fills the pixel buffer with the given QColor\n" ) + diff --git a/src/laybasic/unit_tests/layLayoutViewTests.cc b/src/laybasic/unit_tests/layLayoutViewTests.cc index 5ce061274..1507d8cfd 100644 --- a/src/laybasic/unit_tests/layLayoutViewTests.cc +++ b/src/laybasic/unit_tests/layLayoutViewTests.cc @@ -260,7 +260,7 @@ TEST(13) } #endif -#if defined(HAVE_PNG) || defined(HAVE_QT) +#if defined(HAVE_PNG) && defined(HAVE_QT) TEST(21) { lay::LayoutView lv (0, false, 0); diff --git a/testdata/ruby/layLayoutView.rb b/testdata/ruby/layLayoutView.rb index 28c59f72a..456480a0d 100644 --- a/testdata/ruby/layLayoutView.rb +++ b/testdata/ruby/layLayoutView.rb @@ -425,6 +425,16 @@ class LAYLayoutView_TestClass < TestBase def test_4 + # check if PNG support is compiled in + # TODO: remove this once PNG support is available on all platforms + begin + RBA::PixelBuffer.read_png(File.join($ut_testsrc, "testdata/lay/au_lv1.png")) + rescue => ex + # PNG support missing + puts "WARNING: PNG support not compiled in - skipping test" + return + end + # standalone image generation (see C++ tests) lv = RBA::LayoutView::new lv.set_config("inst-color", "#000000") From 332daf836e4590ef1110b168bf4cd26506cdc843 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 15 May 2022 00:47:59 +0200 Subject: [PATCH 63/88] WIP: split laybasic into layui and layview to separate Qt and non-Qt part even more --- src/ant/ant/antPlugin.cc | 2 +- src/ant/ant/antPlugin.h | 2 +- src/edt/edt/edtPlugin.cc | 12 +- src/img/img/imgPlugin.cc | 2 +- src/img/img/imgPlugin.h | 2 +- src/klayout.pri | 4 +- src/klayout.pro | 15 +- src/lay/lay/layClipDialog.cc | 2 +- src/lay/lay/layFillDialog.cc | 2 +- src/lay/lay/laySearchReplacePlugin.cc | 2 +- src/laybasic/laybasic/gsiDeclLayLayers.cc | 7 +- ...outView.cc => gsiDeclLayLayoutViewBase.cc} | 606 ++++++------------ src/laybasic/laybasic/gsiDeclLayMarker.cc | 4 +- src/laybasic/laybasic/gsiDeclLayPlugin.cc | 10 +- src/laybasic/laybasic/layBookmarkList.cc | 5 - src/laybasic/laybasic/layBookmarkList.h | 4 - src/laybasic/laybasic/layCellView.cc | 2 +- src/laybasic/laybasic/layCellView.h | 2 +- src/laybasic/laybasic/layEditorServiceBase.cc | 4 +- src/laybasic/laybasic/layEditorServiceBase.h | 2 +- src/laybasic/laybasic/layFinder.cc | 14 +- src/laybasic/laybasic/layFinder.h | 20 +- src/laybasic/laybasic/layLayerProperties.cc | 11 +- src/laybasic/laybasic/layLayoutCanvas.cc | 2 +- src/laybasic/laybasic/layLayoutViewBase.cc | 48 +- src/laybasic/laybasic/layLayoutViewBase.h | 73 ++- src/laybasic/laybasic/layMarker.cc | 14 +- src/laybasic/laybasic/layMarker.h | 22 +- src/laybasic/laybasic/layMouseTracker.cc | 2 +- src/laybasic/laybasic/layMove.cc | 2 +- src/laybasic/laybasic/layObjectInstPath.cc | 1 - src/laybasic/laybasic/layParsedLayerSource.cc | 2 +- src/laybasic/laybasic/layPlugin.h | 6 +- src/laybasic/laybasic/layPluginConfigPage.h | 1 - src/laybasic/laybasic/layRedrawThread.h | 2 +- .../laybasic/layRedrawThreadWorker.cc | 6 +- src/laybasic/laybasic/layRedrawThreadWorker.h | 6 +- src/laybasic/laybasic/laySelector.cc | 2 +- src/laybasic/laybasic/laySnap.cc | 22 +- src/laybasic/laybasic/laySnap.h | 14 +- src/laybasic/laybasic/layStream.cc | 1 - src/laybasic/laybasic/layZoomBox.cc | 2 +- src/laybasic/laybasic/laybasic.pro | 438 ++++--------- src/laybasic/unit_tests/layLayerProperties.cc | 14 +- src/laybasic/unit_tests/laySnapTests.cc | 4 +- src/laybasic/unit_tests/unit_tests.pro | 9 - src/layui/layui.pro | 6 + .../layui}/AlignCellOptionsDialog.ui | 0 .../layui}/BookmarkManagementForm.ui | 0 .../layui}/BrowseInstancesConfigPage.ui | 0 .../layui}/BrowseInstancesForm.ui | 0 .../layui}/BrowseShapesConfigPage.ui | 0 .../layui}/BrowseShapesForm.ui | 0 .../laybasic => layui/layui}/BrowserDialog.ui | 0 .../laybasic => layui/layui}/BrowserPanel.ui | 0 .../layui}/CellSelectionForm.ui | 0 .../layui}/ClearLayerModeDialog.ui | 0 .../layui}/ConfigurationDialog.ui | 0 .../layui}/CopyCellModeDialog.ui | 0 .../layui}/DeleteCellModeDialog.ui | 0 .../layui}/DuplicateLayerDialog.ui | 0 .../layui}/EditLineStylesForm.ui | 0 .../layui}/EditStipplesForm.ui | 0 .../layui}/FlattenInstOptionsDialog.ui | 0 .../layui}/GridNetConfigPage.ui | 0 .../layui}/LayerMappingWidget.ui | 0 .../layui}/LayerSourceDialog.ui | 0 .../layui}/LayoutProperties.ui | 0 .../layui}/LayoutStatistics.ui | 0 .../layui}/LayoutViewConfigPage.ui | 0 .../layui}/LayoutViewConfigPage1.ui | 0 .../layui}/LayoutViewConfigPage2a.ui | 0 .../layui}/LayoutViewConfigPage2b.ui | 0 .../layui}/LayoutViewConfigPage2c.ui | 0 .../layui}/LayoutViewConfigPage2d.ui | 0 .../layui}/LayoutViewConfigPage3a.ui | 0 .../layui}/LayoutViewConfigPage3b.ui | 0 .../layui}/LayoutViewConfigPage3c.ui | 0 .../layui}/LayoutViewConfigPage3f.ui | 0 .../layui}/LayoutViewConfigPage4.ui | 0 .../layui}/LayoutViewConfigPage5.ui | 0 .../layui}/LayoutViewConfigPage6.ui | 0 .../layui}/LayoutViewConfigPage6a.ui | 0 .../layui}/LayoutViewConfigPage7.ui | 0 .../layui}/LibraryCellSelectionForm.ui | 0 .../layui}/LoadLayoutOptionsDialog.ui | 0 .../layui}/MarkerBrowserConfigPage.ui | 0 .../layui}/MarkerBrowserConfigPage2.ui | 0 .../layui}/MarkerBrowserDialog.ui | 0 .../layui}/MarkerBrowserPage.ui | 0 .../layui}/MarkerBrowserSnapshotView.ui | 0 .../layui}/MoveOptionsDialog.ui | 0 .../layui}/MoveToOptionsDialog.ui | 0 .../layui}/NetExportDialog.ui | 0 .../laybasic => layui/layui}/NetInfoDialog.ui | 0 .../layui}/NetlistBrowserConfigPage.ui | 0 .../layui}/NetlistBrowserConfigPage2.ui | 0 .../layui}/NetlistBrowserDialog.ui | 0 .../layui}/NetlistBrowserPage.ui | 0 .../layui}/NewCellPropertiesDialog.ui | 0 .../layui}/NewLayerPropertiesDialog.ui | 0 .../layui}/NewLayoutPropertiesDialog.ui | 0 .../layui}/OpenLayoutModeDialog.ui | 0 .../layui}/RenameCellDialog.ui | 0 .../layui}/ReplaceCellOptionsDialog.ui | 0 .../layui}/SaveLayoutAsOptionsDialog.ui | 0 .../layui}/SaveLayoutOptionsDialog.ui | 0 .../layui}/SelectCellViewForm.ui | 0 .../layui}/SelectLineStyleForm.ui | 0 .../layui}/SelectStippleForm.ui | 0 .../layui}/SpecificLoadLayoutOptionsDialog.ui | 0 .../laybasic => layui/layui}/TipDialog.ui | 0 .../layui}/UserPropertiesEditForm.ui | 0 .../layui}/UserPropertiesForm.ui | 0 .../layui}/gsiDeclLayDialogs.cc | 2 +- .../layui}/gsiDeclLayMenu.cc | 0 .../layui}/gsiDeclLayNetlistBrowserDialog.cc | 10 +- .../layui}/gsiDeclLayStream.cc | 0 .../layui}/images/icon_circuit_16.png | Bin .../layui}/images/icon_circuit_24.png | Bin .../layui}/images/icon_circuit_32.png | Bin .../layui}/images/icon_circuit_48.png | Bin .../layui}/images/icon_conn_16.png | Bin .../layui}/images/icon_conn_24.png | Bin .../layui}/images/icon_conn_32.png | Bin .../layui}/images/icon_conn_48.png | Bin .../layui}/images/icon_conn_light_16.png | Bin .../layui}/images/icon_conn_light_24.png | Bin .../layui}/images/icon_conn_light_32.png | Bin .../layui}/images/icon_conn_light_48.png | Bin .../layui}/images/icon_device_bjt_16.png | Bin .../layui}/images/icon_device_bjt_24.png | Bin .../layui}/images/icon_device_bjt_32.png | Bin .../layui}/images/icon_device_bjt_48.png | Bin .../layui}/images/icon_device_cap_16.png | Bin .../layui}/images/icon_device_cap_24.png | Bin .../layui}/images/icon_device_cap_32.png | Bin .../layui}/images/icon_device_cap_48.png | Bin .../layui}/images/icon_device_diode_16.png | Bin .../layui}/images/icon_device_diode_24.png | Bin .../layui}/images/icon_device_diode_32.png | Bin .../layui}/images/icon_device_diode_48.png | Bin .../layui}/images/icon_device_mos_16.png | Bin .../layui}/images/icon_device_mos_24.png | Bin .../layui}/images/icon_device_mos_32.png | Bin .../layui}/images/icon_device_mos_48.png | Bin .../layui}/images/icon_device_res_16.png | Bin .../layui}/images/icon_device_res_24.png | Bin .../layui}/images/icon_device_res_32.png | Bin .../layui}/images/icon_device_res_48.png | Bin .../layui}/images/icon_net_16.png | Bin .../layui}/images/icon_net_24.png | Bin .../layui}/images/icon_net_32.png | Bin .../layui}/images/icon_net_48.png | Bin .../layui}/images/icon_net_light_16.png | Bin .../layui}/images/icon_net_light_24.png | Bin .../layui}/images/icon_net_light_32.png | Bin .../layui}/images/icon_net_light_48.png | Bin .../layui}/images/icon_pin_16.png | Bin .../layui}/images/icon_pin_24.png | Bin .../layui}/images/icon_pin_32.png | Bin .../layui}/images/icon_pin_48.png | Bin .../laybasic => layui/layui}/images/icons.svg | 0 .../layui}/images/st_plus_node.png | Bin .../layui}/layBackgroundAwareTreeStyle.cc | 0 .../layui}/layBackgroundAwareTreeStyle.h | 4 +- .../layui}/layBookmarkManagementForm.cc | 22 +- .../layui}/layBookmarkManagementForm.h | 13 +- .../layui}/layBookmarksView.cc | 4 +- .../layui}/layBookmarksView.h | 8 +- .../layui}/layBrowseInstancesForm.cc | 6 +- .../layui}/layBrowseInstancesForm.h | 4 +- .../layui}/layBrowseShapesForm.cc | 4 +- .../layui}/layBrowseShapesForm.h | 4 +- .../laybasic => layui/layui}/layBrowser.cc | 6 +- .../laybasic => layui/layui}/layBrowser.h | 14 +- .../layui}/layBrowserDialog.cc | 0 .../layui}/layBrowserDialog.h | 2 +- .../layui}/layBrowserPanel.cc | 0 .../layui}/layBrowserPanel.h | 12 +- .../laybasic => layui/layui}/layBusy.cc | 0 .../laybasic => layui/layui}/layBusy.h | 6 +- .../layui}/layCellSelectionForm.cc | 4 +- .../layui}/layCellSelectionForm.h | 8 +- .../layui}/layCellTreeModel.cc | 8 +- .../layui}/layCellTreeModel.h | 10 +- .../layui}/layConfigurationDialog.cc | 0 .../layui}/layConfigurationDialog.h | 2 +- .../laybasic => layui/layui}/layDialogs.cc | 7 +- .../laybasic => layui/layui}/layDialogs.h | 46 +- .../layui}/layEditLineStyleWidget.cc | 0 .../layui}/layEditLineStyleWidget.h | 0 .../layui}/layEditLineStylesForm.cc | 6 +- .../layui}/layEditLineStylesForm.h | 6 +- .../layui}/layEditStippleWidget.cc | 0 .../layui}/layEditStippleWidget.h | 0 .../layui}/layEditStipplesForm.cc | 6 +- .../layui}/layEditStipplesForm.h | 6 +- .../layui}/layEditorOptionsFrame.cc | 4 +- .../layui}/layEditorOptionsFrame.h | 8 +- .../layui}/layEditorOptionsPage.cc | 4 +- .../layui}/layEditorOptionsPage.h | 12 +- .../layui}/layEditorOptionsPages.cc | 2 +- .../layui}/layEditorOptionsPages.h | 4 +- .../laybasic => layui/layui}/layFileDialog.cc | 0 .../laybasic => layui/layui}/layFileDialog.h | 4 +- .../layui}/layGenericSyntaxHighlighter.cc | 0 .../layui}/layGenericSyntaxHighlighter.h | 22 +- .../laybasic => layui/layui}/layGridNet.cc | 7 +- .../laybasic => layui/layui}/layGridNet.h | 8 +- .../layui}/layGridNetConfigPage.cc | 0 .../layui}/layGridNetConfigPage.h | 0 .../layui}/layHierarchyControlPanel.cc | 4 +- .../layui}/layHierarchyControlPanel.h | 8 +- .../layui}/layIndexedNetlistModel.cc | 0 .../layui}/layIndexedNetlistModel.h | 6 +- .../layui}/layItemDelegates.cc | 0 .../layui}/layItemDelegates.h | 4 +- .../layui}/layLayerControlPanel.cc | 6 +- .../layui}/layLayerControlPanel.h | 6 +- .../layui}/layLayerMappingWidget.cc | 0 .../layui}/layLayerMappingWidget.h | 4 +- .../layui}/layLayerToolbox.cc | 4 +- .../layui}/layLayerToolbox.h | 17 +- .../layui}/layLayerTreeModel.cc | 10 +- .../layui}/layLayerTreeModel.h | 13 +- .../layui}/layLayoutPropertiesForm.cc | 4 +- .../layui}/layLayoutPropertiesForm.h | 15 +- .../layui}/layLayoutStatistics.qrc | 0 .../layui}/layLayoutStatisticsForm.cc | 4 +- .../layui}/layLayoutStatisticsForm.h | 4 +- .../layui}/layLayoutViewConfigPages.cc | 0 .../layui}/layLayoutViewConfigPages.h | 0 .../layui}/layLayoutViewFunctions.cc | 156 ++--- .../layui}/layLayoutViewFunctions.h | 12 +- .../layui}/layLibrariesView.cc | 4 +- .../layui}/layLibrariesView.h | 8 +- .../layui}/layLoadLayoutOptionsDialog.cc | 2 +- .../layui}/layLoadLayoutOptionsDialog.h | 6 +- .../layui}/layNetExportDialog.cc | 0 .../layui}/layNetExportDialog.h | 0 .../layui}/layNetInfoDialog.cc | 0 .../layui}/layNetInfoDialog.h | 0 .../layui}/layNetlistBrowser.cc | 85 +-- .../layui}/layNetlistBrowser.h | 18 +- .../layui}/layNetlistBrowserDialog.cc | 144 +++-- .../layui}/layNetlistBrowserDialog.h | 20 +- .../layui}/layNetlistBrowserModel.cc | 0 .../layui}/layNetlistBrowserModel.h | 10 +- .../layui}/layNetlistBrowserPage.cc | 6 +- .../layui}/layNetlistBrowserPage.h | 8 +- .../layui}/layNetlistBrowserTreeModel.cc | 0 .../layui}/layNetlistBrowserTreeModel.h | 6 +- .../layui}/layNetlistCrossReferenceModel.cc | 0 .../layui}/layNetlistCrossReferenceModel.h | 4 +- .../laybasic => layui/layui}/layQtTools.cc | 0 .../laybasic => layui/layui}/layQtTools.h | 20 +- .../layui}/laySaveLayoutOptionsDialog.cc | 4 +- .../layui}/laySaveLayoutOptionsDialog.h | 9 +- .../layui}/laySelectCellViewForm.cc | 4 +- .../layui}/laySelectCellViewForm.h | 8 +- .../layui}/laySelectLineStyleForm.cc | 0 .../layui}/laySelectLineStyleForm.h | 0 .../layui}/laySelectStippleForm.cc | 0 .../layui}/laySelectStippleForm.h | 0 .../laybasic => layui/layui}/layTechnology.cc | 0 .../laybasic => layui/layui}/layTechnology.h | 6 +- .../laybasic => layui/layui}/layTipDialog.cc | 0 .../laybasic => layui/layui}/layTipDialog.h | 4 +- .../laybasic => layui/layui}/layWidgets.cc | 14 +- .../laybasic => layui/layui}/layWidgets.h | 30 +- .../layui}/laybasicResources.qrc | 0 src/layui/layui/layui.pro | 218 +++++++ src/layui/layui/layuiCommon.h | 51 ++ .../laybasic => layui/layui}/rdbInfoWidget.cc | 0 .../laybasic => layui/layui}/rdbInfoWidget.h | 0 .../layui}/rdbMarkerBrowser.cc | 2 +- .../layui}/rdbMarkerBrowser.h | 0 .../layui}/rdbMarkerBrowserDialog.cc | 114 ++-- .../layui}/rdbMarkerBrowserDialog.h | 13 +- .../layui}/rdbMarkerBrowserPage.cc | 4 +- .../layui}/rdbMarkerBrowserPage.h | 6 +- .../layui}/syntax/d25_text.xml | 0 .../layui}/syntax/ur_text.xml | 0 .../laybasic => layui/layui}/tree.stxml | 0 .../unit_tests/layNetlistBrowserModelTests.cc | 0 .../layNetlistBrowserTreeModelTests.cc | 0 src/layui/unit_tests/unit_tests.pro | 26 + src/layview/layview.pro | 6 + .../layview/gsiDeclLayLayoutView_noqt.cc | 84 +++ .../layview/gsiDeclLayLayoutView_qt.cc | 223 +++++++ src/layview/layview/layLayoutView.h | 33 + src/layview/layview/layLayoutView_noqt.cc | 60 ++ src/layview/layview/layLayoutView_noqt.h | 80 +++ .../layview/layLayoutView_qt.cc} | 61 +- .../layview/layLayoutView_qt.h} | 116 +--- src/layview/layview/layview.pro | 55 ++ src/layview/layview/layviewCommon.h | 51 ++ .../unit_tests/layLayoutViewTests.cc | 0 src/layview/unit_tests/unit_tests.pro | 16 + .../lay_plugin/layBooleanOperationsPlugin.cc | 2 +- .../tools/diff/lay_plugin/layDiffPlugin.cc | 2 +- .../lay_plugin/layNetTracerPlugin.cc | 2 +- .../tools/view_25d/lay_plugin/layD25Plugin.cc | 2 +- .../tools/xor/lay_plugin/layXORPlugin.cc | 2 +- 305 files changed, 2079 insertions(+), 1587 deletions(-) rename src/laybasic/laybasic/{gsiDeclLayLayoutView.cc => gsiDeclLayLayoutViewBase.cc} (78%) create mode 100644 src/layui/layui.pro rename src/{laybasic/laybasic => layui/layui}/AlignCellOptionsDialog.ui (100%) rename src/{laybasic/laybasic => layui/layui}/BookmarkManagementForm.ui (100%) rename src/{laybasic/laybasic => layui/layui}/BrowseInstancesConfigPage.ui (100%) rename src/{laybasic/laybasic => layui/layui}/BrowseInstancesForm.ui (100%) rename src/{laybasic/laybasic => layui/layui}/BrowseShapesConfigPage.ui (100%) rename src/{laybasic/laybasic => layui/layui}/BrowseShapesForm.ui (100%) rename src/{laybasic/laybasic => layui/layui}/BrowserDialog.ui (100%) rename src/{laybasic/laybasic => layui/layui}/BrowserPanel.ui (100%) rename src/{laybasic/laybasic => layui/layui}/CellSelectionForm.ui (100%) rename src/{laybasic/laybasic => layui/layui}/ClearLayerModeDialog.ui (100%) rename src/{laybasic/laybasic => layui/layui}/ConfigurationDialog.ui (100%) rename src/{laybasic/laybasic => layui/layui}/CopyCellModeDialog.ui (100%) rename src/{laybasic/laybasic => layui/layui}/DeleteCellModeDialog.ui (100%) rename src/{laybasic/laybasic => layui/layui}/DuplicateLayerDialog.ui (100%) rename src/{laybasic/laybasic => layui/layui}/EditLineStylesForm.ui (100%) rename src/{laybasic/laybasic => layui/layui}/EditStipplesForm.ui (100%) rename src/{laybasic/laybasic => layui/layui}/FlattenInstOptionsDialog.ui (100%) rename src/{laybasic/laybasic => layui/layui}/GridNetConfigPage.ui (100%) rename src/{laybasic/laybasic => layui/layui}/LayerMappingWidget.ui (100%) rename src/{laybasic/laybasic => layui/layui}/LayerSourceDialog.ui (100%) rename src/{laybasic/laybasic => layui/layui}/LayoutProperties.ui (100%) rename src/{laybasic/laybasic => layui/layui}/LayoutStatistics.ui (100%) rename src/{laybasic/laybasic => layui/layui}/LayoutViewConfigPage.ui (100%) rename src/{laybasic/laybasic => layui/layui}/LayoutViewConfigPage1.ui (100%) rename src/{laybasic/laybasic => layui/layui}/LayoutViewConfigPage2a.ui (100%) rename src/{laybasic/laybasic => layui/layui}/LayoutViewConfigPage2b.ui (100%) rename src/{laybasic/laybasic => layui/layui}/LayoutViewConfigPage2c.ui (100%) rename src/{laybasic/laybasic => layui/layui}/LayoutViewConfigPage2d.ui (100%) rename src/{laybasic/laybasic => layui/layui}/LayoutViewConfigPage3a.ui (100%) rename src/{laybasic/laybasic => layui/layui}/LayoutViewConfigPage3b.ui (100%) rename src/{laybasic/laybasic => layui/layui}/LayoutViewConfigPage3c.ui (100%) rename src/{laybasic/laybasic => layui/layui}/LayoutViewConfigPage3f.ui (100%) rename src/{laybasic/laybasic => layui/layui}/LayoutViewConfigPage4.ui (100%) rename src/{laybasic/laybasic => layui/layui}/LayoutViewConfigPage5.ui (100%) rename src/{laybasic/laybasic => layui/layui}/LayoutViewConfigPage6.ui (100%) rename src/{laybasic/laybasic => layui/layui}/LayoutViewConfigPage6a.ui (100%) rename src/{laybasic/laybasic => layui/layui}/LayoutViewConfigPage7.ui (100%) rename src/{laybasic/laybasic => layui/layui}/LibraryCellSelectionForm.ui (100%) rename src/{laybasic/laybasic => layui/layui}/LoadLayoutOptionsDialog.ui (100%) rename src/{laybasic/laybasic => layui/layui}/MarkerBrowserConfigPage.ui (100%) rename src/{laybasic/laybasic => layui/layui}/MarkerBrowserConfigPage2.ui (100%) rename src/{laybasic/laybasic => layui/layui}/MarkerBrowserDialog.ui (100%) rename src/{laybasic/laybasic => layui/layui}/MarkerBrowserPage.ui (100%) rename src/{laybasic/laybasic => layui/layui}/MarkerBrowserSnapshotView.ui (100%) rename src/{laybasic/laybasic => layui/layui}/MoveOptionsDialog.ui (100%) rename src/{laybasic/laybasic => layui/layui}/MoveToOptionsDialog.ui (100%) rename src/{laybasic/laybasic => layui/layui}/NetExportDialog.ui (100%) rename src/{laybasic/laybasic => layui/layui}/NetInfoDialog.ui (100%) rename src/{laybasic/laybasic => layui/layui}/NetlistBrowserConfigPage.ui (100%) rename src/{laybasic/laybasic => layui/layui}/NetlistBrowserConfigPage2.ui (100%) rename src/{laybasic/laybasic => layui/layui}/NetlistBrowserDialog.ui (100%) rename src/{laybasic/laybasic => layui/layui}/NetlistBrowserPage.ui (100%) rename src/{laybasic/laybasic => layui/layui}/NewCellPropertiesDialog.ui (100%) rename src/{laybasic/laybasic => layui/layui}/NewLayerPropertiesDialog.ui (100%) rename src/{laybasic/laybasic => layui/layui}/NewLayoutPropertiesDialog.ui (100%) rename src/{laybasic/laybasic => layui/layui}/OpenLayoutModeDialog.ui (100%) rename src/{laybasic/laybasic => layui/layui}/RenameCellDialog.ui (100%) rename src/{laybasic/laybasic => layui/layui}/ReplaceCellOptionsDialog.ui (100%) rename src/{laybasic/laybasic => layui/layui}/SaveLayoutAsOptionsDialog.ui (100%) rename src/{laybasic/laybasic => layui/layui}/SaveLayoutOptionsDialog.ui (100%) rename src/{laybasic/laybasic => layui/layui}/SelectCellViewForm.ui (100%) rename src/{laybasic/laybasic => layui/layui}/SelectLineStyleForm.ui (100%) rename src/{laybasic/laybasic => layui/layui}/SelectStippleForm.ui (100%) rename src/{laybasic/laybasic => layui/layui}/SpecificLoadLayoutOptionsDialog.ui (100%) rename src/{laybasic/laybasic => layui/layui}/TipDialog.ui (100%) rename src/{laybasic/laybasic => layui/layui}/UserPropertiesEditForm.ui (100%) rename src/{laybasic/laybasic => layui/layui}/UserPropertiesForm.ui (100%) rename src/{laybasic/laybasic => layui/layui}/gsiDeclLayDialogs.cc (99%) rename src/{laybasic/laybasic => layui/layui}/gsiDeclLayMenu.cc (100%) rename src/{laybasic/laybasic => layui/layui}/gsiDeclLayNetlistBrowserDialog.cc (97%) rename src/{laybasic/laybasic => layui/layui}/gsiDeclLayStream.cc (100%) rename src/{laybasic/laybasic => layui/layui}/images/icon_circuit_16.png (100%) rename src/{laybasic/laybasic => layui/layui}/images/icon_circuit_24.png (100%) rename src/{laybasic/laybasic => layui/layui}/images/icon_circuit_32.png (100%) rename src/{laybasic/laybasic => layui/layui}/images/icon_circuit_48.png (100%) rename src/{laybasic/laybasic => layui/layui}/images/icon_conn_16.png (100%) rename src/{laybasic/laybasic => layui/layui}/images/icon_conn_24.png (100%) rename src/{laybasic/laybasic => layui/layui}/images/icon_conn_32.png (100%) rename src/{laybasic/laybasic => layui/layui}/images/icon_conn_48.png (100%) rename src/{laybasic/laybasic => layui/layui}/images/icon_conn_light_16.png (100%) rename src/{laybasic/laybasic => layui/layui}/images/icon_conn_light_24.png (100%) rename src/{laybasic/laybasic => layui/layui}/images/icon_conn_light_32.png (100%) rename src/{laybasic/laybasic => layui/layui}/images/icon_conn_light_48.png (100%) rename src/{laybasic/laybasic => layui/layui}/images/icon_device_bjt_16.png (100%) rename src/{laybasic/laybasic => layui/layui}/images/icon_device_bjt_24.png (100%) rename src/{laybasic/laybasic => layui/layui}/images/icon_device_bjt_32.png (100%) rename src/{laybasic/laybasic => layui/layui}/images/icon_device_bjt_48.png (100%) rename src/{laybasic/laybasic => layui/layui}/images/icon_device_cap_16.png (100%) rename src/{laybasic/laybasic => layui/layui}/images/icon_device_cap_24.png (100%) rename src/{laybasic/laybasic => layui/layui}/images/icon_device_cap_32.png (100%) rename src/{laybasic/laybasic => layui/layui}/images/icon_device_cap_48.png (100%) rename src/{laybasic/laybasic => layui/layui}/images/icon_device_diode_16.png (100%) rename src/{laybasic/laybasic => layui/layui}/images/icon_device_diode_24.png (100%) rename src/{laybasic/laybasic => layui/layui}/images/icon_device_diode_32.png (100%) rename src/{laybasic/laybasic => layui/layui}/images/icon_device_diode_48.png (100%) rename src/{laybasic/laybasic => layui/layui}/images/icon_device_mos_16.png (100%) rename src/{laybasic/laybasic => layui/layui}/images/icon_device_mos_24.png (100%) rename src/{laybasic/laybasic => layui/layui}/images/icon_device_mos_32.png (100%) rename src/{laybasic/laybasic => layui/layui}/images/icon_device_mos_48.png (100%) rename src/{laybasic/laybasic => layui/layui}/images/icon_device_res_16.png (100%) rename src/{laybasic/laybasic => layui/layui}/images/icon_device_res_24.png (100%) rename src/{laybasic/laybasic => layui/layui}/images/icon_device_res_32.png (100%) rename src/{laybasic/laybasic => layui/layui}/images/icon_device_res_48.png (100%) rename src/{laybasic/laybasic => layui/layui}/images/icon_net_16.png (100%) rename src/{laybasic/laybasic => layui/layui}/images/icon_net_24.png (100%) rename src/{laybasic/laybasic => layui/layui}/images/icon_net_32.png (100%) rename src/{laybasic/laybasic => layui/layui}/images/icon_net_48.png (100%) rename src/{laybasic/laybasic => layui/layui}/images/icon_net_light_16.png (100%) rename src/{laybasic/laybasic => layui/layui}/images/icon_net_light_24.png (100%) rename src/{laybasic/laybasic => layui/layui}/images/icon_net_light_32.png (100%) rename src/{laybasic/laybasic => layui/layui}/images/icon_net_light_48.png (100%) rename src/{laybasic/laybasic => layui/layui}/images/icon_pin_16.png (100%) rename src/{laybasic/laybasic => layui/layui}/images/icon_pin_24.png (100%) rename src/{laybasic/laybasic => layui/layui}/images/icon_pin_32.png (100%) rename src/{laybasic/laybasic => layui/layui}/images/icon_pin_48.png (100%) rename src/{laybasic/laybasic => layui/layui}/images/icons.svg (100%) rename src/{laybasic/laybasic => layui/layui}/images/st_plus_node.png (100%) rename src/{laybasic/laybasic => layui/layui}/layBackgroundAwareTreeStyle.cc (100%) rename src/{laybasic/laybasic => layui/layui}/layBackgroundAwareTreeStyle.h (95%) rename src/{laybasic/laybasic => layui/layui}/layBookmarkManagementForm.cc (80%) rename src/{laybasic/laybasic => layui/layui}/layBookmarkManagementForm.h (88%) rename src/{laybasic/laybasic => layui/layui}/layBookmarksView.cc (98%) rename src/{laybasic/laybasic => layui/layui}/layBookmarksView.h (90%) rename src/{laybasic/laybasic => layui/layui}/layBrowseInstancesForm.cc (99%) rename src/{laybasic/laybasic => layui/layui}/layBrowseInstancesForm.h (97%) rename src/{laybasic/laybasic => layui/layui}/layBrowseShapesForm.cc (99%) rename src/{laybasic/laybasic => layui/layui}/layBrowseShapesForm.h (97%) rename src/{laybasic/laybasic => layui/layui}/layBrowser.cc (88%) rename src/{laybasic/laybasic => layui/layui}/layBrowser.h (87%) rename src/{laybasic/laybasic => layui/layui}/layBrowserDialog.cc (100%) rename src/{laybasic/laybasic => layui/layui}/layBrowserDialog.h (98%) rename src/{laybasic/laybasic => layui/layui}/layBrowserPanel.cc (100%) rename src/{laybasic/laybasic => layui/layui}/layBrowserPanel.h (97%) rename src/{laybasic/laybasic => layui/layui}/layBusy.cc (100%) rename src/{laybasic/laybasic => layui/layui}/layBusy.h (93%) rename src/{laybasic/laybasic => layui/layui}/layCellSelectionForm.cc (99%) rename src/{laybasic/laybasic => layui/layui}/layCellSelectionForm.h (95%) rename src/{laybasic/laybasic => layui/layui}/layCellTreeModel.cc (98%) rename src/{laybasic/laybasic => layui/layui}/layCellTreeModel.h (95%) rename src/{laybasic/laybasic => layui/layui}/layConfigurationDialog.cc (100%) rename src/{laybasic/laybasic => layui/layui}/layConfigurationDialog.h (97%) rename src/{laybasic/laybasic => layui/layui}/layDialogs.cc (99%) rename src/{laybasic/laybasic => layui/layui}/layDialogs.h (88%) rename src/{laybasic/laybasic => layui/layui}/layEditLineStyleWidget.cc (100%) rename src/{laybasic/laybasic => layui/layui}/layEditLineStyleWidget.h (100%) rename src/{laybasic/laybasic => layui/layui}/layEditLineStylesForm.cc (98%) rename src/{laybasic/laybasic => layui/layui}/layEditLineStylesForm.h (94%) rename src/{laybasic/laybasic => layui/layui}/layEditStippleWidget.cc (100%) rename src/{laybasic/laybasic => layui/layui}/layEditStippleWidget.h (100%) rename src/{laybasic/laybasic => layui/layui}/layEditStipplesForm.cc (99%) rename src/{laybasic/laybasic => layui/layui}/layEditStipplesForm.h (94%) rename src/{laybasic/laybasic => layui/layui}/layEditorOptionsFrame.cc (96%) rename src/{laybasic/laybasic => layui/layui}/layEditorOptionsFrame.h (90%) rename src/{laybasic/laybasic => layui/layui}/layEditorOptionsPage.cc (94%) rename src/{laybasic/laybasic => layui/layui}/layEditorOptionsPage.h (90%) rename src/{laybasic/laybasic => layui/layui}/layEditorOptionsPages.cc (99%) rename src/{laybasic/laybasic => layui/layui}/layEditorOptionsPages.h (96%) rename src/{laybasic/laybasic => layui/layui}/layFileDialog.cc (100%) rename src/{laybasic/laybasic => layui/layui}/layFileDialog.h (97%) rename src/{laybasic/laybasic => layui/layui}/layGenericSyntaxHighlighter.cc (100%) rename src/{laybasic/laybasic => layui/layui}/layGenericSyntaxHighlighter.h (96%) rename src/{laybasic/laybasic => layui/layui}/layGridNet.cc (99%) rename src/{laybasic/laybasic => layui/layui}/layGridNet.h (94%) rename src/{laybasic/laybasic => layui/layui}/layGridNetConfigPage.cc (100%) rename src/{laybasic/laybasic => layui/layui}/layGridNetConfigPage.h (100%) rename src/{laybasic/laybasic => layui/layui}/layHierarchyControlPanel.cc (99%) rename src/{laybasic/laybasic => layui/layui}/layHierarchyControlPanel.h (97%) rename src/{laybasic/laybasic => layui/layui}/layIndexedNetlistModel.cc (100%) rename src/{laybasic/laybasic => layui/layui}/layIndexedNetlistModel.h (98%) rename src/{laybasic/laybasic => layui/layui}/layItemDelegates.cc (100%) rename src/{laybasic/laybasic => layui/layui}/layItemDelegates.h (97%) rename src/{laybasic/laybasic => layui/layui}/layLayerControlPanel.cc (99%) rename src/{laybasic/laybasic => layui/layui}/layLayerControlPanel.h (98%) rename src/{laybasic/laybasic => layui/layui}/layLayerMappingWidget.cc (100%) rename src/{laybasic/laybasic => layui/layui}/layLayerMappingWidget.h (96%) rename src/{laybasic/laybasic => layui/layui}/layLayerToolbox.cc (99%) rename src/{laybasic/laybasic => layui/layui}/layLayerToolbox.h (96%) rename src/{laybasic/laybasic => layui/layui}/layLayerTreeModel.cc (99%) rename src/{laybasic/laybasic => layui/layui}/layLayerTreeModel.h (95%) rename src/{laybasic/laybasic => layui/layui}/layLayoutPropertiesForm.cc (98%) rename src/{laybasic/laybasic => layui/layui}/layLayoutPropertiesForm.h (86%) rename src/{laybasic/laybasic => layui/layui}/layLayoutStatistics.qrc (100%) rename src/{laybasic/laybasic => layui/layui}/layLayoutStatisticsForm.cc (99%) rename src/{laybasic/laybasic => layui/layui}/layLayoutStatisticsForm.h (92%) rename src/{laybasic/laybasic => layui/layui}/layLayoutViewConfigPages.cc (100%) rename src/{laybasic/laybasic => layui/layui}/layLayoutViewConfigPages.h (100%) rename src/{laybasic/laybasic => layui/layui}/layLayoutViewFunctions.cc (94%) rename src/{laybasic/laybasic => layui/layui}/layLayoutViewFunctions.h (94%) rename src/{laybasic/laybasic => layui/layui}/layLibrariesView.cc (99%) rename src/{laybasic/laybasic => layui/layui}/layLibrariesView.h (97%) rename src/{laybasic/laybasic => layui/layui}/layLoadLayoutOptionsDialog.cc (99%) rename src/{laybasic/laybasic => layui/layui}/layLoadLayoutOptionsDialog.h (95%) rename src/{laybasic/laybasic => layui/layui}/layNetExportDialog.cc (100%) rename src/{laybasic/laybasic => layui/layui}/layNetExportDialog.h (100%) rename src/{laybasic/laybasic => layui/layui}/layNetInfoDialog.cc (100%) rename src/{laybasic/laybasic => layui/layui}/layNetInfoDialog.h (100%) rename src/{laybasic/laybasic => layui/layui}/layNetlistBrowser.cc (81%) rename src/{laybasic/laybasic => layui/layui}/layNetlistBrowser.h (89%) rename src/{laybasic/laybasic => layui/layui}/layNetlistBrowserDialog.cc (82%) rename src/{laybasic/laybasic => layui/layui}/layNetlistBrowserDialog.h (93%) rename src/{laybasic/laybasic => layui/layui}/layNetlistBrowserModel.cc (100%) rename src/{laybasic/laybasic => layui/layui}/layNetlistBrowserModel.h (98%) rename src/{laybasic/laybasic => layui/layui}/layNetlistBrowserPage.cc (99%) rename src/{laybasic/laybasic => layui/layui}/layNetlistBrowserPage.h (98%) rename src/{laybasic/laybasic => layui/layui}/layNetlistBrowserTreeModel.cc (100%) rename src/{laybasic/laybasic => layui/layui}/layNetlistBrowserTreeModel.h (97%) rename src/{laybasic/laybasic => layui/layui}/layNetlistCrossReferenceModel.cc (100%) rename src/{laybasic/laybasic => layui/layui}/layNetlistCrossReferenceModel.h (98%) rename src/{laybasic/laybasic => layui/layui}/layQtTools.cc (100%) rename src/{laybasic/laybasic => layui/layui}/layQtTools.h (76%) rename src/{laybasic/laybasic => layui/layui}/laySaveLayoutOptionsDialog.cc (98%) rename src/{laybasic/laybasic => layui/layui}/laySaveLayoutOptionsDialog.h (88%) rename src/{laybasic/laybasic => layui/layui}/laySelectCellViewForm.cc (97%) rename src/{laybasic/laybasic => layui/layui}/laySelectCellViewForm.h (90%) rename src/{laybasic/laybasic => layui/layui}/laySelectLineStyleForm.cc (100%) rename src/{laybasic/laybasic => layui/layui}/laySelectLineStyleForm.h (100%) rename src/{laybasic/laybasic => layui/layui}/laySelectStippleForm.cc (100%) rename src/{laybasic/laybasic => layui/layui}/laySelectStippleForm.h (100%) rename src/{laybasic/laybasic => layui/layui}/layTechnology.cc (100%) rename src/{laybasic/laybasic => layui/layui}/layTechnology.h (95%) rename src/{laybasic/laybasic => layui/layui}/layTipDialog.cc (100%) rename src/{laybasic/laybasic => layui/layui}/layTipDialog.h (98%) rename src/{laybasic/laybasic => layui/layui}/layWidgets.cc (99%) rename src/{laybasic/laybasic => layui/layui}/layWidgets.h (94%) rename src/{laybasic/laybasic => layui/layui}/laybasicResources.qrc (100%) create mode 100644 src/layui/layui/layui.pro create mode 100644 src/layui/layui/layuiCommon.h rename src/{laybasic/laybasic => layui/layui}/rdbInfoWidget.cc (100%) rename src/{laybasic/laybasic => layui/layui}/rdbInfoWidget.h (100%) rename src/{laybasic/laybasic => layui/layui}/rdbMarkerBrowser.cc (99%) rename src/{laybasic/laybasic => layui/layui}/rdbMarkerBrowser.h (100%) rename src/{laybasic/laybasic => layui/layui}/rdbMarkerBrowserDialog.cc (88%) rename src/{laybasic/laybasic => layui/layui}/rdbMarkerBrowserDialog.h (92%) rename src/{laybasic/laybasic => layui/layui}/rdbMarkerBrowserPage.cc (99%) rename src/{laybasic/laybasic => layui/layui}/rdbMarkerBrowserPage.h (98%) rename src/{laybasic/laybasic => layui/layui}/syntax/d25_text.xml (100%) rename src/{laybasic/laybasic => layui/layui}/syntax/ur_text.xml (100%) rename src/{laybasic/laybasic => layui/layui}/tree.stxml (100%) rename src/{laybasic => layui}/unit_tests/layNetlistBrowserModelTests.cc (100%) rename src/{laybasic => layui}/unit_tests/layNetlistBrowserTreeModelTests.cc (100%) create mode 100644 src/layui/unit_tests/unit_tests.pro create mode 100644 src/layview/layview.pro create mode 100644 src/layview/layview/gsiDeclLayLayoutView_noqt.cc create mode 100644 src/layview/layview/gsiDeclLayLayoutView_qt.cc create mode 100644 src/layview/layview/layLayoutView.h create mode 100644 src/layview/layview/layLayoutView_noqt.cc create mode 100644 src/layview/layview/layLayoutView_noqt.h rename src/{laybasic/laybasic/layLayoutView.cc => layview/layview/layLayoutView_qt.cc} (95%) rename src/{laybasic/laybasic/layLayoutView.h => layview/layview/layLayoutView_qt.h} (89%) create mode 100644 src/layview/layview/layview.pro create mode 100644 src/layview/layview/layviewCommon.h rename src/{laybasic => layview}/unit_tests/layLayoutViewTests.cc (100%) create mode 100644 src/layview/unit_tests/unit_tests.pro diff --git a/src/ant/ant/antPlugin.cc b/src/ant/ant/antPlugin.cc index 1aecb0792..4ad479762 100644 --- a/src/ant/ant/antPlugin.cc +++ b/src/ant/ant/antPlugin.cc @@ -100,7 +100,7 @@ PluginDeclaration::get_menu_entries (std::vector &menu_entries) } lay::Plugin * -PluginDeclaration::create_plugin (db::Manager *manager, lay::Dispatcher *, lay::LayoutView *view) const +PluginDeclaration::create_plugin (db::Manager *manager, lay::Dispatcher *, lay::LayoutViewBase *view) const { return new ant::Service (manager, view); } diff --git a/src/ant/ant/antPlugin.h b/src/ant/ant/antPlugin.h index 9e7e5e943..0b8b4ac05 100644 --- a/src/ant/ant/antPlugin.h +++ b/src/ant/ant/antPlugin.h @@ -42,7 +42,7 @@ public: virtual void get_options (std::vector < std::pair > &options) const; virtual void get_menu_entries (std::vector &menu_entries) const; - virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *, lay::LayoutView *view) const; + virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *, lay::LayoutViewBase *view) const; virtual bool implements_editable (std::string &title) const; virtual bool implements_mouse_mode (std::string &title) const; virtual bool configure (const std::string &name, const std::string &value); diff --git a/src/edt/edt/edtPlugin.cc b/src/edt/edt/edtPlugin.cc index 939c4843c..0f3d01f22 100644 --- a/src/edt/edt/edtPlugin.cc +++ b/src/edt/edt/edtPlugin.cc @@ -217,7 +217,7 @@ public: } #if defined(HAVE_QT) - virtual void get_editor_options_pages (std::vector &pages, lay::LayoutView *view, lay::Dispatcher *root) const + virtual void get_editor_options_pages (std::vector &pages, lay::LayoutViewBase *view, lay::Dispatcher *root) const { if (mp_pages_f != 0) { size_t nstart = pages.size (); @@ -229,7 +229,7 @@ public: } #endif - virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *, lay::LayoutView *view) const + virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *, lay::LayoutViewBase *view) const { Svc *service = new Svc (manager, view); service->set_plugin_declaration (this); @@ -357,7 +357,7 @@ public: return false; } - virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *root, lay::LayoutView *view) const + virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *root, lay::LayoutViewBase *view) const { return new edt::MainService (manager, view, root); } @@ -373,7 +373,7 @@ public: } #if defined(HAVE_QT) - virtual void get_editor_options_pages (std::vector &pages, lay::LayoutView *view, lay::Dispatcher *dispatcher) const + virtual void get_editor_options_pages (std::vector &pages, lay::LayoutViewBase *view, lay::Dispatcher *dispatcher) const { // NOTE: we do not set plugin_declaration which makes the page unspecific EditorOptionsGeneric *generic_opt = new EditorOptionsGeneric (view, dispatcher); @@ -500,12 +500,12 @@ public: // .. nothing yet .. } - virtual void get_editor_options_pages (std::vector & /*pages*/, lay::LayoutView * /*view*/, lay::Dispatcher * /*root*/) const + virtual void get_editor_options_pages (std::vector & /*pages*/, lay::LayoutViewBase * /*view*/, lay::Dispatcher * /*root*/) const { // .. no specific ones .. } - virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *root, lay::LayoutView *view) const + virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *root, lay::LayoutViewBase *view) const { return new edt::PartialService (manager, view, root); } diff --git a/src/img/img/imgPlugin.cc b/src/img/img/imgPlugin.cc index 4936406f0..a5472c5e7 100644 --- a/src/img/img/imgPlugin.cc +++ b/src/img/img/imgPlugin.cc @@ -44,7 +44,7 @@ PluginDeclaration::get_menu_entries (std::vector &menu_entries) } lay::Plugin * -PluginDeclaration::create_plugin (db::Manager *manager, lay::Dispatcher *, lay::LayoutView *view) const +PluginDeclaration::create_plugin (db::Manager *manager, lay::Dispatcher *, lay::LayoutViewBase *view) const { return new img::Service (manager, view); } diff --git a/src/img/img/imgPlugin.h b/src/img/img/imgPlugin.h index 4dc9fa0bd..1575ceccb 100644 --- a/src/img/img/imgPlugin.h +++ b/src/img/img/imgPlugin.h @@ -36,7 +36,7 @@ class PluginDeclaration { public: virtual void get_menu_entries (std::vector &menu_entries) const; - virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *, lay::LayoutView *view) const; + virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *, lay::LayoutViewBase *view) const; virtual bool implements_editable (std::string &title) const; virtual void get_options (std::vector < std::pair > &options) const; }; diff --git a/src/klayout.pri b/src/klayout.pri index 2bc555e29..9bf6debac 100644 --- a/src/klayout.pri +++ b/src/klayout.pri @@ -11,8 +11,10 @@ RDB_INC = $$PWD/rdb/rdb IMG_INC = $$PWD/img/img LYM_INC = $$PWD/lym/lym LIB_INC = $$PWD/lib/lib -LAY_INC = $$PWD/lay/lay LAYBASIC_INC = $$PWD/laybasic/laybasic +LAYVIEW_INC = $$PWD/layview/layview +LAYUI_INC = $$PWD/layui/layui +LAY_INC = $$PWD/lay/lay QTBASIC_INC = $$PWD/gsiqt/qtbasic diff --git a/src/klayout.pro b/src/klayout.pro index c682bb064..a2ece4bb7 100644 --- a/src/klayout.pro +++ b/src/klayout.pro @@ -14,6 +14,7 @@ SUBDIRS = \ buddies \ lym \ laybasic \ + layview \ ant \ img \ edt \ @@ -28,6 +29,7 @@ equals(HAVE_RUBY, "1") { SUBDIRS += \ klayout_main \ lay \ + layui \ fontgen \ } @@ -66,10 +68,11 @@ buddies.depends += plugins lym $$LANG_DEPENDS lym.depends += gsi $$LANG_DEPENDS laybasic.depends += rdb +layview.depends += laybasic -ant.depends += laybasic -img.depends += laybasic -edt.depends += laybasic +ant.depends += layview +img.depends += layview +edt.depends += layview plugins.depends += lib rdb db ant @@ -98,9 +101,11 @@ equals(HAVE_RUBY, "1") { } - plugins.depends += lay + layui.depends += rdb + layview.depends += layui + lay.depends += laybasic ant img edt layui - lay.depends += laybasic ant img edt + plugins.depends += lay klayout_main.depends += plugins $$MAIN_DEPENDS diff --git a/src/lay/lay/layClipDialog.cc b/src/lay/lay/layClipDialog.cc index 36679c03e..88a3102c7 100644 --- a/src/lay/lay/layClipDialog.cc +++ b/src/lay/lay/layClipDialog.cc @@ -55,7 +55,7 @@ public: menu_entries.push_back (lay::menu_item ("clip_tool::show", "clip_tool:edit_mode", "edit_menu.utils_menu.end", tl::to_string (QObject::tr ("Clip Tool")))); } - virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutView *view) const + virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutViewBase *view) const { return new ClipDialog (root, view); } diff --git a/src/lay/lay/layFillDialog.cc b/src/lay/lay/layFillDialog.cc index 63df40cdd..8e3c2cd33 100644 --- a/src/lay/lay/layFillDialog.cc +++ b/src/lay/lay/layFillDialog.cc @@ -62,7 +62,7 @@ public: menu_entries.push_back (lay::menu_item ("fill_tool::show", "fill_tool:edit_mode", "edit_menu.utils_menu.end", tl::to_string (QObject::tr ("Fill Tool")))); } - virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutView *view) const + virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutViewBase *view) const { return new FillDialog (root, view); } diff --git a/src/lay/lay/laySearchReplacePlugin.cc b/src/lay/lay/laySearchReplacePlugin.cc index bc603736d..6c4be161b 100644 --- a/src/lay/lay/laySearchReplacePlugin.cc +++ b/src/lay/lay/laySearchReplacePlugin.cc @@ -63,7 +63,7 @@ public: menu_entries.push_back (lay::menu_item ("search_replace::show", "search_replace_viewer:edit:view_mode", "edit_menu.utils_group+", tl::to_string (QObject::tr ("Search")))); } - virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutView *view) const + virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutViewBase *view) const { return new SearchReplaceDialog (root, view); } diff --git a/src/laybasic/laybasic/gsiDeclLayLayers.cc b/src/laybasic/laybasic/gsiDeclLayLayers.cc index 76955760f..794d83882 100644 --- a/src/laybasic/laybasic/gsiDeclLayLayers.cc +++ b/src/laybasic/laybasic/gsiDeclLayLayers.cc @@ -23,7 +23,7 @@ #include "gsiDecl.h" #include "layLayerProperties.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" namespace gsi { @@ -1227,11 +1227,6 @@ Class decl_LayerPropertiesNode ( "\n" "@return A bbox in micron units\n" ) + - method_ext ("view", &get_view, - "@brief Gets the view this node lives in\n" - "\n" - "This reference can be nil if the node is a orphan node that lives outside a view." - ) + method ("list_index", &lay::LayerPropertiesNode::list_index, "@brief Gets the index of the layer properties list that the node lives in\n" ) + diff --git a/src/laybasic/laybasic/gsiDeclLayLayoutView.cc b/src/laybasic/laybasic/gsiDeclLayLayoutViewBase.cc similarity index 78% rename from src/laybasic/laybasic/gsiDeclLayLayoutView.cc rename to src/laybasic/laybasic/gsiDeclLayLayoutViewBase.cc index 612b28827..3efa7cd32 100644 --- a/src/laybasic/laybasic/gsiDeclLayLayoutView.cc +++ b/src/laybasic/laybasic/gsiDeclLayLayoutViewBase.cc @@ -25,7 +25,7 @@ #include "gsiSignals.h" #include "gsiEnums.h" #include "rdb.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "layDitherPattern.h" #include "layLineStyles.h" #include "dbSaveLayoutOptions.h" @@ -43,7 +43,7 @@ namespace gsi { -static void remove_stipple (lay::LayoutView *view, unsigned int index) +static void remove_stipple (lay::LayoutViewBase *view, unsigned int index) { lay::DitherPattern pattern (view->dither_pattern ()); @@ -56,13 +56,13 @@ static void remove_stipple (lay::LayoutView *view, unsigned int index) } } -static void clear_stipples (lay::LayoutView *view) +static void clear_stipples (lay::LayoutViewBase *view) { lay::DitherPattern no_stipples; view->set_dither_pattern (no_stipples); } -static unsigned int add_stipple1 (lay::LayoutView *view, const std::string &name, const std::vector &data, unsigned int bits) +static unsigned int add_stipple1 (lay::LayoutViewBase *view, const std::string &name, const std::vector &data, unsigned int bits) { lay::DitherPattern pattern (view->dither_pattern ()); @@ -78,7 +78,7 @@ static unsigned int add_stipple1 (lay::LayoutView *view, const std::string &name return index; } -static unsigned int add_stipple2 (lay::LayoutView *view, const std::string &name, const std::string &s) +static unsigned int add_stipple2 (lay::LayoutViewBase *view, const std::string &name, const std::string &s) { lay::DitherPattern pattern (view->dither_pattern ()); @@ -92,13 +92,13 @@ static unsigned int add_stipple2 (lay::LayoutView *view, const std::string &name return index; } -static std::string get_stipple (lay::LayoutView *view, unsigned int index) +static std::string get_stipple (lay::LayoutViewBase *view, unsigned int index) { lay::DitherPattern pattern (view->dither_pattern ()); return pattern.pattern (index).to_string (); } -static void remove_line_style (lay::LayoutView *view, unsigned int index) +static void remove_line_style (lay::LayoutViewBase *view, unsigned int index) { lay::LineStyles styles (view->line_styles ()); @@ -111,13 +111,13 @@ static void remove_line_style (lay::LayoutView *view, unsigned int index) } } -static void clear_line_styles (lay::LayoutView *view) +static void clear_line_styles (lay::LayoutViewBase *view) { lay::LineStyles no_styles; view->set_line_styles (no_styles); } -static unsigned int add_line_style1 (lay::LayoutView *view, const std::string &name, unsigned int data, unsigned int bits) +static unsigned int add_line_style1 (lay::LayoutViewBase *view, const std::string &name, unsigned int data, unsigned int bits) { lay::LineStyles styles (view->line_styles ()); @@ -131,7 +131,7 @@ static unsigned int add_line_style1 (lay::LayoutView *view, const std::string &n return index; } -static unsigned int add_line_style2 (lay::LayoutView *view, const std::string &name, const std::string &str) +static unsigned int add_line_style2 (lay::LayoutViewBase *view, const std::string &name, const std::string &str) { lay::LineStyles styles (view->line_styles ()); @@ -145,93 +145,93 @@ static unsigned int add_line_style2 (lay::LayoutView *view, const std::string &n return index; } -static std::string get_line_style (lay::LayoutView *view, unsigned int index) +static std::string get_line_style (lay::LayoutViewBase *view, unsigned int index) { return view->line_styles ().style (index).to_string (); } -static void transaction (lay::LayoutView *view, const std::string &desc) +static void transaction (lay::LayoutViewBase *view, const std::string &desc) { view->manager ()->transaction (desc); } -static void commit (lay::LayoutView *view) +static void commit (lay::LayoutViewBase *view) { view->manager ()->commit (); } -static void clear_transactions (lay::LayoutView *view) +static void clear_transactions (lay::LayoutViewBase *view) { view->manager ()->clear (); } -static bool transacting (lay::LayoutView *view) +static bool transacting (lay::LayoutViewBase *view) { return view->manager ()->transacting (); } -static db::DCplxTrans viewport_trans (const lay::LayoutView *view) +static db::DCplxTrans viewport_trans (const lay::LayoutViewBase *view) { return view->viewport ().trans (); } -static int viewport_width (const lay::LayoutView *view) +static int viewport_width (const lay::LayoutViewBase *view) { return view->viewport ().width (); } -static int viewport_height (const lay::LayoutView *view) +static int viewport_height (const lay::LayoutViewBase *view) { return view->viewport ().height (); } -static std::vector selected_cells_paths (const lay::LayoutView *view, int cv_index) +static std::vector selected_cells_paths (const lay::LayoutViewBase *view, int cv_index) { - std::vector p; + std::vector p; view->selected_cells_paths (cv_index, p); return p; } -static unsigned int create_rdb (lay::LayoutView *view, const std::string &name) +static unsigned int create_rdb (lay::LayoutViewBase *view, const std::string &name) { rdb::Database *db = new rdb::Database (); db->set_name (name); return view->add_rdb (db); } -static unsigned int create_l2ndb (lay::LayoutView *view, const std::string &name) +static unsigned int create_l2ndb (lay::LayoutViewBase *view, const std::string &name) { db::LayoutToNetlist *db = new db::LayoutToNetlist (); db->set_name (name); return view->add_l2ndb (db); } -static unsigned int create_lvsdb (lay::LayoutView *view, const std::string &name) +static unsigned int create_lvsdb (lay::LayoutViewBase *view, const std::string &name) { db::LayoutVsSchematic *db = new db::LayoutVsSchematic (); db->set_name (name); return view->add_l2ndb (db); } -static db::LayoutVsSchematic *get_lvsdb (lay::LayoutView *view, unsigned int index) +static db::LayoutVsSchematic *get_lvsdb (lay::LayoutViewBase *view, unsigned int index) { db::LayoutToNetlist *db = view->get_l2ndb (index); return dynamic_cast (db); } -static unsigned int add_lvsdb (lay::LayoutView *view, db::LayoutVsSchematic *lvsdb) +static unsigned int add_lvsdb (lay::LayoutViewBase *view, db::LayoutVsSchematic *lvsdb) { return view->add_l2ndb (lvsdb); } -static unsigned int replace_lvsdb (lay::LayoutView *view, unsigned int db_index, db::LayoutVsSchematic *lvsdb) +static unsigned int replace_lvsdb (lay::LayoutViewBase *view, unsigned int db_index, db::LayoutVsSchematic *lvsdb) { return view->replace_l2ndb (db_index, lvsdb); } // this binding returns a const pointer which is not converted into a copy by RBA -static lay::LayerPropertiesNodeRef insert_layer1 (lay::LayoutView *view, const lay::LayerPropertiesConstIterator &iter, const lay::LayerProperties &props) +static lay::LayerPropertiesNodeRef insert_layer1 (lay::LayoutViewBase *view, const lay::LayerPropertiesConstIterator &iter, const lay::LayerProperties &props) { const lay::LayerPropertiesNode *lp = dynamic_cast (&props); if (lp) { @@ -241,7 +241,7 @@ static lay::LayerPropertiesNodeRef insert_layer1 (lay::LayoutView *view, const l } } -static void replace_layer_node2 (lay::LayoutView *view, unsigned int index, const lay::LayerPropertiesConstIterator &iter, const lay::LayerProperties &props) +static void replace_layer_node2 (lay::LayoutViewBase *view, unsigned int index, const lay::LayerPropertiesConstIterator &iter, const lay::LayerProperties &props) { const lay::LayerPropertiesNode *lp = dynamic_cast (&props); if (lp) { @@ -251,7 +251,7 @@ static void replace_layer_node2 (lay::LayoutView *view, unsigned int index, cons } } -static void replace_layer_node1 (lay::LayoutView *view, const lay::LayerPropertiesConstIterator &iter, const lay::LayerProperties &props) +static void replace_layer_node1 (lay::LayoutViewBase *view, const lay::LayerPropertiesConstIterator &iter, const lay::LayerProperties &props) { const lay::LayerPropertiesNode *lp = dynamic_cast (&props); if (lp) { @@ -261,7 +261,7 @@ static void replace_layer_node1 (lay::LayoutView *view, const lay::LayerProperti } } -static lay::LayerPropertiesNodeRef insert_layer2 (lay::LayoutView *view, unsigned int index, const lay::LayerPropertiesConstIterator &iter, const lay::LayerProperties &props) +static lay::LayerPropertiesNodeRef insert_layer2 (lay::LayoutViewBase *view, unsigned int index, const lay::LayerPropertiesConstIterator &iter, const lay::LayerProperties &props) { const lay::LayerPropertiesNode *lp = dynamic_cast (&props); if (lp) { @@ -271,7 +271,7 @@ static lay::LayerPropertiesNodeRef insert_layer2 (lay::LayoutView *view, unsigne } } -static void delete_layers1 (lay::LayoutView *view, const std::vector &iters) +static void delete_layers1 (lay::LayoutViewBase *view, const std::vector &iters) { std::vector sorted (iters); std::sort (sorted.begin (), sorted.end (), lay::CompareLayerIteratorBottomUp ()); @@ -280,7 +280,7 @@ static void delete_layers1 (lay::LayoutView *view, const std::vectorkeep (); @@ -288,7 +288,7 @@ static unsigned int show_layout1 (lay::LayoutView *view, db::Layout *layout, boo return view->add_layout (handle, add_cellview); } -static unsigned int show_layout2 (lay::LayoutView *view, db::Layout *layout, std::string &tech, bool add_cellview) +static unsigned int show_layout2 (lay::LayoutViewBase *view, db::Layout *layout, std::string &tech, bool add_cellview) { // the layout gets held by the LayoutHandle object layout->keep (); @@ -297,7 +297,7 @@ static unsigned int show_layout2 (lay::LayoutView *view, db::Layout *layout, std return view->add_layout (handle, add_cellview); } -static unsigned int show_layout3 (lay::LayoutView *view, db::Layout *layout, std::string &tech, bool add_cellview, bool initialize_layers) +static unsigned int show_layout3 (lay::LayoutViewBase *view, db::Layout *layout, std::string &tech, bool add_cellview, bool initialize_layers) { // the layout gets held by the LayoutHandle object layout->keep (); @@ -306,7 +306,7 @@ static unsigned int show_layout3 (lay::LayoutView *view, db::Layout *layout, std return view->add_layout (handle, add_cellview, initialize_layers); } -static void delete_layers2 (lay::LayoutView *view, unsigned int index, const std::vector &iters) +static void delete_layers2 (lay::LayoutViewBase *view, unsigned int index, const std::vector &iters) { std::vector sorted (iters); std::sort (sorted.begin (), sorted.end (), lay::CompareLayerIteratorBottomUp ()); @@ -315,42 +315,42 @@ static void delete_layers2 (lay::LayoutView *view, unsigned int index, const std } } -static void save_as1 (lay::LayoutView *view, unsigned int index, const std::string &filename, const db::SaveLayoutOptions &options) +static void save_as1 (lay::LayoutViewBase *view, unsigned int index, const std::string &filename, const db::SaveLayoutOptions &options) { view->save_as (index, filename, tl::OutputStream::OM_Auto, options, true, 0); } -static void save_as2 (lay::LayoutView *view, unsigned int index, const std::string &filename, bool /*gzip*/, const db::SaveLayoutOptions &options) +static void save_as2 (lay::LayoutViewBase *view, unsigned int index, const std::string &filename, bool /*gzip*/, const db::SaveLayoutOptions &options) { // because set_format_from_name always returns true now, we ignore the gzip option - // it's probably used only in that context. view->save_as (index, filename, tl::OutputStream::OM_Auto, options, true, 0); } -#if defined(HAVE_QT) && defined(HAVE_QTBINDINGS) -static QImage get_image_with_options (lay::LayoutView *view, unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, const db::DBox &target_box, bool monochrome) +static lay::PixelBuffer get_pixels_with_options (lay::LayoutViewBase *view, unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, const db::DBox &target_box) +{ + return view->get_pixels_with_options (width, height, linewidth, oversampling, resolution, lay::Color (), lay::Color (), lay::Color (), target_box); +} + +static lay::BitmapBuffer get_pixels_with_options_mono (lay::LayoutViewBase *view, unsigned int width, unsigned int height, int linewidth, const db::DBox &target_box) +{ + return view->get_pixels_with_options_mono (width, height, linewidth, lay::Color (), lay::Color (), lay::Color (), target_box); +} + +static void save_image_with_options (lay::LayoutViewBase *view, const std::string &fn, unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, const db::DBox &target_box, bool monochrome) +{ + view->save_image_with_options (fn, width, height, linewidth, oversampling, resolution, lay::Color (), lay::Color (), lay::Color (), target_box, monochrome); +} + +#if defined(HAVE_QTBINDINGS) +static QImage get_image_with_options (lay::LayoutViewBase *view, unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, const db::DBox &target_box, bool monochrome) { return view->get_image_with_options (width, height, linewidth, oversampling, resolution, lay::Color (), lay::Color (), lay::Color (), target_box, monochrome); } #endif -static lay::PixelBuffer get_pixels_with_options (lay::LayoutView *view, unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, const db::DBox &target_box) -{ - return view->get_pixels_with_options (width, height, linewidth, oversampling, resolution, lay::Color (), lay::Color (), lay::Color (), target_box); -} - -static lay::BitmapBuffer get_pixels_with_options_mono (lay::LayoutView *view, unsigned int width, unsigned int height, int linewidth, const db::DBox &target_box) -{ - return view->get_pixels_with_options_mono (width, height, linewidth, lay::Color (), lay::Color (), lay::Color (), target_box); -} - -static void save_image_with_options (lay::LayoutView *view, const std::string &fn, unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, const db::DBox &target_box, bool monochrome) -{ - view->save_image_with_options (fn, width, height, linewidth, oversampling, resolution, lay::Color (), lay::Color (), lay::Color (), target_box, monochrome); -} - static std::vector -get_config_names (lay::LayoutView *view) +get_config_names (lay::LayoutViewBase *view) { std::vector names; view->get_config_names (names); @@ -358,49 +358,49 @@ get_config_names (lay::LayoutView *view) } static void -send_key_press_event (lay::LayoutView *view, unsigned int key, unsigned int buttons) +send_key_press_event (lay::LayoutViewBase *view, unsigned int key, unsigned int buttons) { view->view_object_widget ()->send_key_press_event (key, buttons); } static void -send_mouse_move_event (lay::LayoutView *view, const db::DPoint &pt, unsigned int buttons) +send_mouse_move_event (lay::LayoutViewBase *view, const db::DPoint &pt, unsigned int buttons) { view->view_object_widget ()->send_mouse_move_event (pt, buttons); } static void -send_leave_event (lay::LayoutView *view) +send_leave_event (lay::LayoutViewBase *view) { view->view_object_widget ()->send_leave_event (); } static void -send_enter_event (lay::LayoutView *view) +send_enter_event (lay::LayoutViewBase *view) { view->view_object_widget ()->send_enter_event (); } static void -send_mouse_press_event (lay::LayoutView *view, const db::DPoint &pt, unsigned int buttons) +send_mouse_press_event (lay::LayoutViewBase *view, const db::DPoint &pt, unsigned int buttons) { view->view_object_widget ()->send_mouse_press_event (pt, buttons); } static void -send_mouse_double_clicked_event (lay::LayoutView *view, const db::DPoint &pt, unsigned int buttons) +send_mouse_double_clicked_event (lay::LayoutViewBase *view, const db::DPoint &pt, unsigned int buttons) { view->view_object_widget ()->send_mouse_double_clicked_event (pt, buttons); } static void -send_mouse_release_event (lay::LayoutView *view, const db::DPoint &pt, unsigned int buttons) +send_mouse_release_event (lay::LayoutViewBase *view, const db::DPoint &pt, unsigned int buttons) { view->view_object_widget ()->send_mouse_release_event (pt, buttons); } static void -send_wheel_event (lay::LayoutView *view, int delta, bool horizontal, const db::DPoint &pt, unsigned int buttons) +send_wheel_event (lay::LayoutViewBase *view, int delta, bool horizontal, const db::DPoint &pt, unsigned int buttons) { view->view_object_widget ()->send_wheel_event (delta, horizontal, pt, buttons); } @@ -451,146 +451,96 @@ namespace { } -static LayerPropertiesConstIteratorWrapper each_layer (lay::LayoutView *view) +static LayerPropertiesConstIteratorWrapper each_layer (lay::LayoutViewBase *view) { return LayerPropertiesConstIteratorWrapper (view->begin_layers ()); } -static LayerPropertiesConstIteratorWrapper each_layer2 (lay::LayoutView *view, unsigned int list_index) +static LayerPropertiesConstIteratorWrapper each_layer2 (lay::LayoutViewBase *view, unsigned int list_index) { return LayerPropertiesConstIteratorWrapper (view->begin_layers (list_index)); } -#if defined(HAVE_QTBINDINGS) -static lay::LayoutView *new_view (QWidget *parent, bool editable, db::Manager *manager, unsigned int options) -{ - lay::LayoutView *lv = new lay::LayoutView (manager, editable, 0 /*plugin parent*/, parent, "view", options); - if (parent) { - // transfer ownership to the parent - lv->keep (); - } - return lv; -} -#endif - -static lay::LayoutView *new_view2 (bool editable, db::Manager *manager, unsigned int options) -{ #if defined(HAVE_QT) - return new lay::LayoutView (manager, editable, 0 /*plugin parent*/, 0 /*parent*/, "view", options); +Class decl_LayoutViewBase (QT_EXTERNAL_BASE (QWidget) "lay", "LayoutViewBase", #else - return new lay::LayoutView (manager, editable, 0 /*plugin parent*/, options); +Class decl_LayoutViewBase (QT_EXTERNAL_BASE (QWidget) "lay", "LayoutViewBase", #endif -} - -#if defined(HAVE_QT) -Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "LayoutView", -#else -Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "LayoutView", -#endif -#if defined(HAVE_QTBINDINGS) && defined(HAVE_QT) - gsi::constructor ("new", &new_view, gsi::arg ("parent"), gsi::arg ("editable", false), gsi::arg ("manager", (db::Manager *) 0, "nil"), gsi::arg ("options", (unsigned int) 0), - "@brief Creates a standalone view\n" - "\n" - "This constructor is for special purposes only. To create a view in the context of a main window, " - "use \\MainWindow#create_view and related methods.\n" - "\n" - "@param parent The parent widget in which to embed the view\n" - "@param editable True to make the view editable\n" - "@param manager The \\Manager object to enable undo/redo\n" - "@param options A combination of the values in the LV_... constants\n" - "\n" - "This constructor has been introduced in version 0.25.\n" - "It has been enhanced with the arguments in version 0.27.\n" - ) + -#endif - gsi::constructor ("new", &new_view2, gsi::arg ("editable", false), gsi::arg ("manager", (db::Manager *) 0, "nil"), gsi::arg ("options", (unsigned int) 0), - "@brief Creates a standalone view\n" - "\n" - "This constructor is for special purposes only. To create a view in the context of a main window, " - "use \\MainWindow#create_view and related methods.\n" - "\n" - "@param editable True to make the view editable\n" - "@param manager The \\Manager object to enable undo/redo\n" - "@param options A combination of the values in the LV_... constants\n" - "\n" - "This constructor has been introduced in version 0.25.\n" - "It has been enhanced with the arguments in version 0.27.\n" - ) + - gsi::constant ("LV_NoLayers", (unsigned int) lay::LayoutView::LV_NoLayers, + gsi::constant ("LV_NoLayers", (unsigned int) lay::LayoutViewBase::LV_NoLayers, "@brief With this option, no layers view will be provided (see \\layer_control_frame)\n" "Use this value with the constructor's 'options' argument.\n" "\n" "This constant has been introduced in version 0.27.\n" ) + - gsi::constant ("LV_NoHierarchyPanel", (unsigned int) lay::LayoutView::LV_NoHierarchyPanel, + gsi::constant ("LV_NoHierarchyPanel", (unsigned int) lay::LayoutViewBase::LV_NoHierarchyPanel, "@brief With this option, no cell hierarchy view will be provided (see \\hierarchy_control_frame)\n" "Use this value with the constructor's 'options' argument.\n" "\n" "This constant has been introduced in version 0.27.\n" ) + - gsi::constant ("LV_NoLibrariesView", (unsigned int) lay::LayoutView::LV_NoLibrariesView, + gsi::constant ("LV_NoLibrariesView", (unsigned int) lay::LayoutViewBase::LV_NoLibrariesView, "@brief With this option, no library view will be provided (see \\libraries_frame)\n" "Use this value with the constructor's 'options' argument.\n" "\n" "This constant has been introduced in version 0.27.\n" ) + - gsi::constant ("LV_NoEditorOptionsPanel", (unsigned int) lay::LayoutView::LV_NoEditorOptionsPanel, + gsi::constant ("LV_NoEditorOptionsPanel", (unsigned int) lay::LayoutViewBase::LV_NoEditorOptionsPanel, "@brief With this option, no editor options panel will be provided (see \\editor_options_frame)\n" "Use this value with the constructor's 'options' argument.\n" "\n" "This constant has been introduced in version 0.27.\n" ) + - gsi::constant ("LV_NoBookmarksView", (unsigned int) lay::LayoutView::LV_NoBookmarksView, + gsi::constant ("LV_NoBookmarksView", (unsigned int) lay::LayoutViewBase::LV_NoBookmarksView, "@brief With this option, no bookmarks view will be provided (see \\bookmarks_frame)\n" "Use this value with the constructor's 'options' argument.\n" "\n" "This constant has been introduced in version 0.27.\n" ) + - gsi::constant ("LV_Naked", (unsigned int) lay::LayoutView::LV_Naked, + gsi::constant ("LV_Naked", (unsigned int) lay::LayoutViewBase::LV_Naked, "@brief With this option, no separate views will be provided\n" "Use this value with the constructor's 'options' argument.\n" "This option is basically equivalent to using \\LV_NoLayers+\\LV_NoHierarchyPanel+\\LV_NoLibrariesView+\\LV_NoBookmarksView\n" "\n" "This constant has been introduced in version 0.27.\n" ) + - gsi::constant ("LV_NoZoom", (unsigned int) lay::LayoutView::LV_NoZoom, + gsi::constant ("LV_NoZoom", (unsigned int) lay::LayoutViewBase::LV_NoZoom, "@brief With this option, zooming is disabled\n" "Use this value with the constructor's 'options' argument.\n" "\n" "This constant has been introduced in version 0.27.\n" ) + - gsi::constant ("LV_NoGrid", (unsigned int) lay::LayoutView::LV_NoGrid, + gsi::constant ("LV_NoGrid", (unsigned int) lay::LayoutViewBase::LV_NoGrid, "@brief With this option, the grid background is not shown\n" "Use this value with the constructor's 'options' argument.\n" "\n" "This constant has been introduced in version 0.27.\n" ) + - gsi::constant ("LV_NoMove", (unsigned int) lay::LayoutView::LV_NoMove, + gsi::constant ("LV_NoMove", (unsigned int) lay::LayoutViewBase::LV_NoMove, "@brief With this option, move operations are not supported\n" "Use this value with the constructor's 'options' argument.\n" "\n" "This constant has been introduced in version 0.27.\n" ) + - gsi::constant ("LV_NoTracker", (unsigned int) lay::LayoutView::LV_NoTracker, + gsi::constant ("LV_NoTracker", (unsigned int) lay::LayoutViewBase::LV_NoTracker, "@brief With this option, mouse position tracking is not supported\n" "Use this value with the constructor's 'options' argument.\n" "This option is not useful currently as no mouse tracking support is provided.\n" "\n" "This constant has been introduced in version 0.27.\n" ) + - gsi::constant ("LV_NoSelection", (unsigned int) lay::LayoutView::LV_NoSelection, + gsi::constant ("LV_NoSelection", (unsigned int) lay::LayoutViewBase::LV_NoSelection, "@brief With this option, objects cannot be selected\n" "Use this value with the constructor's 'options' argument.\n" "\n" "This constant has been introduced in version 0.27.\n" ) + - gsi::constant ("LV_NoPlugins", (unsigned int) lay::LayoutView::LV_NoPlugins, + gsi::constant ("LV_NoPlugins", (unsigned int) lay::LayoutViewBase::LV_NoPlugins, "@brief With this option, all plugins are disabled\n" "Use this value with the constructor's 'options' argument.\n" "\n" "This constant has been introduced in version 0.27.\n" ) + - gsi::constant ("LV_NoServices", (unsigned int) lay::LayoutView::LV_NoServices, + gsi::constant ("LV_NoServices", (unsigned int) lay::LayoutViewBase::LV_NoServices, "@brief This option disables all services except the ones for pure viewing\n" "Use this value with the constructor's 'options' argument.\n" "With this option, all manipulation features are disabled, except zooming.\n" @@ -598,64 +548,26 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This constant has been introduced in version 0.27.\n" ) + -#if defined(HAVE_QTBINDINGS) - gsi::method ("layer_control_frame", static_cast (&lay::LayoutView::layer_control_frame), - "@brief Gets the layer control side widget\n" - "A 'side widget' is a widget attached to the view. It does not have a parent, so you can " - "embed it into a different context. Please note that with embedding through 'setParent' it will be " - "destroyed when your parent widget gets destroyed. It will be lost then to the view.\n" - "\n" - "The side widget can be configured through the views configuration interface.\n" - "\n" - "This method has been introduced in version 0.27\n" - ) + - gsi::method ("hierarchy_control_frame", static_cast (&lay::LayoutView::hierarchy_control_frame), - "@brief Gets the cell view (hierarchy view) side widget\n" - "For details about side widgets see \\layer_control_frame.\n" - "\n" - "This method has been introduced in version 0.27\n" - ) + - gsi::method ("libraries_frame", static_cast (&lay::LayoutView::libraries_frame), - "@brief Gets the library view side widget\n" - "For details about side widgets see \\layer_control_frame.\n" - "\n" - "This method has been introduced in version 0.27\n" - ) + - gsi::method ("bookmarks_frame", static_cast (&lay::LayoutView::bookmarks_frame), - "@brief Gets the bookmarks side widget\n" - "For details about side widgets see \\layer_control_frame.\n" - "\n" - "This method has been introduced in version 0.27\n" - ) + -#endif - gsi::method ("call_menu", static_cast (&lay::LayoutView::menu_activated), + gsi::method ("call_menu", static_cast (&lay::LayoutViewBase::menu_activated), "@brief Calls the menu item with the provided symbol.\n" "To obtain all symbols, use get_menu_symbols.\n" "\n" "This method has been introduced in version 0.27." ) + - gsi::method ("menu_symbols", &lay::LayoutView::menu_symbols, + gsi::method ("menu_symbols", &lay::LayoutViewBase::menu_symbols, "@brief Gets all available menu symbols (see \\call_menu).\n" "NOTE: currently this method delivers a superset of all available symbols. Depending on the context, no all symbols may trigger actual functionality.\n" "\n" "This method has been introduced in version 0.27." ) + -#if defined(HAVE_QT) - gsi::method ("current", &lay::LayoutView::current, - "@brief Returns the current view\n" - "The current view is the one that is shown in the current tab. Returns nil if no layout is loaded.\n" - "\n" - "This method has been introduced in version 0.23.\n" - ) + -#endif - gsi::method ("stop_redraw", static_cast (&lay::LayoutView::stop_redraw), + gsi::method ("stop_redraw", static_cast (&lay::LayoutViewBase::stop_redraw), "@brief Stops the redraw thread\n" "\n" "It is very important to stop the redraw thread before applying changes to the " "layout or the cell views and the LayoutView configuration. This is usually done automatically. " "For rare cases, where this is not the case, this method is provided.\n" ) + - gsi::method ("title=|#set_title", static_cast (&lay::LayoutView::set_title), gsi::arg ("title"), + gsi::method ("title=|#set_title", static_cast (&lay::LayoutViewBase::set_title), gsi::arg ("title"), "@brief Sets the title of the view\n" "\n" "@param title The title string to use\n" @@ -664,12 +576,12 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "the specified title string. The title string can be reset with \\reset_title to " "the standard title again." ) + - gsi::method ("reset_title", static_cast (&lay::LayoutView::reset_title), + gsi::method ("reset_title", static_cast (&lay::LayoutViewBase::reset_title), "@brief Resets the title to the standard title\n" "\n" "See \\set_title and \\title for a description about how titles are handled." ) + - gsi::method ("title", static_cast (&lay::LayoutView::title), + gsi::method ("title", static_cast (&lay::LayoutViewBase::title), "@brief Returns the view's title string\n" "\n" "@return The title string\n" @@ -677,19 +589,19 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "The title string is either a string composed of the file names loaded (in some " "\"readable\" manner) or a customized title string set by \\set_title." ) + - gsi::method ("save_layer_props", static_cast (&lay::LayoutView::save_layer_props), gsi::arg ("fn"), + gsi::method ("save_layer_props", static_cast (&lay::LayoutViewBase::save_layer_props), gsi::arg ("fn"), "@brief Saves the layer properties\n" "\n" "Save the layer properties to the file given in \"fn\"" ) + - gsi::method ("load_layer_props", static_cast (&lay::LayoutView::load_layer_props), gsi::arg ("fn"), + gsi::method ("load_layer_props", static_cast (&lay::LayoutViewBase::load_layer_props), gsi::arg ("fn"), "@brief Loads the layer properties\n" "\n" "@param fn The file name of the .lyp file to load\n" "\n" "Load the layer properties from the file given in \"fn\"" ) + - gsi::method ("load_layer_props", static_cast (&lay::LayoutView::load_layer_props), gsi::arg ("fn"), gsi::arg ("add_default"), + gsi::method ("load_layer_props", static_cast (&lay::LayoutViewBase::load_layer_props), gsi::arg ("fn"), gsi::arg ("add_default"), "@brief Loads the layer properties with options\n" "\n" "@param fn The file name of the .lyp file to load\n" @@ -701,7 +613,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This variant has been added on version 0.21." ) + - gsi::method ("load_layer_props", static_cast (&lay::LayoutView::load_layer_props), gsi::arg ("fn"), gsi::arg ("cv_index"), gsi::arg ("add_default"), + gsi::method ("load_layer_props", static_cast (&lay::LayoutViewBase::load_layer_props), gsi::arg ("fn"), gsi::arg ("cv_index"), gsi::arg ("add_default"), "@brief Loads the layer properties with options\n" "\n" "@param fn The file name of the .lyp file to load\n" @@ -719,7 +631,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This variant has been added on version 0.21." ) + - gsi::method ("min_hier_levels=", static_cast (&lay::LayoutView::set_min_hier_levels), gsi::arg ("level"), + gsi::method ("min_hier_levels=", static_cast (&lay::LayoutViewBase::set_min_hier_levels), gsi::arg ("level"), "@brief Sets the minimum hierarchy level at which to display geometries\n" "\n" "@param level The minimum level above which to display something\n" @@ -727,12 +639,12 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "This methods allows setting the minimum hierarchy level above which to display geometries." "This method may cause a redraw if required." ) + - gsi::method ("min_hier_levels", static_cast (&lay::LayoutView::get_min_hier_levels), + gsi::method ("min_hier_levels", static_cast (&lay::LayoutViewBase::get_min_hier_levels), "@brief Returns the minimum hierarchy level at which to display geometries\n" "\n" "@return The minimum level at which to display geometries" ) + - gsi::method ("max_hier_levels=", static_cast (&lay::LayoutView::set_max_hier_levels), gsi::arg ("level"), + gsi::method ("max_hier_levels=", static_cast (&lay::LayoutViewBase::set_max_hier_levels), gsi::arg ("level"), "@brief Sets the maximum hierarchy level up to which to display geometries\n" "\n" "@param level The maximum level below which to display something\n" @@ -740,12 +652,12 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "This methods allows setting the maximum hierarchy below which to display geometries." "This method may cause a redraw if required." ) + - gsi::method ("max_hier_levels", static_cast (&lay::LayoutView::get_max_hier_levels), + gsi::method ("max_hier_levels", static_cast (&lay::LayoutViewBase::get_max_hier_levels), "@brief Returns the maximum hierarchy level up to which to display geometries\n" "\n" "@return The maximum level up to which to display geometries" ) + - gsi::method ("enable_edits", static_cast (&lay::LayoutView::enable_edits), gsi::arg ("enable"), + gsi::method ("enable_edits", static_cast (&lay::LayoutViewBase::enable_edits), gsi::arg ("enable"), "@brief Enables or disables edits\n" "\n" "@param enable Enable edits if set to true\n" @@ -758,17 +670,17 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "In 0.25, this method has been moved from MainWindow to LayoutView.\n" ) + - gsi::method ("is_editable?", static_cast (&lay::LayoutView::is_editable), + gsi::method ("is_editable?", static_cast (&lay::LayoutViewBase::is_editable), "@brief Returns true if the view is in editable mode\n" "\n" "This read-only attribute has been added in version 0.27.5.\n" ) + - gsi::method ("reload_layout", static_cast (&lay::LayoutView::reload_layout), gsi::arg ("cv"), + gsi::method ("reload_layout", static_cast (&lay::LayoutViewBase::reload_layout), gsi::arg ("cv"), "@brief Reloads the given cellview\n" "\n" "@param cv The index of the cellview to reload" ) + - gsi::method ("create_layout", static_cast (&lay::LayoutView::create_layout), gsi::arg ("add_cellview"), + gsi::method ("create_layout", static_cast (&lay::LayoutViewBase::create_layout), gsi::arg ("add_cellview"), "@brief Creates a new, empty layout\n" "\n" "The add_cellview parameter controls whether to create a new cellview (true)\n" @@ -778,7 +690,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "@return The index of the cellview created.\n" ) + - gsi::method ("create_layout", static_cast (&lay::LayoutView::create_layout), gsi::arg ("tech"), gsi::arg ("add_cellview"), + gsi::method ("create_layout", static_cast (&lay::LayoutViewBase::create_layout), gsi::arg ("tech"), gsi::arg ("add_cellview"), "@brief Create a new, empty layout and associate it with the given technology\n" "\n" "The add_cellview parameter controls whether to create a new cellview (true)\n" @@ -788,7 +700,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This variant has been introduced in version 0.22.\n" ) + - gsi::method ("create_layout", static_cast (&lay::LayoutView::create_layout), gsi::arg ("tech"), gsi::arg ("add_cellview"), gsi::arg ("init_layers"), + gsi::method ("create_layout", static_cast (&lay::LayoutViewBase::create_layout), gsi::arg ("tech"), gsi::arg ("add_cellview"), gsi::arg ("init_layers"), "@brief Create a new, empty layout and associate it with the given technology\n" "\n" "The add_cellview parameter controls whether to create a new cellview (true)\n" @@ -846,12 +758,12 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This method has been introduced in version 0.22.\n" ) + - gsi::method ("erase_cellview", static_cast (&lay::LayoutView::erase_cellview), gsi::arg ("index"), + gsi::method ("erase_cellview", static_cast (&lay::LayoutViewBase::erase_cellview), gsi::arg ("index"), "@brief Erases the cellview with the given index\n" "\n" "This closes the given cellview and unloads the layout associated with it, unless referred to by another cellview." ) + - gsi::method ("rename_cellview", static_cast (&lay::LayoutView::rename_cellview), gsi::arg ("name"), gsi::arg ("index"), + gsi::method ("rename_cellview", static_cast (&lay::LayoutViewBase::rename_cellview), gsi::arg ("name"), gsi::arg ("index"), "@brief Renames the cellview with the given index\n" "\n" "If the name is not unique, a unique name will be constructed from the name given.\n" @@ -859,7 +771,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "If a layout is shared between multiple cellviews (which may happen due to a clone of the layout view\n" "for example), all cellviews are renamed.\n" ) + - gsi::method ("load_layout", static_cast (&lay::LayoutView::load_layout), gsi::arg ("filename"), gsi::arg ("options"), gsi::arg ("technology"), gsi::arg ("add_cellview"), + gsi::method ("load_layout", static_cast (&lay::LayoutViewBase::load_layout), gsi::arg ("filename"), gsi::arg ("options"), gsi::arg ("technology"), gsi::arg ("add_cellview"), "@brief Loads a (new) file into the layout view with the given technology\n" "\n" "Loads the file given by the \"filename\" parameter and associates it with the given technology.\n" @@ -871,7 +783,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This version has been introduced in version 0.22.\n" ) + - gsi::method ("load_layout", static_cast (&lay::LayoutView::load_layout), gsi::arg ("filename"), gsi::arg ("options"), gsi::arg ("add_cellview"), + gsi::method ("load_layout", static_cast (&lay::LayoutViewBase::load_layout), gsi::arg ("filename"), gsi::arg ("options"), gsi::arg ("add_cellview"), "@brief Loads a (new) file into the layout view\n" "\n" "Loads the file given by the \"filename\" parameter.\n" @@ -883,7 +795,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This method has been introduced in version 0.18.\n" ) + - gsi::method ("load_layout", static_cast (&lay::LayoutView::load_layout), gsi::arg ("filename"), gsi::arg ("technology"), gsi::arg ("add_cellview"), + gsi::method ("load_layout", static_cast (&lay::LayoutViewBase::load_layout), gsi::arg ("filename"), gsi::arg ("technology"), gsi::arg ("add_cellview"), "@brief Loads a (new) file into the layout view with the given technology\n" "\n" "Loads the file given by the \"filename\" parameter and associates it with the given technology.\n" @@ -894,7 +806,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This version has been introduced in version 0.22.\n" ) + - gsi::method ("load_layout", static_cast (&lay::LayoutView::load_layout), gsi::arg ("filename"), gsi::arg ("add_cellview"), + gsi::method ("load_layout", static_cast (&lay::LayoutViewBase::load_layout), gsi::arg ("filename"), gsi::arg ("add_cellview"), "@brief Loads a (new) file into the layout view\n" "\n" "Loads the file given by the \"filename\" parameter.\n" @@ -903,7 +815,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "@return The index of the cellview loaded.\n" ) + - gsi::method ("active_cellview", static_cast (&lay::LayoutView::active_cellview_ref), + gsi::method ("active_cellview", static_cast (&lay::LayoutViewBase::active_cellview_ref), "@brief Gets the active cellview (shown in hierarchy browser)\n" "\n" "This is a convenience method which is equivalent to cellview(active_cellview_index()).\n" @@ -912,10 +824,10 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "Starting from version 0.25, the returned object can be manipulated which will have an immediate effect " "on the display." ) + - gsi::method ("active_cellview_index", static_cast (&lay::LayoutView::active_cellview_index), + gsi::method ("active_cellview_index", static_cast (&lay::LayoutViewBase::active_cellview_index), "@brief Gets the index of the active cellview (shown in hierarchy browser)\n" ) + - gsi::method ("active_setview_index=|#set_active_cellview_index", &lay::LayoutView::set_active_cellview_index, gsi::arg ("index"), + gsi::method ("active_setview_index=|#set_active_cellview_index", &lay::LayoutViewBase::set_active_cellview_index, gsi::arg ("index"), "@brief Makes the cellview with the given index the active one (shown in hierarchy browser)\n" "See \\active_cellview_index.\n" "\n" @@ -933,7 +845,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This method has be introduced in version 0.25.\n" ) + - gsi::method ("#get_current_cell_path", static_cast (&lay::LayoutView::get_current_cell_path), gsi::arg ("cv_index"), + gsi::method ("#get_current_cell_path", static_cast (&lay::LayoutViewBase::get_current_cell_path), gsi::arg ("cv_index"), "@brief Gets the cell path of the current cell\n" "\n" "The current cell is the one highlighted in the browser with the focus rectangle. The \n" @@ -944,7 +856,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This method is was deprecated in version 0.25 since from then, the \\CellView object can be used to obtain an manipulate the selected cell." ) + - gsi::method ("#set_current_cell_path", static_cast (&lay::LayoutView::set_current_cell_path), gsi::arg ("cv_index"), gsi::arg ("cell_path"), + gsi::method ("#set_current_cell_path", static_cast (&lay::LayoutViewBase::set_current_cell_path), gsi::arg ("cv_index"), gsi::arg ("cell_path"), "@brief Sets the path to the current cell\n" "\n" "The current cell is the one highlighted in the browser with the focus rectangle. The\n" @@ -956,10 +868,10 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This method is was deprecated in version 0.25 since from then, the \\CellView object can be used to obtain an manipulate the selected cell." ) + - gsi::method ("cellviews", static_cast (&lay::LayoutView::cellviews), + gsi::method ("cellviews", static_cast (&lay::LayoutViewBase::cellviews), "@brief Gets the number of cellviews\n" ) + - gsi::method ("cellview", static_cast (&lay::LayoutView::cellview_ref), gsi::arg ("cv_index"), + gsi::method ("cellview", static_cast (&lay::LayoutViewBase::cellview_ref), gsi::arg ("cv_index"), "@brief Gets the cellview object for a given index\n" "\n" "@param cv_index The cellview index for which to get the object for\n" @@ -967,43 +879,43 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "Starting with version 0.25, this method returns a \\CellView object that can be manipulated to directly reflect " "any changes in the display." ) + - gsi::method ("zoom_fit", static_cast (&lay::LayoutView::zoom_fit), + gsi::method ("zoom_fit", static_cast (&lay::LayoutViewBase::zoom_fit), "@brief Fits the contents of the current view into the window" ) + - gsi::method ("zoom_fit_sel", static_cast (&lay::LayoutView::zoom_fit_sel), + gsi::method ("zoom_fit_sel", static_cast (&lay::LayoutViewBase::zoom_fit_sel), "@brief Fits the contents of the current selection into the window\n" "\n" "This method has been introduced in version 0.25.\n" ) + - gsi::method ("zoom_box", static_cast (&lay::LayoutView::zoom_box), gsi::arg ("box"), + gsi::method ("zoom_box", static_cast (&lay::LayoutViewBase::zoom_box), gsi::arg ("box"), "@brief Sets the viewport to the given box\n" "\n" "@param box The box to which to set the view in micron coordinates\n" ) + - gsi::method ("zoom_in", static_cast (&lay::LayoutView::zoom_in), + gsi::method ("zoom_in", static_cast (&lay::LayoutViewBase::zoom_in), "@brief Zooms in somewhat" ) + - gsi::method ("zoom_out", static_cast (&lay::LayoutView::zoom_out), + gsi::method ("zoom_out", static_cast (&lay::LayoutViewBase::zoom_out), "@brief Zooms out somewhat" ) + - gsi::method ("pan_up", static_cast (&lay::LayoutView::pan_up), + gsi::method ("pan_up", static_cast (&lay::LayoutViewBase::pan_up), "@brief Pans upward" ) + - gsi::method ("pan_down", static_cast (&lay::LayoutView::pan_down), + gsi::method ("pan_down", static_cast (&lay::LayoutViewBase::pan_down), "@brief Pans down" ) + - gsi::method ("pan_left", static_cast (&lay::LayoutView::pan_left), + gsi::method ("pan_left", static_cast (&lay::LayoutViewBase::pan_left), "@brief Pans to the left" ) + - gsi::method ("pan_right", static_cast (&lay::LayoutView::pan_right), + gsi::method ("pan_right", static_cast (&lay::LayoutViewBase::pan_right), "@brief Pans to the right" ) + - gsi::method ("pan_center", static_cast (&lay::LayoutView::pan_center), gsi::arg ("p"), + gsi::method ("pan_center", static_cast (&lay::LayoutViewBase::pan_center), gsi::arg ("p"), "@brief Pans to the given point\n" "\n" "The window is positioned such that \"p\" becomes the new center" ) + - gsi::method ("box", static_cast (&lay::LayoutView::box), + gsi::method ("box", static_cast (&lay::LayoutViewBase::box), "@brief Returns the displayed box in micron space" ) + gsi::method_ext ("viewport_trans", &viewport_trans, @@ -1021,22 +933,15 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "@brief Return the viewport height in pixels\n" "This method was introduced in version 0.18.\n" ) + -#if defined(HAVE_QT) - gsi::method ("bookmark_view", static_cast (&lay::LayoutView::bookmark_view), gsi::arg ("name"), - "@brief Bookmarks the current view under the given name\n" - "\n" - "@param name The name under which to bookmark the current state" - ) + -#endif - gsi::method ("add_missing_layers", static_cast (&lay::LayoutView::add_missing_layers), + gsi::method ("add_missing_layers", static_cast (&lay::LayoutViewBase::add_missing_layers), "@brief Adds new layers to layer list\n" "This method was introduced in version 0.19.\n" ) + - gsi::method ("remove_unused_layers", static_cast (&lay::LayoutView::remove_unused_layers), + gsi::method ("remove_unused_layers", static_cast (&lay::LayoutViewBase::remove_unused_layers), "@brief Removes unused layers from layer list\n" "This method was introduced in version 0.19.\n" ) + - gsi::method ("init_layer_properties", (void (lay::LayoutView::*) (lay::LayerProperties &) const) &lay::LayoutView::init_layer_properties, gsi::arg ("props"), + gsi::method ("init_layer_properties", (void (lay::LayoutViewBase::*) (lay::LayerProperties &) const) &lay::LayoutViewBase::init_layer_properties, gsi::arg ("props"), "@brief Fills the layer properties for a new layer\n" "\n" "This method initializes a layer properties object's color and stipples according to " @@ -1047,24 +952,24 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "@param props The layer properties object to initialize." ) + - gsi::method ("cancel", &lay::LayoutView::cancel, + gsi::method ("cancel", &lay::LayoutViewBase::cancel, "@brief Cancels all edit operations\n" "\n" "This method will stop all pending edit operations (i.e. drag and drop) and cancel the current " "selection. Calling this method is useful to ensure there are no potential interactions with the script's " "functionality.\n" ) + - gsi::method ("clear_selection", (void (lay::LayoutView::*) ()) &lay::LayoutView::clear_selection, + gsi::method ("clear_selection", (void (lay::LayoutViewBase::*) ()) &lay::LayoutViewBase::clear_selection, "@brief Clears the selection of all objects (shapes, annotations, images ...)\n" "\n" "This method has been introduced in version 0.26.2\n" ) + - gsi::method ("select_all", (void (lay::LayoutView::*) ()) &lay::LayoutView::select, + gsi::method ("select_all", (void (lay::LayoutViewBase::*) ()) &lay::LayoutViewBase::select, "@brief Selects all objects from the view\n" "\n" "This method has been introduced in version 0.27\n" ) + - gsi::method ("select_from", (void (lay::LayoutView::*) (const db::DPoint &, lay::Editable::SelectionMode)) &lay::LayoutView::select, gsi::arg ("point"), gsi::arg ("mode", lay::Editable::SelectionMode::Replace, "Replace"), + gsi::method ("select_from", (void (lay::LayoutViewBase::*) (const db::DPoint &, lay::Editable::SelectionMode)) &lay::LayoutViewBase::select, gsi::arg ("point"), gsi::arg ("mode", lay::Editable::SelectionMode::Replace, "Replace"), "@brief Selects the objects from a given point\n" "\n" "The mode indicates whether to add to the selection, replace the selection, remove from selection or invert the selected status of the objects " @@ -1072,7 +977,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This method has been introduced in version 0.27\n" ) + - gsi::method ("select_from", (void (lay::LayoutView::*) (const db::DBox &, lay::Editable::SelectionMode)) &lay::LayoutView::select, gsi::arg ("box"), gsi::arg ("mode", lay::Editable::SelectionMode::Replace, "Replace"), + gsi::method ("select_from", (void (lay::LayoutViewBase::*) (const db::DBox &, lay::Editable::SelectionMode)) &lay::LayoutViewBase::select, gsi::arg ("box"), gsi::arg ("mode", lay::Editable::SelectionMode::Replace, "Replace"), "@brief Selects the objects from a given box\n" "\n" "The mode indicates whether to add to the selection, replace the selection, remove from selection or invert the selected status of the objects " @@ -1080,12 +985,12 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This method has been introduced in version 0.27\n" ) + - gsi::method ("clear_transient_selection", static_cast (&lay::LayoutView::clear_transient_selection), + gsi::method ("clear_transient_selection", static_cast (&lay::LayoutViewBase::clear_transient_selection), "@brief Clears the transient selection (mouse-over hightlights) of all objects (shapes, annotations, images ...)\n" "\n" "This method has been introduced in version 0.26.2\n" ) + - gsi::method ("transient_to_selection", static_cast (&lay::LayoutView::transient_to_selection), + gsi::method ("transient_to_selection", static_cast (&lay::LayoutViewBase::transient_to_selection), "@brief Turns the transient selection into the actual selection\n" "\n" "The current selection is cleared before. All highlighted objects under the mouse will become selected. " @@ -1093,26 +998,26 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This method has been introduced in version 0.26.2\n" ) + - gsi::method ("selection_bbox", static_cast (&lay::LayoutView::selection_bbox), + gsi::method ("selection_bbox", static_cast (&lay::LayoutViewBase::selection_bbox), "@brief Returns the bounding box of the current selection\n" "\n" "This method has been introduced in version 0.26.2\n" ) + - gsi::method ("selection_size", (size_t (lay::LayoutView::*) ()) &lay::LayoutView::selection_size, + gsi::method ("selection_size", (size_t (lay::LayoutViewBase::*) ()) &lay::LayoutViewBase::selection_size, "@brief Returns the number of selected objects\n" "\n" "This method has been introduced in version 0.27\n" ) + - gsi::method ("has_selection?", (bool (lay::LayoutView::*) ()) &lay::LayoutView::has_selection, + gsi::method ("has_selection?", (bool (lay::LayoutViewBase::*) ()) &lay::LayoutViewBase::has_selection, "@brief Indicates whether any objects are selected\n" "\n" "This method has been introduced in version 0.27\n" ) + - gsi::method ("stop", static_cast (&lay::LayoutView::stop), + gsi::method ("stop", static_cast (&lay::LayoutViewBase::stop), "@brief Stops redraw thread and close any browsers\n" "This method usually does not need to be called explicitly. The redraw thread is stopped automatically." ) + - gsi::method ("#select_cell_path", (void (lay::LayoutView::*) (const lay::LayoutView::cell_path_type &, int)) &lay::LayoutView::select_cell, gsi::arg ("cell_index"), gsi::arg ("cv_index"), + gsi::method ("#select_cell_path", (void (lay::LayoutViewBase::*) (const lay::LayoutViewBase::cell_path_type &, int)) &lay::LayoutViewBase::select_cell, gsi::arg ("cell_index"), gsi::arg ("cv_index"), "@brief Selects a cell by cell index for a certain cell view\n" "\n" "Select the current (top) cell by specifying a cell indexand the cellview index for which this cell should become the currently shown one. The path to the cell is constructed by " @@ -1122,7 +1027,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This method is was deprecated in version 0.25 since from then, the \\CellView object can be used to obtain an manipulate the selected cell." ) + - gsi::method ("#select_cell", (void (lay::LayoutView::*) (lay::LayoutView::cell_index_type, int)) &lay::LayoutView::select_cell, gsi::arg ("cell_index"), gsi::arg ("cv_index"), + gsi::method ("#select_cell", (void (lay::LayoutViewBase::*) (lay::LayoutViewBase::cell_index_type, int)) &lay::LayoutViewBase::select_cell, gsi::arg ("cell_index"), gsi::arg ("cv_index"), "@brief Selects a cell by index for a certain cell view\n" "\n" "Select the current (top) cell by specifying a path (a list of cell indices from top to " @@ -1133,7 +1038,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This method is was deprecated in version 0.25 since from then, the \\CellView object can be used to obtain an manipulate the selected cell." ) + - gsi::method ("descend", static_cast &, int)> (&lay::LayoutView::descend), gsi::arg ("path"), gsi::arg ("index"), + gsi::method ("descend", static_cast &, int)> (&lay::LayoutViewBase::descend), gsi::arg ("path"), gsi::arg ("index"), "@brief Descends further into the hierarchy.\n" "\n" "Adds the given path (given as an array of InstElement objects) to the specific path of the " @@ -1143,33 +1048,33 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "The path is assumed to originate from the current cell and contain specific instances sorted from " "top to bottom." ) + - gsi::method ("ascend", static_cast (&lay::LayoutView::ascend), gsi::arg ("index"), + gsi::method ("ascend", static_cast (&lay::LayoutViewBase::ascend), gsi::arg ("index"), "@brief Ascends upwards in the hierarchy.\n" "\n" "Removes one element from the specific path of the cellview with the given index. Returns the element " "removed." ) + - gsi::method ("is_cell_hidden?", static_cast (&lay::LayoutView::is_cell_hidden), gsi::arg ("cell_index"), gsi::arg ("cv_index"), + gsi::method ("is_cell_hidden?", static_cast (&lay::LayoutViewBase::is_cell_hidden), gsi::arg ("cell_index"), gsi::arg ("cv_index"), "@brief Returns true, if the cell is hidden\n" "\n" "@return True, if the cell with \"cell_index\" is hidden for the cellview \"cv_index\"" ) + - gsi::method ("hide_cell", static_cast (&lay::LayoutView::hide_cell), gsi::arg ("cell_index"), gsi::arg ("cv_index"), + gsi::method ("hide_cell", static_cast (&lay::LayoutViewBase::hide_cell), gsi::arg ("cell_index"), gsi::arg ("cv_index"), "@brief Hides the given cell for the given cellview\n" ) + - gsi::method ("show_cell", static_cast (&lay::LayoutView::show_cell), gsi::arg ("cell_index"), gsi::arg ("cv_index"), + gsi::method ("show_cell", static_cast (&lay::LayoutViewBase::show_cell), gsi::arg ("cell_index"), gsi::arg ("cv_index"), "@brief Shows the given cell for the given cellview (cancel effect of \\hide_cell)\n" ) + - gsi::method ("show_all_cells", (void (lay::LayoutView::*) ()) &lay::LayoutView::show_all_cells, + gsi::method ("show_all_cells", (void (lay::LayoutViewBase::*) ()) &lay::LayoutViewBase::show_all_cells, "@brief Makes all cells shown (cancel effects of \\hide_cell)" ) + - gsi::method ("show_all_cells", (void (lay::LayoutView::*) (int)) &lay::LayoutView::show_all_cells, gsi::arg ("cv_index"), + gsi::method ("show_all_cells", (void (lay::LayoutViewBase::*) (int)) &lay::LayoutViewBase::show_all_cells, gsi::arg ("cv_index"), "@brief Makes all cells shown (cancel effects of \\hide_cell) for the specified cell view\n" "Unlike \\show_all_cells, this method will only clear the hidden flag on the cell view selected by \\cv_index.\n" "\n" "This variant has been added in version 0.25." ) + - gsi::method ("update_content", static_cast (&lay::LayoutView::force_update_content), + gsi::method ("update_content", static_cast (&lay::LayoutViewBase::force_update_content), "@brief Updates the layout view to the current state\n" "\n" "This method triggers an update of the hierarchy tree and layer view tree. Usually, this " @@ -1178,26 +1083,26 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "Currently, this method should be called however, after the layer view tree has been changed by " "the \\insert_layer, \\replace_layer_node or \\delete_layer methods.\n" ) + - gsi::method ("max_hier", static_cast (&lay::LayoutView::max_hier), + gsi::method ("max_hier", static_cast (&lay::LayoutViewBase::max_hier), "@brief Selects all hierarchy levels available\n" "\n" "Show the layout in full depth down to the deepest level of hierarchy. " "This method may cause a redraw." ) + - gsi::method ("resize", static_cast (&lay::LayoutView::resize), + gsi::method ("resize", static_cast (&lay::LayoutViewBase::resize), "@brief Resizes the layout view to the given dimension\n" "\n" "This method has been made available in all builds in 0.28.\n" ) + #if defined(HAVE_QT) && defined(HAVE_QTBINDINGS) - gsi::method ("get_screenshot", static_cast (&lay::LayoutView::get_screenshot), + gsi::method ("get_screenshot", static_cast (&lay::LayoutViewBase::get_screenshot), "@brief Gets a screenshot as a \\QImage\n" "\n" "Getting the image requires the drawing to be complete. Ideally, synchronous mode is switched on " "for the application to guarantee this condition. The image will have the size of the viewport " "showing the current layout." ) + - gsi::method ("get_image", static_cast (&lay::LayoutView::get_image), gsi::arg ("width"), gsi::arg ("height"), + gsi::method ("get_image", static_cast (&lay::LayoutViewBase::get_image), gsi::arg ("width"), gsi::arg ("height"), "@brief Gets the layout image as a \\QImage\n" "\n" "@param width The width of the image to render in pixel.\n" @@ -1224,7 +1129,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "This method has been introduced in 0.23.10.\n" ) + #endif - gsi::method ("get_screenshot_pixels", static_cast (&lay::LayoutView::get_screenshot_pb), + gsi::method ("get_screenshot_pixels", static_cast (&lay::LayoutViewBase::get_screenshot_pb), "@brief Gets a screenshot as a \\PixelBuffer\n" "\n" "Getting the image requires the drawing to be complete. Ideally, synchronous mode is switched on " @@ -1233,7 +1138,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This method has been introduced in 0.28.\n" ) + - gsi::method ("get_pixels", static_cast (&lay::LayoutView::get_pixels), gsi::arg ("width"), gsi::arg ("height"), + gsi::method ("get_pixels", static_cast (&lay::LayoutViewBase::get_pixels), gsi::arg ("width"), gsi::arg ("height"), "@brief Gets the layout image as a \\PixelBuffer\n" "\n" "@param width The width of the image to render in pixel.\n" @@ -1273,7 +1178,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This method has been introduced in 0.28.\n" ) + - gsi::method ("save_screenshot", static_cast (&lay::LayoutView::save_screenshot), gsi::arg ("filename"), + gsi::method ("save_screenshot", static_cast (&lay::LayoutViewBase::save_screenshot), gsi::arg ("filename"), "@brief Saves a screenshot to the given file\n" "\n" "@param filename The file to which to write the screenshot to.\n" @@ -1283,7 +1188,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "for the application to guarantee this condition. The image will have the size of the viewport " "showing the current layout." ) + - gsi::method ("save_image", static_cast (&lay::LayoutView::save_image), gsi::arg ("filename"), gsi::arg ("width"), gsi::arg ("height"), + gsi::method ("save_image", static_cast (&lay::LayoutViewBase::save_image), gsi::arg ("filename"), gsi::arg ("width"), gsi::arg ("height"), "@brief Saves the layout as an image to the given file\n" "\n" "@param filename The file to which to write the screenshot to.\n" @@ -1344,13 +1249,13 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "If the file name ends with a suffix \".gz\" or \".gzip\", the file is compressed with the zlib " "algorithm.\n" ) + - gsi::method ("set_layer_properties", static_cast (&lay::LayoutView::set_properties), gsi::arg ("iter"), gsi::arg ("props"), + gsi::method ("set_layer_properties", static_cast (&lay::LayoutViewBase::set_properties), gsi::arg ("iter"), gsi::arg ("props"), "@brief Sets the layer properties of the layer pointed to by the iterator\n" "\n" "This method replaces the layer properties of the element pointed to by \"iter\" by the properties " "given by \"props\". It will not change the hierarchy but just the properties of the given node." ) + - gsi::method ("set_layer_properties", static_cast (&lay::LayoutView::set_properties), gsi::arg ("index"), gsi::arg ("iter"), gsi::arg ("props"), + gsi::method ("set_layer_properties", static_cast (&lay::LayoutViewBase::set_properties), gsi::arg ("index"), gsi::arg ("iter"), gsi::arg ("props"), "@brief Sets the layer properties of the layer pointed to by the iterator\n" "\n" "This method replaces the layer properties of the element pointed to by \"iter\" by the properties " @@ -1358,7 +1263,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "This version addresses a specific list in a multi-tab layer properties arrangement with the \"index\" parameter. " "This method has been introduced in version 0.21.\n" ) + - gsi::method ("expand_layer_properties", (void (lay::LayoutView::*) ()) &lay::LayoutView::expand_properties, + gsi::method ("expand_layer_properties", (void (lay::LayoutViewBase::*) ()) &lay::LayoutViewBase::expand_properties, "@brief Expands the layer properties for all tabs\n" "\n" "This method will expand all wildcard specifications in the layer properties by iterating over the specified objects (i.e. layers, cellviews) and " @@ -1366,7 +1271,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This method was introduced in version 0.21.\n" ) + - gsi::method ("expand_layer_properties", (void (lay::LayoutView::*) (unsigned int)) &lay::LayoutView::expand_properties, gsi::arg ("index"), + gsi::method ("expand_layer_properties", (void (lay::LayoutViewBase::*) (unsigned int)) &lay::LayoutViewBase::expand_properties, gsi::arg ("index"), "@brief Expands the layer properties for the given tab\n" "\n" "This method will expand all wildcard specifications in the layer properties by iterating over the specified objects (i.e. layers, cellviews) and " @@ -1431,13 +1336,13 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "This version addresses a specific list in a multi-tab layer properties arrangement with the \"index\" parameter. " "This method has been introduced in version 0.22.\n" ) + - gsi::method ("delete_layer", (void (lay::LayoutView::*) (lay::LayerPropertiesConstIterator &iter)) &lay::LayoutView::delete_layer, gsi::arg ("iter"), + gsi::method ("delete_layer", (void (lay::LayoutViewBase::*) (lay::LayerPropertiesConstIterator &iter)) &lay::LayoutViewBase::delete_layer, gsi::arg ("iter"), "@brief Deletes the layer properties node specified by the iterator\n" "\n" "This method deletes the object that the iterator points to and invalidates\n" "the iterator since the object that the iterator points to is no longer valid.\n" ) + - gsi::method ("delete_layer", (void (lay::LayoutView::*) (unsigned int index, lay::LayerPropertiesConstIterator &iter)) &lay::LayoutView::delete_layer, gsi::arg ("index"), gsi::arg ("iter"), + gsi::method ("delete_layer", (void (lay::LayoutViewBase::*) (unsigned int index, lay::LayerPropertiesConstIterator &iter)) &lay::LayoutViewBase::delete_layer, gsi::arg ("index"), gsi::arg ("iter"), "@brief Deletes the layer properties node specified by the iterator\n" "\n" "This method deletes the object that the iterator points to and invalidates\n" @@ -1453,7 +1358,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "apply changes to the layer settings or even the hierarchy of layers:\n" "\n" "@code\n" - "RBA::LayoutView::current.each_layer do |lref|\n" + "RBA::LayoutViewBase::current.each_layer do |lref|\n" " # lref is a RBA::LayerPropertiesNodeRef object\n" " lref.visible = false\n" "end\n" @@ -1470,7 +1375,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This method was introduced in version 0.25." ) + - gsi::method ("begin_layers", (lay::LayerPropertiesConstIterator (lay::LayoutView::*) () const) &lay::LayoutView::begin_layers, + gsi::method ("begin_layers", (lay::LayerPropertiesConstIterator (lay::LayoutViewBase::*) () const) &lay::LayoutViewBase::begin_layers, "@brief Begin iterator for the layers\n" "\n" "This iterator delivers the layers of this view, either in a recursive or non-recursive\n" @@ -1481,11 +1386,11 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "Starting from version 0.25, an alternative solution is provided with 'each_layer' which is based on the " "\\LayerPropertiesNodeRef class." ) + - gsi::method ("end_layers", (lay::LayerPropertiesConstIterator (lay::LayoutView::*) () const) &lay::LayoutView::end_layers, + gsi::method ("end_layers", (lay::LayerPropertiesConstIterator (lay::LayoutViewBase::*) () const) &lay::LayoutViewBase::end_layers, "@brief End iterator for the layers\n" "See \\begin_layers for a description about this iterator\n" ) + - gsi::method ("begin_layers", (lay::LayerPropertiesConstIterator (lay::LayoutView::*) (unsigned int index) const) &lay::LayoutView::begin_layers, gsi::arg ("index"), + gsi::method ("begin_layers", (lay::LayerPropertiesConstIterator (lay::LayoutViewBase::*) (unsigned int index) const) &lay::LayoutViewBase::begin_layers, gsi::arg ("index"), "@brief Begin iterator for the layers\n" "\n" "This iterator delivers the layers of this view, either in a recursive or non-recursive\n" @@ -1495,44 +1400,44 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "This version addresses a specific list in a multi-tab layer properties arrangement with the \"index\" parameter. " "This method has been introduced in version 0.21.\n" ) + - gsi::method ("end_layers", (lay::LayerPropertiesConstIterator (lay::LayoutView::*) (unsigned int index) const) &lay::LayoutView::end_layers, gsi::arg ("index"), + gsi::method ("end_layers", (lay::LayerPropertiesConstIterator (lay::LayoutViewBase::*) (unsigned int index) const) &lay::LayoutViewBase::end_layers, gsi::arg ("index"), "@brief End iterator for the layers\n" "See \\begin_layers for a description about this iterator\n" "This version addresses a specific list in a multi-tab layer properties arrangement with the \"index\" parameter. " "This method has been introduced in version 0.21.\n" ) + - gsi::method ("clear_layers", (void (lay::LayoutView::*) ()) &lay::LayoutView::clear_layers, + gsi::method ("clear_layers", (void (lay::LayoutViewBase::*) ()) &lay::LayoutViewBase::clear_layers, "@brief Clears all layers\n" ) + - gsi::method ("clear_layers", (void (lay::LayoutView::*) (unsigned int index)) &lay::LayoutView::clear_layers, gsi::arg ("index"), + gsi::method ("clear_layers", (void (lay::LayoutViewBase::*) (unsigned int index)) &lay::LayoutViewBase::clear_layers, gsi::arg ("index"), "@brief Clears all layers for the given layer properties list\n" "This version addresses a specific list in a multi-tab layer properties arrangement with the \"index\" parameter. " "This method has been introduced in version 0.21.\n" ) + - gsi::method ("delete_layer_list", (void (lay::LayoutView::*) (unsigned int index)) &lay::LayoutView::delete_layer_list, gsi::arg ("index"), + gsi::method ("delete_layer_list", (void (lay::LayoutViewBase::*) (unsigned int index)) &lay::LayoutViewBase::delete_layer_list, gsi::arg ("index"), "@brief Deletes the given properties list\n" "At least one layer properties list must remain. This method may change the current properties list.\n" "This method has been introduced in version 0.21.\n" ) + - gsi::method ("insert_layer_list", (void (lay::LayoutView::*) (unsigned int index)) &lay::LayoutView::insert_layer_list, gsi::arg ("index"), + gsi::method ("insert_layer_list", (void (lay::LayoutViewBase::*) (unsigned int index)) &lay::LayoutViewBase::insert_layer_list, gsi::arg ("index"), "@brief Inserts a new layer properties list at the given index\n" "This method inserts a new tab at the given position. The current layer properties list will be changed to " "the new list.\n" "This method has been introduced in version 0.21.\n" ) + - gsi::method ("num_layer_lists", static_cast (&lay::LayoutView::layer_lists), + gsi::method ("num_layer_lists", static_cast (&lay::LayoutViewBase::layer_lists), "@brief Gets the number of layer properties tabs present\n" "This method has been introduced in version 0.23.\n" ) + - gsi::method ("current_layer_list", static_cast (&lay::LayoutView::current_layer_list), + gsi::method ("current_layer_list", static_cast (&lay::LayoutViewBase::current_layer_list), "@brief Gets the index of the currently selected layer properties tab\n" "This method has been introduced in version 0.21.\n" ) + - gsi::method ("current_layer_list=|#set_current_layer_list", static_cast (&lay::LayoutView::set_current_layer_list), gsi::arg ("index"), + gsi::method ("current_layer_list=|#set_current_layer_list", static_cast (&lay::LayoutViewBase::set_current_layer_list), gsi::arg ("index"), "@brief Sets the index of the currently selected layer properties tab\n" "This method has been introduced in version 0.21.\n" ) + - gsi::method ("rename_layer_list", static_cast (&lay::LayoutView::rename_properties), gsi::arg ("index"), gsi::arg ("name"), + gsi::method ("rename_layer_list", static_cast (&lay::LayoutViewBase::rename_properties), gsi::arg ("index"), gsi::arg ("name"), "@brief Sets the title of the given layer properties tab\n" "This method has been introduced in version 0.21.\n" ) + @@ -1622,34 +1527,34 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This method has been introduced in version 0.25." ) + - gsi::method ("current_layer", static_cast (&lay::LayoutView::current_layer), + gsi::method ("current_layer", static_cast (&lay::LayoutViewBase::current_layer), "@brief Gets the current layer view\n" "\n" "Returns the \\LayerPropertiesIterator pointing to the current layer view (the one that has the focus). " "If no layer view is active currently, a null iterator is returned.\n" ) + - gsi::method ("current_layer=", static_cast (&lay::LayoutView::set_current_layer), gsi::arg ("iter"), + gsi::method ("current_layer=", static_cast (&lay::LayoutViewBase::set_current_layer), gsi::arg ("iter"), "@brief Sets the current layer view\n" "\n" "Specifies an \\LayerPropertiesIterator pointing to the new current layer view.\n" "\n" "This method has been introduced in version 0.23.\n" ) + - gsi::method ("selected_layers", static_cast (lay::LayoutView::*) () const> (&lay::LayoutView::selected_layers), + gsi::method ("selected_layers", static_cast (lay::LayoutViewBase::*) () const> (&lay::LayoutViewBase::selected_layers), "@brief Gets the selected layers\n" "\n" "Returns an array of \\LayerPropertiesIterator objects pointing to the currently selected layers. " "If no layer view is selected currently, an empty array is returned.\n" ) + #if !defined(HAVE_QT) - gsi::event ("on_image_updated_event", static_cast (&lay::LayoutView::image_updated_event), + gsi::event ("on_image_updated_event", static_cast (&lay::LayoutViewBase::image_updated_event), "@brief An event indicating that the image (\"screenshot\") was updated\n" "\n" "This event is triggered when calling \\timer." "\n" "This event has been introduced in version 0.28." ) + - gsi::event ("on_drawing_finished_event", static_cast (&lay::LayoutView::drawing_finished_event), + gsi::event ("on_drawing_finished_event", static_cast (&lay::LayoutViewBase::drawing_finished_event), "@brief An event indicating that the image is fully drawn\n" "\n" "This event is triggered when calling \\timer. " @@ -1657,7 +1562,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This event has been introduced in version 0.28." ) + - gsi::method ("timer", static_cast (&lay::LayoutView::timer), + gsi::method ("timer", static_cast (&lay::LayoutViewBase::timer), "@brief A callback required to be called regularily in the non-Qt case.\n" "\n" "This callback eventually implements the event loop in the non-Qt case. The main task " @@ -1669,7 +1574,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "This method has been introduced in version 0.28." ) + #endif - gsi::event ("on_active_cellview_changed", static_cast (&lay::LayoutView::active_cellview_changed_event), + gsi::event ("on_active_cellview_changed", static_cast (&lay::LayoutViewBase::active_cellview_changed_event), "@brief An event indicating that the active cellview has changed\n" "\n" "If the active cellview is changed by selecting a new one from the drop-down list, this event is triggered.\n" @@ -1678,7 +1583,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "Before version 0.25 this event was based on the observer pattern obsolete now. The corresponding methods " "(add_active_cellview_changed/remove_active_cellview_changed) have been removed in 0.25.\n" ) + - gsi::event ("on_cellviews_changed", static_cast (&lay::LayoutView::cellviews_changed_event), + gsi::event ("on_cellviews_changed", static_cast (&lay::LayoutViewBase::cellviews_changed_event), "@brief An event indicating that the cellview collection has changed\n" "\n" "If new cellviews are added or cellviews are removed, this event is triggered.\n" @@ -1687,7 +1592,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "Before version 0.25 this event was based on the observer pattern obsolete now. The corresponding methods " "(add_cellview_list_observer/remove_cellview_list_observer) have been removed in 0.25.\n" ) + - gsi::event ("on_cellview_changed", static_cast (lay::LayoutView::*)> (&lay::LayoutView::cellview_changed_event), gsi::arg ("cellview_index"), + gsi::event ("on_cellview_changed", static_cast (lay::LayoutViewBase::*)> (&lay::LayoutViewBase::cellview_changed_event), gsi::arg ("cellview_index"), "@brief An event indicating that a cellview has changed\n" "\n" "If a cellview is modified, this event is triggered.\n" @@ -1697,7 +1602,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "Before version 0.25 this event was based on the observer pattern obsolete now. The corresponding methods " "(add_cellview_observer/remove_cellview_observer) have been removed in 0.25.\n" ) + - gsi::event ("on_file_open", static_cast (&lay::LayoutView::file_open_event), + gsi::event ("on_file_open", static_cast (&lay::LayoutViewBase::file_open_event), "@brief An event indicating that a file was opened\n" "\n" "If a file is loaded, this event is triggered.\n" @@ -1707,26 +1612,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "Before version 0.25 this event was based on the observer pattern obsolete now. The corresponding methods " "(add_file_open_observer/remove_file_open_observer) have been removed in 0.25.\n" ) + -#if defined(HAVE_QT) - gsi::event ("on_close", static_cast (&lay::LayoutView::close_event), - "@brief A event indicating that the view is about to close\n" - "\n" - "This event is triggered when the view is going to be closed entirely.\n" - "\n" - "It has been added in version 0.25." - ) + - gsi::event ("on_show", static_cast (&lay::LayoutView::show_event), - "@brief A event indicating that the view is going to become visible\n" - "\n" - "It has been added in version 0.25." - ) + - gsi::event ("on_hide", static_cast (&lay::LayoutView::hide_event), - "@brief A event indicating that the view is going to become invisible\n" - "\n" - "It has been added in version 0.25." - ) + -#endif - gsi::event ("on_viewport_changed", static_cast (&lay::LayoutView::viewport_changed_event), + gsi::event ("on_viewport_changed", static_cast (&lay::LayoutViewBase::viewport_changed_event), "@brief An event indicating that the viewport (the visible rectangle) has changed\n" "\n" "This event is triggered after a new display rectangle was chosen - for example, because the user " @@ -1735,7 +1621,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "Before version 0.25 this event was based on the observer pattern obsolete now. The corresponding methods " "(add_viewport_changed_observer/remove_viewport_changed_observer) have been removed in 0.25.\n" ) + - gsi::event ("on_layer_list_changed", static_cast (lay::LayoutView::*)> (&lay::LayoutView::layer_list_changed_event), gsi::arg ("flags"), + gsi::event ("on_layer_list_changed", static_cast (lay::LayoutViewBase::*)> (&lay::LayoutViewBase::layer_list_changed_event), gsi::arg ("flags"), "@brief An event indicating that the layer list has changed\n" "\n" "This event is triggered after the layer list has changed it's configuration.\n" @@ -1746,7 +1632,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "Before version 0.25 this event was based on the observer pattern obsolete now. The corresponding methods " "(add_layer_list_observer/remove_layer_list_observer) have been removed in 0.25.\n" ) + - gsi::event ("on_layer_list_inserted", static_cast (lay::LayoutView::*)> (&lay::LayoutView::layer_list_inserted_event), gsi::arg ("index"), + gsi::event ("on_layer_list_inserted", static_cast (lay::LayoutViewBase::*)> (&lay::LayoutViewBase::layer_list_inserted_event), gsi::arg ("index"), "@brief An event indicating that a layer list (a tab) has been inserted\n" "@param index The index of the layer list that was inserted\n" "\n" @@ -1754,7 +1640,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This event was introduced in version 0.25.\n" ) + - gsi::event ("on_layer_list_deleted", static_cast (lay::LayoutView::*)> (&lay::LayoutView::layer_list_deleted_event), gsi::arg ("index"), + gsi::event ("on_layer_list_deleted", static_cast (lay::LayoutViewBase::*)> (&lay::LayoutViewBase::layer_list_deleted_event), gsi::arg ("index"), "@brief An event indicating that a layer list (a tab) has been removed\n" "@param index The index of the layer list that was removed\n" "\n" @@ -1762,7 +1648,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This event was introduced in version 0.25.\n" ) + - gsi::event ("on_current_layer_list_changed", static_cast (lay::LayoutView::*)> (&lay::LayoutView::current_layer_list_changed_event), gsi::arg ("index"), + gsi::event ("on_current_layer_list_changed", static_cast (lay::LayoutViewBase::*)> (&lay::LayoutViewBase::current_layer_list_changed_event), gsi::arg ("index"), "@brief An event indicating the current layer list (the selected tab) has changed\n" "@param index The index of the new current layer list\n" "\n" @@ -1770,7 +1656,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This event was introduced in version 0.25.\n" ) + - gsi::event ("on_cell_visibility_changed", static_cast (&lay::LayoutView::cell_visibility_changed_event), + gsi::event ("on_cell_visibility_changed", static_cast (&lay::LayoutViewBase::cell_visibility_changed_event), "@brief An event indicating that the visibility of one or more cells has changed\n" "\n" "This event is triggered after the visibility of one or more cells has changed.\n" @@ -1780,7 +1666,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou ) + // HINT: the cast is important to direct GSI to the LayoutView member rather than the // Editables member (in which case we get a segmentation violation ..) - gsi::event ("on_transient_selection_changed", (tl::Event (lay::LayoutView::*)) &lay::LayoutView::transient_selection_changed_event, + gsi::event ("on_transient_selection_changed", (tl::Event (lay::LayoutViewBase::*)) &lay::LayoutViewBase::transient_selection_changed_event, "@brief An event that is triggered if the transient selection is changed\n" "\n" "If the transient selection is changed, this event is triggered.\n" @@ -1790,33 +1676,33 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou ) + // HINT: the cast is important to direct GSI to the LayoutView method rather than the // Editables method (in which case we get a segmentation violation ..) - gsi::event ("on_selection_changed", (tl::Event (lay::LayoutView::*)) &lay::LayoutView::selection_changed_event, + gsi::event ("on_selection_changed", (tl::Event (lay::LayoutViewBase::*)) &lay::LayoutViewBase::selection_changed_event, "@brief An event that is triggered if the selection is changed\n" "\n" "If the selection changed, this event is triggered.\n" "\n" "This event was translated from the Observer pattern to an event in version 0.25." ) + - gsi::event ("on_rdb_list_changed", static_cast (&lay::LayoutView::rdb_list_changed_event), + gsi::event ("on_rdb_list_changed", static_cast (&lay::LayoutViewBase::rdb_list_changed_event), "@brief An event that is triggered the list of report databases is changed\n" "\n" "If a report database is added or removed, this event is triggered.\n" "\n" "This event was translated from the Observer pattern to an event in version 0.25." ) + - gsi::method ("num_rdbs", static_cast (&lay::LayoutView::num_rdbs), + gsi::method ("num_rdbs", static_cast (&lay::LayoutViewBase::num_rdbs), "@brief Gets the number of report databases loaded into this view\n" "@return The number of \\ReportDatabase objects present in this view\n" ) + - gsi::method ("remove_rdb", static_cast (&lay::LayoutView::remove_rdb), gsi::arg ("index"), + gsi::method ("remove_rdb", static_cast (&lay::LayoutViewBase::remove_rdb), gsi::arg ("index"), "@brief Removes a report database with the given index\n" "@param The index of the report database to remove from this view" ) + - gsi::method ("rdb", static_cast (&lay::LayoutView::get_rdb), gsi::arg ("index"), + gsi::method ("rdb", static_cast (&lay::LayoutViewBase::get_rdb), gsi::arg ("index"), "@brief Gets the report database with the given index\n" "@return The \\ReportDatabase object or nil if the index is not valid" ) + - gsi::method ("add_rdb", static_cast (&lay::LayoutView::add_rdb), gsi::arg ("db"), + gsi::method ("add_rdb", static_cast (&lay::LayoutViewBase::add_rdb), gsi::arg ("db"), "@brief Adds the given report database to the view\n" "\n" "This method will add an existing database to the view. It will then appear in the marker database browser.\n" @@ -1826,7 +1712,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This method has been added in version 0.26." ) + - gsi::method ("replace_rdb", static_cast (&lay::LayoutView::replace_rdb), gsi::arg ("db_index"), gsi::arg ("db"), + gsi::method ("replace_rdb", static_cast (&lay::LayoutViewBase::replace_rdb), gsi::arg ("db_index"), gsi::arg ("db"), "@brief Replaces the report database with the given index\n" "\n" "If the index is not valid, the database will be added to the view (see \\add_rdb).\n" @@ -1843,39 +1729,32 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "If a report database with the given name already exists, a unique name will be created.\n" "The name will be replaced by the file name when a file is loaded into the report database.\n" ) + -#if defined(HAVE_QT) - gsi::method ("show_rdb", static_cast (&lay::LayoutView::open_rdb_browser), gsi::arg ("rdb_index"), gsi::arg ("cv_index"), - "@brief Shows a report database in the marker browser on a certain layout\n" - "The marker browser is opened showing the report database with the index given by \"rdb_index\".\n" - "It will be attached (i.e. navigate to) the layout with the given cellview index in \"cv_index\".\n" - ) + -#endif - gsi::event ("on_l2ndb_list_changed", static_cast (&lay::LayoutView::l2ndb_list_changed_event), + gsi::event ("on_l2ndb_list_changed", static_cast (&lay::LayoutViewBase::l2ndb_list_changed_event), "@brief An event that is triggered the list of netlist databases is changed\n" "\n" "If a netlist database is added or removed, this event is triggered.\n" "\n" "This method has been added in version 0.26." ) + - gsi::method ("num_l2ndbs", static_cast (&lay::LayoutView::num_l2ndbs), + gsi::method ("num_l2ndbs", static_cast (&lay::LayoutViewBase::num_l2ndbs), "@brief Gets the number of netlist databases loaded into this view\n" "@return The number of \\LayoutToNetlist objects present in this view\n" "\n" "This method has been added in version 0.26." ) + - gsi::method ("remove_l2ndb", static_cast (&lay::LayoutView::remove_l2ndb), gsi::arg ("index"), + gsi::method ("remove_l2ndb", static_cast (&lay::LayoutViewBase::remove_l2ndb), gsi::arg ("index"), "@brief Removes a netlist database with the given index\n" "@param The index of the netlist database to remove from this view" "\n" "This method has been added in version 0.26." ) + - gsi::method ("l2ndb", static_cast (&lay::LayoutView::get_l2ndb), gsi::arg ("index"), + gsi::method ("l2ndb", static_cast (&lay::LayoutViewBase::get_l2ndb), gsi::arg ("index"), "@brief Gets the netlist database with the given index\n" "@return The \\LayoutToNetlist object or nil if the index is not valid" "\n" "This method has been added in version 0.26." ) + - gsi::method ("add_l2ndb", static_cast (&lay::LayoutView::add_l2ndb), gsi::arg ("db"), + gsi::method ("add_l2ndb", static_cast (&lay::LayoutViewBase::add_l2ndb), gsi::arg ("db"), "@brief Adds the given netlist database to the view\n" "\n" "This method will add an existing database to the view. It will then appear in the netlist database browser.\n" @@ -1885,7 +1764,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This method has been added in version 0.26." ) + - gsi::method ("replace_l2ndb", static_cast (&lay::LayoutView::replace_l2ndb), gsi::arg ("db_index"), gsi::arg ("db"), + gsi::method ("replace_l2ndb", static_cast (&lay::LayoutViewBase::replace_l2ndb), gsi::arg ("db_index"), gsi::arg ("db"), "@brief Replaces the netlist database with the given index\n" "\n" "If the index is not valid, the database will be added to the view (see \\add_lvsdb).\n" @@ -1904,15 +1783,6 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This method has been added in version 0.26." ) + -#if defined(HAVE_QT) - gsi::method ("show_l2ndb", static_cast (&lay::LayoutView::open_l2ndb_browser), gsi::arg ("l2ndb_index"), gsi::arg ("cv_index"), - "@brief Shows a netlist database in the marker browser on a certain layout\n" - "The netlist browser is opened showing the netlist database with the index given by \"l2ndb_index\".\n" - "It will be attached (i.e. navigate to) the layout with the given cellview index in \"cv_index\".\n" - "\n" - "This method has been added in version 0.26." - ) + -#endif gsi::method_ext ("lvsdb", &get_lvsdb, gsi::arg ("index"), "@brief Gets the netlist database with the given index\n" "@return The \\LayoutVsSchematic object or nil if the index is not valid" @@ -1948,21 +1818,12 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This method has been added in version 0.26." ) + -#if defined(HAVE_QT) - gsi::method ("show_lvsdb", static_cast (&lay::LayoutView::open_l2ndb_browser), gsi::arg ("lvsdb_index"), gsi::arg ("cv_index"), - "@brief Shows a netlist database in the marker browser on a certain layout\n" - "The netlist browser is opened showing the netlist database with the index given by \"lvsdb_index\".\n" - "It will be attached (i.e. navigate to) the layout with the given cellview index in \"cv_index\".\n" - "\n" - "This method has been added in version 0.26." - ) + -#endif // HINT: the cast is important to direct GSI to the LayoutView method rather than the // Plugin method (in which case we get a segmentation violation ..) // TODO: this method belongs to the Plugin interface and should be located there. // Change this once there is a mixin concept available and the Plugin interface can // be mixed into LayoutView. - gsi::method ("clear_config", (void (lay::LayoutView::*)()) &lay::LayoutView::clear_config, + gsi::method ("clear_config", (void (lay::LayoutViewBase::*)()) &lay::LayoutViewBase::clear_config, "@brief Clears the local configuration parameters\n" "\n" "See \\set_config for a description of the local configuration parameters." @@ -1983,7 +1844,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou // TODO: this method belongs to the Plugin interface and should be located there. // Change this once there is a mixin concept available and the Plugin interface can // be mixed into LayoutView. - gsi::method ("get_config", (std::string (lay::LayoutView::*)(const std::string &name) const) &lay::LayoutView::config_get, gsi::arg ("name"), + gsi::method ("get_config", (std::string (lay::LayoutViewBase::*)(const std::string &name) const) &lay::LayoutViewBase::config_get, gsi::arg ("name"), "@brief Gets the value of a local configuration parameter\n" "\n" "@param name The name of the configuration parameter whose value shall be obtained (a string)\n" @@ -1995,7 +1856,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou // TODO: this method belongs to the Plugin interface and should be located there. // Change this once there is a mixin concept available and the Plugin interface can // be mixed into LayoutView. - gsi::method ("set_config", (void (lay::LayoutView::*)(const std::string &name, const std::string &value)) &lay::LayoutView::config_set, gsi::arg ("name"), gsi::arg ("value"), + gsi::method ("set_config", (void (lay::LayoutViewBase::*)(const std::string &name, const std::string &value)) &lay::LayoutViewBase::config_set, gsi::arg ("name"), gsi::arg ("value"), "@brief Sets a local configuration parameter with the given name to the given value\n" "\n" "@param name The name of the configuration parameter to set\n" @@ -2010,7 +1871,7 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou // TODO: this method belongs to the Plugin interface and should be located there. // Change this once there is a mixin concept available and the Plugin interface can // be mixed into LayoutView. - gsi::method ("commit_config", (void (lay::LayoutView::*)()) &lay::LayoutView::config_end, + gsi::method ("commit_config", (void (lay::LayoutViewBase::*)()) &lay::LayoutViewBase::config_end, "@brief Commits the configuration settings\n" "\n" "Some configuration options are queued for performance reasons and become active only after 'commit_config' has been called. " @@ -2118,14 +1979,11 @@ Class decl_LayoutView (QT_EXTERNAL_BASE (QWidget) "lay", "Layou "\n" "This method was introduced in version 0.28." ), - "@brief The view object presenting one or more layout objects\n" - "\n" - "The visual part of the view is the tab panel in the main window. The non-visual part " - "are the redraw thread, the layout handles, cell lists, layer view lists etc. " - "This object controls these aspects of the view and controls the appearance of the data. " + "@hide\n" + "@alias LayoutView\n" ); -gsi::EnumIn decl_layLayoutView_SelectionMode ("lay", "SelectionMode", +gsi::EnumIn decl_layLayoutView_SelectionMode ("lay", "SelectionMode", gsi::enum_const ("Add", lay::Editable::SelectionMode::Add, "@brief Adds to any existing selection\n" ) + @@ -2144,7 +2002,7 @@ gsi::EnumIn decl_layLayoutView_Se ); // Inject the NetlistCrossReference::Status declarations into NetlistCrossReference: -gsi::ClassExt inject_SelectionMode_in_parent (decl_layLayoutView_SelectionMode.defs ()); +gsi::ClassExt inject_SelectionMode_in_parent (decl_layLayoutView_SelectionMode.defs ()); static db::Layout *get_layout (const lay::CellViewRef *cv) { @@ -2211,21 +2069,6 @@ static tl::Event &get_technology_changed_event (lay::CellViewRef *cv) return (*cv)->technology_changed_event; } -#if defined(HAVE_QT) -static lay::CellViewRef get_active_cellview_ref () -{ - lay::LayoutView *view = lay::LayoutView::current (); - if (! view) { - return lay::CellViewRef (); - } - if (view->active_cellview_index () >= 0) { - return view->active_cellview_ref (); - } else { - return lay::CellViewRef (); - } -} -#endif - static void set_cell (lay::CellViewRef *cv, db::Cell *cell) { if (! cell) { @@ -2304,11 +2147,6 @@ static void cv_show_all_cells (lay::CellViewRef *cv) } } -static lay::LayoutView *get_view (lay::CellViewRef *cv) -{ - return cv->view ()->ui (); -} - Class decl_CellView ("lay", "CellView", method ("==", static_cast (&lay::CellViewRef::operator==), gsi::arg ("other"), "@brief Equality: indicates whether the cellviews refer to the same one\n" @@ -2320,24 +2158,6 @@ Class decl_CellView ("lay", "CellView", "The index will be negative if the cellview is not a valid one.\n" "This method has been added in version 0.25.\n" ) + - method_ext ("view", &get_view, - "@brief Gets the view the cellview resides in\n" - "This reference will be nil if the cellview is not a valid one.\n" - "This method has been added in version 0.25.\n" - ) + -#if defined(HAVE_QT) - method ("active", &get_active_cellview_ref, - "@brief Gets the active CellView\n" - "The active CellView is the one that is selected in the current layout view. This method is " - "equivalent to\n" - "@code\n" - "RBA::LayoutView::current.active_cellview\n" - "@/code\n" - "If no CellView is active, this method returns nil.\n" - "\n" - "This method has been introduced in version 0.23." - ) + -#endif method ("is_valid?", &lay::CellViewRef::is_valid, "@brief Returns true, if the cellview is valid\n" "A cellview may become invalid if the corresponding tab is closed for example." diff --git a/src/laybasic/laybasic/gsiDeclLayMarker.cc b/src/laybasic/laybasic/gsiDeclLayMarker.cc index 83dfc7ca7..8ecfb49bb 100644 --- a/src/laybasic/laybasic/gsiDeclLayMarker.cc +++ b/src/laybasic/laybasic/gsiDeclLayMarker.cc @@ -23,13 +23,13 @@ #include "gsiDecl.h" #include "layMarker.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" namespace gsi { static -lay::DMarker *create_marker (lay::LayoutView *view) +lay::DMarker *create_marker (lay::LayoutViewBase *view) { return new lay::DMarker (view); } diff --git a/src/laybasic/laybasic/gsiDeclLayPlugin.cc b/src/laybasic/laybasic/gsiDeclLayPlugin.cc index f45415cf9..bce28aa52 100644 --- a/src/laybasic/laybasic/gsiDeclLayPlugin.cc +++ b/src/laybasic/laybasic/gsiDeclLayPlugin.cc @@ -25,7 +25,7 @@ #include "gsiDeclBasic.h" #include "layPlugin.h" #include "layViewObject.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "layCursor.h" namespace gsi @@ -40,7 +40,7 @@ namespace gsi // since PluginBase object are only allowed to be created inside the create_plugin method // of the factory, this hack is a quick but dirty workaround. static bool s_in_create_plugin = false; -static lay::LayoutView *sp_view = 0; +static lay::LayoutViewBase *sp_view = 0; static lay::Dispatcher *sp_dispatcher = 0; class PluginBase @@ -393,7 +393,7 @@ public: } } - virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *root, lay::LayoutView *view) const + virtual lay::Plugin *create_plugin (db::Manager *manager, lay::Dispatcher *root, lay::LayoutViewBase *view) const { if (f_create_plugin.can_issue ()) { return create_plugin_gsi (manager, root, view); @@ -402,7 +402,7 @@ public: } } - virtual gsi::PluginBase *create_plugin_gsi (db::Manager *manager, lay::Dispatcher *root, lay::LayoutView *view) const + virtual gsi::PluginBase *create_plugin_gsi (db::Manager *manager, lay::Dispatcher *root, lay::LayoutViewBase *view) const { // TODO: this is a hack. See notes above at s_in_create_plugin s_in_create_plugin = true; @@ -410,7 +410,7 @@ public: sp_dispatcher = root; gsi::PluginBase *ret = 0; try { - ret = f_create_plugin.issue (&PluginFactoryBase::create_plugin_gsi, manager, root, view); + ret = f_create_plugin.issue (&PluginFactoryBase::create_plugin_gsi, manager, root, view); s_in_create_plugin = false; sp_view = 0; sp_dispatcher = 0; diff --git a/src/laybasic/laybasic/layBookmarkList.cc b/src/laybasic/laybasic/layBookmarkList.cc index dcffe8e15..79e8b2f55 100644 --- a/src/laybasic/laybasic/layBookmarkList.cc +++ b/src/laybasic/laybasic/layBookmarkList.cc @@ -20,8 +20,6 @@ */ -#if defined(HAVE_QT) - #include "layBookmarkList.h" #include "tlXMLParser.h" @@ -118,6 +116,3 @@ BookmarkList::propose_new_bookmark_name () const } } - -#endif - diff --git a/src/laybasic/laybasic/layBookmarkList.h b/src/laybasic/laybasic/layBookmarkList.h index 9d4090d53..86225863d 100644 --- a/src/laybasic/laybasic/layBookmarkList.h +++ b/src/laybasic/laybasic/layBookmarkList.h @@ -20,8 +20,6 @@ */ -#if defined(HAVE_QT) - #ifndef HDR_layBookmarkList #define HDR_layBookmarkList @@ -208,5 +206,3 @@ private: } // namespace lay #endif - -#endif // defined(HAVE_QT) diff --git a/src/laybasic/laybasic/layCellView.cc b/src/laybasic/laybasic/layCellView.cc index f71e1e512..c3d5fe319 100644 --- a/src/laybasic/laybasic/layCellView.cc +++ b/src/laybasic/laybasic/layCellView.cc @@ -22,7 +22,7 @@ #include "layCellView.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #if defined(HAVE_QT) # include "layStream.h" #endif diff --git a/src/laybasic/laybasic/layCellView.h b/src/laybasic/laybasic/layCellView.h index 632b7d304..679ca8854 100644 --- a/src/laybasic/laybasic/layCellView.h +++ b/src/laybasic/laybasic/layCellView.h @@ -36,10 +36,10 @@ #include "dbSaveLayoutOptions.h" #include "dbLoadLayoutOptions.h" #include "dbInstElement.h" +#include "dbTechnology.h" #include "gsi.h" #if defined(HAVE_QT) -# include "layTechnology.h" # include "tlFileSystemWatcher.h" #endif diff --git a/src/laybasic/laybasic/layEditorServiceBase.cc b/src/laybasic/laybasic/layEditorServiceBase.cc index 55b9c44f2..ea6f5fcff 100644 --- a/src/laybasic/laybasic/layEditorServiceBase.cc +++ b/src/laybasic/laybasic/layEditorServiceBase.cc @@ -22,7 +22,7 @@ #include "layEditorServiceBase.h" #include "layViewport.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "laybasicConfig.h" #include "layConverters.h" @@ -206,7 +206,7 @@ private: // -------------------------------------------------------------------------------------- -EditorServiceBase::EditorServiceBase (LayoutView *view) +EditorServiceBase::EditorServiceBase (LayoutViewBase *view) : lay::ViewService (view->view_object_widget ()), lay::Editable (view), lay::Plugin (view), diff --git a/src/laybasic/laybasic/layEditorServiceBase.h b/src/laybasic/laybasic/layEditorServiceBase.h index de44983ea..166f85245 100644 --- a/src/laybasic/laybasic/layEditorServiceBase.h +++ b/src/laybasic/laybasic/layEditorServiceBase.h @@ -46,7 +46,7 @@ public: /** * @brief Constructor */ - EditorServiceBase (lay::LayoutView *view); + EditorServiceBase (lay::LayoutViewBase *view); /** * @brief Destructor diff --git a/src/laybasic/laybasic/layFinder.cc b/src/laybasic/laybasic/layFinder.cc index cc6ea038a..214705fc4 100644 --- a/src/laybasic/laybasic/layFinder.cc +++ b/src/laybasic/laybasic/layFinder.cc @@ -86,7 +86,7 @@ Finder::closer (double d) } void -Finder::start (lay::LayoutView *view, const lay::CellView &cv, unsigned int cv_index, const std::vector &trans, const db::Box ®ion, int min_level, int max_level, const std::vector &layers) +Finder::start (lay::LayoutViewBase *view, const lay::CellView &cv, unsigned int cv_index, const std::vector &trans, const db::Box ®ion, int min_level, int max_level, const std::vector &layers) { m_layers = layers; m_region = region; @@ -265,7 +265,7 @@ struct LPContextCompareOp }; bool -ShapeFinder::find (LayoutView *view, const db::DBox ®ion_mu) +ShapeFinder::find (LayoutViewBase *view, const db::DBox ®ion_mu) { tl::AbsoluteProgress progress (tl::to_string (tr ("Selecting ..."))); progress.set_unit (1000); @@ -330,7 +330,7 @@ ShapeFinder::find (LayoutView *view, const db::DBox ®ion_mu) } bool -ShapeFinder::find (lay::LayoutView *view, const lay::LayerProperties &lprops, const db::DBox ®ion_mu) +ShapeFinder::find (lay::LayoutViewBase *view, const lay::LayerProperties &lprops, const db::DBox ®ion_mu) { tl::AbsoluteProgress progress (tl::to_string (tr ("Selecting ..."))); progress.set_unit (1000); @@ -349,7 +349,7 @@ ShapeFinder::find (lay::LayoutView *view, const lay::LayerProperties &lprops, co } bool -ShapeFinder::find_internal (lay::LayoutView *view, unsigned int cv_index, const std::set *prop_sel, bool inv_prop_sel, const lay::HierarchyLevelSelection &hier_sel, const std::vector &trans_mu, const std::vector &layers, const db::DBox ®ion_mu) +ShapeFinder::find_internal (lay::LayoutViewBase *view, unsigned int cv_index, const std::set *prop_sel, bool inv_prop_sel, const lay::HierarchyLevelSelection &hier_sel, const std::vector &trans_mu, const std::vector &layers, const db::DBox ®ion_mu) { m_cv_index = cv_index; @@ -624,7 +624,7 @@ InstFinder::InstFinder (bool point_mode, bool top_level_sel, bool full_arrays, b } bool -InstFinder::find (lay::LayoutView *view, const db::DBox ®ion_mu) +InstFinder::find (lay::LayoutViewBase *view, const db::DBox ®ion_mu) { tl::AbsoluteProgress progress (tl::to_string (tr ("Selecting ..."))); progress.set_unit (1000); @@ -641,7 +641,7 @@ InstFinder::find (lay::LayoutView *view, const db::DBox ®ion_mu) } bool -InstFinder::find (LayoutView *view, unsigned int cv_index, const db::DCplxTrans &trans_mu, const db::DBox ®ion_mu) +InstFinder::find (LayoutViewBase *view, unsigned int cv_index, const db::DCplxTrans &trans_mu, const db::DBox ®ion_mu) { tl::AbsoluteProgress progress (tl::to_string (tr ("Selecting ..."))); progress.set_unit (1000); @@ -655,7 +655,7 @@ InstFinder::find (LayoutView *view, unsigned int cv_index, const db::DCplxTrans } bool -InstFinder::find_internal (LayoutView *view, unsigned int cv_index, const db::DCplxTrans &trans_mu, const db::DBox ®ion_mu) +InstFinder::find_internal (LayoutViewBase *view, unsigned int cv_index, const db::DCplxTrans &trans_mu, const db::DBox ®ion_mu) { const lay::CellView &cv = view->cellview (cv_index); if (! cv.is_valid ()) { diff --git a/src/laybasic/laybasic/layFinder.h b/src/laybasic/laybasic/layFinder.h index 5b7608de7..a89f73a48 100644 --- a/src/laybasic/laybasic/layFinder.h +++ b/src/laybasic/laybasic/layFinder.h @@ -29,7 +29,7 @@ #include #include "tlVector.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "dbBoxConvert.h" #include "dbLayout.h" #include "dbBox.h" @@ -136,7 +136,7 @@ protected: return m_max_level; } - lay::LayoutView *view () const + lay::LayoutViewBase *view () const { return mp_view; } @@ -153,7 +153,7 @@ protected: * path of instantiations up to the top cell is maintained and accessible by * the path() accessor. */ - void start (LayoutView *view, const lay::CellView &cv, unsigned int cv_index, const std::vector &trans, const db::Box ®ion, int min_level, int max_level, const std::vector &layers = std::vector ()); + void start (LayoutViewBase *view, const lay::CellView &cv, unsigned int cv_index, const std::vector &trans, const db::Box ®ion, int min_level, int max_level, const std::vector &layers = std::vector ()); /** * @brief Provide a basic edge test facility @@ -186,7 +186,7 @@ private: int m_min_level, m_max_level; std::vector m_path; const db::Layout *mp_layout; - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; unsigned int m_cv_index; db::Box m_region; std::vector m_layers; @@ -214,8 +214,8 @@ public: ShapeFinder (bool point_mode, bool top_level_sel, db::ShapeIterator::flags_type flags, const std::set *excludes = 0); - bool find (LayoutView *view, const lay::LayerProperties &lprops, const db::DBox ®ion_mu); - bool find (LayoutView *view, const db::DBox ®ion_mu); + bool find (LayoutViewBase *view, const lay::LayerProperties &lprops, const db::DBox ®ion_mu); + bool find (LayoutViewBase *view, const db::DBox ®ion_mu); iterator begin () const { @@ -262,7 +262,7 @@ protected: private: virtual void visit_cell (const db::Cell &cell, const db::Box &search_box, const db::ICplxTrans &t, int /*level*/); - bool find_internal (LayoutView *view, + bool find_internal (LayoutViewBase *view, unsigned int cv_index, const std::set *prop_sel, bool inv_prop_sel, @@ -300,8 +300,8 @@ public: InstFinder (bool point_mode, bool top_level_sel, bool full_arrays, bool enclose_inst = true, const std::set *excludes = 0, bool visible_layers = false); - bool find (LayoutView *view, unsigned int cv_index, const db::DCplxTrans &trans, const db::DBox ®ion_mu); - bool find (LayoutView *view, const db::DBox ®ion_mu); + bool find (LayoutViewBase *view, unsigned int cv_index, const db::DCplxTrans &trans, const db::DBox ®ion_mu); + bool find (LayoutViewBase *view, const db::DBox ®ion_mu); iterator begin () const { @@ -315,7 +315,7 @@ public: private: virtual void visit_cell (const db::Cell &cell, const db::Box &search_box, const db::ICplxTrans &t, int level); - bool find_internal (LayoutView *view, unsigned int cv_index, const db::DCplxTrans &trans_mu, const db::DBox ®ion_mu); + bool find_internal (LayoutViewBase *view, unsigned int cv_index, const db::DCplxTrans &trans_mu, const db::DBox ®ion_mu); unsigned int m_cv_index; db::cell_index_type m_topcell; diff --git a/src/laybasic/laybasic/layLayerProperties.cc b/src/laybasic/laybasic/layLayerProperties.cc index 7b9476a92..7855cc1de 100644 --- a/src/laybasic/laybasic/layLayerProperties.cc +++ b/src/laybasic/laybasic/layLayerProperties.cc @@ -23,7 +23,6 @@ #include "layLayerProperties.h" #include "layLayoutViewBase.h" -#include "layLayoutView.h" #include "layConverters.h" #include "tlXMLParser.h" #include "tlException.h" @@ -405,7 +404,7 @@ class LayerSourceEval : public tl::Eval { public: - LayerSourceEval (const lay::LayerProperties &lp, const lay::LayoutView *view, bool real) + LayerSourceEval (const lay::LayerProperties &lp, const lay::LayoutViewBase *view, bool real) : m_lp (lp), mp_view (view), m_real (real) { // .. nothing yet .. @@ -416,14 +415,14 @@ public: return m_lp.source (m_real); } - const lay::LayoutView *view () const + const lay::LayoutViewBase *view () const { return mp_view; } private: const lay::LayerProperties &m_lp; - const lay::LayoutView *mp_view; + const lay::LayoutViewBase *mp_view; bool m_real; }; @@ -499,7 +498,7 @@ LayerProperties::display_string (const lay::LayoutViewBase *view, bool real, boo realize_source (); } - LayerSourceEval eval (*this, view->ui (), real); + LayerSourceEval eval (*this, view, real); eval.define_function ("N", new LayerSourceEvalFunction ('N', &eval)); // layer name eval.define_function ("L", new LayerSourceEvalFunction ('L', &eval)); // layer number eval.define_function ("D", new LayerSourceEvalFunction ('D', &eval)); // datatype @@ -1373,7 +1372,7 @@ expand_wildcard_layers (const LayerPropertiesNode &lp, const LayerPropertiesList // NOTE: initialization through LayerProperties creates a new ID lay::LayerPropertiesNode node ((const LayerProperties &) lp); - node.attach_view (view->ui (), list_index); + node.attach_view (view, list_index); // Build a new ParsedLayerSource combining the transformation, hierarchy levels and // property selections from the wildcard one and the requested layer source diff --git a/src/laybasic/laybasic/layLayoutCanvas.cc b/src/laybasic/laybasic/layLayoutCanvas.cc index 482c5806f..22bddfc51 100644 --- a/src/laybasic/laybasic/layLayoutCanvas.cc +++ b/src/laybasic/laybasic/layLayoutCanvas.cc @@ -32,7 +32,7 @@ #include "tlAssert.h" #include "layLayoutCanvas.h" #include "layRedrawThread.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "layMarker.h" #if defined(HAVE_QT) # include "gtf.h" diff --git a/src/laybasic/laybasic/layLayoutViewBase.cc b/src/laybasic/laybasic/layLayoutViewBase.cc index b1d183639..cd8af3a8c 100644 --- a/src/laybasic/laybasic/layLayoutViewBase.cc +++ b/src/laybasic/laybasic/layLayoutViewBase.cc @@ -39,7 +39,6 @@ #include "layViewOp.h" #include "layViewObject.h" #include "layConverters.h" -#include "layGridNet.h" #include "layMove.h" #include "layZoomBox.h" #include "layMouseTracker.h" @@ -236,6 +235,22 @@ struct OpDeleteLayerProps const double animation_interval = 0.5; +LayoutViewBase::LayoutViewBase (db::Manager *manager, bool editable, lay::Plugin *plugin_parent, unsigned int options) + : lay::Dispatcher (plugin_parent, false /*not standalone*/), +#if defined(HAVE_QT) + mp_widget (0), +#endif + mp_ui (0), + m_editable (editable), + m_options (options), + m_annotation_shapes (manager) +{ + // either it's us or the parent has a dispatcher + tl_assert (dispatcher () != 0); + + init (manager); +} + #if defined(HAVE_QT) LayoutViewBase::LayoutViewBase (QWidget *widget, lay::LayoutView *ui, db::Manager *manager, bool editable, lay::Plugin *plugin_parent, unsigned int options) #else @@ -576,7 +591,7 @@ void LayoutViewBase::create_plugins (const lay::PluginDeclaration *except_this) lay::Plugin *LayoutViewBase::create_plugin (const lay::PluginDeclaration *cls) { - lay::Plugin *p = cls->create_plugin (manager (), dispatcher (), ui ()); + lay::Plugin *p = cls->create_plugin (manager (), dispatcher (), this); if (p) { // unhook the plugin from the script side if created there (prevent GC from destroying it) @@ -1351,7 +1366,7 @@ LayoutViewBase::insert_layer_list (unsigned index, const LayerPropertiesList &pr clear_layer_selection (); m_layer_properties_lists.insert (m_layer_properties_lists.begin () + index, new LayerPropertiesList (props)); - m_layer_properties_lists [index]->attach_view (ui (), index); + m_layer_properties_lists [index]->attach_view (this, index); merge_dither_pattern (*m_layer_properties_lists [index]); m_current_layer_list = index; @@ -1560,7 +1575,7 @@ LayoutViewBase::set_properties (unsigned int index, const LayerPropertiesList &p return; } else { m_layer_properties_lists.push_back (new LayerPropertiesList ()); - m_layer_properties_lists.back ()->attach_view (ui (), (unsigned int) (m_layer_properties_lists.size () - 1)); + m_layer_properties_lists.back ()->attach_view (this, (unsigned int) (m_layer_properties_lists.size () - 1)); } } @@ -1579,7 +1594,7 @@ LayoutViewBase::set_properties (unsigned int index, const LayerPropertiesList &p } *m_layer_properties_lists [index] = props; - m_layer_properties_lists [index]->attach_view (ui (), index); + m_layer_properties_lists [index]->attach_view (this, index); merge_dither_pattern (*m_layer_properties_lists [index]); @@ -1997,7 +2012,7 @@ LayoutViewBase::signal_layer_properties_changed () // recompute the source // TODO: this is a side effect of this method - provide a special method for this purpose for (unsigned int i = 0; i < layer_lists (); ++i) { - m_layer_properties_lists [i]->attach_view (ui (), i); + m_layer_properties_lists [i]->attach_view (this, i); } // schedule a redraw request - since the layer views might not have changed, this is necessary @@ -2013,7 +2028,7 @@ LayoutViewBase::signal_prop_ids_changed () // recompute the source // TODO: this is a side effect of this method - provide a special method for this purpose for (unsigned int i = 0; i < layer_lists (); ++i) { - m_layer_properties_lists [i]->attach_view (ui (), i); + m_layer_properties_lists [i]->attach_view (this, i); } } @@ -2278,6 +2293,21 @@ LayoutViewBase::signal_apply_technology (lay::LayoutHandle *layout_handle) } } +void +LayoutViewBase::bookmarks (const BookmarkList &b) +{ + m_bookmarks = b; + bookmarks_changed (); +} + +void +LayoutViewBase::bookmark_view (const std::string &name) +{ + DisplayState state (box (), get_min_hier_levels (), get_max_hier_levels (), cellview_list ()); + m_bookmarks.add (name, state); + bookmarks_changed (); +} + void LayoutViewBase::load_layer_props (const std::string &fn) { @@ -2320,7 +2350,7 @@ LayoutViewBase::do_load_layer_props (const std::string &fn, bool map_cv, int cv_ if (map_cv) { cv_map.insert (std::make_pair (-1, cv_index)); } - p->attach_view (ui (), p - props.begin ()); + p->attach_view (this, p - props.begin ()); p->expand (cv_map, add_default); } @@ -3236,7 +3266,7 @@ LayoutViewBase::create_initial_layer_props (int cv_index, const std::string &lyp // expand the wildcards and map to the target cv. for (std::vector::iterator p = props.begin (); p != props.end (); ++p) { - p->attach_view (ui (), p - props.begin ()); + p->attach_view (this, p - props.begin ()); p->expand (cv_map, add_missing || !loaded); } diff --git a/src/laybasic/laybasic/layLayoutViewBase.h b/src/laybasic/laybasic/layLayoutViewBase.h index 742f3fccc..c4b43ce36 100644 --- a/src/laybasic/laybasic/layLayoutViewBase.h +++ b/src/laybasic/laybasic/layLayoutViewBase.h @@ -35,6 +35,7 @@ #include "layLayerProperties.h" #include "layAnnotationShapes.h" +#include "layBookmarkList.h" #include "layDispatcher.h" #include "layLayoutCanvas.h" #include "layColorPalette.h" @@ -74,8 +75,11 @@ class MouseTracker; class ZoomService; class SelectionService; class MoveService; -class ColorButton; -class ConfigureAction; + +#if defined(HAVE_QT) +class LayerControlPanel; +class HierarchyControlPanel; +#endif /** * @brief Stores a layer reference to create layers which have been added by some action @@ -156,7 +160,6 @@ class LAYBASIC_PUBLIC LayoutViewBase : public: typedef lay::CellView::unspecific_cell_path_type cell_path_type; typedef lay::CellView::cell_index_type cell_index_type; - typedef std::pair bookmark_type; /** * @brief Define some options for the view @@ -180,6 +183,11 @@ public: enum drop_small_cells_cond_type { DSC_Max = 0, DSC_Min = 1, DSC_Sum = 2 }; + /** + * @brief Stand-alone Constructor + */ + LayoutViewBase (db::Manager *mgr, bool editable, lay::Plugin *plugin_parent, unsigned int options = (unsigned int) LV_Normal); + /** * @brief Constructor */ @@ -798,6 +806,24 @@ public: */ void load_layer_props (const std::string &fn, int cv_index, bool add_default); + /** + * @brief Bookmark the current view under the given name + */ + void bookmark_view (const std::string &name); + + /** + * @brief Obtain the bookmarks list + */ + const BookmarkList &bookmarks () const + { + return m_bookmarks; + } + + /** + * @brief Set the bookmarks list + */ + void bookmarks (const BookmarkList &b); + /** * @brief Save the screen content to a file */ @@ -1629,6 +1655,24 @@ public: return mp_canvas; } +#if defined(HAVE_QT) + /** + * @brief Gets the layer control panel + */ + virtual lay::LayerControlPanel *control_panel () + { + return 0; + } + + /** + * @brief Gets the hierarchy panel + */ + virtual lay::HierarchyControlPanel *hierarchy_panel () + { + return 0; + } +#endif + /** * @brief Get the current viewport */ @@ -1839,6 +1883,15 @@ public: */ virtual void drop_url (const std::string &path_or_url); + /** + * @brief Returns true if the layer control panels model got updated + * Internally used by CellTreeModel to synchronize + */ + virtual bool layer_model_updated () + { + return false; + } + /** * @brief Gets a list of all plugins */ @@ -2308,6 +2361,11 @@ public: return (unsigned int) m_rdbs.size (); } + /** + * @brief Open the RDB browser for a given database and associated cv index + */ + virtual void open_rdb_browser (int /*rdb_index*/, int /*cv_index*/) { } + /** * @brief An event signalling a change in the marker database list * @@ -2369,6 +2427,11 @@ public: return (unsigned int) m_l2ndbs.size (); } + /** + * @brief Open the L2NDB browser for a given database and associated cv index + */ + virtual void open_l2ndb_browser (int /*l2ndb_index*/, int /*cv_index*/) { } + /** * @brief An event signalling a change in the netlist database list * @@ -2691,6 +2754,8 @@ private: std::vector m_display_states; unsigned int m_display_state_ptr; + BookmarkList m_bookmarks; + std::vector m_layer_properties_lists; unsigned int m_current_layer_list; @@ -2792,6 +2857,8 @@ protected: virtual void update_content_for_cv (int cv_index); virtual bool set_hier_levels_basic (std::pair l); + virtual void bookmarks_changed () { } + void ensure_layer_selected (); void enable_active_cellview_changed_event (bool enable, bool silent = false); diff --git a/src/laybasic/laybasic/layMarker.cc b/src/laybasic/laybasic/layMarker.cc index 729f4fbcd..93b298099 100644 --- a/src/laybasic/laybasic/layMarker.cc +++ b/src/laybasic/laybasic/layMarker.cc @@ -29,7 +29,7 @@ #include "layCanvasPlane.h" #include "layViewOp.h" #include "layRenderer.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "tlAssert.h" namespace lay @@ -188,7 +188,7 @@ void render_cell_inst (const db::Layout &layout, const db::CellInstArray &inst, // ------------------------------------------------------------------------ -MarkerBase::MarkerBase (lay::LayoutView *view) +MarkerBase::MarkerBase (lay::LayoutViewBase *view) : lay::ViewObject (view->view_object_widget ()), m_line_width (-1), m_vertex_size (-1), m_halo (-1), m_text_enabled (true), m_vertex_shape (lay::ViewOp::Rect), m_line_style (-1), m_dither_pattern (-1), m_frame_pattern (0), mp_view (view) { @@ -372,7 +372,7 @@ MarkerBase::get_bitmaps (const Viewport & /*vp*/, ViewObjectCanvas &canvas, lay: // ------------------------------------------------------------------------ -GenericMarkerBase::GenericMarkerBase (lay::LayoutView *view, unsigned int cv_index) +GenericMarkerBase::GenericMarkerBase (lay::LayoutViewBase *view, unsigned int cv_index) : MarkerBase (view), mp_trans_vector (0), mp_view (view), m_cv_index (cv_index) { // .. nothing yet .. @@ -496,7 +496,7 @@ GenericMarkerBase::dbu () const // ------------------------------------------------------------------------ -InstanceMarker::InstanceMarker (LayoutView *view, unsigned int cv_index, bool draw_outline, size_t max_shapes) +InstanceMarker::InstanceMarker (LayoutViewBase *view, unsigned int cv_index, bool draw_outline, size_t max_shapes) : GenericMarkerBase (view, cv_index), m_draw_outline (draw_outline), m_max_shapes (max_shapes), m_inst () { // .. nothing yet .. @@ -576,7 +576,7 @@ InstanceMarker::item_bbox () const // ------------------------------------------------------------------------ -ShapeMarker::ShapeMarker (LayoutView *view, unsigned int cv_index) +ShapeMarker::ShapeMarker (LayoutViewBase *view, unsigned int cv_index) : GenericMarkerBase (view, cv_index), m_shape () { // .. nothing yet .. @@ -643,7 +643,7 @@ ShapeMarker::item_bbox () const // ------------------------------------------------------------------------ -Marker::Marker (lay::LayoutView *view, unsigned int cv_index, bool draw_outline, size_t max_shapes) +Marker::Marker (lay::LayoutViewBase *view, unsigned int cv_index, bool draw_outline, size_t max_shapes) : GenericMarkerBase (view, cv_index), m_draw_outline (draw_outline), m_max_shapes (max_shapes) { m_type = None; @@ -1135,7 +1135,7 @@ Marker::render (const Viewport &vp, ViewObjectCanvas &canvas) // ------------------------------------------------------------------------ -DMarker::DMarker (LayoutView *view) +DMarker::DMarker (LayoutViewBase *view) : MarkerBase (view), mp_view (view) { m_type = None; diff --git a/src/laybasic/laybasic/layMarker.h b/src/laybasic/laybasic/layMarker.h index 7b18deab6..2cc4a4133 100644 --- a/src/laybasic/laybasic/layMarker.h +++ b/src/laybasic/laybasic/layMarker.h @@ -44,7 +44,7 @@ namespace lay { -class LayoutView; +class LayoutViewBase; /** * @brief The marker base class @@ -59,7 +59,7 @@ public: /** * @brief The constructor */ - MarkerBase (lay::LayoutView *view); + MarkerBase (lay::LayoutViewBase *view); /** * @brief Get the color by which the marker is drawn @@ -232,7 +232,7 @@ protected: bool m_text_enabled; lay::ViewOp::Shape m_vertex_shape; int m_line_style, m_dither_pattern, m_frame_pattern; - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; }; /** @@ -252,7 +252,7 @@ public: /** * @brief The constructor */ - GenericMarkerBase (lay::LayoutView *view, unsigned int cv_index); + GenericMarkerBase (lay::LayoutViewBase *view, unsigned int cv_index); /** * @brief The destructor @@ -321,7 +321,7 @@ public: /** * @brief Gets the view object */ - lay::LayoutView *view () const + lay::LayoutViewBase *view () const { return mp_view; } @@ -344,7 +344,7 @@ public: private: db::CplxTrans m_trans; std::vector *mp_trans_vector; - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; unsigned int m_cv_index; /** @@ -367,7 +367,7 @@ public: /** * @brief The constructor */ - ShapeMarker (lay::LayoutView *view, unsigned int cv_index); + ShapeMarker (lay::LayoutViewBase *view, unsigned int cv_index); /** * @brief The destructor @@ -418,7 +418,7 @@ public: * @param draw_outline True to have instances drawing their outline * @param max_shapes The maximum number of shapes to draw for instances (just a box is drawn if more shapes are present) */ - InstanceMarker (lay::LayoutView *view, unsigned int cv_index, bool draw_outline = true, size_t max_shapes = 0); + InstanceMarker (lay::LayoutViewBase *view, unsigned int cv_index, bool draw_outline = true, size_t max_shapes = 0); /** * @brief The destructor @@ -508,7 +508,7 @@ public: * @param draw_outline True to have instances drawing their outline * @param max_shapes The maximum number of shapes to draw for instances (just a box is drawn if more shapes are present) */ - Marker (lay::LayoutView *view, unsigned int cv_index, bool draw_outline = true, size_t max_shapes = 0); + Marker (lay::LayoutViewBase *view, unsigned int cv_index, bool draw_outline = true, size_t max_shapes = 0); /** * @brief The destructor @@ -743,7 +743,7 @@ public: /** * @brief The constructor */ - DMarker (lay::LayoutView *view); + DMarker (lay::LayoutViewBase *view); /** * @brief The destructor @@ -806,7 +806,7 @@ private: void *any; } m_object; - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; }; } diff --git a/src/laybasic/laybasic/layMouseTracker.cc b/src/laybasic/laybasic/layMouseTracker.cc index f84a48779..9afc48058 100644 --- a/src/laybasic/laybasic/layMouseTracker.cc +++ b/src/laybasic/laybasic/layMouseTracker.cc @@ -23,7 +23,7 @@ #include "layMouseTracker.h" #include "layLayoutCanvas.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" namespace lay { diff --git a/src/laybasic/laybasic/layMove.cc b/src/laybasic/laybasic/layMove.cc index da4264da4..bc22b0332 100644 --- a/src/laybasic/laybasic/layMove.cc +++ b/src/laybasic/laybasic/layMove.cc @@ -24,7 +24,7 @@ #include "layMove.h" #include "layEditable.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "laySelector.h" #include "laybasicConfig.h" diff --git a/src/laybasic/laybasic/layObjectInstPath.cc b/src/laybasic/laybasic/layObjectInstPath.cc index 48ec1167e..8d8f5a870 100644 --- a/src/laybasic/laybasic/layObjectInstPath.cc +++ b/src/laybasic/laybasic/layObjectInstPath.cc @@ -26,7 +26,6 @@ #include "layObjectInstPath.h" #include "layCellView.h" -#include "layLayoutView.h" #include "tlException.h" namespace lay { diff --git a/src/laybasic/laybasic/layParsedLayerSource.cc b/src/laybasic/laybasic/layParsedLayerSource.cc index 1b05eaefe..66130f12f 100644 --- a/src/laybasic/laybasic/layParsedLayerSource.cc +++ b/src/laybasic/laybasic/layParsedLayerSource.cc @@ -22,7 +22,7 @@ #include "layParsedLayerSource.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "tlString.h" #include "tlGlobPattern.h" diff --git a/src/laybasic/laybasic/layPlugin.h b/src/laybasic/laybasic/layPlugin.h index 8d95da611..84244ce2c 100644 --- a/src/laybasic/laybasic/layPlugin.h +++ b/src/laybasic/laybasic/layPlugin.h @@ -48,7 +48,7 @@ namespace lay class Plugin; class Dispatcher; -class LayoutView; +class LayoutViewBase; class ViewService; class Editable; class Drawing; @@ -302,7 +302,7 @@ public: * This method may return 0 for "dummy" plugins that just register menu entries * or configuration options. */ - virtual lay::Plugin *create_plugin (db::Manager * /*manager*/, lay::Dispatcher * /*dispatcher*/, lay::LayoutView * /*view*/) const + virtual lay::Plugin *create_plugin (db::Manager * /*manager*/, lay::Dispatcher * /*dispatcher*/, lay::LayoutViewBase * /*view*/) const { return 0; } @@ -329,7 +329,7 @@ public: * * The new pages are returned in the "pages" vector. The layout view will take ownership of these pages. */ - virtual void get_editor_options_pages (std::vector & /*pages*/, lay::LayoutView * /*view*/, lay::Dispatcher * /*dispatcher*/) const + virtual void get_editor_options_pages (std::vector & /*pages*/, lay::LayoutViewBase * /*view*/, lay::Dispatcher * /*dispatcher*/) const { // .. no pages in the default implementation .. } diff --git a/src/laybasic/laybasic/layPluginConfigPage.h b/src/laybasic/laybasic/layPluginConfigPage.h index fa3362281..73c40b82a 100644 --- a/src/laybasic/laybasic/layPluginConfigPage.h +++ b/src/laybasic/laybasic/layPluginConfigPage.h @@ -33,7 +33,6 @@ namespace lay { class Dispatcher; -class EditorOptionsPage; /** * @brief The base class for configuration pages diff --git a/src/laybasic/laybasic/layRedrawThread.h b/src/laybasic/laybasic/layRedrawThread.h index 4dc328aff..dadba6755 100644 --- a/src/laybasic/laybasic/layRedrawThread.h +++ b/src/laybasic/laybasic/layRedrawThread.h @@ -32,7 +32,7 @@ #include "dbTrans.h" #include "dbLayout.h" #include "layRenderer.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "layRedrawThreadCanvas.h" #include "layRedrawLayerInfo.h" #include "layCanvasPlane.h" diff --git a/src/laybasic/laybasic/layRedrawThreadWorker.cc b/src/laybasic/laybasic/layRedrawThreadWorker.cc index 2a7614177..16c97bc60 100644 --- a/src/laybasic/laybasic/layRedrawThreadWorker.cc +++ b/src/laybasic/laybasic/layRedrawThreadWorker.cc @@ -70,7 +70,7 @@ RedrawThreadWorker::RedrawThreadWorker (RedrawThread *redraw_thread) m_default_text_size = 0.0; m_drop_small_cells = false; m_drop_small_cells_value = 0; - m_drop_small_cells_cond = lay::LayoutView::DSC_Min; + m_drop_small_cells_cond = lay::LayoutViewBase::DSC_Min; m_draw_array_border_instances = false; m_abstract_mode_width = 0; m_child_context_enabled = false; @@ -2097,9 +2097,9 @@ RedrawThreadWorker::drop_cell (const db::Cell &cell, const db::CplxTrans &trans) db::DBox bbox = trans * cell.bbox (); double value = 0; - if (m_drop_small_cells_cond == lay::LayoutView::DSC_Min) { + if (m_drop_small_cells_cond == lay::LayoutViewBase::DSC_Min) { value = std::min (bbox.width (), bbox.height ()); - } else if (m_drop_small_cells_cond == lay::LayoutView::DSC_Max) { + } else if (m_drop_small_cells_cond == lay::LayoutViewBase::DSC_Max) { value = std::max (bbox.width (), bbox.height ()); } else { value = bbox.width () + bbox.height (); diff --git a/src/laybasic/laybasic/layRedrawThreadWorker.h b/src/laybasic/laybasic/layRedrawThreadWorker.h index 68cc2e264..256ad2ac0 100644 --- a/src/laybasic/laybasic/layRedrawThreadWorker.h +++ b/src/laybasic/laybasic/layRedrawThreadWorker.h @@ -25,7 +25,7 @@ #define HDR_layRedrawThreadWorker #include "dbLayout.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "tlThreadedWorkers.h" #include "tlTimer.h" @@ -221,7 +221,7 @@ private: double m_default_text_size; bool m_drop_small_cells; unsigned int m_drop_small_cells_value; - lay::LayoutView::drop_small_cells_cond_type m_drop_small_cells_cond; + lay::LayoutViewBase::drop_small_cells_cond_type m_drop_small_cells_cond; bool m_draw_array_border_instances; double m_abstract_mode_width; bool m_child_context_enabled; @@ -231,7 +231,7 @@ private: std::set , lay::CellVariantCacheCompare> *mp_cell_var_cache; unsigned int m_cache_hits, m_cache_misses; std::set > m_box_variants; - std::vector > m_hidden_cells; + std::vector > m_hidden_cells; std::vector m_cellviews; const db::Layout *mp_layout; int m_cv_index; diff --git a/src/laybasic/laybasic/laySelector.cc b/src/laybasic/laybasic/laySelector.cc index a6bd77b4d..1db1fd427 100644 --- a/src/laybasic/laybasic/laySelector.cc +++ b/src/laybasic/laybasic/laySelector.cc @@ -24,7 +24,7 @@ #include "laySelector.h" #include "layRubberBox.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "tlLog.h" #include "tlException.h" diff --git a/src/laybasic/laybasic/laySnap.cc b/src/laybasic/laybasic/laySnap.cc index 14b7d004b..c123da738 100644 --- a/src/laybasic/laybasic/laySnap.cc +++ b/src/laybasic/laybasic/laySnap.cc @@ -23,7 +23,7 @@ #include "laySnap.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "dbEdge.h" @@ -282,7 +282,7 @@ public: * This will run the finder on the given view. * "search_range" is the search range in micron units. */ - void find (lay::LayoutView *view, double search_range) + void find (lay::LayoutViewBase *view, double search_range) { if (! view) { return; @@ -586,7 +586,7 @@ private: } void - do_find (lay::LayoutView *view, int cv_index, const db::Cell &cell, unsigned int l, int min_level, int max_level, const db::CplxTrans &t) + do_find (lay::LayoutViewBase *view, int cv_index, const db::Cell &cell, unsigned int l, int min_level, int max_level, const db::CplxTrans &t) { db::Box touch_box = t.inverted () * m_region; @@ -727,7 +727,7 @@ private: }; static PointSnapToObjectResult -do_obj_snap (lay::LayoutView *view, const db::DPoint &pt, const db::DVector &grid, double snap_range, const std::vector &cutlines) +do_obj_snap (lay::LayoutViewBase *view, const db::DPoint &pt, const db::DVector &grid, double snap_range, const std::vector &cutlines) { db::DPoint dp (pt); @@ -792,7 +792,7 @@ do_obj_snap (lay::LayoutView *view, const db::DPoint &pt, const db::DVector &gri } static TwoPointSnapToObjectResult -do_obj_snap2 (lay::LayoutView *view, const db::DPoint &pt1, const db::DPoint &pt2, const db::DVector &grid, double min_search_range, double max_search_range, const std::vector &cutlines) +do_obj_snap2 (lay::LayoutViewBase *view, const db::DPoint &pt1, const db::DPoint &pt2, const db::DVector &grid, double min_search_range, double max_search_range, const std::vector &cutlines) { db::DPoint dp1 (pt1); db::DPoint dp2 (pt2); @@ -915,13 +915,13 @@ make_cutlines (lay::angle_constraint_type snap_mode, const db::DPoint &p1, std:: } PointSnapToObjectResult -obj_snap (lay::LayoutView *view, const db::DPoint &pt, const db::DVector &grid, double snap_range) +obj_snap (lay::LayoutViewBase *view, const db::DPoint &pt, const db::DVector &grid, double snap_range) { return do_obj_snap (view, pt, grid, snap_range, std::vector ()); } PointSnapToObjectResult -obj_snap (lay::LayoutView *view, const db::DPoint &p1, const db::DPoint &p2, const db::DVector &grid, lay::angle_constraint_type snap_mode, double snap_range) +obj_snap (lay::LayoutViewBase *view, const db::DPoint &p1, const db::DPoint &p2, const db::DVector &grid, lay::angle_constraint_type snap_mode, double snap_range) { std::vector cutlines; make_cutlines (snap_mode, p1, cutlines); @@ -929,19 +929,19 @@ obj_snap (lay::LayoutView *view, const db::DPoint &p1, const db::DPoint &p2, con } TwoPointSnapToObjectResult -obj_snap2 (lay::LayoutView *view, const db::DPoint &pt, const db::DVector &grid, double min_search_range, double max_search_range) +obj_snap2 (lay::LayoutViewBase *view, const db::DPoint &pt, const db::DVector &grid, double min_search_range, double max_search_range) { return obj_snap2 (view, pt, pt, grid, min_search_range, max_search_range); } TwoPointSnapToObjectResult -obj_snap2 (lay::LayoutView *view, const db::DPoint &pt, const db::DVector &grid, lay::angle_constraint_type ac, double min_search_range, double max_search_range) +obj_snap2 (lay::LayoutViewBase *view, const db::DPoint &pt, const db::DVector &grid, lay::angle_constraint_type ac, double min_search_range, double max_search_range) { return obj_snap2 (view, pt, pt, grid, ac, min_search_range, max_search_range); } TwoPointSnapToObjectResult -obj_snap2 (lay::LayoutView *view, const db::DPoint &pt1, const db::DPoint &pt2, const db::DVector &grid, double min_search_range, double max_search_range) +obj_snap2 (lay::LayoutViewBase *view, const db::DPoint &pt1, const db::DPoint &pt2, const db::DVector &grid, double min_search_range, double max_search_range) { db::DPoint dp1 = lay::snap_xy (pt1, grid); db::DPoint dp2 = lay::snap_xy (pt2, grid); @@ -950,7 +950,7 @@ obj_snap2 (lay::LayoutView *view, const db::DPoint &pt1, const db::DPoint &pt2, } TwoPointSnapToObjectResult -obj_snap2 (lay::LayoutView *view, const db::DPoint &pt1, const db::DPoint &pt2, const db::DVector &grid, lay::angle_constraint_type snap_mode, double min_search_range, double max_search_range) +obj_snap2 (lay::LayoutViewBase *view, const db::DPoint &pt1, const db::DPoint &pt2, const db::DVector &grid, lay::angle_constraint_type snap_mode, double min_search_range, double max_search_range) { db::DPoint dp1 = lay::snap_xy (pt1, grid); db::DPoint dp2 = lay::snap_xy (pt2, grid); diff --git a/src/laybasic/laybasic/laySnap.h b/src/laybasic/laybasic/laySnap.h index 19ebcc05c..eaa26ae4c 100644 --- a/src/laybasic/laybasic/laySnap.h +++ b/src/laybasic/laybasic/laySnap.h @@ -41,7 +41,7 @@ namespace lay { - class LayoutView; + class LayoutViewBase; /** * @brief An angle constraint type @@ -154,7 +154,7 @@ namespace lay * @param grid Either (0,0) to disable grid snapping or a (gx,gy) value for the (potentially anisotropic grid) * @param snap_range The search range for objects */ - LAYBASIC_PUBLIC PointSnapToObjectResult obj_snap (lay::LayoutView *view, const db::DPoint &pt, const db::DVector &grid, double snap_range); + LAYBASIC_PUBLIC PointSnapToObjectResult obj_snap (lay::LayoutViewBase *view, const db::DPoint &pt, const db::DVector &grid, double snap_range); /** * @brief combined grid-, projection- and object snapping provided to implementing "magnetic features" @@ -162,7 +162,7 @@ namespace lay * This is a convenience method that creates the projection axes from a reference point and an angle mode. * "pr" is the reference point, "pt" is the point to snap. */ - LAYBASIC_PUBLIC PointSnapToObjectResult obj_snap (lay::LayoutView *view, const db::DPoint &pr, const db::DPoint &pt, const db::DVector &grid, lay::angle_constraint_type ac, double snap_range); + LAYBASIC_PUBLIC PointSnapToObjectResult obj_snap (lay::LayoutViewBase *view, const db::DPoint &pr, const db::DPoint &pt, const db::DVector &grid, lay::angle_constraint_type ac, double snap_range); /** * @brief A structure describing the snap result for a two-sided object snap (distance measurement) @@ -208,7 +208,7 @@ namespace lay * This method basically implements "auto measure". The first value of the returned pair * is true if such an edge could be found. Otherwise it's false. */ - LAYBASIC_PUBLIC TwoPointSnapToObjectResult obj_snap2 (lay::LayoutView *view, const db::DPoint &pt, const db::DVector &grid, double min_search_range, double max_search_range); + LAYBASIC_PUBLIC TwoPointSnapToObjectResult obj_snap2 (LayoutViewBase *view, const db::DPoint &pt, const db::DVector &grid, double min_search_range, double max_search_range); /** * @brief Same than obj_snap, but delivers two points on two opposite sides of the initial points @@ -218,14 +218,14 @@ namespace lay * * This version accepts two points defining different search regions for first and second edge. */ - LAYBASIC_PUBLIC TwoPointSnapToObjectResult obj_snap2 (lay::LayoutView *view, const db::DPoint &pt1, const db::DPoint &pt2, const db::DVector &grid, double min_search_range, double max_search_range); + LAYBASIC_PUBLIC TwoPointSnapToObjectResult obj_snap2 (lay::LayoutViewBase *view, const db::DPoint &pt1, const db::DPoint &pt2, const db::DVector &grid, double min_search_range, double max_search_range); /** * @brief Same than the previous obj_snap2, but allows specification of an angle constraint * * Measurements will be confined to the direction specified. */ - LAYBASIC_PUBLIC TwoPointSnapToObjectResult obj_snap2 (lay::LayoutView *view, const db::DPoint &pt, const db::DVector &grid, lay::angle_constraint_type ac, double min_search_range, double max_search_range); + LAYBASIC_PUBLIC TwoPointSnapToObjectResult obj_snap2 (lay::LayoutViewBase *view, const db::DPoint &pt, const db::DVector &grid, lay::angle_constraint_type ac, double min_search_range, double max_search_range); /** * @brief Same than the previous obj_snap2, but allows specification of an angle constraint @@ -234,7 +234,7 @@ namespace lay * * This version accepts two points defining different search regions for first and second edge. */ - LAYBASIC_PUBLIC TwoPointSnapToObjectResult obj_snap2 (lay::LayoutView *view, const db::DPoint &pt1, const db::DPoint &pt2, const db::DVector &grid, lay::angle_constraint_type ac, double min_search_range, double max_search_range); + LAYBASIC_PUBLIC TwoPointSnapToObjectResult obj_snap2 (lay::LayoutViewBase *view, const db::DPoint &pt1, const db::DPoint &pt2, const db::DVector &grid, lay::angle_constraint_type ac, double min_search_range, double max_search_range); /** * @brief Reduce a given vector according to the angle constraint diff --git a/src/laybasic/laybasic/layStream.cc b/src/laybasic/laybasic/layStream.cc index 0da6346ec..e467be83e 100644 --- a/src/laybasic/laybasic/layStream.cc +++ b/src/laybasic/laybasic/layStream.cc @@ -25,7 +25,6 @@ #include "layStream.h" #include "layPlugin.h" #include "laybasicConfig.h" -#include "layTechnology.h" #include "dbStream.h" #include "dbLoadLayoutOptions.h" #include "dbSaveLayoutOptions.h" diff --git a/src/laybasic/laybasic/layZoomBox.cc b/src/laybasic/laybasic/layZoomBox.cc index 97f080aa5..26538d076 100644 --- a/src/laybasic/laybasic/layZoomBox.cc +++ b/src/laybasic/laybasic/layZoomBox.cc @@ -23,7 +23,7 @@ #include "layZoomBox.h" #include "layRubberBox.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" namespace lay { diff --git a/src/laybasic/laybasic/laybasic.pro b/src/laybasic/laybasic/laybasic.pro index 95ac373fa..10ed41dd5 100644 --- a/src/laybasic/laybasic/laybasic.pro +++ b/src/laybasic/laybasic/laybasic.pro @@ -6,335 +6,135 @@ include($$PWD/../../lib.pri) DEFINES += MAKE_LAYBASIC_LIBRARY -!equals(HAVE_QT, "0") { +!equals(HAVE_QT, 0) { FORMS = \ - AlignCellOptionsDialog.ui \ - BookmarkManagementForm.ui \ - BrowseInstancesConfigPage.ui \ - BrowseInstancesForm.ui \ - BrowserDialog.ui \ - BrowserPanel.ui \ - BrowseShapesConfigPage.ui \ - BrowseShapesForm.ui \ - CellSelectionForm.ui \ - ClearLayerModeDialog.ui \ - ConfigurationDialog.ui \ - CopyCellModeDialog.ui \ - DeleteCellModeDialog.ui \ - DuplicateLayerDialog.ui \ - EditStipplesForm.ui \ - FlattenInstOptionsDialog.ui \ - GridNetConfigPage.ui \ - LayerMappingWidget.ui \ - LayerSourceDialog.ui \ - LayoutProperties.ui \ - LayoutViewConfigPage1.ui \ - LayoutViewConfigPage2a.ui \ - LayoutViewConfigPage2b.ui \ - LayoutViewConfigPage2c.ui \ - LayoutViewConfigPage2d.ui \ - LayoutViewConfigPage3a.ui \ - LayoutViewConfigPage3b.ui \ - LayoutViewConfigPage3c.ui \ - LayoutViewConfigPage3f.ui \ - LayoutViewConfigPage4.ui \ - LayoutViewConfigPage5.ui \ - LayoutViewConfigPage6.ui \ - LayoutViewConfigPage7.ui \ - LayoutViewConfigPage.ui \ - LibraryCellSelectionForm.ui \ - LoadLayoutOptionsDialog.ui \ - MarkerBrowserConfigPage2.ui \ - MarkerBrowserConfigPage.ui \ - MarkerBrowserDialog.ui \ - MarkerBrowserPage.ui \ - MarkerBrowserSnapshotView.ui \ - MoveOptionsDialog.ui \ - MoveToOptionsDialog.ui \ - NewCellPropertiesDialog.ui \ - NewLayerPropertiesDialog.ui \ - NewLayoutPropertiesDialog.ui \ - OpenLayoutModeDialog.ui \ PropertiesDialog.ui \ - RenameCellDialog.ui \ - ReplaceCellOptionsDialog.ui \ - SaveLayoutOptionsDialog.ui \ - SaveLayoutAsOptionsDialog.ui \ - SelectStippleForm.ui \ - TipDialog.ui \ - UserPropertiesForm.ui \ - UserPropertiesEditForm.ui \ - SpecificLoadLayoutOptionsDialog.ui \ - SelectLineStyleForm.ui \ - LayoutViewConfigPage6a.ui \ - EditLineStylesForm.ui \ - NetlistBrowserPage.ui \ - NetlistBrowserConfigPage.ui \ - NetlistBrowserConfigPage2.ui \ - NetlistBrowserDialog.ui \ - NetInfoDialog.ui \ - NetExportDialog.ui \ - SelectCellViewForm.ui \ - LayoutStatistics.ui \ - RESOURCES = \ - laybasicResources.qrc \ - layLayoutStatistics.qrc \ + SOURCES = \ + gtf.cc \ + layPluginConfigPage.cc \ + layPropertiesDialog.cc \ + layProperties.cc \ + layAbstractMenu.cc \ + layDragDropData.cc \ + layCursor.cc \ + + HEADERS = \ + gtf.h \ + layPluginConfigPage.h \ + layPropertiesDialog.h \ + layProperties.h \ + layAbstractMenu.h \ + layDragDropData.h \ + layCursor.h \ } -# Disabled without Qt: - -SOURCES = \ - gsiDeclLayDialogs.cc \ - gsiDeclLayMenu.cc \ - gsiDeclLayNetlistBrowserDialog.cc \ - gsiDeclLayStream.cc \ - gtf.cc \ - layAbstractMenu.cc \ - layBackgroundAwareTreeStyle.cc \ - layBookmarkList.cc \ - layBookmarkManagementForm.cc \ - layBookmarksView.cc \ - layBrowseInstancesForm.cc \ - layBrowseShapesForm.cc \ - layBrowser.cc \ - layBrowserDialog.cc \ - layBrowserPanel.cc \ - layBusy.cc \ - layCellSelectionForm.cc \ - layCellTreeModel.cc \ - layConfigurationDialog.cc \ - layCursor.cc \ - layDialogs.cc \ - layDragDropData.cc \ - layEditLineStyleWidget.cc \ - layEditLineStylesForm.cc \ - layEditStippleWidget.cc \ - layEditStipplesForm.cc \ - layEditorOptionsFrame.cc \ - layEditorOptionsPage.cc \ - layEditorOptionsPages.cc \ - layFileDialog.cc \ - layGenericSyntaxHighlighter.cc \ - layGridNetConfigPage.cc \ - layHierarchyControlPanel.cc \ - layIndexedNetlistModel.cc \ - layItemDelegates.cc \ - layLayerControlPanel.cc \ - layLayerMappingWidget.cc \ - layLayerToolbox.cc \ - layLayerTreeModel.cc \ - layLayoutPropertiesForm.cc \ - layLayoutStatisticsForm.cc \ - layLayoutViewConfigPages.cc \ - layLayoutViewFunctions.cc \ - layLibrariesView.cc \ - layLoadLayoutOptionsDialog.cc \ - layNetExportDialog.cc \ - layNetInfoDialog.cc \ - layNetlistBrowser.cc \ - layNetlistBrowserDialog.cc \ - layNetlistBrowserModel.cc \ - layNetlistBrowserPage.cc \ - layNetlistBrowserTreeModel.cc \ - layNetlistCrossReferenceModel.cc \ - layPluginConfigPage.cc \ - layProperties.cc \ - layPropertiesDialog.cc \ - layQtTools.cc \ - laySaveLayoutOptionsDialog.cc \ - laySelectCellViewForm.cc \ - laySelectLineStyleForm.cc \ - laySelectStippleForm.cc \ - layStream.cc \ - layTechnology.cc \ - layTipDialog.cc \ - layWidgets.cc \ - rdbInfoWidget.cc \ - rdbMarkerBrowser.cc \ - rdbMarkerBrowserDialog.cc \ - rdbMarkerBrowserPage.cc \ - -# Disabled without Qt: - -HEADERS = \ - gtf.h \ - layAbstractMenu.h \ - layBackgroundAwareTreeStyle.h \ - layBitmap.h \ - layBookmarkList.h \ - layBookmarkManagementForm.h \ - layBookmarksView.h \ - layBrowseInstancesForm.h \ - layBrowseShapesForm.h \ - layBrowser.h \ - layBrowserDialog.h \ - layBrowserPanel.h \ - layBusy.h \ - layCellSelectionForm.h \ - layCellTreeModel.h \ - layConfigurationDialog.h \ - layColor.h \ - layCursor.h \ - layDialogs.h \ - layDragDropData.h \ - layEditLineStyleWidget.h \ - layEditLineStylesForm.h \ - layEditStippleWidget.h \ - layEditStipplesForm.h \ - layEditorOptionsFrame.h \ - layEditorOptionsPage.h \ - layEditorOptionsPages.h \ - layFileDialog.h \ - layGenericSyntaxHighlighter.h \ - layGridNetConfigPage.h \ - layHierarchyControlPanel.h \ - layIndexedNetlistModel.h \ - layItemDelegates.h \ - layLayerControlPanel.h \ - layLayerMappingWidget.h \ - layLayerToolbox.h \ - layLayerTreeModel.h \ - layLayoutPropertiesForm.h \ - layLayoutStatisticsForm.h \ - layLayoutViewConfigPages.h \ - layLayoutViewFunctions.h \ - layLibrariesView.h \ - layLoadLayoutOptionsDialog.h \ - layNetExportDialog.h \ - layNetInfoDialog.h \ - layNetlistBrowser.h \ - layNetlistBrowserDialog.h \ - layNetlistBrowserModel.h \ - layNetlistBrowserPage.h \ - layNetlistBrowserTreeModel.h \ - layNetlistCrossReferenceModel.h \ - layPluginConfigPage.h \ - layProperties.h \ - layPropertiesDialog.h \ - layQtTools.h \ - laySaveLayoutOptionsDialog.h \ - laySelectCellViewForm.h \ - laySelectLineStyleForm.h \ - laySelectStippleForm.h \ - layStream.h \ - layTechnology.h \ - layTipDialog.h \ - layWidgets.h \ - laybasicConfig.h \ - rdbInfoWidget.h \ - rdbMarkerBrowser.h \ - rdbMarkerBrowserDialog.h \ - rdbMarkerBrowserPage.h \ - -# Enabled without Qt: - SOURCES += \ - gsiDeclLayLayers.cc \ - gsiDeclLayLayoutView.cc \ - gsiDeclLayMarker.cc \ - gsiDeclLayPlugin.cc \ - gsiDeclLayPixelBuffer.cc \ - laybasicForceLink.cc \ - layAnnotationShapes.cc \ - layBitmap.cc \ - layBitmapRenderer.cc \ - layBitmapsToImage.cc \ - layCellView.cc \ - layColor.cc \ - layColorPalette.cc \ - layConverters.cc \ - layDispatcher.cc \ - layDisplayState.cc \ - layDitherPattern.cc \ - layDrawing.cc \ - layEditable.cc \ - layEditorServiceBase.cc \ - layFinder.cc \ - layGridNet.cc \ - layFixedFont.cc \ - layLayoutCanvas.cc \ - layLayoutView.cc \ - layLineStylePalette.cc \ - layLineStyles.cc \ - layMarker.cc \ - layMouseTracker.cc \ - layMove.cc \ - layNetColorizer.cc \ - layObjectInstPath.cc \ - layParsedLayerSource.cc \ - layPixelBuffer.cc \ - layPixelBufferPainter.cc \ - layPlugin.cc \ - layRedrawLayerInfo.cc \ - layRedrawThread.cc \ - layRedrawThreadCanvas.cc \ - layRedrawThreadWorker.cc \ - layRenderer.cc \ - layRubberBox.cc \ - laySelector.cc \ - laySnap.cc \ - layStipplePalette.cc \ - layCanvasPlane.cc \ - layLayoutViewBase.cc \ - layLayerProperties.cc \ - layViewObject.cc \ - layViewOp.cc \ - layViewport.cc \ - layZoomBox.cc \ - -# Enabled without Qt: + gsiDeclLayLayers.cc \ + gsiDeclLayLayoutViewBase.cc \ + gsiDeclLayMarker.cc \ + gsiDeclLayPlugin.cc \ + gsiDeclLayPixelBuffer.cc \ + laybasicForceLink.cc \ + layAnnotationShapes.cc \ + layBitmap.cc \ + layBitmapRenderer.cc \ + layBitmapsToImage.cc \ + layBookmarkList.cc \ + layCellView.cc \ + layColor.cc \ + layColorPalette.cc \ + layConverters.cc \ + layDispatcher.cc \ + layDisplayState.cc \ + layDitherPattern.cc \ + layDrawing.cc \ + layEditable.cc \ + layEditorServiceBase.cc \ + layFinder.cc \ + layFixedFont.cc \ + layLayoutCanvas.cc \ + layLineStylePalette.cc \ + layLineStyles.cc \ + layMarker.cc \ + layMouseTracker.cc \ + layMove.cc \ + layNetColorizer.cc \ + layObjectInstPath.cc \ + layParsedLayerSource.cc \ + layPixelBuffer.cc \ + layPixelBufferPainter.cc \ + layPlugin.cc \ + layRedrawLayerInfo.cc \ + layRedrawThread.cc \ + layRedrawThreadCanvas.cc \ + layRedrawThreadWorker.cc \ + layRenderer.cc \ + layRubberBox.cc \ + laySelector.cc \ + laySnap.cc \ + layStream.cc \ + layStipplePalette.cc \ + layCanvasPlane.cc \ + layLayoutViewBase.cc \ + layLayerProperties.cc \ + layViewObject.cc \ + layViewOp.cc \ + layViewport.cc \ + layZoomBox.cc \ HEADERS += \ - laybasicForceLink.h \ - layAnnotationShapes.h \ - layBitmap.h \ - layBitmapRenderer.h \ - layBitmapsToImage.h \ - layCellView.h \ - layColorPalette.h \ - layConverters.h \ - layDispatcher.h \ - layDisplayState.h \ - layDitherPattern.h \ - layDrawing.h \ - layEditable.h \ - layEditorServiceBase.h \ - layLayoutCanvas.h \ - layLayoutView.h \ - layFinder.h \ - layFixedFont.h \ - layGridNet.h \ - layLayoutViewBase.h \ - layLineStylePalette.h \ - layLineStyles.h \ - layMarker.h \ - layMouseTracker.h \ - layMove.h \ - layNetColorizer.h \ - layObjectInstPath.h \ - layParsedLayerSource.h \ - layPixelBuffer.h \ - layPixelBufferPainter.h \ - layPlugin.h \ - layRedrawLayerInfo.h \ - layRedrawThread.h \ - layRedrawThreadCanvas.h \ - layRedrawThreadWorker.h \ - layRenderer.h \ - layRubberBox.h \ - laySelector.h \ - laySnap.h \ - layStipplePalette.h \ - layLayerProperties.h \ - layCanvasPlane.h \ - layViewObject.h \ - layViewOp.h \ - layViewport.h \ - layZoomBox.h \ - laybasicCommon.h \ + laybasicConfig.h \ + laybasicForceLink.h \ + layAnnotationShapes.h \ + layBitmap.h \ + layBitmapRenderer.h \ + layBitmapsToImage.h \ + layBookmarkList.h \ + layCellView.h \ + layColorPalette.h \ + layColor.h \ + layConverters.h \ + layDispatcher.h \ + layDisplayState.h \ + layDitherPattern.h \ + layDrawing.h \ + layEditable.h \ + layEditorServiceBase.h \ + layLayoutCanvas.h \ + layFinder.h \ + layFixedFont.h \ + layLayoutViewBase.h \ + layLineStylePalette.h \ + layLineStyles.h \ + layMarker.h \ + layMouseTracker.h \ + layMove.h \ + layNetColorizer.h \ + layObjectInstPath.h \ + layParsedLayerSource.h \ + layPixelBuffer.h \ + layPixelBufferPainter.h \ + layPlugin.h \ + layRedrawLayerInfo.h \ + layRedrawThread.h \ + layRedrawThreadCanvas.h \ + layRedrawThreadWorker.h \ + layRenderer.h \ + layRubberBox.h \ + laySelector.h \ + laySnap.h \ + layStream.h \ + layStipplePalette.h \ + layLayerProperties.h \ + layCanvasPlane.h \ + layViewObject.h \ + layViewOp.h \ + layViewport.h \ + layZoomBox.h \ + laybasicCommon.h \ INCLUDEPATH += $$TL_INC $$GSI_INC $$DB_INC $$RDB_INC diff --git a/src/laybasic/unit_tests/layLayerProperties.cc b/src/laybasic/unit_tests/layLayerProperties.cc index 3ef24eeea..577fe062c 100644 --- a/src/laybasic/unit_tests/layLayerProperties.cc +++ b/src/laybasic/unit_tests/layLayerProperties.cc @@ -23,7 +23,7 @@ #include "layLayerProperties.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "tlXMLParser.h" #include "tlUnitTest.h" #include "dbLayout.h" @@ -1304,7 +1304,7 @@ TEST (16) lay::LayerPropertiesList list; db::Manager mgr (true); - lay::LayoutView view (&mgr, is_editable (), 0); + lay::LayoutViewBase view (&mgr, is_editable (), 0); list.attach_view (&view, 0); int cv1 = view.create_layout ("", true, false); @@ -1356,7 +1356,7 @@ TEST (17) lay::LayerPropertiesList list; db::Manager mgr (true); - lay::LayoutView view (&mgr, is_editable (), 0); + lay::LayoutViewBase view (&mgr, is_editable (), 0); list.attach_view (&view, 0); int cv1 = view.create_layout ("", true, false); @@ -1423,7 +1423,7 @@ TEST (18) lay::LayerPropertiesList list; db::Manager mgr (true); - lay::LayoutView view (&mgr, is_editable (), 0); + lay::LayoutViewBase view (&mgr, is_editable (), 0); list.attach_view (&view, 0); int cv1 = view.create_layout ("", true, false); @@ -1491,7 +1491,7 @@ TEST (19) lay::LayerPropertiesList list; db::Manager mgr (true); - lay::LayoutView view (&mgr, is_editable (), 0); + lay::LayoutViewBase view (&mgr, is_editable (), 0); list.attach_view (&view, 0); int cv1 = view.create_layout ("", true, false); @@ -1560,7 +1560,7 @@ TEST (20) lay::LayerPropertiesList list; db::Manager mgr (true); - lay::LayoutView view (&mgr, is_editable (), 0); + lay::LayoutViewBase view (&mgr, is_editable (), 0); list.attach_view (&view, 0); int cv1 = view.create_layout ("", true, false); @@ -1632,7 +1632,7 @@ TEST (21) lay::LayerPropertiesList list; db::Manager mgr (true); - lay::LayoutView view (&mgr, is_editable (), 0); + lay::LayoutViewBase view (&mgr, is_editable (), 0); list.attach_view (&view, 0); int cv1 = view.create_layout ("", true, false); diff --git a/src/laybasic/unit_tests/laySnapTests.cc b/src/laybasic/unit_tests/laySnapTests.cc index f51e28c11..f975386c8 100644 --- a/src/laybasic/unit_tests/laySnapTests.cc +++ b/src/laybasic/unit_tests/laySnapTests.cc @@ -21,14 +21,14 @@ */ #include "laySnap.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "tlUnitTest.h" TEST(1) { db::Manager mgr (true); - lay::LayoutView view (&mgr, is_editable (), 0); + lay::LayoutViewBase view (&mgr, is_editable (), 0); int cv1 = view.create_layout ("", true, false); db::Layout &ly1 = view.cellview (cv1)->layout (); diff --git a/src/laybasic/unit_tests/unit_tests.pro b/src/laybasic/unit_tests/unit_tests.pro index 2fd4d74af..e906d3a46 100644 --- a/src/laybasic/unit_tests/unit_tests.pro +++ b/src/laybasic/unit_tests/unit_tests.pro @@ -14,19 +14,10 @@ SOURCES = \ layLayerProperties.cc \ layParsedLayerSource.cc \ layPixelBufferTests.cc \ - layLayoutViewTests.cc \ layRenderer.cc \ layAbstractMenuTests.cc \ laySnapTests.cc -!equals(HAVE_QT, "0") { - - SOURCES += \ - layNetlistBrowserModelTests.cc \ - layNetlistBrowserTreeModelTests.cc \ - -} - INCLUDEPATH += $$TL_INC $$LAYBASIC_INC $$DB_INC $$GSI_INC $$OUT_PWD/../laybasic DEPENDPATH += $$TL_INC $$LAYBASIC_INC $$DB_INC $$GSI_INC $$OUT_PWD/../laybasic diff --git a/src/layui/layui.pro b/src/layui/layui.pro new file mode 100644 index 000000000..19b992d3c --- /dev/null +++ b/src/layui/layui.pro @@ -0,0 +1,6 @@ + +TEMPLATE = subdirs +SUBDIRS = layui unit_tests + +unit_tests.depends += layui + diff --git a/src/laybasic/laybasic/AlignCellOptionsDialog.ui b/src/layui/layui/AlignCellOptionsDialog.ui similarity index 100% rename from src/laybasic/laybasic/AlignCellOptionsDialog.ui rename to src/layui/layui/AlignCellOptionsDialog.ui diff --git a/src/laybasic/laybasic/BookmarkManagementForm.ui b/src/layui/layui/BookmarkManagementForm.ui similarity index 100% rename from src/laybasic/laybasic/BookmarkManagementForm.ui rename to src/layui/layui/BookmarkManagementForm.ui diff --git a/src/laybasic/laybasic/BrowseInstancesConfigPage.ui b/src/layui/layui/BrowseInstancesConfigPage.ui similarity index 100% rename from src/laybasic/laybasic/BrowseInstancesConfigPage.ui rename to src/layui/layui/BrowseInstancesConfigPage.ui diff --git a/src/laybasic/laybasic/BrowseInstancesForm.ui b/src/layui/layui/BrowseInstancesForm.ui similarity index 100% rename from src/laybasic/laybasic/BrowseInstancesForm.ui rename to src/layui/layui/BrowseInstancesForm.ui diff --git a/src/laybasic/laybasic/BrowseShapesConfigPage.ui b/src/layui/layui/BrowseShapesConfigPage.ui similarity index 100% rename from src/laybasic/laybasic/BrowseShapesConfigPage.ui rename to src/layui/layui/BrowseShapesConfigPage.ui diff --git a/src/laybasic/laybasic/BrowseShapesForm.ui b/src/layui/layui/BrowseShapesForm.ui similarity index 100% rename from src/laybasic/laybasic/BrowseShapesForm.ui rename to src/layui/layui/BrowseShapesForm.ui diff --git a/src/laybasic/laybasic/BrowserDialog.ui b/src/layui/layui/BrowserDialog.ui similarity index 100% rename from src/laybasic/laybasic/BrowserDialog.ui rename to src/layui/layui/BrowserDialog.ui diff --git a/src/laybasic/laybasic/BrowserPanel.ui b/src/layui/layui/BrowserPanel.ui similarity index 100% rename from src/laybasic/laybasic/BrowserPanel.ui rename to src/layui/layui/BrowserPanel.ui diff --git a/src/laybasic/laybasic/CellSelectionForm.ui b/src/layui/layui/CellSelectionForm.ui similarity index 100% rename from src/laybasic/laybasic/CellSelectionForm.ui rename to src/layui/layui/CellSelectionForm.ui diff --git a/src/laybasic/laybasic/ClearLayerModeDialog.ui b/src/layui/layui/ClearLayerModeDialog.ui similarity index 100% rename from src/laybasic/laybasic/ClearLayerModeDialog.ui rename to src/layui/layui/ClearLayerModeDialog.ui diff --git a/src/laybasic/laybasic/ConfigurationDialog.ui b/src/layui/layui/ConfigurationDialog.ui similarity index 100% rename from src/laybasic/laybasic/ConfigurationDialog.ui rename to src/layui/layui/ConfigurationDialog.ui diff --git a/src/laybasic/laybasic/CopyCellModeDialog.ui b/src/layui/layui/CopyCellModeDialog.ui similarity index 100% rename from src/laybasic/laybasic/CopyCellModeDialog.ui rename to src/layui/layui/CopyCellModeDialog.ui diff --git a/src/laybasic/laybasic/DeleteCellModeDialog.ui b/src/layui/layui/DeleteCellModeDialog.ui similarity index 100% rename from src/laybasic/laybasic/DeleteCellModeDialog.ui rename to src/layui/layui/DeleteCellModeDialog.ui diff --git a/src/laybasic/laybasic/DuplicateLayerDialog.ui b/src/layui/layui/DuplicateLayerDialog.ui similarity index 100% rename from src/laybasic/laybasic/DuplicateLayerDialog.ui rename to src/layui/layui/DuplicateLayerDialog.ui diff --git a/src/laybasic/laybasic/EditLineStylesForm.ui b/src/layui/layui/EditLineStylesForm.ui similarity index 100% rename from src/laybasic/laybasic/EditLineStylesForm.ui rename to src/layui/layui/EditLineStylesForm.ui diff --git a/src/laybasic/laybasic/EditStipplesForm.ui b/src/layui/layui/EditStipplesForm.ui similarity index 100% rename from src/laybasic/laybasic/EditStipplesForm.ui rename to src/layui/layui/EditStipplesForm.ui diff --git a/src/laybasic/laybasic/FlattenInstOptionsDialog.ui b/src/layui/layui/FlattenInstOptionsDialog.ui similarity index 100% rename from src/laybasic/laybasic/FlattenInstOptionsDialog.ui rename to src/layui/layui/FlattenInstOptionsDialog.ui diff --git a/src/laybasic/laybasic/GridNetConfigPage.ui b/src/layui/layui/GridNetConfigPage.ui similarity index 100% rename from src/laybasic/laybasic/GridNetConfigPage.ui rename to src/layui/layui/GridNetConfigPage.ui diff --git a/src/laybasic/laybasic/LayerMappingWidget.ui b/src/layui/layui/LayerMappingWidget.ui similarity index 100% rename from src/laybasic/laybasic/LayerMappingWidget.ui rename to src/layui/layui/LayerMappingWidget.ui diff --git a/src/laybasic/laybasic/LayerSourceDialog.ui b/src/layui/layui/LayerSourceDialog.ui similarity index 100% rename from src/laybasic/laybasic/LayerSourceDialog.ui rename to src/layui/layui/LayerSourceDialog.ui diff --git a/src/laybasic/laybasic/LayoutProperties.ui b/src/layui/layui/LayoutProperties.ui similarity index 100% rename from src/laybasic/laybasic/LayoutProperties.ui rename to src/layui/layui/LayoutProperties.ui diff --git a/src/laybasic/laybasic/LayoutStatistics.ui b/src/layui/layui/LayoutStatistics.ui similarity index 100% rename from src/laybasic/laybasic/LayoutStatistics.ui rename to src/layui/layui/LayoutStatistics.ui diff --git a/src/laybasic/laybasic/LayoutViewConfigPage.ui b/src/layui/layui/LayoutViewConfigPage.ui similarity index 100% rename from src/laybasic/laybasic/LayoutViewConfigPage.ui rename to src/layui/layui/LayoutViewConfigPage.ui diff --git a/src/laybasic/laybasic/LayoutViewConfigPage1.ui b/src/layui/layui/LayoutViewConfigPage1.ui similarity index 100% rename from src/laybasic/laybasic/LayoutViewConfigPage1.ui rename to src/layui/layui/LayoutViewConfigPage1.ui diff --git a/src/laybasic/laybasic/LayoutViewConfigPage2a.ui b/src/layui/layui/LayoutViewConfigPage2a.ui similarity index 100% rename from src/laybasic/laybasic/LayoutViewConfigPage2a.ui rename to src/layui/layui/LayoutViewConfigPage2a.ui diff --git a/src/laybasic/laybasic/LayoutViewConfigPage2b.ui b/src/layui/layui/LayoutViewConfigPage2b.ui similarity index 100% rename from src/laybasic/laybasic/LayoutViewConfigPage2b.ui rename to src/layui/layui/LayoutViewConfigPage2b.ui diff --git a/src/laybasic/laybasic/LayoutViewConfigPage2c.ui b/src/layui/layui/LayoutViewConfigPage2c.ui similarity index 100% rename from src/laybasic/laybasic/LayoutViewConfigPage2c.ui rename to src/layui/layui/LayoutViewConfigPage2c.ui diff --git a/src/laybasic/laybasic/LayoutViewConfigPage2d.ui b/src/layui/layui/LayoutViewConfigPage2d.ui similarity index 100% rename from src/laybasic/laybasic/LayoutViewConfigPage2d.ui rename to src/layui/layui/LayoutViewConfigPage2d.ui diff --git a/src/laybasic/laybasic/LayoutViewConfigPage3a.ui b/src/layui/layui/LayoutViewConfigPage3a.ui similarity index 100% rename from src/laybasic/laybasic/LayoutViewConfigPage3a.ui rename to src/layui/layui/LayoutViewConfigPage3a.ui diff --git a/src/laybasic/laybasic/LayoutViewConfigPage3b.ui b/src/layui/layui/LayoutViewConfigPage3b.ui similarity index 100% rename from src/laybasic/laybasic/LayoutViewConfigPage3b.ui rename to src/layui/layui/LayoutViewConfigPage3b.ui diff --git a/src/laybasic/laybasic/LayoutViewConfigPage3c.ui b/src/layui/layui/LayoutViewConfigPage3c.ui similarity index 100% rename from src/laybasic/laybasic/LayoutViewConfigPage3c.ui rename to src/layui/layui/LayoutViewConfigPage3c.ui diff --git a/src/laybasic/laybasic/LayoutViewConfigPage3f.ui b/src/layui/layui/LayoutViewConfigPage3f.ui similarity index 100% rename from src/laybasic/laybasic/LayoutViewConfigPage3f.ui rename to src/layui/layui/LayoutViewConfigPage3f.ui diff --git a/src/laybasic/laybasic/LayoutViewConfigPage4.ui b/src/layui/layui/LayoutViewConfigPage4.ui similarity index 100% rename from src/laybasic/laybasic/LayoutViewConfigPage4.ui rename to src/layui/layui/LayoutViewConfigPage4.ui diff --git a/src/laybasic/laybasic/LayoutViewConfigPage5.ui b/src/layui/layui/LayoutViewConfigPage5.ui similarity index 100% rename from src/laybasic/laybasic/LayoutViewConfigPage5.ui rename to src/layui/layui/LayoutViewConfigPage5.ui diff --git a/src/laybasic/laybasic/LayoutViewConfigPage6.ui b/src/layui/layui/LayoutViewConfigPage6.ui similarity index 100% rename from src/laybasic/laybasic/LayoutViewConfigPage6.ui rename to src/layui/layui/LayoutViewConfigPage6.ui diff --git a/src/laybasic/laybasic/LayoutViewConfigPage6a.ui b/src/layui/layui/LayoutViewConfigPage6a.ui similarity index 100% rename from src/laybasic/laybasic/LayoutViewConfigPage6a.ui rename to src/layui/layui/LayoutViewConfigPage6a.ui diff --git a/src/laybasic/laybasic/LayoutViewConfigPage7.ui b/src/layui/layui/LayoutViewConfigPage7.ui similarity index 100% rename from src/laybasic/laybasic/LayoutViewConfigPage7.ui rename to src/layui/layui/LayoutViewConfigPage7.ui diff --git a/src/laybasic/laybasic/LibraryCellSelectionForm.ui b/src/layui/layui/LibraryCellSelectionForm.ui similarity index 100% rename from src/laybasic/laybasic/LibraryCellSelectionForm.ui rename to src/layui/layui/LibraryCellSelectionForm.ui diff --git a/src/laybasic/laybasic/LoadLayoutOptionsDialog.ui b/src/layui/layui/LoadLayoutOptionsDialog.ui similarity index 100% rename from src/laybasic/laybasic/LoadLayoutOptionsDialog.ui rename to src/layui/layui/LoadLayoutOptionsDialog.ui diff --git a/src/laybasic/laybasic/MarkerBrowserConfigPage.ui b/src/layui/layui/MarkerBrowserConfigPage.ui similarity index 100% rename from src/laybasic/laybasic/MarkerBrowserConfigPage.ui rename to src/layui/layui/MarkerBrowserConfigPage.ui diff --git a/src/laybasic/laybasic/MarkerBrowserConfigPage2.ui b/src/layui/layui/MarkerBrowserConfigPage2.ui similarity index 100% rename from src/laybasic/laybasic/MarkerBrowserConfigPage2.ui rename to src/layui/layui/MarkerBrowserConfigPage2.ui diff --git a/src/laybasic/laybasic/MarkerBrowserDialog.ui b/src/layui/layui/MarkerBrowserDialog.ui similarity index 100% rename from src/laybasic/laybasic/MarkerBrowserDialog.ui rename to src/layui/layui/MarkerBrowserDialog.ui diff --git a/src/laybasic/laybasic/MarkerBrowserPage.ui b/src/layui/layui/MarkerBrowserPage.ui similarity index 100% rename from src/laybasic/laybasic/MarkerBrowserPage.ui rename to src/layui/layui/MarkerBrowserPage.ui diff --git a/src/laybasic/laybasic/MarkerBrowserSnapshotView.ui b/src/layui/layui/MarkerBrowserSnapshotView.ui similarity index 100% rename from src/laybasic/laybasic/MarkerBrowserSnapshotView.ui rename to src/layui/layui/MarkerBrowserSnapshotView.ui diff --git a/src/laybasic/laybasic/MoveOptionsDialog.ui b/src/layui/layui/MoveOptionsDialog.ui similarity index 100% rename from src/laybasic/laybasic/MoveOptionsDialog.ui rename to src/layui/layui/MoveOptionsDialog.ui diff --git a/src/laybasic/laybasic/MoveToOptionsDialog.ui b/src/layui/layui/MoveToOptionsDialog.ui similarity index 100% rename from src/laybasic/laybasic/MoveToOptionsDialog.ui rename to src/layui/layui/MoveToOptionsDialog.ui diff --git a/src/laybasic/laybasic/NetExportDialog.ui b/src/layui/layui/NetExportDialog.ui similarity index 100% rename from src/laybasic/laybasic/NetExportDialog.ui rename to src/layui/layui/NetExportDialog.ui diff --git a/src/laybasic/laybasic/NetInfoDialog.ui b/src/layui/layui/NetInfoDialog.ui similarity index 100% rename from src/laybasic/laybasic/NetInfoDialog.ui rename to src/layui/layui/NetInfoDialog.ui diff --git a/src/laybasic/laybasic/NetlistBrowserConfigPage.ui b/src/layui/layui/NetlistBrowserConfigPage.ui similarity index 100% rename from src/laybasic/laybasic/NetlistBrowserConfigPage.ui rename to src/layui/layui/NetlistBrowserConfigPage.ui diff --git a/src/laybasic/laybasic/NetlistBrowserConfigPage2.ui b/src/layui/layui/NetlistBrowserConfigPage2.ui similarity index 100% rename from src/laybasic/laybasic/NetlistBrowserConfigPage2.ui rename to src/layui/layui/NetlistBrowserConfigPage2.ui diff --git a/src/laybasic/laybasic/NetlistBrowserDialog.ui b/src/layui/layui/NetlistBrowserDialog.ui similarity index 100% rename from src/laybasic/laybasic/NetlistBrowserDialog.ui rename to src/layui/layui/NetlistBrowserDialog.ui diff --git a/src/laybasic/laybasic/NetlistBrowserPage.ui b/src/layui/layui/NetlistBrowserPage.ui similarity index 100% rename from src/laybasic/laybasic/NetlistBrowserPage.ui rename to src/layui/layui/NetlistBrowserPage.ui diff --git a/src/laybasic/laybasic/NewCellPropertiesDialog.ui b/src/layui/layui/NewCellPropertiesDialog.ui similarity index 100% rename from src/laybasic/laybasic/NewCellPropertiesDialog.ui rename to src/layui/layui/NewCellPropertiesDialog.ui diff --git a/src/laybasic/laybasic/NewLayerPropertiesDialog.ui b/src/layui/layui/NewLayerPropertiesDialog.ui similarity index 100% rename from src/laybasic/laybasic/NewLayerPropertiesDialog.ui rename to src/layui/layui/NewLayerPropertiesDialog.ui diff --git a/src/laybasic/laybasic/NewLayoutPropertiesDialog.ui b/src/layui/layui/NewLayoutPropertiesDialog.ui similarity index 100% rename from src/laybasic/laybasic/NewLayoutPropertiesDialog.ui rename to src/layui/layui/NewLayoutPropertiesDialog.ui diff --git a/src/laybasic/laybasic/OpenLayoutModeDialog.ui b/src/layui/layui/OpenLayoutModeDialog.ui similarity index 100% rename from src/laybasic/laybasic/OpenLayoutModeDialog.ui rename to src/layui/layui/OpenLayoutModeDialog.ui diff --git a/src/laybasic/laybasic/RenameCellDialog.ui b/src/layui/layui/RenameCellDialog.ui similarity index 100% rename from src/laybasic/laybasic/RenameCellDialog.ui rename to src/layui/layui/RenameCellDialog.ui diff --git a/src/laybasic/laybasic/ReplaceCellOptionsDialog.ui b/src/layui/layui/ReplaceCellOptionsDialog.ui similarity index 100% rename from src/laybasic/laybasic/ReplaceCellOptionsDialog.ui rename to src/layui/layui/ReplaceCellOptionsDialog.ui diff --git a/src/laybasic/laybasic/SaveLayoutAsOptionsDialog.ui b/src/layui/layui/SaveLayoutAsOptionsDialog.ui similarity index 100% rename from src/laybasic/laybasic/SaveLayoutAsOptionsDialog.ui rename to src/layui/layui/SaveLayoutAsOptionsDialog.ui diff --git a/src/laybasic/laybasic/SaveLayoutOptionsDialog.ui b/src/layui/layui/SaveLayoutOptionsDialog.ui similarity index 100% rename from src/laybasic/laybasic/SaveLayoutOptionsDialog.ui rename to src/layui/layui/SaveLayoutOptionsDialog.ui diff --git a/src/laybasic/laybasic/SelectCellViewForm.ui b/src/layui/layui/SelectCellViewForm.ui similarity index 100% rename from src/laybasic/laybasic/SelectCellViewForm.ui rename to src/layui/layui/SelectCellViewForm.ui diff --git a/src/laybasic/laybasic/SelectLineStyleForm.ui b/src/layui/layui/SelectLineStyleForm.ui similarity index 100% rename from src/laybasic/laybasic/SelectLineStyleForm.ui rename to src/layui/layui/SelectLineStyleForm.ui diff --git a/src/laybasic/laybasic/SelectStippleForm.ui b/src/layui/layui/SelectStippleForm.ui similarity index 100% rename from src/laybasic/laybasic/SelectStippleForm.ui rename to src/layui/layui/SelectStippleForm.ui diff --git a/src/laybasic/laybasic/SpecificLoadLayoutOptionsDialog.ui b/src/layui/layui/SpecificLoadLayoutOptionsDialog.ui similarity index 100% rename from src/laybasic/laybasic/SpecificLoadLayoutOptionsDialog.ui rename to src/layui/layui/SpecificLoadLayoutOptionsDialog.ui diff --git a/src/laybasic/laybasic/TipDialog.ui b/src/layui/layui/TipDialog.ui similarity index 100% rename from src/laybasic/laybasic/TipDialog.ui rename to src/layui/layui/TipDialog.ui diff --git a/src/laybasic/laybasic/UserPropertiesEditForm.ui b/src/layui/layui/UserPropertiesEditForm.ui similarity index 100% rename from src/laybasic/laybasic/UserPropertiesEditForm.ui rename to src/layui/layui/UserPropertiesEditForm.ui diff --git a/src/laybasic/laybasic/UserPropertiesForm.ui b/src/layui/layui/UserPropertiesForm.ui similarity index 100% rename from src/laybasic/laybasic/UserPropertiesForm.ui rename to src/layui/layui/UserPropertiesForm.ui diff --git a/src/laybasic/laybasic/gsiDeclLayDialogs.cc b/src/layui/layui/gsiDeclLayDialogs.cc similarity index 99% rename from src/laybasic/laybasic/gsiDeclLayDialogs.cc rename to src/layui/layui/gsiDeclLayDialogs.cc index 61a598926..db506bb9e 100644 --- a/src/laybasic/laybasic/gsiDeclLayDialogs.cc +++ b/src/layui/layui/gsiDeclLayDialogs.cc @@ -390,7 +390,7 @@ Class decl_BrowserSource ("lay", "BrowserSource_Native", "@hide\n@alias BrowserSource" ); -LAYBASIC_PUBLIC +LAYUI_PUBLIC Class &laybasicdecl_BrowserSource () { return decl_BrowserSource; diff --git a/src/laybasic/laybasic/gsiDeclLayMenu.cc b/src/layui/layui/gsiDeclLayMenu.cc similarity index 100% rename from src/laybasic/laybasic/gsiDeclLayMenu.cc rename to src/layui/layui/gsiDeclLayMenu.cc diff --git a/src/laybasic/laybasic/gsiDeclLayNetlistBrowserDialog.cc b/src/layui/layui/gsiDeclLayNetlistBrowserDialog.cc similarity index 97% rename from src/laybasic/laybasic/gsiDeclLayNetlistBrowserDialog.cc rename to src/layui/layui/gsiDeclLayNetlistBrowserDialog.cc index 0190f3890..7f8d3c971 100644 --- a/src/laybasic/laybasic/gsiDeclLayNetlistBrowserDialog.cc +++ b/src/layui/layui/gsiDeclLayNetlistBrowserDialog.cc @@ -25,8 +25,10 @@ #include "gsiDecl.h" #include "gsiDeclBasic.h" #include "gsiSignals.h" +#include "dbNetlist.h" #include "layNetlistBrowserDialog.h" -#include "layLayoutView.h" +#include "layNetlistBrowserModel.h" +#include "layLayoutViewBase.h" namespace gsi { @@ -205,14 +207,14 @@ Class decl_NetlistBrowserDialog ("lay", "NetlistBrows "This class has been introduced in version 0.27.\n" ); -static lay::NetlistBrowserDialog *netlist_browser (lay::LayoutView *lv) +static lay::NetlistBrowserDialog *netlist_browser (lay::LayoutViewBase *lv) { return lv->get_plugin (); } -// extend lay::LayoutView with the getter for the netlist browser +// extend lay::LayoutViewBase with the getter for the netlist browser static -gsi::ClassExt decl_ext_layout_view ( +gsi::ClassExt decl_ext_layout_view ( gsi::method_ext ("netlist_browser", &netlist_browser, "@brief Gets the netlist browser object for the given layout view\n" "\n" diff --git a/src/laybasic/laybasic/gsiDeclLayStream.cc b/src/layui/layui/gsiDeclLayStream.cc similarity index 100% rename from src/laybasic/laybasic/gsiDeclLayStream.cc rename to src/layui/layui/gsiDeclLayStream.cc diff --git a/src/laybasic/laybasic/images/icon_circuit_16.png b/src/layui/layui/images/icon_circuit_16.png similarity index 100% rename from src/laybasic/laybasic/images/icon_circuit_16.png rename to src/layui/layui/images/icon_circuit_16.png diff --git a/src/laybasic/laybasic/images/icon_circuit_24.png b/src/layui/layui/images/icon_circuit_24.png similarity index 100% rename from src/laybasic/laybasic/images/icon_circuit_24.png rename to src/layui/layui/images/icon_circuit_24.png diff --git a/src/laybasic/laybasic/images/icon_circuit_32.png b/src/layui/layui/images/icon_circuit_32.png similarity index 100% rename from src/laybasic/laybasic/images/icon_circuit_32.png rename to src/layui/layui/images/icon_circuit_32.png diff --git a/src/laybasic/laybasic/images/icon_circuit_48.png b/src/layui/layui/images/icon_circuit_48.png similarity index 100% rename from src/laybasic/laybasic/images/icon_circuit_48.png rename to src/layui/layui/images/icon_circuit_48.png diff --git a/src/laybasic/laybasic/images/icon_conn_16.png b/src/layui/layui/images/icon_conn_16.png similarity index 100% rename from src/laybasic/laybasic/images/icon_conn_16.png rename to src/layui/layui/images/icon_conn_16.png diff --git a/src/laybasic/laybasic/images/icon_conn_24.png b/src/layui/layui/images/icon_conn_24.png similarity index 100% rename from src/laybasic/laybasic/images/icon_conn_24.png rename to src/layui/layui/images/icon_conn_24.png diff --git a/src/laybasic/laybasic/images/icon_conn_32.png b/src/layui/layui/images/icon_conn_32.png similarity index 100% rename from src/laybasic/laybasic/images/icon_conn_32.png rename to src/layui/layui/images/icon_conn_32.png diff --git a/src/laybasic/laybasic/images/icon_conn_48.png b/src/layui/layui/images/icon_conn_48.png similarity index 100% rename from src/laybasic/laybasic/images/icon_conn_48.png rename to src/layui/layui/images/icon_conn_48.png diff --git a/src/laybasic/laybasic/images/icon_conn_light_16.png b/src/layui/layui/images/icon_conn_light_16.png similarity index 100% rename from src/laybasic/laybasic/images/icon_conn_light_16.png rename to src/layui/layui/images/icon_conn_light_16.png diff --git a/src/laybasic/laybasic/images/icon_conn_light_24.png b/src/layui/layui/images/icon_conn_light_24.png similarity index 100% rename from src/laybasic/laybasic/images/icon_conn_light_24.png rename to src/layui/layui/images/icon_conn_light_24.png diff --git a/src/laybasic/laybasic/images/icon_conn_light_32.png b/src/layui/layui/images/icon_conn_light_32.png similarity index 100% rename from src/laybasic/laybasic/images/icon_conn_light_32.png rename to src/layui/layui/images/icon_conn_light_32.png diff --git a/src/laybasic/laybasic/images/icon_conn_light_48.png b/src/layui/layui/images/icon_conn_light_48.png similarity index 100% rename from src/laybasic/laybasic/images/icon_conn_light_48.png rename to src/layui/layui/images/icon_conn_light_48.png diff --git a/src/laybasic/laybasic/images/icon_device_bjt_16.png b/src/layui/layui/images/icon_device_bjt_16.png similarity index 100% rename from src/laybasic/laybasic/images/icon_device_bjt_16.png rename to src/layui/layui/images/icon_device_bjt_16.png diff --git a/src/laybasic/laybasic/images/icon_device_bjt_24.png b/src/layui/layui/images/icon_device_bjt_24.png similarity index 100% rename from src/laybasic/laybasic/images/icon_device_bjt_24.png rename to src/layui/layui/images/icon_device_bjt_24.png diff --git a/src/laybasic/laybasic/images/icon_device_bjt_32.png b/src/layui/layui/images/icon_device_bjt_32.png similarity index 100% rename from src/laybasic/laybasic/images/icon_device_bjt_32.png rename to src/layui/layui/images/icon_device_bjt_32.png diff --git a/src/laybasic/laybasic/images/icon_device_bjt_48.png b/src/layui/layui/images/icon_device_bjt_48.png similarity index 100% rename from src/laybasic/laybasic/images/icon_device_bjt_48.png rename to src/layui/layui/images/icon_device_bjt_48.png diff --git a/src/laybasic/laybasic/images/icon_device_cap_16.png b/src/layui/layui/images/icon_device_cap_16.png similarity index 100% rename from src/laybasic/laybasic/images/icon_device_cap_16.png rename to src/layui/layui/images/icon_device_cap_16.png diff --git a/src/laybasic/laybasic/images/icon_device_cap_24.png b/src/layui/layui/images/icon_device_cap_24.png similarity index 100% rename from src/laybasic/laybasic/images/icon_device_cap_24.png rename to src/layui/layui/images/icon_device_cap_24.png diff --git a/src/laybasic/laybasic/images/icon_device_cap_32.png b/src/layui/layui/images/icon_device_cap_32.png similarity index 100% rename from src/laybasic/laybasic/images/icon_device_cap_32.png rename to src/layui/layui/images/icon_device_cap_32.png diff --git a/src/laybasic/laybasic/images/icon_device_cap_48.png b/src/layui/layui/images/icon_device_cap_48.png similarity index 100% rename from src/laybasic/laybasic/images/icon_device_cap_48.png rename to src/layui/layui/images/icon_device_cap_48.png diff --git a/src/laybasic/laybasic/images/icon_device_diode_16.png b/src/layui/layui/images/icon_device_diode_16.png similarity index 100% rename from src/laybasic/laybasic/images/icon_device_diode_16.png rename to src/layui/layui/images/icon_device_diode_16.png diff --git a/src/laybasic/laybasic/images/icon_device_diode_24.png b/src/layui/layui/images/icon_device_diode_24.png similarity index 100% rename from src/laybasic/laybasic/images/icon_device_diode_24.png rename to src/layui/layui/images/icon_device_diode_24.png diff --git a/src/laybasic/laybasic/images/icon_device_diode_32.png b/src/layui/layui/images/icon_device_diode_32.png similarity index 100% rename from src/laybasic/laybasic/images/icon_device_diode_32.png rename to src/layui/layui/images/icon_device_diode_32.png diff --git a/src/laybasic/laybasic/images/icon_device_diode_48.png b/src/layui/layui/images/icon_device_diode_48.png similarity index 100% rename from src/laybasic/laybasic/images/icon_device_diode_48.png rename to src/layui/layui/images/icon_device_diode_48.png diff --git a/src/laybasic/laybasic/images/icon_device_mos_16.png b/src/layui/layui/images/icon_device_mos_16.png similarity index 100% rename from src/laybasic/laybasic/images/icon_device_mos_16.png rename to src/layui/layui/images/icon_device_mos_16.png diff --git a/src/laybasic/laybasic/images/icon_device_mos_24.png b/src/layui/layui/images/icon_device_mos_24.png similarity index 100% rename from src/laybasic/laybasic/images/icon_device_mos_24.png rename to src/layui/layui/images/icon_device_mos_24.png diff --git a/src/laybasic/laybasic/images/icon_device_mos_32.png b/src/layui/layui/images/icon_device_mos_32.png similarity index 100% rename from src/laybasic/laybasic/images/icon_device_mos_32.png rename to src/layui/layui/images/icon_device_mos_32.png diff --git a/src/laybasic/laybasic/images/icon_device_mos_48.png b/src/layui/layui/images/icon_device_mos_48.png similarity index 100% rename from src/laybasic/laybasic/images/icon_device_mos_48.png rename to src/layui/layui/images/icon_device_mos_48.png diff --git a/src/laybasic/laybasic/images/icon_device_res_16.png b/src/layui/layui/images/icon_device_res_16.png similarity index 100% rename from src/laybasic/laybasic/images/icon_device_res_16.png rename to src/layui/layui/images/icon_device_res_16.png diff --git a/src/laybasic/laybasic/images/icon_device_res_24.png b/src/layui/layui/images/icon_device_res_24.png similarity index 100% rename from src/laybasic/laybasic/images/icon_device_res_24.png rename to src/layui/layui/images/icon_device_res_24.png diff --git a/src/laybasic/laybasic/images/icon_device_res_32.png b/src/layui/layui/images/icon_device_res_32.png similarity index 100% rename from src/laybasic/laybasic/images/icon_device_res_32.png rename to src/layui/layui/images/icon_device_res_32.png diff --git a/src/laybasic/laybasic/images/icon_device_res_48.png b/src/layui/layui/images/icon_device_res_48.png similarity index 100% rename from src/laybasic/laybasic/images/icon_device_res_48.png rename to src/layui/layui/images/icon_device_res_48.png diff --git a/src/laybasic/laybasic/images/icon_net_16.png b/src/layui/layui/images/icon_net_16.png similarity index 100% rename from src/laybasic/laybasic/images/icon_net_16.png rename to src/layui/layui/images/icon_net_16.png diff --git a/src/laybasic/laybasic/images/icon_net_24.png b/src/layui/layui/images/icon_net_24.png similarity index 100% rename from src/laybasic/laybasic/images/icon_net_24.png rename to src/layui/layui/images/icon_net_24.png diff --git a/src/laybasic/laybasic/images/icon_net_32.png b/src/layui/layui/images/icon_net_32.png similarity index 100% rename from src/laybasic/laybasic/images/icon_net_32.png rename to src/layui/layui/images/icon_net_32.png diff --git a/src/laybasic/laybasic/images/icon_net_48.png b/src/layui/layui/images/icon_net_48.png similarity index 100% rename from src/laybasic/laybasic/images/icon_net_48.png rename to src/layui/layui/images/icon_net_48.png diff --git a/src/laybasic/laybasic/images/icon_net_light_16.png b/src/layui/layui/images/icon_net_light_16.png similarity index 100% rename from src/laybasic/laybasic/images/icon_net_light_16.png rename to src/layui/layui/images/icon_net_light_16.png diff --git a/src/laybasic/laybasic/images/icon_net_light_24.png b/src/layui/layui/images/icon_net_light_24.png similarity index 100% rename from src/laybasic/laybasic/images/icon_net_light_24.png rename to src/layui/layui/images/icon_net_light_24.png diff --git a/src/laybasic/laybasic/images/icon_net_light_32.png b/src/layui/layui/images/icon_net_light_32.png similarity index 100% rename from src/laybasic/laybasic/images/icon_net_light_32.png rename to src/layui/layui/images/icon_net_light_32.png diff --git a/src/laybasic/laybasic/images/icon_net_light_48.png b/src/layui/layui/images/icon_net_light_48.png similarity index 100% rename from src/laybasic/laybasic/images/icon_net_light_48.png rename to src/layui/layui/images/icon_net_light_48.png diff --git a/src/laybasic/laybasic/images/icon_pin_16.png b/src/layui/layui/images/icon_pin_16.png similarity index 100% rename from src/laybasic/laybasic/images/icon_pin_16.png rename to src/layui/layui/images/icon_pin_16.png diff --git a/src/laybasic/laybasic/images/icon_pin_24.png b/src/layui/layui/images/icon_pin_24.png similarity index 100% rename from src/laybasic/laybasic/images/icon_pin_24.png rename to src/layui/layui/images/icon_pin_24.png diff --git a/src/laybasic/laybasic/images/icon_pin_32.png b/src/layui/layui/images/icon_pin_32.png similarity index 100% rename from src/laybasic/laybasic/images/icon_pin_32.png rename to src/layui/layui/images/icon_pin_32.png diff --git a/src/laybasic/laybasic/images/icon_pin_48.png b/src/layui/layui/images/icon_pin_48.png similarity index 100% rename from src/laybasic/laybasic/images/icon_pin_48.png rename to src/layui/layui/images/icon_pin_48.png diff --git a/src/laybasic/laybasic/images/icons.svg b/src/layui/layui/images/icons.svg similarity index 100% rename from src/laybasic/laybasic/images/icons.svg rename to src/layui/layui/images/icons.svg diff --git a/src/laybasic/laybasic/images/st_plus_node.png b/src/layui/layui/images/st_plus_node.png similarity index 100% rename from src/laybasic/laybasic/images/st_plus_node.png rename to src/layui/layui/images/st_plus_node.png diff --git a/src/laybasic/laybasic/layBackgroundAwareTreeStyle.cc b/src/layui/layui/layBackgroundAwareTreeStyle.cc similarity index 100% rename from src/laybasic/laybasic/layBackgroundAwareTreeStyle.cc rename to src/layui/layui/layBackgroundAwareTreeStyle.cc diff --git a/src/laybasic/laybasic/layBackgroundAwareTreeStyle.h b/src/layui/layui/layBackgroundAwareTreeStyle.h similarity index 95% rename from src/laybasic/laybasic/layBackgroundAwareTreeStyle.h rename to src/layui/layui/layBackgroundAwareTreeStyle.h index 03ec99000..d0ad1b81a 100644 --- a/src/laybasic/laybasic/layBackgroundAwareTreeStyle.h +++ b/src/layui/layui/layBackgroundAwareTreeStyle.h @@ -25,7 +25,7 @@ #ifndef HDR_layBackgroundAwareTreeStyle #define HDR_layBackgroundAwareTreeStyle -#include "laybasicCommon.h" +#include "layuiCommon.h" #include @@ -39,7 +39,7 @@ namespace lay * The default Gtk style is not, hence making the background dark means the * triangles become invisible. */ -class LAYBASIC_PUBLIC BackgroundAwareTreeStyle +class LAYUI_PUBLIC BackgroundAwareTreeStyle : public QProxyStyle { public: diff --git a/src/laybasic/laybasic/layBookmarkManagementForm.cc b/src/layui/layui/layBookmarkManagementForm.cc similarity index 80% rename from src/laybasic/laybasic/layBookmarkManagementForm.cc rename to src/layui/layui/layBookmarkManagementForm.cc index 51b9358d1..a2f2172f4 100644 --- a/src/laybasic/laybasic/layBookmarkManagementForm.cc +++ b/src/layui/layui/layBookmarkManagementForm.cc @@ -24,7 +24,8 @@ #include "layBookmarkManagementForm.h" #include "dbCellInst.h" -#include "layLayoutView.h" + +#include "ui_BookmarkManagementForm.h" #include @@ -55,17 +56,18 @@ private: // ------------------------------------------------------------ BookmarkManagementForm::BookmarkManagementForm (QWidget *parent, const char *name, const lay::BookmarkList &bookmarks, const std::set &selected) - : QDialog (parent), Ui::BookmarkManagementForm (), + : QDialog (parent), m_bookmarks (bookmarks) { + mp_ui = new Ui::BookmarkManagementForm (); setObjectName (QString::fromUtf8 (name)); - Ui::BookmarkManagementForm::setupUi (this); + mp_ui->setupUi (this); QListWidgetItem *first_item = 0; for (size_t i = 0; i < m_bookmarks.size (); ++i) { - QListWidgetItem *item = new BookmarkListLVI (bookmark_list, m_bookmarks.name (i), m_bookmarks.state (i)); + QListWidgetItem *item = new BookmarkListLVI (mp_ui->bookmark_list, m_bookmarks.name (i), m_bookmarks.state (i)); item->setSelected (selected.find (i) != selected.end ()); if (! first_item && item->isSelected ()) { first_item = item; @@ -73,16 +75,16 @@ BookmarkManagementForm::BookmarkManagementForm (QWidget *parent, const char *nam } if (first_item) { - bookmark_list->scrollToItem (first_item); + mp_ui->bookmark_list->scrollToItem (first_item); } - connect (delete_button, SIGNAL (clicked ()), this, SLOT (delete_pressed ())); + connect (mp_ui->delete_button, SIGNAL (clicked ()), this, SLOT (delete_pressed ())); } void BookmarkManagementForm::delete_pressed () { - QList sel = bookmark_list->selectedItems (); + QList sel = mp_ui->bookmark_list->selectedItems (); for (QList::const_iterator i = sel.begin (); i != sel.end (); ++i) { delete *i; } @@ -92,12 +94,12 @@ void BookmarkManagementForm::accept () { m_bookmarks.clear (); - m_bookmarks.reserve (bookmark_list->count ()); + m_bookmarks.reserve (mp_ui->bookmark_list->count ()); // TODO: is there an iterator? Here we use the trick to select all and then get the // list of items - bookmark_list->selectAll (); - QList sel = bookmark_list->selectedItems (); + mp_ui->bookmark_list->selectAll (); + QList sel = mp_ui->bookmark_list->selectedItems (); for (QList::const_iterator i = sel.begin (); i != sel.end (); ++i) { BookmarkListLVI *bm = dynamic_cast (*i); if (bm) { diff --git a/src/laybasic/laybasic/layBookmarkManagementForm.h b/src/layui/layui/layBookmarkManagementForm.h similarity index 88% rename from src/laybasic/laybasic/layBookmarkManagementForm.h rename to src/layui/layui/layBookmarkManagementForm.h index 0b419c181..6973bf11f 100644 --- a/src/laybasic/laybasic/layBookmarkManagementForm.h +++ b/src/layui/layui/layBookmarkManagementForm.h @@ -25,18 +25,22 @@ #ifndef HDR_layBookmarkManagementForm #define HDR_layBookmarkManagementForm -#include // required during the dependency pass -#include "ui_BookmarkManagementForm.h" +#include -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include +namespace Ui +{ + class BookmarkManagementForm; +} + namespace lay { class BookmarkManagementForm - : public QDialog, private Ui::BookmarkManagementForm + : public QDialog { Q_OBJECT @@ -57,6 +61,7 @@ public slots: void delete_pressed (); private: + Ui::BookmarkManagementForm *mp_ui; lay::BookmarkList m_bookmarks; }; diff --git a/src/laybasic/laybasic/layBookmarksView.cc b/src/layui/layui/layBookmarksView.cc similarity index 98% rename from src/laybasic/laybasic/layBookmarksView.cc rename to src/layui/layui/layBookmarksView.cc index 88d359385..3bdbe7cee 100644 --- a/src/laybasic/laybasic/layBookmarksView.cc +++ b/src/layui/layui/layBookmarksView.cc @@ -23,7 +23,7 @@ #if defined(HAVE_QT) #include "layBookmarksView.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "layAbstractMenu.h" #include "laybasicConfig.h" @@ -89,7 +89,7 @@ private: // -------------------------------------------------------------------------------------------- -BookmarksView::BookmarksView (LayoutView *view, QWidget *parent, const char *name) +BookmarksView::BookmarksView (LayoutViewBase *view, QWidget *parent, const char *name) : QFrame (parent), m_follow_selection (false) { setObjectName (QString::fromUtf8 (name)); diff --git a/src/laybasic/laybasic/layBookmarksView.h b/src/layui/layui/layBookmarksView.h similarity index 90% rename from src/laybasic/laybasic/layBookmarksView.h rename to src/layui/layui/layBookmarksView.h index 3a4f78a63..8393f9fea 100644 --- a/src/laybasic/laybasic/layBookmarksView.h +++ b/src/layui/layui/layBookmarksView.h @@ -25,7 +25,7 @@ #ifndef HDR_layBookmarksView #define HDR_layBookmarksView -#include "laybasicCommon.h" +#include "layuiCommon.h" #include "layBookmarkList.h" #include "layColor.h" @@ -44,13 +44,13 @@ class AbstractMenu; /** * @brief A widget to display a bookmark list */ -class LAYBASIC_PUBLIC BookmarksView +class LAYUI_PUBLIC BookmarksView : public QFrame { Q_OBJECT public: - BookmarksView (LayoutView *view, QWidget *parent, const char *name); + BookmarksView (lay::LayoutViewBase *view, QWidget *parent, const char *name); ~BookmarksView (); void set_background_color (lay::Color c); @@ -67,7 +67,7 @@ public slots: void context_menu (const QPoint &p); private: - LayoutView *mp_view; + LayoutViewBase *mp_view; QListView *mp_bookmarks; bool m_follow_selection; }; diff --git a/src/laybasic/laybasic/layBrowseInstancesForm.cc b/src/layui/layui/layBrowseInstancesForm.cc similarity index 99% rename from src/laybasic/laybasic/layBrowseInstancesForm.cc rename to src/layui/layui/layBrowseInstancesForm.cc index f64695169..b1946ebb9 100644 --- a/src/laybasic/laybasic/layBrowseInstancesForm.cc +++ b/src/layui/layui/layBrowseInstancesForm.cc @@ -80,7 +80,7 @@ public: menu_entries.push_back (lay::menu_item ("browse_instances::show", "browse_instances", "tools_menu.end", tl::to_string (QObject::tr ("Browse Instances")))); } - virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutView *view) const + virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutViewBase *view) const { return new BrowseInstancesForm (root, view); } @@ -290,7 +290,7 @@ private: // ------------------------------------------------------------ -BrowseInstancesForm::BrowseInstancesForm (lay::Dispatcher *root, LayoutView *vw) +BrowseInstancesForm::BrowseInstancesForm (lay::Dispatcher *root, LayoutViewBase *vw) : lay::Browser (root, vw), Ui::BrowseInstancesForm (), m_cv_index (0), @@ -533,7 +533,7 @@ BrowseInstancesForm::activated () // obtain active cellview index and cell index int cv_index = view ()->active_cellview_index (); - lay::LayoutView::cell_path_type path; + lay::LayoutViewBase::cell_path_type path; view ()->current_cell_path (path); // no cell to index diff --git a/src/laybasic/laybasic/layBrowseInstancesForm.h b/src/layui/layui/layBrowseInstancesForm.h similarity index 97% rename from src/laybasic/laybasic/layBrowseInstancesForm.h rename to src/layui/layui/layBrowseInstancesForm.h index 8cb36254e..20a5b2479 100644 --- a/src/laybasic/laybasic/layBrowseInstancesForm.h +++ b/src/layui/layui/layBrowseInstancesForm.h @@ -28,7 +28,7 @@ #include "ui_BrowseInstancesForm.h" #include "ui_BrowseInstancesConfigPage.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "layPluginConfigPage.h" #include "layBrowser.h" #include "layMarker.h" @@ -66,7 +66,7 @@ public: enum mode_type { ToCellView = 0, AnyTop, Parent }; enum window_type { DontChange = 0, FitCell, FitMarker, Center, CenterSize }; - BrowseInstancesForm (lay::Dispatcher *root, lay::LayoutView *view); + BrowseInstancesForm (lay::Dispatcher *root, lay::LayoutViewBase *view); ~BrowseInstancesForm (); bool eventFilter (QObject *watched, QEvent *event); diff --git a/src/laybasic/laybasic/layBrowseShapesForm.cc b/src/layui/layui/layBrowseShapesForm.cc similarity index 99% rename from src/laybasic/laybasic/layBrowseShapesForm.cc rename to src/layui/layui/layBrowseShapesForm.cc index 01df4fc13..e75fd9bbb 100644 --- a/src/laybasic/laybasic/layBrowseShapesForm.cc +++ b/src/layui/layui/layBrowseShapesForm.cc @@ -81,7 +81,7 @@ public: menu_entries.push_back (lay::menu_item ("browse_shapes::show", "browse_shapes", "tools_menu.end", tl::to_string (QObject::tr ("Browse Shapes")))); } - virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutView *view) const + virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutViewBase *view) const { return new BrowseShapesForm (root, view); } @@ -393,7 +393,7 @@ private: // ------------------------------------------------------------ -BrowseShapesForm::BrowseShapesForm (lay::Dispatcher *root, LayoutView *vw) +BrowseShapesForm::BrowseShapesForm (lay::Dispatcher *root, LayoutViewBase *vw) : lay::Browser (root, vw), Ui::BrowseShapesForm (), m_cv_index (-1), diff --git a/src/laybasic/laybasic/layBrowseShapesForm.h b/src/layui/layui/layBrowseShapesForm.h similarity index 97% rename from src/laybasic/laybasic/layBrowseShapesForm.h rename to src/layui/layui/layBrowseShapesForm.h index 9e79ff62a..e12a193b5 100644 --- a/src/laybasic/laybasic/layBrowseShapesForm.h +++ b/src/layui/layui/layBrowseShapesForm.h @@ -28,7 +28,7 @@ #include "ui_BrowseShapesForm.h" #include "ui_BrowseShapesConfigPage.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "layPluginConfigPage.h" #include "layBrowser.h" #include "layMarker.h" @@ -65,7 +65,7 @@ public: enum mode_type { ToCellView = 0, AnyTop, Local }; enum window_type { DontChange = 0, FitCell, FitMarker, Center, CenterSize }; - BrowseShapesForm (lay::Dispatcher *root, LayoutView *view); + BrowseShapesForm (lay::Dispatcher *root, LayoutViewBase *view); ~BrowseShapesForm (); bool eventFilter (QObject *watched, QEvent *event); diff --git a/src/laybasic/laybasic/layBrowser.cc b/src/layui/layui/layBrowser.cc similarity index 88% rename from src/laybasic/laybasic/layBrowser.cc rename to src/layui/layui/layBrowser.cc index 049076bf5..27a32a324 100644 --- a/src/laybasic/laybasic/layBrowser.cc +++ b/src/layui/layui/layBrowser.cc @@ -25,7 +25,7 @@ #include #include "layBrowser.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include @@ -33,9 +33,9 @@ namespace lay { #if QT_VERSION >= 0x050000 -Browser::Browser (lay::Dispatcher *root, lay::LayoutView *view, const char *name, Qt::WindowFlags fl) +Browser::Browser (lay::Dispatcher *root, lay::LayoutViewBase *view, const char *name, Qt::WindowFlags fl) #else -Browser::Browser (lay::Dispatcher *root, lay::LayoutView *view, const char *name, Qt::WFlags fl) +Browser::Browser (lay::Dispatcher *root, lay::LayoutViewBase *view, const char *name, Qt::WFlags fl) #endif // TODO: clarify whether to keep the browsers as separate (potentially hidden) windows : QDialog (0 /*view*/, fl), diff --git a/src/laybasic/laybasic/layBrowser.h b/src/layui/layui/layBrowser.h similarity index 87% rename from src/laybasic/laybasic/layBrowser.h rename to src/layui/layui/layBrowser.h index b5ae1b70d..f10434e75 100644 --- a/src/laybasic/laybasic/layBrowser.h +++ b/src/layui/layui/layBrowser.h @@ -25,7 +25,7 @@ #ifndef HDR_layBrowser #define HDR_layBrowser -#include "laybasicCommon.h" +#include "layuiCommon.h" #include "layPlugin.h" @@ -36,10 +36,10 @@ class QCloseEvent; namespace lay { -class LayoutView; +class LayoutViewBase; class Dispatcher; -class LAYBASIC_PUBLIC Browser +class LAYUI_PUBLIC Browser : public QDialog, public lay::Plugin { @@ -48,9 +48,9 @@ public: * @brief Constructor */ #if QT_VERSION >= 0x050000 - Browser (lay::Dispatcher *root, lay::LayoutView *view, const char *name = "", Qt::WindowFlags fl = Qt::Window /*adds minimize button for example*/); + Browser (lay::Dispatcher *root, lay::LayoutViewBase *view, const char *name = "", Qt::WindowFlags fl = Qt::Window /*adds minimize button for example*/); #else - Browser (lay::Dispatcher *root, lay::LayoutView *view, const char *name = "", Qt::WFlags fl = Qt::Window /*adds minimize button for example*/); + Browser (lay::Dispatcher *root, lay::LayoutViewBase *view, const char *name = "", Qt::WFlags fl = Qt::Window /*adds minimize button for example*/); #endif /** @@ -94,7 +94,7 @@ public: /** * @brief Return the pointer to the layout view */ - lay::LayoutView *view () + lay::LayoutViewBase *view () { return mp_view; } @@ -133,7 +133,7 @@ public: private: bool m_active; - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; lay::Dispatcher *mp_root; void closeEvent (QCloseEvent *); diff --git a/src/laybasic/laybasic/layBrowserDialog.cc b/src/layui/layui/layBrowserDialog.cc similarity index 100% rename from src/laybasic/laybasic/layBrowserDialog.cc rename to src/layui/layui/layBrowserDialog.cc diff --git a/src/laybasic/laybasic/layBrowserDialog.h b/src/layui/layui/layBrowserDialog.h similarity index 98% rename from src/laybasic/laybasic/layBrowserDialog.h rename to src/layui/layui/layBrowserDialog.h index 80bd01b41..959277f99 100644 --- a/src/laybasic/laybasic/layBrowserDialog.h +++ b/src/layui/layui/layBrowserDialog.h @@ -42,7 +42,7 @@ namespace lay * URL's with the special scheme "int" are retrieved from a BrowserSource object. * This will act as a kind of "server" for these URL's. */ -class LAYBASIC_PUBLIC BrowserDialog +class LAYUI_PUBLIC BrowserDialog : public QDialog, private Ui::BrowserDialog { diff --git a/src/laybasic/laybasic/layBrowserPanel.cc b/src/layui/layui/layBrowserPanel.cc similarity index 100% rename from src/laybasic/laybasic/layBrowserPanel.cc rename to src/layui/layui/layBrowserPanel.cc diff --git a/src/laybasic/laybasic/layBrowserPanel.h b/src/layui/layui/layBrowserPanel.h similarity index 97% rename from src/laybasic/laybasic/layBrowserPanel.h rename to src/layui/layui/layBrowserPanel.h index e97851b3d..70627b0e2 100644 --- a/src/laybasic/laybasic/layBrowserPanel.h +++ b/src/layui/layui/layBrowserPanel.h @@ -25,7 +25,7 @@ #ifndef HDR_layBrowserPanel #define HDR_layBrowserPanel -#include "laybasicCommon.h" +#include "layuiCommon.h" #include "tlDeferredExecution.h" #include "tlObject.h" #include "gsiObject.h" @@ -58,7 +58,7 @@ class Dispatcher; * The outline is a hierarchical tree of items. Each node has a title, a URL to navigate to and * optional child items. */ -class LAYBASIC_PUBLIC BrowserOutline +class LAYUI_PUBLIC BrowserOutline { public: typedef std::list::const_iterator const_child_iterator; @@ -170,7 +170,7 @@ private: /** * @brief The source for BrowserDialog's "int" URL's */ -class LAYBASIC_PUBLIC BrowserSource +class LAYUI_PUBLIC BrowserSource : public gsi::ObjectBase, public tl::Object { public: @@ -262,7 +262,7 @@ private: /** * @brief A specialization of QTextBrowser that allows loading a specific resource through BrowserPanel */ -class LAYBASIC_PUBLIC BrowserTextWidget +class LAYUI_PUBLIC BrowserTextWidget : public QTextBrowser { public: @@ -286,7 +286,7 @@ private: /** * @brief A structure describing a bookmark item */ -struct LAYBASIC_PUBLIC BookmarkItem +struct LAYUI_PUBLIC BookmarkItem { BookmarkItem () : position (0) { } @@ -306,7 +306,7 @@ struct LAYBASIC_PUBLIC BookmarkItem /** * @brief A specialization of QWidget around a TextBrowser that allows loading a specific resource */ -class LAYBASIC_PUBLIC BrowserPanel +class LAYUI_PUBLIC BrowserPanel : public QWidget { friend class BrowserTextWidget; diff --git a/src/laybasic/laybasic/layBusy.cc b/src/layui/layui/layBusy.cc similarity index 100% rename from src/laybasic/laybasic/layBusy.cc rename to src/layui/layui/layBusy.cc diff --git a/src/laybasic/laybasic/layBusy.h b/src/layui/layui/layBusy.h similarity index 93% rename from src/laybasic/laybasic/layBusy.h rename to src/layui/layui/layBusy.h index 9996faef9..cda8c2e32 100644 --- a/src/laybasic/laybasic/layBusy.h +++ b/src/layui/layui/layBusy.h @@ -25,7 +25,7 @@ #ifndef HDR_layBusy #define HDR_layBusy -#include "laybasicCommon.h" +#include "layuiCommon.h" namespace lay { @@ -35,7 +35,7 @@ namespace lay * * There must be one provider implementing this interface. */ -class LAYBASIC_PUBLIC BusyMode +class LAYUI_PUBLIC BusyMode { public: BusyMode (); @@ -48,7 +48,7 @@ public: /** * @brief A RAII implementation of the busy mode setter */ -class LAYBASIC_PUBLIC BusySection +class LAYUI_PUBLIC BusySection { public: BusySection (); diff --git a/src/laybasic/laybasic/layCellSelectionForm.cc b/src/layui/layui/layCellSelectionForm.cc similarity index 99% rename from src/laybasic/laybasic/layCellSelectionForm.cc rename to src/layui/layui/layCellSelectionForm.cc index 80011e089..c9496b4b0 100644 --- a/src/laybasic/laybasic/layCellSelectionForm.cc +++ b/src/layui/layui/layCellSelectionForm.cc @@ -37,7 +37,7 @@ #include "tlAssert.h" #include "layCellTreeModel.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "tlExceptions.h" #include @@ -50,7 +50,7 @@ static const std::string cfg_cell_selection_search_use_expressions ("cell-select // ------------------------------------------------------------ -CellSelectionForm::CellSelectionForm (QWidget *parent, LayoutView *view, const char *name, bool simple_mode) +CellSelectionForm::CellSelectionForm (QWidget *parent, LayoutViewBase *view, const char *name, bool simple_mode) : QDialog (parent), Ui::CellSelectionForm (), mp_view (view), m_current_cv (-1), diff --git a/src/laybasic/laybasic/layCellSelectionForm.h b/src/layui/layui/layCellSelectionForm.h similarity index 95% rename from src/laybasic/laybasic/layCellSelectionForm.h rename to src/layui/layui/layCellSelectionForm.h index 0c3fd9027..f878e9116 100644 --- a/src/laybasic/laybasic/layCellSelectionForm.h +++ b/src/layui/layui/layCellSelectionForm.h @@ -44,13 +44,13 @@ class LayoutView; /** * @brief A form to select a cell and a cell view index */ -class LAYBASIC_PUBLIC CellSelectionForm +class LAYUI_PUBLIC CellSelectionForm : public QDialog, private Ui::CellSelectionForm { Q_OBJECT public: - CellSelectionForm (QWidget *parent, LayoutView *view, const char *name, bool simple_mode = false); + CellSelectionForm (QWidget *parent, LayoutViewBase *view, const char *name, bool simple_mode = false); /** * @brief Obtain the selected cellview's index (with changes) @@ -77,7 +77,7 @@ public slots: void find_prev_clicked(); private: - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; std::vector m_cellviews; int m_current_cv; bool m_name_cb_enabled; @@ -103,7 +103,7 @@ private: /** * @brief A form to select a cell from a library */ -class LAYBASIC_PUBLIC LibraryCellSelectionForm +class LAYUI_PUBLIC LibraryCellSelectionForm : public QDialog, private Ui::LibraryCellSelectionForm { Q_OBJECT diff --git a/src/laybasic/laybasic/layCellTreeModel.cc b/src/layui/layui/layCellTreeModel.cc similarity index 98% rename from src/laybasic/laybasic/layCellTreeModel.cc rename to src/layui/layui/layCellTreeModel.cc index 0c45b929b..6568a2c3c 100644 --- a/src/laybasic/laybasic/layCellTreeModel.cc +++ b/src/layui/layui/layCellTreeModel.cc @@ -23,7 +23,7 @@ #if defined(HAVE_QT) #include "layCellTreeModel.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "layDragDropData.h" #include "tlGlobPattern.h" #include "dbPCellHeader.h" @@ -305,7 +305,7 @@ CellTreeItem::by_area_equal_than (const CellTreeItem *b) const // valid ("under construction"). In this case, the model will return defaults or void // objects. -CellTreeModel::CellTreeModel (QWidget *parent, lay::LayoutView *view, int cv_index, unsigned int flags, const db::Cell *base, Sorting sorting) +CellTreeModel::CellTreeModel (QWidget *parent, lay::LayoutViewBase *view, int cv_index, unsigned int flags, const db::Cell *base, Sorting sorting) : QAbstractItemModel (parent), m_flags (flags), m_sorting (sorting), @@ -381,7 +381,7 @@ CellTreeModel::~CellTreeModel () } void -CellTreeModel::configure (lay::LayoutView *view, int cv_index, unsigned int flags, const db::Cell *base, Sorting sorting) +CellTreeModel::configure (lay::LayoutViewBase *view, int cv_index, unsigned int flags, const db::Cell *base, Sorting sorting) { db::Layout *layout = & view->cellview (cv_index)->layout (); do_configure (layout, 0, view, cv_index, flags, base, sorting); @@ -400,7 +400,7 @@ CellTreeModel::configure (db::Library *library, unsigned int flags, const db::Ce } void -CellTreeModel::do_configure (db::Layout *layout, db::Library *library, lay::LayoutView *view, int cv_index, unsigned int flags, const db::Cell *base, Sorting sorting) +CellTreeModel::do_configure (db::Layout *layout, db::Library *library, lay::LayoutViewBase *view, int cv_index, unsigned int flags, const db::Cell *base, Sorting sorting) { bool flat = ((flags & Flat) != 0) && ((flags & TopCells) == 0); diff --git a/src/laybasic/laybasic/layCellTreeModel.h b/src/layui/layui/layCellTreeModel.h similarity index 95% rename from src/laybasic/laybasic/layCellTreeModel.h rename to src/layui/layui/layCellTreeModel.h index 590f3dfb0..0ddf88dce 100644 --- a/src/laybasic/laybasic/layCellTreeModel.h +++ b/src/layui/layui/layCellTreeModel.h @@ -46,7 +46,7 @@ namespace db namespace lay { -class LayoutView; +class LayoutViewBase; class CellTreeItem; /** @@ -86,7 +86,7 @@ public: * If flags "Children" or "Parents" are given, "base" must be set to the cell of which * the children or parents should be derived. */ - CellTreeModel (QWidget *parent, lay::LayoutView *view, int cv_index, unsigned int flags = 0, const db::Cell *base = 0, Sorting sorting = ByName); + CellTreeModel (QWidget *parent, lay::LayoutViewBase *view, int cv_index, unsigned int flags = 0, const db::Cell *base = 0, Sorting sorting = ByName); /** * @brief Constructor @@ -121,7 +121,7 @@ public: /** * @brief Reconfigures the model with a LayoutView */ - void configure (LayoutView *view, int cv_index, unsigned int flags = 0, const db::Cell *base = 0, Sorting sorting = ByName); + void configure (LayoutViewBase *view, int cv_index, unsigned int flags = 0, const db::Cell *base = 0, Sorting sorting = ByName); /** * @brief Reconfigures the model with a pure Layout @@ -258,7 +258,7 @@ private: unsigned int m_flags; Sorting m_sorting; QWidget *mp_parent; - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; db::Layout *mp_layout; db::Library *mp_library; int m_cv_index; @@ -272,7 +272,7 @@ private: void build_top_level (); void clear_top_level (); bool search_children (const tl::GlobPattern &pattern, CellTreeItem *item); - void do_configure (db::Layout *layout, db::Library *library, LayoutView *view, int cv_index, unsigned int flags, const db::Cell *base, Sorting sorting); + void do_configure (db::Layout *layout, db::Library *library, LayoutViewBase *view, int cv_index, unsigned int flags, const db::Cell *base, Sorting sorting); }; /** diff --git a/src/laybasic/laybasic/layConfigurationDialog.cc b/src/layui/layui/layConfigurationDialog.cc similarity index 100% rename from src/laybasic/laybasic/layConfigurationDialog.cc rename to src/layui/layui/layConfigurationDialog.cc diff --git a/src/laybasic/laybasic/layConfigurationDialog.h b/src/layui/layui/layConfigurationDialog.h similarity index 97% rename from src/laybasic/laybasic/layConfigurationDialog.h rename to src/layui/layui/layConfigurationDialog.h index 95627bf07..13e0a86c5 100644 --- a/src/laybasic/laybasic/layConfigurationDialog.h +++ b/src/layui/layui/layConfigurationDialog.h @@ -43,7 +43,7 @@ class Dispatcher; class ConfigPage; class PluginDeclaration; -class LAYBASIC_PUBLIC ConfigurationDialog +class LAYUI_PUBLIC ConfigurationDialog : public QDialog { Q_OBJECT diff --git a/src/laybasic/laybasic/layDialogs.cc b/src/layui/layui/layDialogs.cc similarity index 99% rename from src/laybasic/laybasic/layDialogs.cc rename to src/layui/layui/layDialogs.cc index 1a93cf670..5128640d3 100644 --- a/src/laybasic/laybasic/layDialogs.cc +++ b/src/layui/layui/layDialogs.cc @@ -33,8 +33,7 @@ #include "layLayerProperties.h" #include "layFileDialog.h" -#include "layLayoutView.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "layCellTreeModel.h" #include "layQtTools.h" #include "layGenericSyntaxHighlighter.h" @@ -824,7 +823,7 @@ DuplicateLayerDialog::cv_changed (int) } bool -DuplicateLayerDialog::exec_dialog (lay::LayoutView *view, int &cv, int &layer, int &cv_r, int &layer_r, int &hier_mode, bool &clear_before) +DuplicateLayerDialog::exec_dialog (lay::LayoutViewBase *view, int &cv, int &layer, int &cv_r, int &layer_r, int &hier_mode, bool &clear_before) { mp_view = view; @@ -1180,7 +1179,7 @@ UserPropertiesForm::set_properties (const db::PropertiesRepository::properties_s } bool -UserPropertiesForm::show (lay::LayoutView *view, unsigned int cv_index, db::properties_id_type &prop_id) +UserPropertiesForm::show (LayoutViewBase *view, unsigned int cv_index, db::properties_id_type &prop_id) { bool ret = false; diff --git a/src/laybasic/laybasic/layDialogs.h b/src/layui/layui/layDialogs.h similarity index 88% rename from src/laybasic/laybasic/layDialogs.h rename to src/layui/layui/layDialogs.h index 0e35fb555..b78de3731 100644 --- a/src/laybasic/laybasic/layDialogs.h +++ b/src/layui/layui/layDialogs.h @@ -29,7 +29,7 @@ #include "dbVector.h" #include "dbTypes.h" #include "dbPropertiesRepository.h" -#include "laybasicCommon.h" +#include "layuiCommon.h" #include #include @@ -72,12 +72,12 @@ namespace lay { class CellView; -class LayoutView; +class LayoutViewBase; /** * @brief The layer source dialog */ -class LAYBASIC_PUBLIC LayerSourceDialog +class LAYUI_PUBLIC LayerSourceDialog : public QDialog { Q_OBJECT @@ -95,7 +95,7 @@ private: /** * @brief The new cell properties dialog */ -class LAYBASIC_PUBLIC NewCellPropertiesDialog +class LAYUI_PUBLIC NewCellPropertiesDialog : public QDialog { Q_OBJECT @@ -116,7 +116,7 @@ private: /** * @brief The new layer properties dialog */ -class LAYBASIC_PUBLIC NewLayerPropertiesDialog +class LAYUI_PUBLIC NewLayerPropertiesDialog : public QDialog { Q_OBJECT @@ -138,7 +138,7 @@ private: /** * @brief The move options dialog */ -class LAYBASIC_PUBLIC MoveOptionsDialog +class LAYUI_PUBLIC MoveOptionsDialog : public QDialog { Q_OBJECT @@ -158,7 +158,7 @@ private: /** * @brief The move "to" options dialog */ -class LAYBASIC_PUBLIC MoveToOptionsDialog +class LAYUI_PUBLIC MoveToOptionsDialog : public QDialog { Q_OBJECT @@ -181,7 +181,7 @@ private: /** * @brief The rename cell options dialog */ -class LAYBASIC_PUBLIC RenameCellDialog +class LAYUI_PUBLIC RenameCellDialog : public QDialog { Q_OBJECT @@ -202,7 +202,7 @@ private: /** * @brief The replace cell options dialog */ -class LAYBASIC_PUBLIC ReplaceCellOptionsDialog +class LAYUI_PUBLIC ReplaceCellOptionsDialog : public QDialog { Q_OBJECT @@ -228,7 +228,7 @@ private: /** * @brief The copy cell options dialog */ -class LAYBASIC_PUBLIC CopyCellModeDialog +class LAYUI_PUBLIC CopyCellModeDialog : public QDialog { Q_OBJECT @@ -251,7 +251,7 @@ private: /** * @brief The delete cell options dialog */ -class LAYBASIC_PUBLIC DeleteCellModeDialog +class LAYUI_PUBLIC DeleteCellModeDialog : public QDialog { Q_OBJECT @@ -274,7 +274,7 @@ private: /** * @brief The delete cell options dialog */ -class LAYBASIC_PUBLIC ClearLayerModeDialog +class LAYUI_PUBLIC ClearLayerModeDialog : public QDialog { Q_OBJECT @@ -297,7 +297,7 @@ private: /** * @brief The open layout mode dialog */ -class LAYBASIC_PUBLIC OpenLayoutModeDialog +class LAYUI_PUBLIC OpenLayoutModeDialog : public QDialog { Q_OBJECT @@ -320,7 +320,7 @@ private: /** * @brief The new layout properties dialog */ -class LAYBASIC_PUBLIC NewLayoutPropertiesDialog +class LAYUI_PUBLIC NewLayoutPropertiesDialog : public QDialog { Q_OBJECT @@ -343,7 +343,7 @@ private: /** * @brief The duplicate layer operation options */ -class LAYBASIC_PUBLIC DuplicateLayerDialog +class LAYUI_PUBLIC DuplicateLayerDialog : public QDialog { Q_OBJECT @@ -352,7 +352,7 @@ public: DuplicateLayerDialog (QWidget *parent); virtual ~DuplicateLayerDialog (); - bool exec_dialog (lay::LayoutView *view, int &cv, int &layer, int &cv_res, int &layer_res, int &hier_mode, bool &clear_before); + bool exec_dialog (lay::LayoutViewBase *view, int &cv, int &layer, int &cv_res, int &layer_res, int &hier_mode, bool &clear_before); public slots: void cv_changed (int); @@ -361,13 +361,13 @@ private: virtual void accept (); Ui::DuplicateLayerDialog *mp_ui; - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; }; /** * @brief A data structure holding the options for the "align cell" dialog */ -struct LAYBASIC_PUBLIC AlignCellOptions +struct LAYUI_PUBLIC AlignCellOptions { AlignCellOptions () : mode_x (-1), mode_y (-1), xpos (0.0), ypos (0.0), visible_only (false), adjust_parents (true) @@ -382,7 +382,7 @@ struct LAYBASIC_PUBLIC AlignCellOptions /** * @brief The merge operation options */ -class LAYBASIC_PUBLIC AlignCellOptionsDialog +class LAYUI_PUBLIC AlignCellOptionsDialog : public QDialog { Q_OBJECT @@ -404,7 +404,7 @@ private: /** * @brief Options dialog for the "flatten instances" function */ -class LAYBASIC_PUBLIC FlattenInstOptionsDialog +class LAYUI_PUBLIC FlattenInstOptionsDialog : public QDialog { public: @@ -420,7 +420,7 @@ private: /** * @brief The user properties report form */ -class LAYBASIC_PUBLIC UserPropertiesForm +class LAYUI_PUBLIC UserPropertiesForm : public QDialog { Q_OBJECT @@ -429,7 +429,7 @@ public: UserPropertiesForm (QWidget *parent); virtual ~UserPropertiesForm (); - bool show (lay::LayoutView *view, unsigned int cv_index, db::properties_id_type &prop_id); + bool show (lay::LayoutViewBase *view, unsigned int cv_index, db::properties_id_type &prop_id); public slots: void add (); @@ -452,7 +452,7 @@ private: /** * @brief The user properties report form */ -class LAYBASIC_PUBLIC UserPropertiesEditForm +class LAYUI_PUBLIC UserPropertiesEditForm : public QDialog { public: diff --git a/src/laybasic/laybasic/layEditLineStyleWidget.cc b/src/layui/layui/layEditLineStyleWidget.cc similarity index 100% rename from src/laybasic/laybasic/layEditLineStyleWidget.cc rename to src/layui/layui/layEditLineStyleWidget.cc diff --git a/src/laybasic/laybasic/layEditLineStyleWidget.h b/src/layui/layui/layEditLineStyleWidget.h similarity index 100% rename from src/laybasic/laybasic/layEditLineStyleWidget.h rename to src/layui/layui/layEditLineStyleWidget.h diff --git a/src/laybasic/laybasic/layEditLineStylesForm.cc b/src/layui/layui/layEditLineStylesForm.cc similarity index 98% rename from src/laybasic/laybasic/layEditLineStylesForm.cc rename to src/layui/layui/layEditLineStylesForm.cc index a0cca3f00..ece6f7bca 100644 --- a/src/laybasic/laybasic/layEditLineStylesForm.cc +++ b/src/layui/layui/layEditLineStylesForm.cc @@ -25,7 +25,7 @@ #include "layEditLineStylesForm.h" #include "ui_EditLineStylesForm.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "tlExceptions.h" #include "tlString.h" @@ -50,8 +50,8 @@ struct CurrentStyleOp int prev_index, new_index; }; -EditLineStylesForm::EditLineStylesForm (lay::LayoutView *view, const lay::LineStyles &styles) - : QDialog (view), db::Object (0), +EditLineStylesForm::EditLineStylesForm (lay::LayoutViewBase *view, const lay::LineStyles &styles) + : QDialog (view->widget ()), db::Object (0), m_selected (-1), m_styles (styles), m_manager (true), mp_view (view) { m_selection_changed_enabled = false; diff --git a/src/laybasic/laybasic/layEditLineStylesForm.h b/src/layui/layui/layEditLineStylesForm.h similarity index 94% rename from src/laybasic/laybasic/layEditLineStylesForm.h rename to src/layui/layui/layEditLineStylesForm.h index a7e94a3a3..1eab57563 100644 --- a/src/laybasic/laybasic/layEditLineStylesForm.h +++ b/src/layui/layui/layEditLineStylesForm.h @@ -40,7 +40,7 @@ namespace Ui namespace lay { -class LayoutView; +class LayoutViewBase; class EditLineStylesForm : public QDialog, public db::Object @@ -48,7 +48,7 @@ class EditLineStylesForm Q_OBJECT public: - EditLineStylesForm (lay::LayoutView *view, const lay::LineStyles &styles); + EditLineStylesForm (lay::LayoutViewBase *view, const lay::LineStyles &styles); ~EditLineStylesForm (); // ... @@ -100,7 +100,7 @@ private: int m_selected; lay::LineStyles m_styles; db::Manager m_manager; - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; bool m_selection_changed_enabled; }; diff --git a/src/laybasic/laybasic/layEditStippleWidget.cc b/src/layui/layui/layEditStippleWidget.cc similarity index 100% rename from src/laybasic/laybasic/layEditStippleWidget.cc rename to src/layui/layui/layEditStippleWidget.cc diff --git a/src/laybasic/laybasic/layEditStippleWidget.h b/src/layui/layui/layEditStippleWidget.h similarity index 100% rename from src/laybasic/laybasic/layEditStippleWidget.h rename to src/layui/layui/layEditStippleWidget.h diff --git a/src/laybasic/laybasic/layEditStipplesForm.cc b/src/layui/layui/layEditStipplesForm.cc similarity index 99% rename from src/laybasic/laybasic/layEditStipplesForm.cc rename to src/layui/layui/layEditStipplesForm.cc index 6005880ce..eef978271 100644 --- a/src/laybasic/laybasic/layEditStipplesForm.cc +++ b/src/layui/layui/layEditStipplesForm.cc @@ -25,7 +25,7 @@ #include "layEditStipplesForm.h" #include "ui_EditStipplesForm.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "tlExceptions.h" #include "tlString.h" @@ -50,8 +50,8 @@ struct CurrentPatternOp int prev_index, new_index; }; -EditStipplesForm::EditStipplesForm (lay::LayoutView *view, const lay::DitherPattern &pattern) - : QDialog (view), db::Object (0), +EditStipplesForm::EditStipplesForm (lay::LayoutViewBase *view, const lay::DitherPattern &pattern) + : QDialog (view->widget ()), db::Object (0), m_selected (-1), m_pattern (pattern), m_manager (true), mp_view (view) { m_selection_changed_enabled = false; diff --git a/src/laybasic/laybasic/layEditStipplesForm.h b/src/layui/layui/layEditStipplesForm.h similarity index 94% rename from src/laybasic/laybasic/layEditStipplesForm.h rename to src/layui/layui/layEditStipplesForm.h index e8ca40ce8..9d3e55cd0 100644 --- a/src/laybasic/laybasic/layEditStipplesForm.h +++ b/src/layui/layui/layEditStipplesForm.h @@ -40,7 +40,7 @@ namespace Ui namespace lay { -class LayoutView; +class LayoutViewBase; class EditStipplesForm : public QDialog, public db::Object @@ -48,7 +48,7 @@ class EditStipplesForm Q_OBJECT public: - EditStipplesForm (lay::LayoutView *view, const lay::DitherPattern &pattern); + EditStipplesForm (lay::LayoutViewBase *view, const lay::DitherPattern &pattern); ~EditStipplesForm (); // ... @@ -104,7 +104,7 @@ private: int m_selected; lay::DitherPattern m_pattern; db::Manager m_manager; - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; bool m_selection_changed_enabled; }; diff --git a/src/laybasic/laybasic/layEditorOptionsFrame.cc b/src/layui/layui/layEditorOptionsFrame.cc similarity index 96% rename from src/laybasic/laybasic/layEditorOptionsFrame.cc rename to src/layui/layui/layEditorOptionsFrame.cc index d7db2e458..9061e74cc 100644 --- a/src/laybasic/laybasic/layEditorOptionsFrame.cc +++ b/src/layui/layui/layEditorOptionsFrame.cc @@ -26,7 +26,7 @@ #include "layEditorOptionsPage.h" #include "layEditorOptionsPages.h" #include "layPlugin.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include @@ -49,7 +49,7 @@ EditorOptionsFrame::~EditorOptionsFrame () } void -EditorOptionsFrame::populate (LayoutView *view) +EditorOptionsFrame::populate (LayoutViewBase *view) { std::vector prop_dialog_pages; for (tl::Registrar::iterator cls = tl::Registrar::begin (); cls != tl::Registrar::end (); ++cls) { diff --git a/src/laybasic/laybasic/layEditorOptionsFrame.h b/src/layui/layui/layEditorOptionsFrame.h similarity index 90% rename from src/laybasic/laybasic/layEditorOptionsFrame.h rename to src/layui/layui/layEditorOptionsFrame.h index 396f0d9b7..e9ccb73c9 100644 --- a/src/laybasic/laybasic/layEditorOptionsFrame.h +++ b/src/layui/layui/layEditorOptionsFrame.h @@ -25,23 +25,23 @@ #ifndef HDR_layEditorOptionsFrame #define HDR_layEditorOptionsFrame -#include "laybasicCommon.h" +#include "layuiCommon.h" #include namespace lay { class EditorOptionsPages; -class LayoutView; +class LayoutViewBase; -class LAYBASIC_PUBLIC EditorOptionsFrame +class LAYUI_PUBLIC EditorOptionsFrame : public QFrame { public: EditorOptionsFrame (QWidget *parent); virtual ~EditorOptionsFrame (); - void populate (lay::LayoutView *view); + void populate (lay::LayoutViewBase *view); EditorOptionsPages *pages_widget () const { diff --git a/src/laybasic/laybasic/layEditorOptionsPage.cc b/src/layui/layui/layEditorOptionsPage.cc similarity index 94% rename from src/laybasic/laybasic/layEditorOptionsPage.cc rename to src/layui/layui/layEditorOptionsPage.cc index ba8dadb2d..0b093e259 100644 --- a/src/laybasic/laybasic/layEditorOptionsPage.cc +++ b/src/layui/layui/layEditorOptionsPage.cc @@ -25,7 +25,7 @@ #include "tlInternational.h" #include "layEditorOptionsPage.h" #include "layEditorOptionsPages.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" namespace lay { @@ -33,7 +33,7 @@ namespace lay // ------------------------------------------------------------------ // EditorOptionsPage implementation -EditorOptionsPage::EditorOptionsPage (lay::LayoutView *view, lay::Dispatcher *dispatcher) +EditorOptionsPage::EditorOptionsPage (lay::LayoutViewBase *view, lay::Dispatcher *dispatcher) : QWidget (0), mp_owner (0), m_active (true), mp_plugin_declaration (0), mp_dispatcher (dispatcher), mp_view (view) { attach_events (); diff --git a/src/laybasic/laybasic/layEditorOptionsPage.h b/src/layui/layui/layEditorOptionsPage.h similarity index 90% rename from src/laybasic/laybasic/layEditorOptionsPage.h rename to src/layui/layui/layEditorOptionsPage.h index 36356dcf3..51486fae9 100644 --- a/src/laybasic/laybasic/layEditorOptionsPage.h +++ b/src/layui/layui/layEditorOptionsPage.h @@ -25,7 +25,7 @@ #ifndef HDR_layEditorOptionsPage #define HDR_layEditorOptionsPage -#include "laybasicCommon.h" +#include "layuiCommon.h" #include "tlObject.h" @@ -36,7 +36,7 @@ namespace lay class PluginDeclaration; class Dispatcher; -class LayoutView; +class LayoutViewBase; class Plugin; class CellView; class EditorOptionsPages; @@ -44,13 +44,13 @@ class EditorOptionsPages; /** * @brief The base class for a object properties page */ -class LAYBASIC_PUBLIC EditorOptionsPage +class LAYUI_PUBLIC EditorOptionsPage : public QWidget, public tl::Object { Q_OBJECT public: - EditorOptionsPage (lay::LayoutView *view, lay::Dispatcher *dispatcher); + EditorOptionsPage (lay::LayoutViewBase *view, lay::Dispatcher *dispatcher); virtual ~EditorOptionsPage (); virtual std::string title () const = 0; @@ -78,7 +78,7 @@ protected: return mp_dispatcher; } - lay::LayoutView *view () const + lay::LayoutViewBase *view () const { return mp_view; } @@ -91,7 +91,7 @@ private: bool m_active; const lay::PluginDeclaration *mp_plugin_declaration; lay::Dispatcher *mp_dispatcher; - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; void on_active_cellview_changed (); void on_technology_changed (); diff --git a/src/laybasic/laybasic/layEditorOptionsPages.cc b/src/layui/layui/layEditorOptionsPages.cc similarity index 99% rename from src/laybasic/laybasic/layEditorOptionsPages.cc rename to src/layui/layui/layEditorOptionsPages.cc index 2c8d443fa..6dc7cc653 100644 --- a/src/laybasic/laybasic/layEditorOptionsPages.cc +++ b/src/layui/layui/layEditorOptionsPages.cc @@ -26,7 +26,7 @@ #include "layEditorOptionsPages.h" #include "tlExceptions.h" #include "layPlugin.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "layQtTools.h" #include diff --git a/src/laybasic/laybasic/layEditorOptionsPages.h b/src/layui/layui/layEditorOptionsPages.h similarity index 96% rename from src/laybasic/laybasic/layEditorOptionsPages.h rename to src/layui/layui/layEditorOptionsPages.h index a21f82fd0..8e40676d6 100644 --- a/src/laybasic/laybasic/layEditorOptionsPages.h +++ b/src/layui/layui/layEditorOptionsPages.h @@ -25,7 +25,7 @@ #ifndef HDR_layEditorOptionsPages #define HDR_layEditorOptionsPages -#include "laybasicCommon.h" +#include "layuiCommon.h" #include "layEditorOptionsPage.h" #include @@ -47,7 +47,7 @@ class Plugin; /** * @brief The object properties dialog */ -class LAYBASIC_PUBLIC EditorOptionsPages +class LAYUI_PUBLIC EditorOptionsPages : public QFrame { Q_OBJECT diff --git a/src/laybasic/laybasic/layFileDialog.cc b/src/layui/layui/layFileDialog.cc similarity index 100% rename from src/laybasic/laybasic/layFileDialog.cc rename to src/layui/layui/layFileDialog.cc diff --git a/src/laybasic/laybasic/layFileDialog.h b/src/layui/layui/layFileDialog.h similarity index 97% rename from src/laybasic/laybasic/layFileDialog.h rename to src/layui/layui/layFileDialog.h index 2ec220dd2..cb1bdb635 100644 --- a/src/laybasic/laybasic/layFileDialog.h +++ b/src/layui/layui/layFileDialog.h @@ -25,7 +25,7 @@ #ifndef HDR_layFileDialog #define HDR_layFileDialog -#include "laybasicCommon.h" +#include "layuiCommon.h" #include #include @@ -45,7 +45,7 @@ namespace lay * we need to use the static functions since these use the * system dialogs. */ -class LAYBASIC_PUBLIC FileDialog +class LAYUI_PUBLIC FileDialog : public QObject { public: diff --git a/src/laybasic/laybasic/layGenericSyntaxHighlighter.cc b/src/layui/layui/layGenericSyntaxHighlighter.cc similarity index 100% rename from src/laybasic/laybasic/layGenericSyntaxHighlighter.cc rename to src/layui/layui/layGenericSyntaxHighlighter.cc diff --git a/src/laybasic/laybasic/layGenericSyntaxHighlighter.h b/src/layui/layui/layGenericSyntaxHighlighter.h similarity index 96% rename from src/laybasic/laybasic/layGenericSyntaxHighlighter.h rename to src/layui/layui/layGenericSyntaxHighlighter.h index cbc0f684f..dea49a5a2 100644 --- a/src/laybasic/laybasic/layGenericSyntaxHighlighter.h +++ b/src/layui/layui/layGenericSyntaxHighlighter.h @@ -26,7 +26,7 @@ #define HDR_layGenericSyntaxHighlighter #include "tlString.h" -#include "laybasicCommon.h" +#include "layuiCommon.h" #include #include @@ -42,7 +42,7 @@ namespace lay /** * @brief Specifies one element in the text block's user data */ -struct LAYBASIC_PUBLIC SyntaxHighlighterElement +struct LAYUI_PUBLIC SyntaxHighlighterElement { public: /** @@ -63,7 +63,7 @@ public: * * The user data will contain useful data for bracket detection and other things */ -class LAYBASIC_PUBLIC SyntaxHighlighterUserData +class LAYUI_PUBLIC SyntaxHighlighterUserData : public QTextBlockUserData { public: @@ -94,7 +94,7 @@ public: * Rule implementations must implement this base class in order to plug into the * generic syntax highlighter framework. */ -class LAYBASIC_PUBLIC GenericSyntaxHighlighterRuleBase +class LAYUI_PUBLIC GenericSyntaxHighlighterRuleBase { public: /** @@ -133,7 +133,7 @@ public: /** * @brief A specialization of GenericSyntaxHighlighterRuleBase which looks for a choice of strings */ -class LAYBASIC_PUBLIC GenericSyntaxHighlighterRuleStringList +class LAYUI_PUBLIC GenericSyntaxHighlighterRuleStringList : public GenericSyntaxHighlighterRuleBase { public: @@ -154,7 +154,7 @@ private: * * This object will forward the match request to the actual implementation. */ -class LAYBASIC_PUBLIC GenericSyntaxHighlighterRule +class LAYUI_PUBLIC GenericSyntaxHighlighterRule { public: /** @@ -321,7 +321,7 @@ private: * Special context ID's are 0 (#stay), -n (#pop n times). * A context is associated with an attribute, which is given by an integer ID. */ -class LAYBASIC_PUBLIC GenericSyntaxHighlighterContext +class LAYUI_PUBLIC GenericSyntaxHighlighterContext { public: enum { @@ -480,7 +480,7 @@ private: /** * @brief A collection of (named) contexts */ -class LAYBASIC_PUBLIC GenericSyntaxHighlighterContexts +class LAYUI_PUBLIC GenericSyntaxHighlighterContexts { public: GenericSyntaxHighlighterContexts (); @@ -581,7 +581,7 @@ enum def_style { /** * @brief A collection of attributes */ -class LAYBASIC_PUBLIC GenericSyntaxHighlighterAttributes +class LAYUI_PUBLIC GenericSyntaxHighlighterAttributes { public: typedef std::map::const_iterator const_iterator; @@ -674,7 +674,7 @@ private: /** * @brief The parser's state */ -class LAYBASIC_PUBLIC GenericSyntaxHighlighterState +class LAYUI_PUBLIC GenericSyntaxHighlighterState { public: GenericSyntaxHighlighterState (const GenericSyntaxHighlighterContexts *contexts); @@ -712,7 +712,7 @@ private: /** * @brief A generic syntax highlighter using "Kate"'s syntax highlight scripts */ -class LAYBASIC_PUBLIC GenericSyntaxHighlighter +class LAYUI_PUBLIC GenericSyntaxHighlighter : public QSyntaxHighlighter { public: diff --git a/src/laybasic/laybasic/layGridNet.cc b/src/layui/layui/layGridNet.cc similarity index 99% rename from src/laybasic/laybasic/layGridNet.cc rename to src/layui/layui/layGridNet.cc index 612f58fc9..f17061177 100644 --- a/src/laybasic/laybasic/layGridNet.cc +++ b/src/layui/layui/layGridNet.cc @@ -24,10 +24,11 @@ #include "laybasicConfig.h" #include "layGridNet.h" #include "layConverters.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "layFixedFont.h" #include "layPixelBufferPainter.h" #include "laySnap.h" +#include "layColor.h" #include "dbTrans.h" #if defined(HAVE_QT) @@ -106,7 +107,7 @@ GridNetPluginDeclaration::config_page (QWidget *parent, std::string &title) cons #endif lay::Plugin * -GridNetPluginDeclaration::create_plugin (db::Manager *, Dispatcher *, lay::LayoutView *view) const +GridNetPluginDeclaration::create_plugin (db::Manager *, Dispatcher *, lay::LayoutViewBase *view) const { return new lay::GridNet (view); } @@ -116,7 +117,7 @@ static tl::RegisteredClass config_decl (new GridNetPlugi // ------------------------------------------------------------ // Implementation of the GridNet object -GridNet::GridNet (LayoutView *view) +GridNet::GridNet (LayoutViewBase *view) : lay::BackgroundViewObject (view->view_object_widget ()), lay::Plugin (view), mp_view (view), diff --git a/src/laybasic/laybasic/layGridNet.h b/src/layui/layui/layGridNet.h similarity index 94% rename from src/laybasic/laybasic/layGridNet.h rename to src/layui/layui/layGridNet.h index 529b30509..3991f948a 100644 --- a/src/laybasic/laybasic/layGridNet.h +++ b/src/layui/layui/layGridNet.h @@ -39,7 +39,7 @@ namespace Ui { namespace lay { -class LayoutView; +class LayoutViewBase; class ColorButton; class GridNetPluginDeclaration @@ -50,7 +50,7 @@ public: #if defined(HAVE_QT) virtual lay::ConfigPage *config_page (QWidget *parent, std::string &title) const; #endif - virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *, lay::LayoutView *view) const; + virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *, lay::LayoutViewBase *view) const; }; class GridNet @@ -68,7 +68,7 @@ public: CheckerBoard }; - GridNet (lay::LayoutView *view); + GridNet (lay::LayoutViewBase *view); private: virtual void render_bg (const lay::Viewport &vp, lay::ViewObjectCanvas &canvas); @@ -76,7 +76,7 @@ private: // implementation of the lay::Plugin interface virtual bool configure (const std::string &name, const std::string &value); - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; bool m_visible; bool m_show_ruler; double m_grid; diff --git a/src/laybasic/laybasic/layGridNetConfigPage.cc b/src/layui/layui/layGridNetConfigPage.cc similarity index 100% rename from src/laybasic/laybasic/layGridNetConfigPage.cc rename to src/layui/layui/layGridNetConfigPage.cc diff --git a/src/laybasic/laybasic/layGridNetConfigPage.h b/src/layui/layui/layGridNetConfigPage.h similarity index 100% rename from src/laybasic/laybasic/layGridNetConfigPage.h rename to src/layui/layui/layGridNetConfigPage.h diff --git a/src/laybasic/laybasic/layHierarchyControlPanel.cc b/src/layui/layui/layHierarchyControlPanel.cc similarity index 99% rename from src/laybasic/laybasic/layHierarchyControlPanel.cc rename to src/layui/layui/layHierarchyControlPanel.cc index 59293709d..304126ba0 100644 --- a/src/laybasic/laybasic/layHierarchyControlPanel.cc +++ b/src/layui/layui/layHierarchyControlPanel.cc @@ -46,7 +46,7 @@ #include "layBusy.h" #include "layHierarchyControlPanel.h" #include "layCellTreeModel.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "layAbstractMenu.h" #include "layQtTools.h" #include "layDialogs.h" @@ -209,7 +209,7 @@ HCPCellTreeWidget::mouseReleaseEvent (QMouseEvent *event) const int max_cellviews_in_split_mode = 5; -HierarchyControlPanel::HierarchyControlPanel (lay::LayoutView *view, QWidget *parent, const char *name) +HierarchyControlPanel::HierarchyControlPanel (lay::LayoutViewBase *view, QWidget *parent, const char *name) : QFrame (parent), m_enable_cb (true), mp_view (view), diff --git a/src/laybasic/laybasic/layHierarchyControlPanel.h b/src/layui/layui/layHierarchyControlPanel.h similarity index 97% rename from src/laybasic/laybasic/layHierarchyControlPanel.h rename to src/layui/layui/layHierarchyControlPanel.h index b5dab0ebc..8ac5a69a5 100644 --- a/src/laybasic/laybasic/layHierarchyControlPanel.h +++ b/src/layui/layui/layHierarchyControlPanel.h @@ -35,7 +35,7 @@ #include "dbLayout.h" #include "layCanvasPlane.h" #include "layViewOp.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "layCellTreeModel.h" #include "layWidgets.h" #include "tlDeferredExecution.h" @@ -111,7 +111,7 @@ public: * @param parent The Qt parent widget * @param name The layer control panel's widget name */ - HierarchyControlPanel (lay::LayoutView *view, QWidget *parent = 0, const char *name = "control_panel"); + HierarchyControlPanel (lay::LayoutViewBase *view, QWidget *parent = 0, const char *name = "control_panel"); /** * @brief Destructor @@ -258,7 +258,7 @@ public: /** * @brief Gets the layout view this panel is attached to */ - lay::LayoutView *view () + lay::LayoutViewBase *view () { return mp_view; } @@ -284,7 +284,7 @@ public slots: private: db::Layout *mp_layout; bool m_enable_cb; - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; std::vector m_cellviews; std::vector mp_cell_lists; std::vector mp_cell_list_headers; diff --git a/src/laybasic/laybasic/layIndexedNetlistModel.cc b/src/layui/layui/layIndexedNetlistModel.cc similarity index 100% rename from src/laybasic/laybasic/layIndexedNetlistModel.cc rename to src/layui/layui/layIndexedNetlistModel.cc diff --git a/src/laybasic/laybasic/layIndexedNetlistModel.h b/src/layui/layui/layIndexedNetlistModel.h similarity index 98% rename from src/laybasic/laybasic/layIndexedNetlistModel.h rename to src/layui/layui/layIndexedNetlistModel.h index 188a732af..4f6bc4c6a 100644 --- a/src/laybasic/laybasic/layIndexedNetlistModel.h +++ b/src/layui/layui/layIndexedNetlistModel.h @@ -25,7 +25,7 @@ #ifndef HDR_layIndexedNetlistModel #define HDR_layIndexedNetlistModel -#include "laybasicCommon.h" +#include "layuiCommon.h" #include "dbNetlistCrossReference.h" // for Status enum #include @@ -55,7 +55,7 @@ const size_t no_netlist_index = std::numeric_limits::max (); /** * @brief An interface to supply the netlist browser model with indexed items */ -class LAYBASIC_PUBLIC IndexedNetlistModel +class LAYUI_PUBLIC IndexedNetlistModel { public: typedef db::NetlistCrossReference::Status Status; @@ -127,7 +127,7 @@ private: /** * @brief An incarnation of the indexed netlist model for a single netlist */ -class LAYBASIC_PUBLIC SingleIndexedNetlistModel +class LAYUI_PUBLIC SingleIndexedNetlistModel : public IndexedNetlistModel { public: diff --git a/src/laybasic/laybasic/layItemDelegates.cc b/src/layui/layui/layItemDelegates.cc similarity index 100% rename from src/laybasic/laybasic/layItemDelegates.cc rename to src/layui/layui/layItemDelegates.cc diff --git a/src/laybasic/laybasic/layItemDelegates.h b/src/layui/layui/layItemDelegates.h similarity index 97% rename from src/laybasic/laybasic/layItemDelegates.h rename to src/layui/layui/layItemDelegates.h index ab0db7116..f3e5f7e49 100644 --- a/src/laybasic/laybasic/layItemDelegates.h +++ b/src/layui/layui/layItemDelegates.h @@ -25,7 +25,7 @@ #ifndef HDR_layItemDelegates #define HDR_layItemDelegates -#include "laybasicCommon.h" +#include "layuiCommon.h" #include @@ -37,7 +37,7 @@ namespace lay /** * @brief A delegate displaying the display text as HTML formatted text */ -class LAYBASIC_PUBLIC HTMLItemDelegate +class LAYUI_PUBLIC HTMLItemDelegate : public QStyledItemDelegate { Q_OBJECT diff --git a/src/laybasic/laybasic/layLayerControlPanel.cc b/src/layui/layui/layLayerControlPanel.cc similarity index 99% rename from src/laybasic/laybasic/layLayerControlPanel.cc rename to src/layui/layui/layLayerControlPanel.cc index 5be142020..372064b74 100644 --- a/src/laybasic/laybasic/layLayerControlPanel.cc +++ b/src/layui/layui/layLayerControlPanel.cc @@ -199,7 +199,7 @@ LCPTreeWidget::expand_all () // -------------------------------------------------------------------- // LayerControlPanel implementation -LayerControlPanel::LayerControlPanel (lay::LayoutView *view, db::Manager *manager, QWidget *parent, const char *name) +LayerControlPanel::LayerControlPanel (lay::LayoutViewBase *view, db::Manager *manager, QWidget *parent, const char *name) : QFrame (parent), db::Object (manager), mp_view (view), @@ -1307,7 +1307,7 @@ struct LDSortingProps struct LayerSorter { - LayerSorter (const lay::LayoutView *view, lay::LayerControlPanel::SortOrder order) + LayerSorter (const lay::LayoutViewBase *view, lay::LayerControlPanel::SortOrder order) : m_order (order), mp_view (view) { // .. nothing yet .. @@ -1390,7 +1390,7 @@ struct LayerSorter private: lay::LayerControlPanel::SortOrder m_order; - const lay::LayoutView *mp_view; + const lay::LayoutViewBase *mp_view; }; void diff --git a/src/laybasic/laybasic/layLayerControlPanel.h b/src/layui/layui/layLayerControlPanel.h similarity index 98% rename from src/laybasic/laybasic/layLayerControlPanel.h rename to src/layui/layui/layLayerControlPanel.h index 8a7d6904a..872e0b691 100644 --- a/src/laybasic/laybasic/layLayerControlPanel.h +++ b/src/layui/layui/layLayerControlPanel.h @@ -39,7 +39,7 @@ #include "layCanvasPlane.h" #include "layViewOp.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "layColorPalette.h" #include "layStipplePalette.h" #include "layDitherPattern.h" @@ -127,7 +127,7 @@ public: * @param parent The Qt parent widget * @param name The layer control panel's widget name */ - LayerControlPanel (lay::LayoutView *view, db::Manager *manager, QWidget *parent = 0, const char *name = "control_panel"); + LayerControlPanel (LayoutViewBase *view, db::Manager *manager, QWidget *parent = 0, const char *name = "control_panel"); /** * @brief Destructor @@ -339,7 +339,7 @@ private: LCPTreeWidget *mp_layer_list; std::unique_ptr mp_ll_style; LayerTreeModel *mp_model; - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; bool m_needs_update; bool m_tabs_need_update; bool m_hidden_flags_need_update; diff --git a/src/laybasic/laybasic/layLayerMappingWidget.cc b/src/layui/layui/layLayerMappingWidget.cc similarity index 100% rename from src/laybasic/laybasic/layLayerMappingWidget.cc rename to src/layui/layui/layLayerMappingWidget.cc diff --git a/src/laybasic/laybasic/layLayerMappingWidget.h b/src/layui/layui/layLayerMappingWidget.h similarity index 96% rename from src/laybasic/laybasic/layLayerMappingWidget.h rename to src/layui/layui/layLayerMappingWidget.h index b0898381e..706c2c355 100644 --- a/src/laybasic/laybasic/layLayerMappingWidget.h +++ b/src/layui/layui/layLayerMappingWidget.h @@ -27,7 +27,7 @@ #include -#include "laybasicCommon.h" +#include "layuiCommon.h" #include "dbStreamLayers.h" namespace Ui @@ -43,7 +43,7 @@ class FileDialog; /** * @brief A widget for editing the layer mapping for the reader options */ -class LAYBASIC_PUBLIC LayerMappingWidget +class LAYUI_PUBLIC LayerMappingWidget : public QFrame { Q_OBJECT diff --git a/src/laybasic/laybasic/layLayerToolbox.cc b/src/layui/layui/layLayerToolbox.cc similarity index 99% rename from src/laybasic/laybasic/layLayerToolbox.cc rename to src/layui/layui/layLayerToolbox.cc index 0be03095e..416858fdd 100644 --- a/src/laybasic/laybasic/layLayerToolbox.cc +++ b/src/layui/layui/layLayerToolbox.cc @@ -34,7 +34,7 @@ #include #include "tlExceptions.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "layEditStipplesForm.h" #include "layEditLineStylesForm.h" #include "laySelectStippleForm.h" @@ -928,7 +928,7 @@ LayerToolbox::~LayerToolbox () } void -LayerToolbox::set_view (LayoutView *view) +LayerToolbox::set_view (LayoutViewBase *view) { mp_dither_palette->set_view (view); mp_style_palette->set_view (view); diff --git a/src/laybasic/laybasic/layLayerToolbox.h b/src/layui/layui/layLayerToolbox.h similarity index 96% rename from src/laybasic/laybasic/layLayerToolbox.h rename to src/layui/layui/layLayerToolbox.h index b9fd59d6e..a635254b7 100644 --- a/src/laybasic/laybasic/layLayerToolbox.h +++ b/src/layui/layui/layLayerToolbox.h @@ -33,6 +33,7 @@ #include #include +#include "layuiCommon.h" #include "layColorPalette.h" #include "layStipplePalette.h" #include "layLineStylePalette.h" @@ -40,7 +41,7 @@ namespace lay { -class LayoutView; +class LayoutViewBase; class LCPDitherPalette; class LCPColorPalette; class LCPActiveLabel; @@ -143,7 +144,7 @@ Q_OBJECT public: LCPStylePalette (QWidget *parent, const char *name = 0); - void set_view (LayoutView *view) + void set_view (LayoutViewBase *view) { mp_view = view; } @@ -164,7 +165,7 @@ private: void create_pixmap_for_line_style (LCPActiveLabel *b, int n); lay::LineStylePalette m_palette; - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; std::vector m_style_buttons; }; @@ -185,7 +186,7 @@ public: void set_palette (const lay::StipplePalette &p); - void set_view (LayoutView *view) + void set_view (LayoutViewBase *view) { mp_view = view; } @@ -199,7 +200,7 @@ signals: private: lay::StipplePalette m_palette; - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; std::vector m_stipple_buttons; void create_pixmap_for (LCPActiveLabel *b, int n); @@ -259,7 +260,7 @@ private: /** * @brief A widget implementing the layer toolbox */ -class LAYBASIC_PUBLIC LayerToolbox +class LAYUI_PUBLIC LayerToolbox : public QWidget { Q_OBJECT @@ -280,7 +281,7 @@ public: * * This will make the toolbox control the given layout view */ - void set_view (LayoutView *view); + void set_view (LayoutViewBase *view); /** * @brief Changing of the color palette @@ -335,7 +336,7 @@ protected slots: void animation_changed (int mode); private: - LayoutView *mp_view; + LayoutViewBase *mp_view; std::vector > m_tool_panels; LCPDitherPalette *mp_dither_palette; LCPStylePalette *mp_style_palette; diff --git a/src/laybasic/laybasic/layLayerTreeModel.cc b/src/layui/layui/layLayerTreeModel.cc similarity index 99% rename from src/laybasic/laybasic/layLayerTreeModel.cc rename to src/layui/layui/layLayerTreeModel.cc index 741f26957..e53bd19fc 100644 --- a/src/laybasic/laybasic/layLayerTreeModel.cc +++ b/src/layui/layui/layLayerTreeModel.cc @@ -23,7 +23,7 @@ #if defined(HAVE_QT) #include "layLayerTreeModel.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "layBitmapsToImage.h" #include "dbLayoutUtils.h" #include "tlLog.h" @@ -179,7 +179,7 @@ EmptyWithinViewCache::determine_empty_layers (const db::Layout *layout, unsigned // -------------------------------------------------------------------- // LayerTreeModel implementation -LayerTreeModel::LayerTreeModel (QWidget *parent, lay::LayoutView *view) +LayerTreeModel::LayerTreeModel (QWidget *parent, lay::LayoutViewBase *view) : QAbstractItemModel (parent), mp_view (view), m_filter_mode (false), m_id_start (0), m_id_end (0), m_phase ((unsigned int) -1), m_test_shapes_in_view (false), m_hide_empty_layers (false) { @@ -636,9 +636,9 @@ LayerTreeModel::empty_within_view_predicate (const QModelIndex &index) const } } -LAYBASIC_PUBLIC +LAYUI_PUBLIC QIcon -LayerTreeModel::icon_for_layer (const lay::LayerPropertiesConstIterator &iter, lay::LayoutView *view, unsigned int w, unsigned int h, unsigned int di_off, bool no_state) +LayerTreeModel::icon_for_layer (const lay::LayerPropertiesConstIterator &iter, lay::LayoutViewBase *view, unsigned int w, unsigned int h, unsigned int di_off, bool no_state) { h = std::max ((unsigned int) 16, h); w = std::max ((unsigned int) 16, w); @@ -851,7 +851,7 @@ LayerTreeModel::data (const QModelIndex &index, int role) const if (m_selected_ids.find (size_t (index.internalPointer ())) != m_selected_ids.end ()) { // for selected items pick a color between Highlight and Base - QPalette pl (mp_view->palette ()); + QPalette pl (mp_view->widget ()->palette ()); QColor c1 = pl.color (QPalette::Highlight); QColor cb = pl.color (QPalette::Base); return QVariant (QColor ((c1.red () + cb.red ()) / 2, (c1.green () + cb.green ()) / 2, (c1.blue () + cb.blue ()) / 2)); diff --git a/src/laybasic/laybasic/layLayerTreeModel.h b/src/layui/layui/layLayerTreeModel.h similarity index 95% rename from src/laybasic/laybasic/layLayerTreeModel.h rename to src/layui/layui/layLayerTreeModel.h index 8eab10b20..b5a0b49d5 100644 --- a/src/laybasic/laybasic/layLayerTreeModel.h +++ b/src/layui/layui/layLayerTreeModel.h @@ -26,7 +26,7 @@ #define HDR_layLayerTreeModel #include "dbBox.h" -#include "laybasicCommon.h" +#include "layuiCommon.h" #include #include @@ -48,8 +48,7 @@ namespace tl namespace lay { -class LayoutView; -class LayoutView; +class LayoutViewBase; class LayerPropertiesConstIterator; /** @@ -80,7 +79,7 @@ private: * representation or a hierarchical one. */ -class LAYBASIC_PUBLIC LayerTreeModel +class LAYUI_PUBLIC LayerTreeModel : public QAbstractItemModel { Q_OBJECT @@ -91,7 +90,7 @@ public: * * The LayoutView reference is required to obtain hidden cell state and current state flags. */ - LayerTreeModel (QWidget *parent, lay::LayoutView *view); + LayerTreeModel (QWidget *parent, lay::LayoutViewBase *view); /** * @brief Dtor @@ -110,7 +109,7 @@ public: /** * @brief Provides an icon for a given layer style */ - static QIcon icon_for_layer (const lay::LayerPropertiesConstIterator &iter, lay::LayoutView *view, unsigned int w, unsigned int h, unsigned int di_offset, bool no_state = false); + static QIcon icon_for_layer (const lay::LayerPropertiesConstIterator &iter, lay::LayoutViewBase *view, unsigned int w, unsigned int h, unsigned int di_offset, bool no_state = false); /** * @brief Gets the preferred icon size @@ -252,7 +251,7 @@ signals: void hidden_flags_need_update (); private: - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; bool m_filter_mode; size_t m_id_start, m_id_end; unsigned int m_phase; diff --git a/src/laybasic/laybasic/layLayoutPropertiesForm.cc b/src/layui/layui/layLayoutPropertiesForm.cc similarity index 98% rename from src/laybasic/laybasic/layLayoutPropertiesForm.cc rename to src/layui/layui/layLayoutPropertiesForm.cc index 00eeff068..283a2a08f 100644 --- a/src/laybasic/laybasic/layLayoutPropertiesForm.cc +++ b/src/layui/layui/layLayoutPropertiesForm.cc @@ -23,7 +23,7 @@ #if defined(HAVE_QT) #include "layLayoutPropertiesForm.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "tlExceptions.h" #include "layDialogs.h" #include "tlInternational.h" @@ -40,7 +40,7 @@ namespace lay // ------------------------------------------------------------ -LayoutPropertiesForm::LayoutPropertiesForm (QWidget *parent, lay::LayoutView *view, const char *name) +LayoutPropertiesForm::LayoutPropertiesForm (QWidget *parent, lay::LayoutViewBase *view, const char *name) : QDialog (parent), Ui::LayoutPropertiesForm () { m_editable = view->is_editable (); diff --git a/src/laybasic/laybasic/layLayoutPropertiesForm.h b/src/layui/layui/layLayoutPropertiesForm.h similarity index 86% rename from src/laybasic/laybasic/layLayoutPropertiesForm.h rename to src/layui/layui/layLayoutPropertiesForm.h index 5a033616d..5a5e8d664 100644 --- a/src/laybasic/laybasic/layLayoutPropertiesForm.h +++ b/src/layui/layui/layLayoutPropertiesForm.h @@ -25,23 +25,26 @@ #ifndef HDR_layLayoutPropertiesForm #define HDR_layLayoutPropertiesForm -#include -#include "ui_LayoutProperties.h" +#include "layuiCommon.h" #include "layCellView.h" +#include "ui_LayoutProperties.h" + +#include + #include namespace lay { -class LayoutView; +class LayoutViewBase; -class LAYBASIC_PUBLIC LayoutPropertiesForm +class LAYUI_PUBLIC LayoutPropertiesForm : public QDialog, private Ui::LayoutPropertiesForm { Q_OBJECT public: - LayoutPropertiesForm (QWidget *parent, lay::LayoutView *view, const char *name); + LayoutPropertiesForm (QWidget *parent, lay::LayoutViewBase *view, const char *name); void accept (); void commit (); @@ -54,7 +57,7 @@ private slots: private: std::vector m_handles; - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; int m_index; bool m_editable; }; diff --git a/src/laybasic/laybasic/layLayoutStatistics.qrc b/src/layui/layui/layLayoutStatistics.qrc similarity index 100% rename from src/laybasic/laybasic/layLayoutStatistics.qrc rename to src/layui/layui/layLayoutStatistics.qrc diff --git a/src/laybasic/laybasic/layLayoutStatisticsForm.cc b/src/layui/layui/layLayoutStatisticsForm.cc similarity index 99% rename from src/laybasic/laybasic/layLayoutStatisticsForm.cc rename to src/layui/layui/layLayoutStatisticsForm.cc index a3e847ab5..52b3fc9f1 100644 --- a/src/laybasic/laybasic/layLayoutStatisticsForm.cc +++ b/src/layui/layui/layLayoutStatisticsForm.cc @@ -23,7 +23,7 @@ #if defined(HAVE_QT) #include "layLayoutStatisticsForm.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "tlInternational.h" #include "tlString.h" #include "tlExpression.h" @@ -790,7 +790,7 @@ StatisticsSource::get (const std::string &url) // ------------------------------------------------------------ -LayoutStatisticsForm::LayoutStatisticsForm (QWidget *parent, lay::LayoutView *view, const char *name) +LayoutStatisticsForm::LayoutStatisticsForm (QWidget *parent, lay::LayoutViewBase *view, const char *name) : QDialog (parent), Ui::LayoutStatisticsForm (), mp_source (0) { setObjectName (QString::fromUtf8 (name)); diff --git a/src/laybasic/laybasic/layLayoutStatisticsForm.h b/src/layui/layui/layLayoutStatisticsForm.h similarity index 92% rename from src/laybasic/laybasic/layLayoutStatisticsForm.h rename to src/layui/layui/layLayoutStatisticsForm.h index f8ee0835c..e2abaef50 100644 --- a/src/laybasic/laybasic/layLayoutStatisticsForm.h +++ b/src/layui/layui/layLayoutStatisticsForm.h @@ -33,7 +33,7 @@ namespace lay { -class LayoutView; +class LayoutViewBase; class StatisticsSource; class LayoutStatisticsForm @@ -42,7 +42,7 @@ class LayoutStatisticsForm Q_OBJECT public: - LayoutStatisticsForm (QWidget *parent, lay::LayoutView *view, const char *name); + LayoutStatisticsForm (QWidget *parent, lay::LayoutViewBase *view, const char *name); ~LayoutStatisticsForm (); public slots: diff --git a/src/laybasic/laybasic/layLayoutViewConfigPages.cc b/src/layui/layui/layLayoutViewConfigPages.cc similarity index 100% rename from src/laybasic/laybasic/layLayoutViewConfigPages.cc rename to src/layui/layui/layLayoutViewConfigPages.cc diff --git a/src/laybasic/laybasic/layLayoutViewConfigPages.h b/src/layui/layui/layLayoutViewConfigPages.h similarity index 100% rename from src/laybasic/laybasic/layLayoutViewConfigPages.h rename to src/layui/layui/layLayoutViewConfigPages.h diff --git a/src/laybasic/laybasic/layLayoutViewFunctions.cc b/src/layui/layui/layLayoutViewFunctions.cc similarity index 94% rename from src/laybasic/laybasic/layLayoutViewFunctions.cc rename to src/layui/layui/layLayoutViewFunctions.cc index 0596afaed..b25017d5b 100644 --- a/src/laybasic/laybasic/layLayoutViewFunctions.cc +++ b/src/layui/layui/layLayoutViewFunctions.cc @@ -23,7 +23,7 @@ #if defined(HAVE_QT) #include "layLayoutViewFunctions.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "layCellSelectionForm.h" #include "layLayoutStatisticsForm.h" #include "layLayoutPropertiesForm.h" @@ -57,7 +57,7 @@ collect_cells_to_delete (const db::Layout &layout, const db::Cell &cell, std::se } static bool -validate_cell_path (const db::Layout &layout, lay::LayoutView::cell_path_type &path) +validate_cell_path (const db::Layout &layout, lay::LayoutViewBase::cell_path_type &path) { for (size_t i = 0; i < path.size (); ++i) { @@ -79,7 +79,7 @@ validate_cell_path (const db::Layout &layout, lay::LayoutView::cell_path_type &p return false; } -LayoutViewFunctions::LayoutViewFunctions (db::Manager *manager, LayoutView *view) +LayoutViewFunctions::LayoutViewFunctions (db::Manager *manager, LayoutViewBase *view) : lay::Plugin (view), mp_view (view), mp_manager (manager) { m_del_cell_mode = 0; @@ -112,7 +112,7 @@ LayoutViewFunctions::menu_activated (const std::string &symbol) if (symbol == "cm_show_properties") { - view ()->show_properties (view ()); + view ()->show_properties (view ()->widget ()); } else if (symbol == "cm_delete") { @@ -179,7 +179,7 @@ LayoutViewFunctions::menu_activated (const std::string &symbol) } else if (symbol == "cm_select_current_cell") { if (view ()->active_cellview_index () >= 0) { - lay::LayoutView::cell_path_type path; + lay::LayoutViewBase::cell_path_type path; int cvi = view ()->active_cellview_index (); view ()->current_cell_path (path); view ()->select_cell_fit (path, cvi); @@ -305,10 +305,10 @@ LayoutViewFunctions::menu_activated (const std::string &symbol) cm_new_layer (); } } else if (symbol == "cm_layout_props") { - lay::LayoutPropertiesForm lp_form (view (), view (), "layout_props_form"); + lay::LayoutPropertiesForm lp_form (view ()->widget (), view (), "layout_props_form"); lp_form.exec (); } else if (symbol == "cm_layout_stats") { - lay::LayoutStatisticsForm lp_form (view (), view (), "layout_props_form"); + lay::LayoutStatisticsForm lp_form (view ()->widget (), view (), "layout_props_form"); lp_form.exec (); } else if (symbol == "cm_reload") { cm_reload (); @@ -418,13 +418,9 @@ LayoutViewFunctions::menu_activated (const std::string &symbol) void LayoutViewFunctions::cm_cell_user_properties () { - if (! view ()->hierarchy_panel ()) { - return; - } - int cv_index = view ()->active_cellview_index (); - lay::LayoutView::cell_path_type path; - view ()->hierarchy_panel ()->current_cell (cv_index, path); + lay::LayoutViewBase::cell_path_type path; + view ()->current_cell_path (cv_index, path); if (cv_index >= 0 && path.size () > 0) { @@ -432,7 +428,7 @@ LayoutViewFunctions::cm_cell_user_properties () db::Cell &cell = layout.cell (path.back ()); db::properties_id_type prop_id = cell.prop_id (); - lay::UserPropertiesForm props_form (view ()); + lay::UserPropertiesForm props_form (view ()->widget ()); if (props_form.show (view (), cv_index, prop_id)) { view ()->transaction (tl::to_string (tr ("Edit cell's user properties"))); @@ -447,13 +443,9 @@ LayoutViewFunctions::cm_cell_user_properties () void LayoutViewFunctions::cm_cell_replace () { - if (! view ()->hierarchy_panel ()) { - return; - } - int cv_index = view ()->active_cellview_index (); - std::vector paths; - view ()->hierarchy_panel ()->selected_cells (cv_index, paths); + std::vector paths; + view ()->selected_cells_paths (cv_index, paths); if (cv_index >= 0 && paths.size () > 0) { @@ -464,14 +456,14 @@ LayoutViewFunctions::cm_cell_replace () db::Layout &layout = view ()->cellview (cv_index)->layout (); bool needs_to_ask = false; - for (std::vector::const_iterator p = paths.begin (); p != paths.end () && ! needs_to_ask; ++p) { + for (std::vector::const_iterator p = paths.begin (); p != paths.end () && ! needs_to_ask; ++p) { if (layout.is_valid_cell_index (p->back ()) && ! layout.cell (p->back ()).is_leaf ()) { needs_to_ask = true; } } - lay::ReplaceCellOptionsDialog mode_dialog (view ()); + lay::ReplaceCellOptionsDialog mode_dialog (view ()->widget ()); db::cell_index_type with_cell = paths.front ().back (); int mode = needs_to_ask ? m_del_cell_mode : 0; @@ -485,7 +477,7 @@ LayoutViewFunctions::cm_cell_replace () if (with_cell != paths.front ().back ()) { // remember the current path - lay::LayoutView::cell_path_type cell_path (view ()->cellview (cv_index).combined_unspecific_path ()); + lay::LayoutViewBase::cell_path_type cell_path (view ()->cellview (cv_index).combined_unspecific_path ()); view ()->clear_selection (); @@ -507,7 +499,7 @@ LayoutViewFunctions::cm_cell_replace () } std::set cells_to_delete; - for (std::vector::const_iterator p = paths.begin (); p != paths.end (); ++p) { + for (std::vector::const_iterator p = paths.begin (); p != paths.end (); ++p) { if (! p->empty () && layout.is_valid_cell_index (p->back ())) { cells_to_delete.insert (p->back ()); if (mode == 2) { @@ -596,20 +588,16 @@ LayoutViewFunctions::cm_lay_convert_to_static () void LayoutViewFunctions::cm_cell_convert_to_static () { - if (! view ()->hierarchy_panel ()) { - return; - } - int cv_index = view ()->active_cellview_index (); - std::vector paths; - view ()->hierarchy_panel ()->selected_cells (cv_index, paths); + std::vector paths; + view ()->selected_cells_paths (cv_index, paths); if (cv_index >= 0 && paths.size () > 0) { db::Layout &layout = view ()->cellview (cv_index)->layout (); // remember the current path - lay::LayoutView::cell_path_type cell_path (view ()->cellview (cv_index).combined_unspecific_path ()); + lay::LayoutViewBase::cell_path_type cell_path (view ()->cellview (cv_index).combined_unspecific_path ()); view ()->clear_selection (); @@ -617,7 +605,7 @@ LayoutViewFunctions::cm_cell_convert_to_static () std::map cell_map; - for (std::vector::iterator p = paths.begin (); p != paths.end (); ++p) { + for (std::vector::iterator p = paths.begin (); p != paths.end (); ++p) { if (! p->empty () && layout.is_valid_cell_index (p->back ())) { db::cell_index_type new_cell = layout.convert_cell_to_static (p->back ()); if (new_cell != p->back ()) { @@ -653,20 +641,16 @@ LayoutViewFunctions::cm_cell_convert_to_static () void LayoutViewFunctions::cm_cell_delete () { - if (! view ()->hierarchy_panel ()) { - return; - } - int cv_index = view ()->active_cellview_index (); - std::vector paths; - view ()->hierarchy_panel ()->selected_cells (cv_index, paths); + std::vector paths; + view ()->selected_cells_paths (cv_index, paths); if (cv_index >= 0 && paths.size () > 0) { db::Layout &layout = view ()->cellview (cv_index)->layout (); bool needs_to_ask = false; - for (std::vector::const_iterator p = paths.begin (); p != paths.end () && ! needs_to_ask; ++p) { + for (std::vector::const_iterator p = paths.begin (); p != paths.end () && ! needs_to_ask; ++p) { if (layout.is_valid_cell_index (p->back ()) && ! layout.cell (p->back ()).is_leaf ()) { needs_to_ask = true; } @@ -677,7 +661,7 @@ LayoutViewFunctions::cm_cell_delete () mode = 0; } - lay::DeleteCellModeDialog mode_dialog (view ()); + lay::DeleteCellModeDialog mode_dialog (view ()->widget ()); if (! needs_to_ask || mode_dialog.exec_dialog (mode)) { if (needs_to_ask) { @@ -685,12 +669,12 @@ LayoutViewFunctions::cm_cell_delete () } // remember the current path - lay::LayoutView::cell_path_type cell_path (view ()->cellview (cv_index).combined_unspecific_path ()); + lay::LayoutViewBase::cell_path_type cell_path (view ()->cellview (cv_index).combined_unspecific_path ()); view ()->clear_selection (); std::set cells_to_delete; - for (std::vector::const_iterator p = paths.begin (); p != paths.end (); ++p) { + for (std::vector::const_iterator p = paths.begin (); p != paths.end (); ++p) { if (! p->empty () && layout.is_valid_cell_index (p->back ())) { cells_to_delete.insert (p->back ()); if (mode == 2) { @@ -789,7 +773,7 @@ LayoutViewFunctions::cm_cell_flatten () if (cv.is_valid ()) { std::vector paths; - view ()->hierarchy_panel ()->selected_cells (cv_index, paths); + view ()->selected_cells_paths (cv_index, paths); if (paths.empty ()) { throw tl::Exception (tl::to_string (tr ("No cells selected for flattening"))); } @@ -800,7 +784,7 @@ LayoutViewFunctions::cm_cell_flatten () } } - FlattenInstOptionsDialog options_dialog (view ()); + FlattenInstOptionsDialog options_dialog (view ()->widget ()); int flatten_insts_levels = -1; bool prune = true; @@ -876,17 +860,13 @@ LayoutViewFunctions::cm_cell_flatten () void LayoutViewFunctions::cm_cell_rename () { - if (! view ()->hierarchy_panel ()) { - return; - } - int cv_index = view ()->active_cellview_index (); - lay::LayoutView::cell_path_type path; - view ()->hierarchy_panel ()->current_cell (cv_index, path); + lay::LayoutViewBase::cell_path_type path; + view ()->current_cell_path (cv_index, path); if (cv_index >= 0 && path.size () > 0) { - lay::RenameCellDialog name_dialog (view ()); + lay::RenameCellDialog name_dialog (view ()->widget ()); db::Layout &layout = view ()->cellview (cv_index)->layout (); std::string name (layout.cell_name (path.back ())); @@ -918,53 +898,43 @@ LayoutViewFunctions::cm_open_current_cell () void LayoutViewFunctions::cm_cell_hide () { - if (view ()->hierarchy_panel ()) { + std::vector paths; + view ()->selected_cells_paths (view ()->active_cellview_index (), paths); - std::vector paths; - view ()->hierarchy_panel ()->selected_cells (view ()->active_cellview_index (), paths); + view ()->transaction (tl::to_string (tr ("Hide cell"))); - view ()->transaction (tl::to_string (tr ("Hide cell"))); - - for (std::vector::const_iterator p = paths.begin (); p != paths.end (); ++p) { - if (! p->empty ()) { - view ()->hide_cell (p->back (), view ()->active_cellview_index ()); - } + for (std::vector::const_iterator p = paths.begin (); p != paths.end (); ++p) { + if (! p->empty ()) { + view ()->hide_cell (p->back (), view ()->active_cellview_index ()); } - - view ()->commit (); - } + + view ()->commit (); } void LayoutViewFunctions::cm_cell_show () { - if (view ()->hierarchy_panel ()) { + std::vector paths; + view ()->selected_cells_paths (view ()->active_cellview_index (), paths); - std::vector paths; - view ()->hierarchy_panel ()->selected_cells (view ()->active_cellview_index (), paths); + view ()->transaction (tl::to_string (tr ("Show cell"))); - view ()->transaction (tl::to_string (tr ("Show cell"))); - - for (std::vector::const_iterator p = paths.begin (); p != paths.end (); ++p) { - if (! p->empty ()) { - view ()->show_cell (p->back (), view ()->active_cellview_index ()); - } + for (std::vector::const_iterator p = paths.begin (); p != paths.end (); ++p) { + if (! p->empty ()) { + view ()->show_cell (p->back (), view ()->active_cellview_index ()); } - - view ()->commit (); - } + + view ()->commit (); } void LayoutViewFunctions::cm_cell_show_all () { - if (view ()->hierarchy_panel ()) { - view ()->transaction (tl::to_string (tr ("Show all cells"))); - view ()->show_all_cells (); - view ()->commit (); - } + view ()->transaction (tl::to_string (tr ("Show all cells"))); + view ()->show_all_cells (); + view ()->commit (); } void @@ -1246,7 +1216,7 @@ LayoutViewFunctions::cm_new_cell () static double s_new_cell_window_size = 2.0; static std::string s_new_cell_cell_name; - NewCellPropertiesDialog cell_prop_dia (view ()); + NewCellPropertiesDialog cell_prop_dia (view ()->widget ()); if (cell_prop_dia.exec_dialog (& cv->layout (), s_new_cell_cell_name, s_new_cell_window_size)) { db::cell_index_type new_ci = view ()->new_cell (view ()->active_cellview_index (), s_new_cell_cell_name.c_str ()); @@ -1309,7 +1279,7 @@ LayoutViewFunctions::cm_reload () bool can_reload = true; if (dirty_layouts != 0) { - QMessageBox mbox (view ()); + QMessageBox mbox (view ()->widget ()); mbox.setText (tl::to_qstring (tl::to_string (tr ("The following layouts need saving:\n\n")) + dirty_files + "\n\nPress 'Reload Without Saving' to reload anyhow and discard changes.")); mbox.setWindowTitle (tr ("Save Needed")); mbox.setIcon (QMessageBox::Warning); @@ -1362,7 +1332,7 @@ LayoutViewFunctions::transform_layout (const db::DCplxTrans &tr_mic) } if (has_proxy && - QMessageBox::question (view (), + QMessageBox::question (view ()->widget (), tr ("Transforming PCells Or Library Cells"), tr ("The layout contains PCells or library cells or both.\n" "Any changes to such cells may be lost when their layout is refreshed later.\n" @@ -1449,7 +1419,7 @@ LayoutViewFunctions::cm_lay_scale () void LayoutViewFunctions::cm_lay_move () { - lay::MoveOptionsDialog options (view ()); + lay::MoveOptionsDialog options (view ()->widget ()); if (options.exec_dialog (m_move_dist)) { transform_layout (db::DCplxTrans (m_move_dist)); } @@ -1569,7 +1539,7 @@ LayoutViewFunctions::cm_sel_move_to () double y = sel_bbox.bottom () + (sel_bbox.height () * (1 + m_move_to_origin_mode_y) * 0.5); db::DPoint move_target (x, y); - lay::MoveToOptionsDialog options (view ()); + lay::MoveToOptionsDialog options (view ()->widget ()); if (options.exec_dialog (m_move_to_origin_mode_x, m_move_to_origin_mode_y, move_target)) { x = sel_bbox.left () + (sel_bbox.width () * (1 + m_move_to_origin_mode_x) * 0.5); @@ -1583,7 +1553,7 @@ LayoutViewFunctions::cm_sel_move_to () void LayoutViewFunctions::cm_sel_move () { - lay::MoveOptionsDialog options (view ()); + lay::MoveOptionsDialog options (view ()->widget ()); if (options.exec_dialog (m_move_dist)) { do_transform (db::DCplxTrans (m_move_dist)); } @@ -1617,7 +1587,7 @@ LayoutViewFunctions::cm_copy_layer () } - lay::DuplicateLayerDialog dialog (view ()); + lay::DuplicateLayerDialog dialog (view ()->widget ()); if (dialog.exec_dialog (view (), m_copy_cva, m_copy_layera, m_copy_cvr, m_copy_layerr, m_duplicate_hier_mode, m_clear_before)) { bool supports_undo = true; @@ -1777,7 +1747,7 @@ LayoutViewFunctions::cm_new_layer () const lay::CellView &cv = view ()->cellview (index); - lay::NewLayerPropertiesDialog prop_dia (view ()); + lay::NewLayerPropertiesDialog prop_dia (view ()->widget ()); if (prop_dia.exec_dialog (cv, m_new_layer_props)) { for (unsigned int l = 0; l < cv->layout ().layers (); ++l) { @@ -1815,7 +1785,7 @@ LayoutViewFunctions::cm_align_cell_origin () throw tl::Exception (tl::to_string (tr ("Cannot use this function on a PCell or library cell"))); } - lay::AlignCellOptionsDialog dialog (view ()); + lay::AlignCellOptionsDialog dialog (view ()->widget ()); if (dialog.exec_dialog (m_align_cell_options)) { view ()->clear_selection (); @@ -1914,7 +1884,7 @@ LayoutViewFunctions::cm_edit_layer () db::LayerProperties layer_props = cv->layout ().get_properties ((unsigned int) sel->layer_index ()); - lay::NewLayerPropertiesDialog prop_dia (view ()); + lay::NewLayerPropertiesDialog prop_dia (view ()->widget ()); if (prop_dia.exec_dialog (cv, layer_props)) { for (unsigned int l = 0; l < cv->layout ().layers (); ++l) { @@ -2007,7 +1977,7 @@ LayoutViewFunctions::cm_clear_layer () throw tl::Exception (tl::to_string (tr ("No layer selected for clearing"))); } - lay::ClearLayerModeDialog mode_dialog (view ()); + lay::ClearLayerModeDialog mode_dialog (view ()->widget ()); if (mode_dialog.exec_dialog (m_layer_hier_mode)) { view ()->cancel_edits (); @@ -2237,7 +2207,7 @@ public: void implements_primary_mouse_modes (std::vector > > &modes) { std::vector mode_titles; - lay::LayoutView::intrinsic_mouse_modes (&mode_titles); + lay::LayoutViewBase::intrinsic_mouse_modes (&mode_titles); int mode_id = 0; for (std::vector ::const_iterator t = mode_titles.begin (); t != mode_titles.end (); ++t, --mode_id) { @@ -2246,7 +2216,7 @@ public: } } - lay::Plugin *create_plugin (db::Manager *manager, Dispatcher *, LayoutView *view) const + lay::Plugin *create_plugin (db::Manager *manager, Dispatcher *, LayoutViewBase *view) const { return new LayoutViewFunctions (manager, view); } diff --git a/src/laybasic/laybasic/layLayoutViewFunctions.h b/src/layui/layui/layLayoutViewFunctions.h similarity index 94% rename from src/laybasic/laybasic/layLayoutViewFunctions.h rename to src/layui/layui/layLayoutViewFunctions.h index 6f25e5eb7..9950ebcf2 100644 --- a/src/laybasic/laybasic/layLayoutViewFunctions.h +++ b/src/layui/layui/layLayoutViewFunctions.h @@ -25,7 +25,7 @@ #ifndef HDR_layLayoutViewFunctions #define HDR_layLayoutViewFunctions -#include "laybasicCommon.h" +#include "layuiCommon.h" #include "layPlugin.h" #include "layDialogs.h" // For AlignCellOptions @@ -35,19 +35,19 @@ namespace lay { -class LayoutView; +class LayoutViewBase; /** * @brief The layout view's functions implementation */ -class LAYBASIC_PUBLIC LayoutViewFunctions +class LAYUI_PUBLIC LayoutViewFunctions : public lay::Plugin { public: /** * @brief Constructor */ - LayoutViewFunctions (db::Manager *manager, lay::LayoutView *view); + LayoutViewFunctions (db::Manager *manager, lay::LayoutViewBase *view); /** * @brief Destructor @@ -133,7 +133,7 @@ public: void cm_cell_convert_to_static (); protected: - lay::LayoutView *view () + lay::LayoutViewBase *view () { return mp_view; } @@ -152,7 +152,7 @@ protected: void transform_layout (const db::DCplxTrans &tr); private: - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; db::Manager *mp_manager; db::LayerProperties m_new_layer_props; db::DVector m_move_dist; diff --git a/src/laybasic/laybasic/layLibrariesView.cc b/src/layui/layui/layLibrariesView.cc similarity index 99% rename from src/laybasic/laybasic/layLibrariesView.cc rename to src/layui/layui/layLibrariesView.cc index 2aac160a3..203213bf9 100644 --- a/src/laybasic/laybasic/layLibrariesView.cc +++ b/src/layui/layui/layLibrariesView.cc @@ -48,7 +48,7 @@ #include "layBusy.h" #include "layLibrariesView.h" #include "layCellTreeModel.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "layAbstractMenu.h" #include "layDialogs.h" #include "tlExceptions.h" @@ -199,7 +199,7 @@ LibraryTreeWidget::mouseReleaseEvent (QMouseEvent *event) const int max_cellviews_in_split_mode = 5; -LibrariesView::LibrariesView (lay::LayoutView *view, QWidget *parent, const char *name) +LibrariesView::LibrariesView (lay::LayoutViewBase *view, QWidget *parent, const char *name) : QFrame (parent), m_enable_cb (true), mp_view (view), diff --git a/src/laybasic/laybasic/layLibrariesView.h b/src/layui/layui/layLibrariesView.h similarity index 97% rename from src/laybasic/laybasic/layLibrariesView.h rename to src/layui/layui/layLibrariesView.h index 537556044..4017e611d 100644 --- a/src/laybasic/laybasic/layLibrariesView.h +++ b/src/layui/layui/layLibrariesView.h @@ -35,7 +35,7 @@ #include "dbLayout.h" #include "layCanvasPlane.h" #include "layViewOp.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "layCellTreeModel.h" #include "layWidgets.h" #include "tlDeferredExecution.h" @@ -108,7 +108,7 @@ public: * @param parent The Qt parent widget * @param name The layer control panel's widget name */ - LibrariesView (lay::LayoutView *view, QWidget *parent = 0, const char *name = "libraries_view"); + LibrariesView (LayoutViewBase *view, QWidget *parent = 0, const char *name = "libraries_view"); /** * @brief Destructor @@ -207,7 +207,7 @@ public: /** * @brief Gets the layout view this panel is attached to */ - lay::LayoutView *view () + lay::LayoutViewBase *view () { return mp_view; } @@ -231,7 +231,7 @@ public slots: private: db::Layout *mp_layout; bool m_enable_cb; - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; std::vector mp_cell_lists; std::vector mp_cell_list_headers; std::vector mp_cell_list_frames; diff --git a/src/laybasic/laybasic/layLoadLayoutOptionsDialog.cc b/src/layui/layui/layLoadLayoutOptionsDialog.cc similarity index 99% rename from src/laybasic/laybasic/layLoadLayoutOptionsDialog.cc rename to src/layui/layui/layLoadLayoutOptionsDialog.cc index 08dbf35b0..b36ba0ac1 100644 --- a/src/laybasic/laybasic/layLoadLayoutOptionsDialog.cc +++ b/src/layui/layui/layLoadLayoutOptionsDialog.cc @@ -22,7 +22,7 @@ #if defined(HAVE_QT) -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "layLoadLayoutOptionsDialog.h" #include "layStream.h" #include "layFileDialog.h" diff --git a/src/laybasic/laybasic/layLoadLayoutOptionsDialog.h b/src/layui/layui/layLoadLayoutOptionsDialog.h similarity index 95% rename from src/laybasic/laybasic/layLoadLayoutOptionsDialog.h rename to src/layui/layui/layLoadLayoutOptionsDialog.h index 2ac954128..f276b783b 100644 --- a/src/laybasic/laybasic/layLoadLayoutOptionsDialog.h +++ b/src/layui/layui/layLoadLayoutOptionsDialog.h @@ -25,6 +25,7 @@ #ifndef HDR_layLoadLayoutOptionsDialog #define HDR_layLoadLayoutOptionsDialog +#include "layuiCommon.h" #include "dbStream.h" #include "dbLayout.h" #include "layStream.h" @@ -51,11 +52,10 @@ namespace Ui namespace lay { -class LayoutView; class Dispatcher; class FileDialog; -class LAYBASIC_PUBLIC LoadLayoutOptionsDialog +class LAYUI_PUBLIC LoadLayoutOptionsDialog : public QDialog { Q_OBJECT @@ -96,7 +96,7 @@ private: bool get_options_internal (); }; -class LAYBASIC_PUBLIC SpecificLoadLayoutOptionsDialog +class LAYUI_PUBLIC SpecificLoadLayoutOptionsDialog : public QDialog { public: diff --git a/src/laybasic/laybasic/layNetExportDialog.cc b/src/layui/layui/layNetExportDialog.cc similarity index 100% rename from src/laybasic/laybasic/layNetExportDialog.cc rename to src/layui/layui/layNetExportDialog.cc diff --git a/src/laybasic/laybasic/layNetExportDialog.h b/src/layui/layui/layNetExportDialog.h similarity index 100% rename from src/laybasic/laybasic/layNetExportDialog.h rename to src/layui/layui/layNetExportDialog.h diff --git a/src/laybasic/laybasic/layNetInfoDialog.cc b/src/layui/layui/layNetInfoDialog.cc similarity index 100% rename from src/laybasic/laybasic/layNetInfoDialog.cc rename to src/layui/layui/layNetInfoDialog.cc diff --git a/src/laybasic/laybasic/layNetInfoDialog.h b/src/layui/layui/layNetInfoDialog.h similarity index 100% rename from src/laybasic/laybasic/layNetInfoDialog.h rename to src/layui/layui/layNetInfoDialog.h diff --git a/src/laybasic/laybasic/layNetlistBrowser.cc b/src/layui/layui/layNetlistBrowser.cc similarity index 81% rename from src/laybasic/laybasic/layNetlistBrowser.cc rename to src/layui/layui/layNetlistBrowser.cc index 33d312f3f..4069e9166 100644 --- a/src/laybasic/laybasic/layNetlistBrowser.cc +++ b/src/layui/layui/layNetlistBrowser.cc @@ -22,11 +22,14 @@ #if defined(HAVE_QT) -#include "laybasicCommon.h" +#include "layuiCommon.h" #include "layNetlistBrowserDialog.h" #include "layConverters.h" #include "layDispatcher.h" +#include "ui_NetlistBrowserConfigPage.h" +#include "ui_NetlistBrowserConfigPage2.h" + #include #include @@ -100,9 +103,10 @@ NetlistBrowserWindowModeConverter::to_string (lay::NetlistBrowserConfig::net_win NetlistBrowserConfigPage::NetlistBrowserConfigPage (QWidget *parent) : lay::ConfigPage (parent) { - Ui::NetlistBrowserConfigPage::setupUi (this); + mp_ui = new Ui::NetlistBrowserConfigPage (); + mp_ui->setupUi (this); - connect (cbx_window, SIGNAL (currentIndexChanged (int)), this, SLOT (window_changed (int))); + connect (mp_ui->cbx_window, SIGNAL (currentIndexChanged (int)), this, SLOT (window_changed (int))); } void @@ -111,17 +115,17 @@ NetlistBrowserConfigPage::setup (lay::Dispatcher *root) // window mode lay::NetlistBrowserConfig::net_window_type wmode = lay::NetlistBrowserConfig::FitNet; root->config_get (cfg_l2ndb_window_mode, wmode, NetlistBrowserWindowModeConverter ()); - cbx_window->setCurrentIndex (int (wmode)); + mp_ui->cbx_window->setCurrentIndex (int (wmode)); // window dimension double wdim = 1.0; root->config_get (cfg_l2ndb_window_dim, wdim); - le_window->setText (tl::to_qstring (tl::to_string (wdim))); + mp_ui->le_window->setText (tl::to_qstring (tl::to_string (wdim))); // max. shapes highlighted unsigned int max_marker_count = 10000; root->config_get (cfg_l2ndb_max_shapes_highlighted, max_marker_count); - le_max_markers->setText (tl::to_qstring (tl::to_string (max_marker_count))); + mp_ui->le_max_markers->setText (tl::to_qstring (tl::to_string (max_marker_count))); // enable controls window_changed (int (wmode)); @@ -130,19 +134,19 @@ NetlistBrowserConfigPage::setup (lay::Dispatcher *root) void NetlistBrowserConfigPage::window_changed (int m) { - le_window->setEnabled (m == int (lay::NetlistBrowserConfig::FitNet) || m == int (lay::NetlistBrowserConfig::CenterSize)); + mp_ui->le_window->setEnabled (m == int (lay::NetlistBrowserConfig::FitNet) || m == int (lay::NetlistBrowserConfig::CenterSize)); } void NetlistBrowserConfigPage::commit (lay::Dispatcher *root) { double dim = 1.0; - tl::from_string_ext (tl::to_string (le_window->text ()), dim); + tl::from_string_ext (tl::to_string (mp_ui->le_window->text ()), dim); unsigned int max_shapes_highlighted = 10000; - tl::from_string_ext (tl::to_string (le_max_markers->text ()), max_shapes_highlighted); + tl::from_string_ext (tl::to_string (mp_ui->le_max_markers->text ()), max_shapes_highlighted); - root->config_set (cfg_l2ndb_window_mode, lay::NetlistBrowserConfig::net_window_type (cbx_window->currentIndex ()), NetlistBrowserWindowModeConverter ()); + root->config_set (cfg_l2ndb_window_mode, lay::NetlistBrowserConfig::net_window_type (mp_ui->cbx_window->currentIndex ()), NetlistBrowserWindowModeConverter ()); root->config_set (cfg_l2ndb_window_dim, dim); root->config_set (cfg_l2ndb_max_shapes_highlighted, max_shapes_highlighted); } @@ -163,10 +167,11 @@ static QToolButton * (Ui::NetlistBrowserConfigPage2::*cc_buttons []) = { NetlistBrowserConfigPage2::NetlistBrowserConfigPage2 (QWidget *parent) : lay::ConfigPage (parent) { - Ui::NetlistBrowserConfigPage2::setupUi (this); + mp_ui = new Ui::NetlistBrowserConfigPage2 (); + mp_ui->setupUi (this); for (unsigned int i = 0; i < sizeof (cc_buttons) / sizeof (cc_buttons [0]); ++i) { - connect (this->*(cc_buttons [i]), SIGNAL (clicked ()), this, SLOT (color_button_clicked ())); + connect (mp_ui->*(cc_buttons [i]), SIGNAL (clicked ()), this, SLOT (color_button_clicked ())); } } @@ -175,7 +180,7 @@ NetlistBrowserConfigPage2::color_button_clicked () { for (unsigned int i = 0; i < sizeof (cc_buttons) / sizeof (cc_buttons [0]); ++i) { - if (sender () == this->*(cc_buttons [i])) { + if (sender () == mp_ui->*(cc_buttons [i])) { QColor c; if (m_palette.colors () > i) { @@ -200,7 +205,7 @@ NetlistBrowserConfigPage2::setup (lay::Dispatcher *root) { bool cycle_enabled = false; root->config_get (cfg_l2ndb_marker_cycle_colors_enabled, cycle_enabled); - cycle_colors_cb->setChecked (cycle_enabled); + mp_ui->cycle_colors_cb->setChecked (cycle_enabled); std::string cc; root->config_get (cfg_l2ndb_marker_cycle_colors, cc); @@ -218,47 +223,47 @@ NetlistBrowserConfigPage2::setup (lay::Dispatcher *root) // marker color QColor color; root->config_get (cfg_l2ndb_marker_color, color, lay::ColorConverter ()); - color_pb->set_color (color); + mp_ui->color_pb->set_color (color); // use original color bool original_colors = false; root->config_get (cfg_l2ndb_marker_use_original_colors, original_colors); - brightness_cb->setChecked (original_colors); - brightness_sb->setEnabled (original_colors); - brightness_label->setEnabled (original_colors); + mp_ui->brightness_cb->setChecked (original_colors); + mp_ui->brightness_sb->setEnabled (original_colors); + mp_ui->brightness_label->setEnabled (original_colors); // brightness offset int brightness = 0; root->config_get (cfg_l2ndb_marker_intensity, brightness); - brightness_sb->setValue (brightness); + mp_ui->brightness_sb->setValue (brightness); // marker line width int lw = 0; root->config_get (cfg_l2ndb_marker_line_width, lw); if (lw < 0) { - lw_le->setText (QString ()); + mp_ui->lw_le->setText (QString ()); } else { - lw_le->setText (tl::to_qstring (tl::to_string (lw))); + mp_ui->lw_le->setText (tl::to_qstring (tl::to_string (lw))); } // marker vertex size int vs = 0; root->config_get (cfg_l2ndb_marker_vertex_size, vs); if (vs < 0) { - vs_le->setText (QString ()); + mp_ui->vs_le->setText (QString ()); } else { - vs_le->setText (tl::to_qstring (tl::to_string (vs))); + mp_ui->vs_le->setText (tl::to_qstring (tl::to_string (vs))); } // stipple pattern int dp = 0; root->config_get (cfg_l2ndb_marker_dither_pattern, dp); - stipple_pb->set_dither_pattern (dp); + mp_ui->stipple_pb->set_dither_pattern (dp); // halo int halo = 0; root->config_get (cfg_l2ndb_marker_halo, halo); - halo_cb->setCheckState (halo < 0 ? Qt::PartiallyChecked : (halo ? Qt::Checked : Qt::Unchecked)); + mp_ui->halo_cb->setCheckState (halo < 0 ? Qt::PartiallyChecked : (halo ? Qt::Checked : Qt::Unchecked)); } void @@ -281,8 +286,8 @@ NetlistBrowserConfigPage2::update_colors () QRect r (0, 0, pxmp.width () - 1, pxmp.height () - 1); pxpainter.drawRect (r); - (this->*(cc_buttons [i]))->setIconSize (pxmp.size ()); - (this->*(cc_buttons [i]))->setIcon (QIcon (pxmp)); + (mp_ui->*(cc_buttons [i]))->setIconSize (pxmp.size ()); + (mp_ui->*(cc_buttons [i]))->setIcon (QIcon (pxmp)); } } @@ -290,45 +295,45 @@ NetlistBrowserConfigPage2::update_colors () void NetlistBrowserConfigPage2::commit (lay::Dispatcher *root) { - root->config_set (cfg_l2ndb_marker_cycle_colors_enabled, cycle_colors_cb->isChecked ()); + root->config_set (cfg_l2ndb_marker_cycle_colors_enabled, mp_ui->cycle_colors_cb->isChecked ()); root->config_set (cfg_l2ndb_marker_cycle_colors, m_palette.to_string ()); - QColor color = color_pb->get_color (); + QColor color = mp_ui->color_pb->get_color (); root->config_set (cfg_l2ndb_marker_color, color, lay::ColorConverter ()); - if (lw_le->text ().isEmpty ()) { + if (mp_ui->lw_le->text ().isEmpty ()) { root->config_set (cfg_l2ndb_marker_line_width, -1); } else { try { int s; - tl::from_string_ext (tl::to_string (lw_le->text ()), s); + tl::from_string_ext (tl::to_string (mp_ui->lw_le->text ()), s); root->config_set (cfg_l2ndb_marker_line_width, s); } catch (...) { } } - if (vs_le->text ().isEmpty ()) { + if (mp_ui->vs_le->text ().isEmpty ()) { root->config_set (cfg_l2ndb_marker_vertex_size, -1); } else { try { int s; - tl::from_string_ext (tl::to_string (vs_le->text ()), s); + tl::from_string_ext (tl::to_string (mp_ui->vs_le->text ()), s); root->config_set (cfg_l2ndb_marker_vertex_size, s); } catch (...) { } } - root->config_set (cfg_l2ndb_marker_dither_pattern, stipple_pb->dither_pattern ()); + root->config_set (cfg_l2ndb_marker_dither_pattern, mp_ui->stipple_pb->dither_pattern ()); - if (halo_cb->checkState () == Qt::PartiallyChecked) { + if (mp_ui->halo_cb->checkState () == Qt::PartiallyChecked) { root->config_set (cfg_l2ndb_marker_halo, -1); - } else if (halo_cb->checkState () == Qt::Unchecked) { + } else if (mp_ui->halo_cb->checkState () == Qt::Unchecked) { root->config_set (cfg_l2ndb_marker_halo, 0); - } else if (halo_cb->checkState () == Qt::Checked) { + } else if (mp_ui->halo_cb->checkState () == Qt::Checked) { root->config_set (cfg_l2ndb_marker_halo, 1); } - root->config_set (cfg_l2ndb_marker_intensity, brightness_sb->value ()); + root->config_set (cfg_l2ndb_marker_intensity, mp_ui->brightness_sb->value ()); - root->config_set (cfg_l2ndb_marker_use_original_colors, brightness_cb->isChecked ()); + root->config_set (cfg_l2ndb_marker_use_original_colors, mp_ui->brightness_cb->isChecked ()); } // ------------------------------------------------------------ @@ -377,7 +382,7 @@ public: menu_entries.push_back (lay::menu_item ("netlist_browser::show", "browse_netlists", "tools_menu.end", tl::to_string (QObject::tr ("Netlist Browser")))); } - virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutView *view) const + virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutViewBase *view) const { return new lay::NetlistBrowserDialog (root, view); } diff --git a/src/laybasic/laybasic/layNetlistBrowser.h b/src/layui/layui/layNetlistBrowser.h similarity index 89% rename from src/laybasic/laybasic/layNetlistBrowser.h rename to src/layui/layui/layNetlistBrowser.h index 8e848d669..1bea24283 100644 --- a/src/laybasic/laybasic/layNetlistBrowser.h +++ b/src/layui/layui/layNetlistBrowser.h @@ -28,13 +28,17 @@ #include "layPlugin.h" #include "layPluginConfigPage.h" #include "layColorPalette.h" -#include "ui_NetlistBrowserConfigPage.h" -#include "ui_NetlistBrowserConfigPage2.h" #include "dbTrans.h" #include +namespace Ui +{ + class NetlistBrowserConfigPage; + class NetlistBrowserConfigPage2; +} + namespace lay { @@ -44,8 +48,7 @@ struct NetlistBrowserConfig }; class NetlistBrowserConfigPage - : public lay::ConfigPage, - private Ui::NetlistBrowserConfigPage + : public lay::ConfigPage { Q_OBJECT @@ -57,11 +60,13 @@ public: public slots: void window_changed (int); + +private: + Ui::NetlistBrowserConfigPage *mp_ui; }; class NetlistBrowserConfigPage2 - : public lay::ConfigPage, - private Ui::NetlistBrowserConfigPage2 + : public lay::ConfigPage { Q_OBJECT @@ -77,6 +82,7 @@ public slots: private: void update_colors (); + Ui::NetlistBrowserConfigPage2 *mp_ui; lay::ColorPalette m_palette; }; diff --git a/src/laybasic/laybasic/layNetlistBrowserDialog.cc b/src/layui/layui/layNetlistBrowserDialog.cc similarity index 82% rename from src/laybasic/laybasic/layNetlistBrowserDialog.cc rename to src/layui/layui/layNetlistBrowserDialog.cc index 7247effd1..8c54ccb54 100644 --- a/src/laybasic/laybasic/layNetlistBrowserDialog.cc +++ b/src/layui/layui/layNetlistBrowserDialog.cc @@ -25,7 +25,7 @@ #include "layNetlistBrowserDialog.h" #include "tlProgress.h" #include "tlExceptions.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "layFinder.h" #include "layFileDialog.h" #include "layConverters.h" @@ -34,6 +34,8 @@ #include "dbLayoutToNetlist.h" #include "dbRecursiveShapeIterator.h" +#include "ui_NetlistBrowserDialog.h" + #include #include @@ -57,10 +59,9 @@ extern const std::string cfg_l2ndb_max_shapes_highlighted; extern const std::string cfg_l2ndb_show_all; extern const std::string cfg_l2ndb_window_state; -NetlistBrowserDialog::NetlistBrowserDialog (lay::Dispatcher *root, lay::LayoutView *vw) +NetlistBrowserDialog::NetlistBrowserDialog (lay::Dispatcher *root, LayoutViewBase *vw) : lay::Browser (root, vw), lay::ViewService (vw->view_object_widget ()), - Ui::NetlistBrowserDialog (), m_window (lay::NetlistBrowserConfig::FitNet), m_window_dim (0.0), m_max_shape_count (0), @@ -75,9 +76,10 @@ NetlistBrowserDialog::NetlistBrowserDialog (lay::Dispatcher *root, lay::LayoutVi m_l2n_index (-1), m_mouse_state (0) { - Ui::NetlistBrowserDialog::setupUi (this); + mp_ui = new Ui::NetlistBrowserDialog (); + mp_ui->setupUi (this); - browser_page->set_dispatcher (root); + mp_ui->browser_page->set_dispatcher (root); if (view ()) { view ()->cellviews_changed_event.add (this, &NetlistBrowserDialog::cellviews_changed); @@ -85,12 +87,12 @@ NetlistBrowserDialog::NetlistBrowserDialog (lay::Dispatcher *root, lay::LayoutVi view ()->l2ndb_list_changed_event.add (this, &NetlistBrowserDialog::l2ndbs_changed); } - m_open_action = new QAction (QObject::tr ("Open"), file_menu); - m_saveas_action = new QAction (QObject::tr ("Save As"), file_menu); - m_export_action = new QAction (QObject::tr ("Export To Layout"), file_menu); - m_reload_action = new QAction (QObject::tr ("Reload"), file_menu); - m_unload_action = new QAction (QObject::tr ("Unload"), file_menu); - m_unload_all_action = new QAction (QObject::tr ("Unload All"), file_menu); + m_open_action = new QAction (QObject::tr ("Open"), mp_ui->file_menu); + m_saveas_action = new QAction (QObject::tr ("Save As"), mp_ui->file_menu); + m_export_action = new QAction (QObject::tr ("Export To Layout"), mp_ui->file_menu); + m_reload_action = new QAction (QObject::tr ("Reload"), mp_ui->file_menu); + m_unload_action = new QAction (QObject::tr ("Unload"), mp_ui->file_menu); + m_unload_all_action = new QAction (QObject::tr ("Unload All"), mp_ui->file_menu); connect (m_open_action, SIGNAL (triggered ()), this, SLOT (open_clicked ())); connect (m_saveas_action, SIGNAL (triggered ()), this, SLOT (saveas_clicked ())); @@ -99,30 +101,30 @@ NetlistBrowserDialog::NetlistBrowserDialog (lay::Dispatcher *root, lay::LayoutVi connect (m_unload_action, SIGNAL (triggered ()), this, SLOT (unload_clicked ())); connect (m_unload_all_action, SIGNAL (triggered ()), this, SLOT (unload_all_clicked ())); - file_menu->addAction (m_open_action); - file_menu->addAction (m_saveas_action); - QAction *sep0 = new QAction (file_menu); + mp_ui->file_menu->addAction (m_open_action); + mp_ui->file_menu->addAction (m_saveas_action); + QAction *sep0 = new QAction (mp_ui->file_menu); sep0->setSeparator (true); - file_menu->addAction (m_export_action); - QAction *sep1 = new QAction (file_menu); + mp_ui->file_menu->addAction (m_export_action); + QAction *sep1 = new QAction (mp_ui->file_menu); sep1->setSeparator (true); - file_menu->addAction (sep1); - file_menu->addAction (m_reload_action); - QAction *sep2 = new QAction (file_menu); + mp_ui->file_menu->addAction (sep1); + mp_ui->file_menu->addAction (m_reload_action); + QAction *sep2 = new QAction (mp_ui->file_menu); sep2->setSeparator (true); - file_menu->addAction (sep2); - file_menu->addAction (m_unload_action); - file_menu->addAction (m_unload_all_action); + mp_ui->file_menu->addAction (sep2); + mp_ui->file_menu->addAction (m_unload_action); + mp_ui->file_menu->addAction (m_unload_all_action); - connect (layout_cb, SIGNAL (activated (int)), this, SLOT (cv_index_changed (int))); - connect (l2ndb_cb, SIGNAL (activated (int)), this, SLOT (l2ndb_index_changed (int))); - connect (configure_pb, SIGNAL (clicked ()), this, SLOT (configure_clicked ())); - connect (probe_pb, SIGNAL (clicked ()), this, SLOT (probe_button_pressed ())); - connect (sticky_cbx, SIGNAL (clicked ()), this, SLOT (sticky_mode_clicked ())); + connect (mp_ui->layout_cb, SIGNAL (activated (int)), this, SLOT (cv_index_changed (int))); + connect (mp_ui->l2ndb_cb, SIGNAL (activated (int)), this, SLOT (l2ndb_index_changed (int))); + connect (mp_ui->configure_pb, SIGNAL (clicked ()), this, SLOT (configure_clicked ())); + connect (mp_ui->probe_pb, SIGNAL (clicked ()), this, SLOT (probe_button_pressed ())); + connect (mp_ui->sticky_cbx, SIGNAL (clicked ()), this, SLOT (sticky_mode_clicked ())); cellviews_changed (); - browser_page->selection_changed_event.add (this, &NetlistBrowserDialog::selection_changed); + mp_ui->browser_page->selection_changed_event.add (this, &NetlistBrowserDialog::selection_changed); } NetlistBrowserDialog::~NetlistBrowserDialog () @@ -133,14 +135,14 @@ NetlistBrowserDialog::~NetlistBrowserDialog () db::LayoutToNetlist * NetlistBrowserDialog::db () { - return browser_page->db (); + return mp_ui->browser_page->db (); } const lay::NetlistObjectsPath & NetlistBrowserDialog::current_path () const { - if (browser_page) { - return browser_page->current_path (); + if (mp_ui->browser_page) { + return mp_ui->browser_page->current_path (); } else { static lay::NetlistObjectsPath empty; return empty; @@ -150,8 +152,8 @@ NetlistBrowserDialog::current_path () const const std::vector & NetlistBrowserDialog::selected_paths () const { - if (browser_page) { - return browser_page->selected_paths (); + if (mp_ui->browser_page) { + return mp_ui->browser_page->selected_paths (); } else { static std::vector empty; return empty; @@ -181,7 +183,7 @@ void NetlistBrowserDialog::sticky_mode_clicked () { BEGIN_PROTECTED - if (! sticky_cbx->isChecked ()) { + if (! mp_ui->sticky_cbx->isChecked ()) { release_mouse (); } else { probe_button_pressed (); @@ -206,7 +208,7 @@ NetlistBrowserDialog::mouse_click_event (const db::DPoint &p, unsigned int butto bool trace_path = (m_mouse_state == 3); - if (trace_path || ! sticky_cbx->isChecked ()) { + if (trace_path || ! mp_ui->sticky_cbx->isChecked ()) { release_mouse (); } @@ -333,12 +335,12 @@ NetlistBrowserDialog::probe_net (const db::DPoint &p, bool trace_path) path.path = lay::NetlistObjectPath::path_type (sc_path.begin (), sc_path.end ()); } - browser_page->select_path (path); + mp_ui->browser_page->select_path (path); // emits the probe event // NOTE: browser_page->current_path () will hold the paired path with the schematic side being // expanded. - probe_event (browser_page->current_path ().first (), browser_page->current_path ().second ()); + probe_event (mp_ui->browser_page->current_path ().first (), mp_ui->browser_page->current_path ().second ()); } void @@ -410,7 +412,7 @@ void NetlistBrowserDialog::export_clicked () { if (m_l2n_index < int (view ()->num_l2ndbs ()) && m_l2n_index >= 0) { - browser_page->export_all (); + mp_ui->browser_page->export_all (); } } @@ -424,7 +426,7 @@ BEGIN_PROTECTED db::LayoutToNetlist *l2ndb = view ()->get_l2ndb (m_l2n_index); db::LayoutVsSchematic *lvsdb = dynamic_cast (l2ndb); - if (lvsdb && ! browser_page->is_netlist_mode ()) { + if (lvsdb && ! mp_ui->browser_page->is_netlist_mode ()) { // prepare and open the file dialog lay::FileDialog save_dialog (this, tl::to_string (QObject::tr ("Save LVS Database")), "KLayout LVS DB files (*.lvsdb)"); @@ -472,10 +474,10 @@ BEGIN_PROTECTED tl::log << tl::to_string (QObject::tr ("Loading file: ")) << l2ndb->filename (); tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Loading"))); - browser_page->set_db (0); + mp_ui->browser_page->set_db (0); try { l2ndb->load (l2ndb->filename ()); - browser_page->set_db (l2ndb); + mp_ui->browser_page->set_db (l2ndb); current_db_changed_event (); } catch (...) { current_db_changed_event (); @@ -513,7 +515,7 @@ BEGIN_PROTECTED tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (QObject::tr ("Loading"))); int l2n_index = view ()->add_l2ndb (db::LayoutToNetlist::create_from_file (m_open_filename)); - l2ndb_cb->setCurrentIndex (l2n_index); + mp_ui->l2ndb_cb->setCurrentIndex (l2n_index); // it looks like the setCurrentIndex does not issue this signal: l2ndb_index_changed (l2n_index); @@ -527,7 +529,7 @@ NetlistBrowserDialog::configure (const std::string &name, const std::string &val { bool need_update = false; bool taken = true; - bool show_all = browser_page->show_all (); + bool show_all = mp_ui->browser_page->show_all (); if (name == cfg_l2ndb_show_all) { @@ -624,12 +626,12 @@ NetlistBrowserDialog::configure (const std::string &name, const std::string &val } if (active () && need_update) { - browser_page->set_max_shape_count (m_max_shape_count); - browser_page->set_window (m_window, m_window_dim); - browser_page->set_highlight_style (m_marker_color, m_marker_line_width, m_marker_vertex_size, m_marker_halo, m_marker_dither_pattern, m_marker_intensity, m_use_original_colors, m_auto_color_enabled ? &m_auto_colors : 0); + mp_ui->browser_page->set_max_shape_count (m_max_shape_count); + mp_ui->browser_page->set_window (m_window, m_window_dim); + mp_ui->browser_page->set_highlight_style (m_marker_color, m_marker_line_width, m_marker_vertex_size, m_marker_halo, m_marker_dither_pattern, m_marker_intensity, m_use_original_colors, m_auto_color_enabled ? &m_auto_colors : 0); } - browser_page->show_all (show_all); + mp_ui->browser_page->show_all (show_all); return taken; } @@ -662,11 +664,11 @@ NetlistBrowserDialog::l2ndbs_changed () { int l2n_index = -1; - l2ndb_cb->clear (); + mp_ui->l2ndb_cb->clear (); for (unsigned int i = 0; i < view ()->num_l2ndbs (); ++i) { const db::LayoutToNetlist *l2ndb = view ()->get_l2ndb (i); - l2ndb_cb->addItem (tl::to_qstring (l2ndb->name ())); + mp_ui->l2ndb_cb->addItem (tl::to_qstring (l2ndb->name ())); if (l2ndb->name () == m_l2ndb_name) { l2n_index = i; } @@ -674,7 +676,7 @@ NetlistBrowserDialog::l2ndbs_changed () // force an update m_l2n_index = l2n_index; - l2ndb_cb->setCurrentIndex (l2n_index); + mp_ui->l2ndb_cb->setCurrentIndex (l2n_index); if (active ()) { update_content (); } @@ -683,7 +685,7 @@ NetlistBrowserDialog::l2ndbs_changed () void NetlistBrowserDialog::cellview_changed (int) { - browser_page->update_highlights (); + mp_ui->browser_page->update_highlights (); } void @@ -691,17 +693,17 @@ NetlistBrowserDialog::cellviews_changed () { int cv_index = -1; - layout_cb->clear (); + mp_ui->layout_cb->clear (); for (unsigned int i = 0; i < view ()->cellviews (); ++i) { const lay::CellView &cv = view ()->cellview (i); - layout_cb->addItem (tl::to_qstring (cv->name ())); + mp_ui->layout_cb->addItem (tl::to_qstring (cv->name ())); if (cv.is_valid () && cv->name () == m_layout_name) { cv_index = i; } } - layout_cb->setCurrentIndex (cv_index); + mp_ui->layout_cb->setCurrentIndex (cv_index); cv_index_changed (cv_index); } @@ -757,11 +759,11 @@ NetlistBrowserDialog::update_content () db::LayoutToNetlist *l2ndb = view ()->get_l2ndb (m_l2n_index); - probe_pb->setEnabled (l2ndb != 0); + mp_ui->probe_pb->setEnabled (l2ndb != 0); release_mouse (); if (! l2ndb) { - central_stack->setCurrentIndex (1); + mp_ui->central_stack->setCurrentIndex (1); } bool db_changed = false; @@ -772,18 +774,18 @@ NetlistBrowserDialog::update_content () m_unload_all_action->setEnabled (l2ndb != 0); m_reload_action->setEnabled (l2ndb != 0); - browser_page->enable_updates (false); // Avoid building the internal lists several times ... - db_changed = browser_page->set_db (l2ndb); - browser_page->set_max_shape_count (m_max_shape_count); - browser_page->set_highlight_style (m_marker_color, m_marker_line_width, m_marker_vertex_size, m_marker_halo, m_marker_dither_pattern, m_marker_intensity, m_use_original_colors, m_auto_color_enabled ? &m_auto_colors : 0); - browser_page->set_window (m_window, m_window_dim); - browser_page->set_view (view (), m_cv_index); - browser_page->enable_updates (true); + mp_ui->browser_page->enable_updates (false); // Avoid building the internal lists several times ... + db_changed = mp_ui->browser_page->set_db (l2ndb); + mp_ui->browser_page->set_max_shape_count (m_max_shape_count); + mp_ui->browser_page->set_highlight_style (m_marker_color, m_marker_line_width, m_marker_vertex_size, m_marker_halo, m_marker_dither_pattern, m_marker_intensity, m_use_original_colors, m_auto_color_enabled ? &m_auto_colors : 0); + mp_ui->browser_page->set_window (m_window, m_window_dim); + mp_ui->browser_page->set_view (view (), m_cv_index); + mp_ui->browser_page->enable_updates (true); if (l2ndb) { // Note: it appears to be required to show the browser page after it has been configured. // Otherwise the header gets messed up and the configuration is reset. - central_stack->setCurrentIndex (0); + mp_ui->central_stack->setCurrentIndex (0); } lay::CellView cv = view ()->cellview (m_cv_index); @@ -792,12 +794,12 @@ NetlistBrowserDialog::update_content () m_layout_name = cv->name (); } - if (layout_cb->currentIndex () != m_cv_index) { - layout_cb->setCurrentIndex (m_cv_index); + if (mp_ui->layout_cb->currentIndex () != m_cv_index) { + mp_ui->layout_cb->setCurrentIndex (m_cv_index); } - if (l2ndb_cb->currentIndex () != m_l2n_index) { - l2ndb_cb->setCurrentIndex (m_l2n_index); + if (mp_ui->l2ndb_cb->currentIndex () != m_l2n_index) { + mp_ui->l2ndb_cb->setCurrentIndex (m_l2n_index); } if (db_changed) { @@ -815,11 +817,11 @@ NetlistBrowserDialog::deactivated () } bool db_changed = false; - if (browser_page->db () != 0) { + if (mp_ui->browser_page->db () != 0) { db_changed = true; - browser_page->set_db (0); + mp_ui->browser_page->set_db (0); } - browser_page->set_view (0, 0); + mp_ui->browser_page->set_view (0, 0); if (db_changed) { current_db_changed_event (); diff --git a/src/laybasic/laybasic/layNetlistBrowserDialog.h b/src/layui/layui/layNetlistBrowserDialog.h similarity index 93% rename from src/laybasic/laybasic/layNetlistBrowserDialog.h rename to src/layui/layui/layNetlistBrowserDialog.h index e63d91957..d7cf015fb 100644 --- a/src/laybasic/laybasic/layNetlistBrowserDialog.h +++ b/src/layui/layui/layNetlistBrowserDialog.h @@ -25,25 +25,36 @@ #ifndef HDR_layNetlistBrowserDialog #define HDR_layNetlistBrowserDialog -#include "ui_NetlistBrowserDialog.h" #include "layBrowser.h" #include "layNetlistBrowser.h" #include "layViewObject.h" #include "layColorPalette.h" #include "tlEvents.h" +namespace Ui +{ + class NetlistBrowserDialog; +} + +namespace db +{ + class LayoutToNetlist; +} + namespace lay { +class NetlistObjectPath; +class NetlistObjectsPath; + class NetlistBrowserDialog : public lay::Browser, - public lay::ViewService, - private Ui::NetlistBrowserDialog + public lay::ViewService { Q_OBJECT public: - NetlistBrowserDialog (lay::Dispatcher *root, lay::LayoutView *view); + NetlistBrowserDialog (lay::Dispatcher *root, lay::LayoutViewBase *view); ~NetlistBrowserDialog (); void load (int lay_index, int cv_index); @@ -117,6 +128,7 @@ public slots: void sticky_mode_clicked (); private: + Ui::NetlistBrowserDialog *mp_ui; lay::NetlistBrowserConfig::net_window_type m_window; double m_window_dim; unsigned int m_max_shape_count; diff --git a/src/laybasic/laybasic/layNetlistBrowserModel.cc b/src/layui/layui/layNetlistBrowserModel.cc similarity index 100% rename from src/laybasic/laybasic/layNetlistBrowserModel.cc rename to src/layui/layui/layNetlistBrowserModel.cc diff --git a/src/laybasic/laybasic/layNetlistBrowserModel.h b/src/layui/layui/layNetlistBrowserModel.h similarity index 98% rename from src/laybasic/laybasic/layNetlistBrowserModel.h rename to src/layui/layui/layNetlistBrowserModel.h index 8a86696ba..0a634aebd 100644 --- a/src/laybasic/laybasic/layNetlistBrowserModel.h +++ b/src/layui/layui/layNetlistBrowserModel.h @@ -27,7 +27,7 @@ #include "layColorPalette.h" #include "layColor.h" -#include "laybasicCommon.h" +#include "layuiCommon.h" #include "dbLayoutToNetlist.h" #include "dbLayoutVsSchematic.h" @@ -135,8 +135,9 @@ private: * This object applies to pairs of these objects. A class providing a path for a single * object is NetlistObjectPath */ -struct LAYBASIC_PUBLIC NetlistObjectPath +class LAYUI_PUBLIC NetlistObjectPath { +public: typedef std::list path_type; typedef path_type::const_iterator path_iterator; @@ -169,8 +170,9 @@ struct LAYBASIC_PUBLIC NetlistObjectPath * This object applies to pairs of these objects. A class providing a path for a single * object is NetlistObjectPath */ -struct LAYBASIC_PUBLIC NetlistObjectsPath +class LAYUI_PUBLIC NetlistObjectsPath { +public: typedef std::list > path_type; typedef path_type::const_iterator path_iterator; @@ -221,7 +223,7 @@ struct LAYBASIC_PUBLIC NetlistObjectsPath * - #pins+#nets+#subcircuits..: devices * - terminals and nets */ -class LAYBASIC_PUBLIC NetlistBrowserModel +class LAYUI_PUBLIC NetlistBrowserModel : public QAbstractItemModel, public tl::Object { Q_OBJECT diff --git a/src/laybasic/laybasic/layNetlistBrowserPage.cc b/src/layui/layui/layNetlistBrowserPage.cc similarity index 99% rename from src/laybasic/laybasic/layNetlistBrowserPage.cc rename to src/layui/layui/layNetlistBrowserPage.cc index 1085d4c1e..ebe686886 100644 --- a/src/laybasic/laybasic/layNetlistBrowserPage.cc +++ b/src/layui/layui/layNetlistBrowserPage.cc @@ -27,7 +27,7 @@ #include "layNetlistBrowserTreeModel.h" #include "layItemDelegates.h" #include "layCellView.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "layMarker.h" #include "layNetInfoDialog.h" #include "layNetExportDialog.h" @@ -243,7 +243,7 @@ NetlistBrowserPage::set_highlight_style (lay::Color color, int line_width, int v } void -NetlistBrowserPage::set_view (lay::LayoutView *view, int cv_index) +NetlistBrowserPage::set_view (lay::LayoutViewBase *view, int cv_index) { if (mp_view) { mp_view->layer_list_changed_event.remove (this, &NetlistBrowserPage::layer_list_changed); @@ -1425,7 +1425,7 @@ NetlistBrowserPage::export_nets (const std::vector *nets) if (dialog->exec_dialog (mp_plugin_root)) { // NOTE: mp_view and database might get reset to 0 in create_layout - lay::LayoutView *view = mp_view; + lay::LayoutViewBase *view = mp_view; db::LayoutToNetlist *database = mp_database.get (); unsigned int cv_index = view->create_layout (true); diff --git a/src/laybasic/laybasic/layNetlistBrowserPage.h b/src/layui/layui/layNetlistBrowserPage.h similarity index 98% rename from src/laybasic/laybasic/layNetlistBrowserPage.h rename to src/layui/layui/layNetlistBrowserPage.h index ac135245d..4fb4281ac 100644 --- a/src/laybasic/laybasic/layNetlistBrowserPage.h +++ b/src/layui/layui/layNetlistBrowserPage.h @@ -28,7 +28,7 @@ #include "ui_NetlistBrowserPage.h" #include "layNetlistBrowserModel.h" #include "layNetlistBrowser.h" -#include "laybasicCommon.h" +#include "layuiCommon.h" #include "dbLayoutToNetlist.h" #include "dbLayoutVsSchematic.h" #include "dbLayoutUtils.h" @@ -43,7 +43,7 @@ class QAction; namespace lay { -class LayoutView; +class LayoutViewBase; class Dispatcher; class Marker; class NetInfoDialog; @@ -87,7 +87,7 @@ public: * If that pointer is non-null, the browser will attach itself to * the view and provide highlights for the selected markers inside the given cellview. */ - void set_view (LayoutView *view, int cv_index); + void set_view (LayoutViewBase *view, int cv_index); /** * @brief Attaches the page to a L2N DB @@ -225,7 +225,7 @@ private: int m_marker_dither_pattern; int m_marker_intensity; bool m_use_original_colors; - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; unsigned int m_cv_index; lay::Dispatcher *mp_plugin_root; tl::weak_ptr mp_database; diff --git a/src/laybasic/laybasic/layNetlistBrowserTreeModel.cc b/src/layui/layui/layNetlistBrowserTreeModel.cc similarity index 100% rename from src/laybasic/laybasic/layNetlistBrowserTreeModel.cc rename to src/layui/layui/layNetlistBrowserTreeModel.cc diff --git a/src/laybasic/laybasic/layNetlistBrowserTreeModel.h b/src/layui/layui/layNetlistBrowserTreeModel.h similarity index 97% rename from src/laybasic/laybasic/layNetlistBrowserTreeModel.h rename to src/layui/layui/layNetlistBrowserTreeModel.h index 19fdf20b4..021694e8a 100644 --- a/src/laybasic/laybasic/layNetlistBrowserTreeModel.h +++ b/src/layui/layui/layNetlistBrowserTreeModel.h @@ -26,7 +26,7 @@ #define HDR_layNetlistBrowserTreeModel #include "layColorPalette.h" -#include "laybasicCommon.h" +#include "layuiCommon.h" #include "dbLayoutToNetlist.h" #include "dbLayoutVsSchematic.h" @@ -43,7 +43,7 @@ namespace lay { class IndexedNetlistModel; -struct NetlistObjectsPath; +class NetlistObjectsPath; // ---------------------------------------------------------------------------------- // NetlistBrowserTreeModel definition @@ -51,7 +51,7 @@ struct NetlistObjectsPath; /** * @brief The model for the circuit hierarchy tree */ -class LAYBASIC_PUBLIC NetlistBrowserTreeModel +class LAYUI_PUBLIC NetlistBrowserTreeModel : public QAbstractItemModel { Q_OBJECT diff --git a/src/laybasic/laybasic/layNetlistCrossReferenceModel.cc b/src/layui/layui/layNetlistCrossReferenceModel.cc similarity index 100% rename from src/laybasic/laybasic/layNetlistCrossReferenceModel.cc rename to src/layui/layui/layNetlistCrossReferenceModel.cc diff --git a/src/laybasic/laybasic/layNetlistCrossReferenceModel.h b/src/layui/layui/layNetlistCrossReferenceModel.h similarity index 98% rename from src/laybasic/laybasic/layNetlistCrossReferenceModel.h rename to src/layui/layui/layNetlistCrossReferenceModel.h index 01475b35b..9a721c56a 100644 --- a/src/laybasic/laybasic/layNetlistCrossReferenceModel.h +++ b/src/layui/layui/layNetlistCrossReferenceModel.h @@ -25,7 +25,7 @@ #ifndef HDR_layNetlistCrossReference #define HDR_layNetlistCrossReference -#include "laybasicCommon.h" +#include "layuiCommon.h" #include "layIndexedNetlistModel.h" #include "dbNetlistCrossReference.h" @@ -36,7 +36,7 @@ namespace lay /** * @brief An indexed netlist model for the netlist cross-reference */ -class LAYBASIC_PUBLIC NetlistCrossReferenceModel +class LAYUI_PUBLIC NetlistCrossReferenceModel : public lay::IndexedNetlistModel { public: diff --git a/src/laybasic/laybasic/layQtTools.cc b/src/layui/layui/layQtTools.cc similarity index 100% rename from src/laybasic/laybasic/layQtTools.cc rename to src/layui/layui/layQtTools.cc diff --git a/src/laybasic/laybasic/layQtTools.h b/src/layui/layui/layQtTools.h similarity index 76% rename from src/laybasic/laybasic/layQtTools.h rename to src/layui/layui/layQtTools.h index 7b49c8aff..f5c4ae97f 100644 --- a/src/laybasic/laybasic/layQtTools.h +++ b/src/layui/layui/layQtTools.h @@ -25,7 +25,7 @@ #ifndef HDR_layQtTools #define HDR_layQtTools -#include "laybasicCommon.h" +#include "layuiCommon.h" #include #include @@ -48,27 +48,27 @@ namespace lay * * The state can be recovered from the string using restore_dialog_state; */ -LAYBASIC_PUBLIC std::string save_dialog_state (QWidget *dialog, bool with_section_sizes = true); +LAYUI_PUBLIC std::string save_dialog_state (QWidget *dialog, bool with_section_sizes = true); /** * @brief Restore the dialog's state from the given string */ -LAYBASIC_PUBLIC void restore_dialog_state (QWidget *dialog, const std::string &s, bool with_section_sizes = true); +LAYUI_PUBLIC void restore_dialog_state (QWidget *dialog, const std::string &s, bool with_section_sizes = true); /** * @brief A utility function connecting a label's linkActivated event with the help browser */ -LAYBASIC_PUBLIC void activate_help_links (QLabel *label); +LAYUI_PUBLIC void activate_help_links (QLabel *label); /** * @brief A utility function connecting a label's linkActivated event with the help browser (modal help dialogs) */ -LAYBASIC_PUBLIC void activate_modal_help_links (QLabel *label); +LAYUI_PUBLIC void activate_modal_help_links (QLabel *label); /** * @brief Register the help handler (object and slots for non-modal and modal help dialogs) */ -LAYBASIC_PUBLIC void register_help_handler (QObject *object, const char *slot, const char *modal_slot); +LAYUI_PUBLIC void register_help_handler (QObject *object, const char *slot, const char *modal_slot); /** * @brief Configures a QLineEdit or other widget to indicate an error @@ -77,24 +77,24 @@ LAYBASIC_PUBLIC void register_help_handler (QObject *object, const char *slot, c * and the exception's text will be used as tooltip. Use this function with * a null ex pointer to clear the error condition. */ -LAYBASIC_PUBLIC void indicate_error (QWidget *le, const tl::Exception *ex); +LAYUI_PUBLIC void indicate_error (QWidget *le, const tl::Exception *ex); /** * @brief Configures a QLineEdit or other widget to indicate an error */ -LAYBASIC_PUBLIC void indicate_error (QWidget *le, bool error); +LAYUI_PUBLIC void indicate_error (QWidget *le, bool error); /** * @brief Gets the system monospace font */ -LAYBASIC_PUBLIC QFont monospace_font (); +LAYUI_PUBLIC QFont monospace_font (); #if QT_VERSION < 0x050000 // Provide missing QSignalBlocker for Qt4 -class LAYBASIC_PUBLIC SignalBlocker +class LAYUI_PUBLIC SignalBlocker { public: SignalBlocker (QWidget *w); diff --git a/src/laybasic/laybasic/laySaveLayoutOptionsDialog.cc b/src/layui/layui/laySaveLayoutOptionsDialog.cc similarity index 98% rename from src/laybasic/laybasic/laySaveLayoutOptionsDialog.cc rename to src/layui/layui/laySaveLayoutOptionsDialog.cc index ff5b28002..d629ba568 100644 --- a/src/laybasic/laybasic/laySaveLayoutOptionsDialog.cc +++ b/src/layui/layui/laySaveLayoutOptionsDialog.cc @@ -22,7 +22,7 @@ #if defined(HAVE_QT) -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "laySaveLayoutOptionsDialog.h" #include "layStream.h" #include "laybasicConfig.h" @@ -406,7 +406,7 @@ SaveLayoutAsOptionsDialog::ok_button_pressed () } bool -SaveLayoutAsOptionsDialog::get_options (lay::LayoutView *view, unsigned int cv_index, const std::string &fn, tl::OutputStream::OutputStreamMode &om, db::SaveLayoutOptions &options) +SaveLayoutAsOptionsDialog::get_options (lay::LayoutViewBase *view, unsigned int cv_index, const std::string &fn, tl::OutputStream::OutputStreamMode &om, db::SaveLayoutOptions &options) { const lay::CellView &cv = view->cellview (cv_index); if (! cv.is_valid ()) { diff --git a/src/laybasic/laybasic/laySaveLayoutOptionsDialog.h b/src/layui/layui/laySaveLayoutOptionsDialog.h similarity index 88% rename from src/laybasic/laybasic/laySaveLayoutOptionsDialog.h rename to src/layui/layui/laySaveLayoutOptionsDialog.h index a8dcb6554..db37f3c4d 100644 --- a/src/laybasic/laybasic/laySaveLayoutOptionsDialog.h +++ b/src/layui/layui/laySaveLayoutOptionsDialog.h @@ -25,6 +25,7 @@ #ifndef HDR_laySaveLayoutOptionsDialog #define HDR_laySaveLayoutOptionsDialog +#include "layuiCommon.h" #include "ui_SaveLayoutOptionsDialog.h" #include "ui_SaveLayoutAsOptionsDialog.h" #include "dbStream.h" @@ -46,9 +47,9 @@ namespace db namespace lay { -class LayoutView; +class LayoutViewBase; -class LAYBASIC_PUBLIC SaveLayoutAsOptionsDialog +class LAYUI_PUBLIC SaveLayoutAsOptionsDialog : public QDialog, private Ui::SaveLayoutAsOptionsDialog { Q_OBJECT @@ -57,7 +58,7 @@ public: SaveLayoutAsOptionsDialog (QWidget *parent, const std::string &title); ~SaveLayoutAsOptionsDialog (); - bool get_options (lay::LayoutView *view, unsigned int cv_index, const std::string &fn, tl::OutputStream::OutputStreamMode &compression, db::SaveLayoutOptions &options); + bool get_options (lay::LayoutViewBase *view, unsigned int cv_index, const std::string &fn, tl::OutputStream::OutputStreamMode &compression, db::SaveLayoutOptions &options); public slots: void ok_button_pressed (); @@ -71,7 +72,7 @@ private: const db::Technology *mp_tech; }; -class LAYBASIC_PUBLIC SaveLayoutOptionsDialog +class LAYUI_PUBLIC SaveLayoutOptionsDialog : public QDialog, private Ui::SaveLayoutOptionsDialog { Q_OBJECT diff --git a/src/laybasic/laybasic/laySelectCellViewForm.cc b/src/layui/layui/laySelectCellViewForm.cc similarity index 97% rename from src/laybasic/laybasic/laySelectCellViewForm.cc rename to src/layui/layui/laySelectCellViewForm.cc index 1ae4b1da7..ccdb27d1d 100644 --- a/src/laybasic/laybasic/laySelectCellViewForm.cc +++ b/src/layui/layui/laySelectCellViewForm.cc @@ -24,14 +24,14 @@ #include "laySelectCellViewForm.h" #include "layCellView.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" namespace lay { // ------------------------------------------------------------ -SelectCellViewForm::SelectCellViewForm (QWidget *parent, lay::LayoutView *view, const std::string &title, bool single) +SelectCellViewForm::SelectCellViewForm (QWidget *parent, lay::LayoutViewBase *view, const std::string &title, bool single) : QDialog (parent), Ui::SelectCellViewForm () { setObjectName (QString::fromUtf8 ("select_cv")); diff --git a/src/laybasic/laybasic/laySelectCellViewForm.h b/src/layui/layui/laySelectCellViewForm.h similarity index 90% rename from src/laybasic/laybasic/laySelectCellViewForm.h rename to src/layui/layui/laySelectCellViewForm.h index 5abd7efe2..9d3a1d63c 100644 --- a/src/laybasic/laybasic/laySelectCellViewForm.h +++ b/src/layui/layui/laySelectCellViewForm.h @@ -25,7 +25,7 @@ #ifndef HDR_SelectCellViewForm #define HDR_SelectCellViewForm -#include "laybasicCommon.h" +#include "layuiCommon.h" #include #include @@ -38,15 +38,15 @@ namespace lay { class CellView; -class LayoutView; +class LayoutViewBase; -class LAYBASIC_PUBLIC SelectCellViewForm +class LAYUI_PUBLIC SelectCellViewForm : public QDialog, private Ui::SelectCellViewForm { Q_OBJECT public: - SelectCellViewForm (QWidget *parent, lay::LayoutView *view, const std::string &title, bool single = false); + SelectCellViewForm (QWidget *parent, lay::LayoutViewBase *view, const std::string &title, bool single = false); /** * @brief Set the selection to a single selection diff --git a/src/laybasic/laybasic/laySelectLineStyleForm.cc b/src/layui/layui/laySelectLineStyleForm.cc similarity index 100% rename from src/laybasic/laybasic/laySelectLineStyleForm.cc rename to src/layui/layui/laySelectLineStyleForm.cc diff --git a/src/laybasic/laybasic/laySelectLineStyleForm.h b/src/layui/layui/laySelectLineStyleForm.h similarity index 100% rename from src/laybasic/laybasic/laySelectLineStyleForm.h rename to src/layui/layui/laySelectLineStyleForm.h diff --git a/src/laybasic/laybasic/laySelectStippleForm.cc b/src/layui/layui/laySelectStippleForm.cc similarity index 100% rename from src/laybasic/laybasic/laySelectStippleForm.cc rename to src/layui/layui/laySelectStippleForm.cc diff --git a/src/laybasic/laybasic/laySelectStippleForm.h b/src/layui/layui/laySelectStippleForm.h similarity index 100% rename from src/laybasic/laybasic/laySelectStippleForm.h rename to src/layui/layui/laySelectStippleForm.h diff --git a/src/laybasic/laybasic/layTechnology.cc b/src/layui/layui/layTechnology.cc similarity index 100% rename from src/laybasic/laybasic/layTechnology.cc rename to src/layui/layui/layTechnology.cc diff --git a/src/laybasic/laybasic/layTechnology.h b/src/layui/layui/layTechnology.h similarity index 95% rename from src/laybasic/laybasic/layTechnology.h rename to src/layui/layui/layTechnology.h index c7168b313..1dcf693a1 100644 --- a/src/laybasic/laybasic/layTechnology.h +++ b/src/layui/layui/layTechnology.h @@ -25,7 +25,7 @@ #ifndef HDR_layTechnology #define HDR_layTechnology -#include "laybasicCommon.h" +#include "layuiCommon.h" #include "dbTechnology.h" @@ -41,7 +41,7 @@ namespace lay * To do so, it must implement a TechnologyComponentEditor that provides an * editor for it's component. */ -class LAYBASIC_PUBLIC TechnologyComponentEditor +class LAYUI_PUBLIC TechnologyComponentEditor : public QFrame { public: @@ -106,7 +106,7 @@ private: /** * @brief A base class for a technology component provider */ -class LAYBASIC_PUBLIC TechnologyEditorProvider +class LAYUI_PUBLIC TechnologyEditorProvider { public: /** diff --git a/src/laybasic/laybasic/layTipDialog.cc b/src/layui/layui/layTipDialog.cc similarity index 100% rename from src/laybasic/laybasic/layTipDialog.cc rename to src/layui/layui/layTipDialog.cc diff --git a/src/laybasic/laybasic/layTipDialog.h b/src/layui/layui/layTipDialog.h similarity index 98% rename from src/laybasic/laybasic/layTipDialog.h rename to src/layui/layui/layTipDialog.h index fc6ffaf27..80748bef9 100644 --- a/src/laybasic/laybasic/layTipDialog.h +++ b/src/layui/layui/layTipDialog.h @@ -25,7 +25,7 @@ #ifndef HDR_layTipDialog #define HDR_layTipDialog -#include "laybasicCommon.h" +#include "layuiCommon.h" #include #include @@ -42,7 +42,7 @@ namespace lay { * A tip window is basically a message box with the ability to hide the box forever (or at least until the * configuration is reset). */ -class LAYBASIC_PUBLIC TipDialog +class LAYUI_PUBLIC TipDialog : public QDialog { Q_OBJECT diff --git a/src/laybasic/laybasic/layWidgets.cc b/src/layui/layui/layWidgets.cc similarity index 99% rename from src/laybasic/laybasic/layWidgets.cc rename to src/layui/layui/layWidgets.cc index aa31b339a..7f8207279 100644 --- a/src/laybasic/laybasic/layWidgets.cc +++ b/src/layui/layui/layWidgets.cc @@ -31,7 +31,7 @@ #include "layWidgets.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "layDialogs.h" #include "tlExceptions.h" #include "layStipplePalette.h" @@ -69,7 +69,7 @@ DitherPatternSelectionButton::~DitherPatternSelectionButton () } void -DitherPatternSelectionButton::set_view (lay::LayoutView *view) +DitherPatternSelectionButton::set_view (lay::LayoutViewBase *view) { if (view != mp_view) { mp_view = view; @@ -228,7 +228,7 @@ DitherPatternSelectionButton::update_menu () struct CellViewSelectionComboBoxPrivateData { - const lay::LayoutView *layout_view; + const lay::LayoutViewBase *layout_view; }; CellViewSelectionComboBox::CellViewSelectionComboBox (QWidget *parent) @@ -244,14 +244,14 @@ CellViewSelectionComboBox::~CellViewSelectionComboBox () mp_private = 0; } -const lay::LayoutView * +const lay::LayoutViewBase * CellViewSelectionComboBox::layout_view () const { return mp_private->layout_view; } void -CellViewSelectionComboBox::set_layout_view (const lay::LayoutView *layout_view) +CellViewSelectionComboBox::set_layout_view (const lay::LayoutViewBase *layout_view) { // TODO: should register a listener, so it does the update automatically. mp_private->layout_view = layout_view; @@ -297,7 +297,7 @@ struct LayerSelectionComboBoxPrivateData bool new_layer_enabled; bool all_layers; const db::Layout *layout; - lay::LayoutView *view; + lay::LayoutViewBase *view; int cv_index; db::LayerProperties last_props; }; @@ -414,7 +414,7 @@ struct LPIPairCompareOp }; void -LayerSelectionComboBox::set_view (lay::LayoutView *view, int cv_index, bool all_layers) +LayerSelectionComboBox::set_view (lay::LayoutViewBase *view, int cv_index, bool all_layers) { if (view == 0 || cv_index < 0) { set_layout (0); diff --git a/src/laybasic/laybasic/layWidgets.h b/src/layui/layui/layWidgets.h similarity index 94% rename from src/laybasic/laybasic/layWidgets.h rename to src/layui/layui/layWidgets.h index eb3ef708f..02d9666f4 100644 --- a/src/laybasic/laybasic/layWidgets.h +++ b/src/layui/layui/layWidgets.h @@ -25,7 +25,7 @@ #ifndef HDR_layWidgets #define HDR_layWidgets -#include "laybasicCommon.h" +#include "layuiCommon.h" #include "tlObject.h" @@ -47,14 +47,14 @@ namespace db namespace lay { -class LayoutView; +class LayoutViewBase; struct LayerSelectionComboBoxPrivateData; struct CellViewSelectionComboBoxPrivateData; /** * @brief A selection button for dither pattern */ -class LAYBASIC_PUBLIC DitherPatternSelectionButton +class LAYUI_PUBLIC DitherPatternSelectionButton : public QPushButton { Q_OBJECT @@ -75,7 +75,7 @@ public: * * This method is required to select the proper dither pattern */ - void set_view (lay::LayoutView *view); + void set_view (lay::LayoutViewBase *view); /** * @brief Set the dither pattern index @@ -106,7 +106,7 @@ private slots: void menu_about_to_show (); private: - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; int m_dither_pattern; void update_pattern (); @@ -118,7 +118,7 @@ private: * * This combo box allows selecting a library */ -class LAYBASIC_PUBLIC LibrarySelectionComboBox +class LAYUI_PUBLIC LibrarySelectionComboBox : public QComboBox { Q_OBJECT @@ -172,7 +172,7 @@ private: * * This combo box allows selecting a (physical) layer from a layout */ -class LAYBASIC_PUBLIC LayerSelectionComboBox +class LAYUI_PUBLIC LayerSelectionComboBox : public QComboBox, public tl::Object { Q_OBJECT @@ -204,7 +204,7 @@ public: * If all_layers is set to true, layers are shown which are in the layer list, but * not created as layers yet. */ - void set_view (lay::LayoutView *view, int cv_index, bool all_layers = false); + void set_view (lay::LayoutViewBase *view, int cv_index, bool all_layers = false); /** * @brief Sets a flag indicating whether the "new layer" option is available @@ -261,7 +261,7 @@ private: * * This combo box allows selecting a cellview from a lay::LayoutView */ -class LAYBASIC_PUBLIC CellViewSelectionComboBox +class LAYUI_PUBLIC CellViewSelectionComboBox : public QComboBox { Q_OBJECT @@ -270,8 +270,8 @@ public: CellViewSelectionComboBox (QWidget *parent); ~CellViewSelectionComboBox (); - void set_layout_view (const lay::LayoutView *view); - const lay::LayoutView *layout_view () const; + void set_layout_view (const lay::LayoutViewBase *view); + const lay::LayoutViewBase *layout_view () const; void set_current_cv_index (int l); int current_cv_index () const; @@ -287,7 +287,7 @@ private: * usual push button and supplies a color chooser without the * capability to switch to "auto" color mode. */ -class LAYBASIC_PUBLIC SimpleColorButton +class LAYUI_PUBLIC SimpleColorButton : public QPushButton { Q_OBJECT @@ -320,7 +320,7 @@ private slots: * usual push button and supplies a color chooser with the * capability to switch to "auto" color mode. */ -class LAYBASIC_PUBLIC ColorButton +class LAYUI_PUBLIC ColorButton : public QPushButton { Q_OBJECT @@ -355,7 +355,7 @@ private slots: /** * @brief An edit box with a clear button and options menu */ -class LAYBASIC_PUBLIC DecoratedLineEdit +class LAYUI_PUBLIC DecoratedLineEdit : public QLineEdit { Q_OBJECT @@ -468,7 +468,7 @@ private: /** * @brief An interactive list widget which offers slots to delete and move items and interfaces to std::vector */ -class LAYBASIC_PUBLIC InteractiveListWidget +class LAYUI_PUBLIC InteractiveListWidget : public QListWidget { Q_OBJECT diff --git a/src/laybasic/laybasic/laybasicResources.qrc b/src/layui/layui/laybasicResources.qrc similarity index 100% rename from src/laybasic/laybasic/laybasicResources.qrc rename to src/layui/layui/laybasicResources.qrc diff --git a/src/layui/layui/layui.pro b/src/layui/layui/layui.pro new file mode 100644 index 000000000..733082897 --- /dev/null +++ b/src/layui/layui/layui.pro @@ -0,0 +1,218 @@ + +DESTDIR = $$OUT_PWD/../.. +TARGET = klayout_layui + +include($$PWD/../../lib.pri) + +DEFINES += MAKE_LAYUI_LIBRARY + +FORMS = \ + AlignCellOptionsDialog.ui \ + BookmarkManagementForm.ui \ + BrowseInstancesConfigPage.ui \ + BrowseInstancesForm.ui \ + BrowserDialog.ui \ + BrowserPanel.ui \ + BrowseShapesConfigPage.ui \ + BrowseShapesForm.ui \ + CellSelectionForm.ui \ + ClearLayerModeDialog.ui \ + ConfigurationDialog.ui \ + CopyCellModeDialog.ui \ + DeleteCellModeDialog.ui \ + DuplicateLayerDialog.ui \ + EditStipplesForm.ui \ + FlattenInstOptionsDialog.ui \ + GridNetConfigPage.ui \ + LayerMappingWidget.ui \ + LayerSourceDialog.ui \ + LayoutProperties.ui \ + LayoutViewConfigPage1.ui \ + LayoutViewConfigPage2a.ui \ + LayoutViewConfigPage2b.ui \ + LayoutViewConfigPage2c.ui \ + LayoutViewConfigPage2d.ui \ + LayoutViewConfigPage3a.ui \ + LayoutViewConfigPage3b.ui \ + LayoutViewConfigPage3c.ui \ + LayoutViewConfigPage3f.ui \ + LayoutViewConfigPage4.ui \ + LayoutViewConfigPage5.ui \ + LayoutViewConfigPage6.ui \ + LayoutViewConfigPage7.ui \ + LayoutViewConfigPage.ui \ + LibraryCellSelectionForm.ui \ + LoadLayoutOptionsDialog.ui \ + MarkerBrowserConfigPage2.ui \ + MarkerBrowserConfigPage.ui \ + MarkerBrowserDialog.ui \ + MarkerBrowserPage.ui \ + MarkerBrowserSnapshotView.ui \ + MoveOptionsDialog.ui \ + MoveToOptionsDialog.ui \ + NewCellPropertiesDialog.ui \ + NewLayerPropertiesDialog.ui \ + NewLayoutPropertiesDialog.ui \ + OpenLayoutModeDialog.ui \ + RenameCellDialog.ui \ + ReplaceCellOptionsDialog.ui \ + SaveLayoutOptionsDialog.ui \ + SaveLayoutAsOptionsDialog.ui \ + SelectStippleForm.ui \ + TipDialog.ui \ + UserPropertiesForm.ui \ + UserPropertiesEditForm.ui \ + SpecificLoadLayoutOptionsDialog.ui \ + SelectLineStyleForm.ui \ + LayoutViewConfigPage6a.ui \ + EditLineStylesForm.ui \ + NetlistBrowserPage.ui \ + NetlistBrowserConfigPage.ui \ + NetlistBrowserConfigPage2.ui \ + NetlistBrowserDialog.ui \ + NetInfoDialog.ui \ + NetExportDialog.ui \ + SelectCellViewForm.ui \ + LayoutStatistics.ui \ + +RESOURCES = \ + laybasicResources.qrc \ + layLayoutStatistics.qrc \ + +SOURCES = \ + gsiDeclLayDialogs.cc \ + gsiDeclLayMenu.cc \ + gsiDeclLayNetlistBrowserDialog.cc \ + gsiDeclLayStream.cc \ + layBackgroundAwareTreeStyle.cc \ + layBookmarkManagementForm.cc \ + layBookmarksView.cc \ + layBrowseInstancesForm.cc \ + layBrowseShapesForm.cc \ + layBrowser.cc \ + layBrowserDialog.cc \ + layBrowserPanel.cc \ + layBusy.cc \ + layCellSelectionForm.cc \ + layCellTreeModel.cc \ + layConfigurationDialog.cc \ + layDialogs.cc \ + layEditLineStyleWidget.cc \ + layEditLineStylesForm.cc \ + layEditStippleWidget.cc \ + layEditStipplesForm.cc \ + layEditorOptionsFrame.cc \ + layEditorOptionsPage.cc \ + layEditorOptionsPages.cc \ + layFileDialog.cc \ + layGridNetConfigPage.cc \ + layGridNet.cc \ + layGenericSyntaxHighlighter.cc \ + layHierarchyControlPanel.cc \ + layIndexedNetlistModel.cc \ + layItemDelegates.cc \ + layLayerControlPanel.cc \ + layLayerMappingWidget.cc \ + layLayerToolbox.cc \ + layLayerTreeModel.cc \ + layLayoutPropertiesForm.cc \ + layLayoutStatisticsForm.cc \ + layLayoutViewConfigPages.cc \ + layLayoutViewFunctions.cc \ + layLibrariesView.cc \ + layLoadLayoutOptionsDialog.cc \ + layNetExportDialog.cc \ + layNetInfoDialog.cc \ + layNetlistBrowser.cc \ + layNetlistBrowserDialog.cc \ + layNetlistBrowserModel.cc \ + layNetlistBrowserPage.cc \ + layNetlistBrowserTreeModel.cc \ + layNetlistCrossReferenceModel.cc \ + layQtTools.cc \ + laySaveLayoutOptionsDialog.cc \ + laySelectCellViewForm.cc \ + laySelectLineStyleForm.cc \ + laySelectStippleForm.cc \ + layTechnology.cc \ + layTipDialog.cc \ + layWidgets.cc \ + rdbInfoWidget.cc \ + rdbMarkerBrowser.cc \ + rdbMarkerBrowserDialog.cc \ + rdbMarkerBrowserPage.cc \ + +HEADERS = \ + layBackgroundAwareTreeStyle.h \ + layBookmarkManagementForm.h \ + layBookmarksView.h \ + layBrowseInstancesForm.h \ + layBrowseShapesForm.h \ + layBrowser.h \ + layBrowserDialog.h \ + layBrowserPanel.h \ + layBusy.h \ + layCellSelectionForm.h \ + layCellTreeModel.h \ + layConfigurationDialog.h \ + layDialogs.h \ + layEditLineStyleWidget.h \ + layEditLineStylesForm.h \ + layEditStippleWidget.h \ + layEditStipplesForm.h \ + layEditorOptionsFrame.h \ + layEditorOptionsPage.h \ + layEditorOptionsPages.h \ + layFileDialog.h \ + layGenericSyntaxHighlighter.h \ + layGridNetConfigPage.h \ + layGridNet.h \ + layHierarchyControlPanel.h \ + layIndexedNetlistModel.h \ + layItemDelegates.h \ + layLayerControlPanel.h \ + layLayerMappingWidget.h \ + layLayerToolbox.h \ + layLayerTreeModel.h \ + layLayoutPropertiesForm.h \ + layLayoutStatisticsForm.h \ + layLayoutViewConfigPages.h \ + layLayoutViewFunctions.h \ + layLibrariesView.h \ + layLoadLayoutOptionsDialog.h \ + layNetExportDialog.h \ + layNetInfoDialog.h \ + layNetlistBrowser.h \ + layNetlistBrowserDialog.h \ + layNetlistBrowserModel.h \ + layNetlistBrowserPage.h \ + layNetlistBrowserTreeModel.h \ + layNetlistCrossReferenceModel.h \ + layQtTools.h \ + laySaveLayoutOptionsDialog.h \ + laySelectCellViewForm.h \ + laySelectLineStyleForm.h \ + laySelectStippleForm.h \ + layTechnology.h \ + layTipDialog.h \ + layWidgets.h \ + laybasicConfig.h \ + rdbInfoWidget.h \ + rdbMarkerBrowser.h \ + rdbMarkerBrowserDialog.h \ + rdbMarkerBrowserPage.h \ + +INCLUDEPATH += $$LAYBASIC_INC $$TL_INC $$GSI_INC $$DB_INC $$RDB_INC +DEPENDPATH += $$LAYBASIC_INC $$TL_INC $$GSI_INC $$DB_INC $$RDB_INC +LIBS += -L$$DESTDIR -lklayout_laybasic -lklayout_tl -lklayout_gsi -lklayout_db -lklayout_rdb + +INCLUDEPATH += $$QTBASIC_INC +DEPENDPATH += $$QTBASIC_INC + +equals(HAVE_QTBINDINGS, "1") { + LIBS += -lklayout_qtbasic -lklayout_QtGui -lklayout_QtCore + greaterThan(QT_MAJOR_VERSION, 4) { + LIBS += -lklayout_QtWidgets + } +} + diff --git a/src/layui/layui/layuiCommon.h b/src/layui/layui/layuiCommon.h new file mode 100644 index 000000000..b6c807d2f --- /dev/null +++ b/src/layui/layui/layuiCommon.h @@ -0,0 +1,51 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 + +*/ + + +#if !defined(HDR_layuiCommon_h) +# define HDR_layuiCommon_h + +# if defined _WIN32 || defined __CYGWIN__ + +# ifdef MAKE_LAYUI_LIBRARY +# define LAYUI_PUBLIC __declspec(dllexport) +# else +# define LAYUI_PUBLIC __declspec(dllimport) +# endif +# define LAYUI_LOCAL +# define LAYUI_PUBLIC_TEMPLATE + +# else + +# if __GNUC__ >= 4 || defined(__clang__) +# define LAYUI_PUBLIC __attribute__ ((visibility ("default"))) +# define LAYUI_PUBLIC_TEMPLATE __attribute__ ((visibility ("default"))) +# define LAYUI_LOCAL __attribute__ ((visibility ("hidden"))) +# else +# define LAYUI_PUBLIC +# define LAYUI_PUBLIC_TEMPLATE +# define LAYUI_LOCAL +# endif + +# endif + +#endif diff --git a/src/laybasic/laybasic/rdbInfoWidget.cc b/src/layui/layui/rdbInfoWidget.cc similarity index 100% rename from src/laybasic/laybasic/rdbInfoWidget.cc rename to src/layui/layui/rdbInfoWidget.cc diff --git a/src/laybasic/laybasic/rdbInfoWidget.h b/src/layui/layui/rdbInfoWidget.h similarity index 100% rename from src/laybasic/laybasic/rdbInfoWidget.h rename to src/layui/layui/rdbInfoWidget.h diff --git a/src/laybasic/laybasic/rdbMarkerBrowser.cc b/src/layui/layui/rdbMarkerBrowser.cc similarity index 99% rename from src/laybasic/laybasic/rdbMarkerBrowser.cc rename to src/layui/layui/rdbMarkerBrowser.cc index b0093decf..06b2df327 100644 --- a/src/laybasic/laybasic/rdbMarkerBrowser.cc +++ b/src/layui/layui/rdbMarkerBrowser.cc @@ -302,7 +302,7 @@ public: menu_entries.push_back (lay::menu_item ("marker_browser::scan_layers_flat", "scan_layers_flat", "tools_menu.shapes_to_markers.end", tl::to_string (QObject::tr ("Flat")))); } - virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutView *view) const + virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutViewBase *view) const { return new rdb::MarkerBrowserDialog (root, view); } diff --git a/src/laybasic/laybasic/rdbMarkerBrowser.h b/src/layui/layui/rdbMarkerBrowser.h similarity index 100% rename from src/laybasic/laybasic/rdbMarkerBrowser.h rename to src/layui/layui/rdbMarkerBrowser.h diff --git a/src/laybasic/laybasic/rdbMarkerBrowserDialog.cc b/src/layui/layui/rdbMarkerBrowserDialog.cc similarity index 88% rename from src/laybasic/laybasic/rdbMarkerBrowserDialog.cc rename to src/layui/layui/rdbMarkerBrowserDialog.cc index 644d0c089..b3c7de898 100644 --- a/src/laybasic/laybasic/rdbMarkerBrowserDialog.cc +++ b/src/layui/layui/rdbMarkerBrowserDialog.cc @@ -26,7 +26,7 @@ #include "rdb.h" #include "rdbReader.h" #include "tlProgress.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "tlExceptions.h" #include "layFileDialog.h" #include "layConverters.h" @@ -35,6 +35,8 @@ #include "dbLayoutUtils.h" #include "dbRecursiveShapeIterator.h" +#include "ui_MarkerBrowserDialog.h" + #include #include @@ -55,9 +57,8 @@ extern std::string cfg_rdb_marker_vertex_size; extern std::string cfg_rdb_marker_halo; extern std::string cfg_rdb_marker_dither_pattern; -MarkerBrowserDialog::MarkerBrowserDialog (lay::Dispatcher *root, lay::LayoutView *vw) +MarkerBrowserDialog::MarkerBrowserDialog (lay::Dispatcher *root, lay::LayoutViewBase *vw) : lay::Browser (root, vw), - Ui::MarkerBrowserDialog (), m_context (rdb::AnyCell), m_window (rdb::FitMarker), m_window_dim (0.0), @@ -69,9 +70,10 @@ MarkerBrowserDialog::MarkerBrowserDialog (lay::Dispatcher *root, lay::LayoutView m_cv_index (-1), m_rdb_index (-1) { - Ui::MarkerBrowserDialog::setupUi (this); + mp_ui = new Ui::MarkerBrowserDialog (); + mp_ui->setupUi (this); - browser_frame->set_dispatcher (root); + mp_ui->browser_frame->set_dispatcher (root); if (view ()) { view ()->cellviews_changed_event.add (this, &MarkerBrowserDialog::cellviews_changed); @@ -79,12 +81,12 @@ MarkerBrowserDialog::MarkerBrowserDialog (lay::Dispatcher *root, lay::LayoutView view ()->rdb_list_changed_event.add (this, &MarkerBrowserDialog::rdbs_changed); } - m_open_action = new QAction (QObject::tr ("Open"), file_menu); - m_saveas_action = new QAction (QObject::tr ("Save As"), file_menu); - m_export_action = new QAction (QObject::tr ("Export To Layout"), file_menu); - m_reload_action = new QAction (QObject::tr ("Reload"), file_menu); - m_unload_action = new QAction (QObject::tr ("Unload"), file_menu); - m_unload_all_action = new QAction (QObject::tr ("Unload All"), file_menu); + m_open_action = new QAction (QObject::tr ("Open"), mp_ui->file_menu); + m_saveas_action = new QAction (QObject::tr ("Save As"), mp_ui->file_menu); + m_export_action = new QAction (QObject::tr ("Export To Layout"), mp_ui->file_menu); + m_reload_action = new QAction (QObject::tr ("Reload"), mp_ui->file_menu); + m_unload_action = new QAction (QObject::tr ("Unload"), mp_ui->file_menu); + m_unload_all_action = new QAction (QObject::tr ("Unload All"), mp_ui->file_menu); connect (m_open_action, SIGNAL (triggered ()), this, SLOT (open_clicked ())); connect (m_saveas_action, SIGNAL (triggered ()), this, SLOT (saveas_clicked ())); @@ -93,24 +95,24 @@ MarkerBrowserDialog::MarkerBrowserDialog (lay::Dispatcher *root, lay::LayoutView connect (m_unload_action, SIGNAL (triggered ()), this, SLOT (unload_clicked ())); connect (m_unload_all_action, SIGNAL (triggered ()), this, SLOT (unload_all_clicked ())); - file_menu->addAction (m_open_action); - file_menu->addAction (m_saveas_action); - QAction *sep0 = new QAction (file_menu); + mp_ui->file_menu->addAction (m_open_action); + mp_ui->file_menu->addAction (m_saveas_action); + QAction *sep0 = new QAction (mp_ui->file_menu); sep0->setSeparator (true); - file_menu->addAction (m_export_action); - QAction *sep1 = new QAction (file_menu); + mp_ui->file_menu->addAction (m_export_action); + QAction *sep1 = new QAction (mp_ui->file_menu); sep1->setSeparator (true); - file_menu->addAction (sep1); - file_menu->addAction (m_reload_action); - QAction *sep2 = new QAction (file_menu); + mp_ui->file_menu->addAction (sep1); + mp_ui->file_menu->addAction (m_reload_action); + QAction *sep2 = new QAction (mp_ui->file_menu); sep2->setSeparator (true); - file_menu->addAction (sep2); - file_menu->addAction (m_unload_action); - file_menu->addAction (m_unload_all_action); + mp_ui->file_menu->addAction (sep2); + mp_ui->file_menu->addAction (m_unload_action); + mp_ui->file_menu->addAction (m_unload_all_action); - connect (layout_cb, SIGNAL (activated (int)), this, SLOT (cv_index_changed (int))); - connect (rdb_cb, SIGNAL (activated (int)), this, SLOT (rdb_index_changed (int))); - connect (configure_pb, SIGNAL (clicked ()), this, SLOT (configure_clicked ())); + connect (mp_ui->layout_cb, SIGNAL (activated (int)), this, SLOT (cv_index_changed (int))); + connect (mp_ui->rdb_cb, SIGNAL (activated (int)), this, SLOT (rdb_index_changed (int))); + connect (mp_ui->configure_pb, SIGNAL (clicked ()), this, SLOT (configure_clicked ())); cellviews_changed (); } @@ -397,9 +399,9 @@ BEGIN_PROTECTED rdb::Database *rdb = view ()->get_rdb (m_rdb_index); if (rdb && ! rdb->filename ().empty ()) { - browser_frame->set_rdb (0); + mp_ui->browser_frame->set_rdb (0); rdb->load (rdb->filename ()); - browser_frame->set_rdb (rdb); + mp_ui->browser_frame->set_rdb (rdb); } @@ -426,7 +428,7 @@ BEGIN_PROTECTED db->load (m_open_filename); int rdb_index = view ()->add_rdb (db.release ()); - rdb_cb->setCurrentIndex (rdb_index); + mp_ui->rdb_cb->setCurrentIndex (rdb_index); // it looks like the setCurrentIndex does not issue this signal: rdb_index_changed (rdb_index); @@ -440,7 +442,7 @@ MarkerBrowserDialog::configure (const std::string &name, const std::string &valu { bool need_update = false; bool taken = true; - bool show_all = browser_frame->show_all (); + bool show_all = mp_ui->browser_frame->show_all (); if (name == cfg_rdb_context_mode) { @@ -530,12 +532,12 @@ MarkerBrowserDialog::configure (const std::string &name, const std::string &valu } if (active () && need_update) { - browser_frame->set_max_marker_count (m_max_marker_count); - browser_frame->set_window (m_window, m_window_dim, m_context); - browser_frame->set_marker_style (m_marker_color, m_marker_line_width, m_marker_vertex_size, m_marker_halo, m_marker_dither_pattern); + mp_ui->browser_frame->set_max_marker_count (m_max_marker_count); + mp_ui->browser_frame->set_window (m_window, m_window_dim, m_context); + mp_ui->browser_frame->set_marker_style (m_marker_color, m_marker_line_width, m_marker_vertex_size, m_marker_halo, m_marker_dither_pattern); } - browser_frame->show_all (show_all); + mp_ui->browser_frame->show_all (show_all); return taken; } @@ -568,11 +570,11 @@ MarkerBrowserDialog::rdbs_changed () { int rdb_index = -1; - rdb_cb->clear (); + mp_ui->rdb_cb->clear (); for (unsigned int i = 0; i < view ()->num_rdbs (); ++i) { const rdb::Database *rdb = view ()->get_rdb (i); - rdb_cb->addItem (tl::to_qstring (rdb->name ())); + mp_ui->rdb_cb->addItem (tl::to_qstring (rdb->name ())); if (rdb->name () == m_rdb_name) { rdb_index = i; } @@ -580,7 +582,7 @@ MarkerBrowserDialog::rdbs_changed () // force an update m_rdb_index = rdb_index; - rdb_cb->setCurrentIndex (rdb_index); + mp_ui->rdb_cb->setCurrentIndex (rdb_index); if (active ()) { update_content (); } @@ -589,7 +591,7 @@ MarkerBrowserDialog::rdbs_changed () void MarkerBrowserDialog::cellview_changed (int) { - browser_frame->update_markers (); + mp_ui->browser_frame->update_markers (); } void @@ -597,17 +599,17 @@ MarkerBrowserDialog::cellviews_changed () { int cv_index = -1; - layout_cb->clear (); + mp_ui->layout_cb->clear (); for (unsigned int i = 0; i < view ()->cellviews (); ++i) { const lay::CellView &cv = view ()->cellview (i); - layout_cb->addItem (tl::to_qstring (cv->name ())); + mp_ui->layout_cb->addItem (tl::to_qstring (cv->name ())); if (cv.is_valid () && cv->name () == m_layout_name) { cv_index = i; } } - layout_cb->setCurrentIndex (cv_index); + mp_ui->layout_cb->setCurrentIndex (cv_index); cv_index_changed (cv_index); } @@ -662,7 +664,7 @@ MarkerBrowserDialog::update_content () rdb::Database *rdb = view ()->get_rdb (m_rdb_index); if (!rdb ) { - central_stack->setCurrentIndex (1); + mp_ui->central_stack->setCurrentIndex (1); } m_saveas_action->setEnabled (rdb != 0); @@ -671,19 +673,19 @@ MarkerBrowserDialog::update_content () m_unload_all_action->setEnabled (rdb != 0); m_reload_action->setEnabled (rdb != 0); - browser_frame->enable_updates (false); // Avoid building the internal lists several times ... - browser_frame->set_rdb (0); // force update - browser_frame->set_rdb (rdb); - browser_frame->set_max_marker_count (m_max_marker_count); - browser_frame->set_marker_style (m_marker_color, m_marker_line_width, m_marker_vertex_size, m_marker_halo, m_marker_dither_pattern); - browser_frame->set_window (m_window, m_window_dim, m_context); - browser_frame->set_view (view (), m_cv_index); - browser_frame->enable_updates (true); + mp_ui->browser_frame->enable_updates (false); // Avoid building the internal lists several times ... + mp_ui->browser_frame->set_rdb (0); // force update + mp_ui->browser_frame->set_rdb (rdb); + mp_ui->browser_frame->set_max_marker_count (m_max_marker_count); + mp_ui->browser_frame->set_marker_style (m_marker_color, m_marker_line_width, m_marker_vertex_size, m_marker_halo, m_marker_dither_pattern); + mp_ui->browser_frame->set_window (m_window, m_window_dim, m_context); + mp_ui->browser_frame->set_view (view (), m_cv_index); + mp_ui->browser_frame->enable_updates (true); if (rdb) { // Note: it appears to be required to show the browser page after it has been configured. // Otherwise the header gets messed up and the configuration is reset. - central_stack->setCurrentIndex (0); + mp_ui->central_stack->setCurrentIndex (0); } lay::CellView cv = view ()->cellview (m_cv_index); @@ -692,12 +694,12 @@ MarkerBrowserDialog::update_content () m_layout_name = cv->name (); } - if (layout_cb->currentIndex () != m_cv_index) { - layout_cb->setCurrentIndex (m_cv_index); + if (mp_ui->layout_cb->currentIndex () != m_cv_index) { + mp_ui->layout_cb->setCurrentIndex (m_cv_index); } - if (rdb_cb->currentIndex () != m_rdb_index) { - rdb_cb->setCurrentIndex (m_rdb_index); + if (mp_ui->rdb_cb->currentIndex () != m_rdb_index) { + mp_ui->rdb_cb->setCurrentIndex (m_rdb_index); } } @@ -708,8 +710,8 @@ MarkerBrowserDialog::deactivated () lay::Dispatcher::instance ()->config_set (cfg_rdb_window_state, lay::save_dialog_state (this).c_str ()); } - browser_frame->set_rdb (0); - browser_frame->set_view (0, 0); + mp_ui->browser_frame->set_rdb (0); + mp_ui->browser_frame->set_view (0, 0); } void diff --git a/src/laybasic/laybasic/rdbMarkerBrowserDialog.h b/src/layui/layui/rdbMarkerBrowserDialog.h similarity index 92% rename from src/laybasic/laybasic/rdbMarkerBrowserDialog.h rename to src/layui/layui/rdbMarkerBrowserDialog.h index a8c6703d1..118aac720 100644 --- a/src/laybasic/laybasic/rdbMarkerBrowserDialog.h +++ b/src/layui/layui/rdbMarkerBrowserDialog.h @@ -25,21 +25,25 @@ #ifndef HDR_rdbMarkerBrowserDialog #define HDR_rdbMarkerBrowserDialog -#include "ui_MarkerBrowserDialog.h" #include "layBrowser.h" +#include "layColor.h" #include "rdbMarkerBrowser.h" +namespace Ui +{ + class MarkerBrowserDialog; +} + namespace rdb { class MarkerBrowserDialog - : public lay::Browser, - private Ui::MarkerBrowserDialog + : public lay::Browser { Q_OBJECT public: - MarkerBrowserDialog (lay::Dispatcher *root, lay::LayoutView *view); + MarkerBrowserDialog (lay::Dispatcher *root, lay::LayoutViewBase *view); ~MarkerBrowserDialog (); void load (int rdb_index, int cv_index); @@ -70,6 +74,7 @@ public slots: void configure_clicked (); private: + Ui::MarkerBrowserDialog *mp_ui; context_mode_type m_context; window_type m_window; double m_window_dim; diff --git a/src/laybasic/laybasic/rdbMarkerBrowserPage.cc b/src/layui/layui/rdbMarkerBrowserPage.cc similarity index 99% rename from src/laybasic/laybasic/rdbMarkerBrowserPage.cc rename to src/layui/layui/rdbMarkerBrowserPage.cc index 2efedbc0f..52bd2b58a 100644 --- a/src/laybasic/laybasic/rdbMarkerBrowserPage.cc +++ b/src/layui/layui/rdbMarkerBrowserPage.cc @@ -28,7 +28,7 @@ #include "dbLayoutUtils.h" #include "tlRecipe.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "layMarker.h" #include "tlExceptions.h" @@ -1621,7 +1621,7 @@ MarkerBrowserPage::set_marker_style (lay::Color color, int line_width, int verte } void -MarkerBrowserPage::set_view (lay::LayoutView *view, unsigned int cv_index) +MarkerBrowserPage::set_view (lay::LayoutViewBase *view, unsigned int cv_index) { mp_view = view; m_cv_index = cv_index; diff --git a/src/laybasic/laybasic/rdbMarkerBrowserPage.h b/src/layui/layui/rdbMarkerBrowserPage.h similarity index 98% rename from src/laybasic/laybasic/rdbMarkerBrowserPage.h rename to src/layui/layui/rdbMarkerBrowserPage.h index 2982cb045..21448553d 100644 --- a/src/laybasic/laybasic/rdbMarkerBrowserPage.h +++ b/src/layui/layui/rdbMarkerBrowserPage.h @@ -37,7 +37,7 @@ class QAction; namespace lay { - class LayoutView; + class LayoutViewBase; class DMarker; class Dispatcher; } @@ -79,7 +79,7 @@ public: * If that pointer is non-null, the browser will attach itself to * the view and provide highlights for the selected markers inside the given cellview. */ - void set_view (lay::LayoutView *view, unsigned int cv_index); + void set_view (lay::LayoutViewBase *view, unsigned int cv_index); /** * @brief Attach the page to a RDB @@ -185,7 +185,7 @@ private: rdb::Database *mp_database; bool m_show_all; QAction *m_show_all_action; - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; unsigned int m_cv_index; std::vector mp_markers; db::DBox m_markers_bbox; diff --git a/src/laybasic/laybasic/syntax/d25_text.xml b/src/layui/layui/syntax/d25_text.xml similarity index 100% rename from src/laybasic/laybasic/syntax/d25_text.xml rename to src/layui/layui/syntax/d25_text.xml diff --git a/src/laybasic/laybasic/syntax/ur_text.xml b/src/layui/layui/syntax/ur_text.xml similarity index 100% rename from src/laybasic/laybasic/syntax/ur_text.xml rename to src/layui/layui/syntax/ur_text.xml diff --git a/src/laybasic/laybasic/tree.stxml b/src/layui/layui/tree.stxml similarity index 100% rename from src/laybasic/laybasic/tree.stxml rename to src/layui/layui/tree.stxml diff --git a/src/laybasic/unit_tests/layNetlistBrowserModelTests.cc b/src/layui/unit_tests/layNetlistBrowserModelTests.cc similarity index 100% rename from src/laybasic/unit_tests/layNetlistBrowserModelTests.cc rename to src/layui/unit_tests/layNetlistBrowserModelTests.cc diff --git a/src/laybasic/unit_tests/layNetlistBrowserTreeModelTests.cc b/src/layui/unit_tests/layNetlistBrowserTreeModelTests.cc similarity index 100% rename from src/laybasic/unit_tests/layNetlistBrowserTreeModelTests.cc rename to src/layui/unit_tests/layNetlistBrowserTreeModelTests.cc diff --git a/src/layui/unit_tests/unit_tests.pro b/src/layui/unit_tests/unit_tests.pro new file mode 100644 index 000000000..d9772a389 --- /dev/null +++ b/src/layui/unit_tests/unit_tests.pro @@ -0,0 +1,26 @@ + +DESTDIR_UT = $$OUT_PWD/../.. +DESTDIR = $$OUT_PWD/.. + +TARGET = layui_tests + +include($$PWD/../../lib_ut.pri) + +SOURCES = \ + layAbstractMenuTests.cc \ + +SOURCES = \ + +!equals(HAVE_QT, "0") { + + SOURCES += \ + layNetlistBrowserModelTests.cc \ + layNetlistBrowserTreeModelTests.cc \ + +} + +INCLUDEPATH += $$LAYUI_INC $$LAYBASIC_INC $$TL_INC $$UI_INC $$DB_INC $$RDB_INC $$GSI_INC $$OUT_PWD/../ui +DEPENDPATH += $$LAYUI_INC $$LAYBASIC_INC $$TL_INC $$UI_INC $$DB_INC $$RDB_INC $$GSI_INC $$OUT_PWD/../ui + +LIBS += -L$$DESTDIR_UT -lklayout_laybasic -lklayout_layui -lklayout_db -lklayout_tl -lklayout_gsi + diff --git a/src/layview/layview.pro b/src/layview/layview.pro new file mode 100644 index 000000000..7a08952e9 --- /dev/null +++ b/src/layview/layview.pro @@ -0,0 +1,6 @@ + +TEMPLATE = subdirs +SUBDIRS = layview unit_tests + +unit_tests.depends += layview + diff --git a/src/layview/layview/gsiDeclLayLayoutView_noqt.cc b/src/layview/layview/gsiDeclLayLayoutView_noqt.cc new file mode 100644 index 000000000..528636548 --- /dev/null +++ b/src/layview/layview/gsiDeclLayLayoutView_noqt.cc @@ -0,0 +1,84 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 "layLayoutView.h" + +namespace gsi +{ + +static lay::LayoutView *new_view2 (bool editable, db::Manager *manager, unsigned int options) +{ + return new lay::LayoutView (manager, editable, 0 /*plugin parent*/, options); +} + +extern Class decl_LayoutViewBase; + +Class decl_LayoutView (decl_LayoutViewBase, "lay", "LayoutView", + gsi::constructor ("new", &new_view2, gsi::arg ("editable", false), gsi::arg ("manager", (db::Manager *) 0, "nil"), gsi::arg ("options", (unsigned int) 0), + "@brief Creates a standalone view\n" + "\n" + "This constructor is for special purposes only. To create a view in the context of a main window, " + "use \\MainWindow#create_view and related methods.\n" + "\n" + "@param editable True to make the view editable\n" + "@param manager The \\Manager object to enable undo/redo\n" + "@param options A combination of the values in the LV_... constants\n" + "\n" + "This constructor has been introduced in version 0.25.\n" + "It has been enhanced with the arguments in version 0.27.\n" + ), + "@brief The view object presenting one or more layout objects\n" + "\n" + "The visual part of the view is the tab panel in the main window. The non-visual part " + "are the redraw thread, the layout handles, cell lists, layer view lists etc. " + "This object controls these aspects of the view and controls the appearance of the data. " +); + +static lay::LayoutView *get_view (lay::CellViewRef *cv) +{ + return cv->view ()->ui (); +} + +static ClassExt extdecl_CellView ( + method_ext ("view", &get_view, + "@brief Gets the view the cellview resides in\n" + "This reference will be nil if the cellview is not a valid one.\n" + "This method has been added in version 0.25.\n" + ) +); + +static lay::LayoutView *get_view_from_lp (lay::LayerPropertiesNode *node) +{ + return node->view ()->ui (); +} + +static ClassExt extdecl_LayerPropertiesNode ( + method_ext ("view", &get_view_from_lp, + "@brief Gets the view this node lives in\n" + "\n" + "This reference can be nil if the node is a orphan node that lives outside a view." + ) +); + +} + diff --git a/src/layview/layview/gsiDeclLayLayoutView_qt.cc b/src/layview/layview/gsiDeclLayLayoutView_qt.cc new file mode 100644 index 000000000..7ea2ef2e2 --- /dev/null +++ b/src/layview/layview/gsiDeclLayLayoutView_qt.cc @@ -0,0 +1,223 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 "gsiSignals.h" +#include "gsiEnums.h" +#include "rdb.h" +#include "layLayoutView.h" +#include "layLayerProperties.h" +#include "layDitherPattern.h" +#include "layLineStyles.h" +#include "dbSaveLayoutOptions.h" +#include "dbLayoutToNetlist.h" +#include "dbLayoutVsSchematic.h" +#include "tlStream.h" + +namespace gsi +{ + +#if defined(HAVE_QTBINDINGS) +static lay::LayoutView *new_view (QWidget *parent, bool editable, db::Manager *manager, unsigned int options) +{ + lay::LayoutView *lv = new lay::LayoutView (manager, editable, 0 /*plugin parent*/, parent, "view", options); + if (parent) { + // transfer ownership to the parent + lv->keep (); + } + return lv; +} +#endif + +static lay::LayoutView *new_view2 (bool editable, db::Manager *manager, unsigned int options) +{ + return new lay::LayoutView (manager, editable, 0 /*plugin parent*/, 0 /*parent*/, "view", options); +} + +extern Class decl_LayoutViewBase; + +Class decl_LayoutView (decl_LayoutViewBase, "lay", "LayoutView", +#if defined(HAVE_QTBINDINGS) + gsi::constructor ("new", &new_view, gsi::arg ("parent"), gsi::arg ("editable", false), gsi::arg ("manager", (db::Manager *) 0, "nil"), gsi::arg ("options", (unsigned int) 0), + "@brief Creates a standalone view\n" + "\n" + "This constructor is for special purposes only. To create a view in the context of a main window, " + "use \\MainWindow#create_view and related methods.\n" + "\n" + "@param parent The parent widget in which to embed the view\n" + "@param editable True to make the view editable\n" + "@param manager The \\Manager object to enable undo/redo\n" + "@param options A combination of the values in the LV_... constants\n" + "\n" + "This constructor has been introduced in version 0.25.\n" + "It has been enhanced with the arguments in version 0.27.\n" + ) + +#endif + gsi::constructor ("new", &new_view2, gsi::arg ("editable", false), gsi::arg ("manager", (db::Manager *) 0, "nil"), gsi::arg ("options", (unsigned int) 0), + "@brief Creates a standalone view\n" + "\n" + "This constructor is for special purposes only. To create a view in the context of a main window, " + "use \\MainWindow#create_view and related methods.\n" + "\n" + "@param editable True to make the view editable\n" + "@param manager The \\Manager object to enable undo/redo\n" + "@param options A combination of the values in the LV_... constants\n" + "\n" + "This constructor has been introduced in version 0.25.\n" + "It has been enhanced with the arguments in version 0.27.\n" + ) + +#if defined(HAVE_QTBINDINGS) + gsi::method ("layer_control_frame", static_cast (&lay::LayoutView::layer_control_frame), + "@brief Gets the layer control side widget\n" + "A 'side widget' is a widget attached to the view. It does not have a parent, so you can " + "embed it into a different context. Please note that with embedding through 'setParent' it will be " + "destroyed when your parent widget gets destroyed. It will be lost then to the view.\n" + "\n" + "The side widget can be configured through the views configuration interface.\n" + "\n" + "This method has been introduced in version 0.27\n" + ) + + gsi::method ("hierarchy_control_frame", static_cast (&lay::LayoutView::hierarchy_control_frame), + "@brief Gets the cell view (hierarchy view) side widget\n" + "For details about side widgets see \\layer_control_frame.\n" + "\n" + "This method has been introduced in version 0.27\n" + ) + + gsi::method ("libraries_frame", static_cast (&lay::LayoutView::libraries_frame), + "@brief Gets the library view side widget\n" + "For details about side widgets see \\layer_control_frame.\n" + "\n" + "This method has been introduced in version 0.27\n" + ) + + gsi::method ("bookmarks_frame", static_cast (&lay::LayoutView::bookmarks_frame), + "@brief Gets the bookmarks side widget\n" + "For details about side widgets see \\layer_control_frame.\n" + "\n" + "This method has been introduced in version 0.27\n" + ) + +#endif + gsi::method ("current", &lay::LayoutView::current, + "@brief Returns the current view\n" + "The current view is the one that is shown in the current tab. Returns nil if no layout is loaded.\n" + "\n" + "This method has been introduced in version 0.23.\n" + ) + + gsi::method ("bookmark_view", static_cast (&lay::LayoutView::bookmark_view), gsi::arg ("name"), + "@brief Bookmarks the current view under the given name\n" + "\n" + "@param name The name under which to bookmark the current state" + ) + + gsi::event ("on_close", static_cast (&lay::LayoutView::close_event), + "@brief A event indicating that the view is about to close\n" + "\n" + "This event is triggered when the view is going to be closed entirely.\n" + "\n" + "It has been added in version 0.25." + ) + + gsi::event ("on_show", static_cast (&lay::LayoutView::show_event), + "@brief A event indicating that the view is going to become visible\n" + "\n" + "It has been added in version 0.25." + ) + + gsi::event ("on_hide", static_cast (&lay::LayoutView::hide_event), + "@brief A event indicating that the view is going to become invisible\n" + "\n" + "It has been added in version 0.25." + ) + + gsi::method ("show_rdb", static_cast (&lay::LayoutView::open_rdb_browser), gsi::arg ("rdb_index"), gsi::arg ("cv_index"), + "@brief Shows a report database in the marker browser on a certain layout\n" + "The marker browser is opened showing the report database with the index given by \"rdb_index\".\n" + "It will be attached (i.e. navigate to) the layout with the given cellview index in \"cv_index\".\n" + ) + + gsi::method ("show_l2ndb", static_cast (&lay::LayoutView::open_l2ndb_browser), gsi::arg ("l2ndb_index"), gsi::arg ("cv_index"), + "@brief Shows a netlist database in the marker browser on a certain layout\n" + "The netlist browser is opened showing the netlist database with the index given by \"l2ndb_index\".\n" + "It will be attached (i.e. navigate to) the layout with the given cellview index in \"cv_index\".\n" + "\n" + "This method has been added in version 0.26." + ) + + gsi::method ("show_lvsdb", static_cast (&lay::LayoutView::open_l2ndb_browser), gsi::arg ("lvsdb_index"), gsi::arg ("cv_index"), + "@brief Shows a netlist database in the marker browser on a certain layout\n" + "The netlist browser is opened showing the netlist database with the index given by \"lvsdb_index\".\n" + "It will be attached (i.e. navigate to) the layout with the given cellview index in \"cv_index\".\n" + "\n" + "This method has been added in version 0.26." + ), + "@brief The view object presenting one or more layout objects\n" + "\n" + "The visual part of the view is the tab panel in the main window. The non-visual part " + "are the redraw thread, the layout handles, cell lists, layer view lists etc. " + "This object controls these aspects of the view and controls the appearance of the data. " +); + +static lay::CellViewRef get_active_cellview_ref () +{ + lay::LayoutView *view = lay::LayoutView::current (); + if (! view) { + return lay::CellViewRef (); + } + if (view->active_cellview_index () >= 0) { + return view->active_cellview_ref (); + } else { + return lay::CellViewRef (); + } +} + +static lay::LayoutView *get_view (lay::CellViewRef *cv) +{ + return cv->view ()->ui (); +} + +static ClassExt extdecl_CellView ( + method ("active", &get_active_cellview_ref, + "@brief Gets the active CellView\n" + "The active CellView is the one that is selected in the current layout view. This method is " + "equivalent to\n" + "@code\n" + "RBA::LayoutView::current.active_cellview\n" + "@/code\n" + "If no CellView is active, this method returns nil.\n" + "\n" + "This method has been introduced in version 0.23." + ) + + method_ext ("view", &get_view, + "@brief Gets the view the cellview resides in\n" + "This reference will be nil if the cellview is not a valid one.\n" + "This method has been added in version 0.25.\n" + ) +); + +static lay::LayoutView *get_view_from_lp (lay::LayerPropertiesNode *node) +{ + return node->view ()->ui (); +} + +static ClassExt extdecl_LayerPropertiesNode ( + method_ext ("view", &get_view_from_lp, + "@brief Gets the view this node lives in\n" + "\n" + "This reference can be nil if the node is a orphan node that lives outside a view." + ) +); + +} diff --git a/src/layview/layview/layLayoutView.h b/src/layview/layview/layLayoutView.h new file mode 100644 index 000000000..16d5cc9cf --- /dev/null +++ b/src/layview/layview/layLayoutView.h @@ -0,0 +1,33 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 + +*/ + + +#ifndef HDR_layLayoutView +#define HDR_layLayoutView + +#if defined(HAVE_QT) +# include "layLayoutView_qt.h" +#else +# include "layLayoutView_noqt.h" +#endif + +#endif diff --git a/src/layview/layview/layLayoutView_noqt.cc b/src/layview/layview/layLayoutView_noqt.cc new file mode 100644 index 000000000..20c612067 --- /dev/null +++ b/src/layview/layview/layLayoutView_noqt.cc @@ -0,0 +1,60 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 "layLayoutView.h" + +namespace lay +{ + +LayoutView::LayoutView (db::Manager *mgr, bool editable, lay::Plugin *plugin_parent, unsigned int options) + : LayoutViewBase (this, mgr, editable, plugin_parent, options) +{ + config_setup (); +} + +LayoutView::LayoutView (lay::LayoutView *source, db::Manager *mgr, bool editable, lay::Plugin *plugin_parent, unsigned int options) + : LayoutViewBase (this, source, mgr, editable, plugin_parent, options) +{ + config_setup (); +} + +// NOTE: this methods needs to be called "frequently" +void +LayoutView::timer () +{ + LayoutViewBase::timer (); + + // Without Qt, this is also the opportunity to execute deferred methods + tl::DeferredMethodScheduler::execute (); + + // We also issue the "image_updated" event if the image ("screenshot") has been updated + if (canvas ()->image_updated ()) { + image_updated_event (); + } + + // And also the drawing_finished event + if (canvas ()->drawing_finished ()) { + drawing_finished_event (); + } +} + +} // namespace lay diff --git a/src/layview/layview/layLayoutView_noqt.h b/src/layview/layview/layLayoutView_noqt.h new file mode 100644 index 000000000..9c1d16c52 --- /dev/null +++ b/src/layview/layview/layLayoutView_noqt.h @@ -0,0 +1,80 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 + +*/ + + +#ifndef HDR_layLayoutViewNoQt +#define HDR_layLayoutViewNoQt + +#include "layviewCommon.h" +#include "layLayoutViewBase.h" + +namespace lay +{ + +/** + * @brief The layout view object + * + * The layout view is responsible for displaying one or a set of layouts. + * It manages the layer display list and many other components. + */ +class LAYVIEW_PUBLIC LayoutView + : public LayoutViewBase +{ +public: + /** + * @brief Constructor + */ + LayoutView (db::Manager *mgr, bool editable, lay::Plugin *plugin_parent, unsigned int options = (unsigned int) LV_Normal); + + /** + * @brief Constructor (clone from another view) + */ + LayoutView (lay::LayoutView *source, db::Manager *mgr, bool editable, lay::Plugin *plugin_parent, unsigned int options = (unsigned int) LV_Normal); + + /** + * @brief This event is triggered in the "timer" callback when the image ("screenshot") was updated. + */ + tl::Event image_updated_event; + + /** + * @brief This event is triggered in the "timer" callback when the drawing thread has finished. + */ + tl::Event drawing_finished_event; + + /** + * @brief A callback that needs to be called "frequently" + */ + void timer (); + +protected: + /** + * @brief Gets the LayoutView interface + */ + virtual LayoutView *get_ui () { return this; } + +private: + using LayoutViewBase::ui; +}; + +} + +#endif diff --git a/src/laybasic/laybasic/layLayoutView.cc b/src/layview/layview/layLayoutView_qt.cc similarity index 95% rename from src/laybasic/laybasic/layLayoutView.cc rename to src/layview/layview/layLayoutView_qt.cc index 3101d5c65..82fbe3c3e 100644 --- a/src/laybasic/laybasic/layLayoutView.cc +++ b/src/layview/layview/layLayoutView_qt.cc @@ -20,8 +20,6 @@ */ -#if defined(HAVE_QT) - #include #include #include @@ -709,7 +707,7 @@ LayoutView::layer_model_updated () void LayoutView::bookmark_current_view () { - QString proposed_name = tl::to_qstring (m_bookmarks.propose_new_bookmark_name ()); + QString proposed_name = tl::to_qstring (bookmarks ().propose_new_bookmark_name ()); while (true) { bool ok = false; @@ -740,24 +738,14 @@ LayoutView::manage_bookmarks () } } -void -LayoutView::bookmarks (const BookmarkList &b) +void +LayoutView::bookmarks_changed () { - m_bookmarks = b; mp_bookmarks_view->refresh (); emit menu_needs_update (); } void -LayoutView::bookmark_view (const std::string &name) -{ - DisplayState state (box (), get_min_hier_levels (), get_max_hier_levels (), cellview_list ()); - m_bookmarks.add (name, state); - mp_bookmarks_view->refresh (); - emit menu_needs_update (); -} - -void LayoutView::layer_tab_changed () { update_content (); @@ -1129,46 +1117,3 @@ LayoutView::sizeHint () const } } // namespace lay - -#else // defined(HAVE_QT) - -#include "layLayoutView.h" - -namespace lay -{ - -LayoutView::LayoutView (db::Manager *mgr, bool editable, lay::Plugin *plugin_parent, unsigned int options) - : LayoutViewBase (this, mgr, editable, plugin_parent, options) -{ - config_setup (); -} - -LayoutView::LayoutView (lay::LayoutView *source, db::Manager *mgr, bool editable, lay::Plugin *plugin_parent, unsigned int options) - : LayoutViewBase (this, source, mgr, editable, plugin_parent, options) -{ - config_setup (); -} - -// NOTE: this methods needs to be called "frequently" -void -LayoutView::timer () -{ - LayoutViewBase::timer (); - - // Without Qt, this is also the opportunity to execute deferred methods - tl::DeferredMethodScheduler::execute (); - - // We also issue the "image_updated" event if the image ("screenshot") has been updated - if (canvas ()->image_updated ()) { - image_updated_event (); - } - - // And also the drawing_finished event - if (canvas ()->drawing_finished ()) { - drawing_finished_event (); - } -} - -} // namespace lay - -#endif diff --git a/src/laybasic/laybasic/layLayoutView.h b/src/layview/layview/layLayoutView_qt.h similarity index 89% rename from src/laybasic/laybasic/layLayoutView.h rename to src/layview/layview/layLayoutView_qt.h index 0ce115255..6d87a57ad 100644 --- a/src/laybasic/laybasic/layLayoutView.h +++ b/src/layview/layview/layLayoutView_qt.h @@ -21,22 +21,10 @@ */ -#ifndef HDR_layLayoutView -#define HDR_layLayoutView +#ifndef HDR_layLayoutViewQt +#define HDR_layLayoutViewQt -#include "laybasicCommon.h" - -#if defined(HAVE_QT) - -#include -#include -#include -#include -#include -#include - -#include -#include +#include "layviewCommon.h" #include "layLayoutViewBase.h" #include "layLayerProperties.h" @@ -59,6 +47,16 @@ #include "tlEvents.h" #include "dbInstElement.h" +#include +#include +#include +#include +#include +#include + +#include +#include + class QSpinBox; namespace rdb { @@ -95,7 +93,7 @@ class EditorOptionsPages; * It is composed of a canvas and controls to control the appearance. * It manages the layer display list, bookmark list etc. */ -class LAYBASIC_PUBLIC LayoutView +class LAYVIEW_PUBLIC LayoutView : public QFrame, public LayoutViewBase { @@ -143,7 +141,7 @@ public: virtual bool has_selection (); /** - * @brief Display a status message + * @brief Displays a status message */ void message (const std::string &s = "", int timeout = 10); @@ -314,11 +312,6 @@ public: */ virtual void current_pos (double x, double y); - /** - * @brief Bookmark the current view under the given name - */ - void bookmark_view (const std::string &name); - /** * @brief Asks for a bookmark name and bookmark the current view under this name */ @@ -329,28 +322,15 @@ public: */ void manage_bookmarks (); - /** - * @brief Obtain the bookmarks list - */ - const BookmarkList &bookmarks () const - { - return m_bookmarks; - } - - /** - * @brief Set the bookmarks list - */ - void bookmarks (const BookmarkList &b); - /** * @brief Open the RDB browser for a given database and associated cv index */ - void open_rdb_browser (int rdb_index, int cv_index); + virtual void open_rdb_browser (int rdb_index, int cv_index); /** * @brief Open the L2NDB browser for a given database and associated cv index */ - void open_l2ndb_browser (int l2ndb_index, int cv_index); + virtual void open_l2ndb_browser (int l2ndb_index, int cv_index); /** * @brief Gets the editor options pages @@ -368,7 +348,7 @@ public: /** * @brief Gets the layer control panel */ - lay::LayerControlPanel *control_panel () + virtual lay::LayerControlPanel *control_panel () { return mp_control_panel; } @@ -384,7 +364,7 @@ public: /** * @brief Gets the hierarchy panel */ - lay::HierarchyControlPanel *hierarchy_panel () + virtual lay::HierarchyControlPanel *hierarchy_panel () { return mp_hierarchy_panel; } @@ -719,7 +699,6 @@ private: lay::EditorOptionsFrame *mp_editor_options_frame; QSpinBox *mp_min_hier_spbx; QSpinBox *mp_max_hier_spbx; - BookmarkList m_bookmarks; bool m_always_show_source; bool m_always_show_ld; bool m_always_show_layout_index; @@ -752,6 +731,7 @@ protected: virtual bool set_hier_levels_basic (std::pair l); virtual void do_change_active_cellview (); virtual bool is_activated () const; + virtual void bookmarks_changed (); // overrides Editables method to display a message void signal_selection_changed (); @@ -767,60 +747,4 @@ private: } -#else // defined(HAVE_QT) - -#include "layLayoutViewBase.h" - -namespace lay -{ - -/** - * @brief The layout view object - * - * The layout view is responsible for displaying one or a set of layouts. - * It manages the layer display list and many other components. - */ -class LAYBASIC_PUBLIC LayoutView - : public LayoutViewBase -{ -public: - /** - * @brief Constructor - */ - LayoutView (db::Manager *mgr, bool editable, lay::Plugin *plugin_parent, unsigned int options = (unsigned int) LV_Normal); - - /** - * @brief Constructor (clone from another view) - */ - LayoutView (lay::LayoutView *source, db::Manager *mgr, bool editable, lay::Plugin *plugin_parent, unsigned int options = (unsigned int) LV_Normal); - - /** - * @brief This event is triggered in the "timer" callback when the image ("screenshot") was updated. - */ - tl::Event image_updated_event; - - /** - * @brief This event is triggered in the "timer" callback when the drawing thread has finished. - */ - tl::Event drawing_finished_event; - - /** - * @brief A callback that needs to be called "frequently" - */ - void timer (); - -protected: - /** - * @brief Gets the LayoutView interface - */ - virtual LayoutView *get_ui () { return this; } - -private: - using LayoutViewBase::ui; -}; - -} - -#endif - #endif diff --git a/src/layview/layview/layview.pro b/src/layview/layview/layview.pro new file mode 100644 index 000000000..097295239 --- /dev/null +++ b/src/layview/layview/layview.pro @@ -0,0 +1,55 @@ + +DESTDIR = $$OUT_PWD/../.. +TARGET = klayout_ui + +include($$PWD/../../lib.pri) + +DEFINES += MAKE_UI_LIBRARY + +FORMS = \ + +RESOURCES = \ + +SOURCES = \ + +HEADERS = \ + layLayoutView.h + +!equals(HAVE_QT, "0") { + + SOURCES += \ + layLayoutView_qt.cc \ + gsiDeclLayLayoutView_qt.cc \ + + HEADERS += \ + layLayoutView_qt.h \ + +} else { + + SOURCES += \ + layLayoutView_noqt.cc \ + gsiDeclLayLayoutView_noqt.cc \ + + HEADERS += \ + layLayoutView_noqt.h \ + +} + +INCLUDEPATH += $$LAYBASIC_INC $$TL_INC $$GSI_INC $$DB_INC $$RDB_INC +DEPENDPATH += $$LAYBASIC_INC $$TL_INC $$GSI_INC $$DB_INC $$RDB_INC +LIBS += -L$$DESTDIR -lklayout_laybasic -lklayout_tl -lklayout_gsi -lklayout_db -lklayout_rdb + +!equals(HAVE_QT, "0") { + + INCLUDEPATH += $$QTBASIC_INC $$LAYUI_INC + DEPENDPATH += $$QTBASIC_INC $$LAYUI_INC + LIBS += -lklayout_layui + + equals(HAVE_QTBINDINGS, "1") { + LIBS += -lklayout_qtbasic -lklayout_QtGui -lklayout_QtCore + greaterThan(QT_MAJOR_VERSION, 4) { + LIBS += -lklayout_QtWidgets + } + } + +} diff --git a/src/layview/layview/layviewCommon.h b/src/layview/layview/layviewCommon.h new file mode 100644 index 000000000..dced42bd8 --- /dev/null +++ b/src/layview/layview/layviewCommon.h @@ -0,0 +1,51 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 + +*/ + + +#if !defined(HDR_layviewCommon_h) +# define HDR_layviewCommon_h + +# if defined _WIN32 || defined __CYGWIN__ + +# ifdef MAKE_LAYVIEW_LIBRARY +# define LAYVIEW_PUBLIC __declspec(dllexport) +# else +# define LAYVIEW_PUBLIC __declspec(dllimport) +# endif +# define LAYVIEW_LOCAL +# define LAYVIEW_PUBLIC_TEMPLATE + +# else + +# if __GNUC__ >= 4 || defined(__clang__) +# define LAYVIEW_PUBLIC __attribute__ ((visibility ("default"))) +# define LAYVIEW_PUBLIC_TEMPLATE __attribute__ ((visibility ("default"))) +# define LAYVIEW_LOCAL __attribute__ ((visibility ("hidden"))) +# else +# define LAYVIEW_PUBLIC +# define LAYVIEW_PUBLIC_TEMPLATE +# define LAYVIEW_LOCAL +# endif + +# endif + +#endif diff --git a/src/laybasic/unit_tests/layLayoutViewTests.cc b/src/layview/unit_tests/layLayoutViewTests.cc similarity index 100% rename from src/laybasic/unit_tests/layLayoutViewTests.cc rename to src/layview/unit_tests/layLayoutViewTests.cc diff --git a/src/layview/unit_tests/unit_tests.pro b/src/layview/unit_tests/unit_tests.pro new file mode 100644 index 000000000..52017fc45 --- /dev/null +++ b/src/layview/unit_tests/unit_tests.pro @@ -0,0 +1,16 @@ + +DESTDIR_UT = $$OUT_PWD/../.. +DESTDIR = $$OUT_PWD/.. + +TARGET = layview_tests + +include($$PWD/../../lib_ut.pri) + +SOURCES = \ + layLayoutViewTests.cc \ + +INCLUDEPATH += $$TL_INC $$LAYBASIC_INC $$LAYVIEW_INC $$LAYUI_INC $$DB_INC $$RDB_INC $$GSI_INC $$OUT_PWD/../layview +DEPENDPATH += $$TL_INC $$LAYBASIC_INC $$LAYVIEW_INC $$LAYUI_INC $$DB_INC $$RDB_INC $$GSI_INC $$OUT_PWD/../layview + +LIBS += -L$$DESTDIR_UT -lklayout_layview -lklayout_db -lklayout_tl -lklayout_gsi + diff --git a/src/plugins/tools/bool/lay_plugin/layBooleanOperationsPlugin.cc b/src/plugins/tools/bool/lay_plugin/layBooleanOperationsPlugin.cc index 668f159e6..7202d66e1 100644 --- a/src/plugins/tools/bool/lay_plugin/layBooleanOperationsPlugin.cc +++ b/src/plugins/tools/bool/lay_plugin/layBooleanOperationsPlugin.cc @@ -494,7 +494,7 @@ public: // .. nothing yet .. } - lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutView *view) const + lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutViewBase *view) const { return new BooleanOperationsPlugin (root, view); } diff --git a/src/plugins/tools/diff/lay_plugin/layDiffPlugin.cc b/src/plugins/tools/diff/lay_plugin/layDiffPlugin.cc index 986dbbf04..cde5bed10 100644 --- a/src/plugins/tools/diff/lay_plugin/layDiffPlugin.cc +++ b/src/plugins/tools/diff/lay_plugin/layDiffPlugin.cc @@ -103,7 +103,7 @@ public: // .. nothing yet .. } - lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutView *view) const + lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutViewBase *view) const { return new DiffPlugin (root, view); } diff --git a/src/plugins/tools/net_tracer/lay_plugin/layNetTracerPlugin.cc b/src/plugins/tools/net_tracer/lay_plugin/layNetTracerPlugin.cc index 45b5cd290..619d12e53 100644 --- a/src/plugins/tools/net_tracer/lay_plugin/layNetTracerPlugin.cc +++ b/src/plugins/tools/net_tracer/lay_plugin/layNetTracerPlugin.cc @@ -76,7 +76,7 @@ public: menu_entries.push_back (lay::menu_item ("lay::edit_layer_stack", "edit_layer_stack", "tools_menu.end", tl::to_string (QObject::tr ("Edit Layer Stack")))); } - virtual lay::Plugin *create_plugin (db::Manager * /*manager*/, lay::Dispatcher *root, lay::LayoutView *view) const + virtual lay::Plugin *create_plugin (db::Manager * /*manager*/, lay::Dispatcher *root, lay::LayoutViewBase *view) const { return new NetTracerDialog (root, view); } diff --git a/src/plugins/tools/view_25d/lay_plugin/layD25Plugin.cc b/src/plugins/tools/view_25d/lay_plugin/layD25Plugin.cc index c6830127c..4bb1601c8 100644 --- a/src/plugins/tools/view_25d/lay_plugin/layD25Plugin.cc +++ b/src/plugins/tools/view_25d/lay_plugin/layD25Plugin.cc @@ -67,7 +67,7 @@ public: // .. nothing yet .. } - lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutView *view) const + lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutViewBase *view) const { return new D25View (root, view); } diff --git a/src/plugins/tools/xor/lay_plugin/layXORPlugin.cc b/src/plugins/tools/xor/lay_plugin/layXORPlugin.cc index 9e0416339..0a3f60b65 100644 --- a/src/plugins/tools/xor/lay_plugin/layXORPlugin.cc +++ b/src/plugins/tools/xor/lay_plugin/layXORPlugin.cc @@ -111,7 +111,7 @@ public: // .. nothing yet .. } - lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutView *view) const + lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutViewBase *view) const { return new XORPlugin (root, view); } From 5fed1648e63c5fe43d936f3b08aac88083e62ce0 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 15 May 2022 00:54:15 +0200 Subject: [PATCH 64/88] WIP --- src/layui/layui/rdbMarkerBrowser.cc | 61 +++++++++++++------------ src/layui/layui/rdbMarkerBrowser.h | 20 +++++--- src/layview/layview/layLayoutView_qt.cc | 2 + src/layview/layview/layview.pro | 4 +- 4 files changed, 51 insertions(+), 36 deletions(-) diff --git a/src/layui/layui/rdbMarkerBrowser.cc b/src/layui/layui/rdbMarkerBrowser.cc index 06b2df327..4b7e3ec2f 100644 --- a/src/layui/layui/rdbMarkerBrowser.cc +++ b/src/layui/layui/rdbMarkerBrowser.cc @@ -28,6 +28,9 @@ #include "layConverters.h" #include "layDispatcher.h" +#include "ui_MarkerBrowserConfigPage.h" +#include "ui_MarkerBrowserConfigPage2.h" + #include namespace rdb @@ -128,9 +131,10 @@ MarkerBrowserWindowModeConverter::to_string (rdb::window_type mode) MarkerBrowserConfigPage::MarkerBrowserConfigPage (QWidget *parent) : lay::ConfigPage (parent) { - Ui::MarkerBrowserConfigPage::setupUi (this); + mp_ui = new Ui::MarkerBrowserConfigPage (); + mp_ui->setupUi (this); - connect (cbx_window, SIGNAL (currentIndexChanged (int)), this, SLOT (window_changed (int))); + connect (mp_ui->cbx_window, SIGNAL (currentIndexChanged (int)), this, SLOT (window_changed (int))); } void @@ -139,22 +143,22 @@ MarkerBrowserConfigPage::setup (lay::Dispatcher *root) // context mode rdb::context_mode_type cmode = rdb::DatabaseTop; root->config_get (cfg_rdb_context_mode, cmode, MarkerBrowserContextModeConverter ()); - cbx_context->setCurrentIndex (int (cmode)); + mp_ui->cbx_context->setCurrentIndex (int (cmode)); // window mode rdb::window_type wmode = rdb::FitMarker; root->config_get (cfg_rdb_window_mode, wmode, MarkerBrowserWindowModeConverter ()); - cbx_window->setCurrentIndex (int (wmode)); + mp_ui->cbx_window->setCurrentIndex (int (wmode)); // window dimension double wdim = 1.0; root->config_get (cfg_rdb_window_dim, wdim); - le_window->setText (tl::to_qstring (tl::to_string (wdim))); + mp_ui->le_window->setText (tl::to_qstring (tl::to_string (wdim))); // max. marker count unsigned int max_marker_count = 1000; root->config_get (cfg_rdb_max_marker_count, max_marker_count); - le_max_markers->setText (tl::to_qstring (tl::to_string (max_marker_count))); + mp_ui->le_max_markers->setText (tl::to_qstring (tl::to_string (max_marker_count))); // enable controls window_changed (int (wmode)); @@ -163,20 +167,20 @@ MarkerBrowserConfigPage::setup (lay::Dispatcher *root) void MarkerBrowserConfigPage::window_changed (int m) { - le_window->setEnabled (m == int (rdb::FitMarker) || m == int (rdb::CenterSize)); + mp_ui->le_window->setEnabled (m == int (rdb::FitMarker) || m == int (rdb::CenterSize)); } void MarkerBrowserConfigPage::commit (lay::Dispatcher *root) { double dim = 1.0; - tl::from_string_ext (tl::to_string (le_window->text ()), dim); + tl::from_string_ext (tl::to_string (mp_ui->le_window->text ()), dim); unsigned int max_markers_count = 1000; - tl::from_string_ext (tl::to_string (le_max_markers->text ()), max_markers_count); + tl::from_string_ext (tl::to_string (mp_ui->le_max_markers->text ()), max_markers_count); - root->config_set (cfg_rdb_context_mode, rdb::context_mode_type (cbx_context->currentIndex ()), MarkerBrowserContextModeConverter ()); - root->config_set (cfg_rdb_window_mode, rdb::window_type (cbx_window->currentIndex ()), MarkerBrowserWindowModeConverter ()); + root->config_set (cfg_rdb_context_mode, rdb::context_mode_type (mp_ui->cbx_context->currentIndex ()), MarkerBrowserContextModeConverter ()); + root->config_set (cfg_rdb_window_mode, rdb::window_type (mp_ui->cbx_window->currentIndex ()), MarkerBrowserWindowModeConverter ()); root->config_set (cfg_rdb_window_dim, dim); root->config_set (cfg_rdb_max_marker_count, max_markers_count); } @@ -187,7 +191,8 @@ MarkerBrowserConfigPage::commit (lay::Dispatcher *root) MarkerBrowserConfigPage2::MarkerBrowserConfigPage2 (QWidget *parent) : lay::ConfigPage (parent) { - Ui::MarkerBrowserConfigPage2::setupUi (this); + mp_ui = new Ui::MarkerBrowserConfigPage2 (); + mp_ui->setupUi (this); } void @@ -196,70 +201,70 @@ MarkerBrowserConfigPage2::setup (lay::Dispatcher *root) // marker color QColor color; root->config_get (cfg_rdb_marker_color, color, lay::ColorConverter ()); - color_pb->set_color (color); + mp_ui->color_pb->set_color (color); // marker line width int lw = 0; root->config_get (cfg_rdb_marker_line_width, lw); if (lw < 0) { - lw_le->setText (QString ()); + mp_ui->lw_le->setText (QString ()); } else { - lw_le->setText (tl::to_qstring (tl::to_string (lw))); + mp_ui->lw_le->setText (tl::to_qstring (tl::to_string (lw))); } // marker vertex size int vs = 0; root->config_get (cfg_rdb_marker_vertex_size, vs); if (vs < 0) { - vs_le->setText (QString ()); + mp_ui->vs_le->setText (QString ()); } else { - vs_le->setText (tl::to_qstring (tl::to_string (vs))); + mp_ui->vs_le->setText (tl::to_qstring (tl::to_string (vs))); } // stipple pattern int dp = 0; root->config_get (cfg_rdb_marker_dither_pattern, dp); - stipple_pb->set_dither_pattern (dp); + mp_ui->stipple_pb->set_dither_pattern (dp); // halo int halo = 0; root->config_get (cfg_rdb_marker_halo, halo); - halo_cb->setCheckState (halo < 0 ? Qt::PartiallyChecked : (halo ? Qt::Checked : Qt::Unchecked)); + mp_ui->halo_cb->setCheckState (halo < 0 ? Qt::PartiallyChecked : (halo ? Qt::Checked : Qt::Unchecked)); } void MarkerBrowserConfigPage2::commit (lay::Dispatcher *root) { - QColor color (color_pb->get_color ()); + QColor color (mp_ui->color_pb->get_color ()); root->config_set (cfg_rdb_marker_color, color, lay::ColorConverter ()); - if (lw_le->text ().isEmpty ()) { + if (mp_ui->lw_le->text ().isEmpty ()) { root->config_set (cfg_rdb_marker_line_width, -1); } else { try { int s; - tl::from_string_ext (tl::to_string (lw_le->text ()), s); + tl::from_string_ext (tl::to_string (mp_ui->lw_le->text ()), s); root->config_set (cfg_rdb_marker_line_width, s); } catch (...) { } } - if (vs_le->text ().isEmpty ()) { + if (mp_ui->vs_le->text ().isEmpty ()) { root->config_set (cfg_rdb_marker_vertex_size, -1); } else { try { int s; - tl::from_string_ext (tl::to_string (vs_le->text ()), s); + tl::from_string_ext (tl::to_string (mp_ui->vs_le->text ()), s); root->config_set (cfg_rdb_marker_vertex_size, s); } catch (...) { } } - root->config_set (cfg_rdb_marker_dither_pattern, stipple_pb->dither_pattern ()); + root->config_set (cfg_rdb_marker_dither_pattern, mp_ui->stipple_pb->dither_pattern ()); - if (halo_cb->checkState () == Qt::PartiallyChecked) { + if (mp_ui->halo_cb->checkState () == Qt::PartiallyChecked) { root->config_set (cfg_rdb_marker_halo, -1); - } else if (halo_cb->checkState () == Qt::Unchecked) { + } else if (mp_ui->halo_cb->checkState () == Qt::Unchecked) { root->config_set (cfg_rdb_marker_halo, 0); - } else if (halo_cb->checkState () == Qt::Checked) { + } else if (mp_ui->halo_cb->checkState () == Qt::Checked) { root->config_set (cfg_rdb_marker_halo, 1); } } diff --git a/src/layui/layui/rdbMarkerBrowser.h b/src/layui/layui/rdbMarkerBrowser.h index fd39a132e..0c0a21f04 100644 --- a/src/layui/layui/rdbMarkerBrowser.h +++ b/src/layui/layui/rdbMarkerBrowser.h @@ -27,13 +27,17 @@ #include "layPlugin.h" #include "layPluginConfigPage.h" -#include "ui_MarkerBrowserConfigPage.h" -#include "ui_MarkerBrowserConfigPage2.h" #include "dbTrans.h" #include +namespace Ui +{ + class MarkerBrowserConfigPage; + class MarkerBrowserConfigPage2; +} + namespace rdb { @@ -41,8 +45,7 @@ enum context_mode_type { AnyCell = 0 , DatabaseTop, Current, CurrentOrAny, Local enum window_type { DontChange = 0, FitCell, FitMarker, Center, CenterSize }; class MarkerBrowserConfigPage - : public lay::ConfigPage, - private Ui::MarkerBrowserConfigPage + : public lay::ConfigPage { Q_OBJECT @@ -54,11 +57,13 @@ public: public slots: void window_changed (int); + +private: + Ui::MarkerBrowserConfigPage *mp_ui; }; class MarkerBrowserConfigPage2 - : public lay::ConfigPage, - private Ui::MarkerBrowserConfigPage2 + : public lay::ConfigPage { Q_OBJECT @@ -67,6 +72,9 @@ public: virtual void setup (lay::Dispatcher *root); virtual void commit (lay::Dispatcher *root); + +private: + Ui::MarkerBrowserConfigPage2 *mp_ui; }; class MarkerBrowserContextModeConverter diff --git a/src/layview/layview/layLayoutView_qt.cc b/src/layview/layview/layLayoutView_qt.cc index 82fbe3c3e..c9bf40661 100644 --- a/src/layview/layview/layLayoutView_qt.cc +++ b/src/layview/layview/layLayoutView_qt.cc @@ -34,6 +34,8 @@ #include #include #include +#include +#include #include "tlInternational.h" #include "tlExpression.h" diff --git a/src/layview/layview/layview.pro b/src/layview/layview/layview.pro index 097295239..eb6211e0a 100644 --- a/src/layview/layview/layview.pro +++ b/src/layview/layview/layview.pro @@ -1,10 +1,10 @@ DESTDIR = $$OUT_PWD/../.. -TARGET = klayout_ui +TARGET = klayout_layview include($$PWD/../../lib.pri) -DEFINES += MAKE_UI_LIBRARY +DEFINES += MAKE_LAYVIEW_LIBRARY FORMS = \ From 53490a9faf4987e0e6e26fa548eb0d72f2974a77 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 15 May 2022 01:14:29 +0200 Subject: [PATCH 65/88] WIP --- src/edt/edt/edt.pro | 14 +++++++++----- src/edt/edt/edtDialogs.cc | 6 +++--- src/edt/edt/edtDialogs.h | 8 ++++---- src/edt/edt/edtEditorOptionsPages.cc | 2 +- src/edt/edt/edtEditorOptionsPages.h | 12 ++++++------ src/edt/edt/edtInstPropertiesPage.cc | 2 +- src/edt/edt/edtMainService.cc | 4 ++-- src/edt/edt/edtMainService.h | 6 +++--- src/edt/edt/edtPCellParametersPage.cc | 4 ++-- src/edt/edt/edtPCellParametersPage.h | 6 +++--- src/edt/edt/edtPartialService.cc | 4 ++-- src/edt/edt/edtPartialService.h | 6 +++--- src/edt/edt/edtPlugin.cc | 16 ++++++++-------- src/edt/edt/edtPlugin.h | 4 ++-- src/edt/edt/edtPropertiesPages.cc | 2 +- src/edt/edt/edtRecentConfigurationPage.cc | 6 +++--- src/edt/edt/edtRecentConfigurationPage.h | 4 ++-- src/edt/edt/edtService.cc | 6 +++--- src/edt/edt/edtService.h | 8 ++++---- src/edt/edt/edtServiceImpl.cc | 14 +++++++------- src/edt/edt/edtServiceImpl.h | 13 +++++++------ src/edt/edt/edtUtils.cc | 6 +++--- src/edt/edt/edtUtils.h | 6 +++--- src/edt/edt/gsiDeclEdt.cc | 22 +++++++++++----------- 24 files changed, 93 insertions(+), 88 deletions(-) diff --git a/src/edt/edt/edt.pro b/src/edt/edt/edt.pro index 087503794..5a0ce9312 100644 --- a/src/edt/edt/edt.pro +++ b/src/edt/edt/edt.pro @@ -80,10 +80,14 @@ SOURCES += \ INCLUDEPATH += $$TL_INC $$GSI_INC $$LAYBASIC_INC $$DB_INC DEPENDPATH += $$TL_INC $$GSI_INC $$LAYBASIC_INC $$DB_INC -# Note: this accounts for UI-generated headers placed into the output folders in -# shadow builds: -INCLUDEPATH += $$DESTDIR/laybasic/laybasic -DEPENDPATH += $$DESTDIR/laybasic/laybasic - LIBS += -L$$DESTDIR -lklayout_tl -lklayout_gsi -lklayout_laybasic -lklayout_db +!equals(HAVE_QT, "0") { + + INCLUDEPATH += $$LAYUI_INC + DEPENDPATH += $$LAYUI_INC + + LIBS += -lklayout_layui + +} + diff --git a/src/edt/edt/edtDialogs.cc b/src/edt/edt/edtDialogs.cc index 37f6cef49..1486b2abf 100644 --- a/src/edt/edt/edtDialogs.cc +++ b/src/edt/edt/edtDialogs.cc @@ -28,7 +28,7 @@ #include "edtDialogs.h" #include "layObjectInstPath.h" #include "layCellView.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "layMarker.h" #include "tlException.h" #include "tlExceptions.h" @@ -105,7 +105,7 @@ InstantiationForm::double_clicked (QListWidgetItem *item) } void -InstantiationForm::show (lay::LayoutView *view, const lay::ObjectInstPath &path) +InstantiationForm::show (lay::LayoutViewBase *view, const lay::ObjectInstPath &path) { mp_view = view; mp_path = &path; @@ -233,7 +233,7 @@ ChangeLayerOptionsDialog::~ChangeLayerOptionsDialog () } bool -ChangeLayerOptionsDialog::exec_dialog (lay::LayoutView *view, int cv_index, unsigned int &new_layer) +ChangeLayerOptionsDialog::exec_dialog (lay::LayoutViewBase *view, int cv_index, unsigned int &new_layer) { std::vector > ll; diff --git a/src/edt/edt/edtDialogs.h b/src/edt/edt/edtDialogs.h index b0ee473a9..5864a8d54 100644 --- a/src/edt/edt/edtDialogs.h +++ b/src/edt/edt/edtDialogs.h @@ -46,7 +46,7 @@ namespace lay { - class LayoutView; + class LayoutViewBase; class Marker; class ObjectInstPath; } @@ -82,7 +82,7 @@ public: InstantiationForm (QWidget *parent); virtual ~InstantiationForm (); - void show (lay::LayoutView *view, const lay::ObjectInstPath &path); + void show (lay::LayoutViewBase *view, const lay::ObjectInstPath &path); public slots: void display_mode_changed (bool); @@ -91,7 +91,7 @@ public slots: private: void update (); - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; const lay::ObjectInstPath *mp_path; lay::Marker *mp_marker; bool m_enable_cb_callbacks; @@ -110,7 +110,7 @@ public: ChangeLayerOptionsDialog (QWidget *parent); virtual ~ChangeLayerOptionsDialog (); - bool exec_dialog (lay::LayoutView *view, int cv_index, unsigned int &new_layer); + bool exec_dialog (lay::LayoutViewBase *view, int cv_index, unsigned int &new_layer); }; /** diff --git a/src/edt/edt/edtEditorOptionsPages.cc b/src/edt/edt/edtEditorOptionsPages.cc index ff6b298d8..3ed5b6e20 100644 --- a/src/edt/edt/edtEditorOptionsPages.cc +++ b/src/edt/edt/edtEditorOptionsPages.cc @@ -33,7 +33,7 @@ #include "edtPropertiesPageUtils.h" #include "tlExceptions.h" #include "layPlugin.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "layCellSelectionForm.h" #include "layQtTools.h" #include "ui_EditorOptionsGeneric.h" diff --git a/src/edt/edt/edtEditorOptionsPages.h b/src/edt/edt/edtEditorOptionsPages.h index 394b76025..9ba3ee41e 100644 --- a/src/edt/edt/edtEditorOptionsPages.h +++ b/src/edt/edt/edtEditorOptionsPages.h @@ -52,7 +52,7 @@ namespace lay { class PluginDeclaration; class Dispatcher; - class LayoutView; + class LayoutViewBase; class Plugin; } @@ -70,7 +70,7 @@ class EditorOptionsGeneric Q_OBJECT public: - EditorOptionsGeneric (lay::LayoutView *view, lay::Dispatcher *dispatcher); + EditorOptionsGeneric (lay::LayoutViewBase *view, lay::Dispatcher *dispatcher); ~EditorOptionsGeneric (); virtual std::string title () const; @@ -93,7 +93,7 @@ class EditorOptionsText : public lay::EditorOptionsPage { public: - EditorOptionsText (lay::LayoutView *view, lay::Dispatcher *dispatcher); + EditorOptionsText (lay::LayoutViewBase *view, lay::Dispatcher *dispatcher); ~EditorOptionsText (); virtual std::string title () const; @@ -114,7 +114,7 @@ class EditorOptionsPath Q_OBJECT public: - EditorOptionsPath (lay::LayoutView *view, lay::Dispatcher *dispatcher); + EditorOptionsPath (lay::LayoutViewBase *view, lay::Dispatcher *dispatcher); ~EditorOptionsPath (); virtual std::string title () const; @@ -138,7 +138,7 @@ class EditorOptionsInst Q_OBJECT public: - EditorOptionsInst (lay::LayoutView *view, lay::Dispatcher *root); + EditorOptionsInst (lay::LayoutViewBase *view, lay::Dispatcher *root); ~EditorOptionsInst (); virtual std::string title () const; @@ -170,7 +170,7 @@ class EditorOptionsInstPCellParam Q_OBJECT public: - EditorOptionsInstPCellParam (lay::LayoutView *view, lay::Dispatcher *root); + EditorOptionsInstPCellParam (lay::LayoutViewBase *view, lay::Dispatcher *root); ~EditorOptionsInstPCellParam (); virtual std::string title () const; diff --git a/src/edt/edt/edtInstPropertiesPage.cc b/src/edt/edt/edtInstPropertiesPage.cc index e1b601e91..cde690911 100644 --- a/src/edt/edt/edtInstPropertiesPage.cc +++ b/src/edt/edt/edtInstPropertiesPage.cc @@ -32,7 +32,7 @@ #include "edtDialogs.h" #include "layDialogs.h" #include "layObjectInstPath.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "layCellSelectionForm.h" #include "layQtTools.h" #include "tlExceptions.h" diff --git a/src/edt/edt/edtMainService.cc b/src/edt/edt/edtMainService.cc index 73957aebd..56a5101e6 100644 --- a/src/edt/edt/edtMainService.cc +++ b/src/edt/edt/edtMainService.cc @@ -26,7 +26,7 @@ #include "dbLibrary.h" #include "dbLibraryManager.h" #include "tlExceptions.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "laySelector.h" #include "layFinder.h" #include "layLayerProperties.h" @@ -59,7 +59,7 @@ namespace edt // ----------------------------------------------------------------------------- // Main Service implementation -MainService::MainService (db::Manager *manager, lay::LayoutView *view, lay::Dispatcher *root) +MainService::MainService (db::Manager *manager, lay::LayoutViewBase *view, lay::Dispatcher *root) : lay::Plugin (view), lay::Editable (view), db::Object (manager), diff --git a/src/edt/edt/edtMainService.h b/src/edt/edt/edtMainService.h index 87d74e307..e6b26f98b 100644 --- a/src/edt/edt/edtMainService.h +++ b/src/edt/edt/edtMainService.h @@ -64,7 +64,7 @@ public: /** * @brief The constructor */ - MainService (db::Manager *manager, lay::LayoutView *view, lay::Dispatcher *root); + MainService (db::Manager *manager, lay::LayoutViewBase *view, lay::Dispatcher *root); /** * @brief The destructor @@ -74,7 +74,7 @@ public: /** * @brief Access to the view object */ - lay::LayoutView *view () const + lay::LayoutViewBase *view () const { return mp_view; } @@ -196,7 +196,7 @@ public: private: // The layout view that this service is attached to - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; lay::Dispatcher *mp_root; bool m_needs_update; diff --git a/src/edt/edt/edtPCellParametersPage.cc b/src/edt/edt/edtPCellParametersPage.cc index 1bf4c98e7..4edab8ab7 100644 --- a/src/edt/edt/edtPCellParametersPage.cc +++ b/src/edt/edt/edtPCellParametersPage.cc @@ -26,7 +26,7 @@ #include "edtPropertiesPageUtils.h" #include "layWidgets.h" #include "layQtTools.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "tlScriptError.h" #include @@ -233,7 +233,7 @@ PCellParametersPage::lazy_evaluation () } void -PCellParametersPage::setup (lay::LayoutView *view, int cv_index, const db::PCellDeclaration *pcell_decl, const db::pcell_parameters_type ¶meters) +PCellParametersPage::setup (lay::LayoutViewBase *view, int cv_index, const db::PCellDeclaration *pcell_decl, const db::pcell_parameters_type ¶meters) { mp_pcell_decl.reset (const_cast (pcell_decl)); // no const weak_ptr ... mp_view = view; diff --git a/src/edt/edt/edtPCellParametersPage.h b/src/edt/edt/edtPCellParametersPage.h index aa5a6ef38..83eadfea1 100644 --- a/src/edt/edt/edtPCellParametersPage.h +++ b/src/edt/edt/edtPCellParametersPage.h @@ -35,7 +35,7 @@ namespace lay { - class LayoutView; + class LayoutViewBase; } namespace edt @@ -80,7 +80,7 @@ public: * @param pcell_decl The PCell declaration * @param parameters The parameter values to show (if empty, the default values are used) */ - void setup (lay::LayoutView *view, int cv_index, const db::PCellDeclaration *pcell_decl, const db::pcell_parameters_type ¶meters); + void setup (lay::LayoutViewBase *view, int cv_index, const db::PCellDeclaration *pcell_decl, const db::pcell_parameters_type ¶meters); /** * @brief Gets the pages current state @@ -141,7 +141,7 @@ private: QFrame *mp_error_frame, *mp_update_frame; tl::weak_ptr mp_pcell_decl; std::vector m_widgets; - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; int m_cv_index; db::pcell_parameters_type m_parameters; bool m_dense; diff --git a/src/edt/edt/edtPartialService.cc b/src/edt/edt/edtPartialService.cc index 91bd17582..7f89ef2fa 100644 --- a/src/edt/edt/edtPartialService.cc +++ b/src/edt/edt/edtPartialService.cc @@ -22,7 +22,7 @@ #include "dbVector.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "laySnap.h" #include "layFinder.h" #include "tlProgress.h" @@ -1011,7 +1011,7 @@ PartialShapeFinder::visit_cell (const db::Cell &cell, const db::Box &search_box, // ----------------------------------------------------------------------------- // Main Service implementation -PartialService::PartialService (db::Manager *manager, lay::LayoutView *view, lay::Dispatcher *root) : +PartialService::PartialService (db::Manager *manager, lay::LayoutViewBase *view, lay::Dispatcher *root) : #if defined(HAVE_QT) QObject (), #endif diff --git a/src/edt/edt/edtPartialService.h b/src/edt/edt/edtPartialService.h index 9e59b3b1f..a0f7b0e78 100644 --- a/src/edt/edt/edtPartialService.h +++ b/src/edt/edt/edtPartialService.h @@ -155,7 +155,7 @@ public: /** * @brief The constructor */ - PartialService (db::Manager *manager, lay::LayoutView *view, lay::Dispatcher *root); + PartialService (db::Manager *manager, lay::LayoutViewBase *view, lay::Dispatcher *root); /** * @brief The destructor @@ -165,7 +165,7 @@ public: /** * @brief Access to the view object */ - lay::LayoutView *view () const + lay::LayoutViewBase *view () const { tl_assert (mp_view != 0); return mp_view; @@ -306,7 +306,7 @@ protected: private: // The layout view that this service is attached to - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; lay::Dispatcher *mp_root; bool m_dragging; bool m_keep_selection; diff --git a/src/edt/edt/edtPlugin.cc b/src/edt/edt/edtPlugin.cc index 0f3d01f22..5da6ed90a 100644 --- a/src/edt/edt/edtPlugin.cc +++ b/src/edt/edt/edtPlugin.cc @@ -27,7 +27,7 @@ #endif #include "layDispatcher.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "edtPlugin.h" #include "edtConfig.h" #include "edtService.h" @@ -56,7 +56,7 @@ edt::RecentConfigurationPage::ConfigurationDescriptor shape_cfg_descriptors[] = #if defined(HAVE_QT) static -void get_shape_editor_options_pages (std::vector &ret, lay::LayoutView *view, lay::Dispatcher *dispatcher) +void get_shape_editor_options_pages (std::vector &ret, lay::LayoutViewBase *view, lay::Dispatcher *dispatcher) { ret.push_back (new RecentConfigurationPage (view, dispatcher, "edit-recent-shape-param", &shape_cfg_descriptors[0], &shape_cfg_descriptors[sizeof (shape_cfg_descriptors) / sizeof (shape_cfg_descriptors[0])])); @@ -76,7 +76,7 @@ void get_text_options (std::vector < std::pair > &opti #if defined(HAVE_QT) static -void get_text_editor_options_pages (std::vector &ret, lay::LayoutView *view, lay::Dispatcher *dispatcher) +void get_text_editor_options_pages (std::vector &ret, lay::LayoutViewBase *view, lay::Dispatcher *dispatcher) { static edt::RecentConfigurationPage::ConfigurationDescriptor text_cfg_descriptors[] = { @@ -106,7 +106,7 @@ void get_path_options (std::vector < std::pair > &opti #if defined(HAVE_QT) static -void get_path_editor_options_pages (std::vector &ret, lay::LayoutView *view, lay::Dispatcher *dispatcher) +void get_path_editor_options_pages (std::vector &ret, lay::LayoutViewBase *view, lay::Dispatcher *dispatcher) { static edt::RecentConfigurationPage::ConfigurationDescriptor path_cfg_descriptors[] = { @@ -146,7 +146,7 @@ void get_inst_options (std::vector < std::pair > &opti #if defined(HAVE_QT) static -void get_inst_editor_options_pages (std::vector &ret, lay::LayoutView *view, lay::Dispatcher *dispatcher) +void get_inst_editor_options_pages (std::vector &ret, lay::LayoutViewBase *view, lay::Dispatcher *dispatcher) { static edt::RecentConfigurationPage::ConfigurationDescriptor inst_cfg_descriptors[] = { @@ -182,7 +182,7 @@ public: #if defined(HAVE_QT) PluginDeclaration (const std::string &title, const std::string &mouse_mode, void (*option_get_f) (std::vector < std::pair > &) = 0, - void (*pages_f) (std::vector &, lay::LayoutView *, lay::Dispatcher *) = 0) + void (*pages_f) (std::vector &, lay::LayoutViewBase *, lay::Dispatcher *) = 0) : m_title (title), m_mouse_mode (mouse_mode), mp_option_get_f (option_get_f), mp_pages_f (pages_f) { // .. nothing yet .. @@ -254,7 +254,7 @@ private: void (*mp_option_get_f) (std::vector < std::pair > &options); #if defined(HAVE_QT) - void (*mp_pages_f) (std::vector &, lay::LayoutView *, lay::Dispatcher *); + void (*mp_pages_f) (std::vector &, lay::LayoutViewBase *, lay::Dispatcher *); #else void (*mp_pages_f) (); #endif @@ -469,7 +469,7 @@ private: static tl::RegisteredClass config_decl_main (new edt::MainPluginDeclaration (tl::to_string (tr ("Instances and shapes"))), 4000, "edt::MainService"); void -commit_recent (lay::LayoutView *view) +commit_recent (lay::LayoutViewBase *view) { #if defined(HAVE_QT) lay::EditorOptionsPages *eo_pages = view->editor_options_pages (); diff --git a/src/edt/edt/edtPlugin.h b/src/edt/edt/edtPlugin.h index d70ade213..4b036e553 100644 --- a/src/edt/edt/edtPlugin.h +++ b/src/edt/edt/edtPlugin.h @@ -32,7 +32,7 @@ namespace lay { class Dispatcher; class EditorOptionsPage; - class LayoutView; + class LayoutViewBase; } namespace edt @@ -49,7 +49,7 @@ namespace edt /** * @brief Commits the current configuration for the recently used configuration list */ - void commit_recent (lay::LayoutView *view); + void commit_recent (lay::LayoutViewBase *view); } #endif diff --git a/src/edt/edt/edtPropertiesPages.cc b/src/edt/edt/edtPropertiesPages.cc index 7a34c1981..7f01f3158 100644 --- a/src/edt/edt/edtPropertiesPages.cc +++ b/src/edt/edt/edtPropertiesPages.cc @@ -28,7 +28,7 @@ #include "edtPropertiesPageUtils.h" #include "layDialogs.h" #include "layObjectInstPath.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "layQtTools.h" #include "tlExceptions.h" #include "tlString.h" diff --git a/src/edt/edt/edtRecentConfigurationPage.cc b/src/edt/edt/edtRecentConfigurationPage.cc index 09c4a50ed..f184cb692 100644 --- a/src/edt/edt/edtRecentConfigurationPage.cc +++ b/src/edt/edt/edtRecentConfigurationPage.cc @@ -25,7 +25,7 @@ #include "edtRecentConfigurationPage.h" #include "edtUtils.h" #include "layDispatcher.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "layLayerTreeModel.h" #include "dbLibraryManager.h" #include "dbLibrary.h" @@ -133,7 +133,7 @@ RecentConfigurationPage::set_stored_values (const std::list[@]) db::LayerProperties lp; @@ -181,7 +181,7 @@ RecentConfigurationPage::render_to (QTreeWidgetItem *item, int column, const std case RecentConfigurationPage::Layer: { - int icon_size = view ()->style ()->pixelMetric (QStyle::PM_ButtonIconSize); + int icon_size = view ()->widget ()->style ()->pixelMetric (QStyle::PM_ButtonIconSize); lay::LayerPropertiesConstIterator l; try { l = lp_iter_from_string (view (), values [column]); diff --git a/src/edt/edt/edtRecentConfigurationPage.h b/src/edt/edt/edtRecentConfigurationPage.h index ab8c88800..00997fd0f 100644 --- a/src/edt/edt/edtRecentConfigurationPage.h +++ b/src/edt/edt/edtRecentConfigurationPage.h @@ -33,7 +33,7 @@ namespace lay { - class LayoutView; + class LayoutViewBase; } namespace edt @@ -78,7 +78,7 @@ public: }; template - RecentConfigurationPage (lay::LayoutView *view, lay::Dispatcher *dispatcher, const std::string &recent_cfg_name, Iter begin_cfg, Iter end_cfg) + RecentConfigurationPage (lay::LayoutViewBase *view, lay::Dispatcher *dispatcher, const std::string &recent_cfg_name, Iter begin_cfg, Iter end_cfg) : EditorOptionsPage (view, dispatcher), m_recent_cfg_name (recent_cfg_name), m_cfg (begin_cfg, end_cfg) { init (); diff --git a/src/edt/edt/edtService.cc b/src/edt/edt/edtService.cc index dd439ebed..7e3320bee 100644 --- a/src/edt/edt/edtService.cc +++ b/src/edt/edt/edtService.cc @@ -31,7 +31,7 @@ # include "edtDialogs.h" #endif #include "layFinder.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "laySnap.h" #include "tlProgress.h" #include "tlTimer.h" @@ -62,7 +62,7 @@ ac_from_buttons (unsigned int buttons) // ------------------------------------------------------------- -Service::Service (db::Manager *manager, lay::LayoutView *view, db::ShapeIterator::flags_type flags) +Service::Service (db::Manager *manager, lay::LayoutViewBase *view, db::ShapeIterator::flags_type flags) : lay::EditorServiceBase (view), db::Object (manager), mp_view (view), @@ -82,7 +82,7 @@ Service::Service (db::Manager *manager, lay::LayoutView *view, db::ShapeIterator // .. nothing yet .. } -Service::Service (db::Manager *manager, lay::LayoutView *view) +Service::Service (db::Manager *manager, lay::LayoutViewBase *view) : lay::EditorServiceBase (view), db::Object (manager), mp_view (view), diff --git a/src/edt/edt/edtService.h b/src/edt/edt/edtService.h index 15121657a..cd05cd739 100644 --- a/src/edt/edt/edtService.h +++ b/src/edt/edt/edtService.h @@ -83,12 +83,12 @@ public: /** * @brief The constructor for an service selecting shapes */ - Service (db::Manager *manager, lay::LayoutView *view, db::ShapeIterator::flags_type shape_types); + Service (db::Manager *manager, lay::LayoutViewBase *view, db::ShapeIterator::flags_type shape_types); /** * @brief The constructor for an service selecting instances */ - Service (db::Manager *manager, lay::LayoutView *view); + Service (db::Manager *manager, lay::LayoutViewBase *view); /** * @brief The destructor @@ -244,7 +244,7 @@ public: /** * @brief Access to the view object */ - lay::LayoutView *view () const + lay::LayoutViewBase *view () const { tl_assert (mp_view != 0); return mp_view; @@ -560,7 +560,7 @@ protected: private: // The layout view that the editor service is attached to - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; // The marker objects representing the selection std::vector m_markers; diff --git a/src/edt/edt/edtServiceImpl.cc b/src/edt/edt/edtServiceImpl.cc index ba5605954..60cd2ee29 100644 --- a/src/edt/edt/edtServiceImpl.cc +++ b/src/edt/edt/edtServiceImpl.cc @@ -37,7 +37,7 @@ #include "dbEdgeProcessor.h" #include "layMarker.h" #include "layLayerProperties.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #if defined(HAVE_QT) # include "layTipDialog.h" @@ -54,7 +54,7 @@ namespace edt // ----------------------------------------------------------------------------- // ShapeEditService implementation -ShapeEditService::ShapeEditService (db::Manager *manager, lay::LayoutView *view, db::ShapeIterator::flags_type shape_types) +ShapeEditService::ShapeEditService (db::Manager *manager, lay::LayoutViewBase *view, db::ShapeIterator::flags_type shape_types) : edt::Service (manager, view, shape_types), m_layer (0), m_cv_index (0), mp_cell (0), mp_layout (0), m_combine_mode (CM_Add) { @@ -373,7 +373,7 @@ ShapeEditService::deliver_shape (const db::Box &box) // ----------------------------------------------------------------------------- // PolygonService implementation -PolygonService::PolygonService (db::Manager *manager, lay::LayoutView *view) +PolygonService::PolygonService (db::Manager *manager, lay::LayoutViewBase *view) : ShapeEditService (manager, view, db::ShapeIterator::Polygons), m_closure_set (false), m_closure () { @@ -705,7 +705,7 @@ PolygonService::update_marker () // ----------------------------------------------------------------------------- // BoxService implementation -BoxService::BoxService (db::Manager *manager, lay::LayoutView *view) +BoxService::BoxService (db::Manager *manager, lay::LayoutViewBase *view) : ShapeEditService (manager, view, db::ShapeIterator::Boxes) { // .. nothing yet .. @@ -799,7 +799,7 @@ BoxService::selection_applies (const lay::ObjectInstPath &sel) const // ----------------------------------------------------------------------------- // TextService implementation -TextService::TextService (db::Manager *manager, lay::LayoutView *view) +TextService::TextService (db::Manager *manager, lay::LayoutViewBase *view) : ShapeEditService (manager, view, db::ShapeIterator::Texts), m_rot (0) { @@ -991,7 +991,7 @@ TextService::configure (const std::string &name, const std::string &value) // ----------------------------------------------------------------------------- // PathService implementation -PathService::PathService (db::Manager *manager, lay::LayoutView *view) +PathService::PathService (db::Manager *manager, lay::LayoutViewBase *view) : ShapeEditService (manager, view, db::ShapeIterator::Paths), m_width (0.1), m_bgnext (0.0), m_endext (0.0), m_type (Flush), m_needs_update (true) { @@ -1232,7 +1232,7 @@ PathService::config_finalize () // ----------------------------------------------------------------------------- // InstService implementation -InstService::InstService (db::Manager *manager, lay::LayoutView *view) +InstService::InstService (db::Manager *manager, lay::LayoutViewBase *view) : edt::Service (manager, view), m_angle (0.0), m_scale (1.0), m_mirror (false), m_is_pcell (false), diff --git a/src/edt/edt/edtServiceImpl.h b/src/edt/edt/edtServiceImpl.h index 9d9ebc2f8..1de7c70a6 100644 --- a/src/edt/edt/edtServiceImpl.h +++ b/src/edt/edt/edtServiceImpl.h @@ -32,6 +32,7 @@ namespace lay { class CellView; + class LayoutViewBase; class LayerPropertiesConstIterator; } @@ -45,7 +46,7 @@ class ShapeEditService : public edt::Service { public: - ShapeEditService (db::Manager *manager, lay::LayoutView *view, db::ShapeIterator::flags_type shape_types); + ShapeEditService (db::Manager *manager, lay::LayoutViewBase *view, db::ShapeIterator::flags_type shape_types); protected: void get_edit_layer (); @@ -86,7 +87,7 @@ class PolygonService : public ShapeEditService { public: - PolygonService (db::Manager *manager, lay::LayoutView *view); + PolygonService (db::Manager *manager, lay::LayoutViewBase *view); #if defined(HAVE_QT) virtual lay::PropertiesPage *properties_page (db::Manager *manager, QWidget *parent); @@ -119,7 +120,7 @@ class BoxService : public ShapeEditService { public: - BoxService (db::Manager *manager, lay::LayoutView *view); + BoxService (db::Manager *manager, lay::LayoutViewBase *view); #if defined(HAVE_QT) virtual lay::PropertiesPage *properties_page (db::Manager *manager, QWidget *parent); @@ -146,7 +147,7 @@ class TextService : public ShapeEditService { public: - TextService (db::Manager *manager, lay::LayoutView *view); + TextService (db::Manager *manager, lay::LayoutViewBase *view); ~TextService (); #if defined(HAVE_QT) @@ -180,7 +181,7 @@ class PathService : public ShapeEditService { public: - PathService (db::Manager *manager, lay::LayoutView *view); + PathService (db::Manager *manager, lay::LayoutViewBase *view); ~PathService (); #if defined(HAVE_QT) @@ -219,7 +220,7 @@ class InstService : public edt::Service { public: - InstService (db::Manager *manager, lay::LayoutView *view); + InstService (db::Manager *manager, lay::LayoutViewBase *view); #if defined(HAVE_QT) virtual lay::PropertiesPage *properties_page (db::Manager *manager, QWidget *parent); diff --git a/src/edt/edt/edtUtils.cc b/src/edt/edt/edtUtils.cc index 4b04d9de8..e4e6c69c0 100644 --- a/src/edt/edt/edtUtils.cc +++ b/src/edt/edt/edtUtils.cc @@ -29,7 +29,7 @@ #include "edtService.h" #include "layCellView.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "layEditable.h" #include "tlException.h" @@ -77,7 +77,7 @@ std::map pcell_parameters_from_string (const std::stri // ------------------------------------------------------------- // SelectionIterator implementation -SelectionIterator::SelectionIterator (lay::LayoutView *view, bool including_transient) +SelectionIterator::SelectionIterator (lay::LayoutViewBase *view, bool including_transient) : m_transient_mode (false) { mp_edt_services = view->get_plugins (); @@ -145,7 +145,7 @@ SelectionIterator::next () // TransformationsVariants implementation // for a lay::LayoutView -TransformationVariants::TransformationVariants (const lay::LayoutView *view, bool per_cv_and_layer, bool per_cv) +TransformationVariants::TransformationVariants (const lay::LayoutViewBase *view, bool per_cv_and_layer, bool per_cv) { // build the transformation variants cache diff --git a/src/edt/edt/edtUtils.h b/src/edt/edt/edtUtils.h index 83189a84d..dc2a0c293 100644 --- a/src/edt/edt/edtUtils.h +++ b/src/edt/edt/edtUtils.h @@ -38,7 +38,7 @@ namespace lay { - class LayoutView; + class LayoutViewBase; } namespace edt { @@ -82,7 +82,7 @@ public: class TransformationVariants { public: - TransformationVariants (const lay::LayoutView *view, bool per_cv_and_layer = true, bool per_cv = true); + TransformationVariants (const lay::LayoutViewBase *view, bool per_cv_and_layer = true, bool per_cv = true); const std::vector *per_cv_and_layer (unsigned int cv, unsigned int layer) const; const std::vector *per_cv (unsigned int cv) const; @@ -107,7 +107,7 @@ public: * * If "including_transient" is true, the transient selection will be used as fallback. */ - SelectionIterator (lay::LayoutView *view, bool including_transient = true); + SelectionIterator (lay::LayoutViewBase *view, bool including_transient = true); /** * @brief Returns a value indicating whether the transient selection is taken diff --git a/src/edt/edt/gsiDeclEdt.cc b/src/edt/edt/gsiDeclEdt.cc index 75e96b0f4..95a55f333 100644 --- a/src/edt/edt/gsiDeclEdt.cc +++ b/src/edt/edt/gsiDeclEdt.cc @@ -25,7 +25,7 @@ #include "edtService.h" #include "dbRecursiveShapeIterator.h" #include "layObjectInstPath.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" namespace gsi { @@ -489,7 +489,7 @@ private: // extend the layout view by "edtService" specific methods -static std::vector object_selection (const lay::LayoutView *view) +static std::vector object_selection (const lay::LayoutViewBase *view) { std::vector result; std::vector edt_services = view->get_plugins (); @@ -501,7 +501,7 @@ static std::vector object_selection (const la return result; } -static void set_object_selection (const lay::LayoutView *view, const std::vector &all_selected) +static void set_object_selection (const lay::LayoutViewBase *view, const std::vector &all_selected) { std::vector sel; @@ -521,7 +521,7 @@ static void set_object_selection (const lay::LayoutView *view, const std::vector } } -static bool has_object_selection (const lay::LayoutView *view) +static bool has_object_selection (const lay::LayoutViewBase *view) { std::vector edt_services = view->get_plugins (); for (std::vector::const_iterator s = edt_services.begin (); s != edt_services.end (); ++s) { @@ -532,7 +532,7 @@ static bool has_object_selection (const lay::LayoutView *view) return false; } -static void clear_object_selection (const lay::LayoutView *view) +static void clear_object_selection (const lay::LayoutViewBase *view) { std::vector edt_services = view->get_plugins (); for (std::vector::const_iterator s = edt_services.begin (); s != edt_services.end (); ++s) { @@ -540,7 +540,7 @@ static void clear_object_selection (const lay::LayoutView *view) } } -static void select_object (const lay::LayoutView *view, const edt::Service::objects::value_type &object) +static void select_object (const lay::LayoutViewBase *view, const edt::Service::objects::value_type &object) { std::vector edt_services = view->get_plugins (); for (std::vector::const_iterator s = edt_services.begin (); s != edt_services.end (); ++s) { @@ -551,7 +551,7 @@ static void select_object (const lay::LayoutView *view, const edt::Service::obje } } -static void unselect_object (const lay::LayoutView *view, const edt::Service::objects::value_type &object) +static void unselect_object (const lay::LayoutViewBase *view, const edt::Service::objects::value_type &object) { std::vector edt_services = view->get_plugins (); for (std::vector::const_iterator s = edt_services.begin (); s != edt_services.end (); ++s) { @@ -562,7 +562,7 @@ static void unselect_object (const lay::LayoutView *view, const edt::Service::ob } } -static bool has_transient_object_selection (const lay::LayoutView *view) +static bool has_transient_object_selection (const lay::LayoutViewBase *view) { std::vector edt_services = view->get_plugins (); for (std::vector::const_iterator s = edt_services.begin (); s != edt_services.end (); ++s) { @@ -573,18 +573,18 @@ static bool has_transient_object_selection (const lay::LayoutView *view) return false; } -static EditableSelectionIterator begin_objects_selected (const lay::LayoutView *view) +static EditableSelectionIterator begin_objects_selected (const lay::LayoutViewBase *view) { return EditableSelectionIterator (view->get_plugins (), false); } -static EditableSelectionIterator begin_objects_selected_transient (const lay::LayoutView *view) +static EditableSelectionIterator begin_objects_selected_transient (const lay::LayoutViewBase *view) { return EditableSelectionIterator (view->get_plugins (), true); } static -gsi::ClassExt layout_view_decl ( +gsi::ClassExt layout_view_decl ( gsi::method_ext ("has_object_selection?", &has_object_selection, "@brief Returns true, if geometrical objects (shapes or cell instances) are selected in this view" ) + From d2f2d630d9feafe493665ac2aa739caa58e2eb1c Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 15 May 2022 01:19:56 +0200 Subject: [PATCH 66/88] WIP --- src/edt/edt/edtRecentConfigurationPage.cc | 37 ++++++++++++++++++++++- src/layview/layview/layLayoutView_qt.cc | 35 --------------------- src/layview/layview/layLayoutView_qt.h | 8 ----- 3 files changed, 36 insertions(+), 44 deletions(-) diff --git a/src/edt/edt/edtRecentConfigurationPage.cc b/src/edt/edt/edtRecentConfigurationPage.cc index f184cb692..ee68dbd75 100644 --- a/src/edt/edt/edtRecentConfigurationPage.cc +++ b/src/edt/edt/edtRecentConfigurationPage.cc @@ -34,6 +34,7 @@ #include #include #include +#include namespace edt { @@ -346,6 +347,40 @@ RecentConfigurationPage::update_list (const std::list > mp_tree_widget->header ()->resizeSections (QHeaderView::ResizeToContents); } +static bool +set_or_request_current_layer (lay::LayoutViewBase *view, unsigned int cv_index, const db::LayerProperties &lp) +{ + bool ok = view->set_current_layer (cv_index, lp); + if (ok) { + return true; + } + + if (! view->control_panel ()) { + return false; + } + + const lay::CellView &cv = view->cellview (cv_index); + if (! cv.is_valid ()) { + return false; + } + + if (QMessageBox::question (view->widget (), tr ("Create Layer"), tr ("Layer %1 does not exist yet. Create it now?").arg (tl::to_qstring (lp.to_string ()))) == QMessageBox::Yes) { + + lay::LayerPropertiesNode lpn; + lpn.set_source (lay::ParsedLayerSource (lp, cv_index)); + view->init_layer_properties (lpn); + + view->transaction (tl::to_string (QObject::tr ("Create new layer"))); + view->set_current_layer (lay::LayerPropertiesConstIterator (& view->insert_layer (view->end_layers (), lpn))); + view->commit (); + + return true; + + } + + return false; +} + void RecentConfigurationPage::item_clicked (QTreeWidgetItem *item) { @@ -365,7 +400,7 @@ RecentConfigurationPage::item_clicked (QTreeWidgetItem *item) ex.read (cv_index); } - view ()->set_or_request_current_layer (cv_index, lp); + set_or_request_current_layer (view (), cv_index, lp); } else { dispatcher ()->config_set (c->cfg_name, v); diff --git a/src/layview/layview/layLayoutView_qt.cc b/src/layview/layview/layLayoutView_qt.cc index c9bf40661..bf3070ede 100644 --- a/src/layview/layview/layLayoutView_qt.cc +++ b/src/layview/layview/layLayoutView_qt.cc @@ -33,7 +33,6 @@ #include #include #include -#include #include #include @@ -608,40 +607,6 @@ LayoutView::config_finalize () dm_setup_editor_option_pages (); } -bool -LayoutView::set_or_request_current_layer (unsigned int cv_index, const db::LayerProperties &lp) -{ - bool ok = set_current_layer (cv_index, lp); - if (ok) { - return true; - } - - if (! mp_control_panel) { - return false; - } - - const lay::CellView &cv = cellview (cv_index); - if (! cv.is_valid ()) { - return false; - } - - if (QMessageBox::question (this, tr ("Create Layer"), tr ("Layer %1 does not exist yet. Create it now?").arg (tl::to_qstring (lp.to_string ()))) == QMessageBox::Yes) { - - lay::LayerPropertiesNode lpn; - lpn.set_source (lay::ParsedLayerSource (lp, cv_index)); - init_layer_properties (lpn); - - transaction (tl::to_string (QObject::tr ("Create new layer"))); - set_current_layer (lay::LayerPropertiesConstIterator (& insert_layer (end_layers (), lpn))); - commit (); - - return true; - - } - - return false; -} - void LayoutView::set_current_layer (const lay::LayerPropertiesConstIterator &l) { diff --git a/src/layview/layview/layLayoutView_qt.h b/src/layview/layview/layLayoutView_qt.h index 6d87a57ad..5eca291cf 100644 --- a/src/layview/layview/layLayoutView_qt.h +++ b/src/layview/layview/layLayoutView_qt.h @@ -179,14 +179,6 @@ public: */ virtual void create_plugins (const lay::PluginDeclaration *except_this = 0); - /** - * @brief Sets the currently active layer by layer properties and cell view index - * - * If the layer does not exist, the user will be asked whether to create the layer. - * Returns false if the layer is not a valid one and the user defined to create the layer. - */ - bool set_or_request_current_layer (unsigned int cv_index, const db::LayerProperties &properties); - /** * @brief Sets the currently active layer by layer properties and cell view index * From b17b2714a55dd175c6d1928312fe880563766214 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 15 May 2022 01:25:36 +0200 Subject: [PATCH 67/88] WIP --- src/laybasic/laybasic/gsiDeclLayLayers.cc | 5 ----- src/laybasic/laybasic/layLayoutViewBase.h | 9 +++++++++ src/layview/layview/layLayoutView_qt.cc | 1 + src/layview/layview/layLayoutView_qt.h | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/laybasic/laybasic/gsiDeclLayLayers.cc b/src/laybasic/laybasic/gsiDeclLayLayers.cc index 794d83882..ff03eeec6 100644 --- a/src/laybasic/laybasic/gsiDeclLayLayers.cc +++ b/src/laybasic/laybasic/gsiDeclLayLayers.cc @@ -1165,11 +1165,6 @@ static void clear_children (lay::LayerPropertiesNode *node) node->clear_children (); } -static lay::LayoutView *get_view (lay::LayerPropertiesNode *node) -{ - return node->view ()->ui (); -} - Class decl_LayerPropertiesNode ( decl_LayerProperties, "lay", "LayerPropertiesNode", diff --git a/src/laybasic/laybasic/layLayoutViewBase.h b/src/laybasic/laybasic/layLayoutViewBase.h index c4b43ce36..0c41cf425 100644 --- a/src/laybasic/laybasic/layLayoutViewBase.h +++ b/src/laybasic/laybasic/layLayoutViewBase.h @@ -79,6 +79,7 @@ class MoveService; #if defined(HAVE_QT) class LayerControlPanel; class HierarchyControlPanel; +class EditorOptionsPages; #endif /** @@ -1671,6 +1672,14 @@ public: { return 0; } + + /** + * @brief Gets the hierarchy panel + */ + virtual lay::EditorOptionsPages *editor_options_pages () + { + return 0; + } #endif /** diff --git a/src/layview/layview/layLayoutView_qt.cc b/src/layview/layview/layLayoutView_qt.cc index bf3070ede..3606f56ce 100644 --- a/src/layview/layview/layLayoutView_qt.cc +++ b/src/layview/layview/layLayoutView_qt.cc @@ -35,6 +35,7 @@ #include #include #include +#include #include "tlInternational.h" #include "tlExpression.h" diff --git a/src/layview/layview/layLayoutView_qt.h b/src/layview/layview/layLayoutView_qt.h index 5eca291cf..486abc108 100644 --- a/src/layview/layview/layLayoutView_qt.h +++ b/src/layview/layview/layLayoutView_qt.h @@ -327,7 +327,7 @@ public: /** * @brief Gets the editor options pages */ - lay::EditorOptionsPages *editor_options_pages (); + virtual lay::EditorOptionsPages *editor_options_pages (); /** * @brief Gets the container with the layer control panel From f5b4bbb62cdcdaadce734b91c6ffc06fada05f43 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 15 May 2022 10:31:09 +0200 Subject: [PATCH 68/88] WIP --- src/ant/ant/ant.pro | 15 +- src/ant/ant/antPropertiesPage.cc | 2 +- src/ant/ant/antService.cc | 4 +- src/ant/ant/antService.h | 6 +- src/ant/ant/gsiDeclAnt.cc | 56 ++-- src/edt/edt/edt.pro | 6 +- src/edt/edt/edtEditorOptionsPages.cc | 10 +- src/edt/edt/edtMainService.cc | 6 +- src/img/img/gsiDeclImg.cc | 52 ++-- src/img/img/img.pro | 14 +- src/img/img/imgLandmarksDialog.cc | 2 +- src/img/img/imgNavigator.h | 4 +- src/img/img/imgService.cc | 4 +- src/img/img/imgService.h | 6 +- src/lay/lay/lay.pro | 8 +- src/lay/lay/layClipDialog.cc | 2 +- src/lay/lay/layClipDialog.h | 2 +- src/lay/lay/layFillDialog.cc | 2 +- src/lay/lay/layFillDialog.h | 4 +- src/lay/lay/laySearchReplaceDialog.cc | 2 +- src/lay/lay/laySearchReplaceDialog.h | 4 +- .../lay/laySearchReplacePropertiesWidgets.cc | 28 +- .../lay/laySearchReplacePropertiesWidgets.h | 4 +- src/lay/unit_tests/unit_tests.pro | 6 +- .../laybasic/gsiDeclLayLayoutViewBase.cc | 4 +- src/laybasic/laybasic/layFixedFont.h | 4 +- src/laybasic/laybasic/layLayoutCanvas.h | 13 +- src/laybasic/laybasic/layMove.h | 3 +- .../laybasic}/layNativePlugin.cc | 0 .../laybasic}/layNativePlugin.h | 14 +- src/laybasic/laybasic/laybasic.pro | 2 + src/layui/layui/layBookmarkManagementForm.h | 3 +- src/layui/layui/layCellSelectionForm.cc | 267 +++++++++--------- src/layui/layui/layCellSelectionForm.h | 17 +- src/layui/layui/layHierarchyControlPanel.h | 3 +- src/layui/layui/layLayerControlPanel.h | 25 +- src/layui/layui/layLibrariesView.h | 17 +- src/layui/layui/layNetlistBrowserDialog.h | 3 +- src/layui/layui/rdbMarkerBrowserDialog.h | 3 +- src/plugins/lay_plugin.pri | 6 +- .../lefdef/lay_plugin/layLEFDEFImport.cc | 1 + .../lay_plugin/layBooleanOperationsDialogs.cc | 6 +- .../lay_plugin/layBooleanOperationsDialogs.h | 14 +- .../lay_plugin/layBooleanOperationsPlugin.cc | 12 +- .../tools/diff/lay_plugin/layDiffPlugin.cc | 6 +- .../diff/lay_plugin/layDiffToolDialog.cc | 4 +- .../tools/diff/lay_plugin/layDiffToolDialog.h | 6 +- .../lay_plugin/layNetTracerDialog.cc | 2 +- .../lay_plugin/layNetTracerDialog.h | 6 +- .../tools/view_25d/lay_plugin/layD25View.cc | 4 +- .../tools/view_25d/lay_plugin/layD25View.h | 6 +- .../view_25d/lay_plugin/layD25ViewWidget.cc | 2 +- .../view_25d/lay_plugin/layD25ViewWidget.h | 6 +- .../tools/xor/lay_plugin/layXORPlugin.cc | 4 +- .../tools/xor/lay_plugin/layXORToolDialog.cc | 2 +- .../tools/xor/lay_plugin/layXORToolDialog.h | 6 +- src/with_all_libs.pri | 17 +- 57 files changed, 388 insertions(+), 349 deletions(-) rename src/{lay/lay => laybasic/laybasic}/layNativePlugin.cc (100%) rename src/{lay/lay => laybasic/laybasic}/layNativePlugin.h (84%) diff --git a/src/ant/ant/ant.pro b/src/ant/ant/ant.pro index 079b34e75..c6052dab5 100644 --- a/src/ant/ant/ant.pro +++ b/src/ant/ant/ant.pro @@ -47,7 +47,16 @@ SOURCES += \ gsiDeclAnt.cc \ antForceLink.cc -INCLUDEPATH += $$TL_INC $$GSI_INC $$LAYBASIC_INC $$DB_INC -DEPENDPATH += $$TL_INC $$GSI_INC $$LAYBASIC_INC $$DB_INC -LIBS += -L$$DESTDIR -lklayout_tl -lklayout_gsi -lklayout_laybasic -lklayout_db +INCLUDEPATH += $$TL_INC $$GSI_INC $$LAYBASIC_INC $$LAYVIEW_INC $$DB_INC +DEPENDPATH += $$TL_INC $$GSI_INC $$LAYBASIC_INC $$LAYVIEW_INC $$DB_INC +LIBS += -L$$DESTDIR -lklayout_tl -lklayout_gsi -lklayout_laybasic -lklayout_layview -lklayout_db + +!equals(HAVE_QT, "0") { + + INCLUDEPATH += $$LAYUI_INC + DEPENDPATH += $$LAYUI_INC + + LIBS += -lklayout_layui + +} diff --git a/src/ant/ant/antPropertiesPage.cc b/src/ant/ant/antPropertiesPage.cc index 99f8f4056..1c7794db4 100644 --- a/src/ant/ant/antPropertiesPage.cc +++ b/src/ant/ant/antPropertiesPage.cc @@ -23,7 +23,7 @@ #if defined(HAVE_QT) #include "antPropertiesPage.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "layQtTools.h" namespace ant diff --git a/src/ant/ant/antService.cc b/src/ant/ant/antService.cc index 3208df850..e9d6401c5 100644 --- a/src/ant/ant/antService.cc +++ b/src/ant/ant/antService.cc @@ -28,7 +28,7 @@ #include "layPlugin.h" #include "layRenderer.h" #include "laySnap.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "laybasicConfig.h" #include "layConverters.h" #include "layLayoutCanvas.h" @@ -788,7 +788,7 @@ View::render (const lay::Viewport &vp, lay::ViewObjectCanvas &canvas) // ------------------------------------------------------------- // ant::Service implementation -Service::Service (db::Manager *manager, lay::LayoutView *view) +Service::Service (db::Manager *manager, lay::LayoutViewBase *view) : lay::EditorServiceBase (view), lay::Drawing (1/*number of planes*/, view->drawings ()), db::Object (manager), diff --git a/src/ant/ant/antService.h b/src/ant/ant/antService.h index d6b3f30b3..c52c4d138 100644 --- a/src/ant/ant/antService.h +++ b/src/ant/ant/antService.h @@ -201,7 +201,7 @@ public: */ enum MoveMode { MoveNone, MoveP1, MoveP2, MoveP12, MoveP21, MoveP1X, MoveP2X, MoveP1Y, MoveP2Y, MoveRuler, MoveSelected }; - Service (db::Manager *manager, lay::LayoutView *view); + Service (db::Manager *manager, lay::LayoutViewBase *view); ~Service (); @@ -429,7 +429,7 @@ public: /** * @brief Access to the view object */ - lay::LayoutView *view () const + lay::LayoutViewBase *view () const { return mp_view; } @@ -512,7 +512,7 @@ private: int m_max_number_of_rulers; // The layout view that the ruler service is attached to - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; // The ruler view objects representing the selection // and the moved rules in move mode diff --git a/src/ant/ant/gsiDeclAnt.cc b/src/ant/ant/gsiDeclAnt.cc index 325867bc0..8889af167 100644 --- a/src/ant/ant/gsiDeclAnt.cc +++ b/src/ant/ant/gsiDeclAnt.cc @@ -25,7 +25,7 @@ #include "antObject.h" #include "antService.h" #include "antPlugin.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" namespace gsi { @@ -70,10 +70,10 @@ static int align_right () { return int (ant::Object::AL_right); } static int align_top () { return int (ant::Object::AL_top); } static int align_up () { return int (ant::Object::AL_up); } -static void clear_annotations (lay::LayoutView *view); -static void insert_annotation (lay::LayoutView *view, AnnotationRef *obj); -static void erase_annotation_base (lay::LayoutView *view, int id); -static void replace_annotation_base (lay::LayoutView *view, int id, const AnnotationRef &obj); +static void clear_annotations (lay::LayoutViewBase *view); +static void insert_annotation (lay::LayoutViewBase *view, AnnotationRef *obj); +static void erase_annotation_base (lay::LayoutViewBase *view, int id); +static void replace_annotation_base (lay::LayoutViewBase *view, int id, const AnnotationRef &obj); /** * @brief An extension of the ant::Object that provides "live" updates of the view @@ -88,7 +88,7 @@ public: // .. nothing yet .. } - AnnotationRef (const ant::Object &other, lay::LayoutView *view) + AnnotationRef (const ant::Object &other, lay::LayoutViewBase *view) : ant::Object (other), mp_view (view) { // .. nothing yet .. @@ -140,10 +140,10 @@ public: template AnnotationRef transformed (const T &t) const { - return AnnotationRef (ant::Object::transformed (t), const_cast (mp_view.get ())); + return AnnotationRef (ant::Object::transformed (t), const_cast (mp_view.get ())); } - void set_view (lay::LayoutView *view) + void set_view (lay::LayoutViewBase *view) { mp_view.reset (view); } @@ -157,10 +157,10 @@ protected: } private: - tl::weak_ptr mp_view; + tl::weak_ptr mp_view; }; -static void clear_annotations (lay::LayoutView *view) +static void clear_annotations (lay::LayoutViewBase *view) { ant::Service *ant_service = view->get_plugin (); if (ant_service) { @@ -168,7 +168,7 @@ static void clear_annotations (lay::LayoutView *view) } } -static void insert_annotation (lay::LayoutView *view, AnnotationRef *obj) +static void insert_annotation (lay::LayoutViewBase *view, AnnotationRef *obj) { if (obj->is_valid ()) { throw tl::Exception (tl::to_string (tr ("The object is already inserted into a view - detach the object first or create a different object."))); @@ -182,7 +182,7 @@ static void insert_annotation (lay::LayoutView *view, AnnotationRef *obj) } } -static void erase_annotation_base (lay::LayoutView *view, int id) +static void erase_annotation_base (lay::LayoutViewBase *view, int id) { ant::Service *ant_service = view->get_plugin (); if (ant_service) { @@ -195,12 +195,12 @@ static void erase_annotation_base (lay::LayoutView *view, int id) } } -static void erase_annotation (lay::LayoutView *view, int id) +static void erase_annotation (lay::LayoutViewBase *view, int id) { erase_annotation_base (view, id); } -static void replace_annotation_base (lay::LayoutView *view, int id, const AnnotationRef &obj) +static void replace_annotation_base (lay::LayoutViewBase *view, int id, const AnnotationRef &obj) { ant::Service *ant_service = view->get_plugin (); if (ant_service) { @@ -213,12 +213,12 @@ static void replace_annotation_base (lay::LayoutView *view, int id, const Annota } } -static void replace_annotation (lay::LayoutView *view, int id, const AnnotationRef &obj) +static void replace_annotation (lay::LayoutViewBase *view, int id, const AnnotationRef &obj) { replace_annotation_base (view, id, obj); } -static AnnotationRef create_measure_ruler (lay::LayoutView *view, const db::DPoint &pt, int angle_constraint) +static AnnotationRef create_measure_ruler (lay::LayoutViewBase *view, const db::DPoint &pt, int angle_constraint) { std::vector ant_services = view->get_plugins (); if (! ant_services.empty ()) { @@ -351,7 +351,7 @@ public: // .. nothing yet .. } - AnnotationRefIterator (const ant::AnnotationIterator &iter, lay::LayoutView *view) + AnnotationRefIterator (const ant::AnnotationIterator &iter, lay::LayoutViewBase *view) : ant::AnnotationIterator (iter), mp_view (view) { // .. nothing yet .. @@ -359,14 +359,14 @@ public: reference operator* () const { - return reference (ant::AnnotationIterator::operator* (), const_cast(mp_view.get ())); + return reference (ant::AnnotationIterator::operator* (), const_cast(mp_view.get ())); } private: - tl::weak_ptr mp_view; + tl::weak_ptr mp_view; }; -static AnnotationRefIterator begin_annotations (lay::LayoutView *view) +static AnnotationRefIterator begin_annotations (lay::LayoutViewBase *view) { ant::Service *ant_service = view->get_plugin (); if (ant_service) { @@ -376,7 +376,7 @@ static AnnotationRefIterator begin_annotations (lay::LayoutView *view) } } -static AnnotationRef get_annotation (lay::LayoutView *view, int id) +static AnnotationRef get_annotation (lay::LayoutViewBase *view, int id) { ant::Service *ant_service = view->get_plugin (); if (ant_service) { @@ -389,21 +389,21 @@ static AnnotationRef get_annotation (lay::LayoutView *view, int id) return AnnotationRef (); } -static tl::Event &get_annotations_changed_event (lay::LayoutView *view) +static tl::Event &get_annotations_changed_event (lay::LayoutViewBase *view) { ant::Service *ant_service = view->get_plugin (); tl_assert (ant_service != 0); return ant_service->annotations_changed_event; } -static tl::Event &get_annotation_selection_changed_event (lay::LayoutView *view) +static tl::Event &get_annotation_selection_changed_event (lay::LayoutViewBase *view) { ant::Service *ant_service = view->get_plugin (); tl_assert (ant_service != 0); return ant_service->annotation_selection_changed_event; } -static tl::event &get_annotation_changed_event (lay::LayoutView *view) +static tl::event &get_annotation_changed_event (lay::LayoutViewBase *view) { ant::Service *ant_service = view->get_plugin (); tl_assert (ant_service != 0); @@ -989,7 +989,7 @@ gsi::Class decl_Annotation (decl_BasicAnnotation, "lay", "Annotat ); static -gsi::ClassExt layout_view_decl ( +gsi::ClassExt layout_view_decl ( gsi::method_ext ("clear_annotations", &gsi::clear_annotations, "@brief Clears all annotations on this view" ) + @@ -1123,7 +1123,7 @@ private: // extend the layout view by "edtService" specific methods -static bool has_annotation_selection (const lay::LayoutView *view) +static bool has_annotation_selection (const lay::LayoutViewBase *view) { std::vector ant_services = view->get_plugins (); for (std::vector::const_iterator s = ant_services.begin (); s != ant_services.end (); ++s) { @@ -1134,13 +1134,13 @@ static bool has_annotation_selection (const lay::LayoutView *view) return false; } -static AnnotationSelectionIterator begin_annotations_selected (const lay::LayoutView *view) +static AnnotationSelectionIterator begin_annotations_selected (const lay::LayoutViewBase *view) { return AnnotationSelectionIterator (view->get_plugins ()); } static -gsi::ClassExt layout_view_decl2 ( +gsi::ClassExt layout_view_decl2 ( gsi::method_ext ("has_annotation_selection?", &has_annotation_selection, "@brief Returns true, if annotations (rulers) are selected in this view" "\n" diff --git a/src/edt/edt/edt.pro b/src/edt/edt/edt.pro index 5a0ce9312..24075ca3b 100644 --- a/src/edt/edt/edt.pro +++ b/src/edt/edt/edt.pro @@ -77,10 +77,10 @@ SOURCES += \ gsiDeclEdt.cc \ edtDistribute.cc \ -INCLUDEPATH += $$TL_INC $$GSI_INC $$LAYBASIC_INC $$DB_INC -DEPENDPATH += $$TL_INC $$GSI_INC $$LAYBASIC_INC $$DB_INC +INCLUDEPATH += $$TL_INC $$GSI_INC $$LAYBASIC_INC $$LAYVIEW_INC $$DB_INC +DEPENDPATH += $$TL_INC $$GSI_INC $$LAYBASIC_INC $$LAYVIEW_INC $$DB_INC -LIBS += -L$$DESTDIR -lklayout_tl -lklayout_gsi -lklayout_laybasic -lklayout_db +LIBS += -L$$DESTDIR -lklayout_tl -lklayout_gsi -lklayout_laybasic -lklayout_layview -lklayout_db !equals(HAVE_QT, "0") { diff --git a/src/edt/edt/edtEditorOptionsPages.cc b/src/edt/edt/edtEditorOptionsPages.cc index 3ed5b6e20..36c4a253c 100644 --- a/src/edt/edt/edtEditorOptionsPages.cc +++ b/src/edt/edt/edtEditorOptionsPages.cc @@ -70,7 +70,7 @@ static void configure_from_line_edit (lay::Dispatcher *dispatcher, QLineEdit *le // ------------------------------------------------------------------ // EditorOptionsGeneric implementation -EditorOptionsGeneric::EditorOptionsGeneric (lay::LayoutView *view, lay::Dispatcher *dispatcher) +EditorOptionsGeneric::EditorOptionsGeneric (lay::LayoutViewBase *view, lay::Dispatcher *dispatcher) : EditorOptionsPage (view, dispatcher) { mp_ui = new Ui::EditorOptionsGeneric (); @@ -207,7 +207,7 @@ EditorOptionsGeneric::setup (lay::Dispatcher *root) // ------------------------------------------------------------------ // EditorOptionsText implementation -EditorOptionsText::EditorOptionsText (lay::LayoutView *view, lay::Dispatcher *dispatcher) +EditorOptionsText::EditorOptionsText (lay::LayoutViewBase *view, lay::Dispatcher *dispatcher) : lay::EditorOptionsPage (view, dispatcher) { mp_ui = new Ui::EditorOptionsText (); @@ -285,7 +285,7 @@ EditorOptionsText::setup (lay::Dispatcher *root) // ------------------------------------------------------------------ // EditorOptionsPath implementation -EditorOptionsPath::EditorOptionsPath (lay::LayoutView *view, lay::Dispatcher *dispatcher) +EditorOptionsPath::EditorOptionsPath (lay::LayoutViewBase *view, lay::Dispatcher *dispatcher) : lay::EditorOptionsPage (view, dispatcher) { mp_ui = new Ui::EditorOptionsPath (); @@ -386,7 +386,7 @@ EditorOptionsPath::setup (lay::Dispatcher *root) // ------------------------------------------------------------------ // EditorOptionsInst implementation -EditorOptionsInst::EditorOptionsInst (lay::LayoutView *view, lay::Dispatcher *dispatcher) +EditorOptionsInst::EditorOptionsInst (lay::LayoutViewBase *view, lay::Dispatcher *dispatcher) : lay::EditorOptionsPage (view, dispatcher) { mp_ui = new Ui::EditorOptionsInst (); @@ -679,7 +679,7 @@ EditorOptionsInst::setup (lay::Dispatcher *root) // ------------------------------------------------------------------ // EditorOptionsInstPCellParam implementation -EditorOptionsInstPCellParam::EditorOptionsInstPCellParam (lay::LayoutView *view, lay::Dispatcher *dispatcher) +EditorOptionsInstPCellParam::EditorOptionsInstPCellParam (lay::LayoutViewBase *view, lay::Dispatcher *dispatcher) : lay::EditorOptionsPage (view, dispatcher), mp_pcell_parameters (0), mp_placeholder_label (0) { mp_ui = new Ui::EditorOptionsInstPCellParam (); diff --git a/src/edt/edt/edtMainService.cc b/src/edt/edt/edtMainService.cc index 56a5101e6..3ccc53648 100644 --- a/src/edt/edt/edtMainService.cc +++ b/src/edt/edt/edtMainService.cc @@ -1333,7 +1333,7 @@ MainService::cm_convert_to_pcell () if (any_non_converted) { tl::warn << tl::to_string (tr ("Some of the shapes could not be converted to the desired PCell")); #if defined(HAVE_QT) - QMessageBox::warning (view (), tr ("Warning"), tr ("Some of the shapes could not be converted to the desired PCell")); + QMessageBox::warning (view ()->widget (), tr ("Warning"), tr ("Some of the shapes could not be converted to the desired PCell")); #endif } @@ -1812,7 +1812,7 @@ db::DVector compute_alignment_vector (const db::DBox &prim_box, const db::DBox & } static db::DBox -inst_bbox (const db::CplxTrans &tr, lay::LayoutView *view, int cv_index, const db::InstElement &inst_element, bool visible_only) +inst_bbox (const db::CplxTrans &tr, lay::LayoutViewBase *view, int cv_index, const db::InstElement &inst_element, bool visible_only) { db::DBox box; @@ -2385,7 +2385,7 @@ class NewObjectsSelection : public db::ClipboardDataInsertReceiver { public: - NewObjectsSelection (int cv_index, db::cell_index_type topcell, lay::LayoutView *view) + NewObjectsSelection (int cv_index, db::cell_index_type topcell, lay::LayoutViewBase *view) : m_cv_index (cv_index), m_topcell (topcell) { mp_polygon_service = view->get_plugin (); diff --git a/src/img/img/gsiDeclImg.cc b/src/img/img/gsiDeclImg.cc index 13413edfb..01bc8fefa 100644 --- a/src/img/img/gsiDeclImg.cc +++ b/src/img/img/gsiDeclImg.cc @@ -28,7 +28,7 @@ #include "imgService.h" #include "imgStream.h" #include "dbTilingProcessor.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" namespace gsi { @@ -299,8 +299,8 @@ gsi::Class decl_ImageDataMapping ("lay", "ImageDataMapping", class ImageRef; -static void replace_image_base (lay::LayoutView *view, size_t id, ImageRef &new_obj); -static void erase_image_base (lay::LayoutView *view, size_t id); +static void replace_image_base (lay::LayoutViewBase *view, size_t id, ImageRef &new_obj); +static void erase_image_base (lay::LayoutViewBase *view, size_t id); /** * @brief An extension of the img::Object that provides "live" updates of the view @@ -321,7 +321,7 @@ public: // .. nothing yet .. } - ImageRef (const img::Object &other, lay::LayoutView *view) + ImageRef (const img::Object &other, lay::LayoutViewBase *view) : img::Object (other), mp_view (view), dm_update_view (this, &ImageRef::do_update_view) { // .. nothing yet .. @@ -373,10 +373,10 @@ public: template ImageRef transformed (const T &t) const { - return ImageRef (img::Object::transformed (t), const_cast (mp_view.get ())); + return ImageRef (img::Object::transformed (t), const_cast (mp_view.get ())); } - void set_view (lay::LayoutView *view) + void set_view (lay::LayoutViewBase *view) { mp_view.reset (view); } @@ -403,7 +403,7 @@ protected: } private: - tl::weak_ptr mp_view; + tl::weak_ptr mp_view; tl::DeferredMethod dm_update_view; }; @@ -1073,7 +1073,7 @@ public: // .. nothing yet .. } - ImageRefIterator (const img::ImageIterator &iter, lay::LayoutView *view) + ImageRefIterator (const img::ImageIterator &iter, lay::LayoutViewBase *view) : img::ImageIterator (iter), mp_view (view) { // .. nothing yet .. @@ -1081,14 +1081,14 @@ public: reference operator* () const { - return reference (img::ImageIterator::operator* (), const_cast(mp_view.get ())); + return reference (img::ImageIterator::operator* (), const_cast(mp_view.get ())); } private: - tl::weak_ptr mp_view; + tl::weak_ptr mp_view; }; -static void clear_images (lay::LayoutView *view) +static void clear_images (lay::LayoutViewBase *view) { img::Service *img_service = view->get_plugin (); if (img_service) { @@ -1096,7 +1096,7 @@ static void clear_images (lay::LayoutView *view) } } -static void show_image (lay::LayoutView *view, size_t id, bool visible) +static void show_image (lay::LayoutViewBase *view, size_t id, bool visible) { img::Service *img_service = view->get_plugin (); if (img_service) { @@ -1114,7 +1114,7 @@ static void show_image (lay::LayoutView *view, size_t id, bool visible) } } -void replace_image_base (lay::LayoutView *view, size_t id, ImageRef &new_obj) +void replace_image_base (lay::LayoutViewBase *view, size_t id, ImageRef &new_obj) { img::Service *img_service = view->get_plugin (); if (img_service) { @@ -1129,12 +1129,12 @@ void replace_image_base (lay::LayoutView *view, size_t id, ImageRef &new_obj) } } -static void replace_image (lay::LayoutView *view, size_t id, ImageRef &new_obj) +static void replace_image (lay::LayoutViewBase *view, size_t id, ImageRef &new_obj) { replace_image_base (view, id, new_obj); } -void erase_image_base (lay::LayoutView *view, size_t id) +void erase_image_base (lay::LayoutViewBase *view, size_t id) { img::Service *img_service = view->get_plugin (); if (img_service) { @@ -1149,12 +1149,12 @@ void erase_image_base (lay::LayoutView *view, size_t id) } } -static void erase_image (lay::LayoutView *view, size_t id) +static void erase_image (lay::LayoutViewBase *view, size_t id) { erase_image_base (view, id); } -static void insert_image (lay::LayoutView *view, ImageRef &obj) +static void insert_image (lay::LayoutViewBase *view, ImageRef &obj) { if (obj.is_valid ()) { throw tl::Exception (tl::to_string (tr ("The object is already inserted into a view - detach the object first or create a different object."))); @@ -1168,7 +1168,7 @@ static void insert_image (lay::LayoutView *view, ImageRef &obj) } } -static ImageRef get_image (lay::LayoutView *view, size_t id) +static ImageRef get_image (lay::LayoutViewBase *view, size_t id) { img::Service *img_service = view->get_plugin (); if (img_service) { @@ -1181,28 +1181,28 @@ static ImageRef get_image (lay::LayoutView *view, size_t id) return ImageRef (); } -static tl::Event &get_images_changed_event (lay::LayoutView *view) +static tl::Event &get_images_changed_event (lay::LayoutViewBase *view) { img::Service *img_service = view->get_plugin (); tl_assert (img_service != 0); return img_service->images_changed_event; } -static tl::Event &get_image_selection_changed_event (lay::LayoutView *view) +static tl::Event &get_image_selection_changed_event (lay::LayoutViewBase *view) { img::Service *img_service = view->get_plugin (); tl_assert (img_service != 0); return img_service->image_selection_changed_event; } -static tl::event &get_image_changed_event (lay::LayoutView *view) +static tl::event &get_image_changed_event (lay::LayoutViewBase *view) { img::Service *img_service = view->get_plugin (); tl_assert (img_service != 0); return img_service->image_changed_event; } -static ImageRefIterator begin_images (lay::LayoutView *view) +static ImageRefIterator begin_images (lay::LayoutViewBase *view) { img::Service *img_service = view->get_plugin (); if (img_service) { @@ -1213,7 +1213,7 @@ static ImageRefIterator begin_images (lay::LayoutView *view) } static -gsi::ClassExt layout_view_decl ( +gsi::ClassExt layout_view_decl ( gsi::method_ext ("clear_images", &gsi::clear_images, "@brief Clear all images on this view" ) + @@ -1342,7 +1342,7 @@ private: // extend the layout view by "edtService" specific methods -static bool has_image_selection (const lay::LayoutView *view) +static bool has_image_selection (const lay::LayoutViewBase *view) { std::vector img = view->get_plugins (); for (std::vector::const_iterator s = img.begin (); s != img.end (); ++s) { @@ -1353,14 +1353,14 @@ static bool has_image_selection (const lay::LayoutView *view) return false; } -static SelectionIterator begin_images_selected (const lay::LayoutView *view) +static SelectionIterator begin_images_selected (const lay::LayoutViewBase *view) { return SelectionIterator (view->get_plugins ()); } static -gsi::ClassExt layout_view_decl2 ( +gsi::ClassExt layout_view_decl2 ( gsi::method_ext ("has_image_selection?", &has_image_selection, "@brief Returns true, if images are selected in this view" "\n" diff --git a/src/img/img/img.pro b/src/img/img/img.pro index 4bfd510ab..89d40ba90 100644 --- a/src/img/img/img.pro +++ b/src/img/img/img.pro @@ -47,7 +47,15 @@ SOURCES += \ imgForceLink.cc \ imgStream.cc -INCLUDEPATH += $$TL_INC $$DB_INC $$GSI_INC $$LAYBASIC_INC $$DB_INC -DEPENDPATH += $$TL_INC $$DB_INC $$GSI_INC $$LAYBASIC_INC $$DB_INC -LIBS += -L$$DESTDIR -lklayout_tl -lklayout_db -lklayout_gsi -lklayout_laybasic -lklayout_db +INCLUDEPATH += $$TL_INC $$DB_INC $$GSI_INC $$LAYBASIC_INC $$LAYVIEW_INC $$DB_INC +DEPENDPATH += $$TL_INC $$DB_INC $$GSI_INC $$LAYBASIC_INC $$LAYVIEW_INC $$DB_INC +LIBS += -L$$DESTDIR -lklayout_tl -lklayout_db -lklayout_gsi -lklayout_laybasic -lklayout_layview -lklayout_db +!equals(HAVE_QT, "0") { + + INCLUDEPATH += $$LAYUI_INC + DEPENDPATH += $$LAYUI_INC + + LIBS += -lklayout_layui + +} diff --git a/src/img/img/imgLandmarksDialog.cc b/src/img/img/imgLandmarksDialog.cc index 25bb29e0d..4be4ba291 100644 --- a/src/img/img/imgLandmarksDialog.cc +++ b/src/img/img/imgLandmarksDialog.cc @@ -145,7 +145,7 @@ class LandmarkEditorService : public lay::ViewService { public: - LandmarkEditorService (lay::LayoutView *view, img::Object *img) + LandmarkEditorService (lay::LayoutViewBase *view, img::Object *img) : lay::ViewService (view->view_object_widget ()), mp_image (img), m_selected (-1), m_dragging (false), m_mode (LandmarksDialog::None) diff --git a/src/img/img/imgNavigator.h b/src/img/img/imgNavigator.h index 013d9a530..e9c70ffdc 100644 --- a/src/img/img/imgNavigator.h +++ b/src/img/img/imgNavigator.h @@ -55,7 +55,7 @@ public: void background_color (QColor c); img::Object *setup (lay::Dispatcher *root, img::Object *img); - lay::LayoutView *view () + lay::LayoutView *view () { return mp_view; } @@ -63,7 +63,7 @@ public: void activate_service (lay::ViewService *service); private: - lay::LayoutView *mp_view; + lay::LayoutView *mp_view; lay::ZoomService *mp_zoom_service; }; diff --git a/src/img/img/imgService.cc b/src/img/img/imgService.cc index 4ae8ff5ac..de9fd331f 100644 --- a/src/img/img/imgService.cc +++ b/src/img/img/imgService.cc @@ -30,7 +30,7 @@ #include "layPlugin.h" #include "layRenderer.h" #include "laySnap.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "laybasicConfig.h" #if defined(HAVE_QT) # include "layProperties.h" @@ -409,7 +409,7 @@ View::render (const lay::Viewport &vp, lay::ViewObjectCanvas &canvas) // ------------------------------------------------------------- // img::Service implementation -Service::Service (db::Manager *manager, lay::LayoutView *view) +Service::Service (db::Manager *manager, lay::LayoutViewBase *view) : lay::BackgroundViewObject (view->view_object_widget ()), lay::Editable (view), lay::Plugin (view), diff --git a/src/img/img/imgService.h b/src/img/img/imgService.h index 56f70fda6..9379c9b49 100644 --- a/src/img/img/imgService.h +++ b/src/img/img/imgService.h @@ -203,7 +203,7 @@ public: typedef lay::AnnotationShapes::iterator obj_iterator; enum MoveMode { move_none, move_selected, move_landmark, move_l, move_r, move_t, move_b, move_lr, move_tr, move_ll, move_tl, move_all }; - Service (db::Manager *manager, lay::LayoutView *view); + Service (db::Manager *manager, lay::LayoutViewBase *view); ~Service (); @@ -434,7 +434,7 @@ public: /** * @brief Access to the view object */ - lay::LayoutView *view () const + lay::LayoutViewBase *view () const { return mp_view; } @@ -482,7 +482,7 @@ public: private: // The layout view that the image service is attached to - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; // The view objects representing the selection and the moved images in move mode std::vector m_selected_image_views; diff --git a/src/lay/lay/lay.pro b/src/lay/lay/lay.pro index dea36e8e7..71bd193f7 100644 --- a/src/lay/lay/lay.pro +++ b/src/lay/lay/lay.pro @@ -56,7 +56,6 @@ HEADERS = \ laySignalHandler.h \ layLibraryController.h \ layFontController.h \ - layNativePlugin.h \ laySystemPaths.h \ layMacroEditorSetupPage.h \ layPasswordDialog.h \ @@ -164,7 +163,6 @@ SOURCES = \ laySignalHandler.cc \ layLibraryController.cc \ layFontController.cc \ - layNativePlugin.cc \ laySystemPaths.cc \ layMacroEditorSetupPage.cc \ layPasswordDialog.cc \ @@ -179,9 +177,9 @@ RESOURCES = layBuildInMacros.qrc \ laySaltTemplates.qrc \ layDRCLVSHelpResources.qrc -INCLUDEPATH += $$TL_INC $$GSI_INC $$DB_INC $$RDB_INC $$LAYBASIC_INC $$ANT_INC $$IMG_INC $$EDT_INC $$LYM_INC -DEPENDPATH += $$TL_INC $$GSI_INC $$DB_INC $$RDB_INC $$LAYBASIC_INC $$ANT_INC $$IMG_INC $$EDT_INC $$LYM_INC -LIBS += -L$$DESTDIR -lklayout_tl -lklayout_gsi -lklayout_db -lklayout_rdb -lklayout_lym -lklayout_laybasic -lklayout_ant -lklayout_img -lklayout_edt +INCLUDEPATH += $$TL_INC $$GSI_INC $$DB_INC $$RDB_INC $$LAYBASIC_INC $$LAYUI_INC $$LAYVIEW_INC $$ANT_INC $$IMG_INC $$EDT_INC $$LYM_INC +DEPENDPATH += $$TL_INC $$GSI_INC $$DB_INC $$RDB_INC $$LAYBASIC_INC $$LAYUI_INC $$LAYVIEW_INC $$ANT_INC $$IMG_INC $$EDT_INC $$LYM_INC +LIBS += -L$$DESTDIR -lklayout_tl -lklayout_gsi -lklayout_db -lklayout_rdb -lklayout_lym -lklayout_laybasic -lklayout_layview -lklayout_layui -lklayout_ant -lklayout_img -lklayout_edt win32 { # for stack trace support: diff --git a/src/lay/lay/layClipDialog.cc b/src/lay/lay/layClipDialog.cc index 88a3102c7..2c28187e0 100644 --- a/src/lay/lay/layClipDialog.cc +++ b/src/lay/lay/layClipDialog.cc @@ -66,7 +66,7 @@ static tl::RegisteredClass config_decl (new ClipDialogPl // ------------------------------------------------------------ -ClipDialog::ClipDialog (lay::Dispatcher *root, LayoutView *vw) +ClipDialog::ClipDialog (lay::Dispatcher *root, LayoutViewBase *vw) : lay::Browser (root, vw), Ui::ClipDialog () { diff --git a/src/lay/lay/layClipDialog.h b/src/lay/lay/layClipDialog.h index bab730bf9..e84ad2435 100644 --- a/src/lay/lay/layClipDialog.h +++ b/src/lay/lay/layClipDialog.h @@ -40,7 +40,7 @@ class ClipDialog Q_OBJECT public: - ClipDialog (lay::Dispatcher *root, lay::LayoutView *view); + ClipDialog (lay::Dispatcher *root, lay::LayoutViewBase *view); ~ClipDialog (); public slots: diff --git a/src/lay/lay/layFillDialog.cc b/src/lay/lay/layFillDialog.cc index 8e3c2cd33..458c90afa 100644 --- a/src/lay/lay/layFillDialog.cc +++ b/src/lay/lay/layFillDialog.cc @@ -73,7 +73,7 @@ static tl::RegisteredClass config_decl (new FillDialogPl // ------------------------------------------------------------ -FillDialog::FillDialog (lay::Dispatcher *main, LayoutView *view) +FillDialog::FillDialog (lay::Dispatcher *main, LayoutViewBase *view) : QDialog (view->widget ()), lay::Plugin (main), Ui::FillDialog (), diff --git a/src/lay/lay/layFillDialog.h b/src/lay/lay/layFillDialog.h index 52deb5826..faa06851a 100644 --- a/src/lay/lay/layFillDialog.h +++ b/src/lay/lay/layFillDialog.h @@ -76,7 +76,7 @@ class LAY_PUBLIC FillDialog Q_OBJECT public: - FillDialog (lay::Dispatcher *root, lay::LayoutView *view); + FillDialog (lay::Dispatcher *root, lay::LayoutViewBase *view); ~FillDialog (); public slots: @@ -95,7 +95,7 @@ private: void generate_fill (const FillParameters &fp); FillParameters get_fill_parameters (); - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; }; } diff --git a/src/lay/lay/laySearchReplaceDialog.cc b/src/lay/lay/laySearchReplaceDialog.cc index f2f46bdb2..76dd57c08 100644 --- a/src/lay/lay/laySearchReplaceDialog.cc +++ b/src/lay/lay/laySearchReplaceDialog.cc @@ -699,7 +699,7 @@ fill_ctx_cbx (QComboBox *cbx) cbx->addItem (QObject::tr ("All cells")); } -SearchReplaceDialog::SearchReplaceDialog (lay::Dispatcher *root, lay::LayoutView *view) +SearchReplaceDialog::SearchReplaceDialog (lay::Dispatcher *root, LayoutViewBase *view) : lay::Browser (root, view), Ui::SearchReplaceDialog (), mp_view (view), diff --git a/src/lay/lay/laySearchReplaceDialog.h b/src/lay/lay/laySearchReplaceDialog.h index ae0223f85..3ad00e469 100644 --- a/src/lay/lay/laySearchReplaceDialog.h +++ b/src/lay/lay/laySearchReplaceDialog.h @@ -164,7 +164,7 @@ public: std::string text; }; - SearchReplaceDialog (lay::Dispatcher *root, lay::LayoutView *view); + SearchReplaceDialog (lay::Dispatcher *root, lay::LayoutViewBase *view); ~SearchReplaceDialog (); private: @@ -174,7 +174,7 @@ private: // implementation of the lay::Plugin interface void menu_activated (const std::string &symbol); - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; std::vector m_mru; std::vector m_saved; int m_current_mode; diff --git a/src/lay/lay/laySearchReplacePropertiesWidgets.cc b/src/lay/lay/laySearchReplacePropertiesWidgets.cc index 26263b288..f8aa33081 100644 --- a/src/lay/lay/laySearchReplacePropertiesWidgets.cc +++ b/src/lay/lay/laySearchReplacePropertiesWidgets.cc @@ -320,7 +320,7 @@ class SearchInstanceProperties private Ui::SearchPropertiesInstance { public: - SearchInstanceProperties (QStackedWidget *sw, lay::LayoutView * /*view*/, int /*cv_index*/) + SearchInstanceProperties (QStackedWidget *sw, lay::LayoutViewBase * /*view*/, int /*cv_index*/) : SearchPropertiesWidget (sw) { setupUi (this); @@ -377,7 +377,7 @@ class SearchShapeProperties protected Ui::SearchPropertiesShape { public: - SearchShapeProperties (QStackedWidget *sw, lay::LayoutView *view, int cv_index) + SearchShapeProperties (QStackedWidget *sw, lay::LayoutViewBase *view, int cv_index) : SearchPropertiesWidget (sw) { setupUi (this); @@ -449,7 +449,7 @@ class SearchPolygonProperties : public SearchShapeProperties { public: - SearchPolygonProperties (QStackedWidget *sw, lay::LayoutView *view, int cv_index) + SearchPolygonProperties (QStackedWidget *sw, lay::LayoutViewBase *view, int cv_index) : SearchShapeProperties (sw, view, cv_index) { // .. nothing yet .. @@ -518,7 +518,7 @@ class SearchBoxProperties private Ui::SearchPropertiesBox { public: - SearchBoxProperties (QStackedWidget *sw, lay::LayoutView *view, int cv_index) + SearchBoxProperties (QStackedWidget *sw, lay::LayoutViewBase *view, int cv_index) : SearchPropertiesWidget (sw) { setupUi (this); @@ -593,7 +593,7 @@ class SearchPathProperties private Ui::SearchPropertiesPath { public: - SearchPathProperties (QStackedWidget *sw, lay::LayoutView *view, int cv_index) + SearchPathProperties (QStackedWidget *sw, lay::LayoutViewBase *view, int cv_index) : SearchPropertiesWidget (sw) { setupUi (this); @@ -666,7 +666,7 @@ class SearchTextProperties private Ui::SearchPropertiesText { public: - SearchTextProperties (QStackedWidget *sw, lay::LayoutView *view, int cv_index) + SearchTextProperties (QStackedWidget *sw, lay::LayoutViewBase *view, int cv_index) : SearchPropertiesWidget (sw) { setupUi (this); @@ -748,7 +748,7 @@ class ReplaceInstanceProperties private Ui::ReplacePropertiesInstance { public: - ReplaceInstanceProperties (QStackedWidget *sw, lay::LayoutView * /*view*/, int /*cv_index*/) + ReplaceInstanceProperties (QStackedWidget *sw, lay::LayoutViewBase * /*view*/, int /*cv_index*/) : ReplacePropertiesWidget (sw) { setupUi (this); @@ -787,7 +787,7 @@ class ReplaceShapeProperties protected Ui::ReplacePropertiesShape { public: - ReplaceShapeProperties (QStackedWidget *sw, lay::LayoutView *view, int cv_index) + ReplaceShapeProperties (QStackedWidget *sw, lay::LayoutViewBase *view, int cv_index) : ReplacePropertiesWidget (sw) { setupUi (this); @@ -828,7 +828,7 @@ class ReplacePolygonProperties : public ReplaceShapeProperties { public: - ReplacePolygonProperties (QStackedWidget *sw, lay::LayoutView *view, int cv_index) + ReplacePolygonProperties (QStackedWidget *sw, lay::LayoutViewBase *view, int cv_index) : ReplaceShapeProperties (sw, view, cv_index) { // .. nothing yet .. @@ -867,7 +867,7 @@ class ReplaceBoxProperties private Ui::ReplacePropertiesBox { public: - ReplaceBoxProperties (QStackedWidget *sw, lay::LayoutView *view, int cv_index) + ReplaceBoxProperties (QStackedWidget *sw, lay::LayoutViewBase *view, int cv_index) : ReplacePropertiesWidget (sw) { setupUi (this); @@ -919,7 +919,7 @@ class ReplacePathProperties private Ui::ReplacePropertiesPath { public: - ReplacePathProperties (QStackedWidget *sw, lay::LayoutView *view, int cv_index) + ReplacePathProperties (QStackedWidget *sw, lay::LayoutViewBase *view, int cv_index) : ReplacePropertiesWidget (sw) { setupUi (this); @@ -966,7 +966,7 @@ class ReplaceTextProperties private Ui::ReplacePropertiesText { public: - ReplaceTextProperties (QStackedWidget *sw, lay::LayoutView *view, int cv_index) + ReplaceTextProperties (QStackedWidget *sw, lay::LayoutViewBase *view, int cv_index) : ReplacePropertiesWidget (sw) { setupUi (this); @@ -1018,7 +1018,7 @@ public: // ---------------------------------------------------------------------------- -void fill_find_pages (QStackedWidget *sw, lay::LayoutView *view, int cv_index) +void fill_find_pages (QStackedWidget *sw, lay::LayoutViewBase *view, int cv_index) { while (sw->count () > 0) { sw->removeWidget (sw->widget (0)); @@ -1031,7 +1031,7 @@ void fill_find_pages (QStackedWidget *sw, lay::LayoutView *view, int cv_index) sw->addWidget (new SearchTextProperties (sw, view, cv_index)); } -void fill_replace_pages (QStackedWidget *sw, lay::LayoutView *view, int cv_index) +void fill_replace_pages (QStackedWidget *sw, lay::LayoutViewBase *view, int cv_index) { while (sw->count () > 0) { sw->removeWidget (sw->widget (0)); diff --git a/src/lay/lay/laySearchReplacePropertiesWidgets.h b/src/lay/lay/laySearchReplacePropertiesWidgets.h index 0d4b0d235..59c47bfd6 100644 --- a/src/lay/lay/laySearchReplacePropertiesWidgets.h +++ b/src/lay/lay/laySearchReplacePropertiesWidgets.h @@ -86,12 +86,12 @@ public: /** * @brief Fill the given stack widget with pairs of items plus properties widget */ -void fill_find_pages (QStackedWidget *sw, lay::LayoutView *view, int cv_index); +void fill_find_pages (QStackedWidget *sw, lay::LayoutViewBase *view, int cv_index); /** * @brief Fill the given stack widget with pairs of items plus properties widget */ -void fill_replace_pages (QStackedWidget *sw, lay::LayoutView *view, int cv_index); +void fill_replace_pages (QStackedWidget *sw, lay::LayoutViewBase *view, int cv_index); /** * @brief Get an object id from a page index diff --git a/src/lay/unit_tests/unit_tests.pro b/src/lay/unit_tests/unit_tests.pro index dc5315166..2452b866f 100644 --- a/src/lay/unit_tests/unit_tests.pro +++ b/src/lay/unit_tests/unit_tests.pro @@ -10,8 +10,8 @@ SOURCES = \ laySalt.cc \ laySessionTests.cc -INCLUDEPATH += $$LAY_INC $$TL_INC $$LAYBASIC_INC $$DB_INC $$GSI_INC $$ANT_INC $$IMG_INC $$RDB_INC -DEPENDPATH += $$LAY_INC $$TL_INC $$LAYBASIC_INC $$DB_INC $$GSI_INC $$ANT_INC $$IMG_INC $$RDB_INC +INCLUDEPATH += $$LAY_INC $$TL_INC $$LAYBASIC_INC $$LAYUI_INC $$LAYVIEW_INC $$DB_INC $$GSI_INC $$ANT_INC $$IMG_INC $$RDB_INC +DEPENDPATH += $$LAY_INC $$TL_INC $$LAYBASIC_INC $$LAYUI_INC $$LAYVIEW_INC $$DB_INC $$GSI_INC $$ANT_INC $$IMG_INC $$RDB_INC -LIBS += -L$$DESTDIR_UT -lklayout_lay -lklayout_laybasic -lklayout_db -lklayout_tl -lklayout_gsi -lklayout_ant -lklayout_img -lklayout_rdb +LIBS += -L$$DESTDIR_UT -lklayout_lay -lklayout_laybasic -lklayout_layui -lklayout_layview -lklayout_db -lklayout_tl -lklayout_gsi -lklayout_ant -lklayout_img -lklayout_rdb diff --git a/src/laybasic/laybasic/gsiDeclLayLayoutViewBase.cc b/src/laybasic/laybasic/gsiDeclLayLayoutViewBase.cc index 3efa7cd32..765271b88 100644 --- a/src/laybasic/laybasic/gsiDeclLayLayoutViewBase.cc +++ b/src/laybasic/laybasic/gsiDeclLayLayoutViewBase.cc @@ -462,9 +462,9 @@ static LayerPropertiesConstIteratorWrapper each_layer2 (lay::LayoutViewBase *vie } #if defined(HAVE_QT) -Class decl_LayoutViewBase (QT_EXTERNAL_BASE (QWidget) "lay", "LayoutViewBase", +LAYBASIC_PUBLIC Class decl_LayoutViewBase (QT_EXTERNAL_BASE (QWidget) "lay", "LayoutViewBase", #else -Class decl_LayoutViewBase (QT_EXTERNAL_BASE (QWidget) "lay", "LayoutViewBase", +LAYBASIC_PUBLIC Class decl_LayoutViewBase (QT_EXTERNAL_BASE (QWidget) "lay", "LayoutViewBase", #endif gsi::constant ("LV_NoLayers", (unsigned int) lay::LayoutViewBase::LV_NoLayers, "@brief With this option, no layers view will be provided (see \\layer_control_frame)\n" diff --git a/src/laybasic/laybasic/layFixedFont.h b/src/laybasic/laybasic/layFixedFont.h index fecff4abe..8803a4fe8 100644 --- a/src/laybasic/laybasic/layFixedFont.h +++ b/src/laybasic/laybasic/layFixedFont.h @@ -3,6 +3,8 @@ #ifndef HDR_layFixedFont #define HDR_layFixedFont +#include "laybasicCommon.h" + #include namespace lay @@ -12,7 +14,7 @@ namespace lay * @brief A descriptor class for a fixed font */ -class FixedFont +class LAYBASIC_PUBLIC FixedFont { public: /** diff --git a/src/laybasic/laybasic/layLayoutCanvas.h b/src/laybasic/laybasic/layLayoutCanvas.h index 9e6a2f169..c66ac1fcd 100644 --- a/src/laybasic/laybasic/layLayoutCanvas.h +++ b/src/laybasic/laybasic/layLayoutCanvas.h @@ -24,11 +24,7 @@ #ifndef HDR_layLayoutCanvas #define HDR_layLayoutCanvas -#include -#include -#include -#include - +#include "laybasicCommon.h" #include "dbTrans.h" #include "dbBox.h" #include "layViewport.h" @@ -44,6 +40,11 @@ #include "tlDeferredExecution.h" #include "tlThreads.h" +#include +#include +#include +#include + namespace lay { @@ -132,7 +133,7 @@ private: * and to manage the auxiliary objects like rulers etc. */ -class LayoutCanvas +class LAYBASIC_PUBLIC LayoutCanvas : public lay::ViewObjectWidget, public lay::BitmapViewObjectCanvas, public lay::BitmapRedrawThreadCanvas, diff --git a/src/laybasic/laybasic/layMove.h b/src/laybasic/laybasic/layMove.h index 3908c6505..e46162970 100644 --- a/src/laybasic/laybasic/layMove.h +++ b/src/laybasic/laybasic/layMove.h @@ -23,6 +23,7 @@ #ifndef HDR_layMove #define HDR_layMove +#include "laybasicCommon.h" #include "dbManager.h" #include "layViewObject.h" @@ -33,7 +34,7 @@ namespace lay { class Editables; class LayoutViewBase; -class MoveService : +class LAYBASIC_PUBLIC MoveService : public lay::ViewService { public: diff --git a/src/lay/lay/layNativePlugin.cc b/src/laybasic/laybasic/layNativePlugin.cc similarity index 100% rename from src/lay/lay/layNativePlugin.cc rename to src/laybasic/laybasic/layNativePlugin.cc diff --git a/src/lay/lay/layNativePlugin.h b/src/laybasic/laybasic/layNativePlugin.h similarity index 84% rename from src/lay/lay/layNativePlugin.h rename to src/laybasic/laybasic/layNativePlugin.h index c3922bc70..b57c2b201 100644 --- a/src/lay/lay/layNativePlugin.h +++ b/src/laybasic/laybasic/layNativePlugin.h @@ -23,7 +23,7 @@ #ifndef HDR_layNativePlugin #define HDR_layNativePlugin -#include "layCommon.h" +#include "laybasicCommon.h" /** * @brief A struct to hold the data of the plugin @@ -84,12 +84,12 @@ struct klp_method_t { }; * @brief The gsi API functions wrapped for the native API */ extern "C" { - LAY_PUBLIC const klp_class_t *klp_class_by_name (const char *name); - LAY_PUBLIC void *klp_create (const klp_class_t *cls); - LAY_PUBLIC void klp_destroy (const klp_class_t *cls, void *obj); - LAY_PUBLIC void *klp_clone (const klp_class_t *cls, const void *source); - LAY_PUBLIC void klp_assign (const klp_class_t *cls, void *target, const void *source); - LAY_PUBLIC void klp_require_api_version (const char *version); + LAYBASIC_PUBLIC const klp_class_t *klp_class_by_name (const char *name); + LAYBASIC_PUBLIC void *klp_create (const klp_class_t *cls); + LAYBASIC_PUBLIC void klp_destroy (const klp_class_t *cls, void *obj); + LAYBASIC_PUBLIC void *klp_clone (const klp_class_t *cls, const void *source); + LAYBASIC_PUBLIC void klp_assign (const klp_class_t *cls, void *target, const void *source); + LAYBASIC_PUBLIC void klp_require_api_version (const char *version); } diff --git a/src/laybasic/laybasic/laybasic.pro b/src/laybasic/laybasic/laybasic.pro index 10ed41dd5..33b10cf08 100644 --- a/src/laybasic/laybasic/laybasic.pro +++ b/src/laybasic/laybasic/laybasic.pro @@ -61,6 +61,7 @@ SOURCES += \ layMarker.cc \ layMouseTracker.cc \ layMove.cc \ + layNativePlugin.cc \ layNetColorizer.cc \ layObjectInstPath.cc \ layParsedLayerSource.cc \ @@ -112,6 +113,7 @@ HEADERS += \ layMarker.h \ layMouseTracker.h \ layMove.h \ + layNativePlugin.h \ layNetColorizer.h \ layObjectInstPath.h \ layParsedLayerSource.h \ diff --git a/src/layui/layui/layBookmarkManagementForm.h b/src/layui/layui/layBookmarkManagementForm.h index 6973bf11f..ba437c862 100644 --- a/src/layui/layui/layBookmarkManagementForm.h +++ b/src/layui/layui/layBookmarkManagementForm.h @@ -27,6 +27,7 @@ #include +#include "layuiCommon.h" #include "layLayoutViewBase.h" #include @@ -39,7 +40,7 @@ namespace Ui namespace lay { -class BookmarkManagementForm +class LAYUI_PUBLIC BookmarkManagementForm : public QDialog { Q_OBJECT diff --git a/src/layui/layui/layCellSelectionForm.cc b/src/layui/layui/layCellSelectionForm.cc index c9496b4b0..17c9ede28 100644 --- a/src/layui/layui/layCellSelectionForm.cc +++ b/src/layui/layui/layCellSelectionForm.cc @@ -40,6 +40,9 @@ #include "layLayoutViewBase.h" #include "tlExceptions.h" +#include "ui_CellSelectionForm.h" +#include "ui_LibraryCellSelectionForm.h" + #include namespace lay @@ -51,7 +54,7 @@ static const std::string cfg_cell_selection_search_use_expressions ("cell-select // ------------------------------------------------------------ CellSelectionForm::CellSelectionForm (QWidget *parent, LayoutViewBase *view, const char *name, bool simple_mode) - : QDialog (parent), Ui::CellSelectionForm (), + : QDialog (parent), mp_view (view), m_current_cv (-1), m_name_cb_enabled (true), @@ -61,11 +64,12 @@ CellSelectionForm::CellSelectionForm (QWidget *parent, LayoutViewBase *view, con m_update_all_dm (this, &CellSelectionForm::update_all), m_simple_mode (simple_mode) { + mp_ui = new Ui::CellSelectionForm (); setObjectName (QString::fromUtf8 (name)); - Ui::CellSelectionForm::setupUi (this); + mp_ui->setupUi (this); - le_cell_name->set_tab_signal_enabled (true); + mp_ui->le_cell_name->set_tab_signal_enabled (true); mp_use_regular_expressions = new QAction (this); mp_use_regular_expressions->setCheckable (true); @@ -86,33 +90,33 @@ CellSelectionForm::CellSelectionForm (QWidget *parent, LayoutViewBase *view, con mp_use_regular_expressions->setChecked (ue); } - QMenu *m = new QMenu (le_cell_name); + QMenu *m = new QMenu (mp_ui->le_cell_name); m->addAction (mp_use_regular_expressions); m->addAction (mp_case_sensitive); connect (mp_use_regular_expressions, SIGNAL (triggered ()), this, SLOT (name_changed ())); connect (mp_case_sensitive, SIGNAL (triggered ()), this, SLOT (name_changed ())); - le_cell_name->set_clear_button_enabled (true); - le_cell_name->set_options_button_enabled (true); - le_cell_name->set_options_menu (m); + mp_ui->le_cell_name->set_clear_button_enabled (true); + mp_ui->le_cell_name->set_options_button_enabled (true); + mp_ui->le_cell_name->set_options_menu (m); // signals and slots connections - connect (cancel_button, SIGNAL(clicked()), this, SLOT(reject())); - connect (cb_views, SIGNAL(activated(int)), this, SLOT(view_changed(int))); - connect (tb_set_parent, SIGNAL(clicked()), this, SLOT(set_parent())); - connect (tb_set_child, SIGNAL(clicked()), this, SLOT(set_child())); - connect (pb_hide, SIGNAL(clicked()), this, SLOT(hide_cell())); - connect (pb_show, SIGNAL(clicked()), this, SLOT(show_cell())); - connect (le_cell_name, SIGNAL(textChanged(const QString&)), this, SLOT(name_changed())); - connect (ok_button, SIGNAL(clicked()), this, SLOT(accept())); - connect (apply_button, SIGNAL(clicked()), this, SLOT(apply_clicked())); - connect (find_next, SIGNAL(clicked()), this, SLOT(find_next_clicked())); - connect (le_cell_name, SIGNAL(tab_pressed()), this, SLOT(find_next_clicked())); - connect (le_cell_name, SIGNAL(backtab_pressed()), this, SLOT(find_prev_clicked())); + connect (mp_ui->cancel_button, SIGNAL(clicked()), this, SLOT(reject())); + connect (mp_ui->cb_views, SIGNAL(activated(int)), this, SLOT(view_changed(int))); + connect (mp_ui->tb_set_parent, SIGNAL(clicked()), this, SLOT(set_parent())); + connect (mp_ui->tb_set_child, SIGNAL(clicked()), this, SLOT(set_child())); + connect (mp_ui->pb_hide, SIGNAL(clicked()), this, SLOT(hide_cell())); + connect (mp_ui->pb_show, SIGNAL(clicked()), this, SLOT(show_cell())); + connect (mp_ui->le_cell_name, SIGNAL(textChanged(const QString&)), this, SLOT(name_changed())); + connect (mp_ui->ok_button, SIGNAL(clicked()), this, SLOT(accept())); + connect (mp_ui->apply_button, SIGNAL(clicked()), this, SLOT(apply_clicked())); + connect (mp_ui->find_next, SIGNAL(clicked()), this, SLOT(find_next_clicked())); + connect (mp_ui->le_cell_name, SIGNAL(tab_pressed()), this, SLOT(find_next_clicked())); + connect (mp_ui->le_cell_name, SIGNAL(backtab_pressed()), this, SLOT(find_prev_clicked())); - connect (lv_parents, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(parent_changed(const QModelIndex &))); - connect (lv_children, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(child_changed(const QModelIndex &))); + connect (mp_ui->lv_parents, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(parent_changed(const QModelIndex &))); + connect (mp_ui->lv_children, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(child_changed(const QModelIndex &))); m_cellviews.reserve (mp_view->cellviews ()); @@ -121,11 +125,11 @@ CellSelectionForm::CellSelectionForm (QWidget *parent, LayoutViewBase *view, con } if (simple_mode) { - apply_button->hide (); - tools_frame->hide (); + mp_ui->apply_button->hide (); + mp_ui->tools_frame->hide (); } else { - apply_button->show (); - tools_frame->show (); + mp_ui->apply_button->show (); + mp_ui->tools_frame->show (); } if (! m_cellviews.empty ()) { @@ -134,26 +138,26 @@ CellSelectionForm::CellSelectionForm (QWidget *parent, LayoutViewBase *view, con int cvi = 0; for (std::vector::const_iterator cv = m_cellviews.begin (); cv != m_cellviews.end (); ++cv, ++cvi) { - cb_views->addItem (tl::to_qstring ((*cv)->name () + " (@" + tl::to_string (cvi + 1) + ")")); + mp_ui->cb_views->addItem (tl::to_qstring ((*cv)->name () + " (@" + tl::to_string (cvi + 1) + ")")); } - cb_views->setCurrentIndex (m_current_cv); + mp_ui->cb_views->setCurrentIndex (m_current_cv); if (m_cellviews.size () == 1) { - cb_views->hide (); - layout_lbl->hide (); + mp_ui->cb_views->hide (); + mp_ui->layout_lbl->hide (); } else { - cb_views->show (); - layout_lbl->show (); + mp_ui->cb_views->show (); + mp_ui->layout_lbl->show (); } - lv_cells->header ()->hide (); - lv_cells->setRootIsDecorated (false); + mp_ui->lv_cells->header ()->hide (); + mp_ui->lv_cells->setRootIsDecorated (false); - lv_children->header ()->hide (); - lv_children->setRootIsDecorated (false); + mp_ui->lv_children->header ()->hide (); + mp_ui->lv_children->setRootIsDecorated (false); - lv_parents->header ()->hide (); - lv_parents->setRootIsDecorated (false); + mp_ui->lv_parents->header ()->hide (); + mp_ui->lv_parents->setRootIsDecorated (false); update_cell_list (); @@ -168,15 +172,15 @@ CellSelectionForm::update_cell_list () return; } - if (lv_cells->model ()) { - delete lv_cells->model (); + if (mp_ui->lv_cells->model ()) { + delete mp_ui->lv_cells->model (); } - lay::CellTreeModel *model = new lay::CellTreeModel (lv_cells, mp_view, m_current_cv, lay::CellTreeModel::Flat); + lay::CellTreeModel *model = new lay::CellTreeModel (mp_ui->lv_cells, mp_view, m_current_cv, lay::CellTreeModel::Flat); - lv_cells->setModel (model); + mp_ui->lv_cells->setModel (model); // connect can only happen after setModel() - connect (lv_cells->selectionModel (), SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(cell_changed(const QModelIndex &, const QModelIndex &))); + connect (mp_ui->lv_cells->selectionModel (), SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(cell_changed(const QModelIndex &, const QModelIndex &))); lay::CellView::unspecific_cell_path_type path (m_cellviews [m_current_cv].combined_unspecific_path ()); if (! path.empty ()) { @@ -191,13 +195,13 @@ CellSelectionForm::update_parents_list () if (m_current_cv >= 0 && m_current_cv < int (m_cellviews.size ())) { - lay::CellTreeModel *model = dynamic_cast (lv_cells->model ()); + lay::CellTreeModel *model = dynamic_cast (mp_ui->lv_cells->model ()); if (model) { - if (lv_parents->model ()) { - delete lv_parents->model (); + if (mp_ui->lv_parents->model ()) { + delete mp_ui->lv_parents->model (); } - lv_parents->setModel (new lay::CellTreeModel (lv_parents, mp_view, m_current_cv, lay::CellTreeModel::Flat | lay::CellTreeModel::Parents, model->cell (lv_cells->selectionModel ()->currentIndex ()))); + mp_ui->lv_parents->setModel (new lay::CellTreeModel (mp_ui->lv_parents, mp_view, m_current_cv, lay::CellTreeModel::Flat | lay::CellTreeModel::Parents, model->cell (mp_ui->lv_cells->selectionModel ()->currentIndex ()))); } @@ -213,13 +217,13 @@ CellSelectionForm::update_children_list () if (m_current_cv >= 0 && m_current_cv < int (m_cellviews.size ())) { - lay::CellTreeModel *model = dynamic_cast (lv_cells->model ()); + lay::CellTreeModel *model = dynamic_cast (mp_ui->lv_cells->model ()); if (model) { - if (lv_children->model ()) { - delete lv_children->model (); + if (mp_ui->lv_children->model ()) { + delete mp_ui->lv_children->model (); } - lv_children->setModel (new lay::CellTreeModel (lv_children, mp_view, m_current_cv, lay::CellTreeModel::Flat | lay::CellTreeModel::Children, model->cell (lv_cells->selectionModel ()->currentIndex ()))); + mp_ui->lv_children->setModel (new lay::CellTreeModel (mp_ui->lv_children, mp_view, m_current_cv, lay::CellTreeModel::Flat | lay::CellTreeModel::Children, model->cell (mp_ui->lv_cells->selectionModel ()->currentIndex ()))); } @@ -247,12 +251,12 @@ CellSelectionForm::commit_cv () // update the cell view if (m_current_cv >= 0 && m_current_cv < int (m_cellviews.size ())) { - lay::CellTreeModel *model = dynamic_cast (lv_cells->model ()); + lay::CellTreeModel *model = dynamic_cast (mp_ui->lv_cells->model ()); if (! model) { return; } - const db::Cell *cell = model->cell (lv_cells->selectionModel ()->currentIndex ()); + const db::Cell *cell = model->cell (mp_ui->lv_cells->selectionModel ()->currentIndex ()); if (cell) { m_cellviews [m_current_cv].set_cell (cell->cell_index ()); } @@ -298,12 +302,12 @@ CellSelectionForm::apply_clicked() // select the current cell but don't make it the new top. if (m_current_cv >= 0 && m_current_cv < int (m_cellviews.size ())) { - lay::CellTreeModel *model = dynamic_cast (lv_cells->model ()); + lay::CellTreeModel *model = dynamic_cast (mp_ui->lv_cells->model ()); if (! model) { return; } - const db::Cell *cell = model->cell (lv_cells->selectionModel ()->currentIndex ()); + const db::Cell *cell = model->cell (mp_ui->lv_cells->selectionModel ()->currentIndex ()); lay::CellView cv (m_cellviews [m_current_cv]); cv.set_cell (cell->cell_index ()); @@ -319,9 +323,9 @@ CellSelectionForm::cell_changed (const QModelIndex ¤t, const QModelIndex & m_name_cb_enabled = false; - lay::CellTreeModel *model = dynamic_cast (lv_cells->model ()); + lay::CellTreeModel *model = dynamic_cast (mp_ui->lv_cells->model ()); if (model) { - le_cell_name->setText (tl::to_qstring (model->cell_name (current))); + mp_ui->le_cell_name->setText (tl::to_qstring (model->cell_name (current))); model->clear_locate (); } @@ -336,7 +340,7 @@ CellSelectionForm::cell_changed (const QModelIndex ¤t, const QModelIndex & void CellSelectionForm::set_child () { - child_changed (lv_children->selectionModel ()->currentIndex ()); + child_changed (mp_ui->lv_children->selectionModel ()->currentIndex ()); } void @@ -344,9 +348,9 @@ CellSelectionForm::child_changed(const QModelIndex ¤t) { if (m_children_cb_enabled && current.isValid ()) { if (m_current_cv >= 0 && m_current_cv < int (m_cellviews.size ())) { - lay::CellTreeModel *model = dynamic_cast (lv_children->model ()); + lay::CellTreeModel *model = dynamic_cast (mp_ui->lv_children->model ()); if (model) { - select_entry (model->cell_index (lv_children->selectionModel ()->currentIndex ())); + select_entry (model->cell_index (mp_ui->lv_children->selectionModel ()->currentIndex ())); } } } @@ -355,7 +359,7 @@ CellSelectionForm::child_changed(const QModelIndex ¤t) void CellSelectionForm::set_parent () { - parent_changed (lv_parents->selectionModel ()->currentIndex ()); + parent_changed (mp_ui->lv_parents->selectionModel ()->currentIndex ()); } void @@ -363,9 +367,9 @@ CellSelectionForm::parent_changed(const QModelIndex ¤t) { if (m_parents_cb_enabled && current.isValid ()) { if (m_current_cv >= 0 && m_current_cv < int (m_cellviews.size ())) { - lay::CellTreeModel *model = dynamic_cast (lv_parents->model ()); + lay::CellTreeModel *model = dynamic_cast (mp_ui->lv_parents->model ()); if (model) { - select_entry (model->cell_index (lv_parents->selectionModel ()->currentIndex ())); + select_entry (model->cell_index (mp_ui->lv_parents->selectionModel ()->currentIndex ())); } } } @@ -376,7 +380,7 @@ CellSelectionForm::select_entry (lay::CellView::cell_index_type ci) { m_cells_cb_enabled = false; - lay::CellTreeModel *model = dynamic_cast (lv_cells->model ()); + lay::CellTreeModel *model = dynamic_cast (mp_ui->lv_cells->model ()); if (! model) { return; } @@ -394,12 +398,12 @@ CellSelectionForm::select_entry (lay::CellView::cell_index_type ci) if (mi.isValid ()) { m_cells_cb_enabled = false; - lv_cells->selectionModel ()->setCurrentIndex (mi, QItemSelectionModel::Clear | QItemSelectionModel::SelectCurrent); - lv_cells->scrollTo (mi); + mp_ui->lv_cells->selectionModel ()->setCurrentIndex (mi, QItemSelectionModel::Clear | QItemSelectionModel::SelectCurrent); + mp_ui->lv_cells->scrollTo (mi); m_cells_cb_enabled = true; m_name_cb_enabled = false; - le_cell_name->setText (tl::to_qstring (model->cell_name (mi))); + mp_ui->le_cell_name->setText (tl::to_qstring (model->cell_name (mi))); model->clear_locate (); m_name_cb_enabled = true; @@ -422,7 +426,7 @@ CellSelectionForm::update_all () void CellSelectionForm::find_next_clicked () { - lay::CellTreeModel *model = dynamic_cast (lv_cells->model ()); + lay::CellTreeModel *model = dynamic_cast (mp_ui->lv_cells->model ()); if (! model) { return; } @@ -431,8 +435,8 @@ CellSelectionForm::find_next_clicked () if (mi.isValid ()) { m_cells_cb_enabled = false; - lv_cells->selectionModel ()->setCurrentIndex (mi, QItemSelectionModel::SelectCurrent); - lv_cells->scrollTo (mi); + mp_ui->lv_cells->selectionModel ()->setCurrentIndex (mi, QItemSelectionModel::SelectCurrent); + mp_ui->lv_cells->scrollTo (mi); update_children_list (); update_parents_list (); m_cells_cb_enabled = true; @@ -443,7 +447,7 @@ CellSelectionForm::find_next_clicked () void CellSelectionForm::find_prev_clicked () { - lay::CellTreeModel *model = dynamic_cast (lv_cells->model ()); + lay::CellTreeModel *model = dynamic_cast (mp_ui->lv_cells->model ()); if (! model) { return; } @@ -452,8 +456,8 @@ CellSelectionForm::find_prev_clicked () if (mi.isValid ()) { m_cells_cb_enabled = false; - lv_cells->selectionModel ()->setCurrentIndex (mi, QItemSelectionModel::SelectCurrent); - lv_cells->scrollTo (mi); + mp_ui->lv_cells->selectionModel ()->setCurrentIndex (mi, QItemSelectionModel::SelectCurrent); + mp_ui->lv_cells->scrollTo (mi); update_children_list (); update_parents_list (); m_cells_cb_enabled = true; @@ -466,9 +470,9 @@ CellSelectionForm::name_changed () { if (m_name_cb_enabled) { - QString s = le_cell_name->text (); + QString s = mp_ui->le_cell_name->text (); - lay::CellTreeModel *model = dynamic_cast (lv_cells->model ()); + lay::CellTreeModel *model = dynamic_cast (mp_ui->lv_cells->model ()); if (! model) { return; } @@ -481,9 +485,9 @@ CellSelectionForm::name_changed () } m_cells_cb_enabled = false; - lv_cells->selectionModel ()->setCurrentIndex (mi, QItemSelectionModel::SelectCurrent); + mp_ui->lv_cells->selectionModel ()->setCurrentIndex (mi, QItemSelectionModel::SelectCurrent); if (mi.isValid ()) { - lv_cells->scrollTo (mi); + mp_ui->lv_cells->scrollTo (mi); } update_children_list (); update_parents_list (); @@ -495,7 +499,7 @@ CellSelectionForm::name_changed () void CellSelectionForm::show_cell () { - lay::CellTreeModel *model = dynamic_cast (lv_cells->model ()); + lay::CellTreeModel *model = dynamic_cast (mp_ui->lv_cells->model ()); if (! model) { return; } @@ -503,7 +507,7 @@ CellSelectionForm::show_cell () return; } - QModelIndexList sel = lv_cells->selectionModel ()->selectedIndexes (); + QModelIndexList sel = mp_ui->lv_cells->selectionModel ()->selectedIndexes (); for (QModelIndexList::const_iterator s = sel.begin (); s != sel.end (); ++s) { db::cell_index_type ci = model->cell (*s)->cell_index (); mp_view->manager ()->transaction (tl::to_string (QObject::tr ("Show cells"))); @@ -517,7 +521,7 @@ CellSelectionForm::show_cell () void CellSelectionForm::hide_cell () { - lay::CellTreeModel *model = dynamic_cast (lv_cells->model ()); + lay::CellTreeModel *model = dynamic_cast (mp_ui->lv_cells->model ()); if (! model) { return; } @@ -525,7 +529,7 @@ CellSelectionForm::hide_cell () return; } - QModelIndexList sel = lv_cells->selectionModel ()->selectedIndexes (); + QModelIndexList sel = mp_ui->lv_cells->selectionModel ()->selectedIndexes (); for (QModelIndexList::const_iterator s = sel.begin (); s != sel.end (); ++s) { db::cell_index_type ci = model->cell (*s)->cell_index (); mp_view->manager ()->transaction (tl::to_string (QObject::tr ("Hide cells"))); @@ -539,7 +543,7 @@ CellSelectionForm::hide_cell () // ------------------------------------------------------------ LibraryCellSelectionForm::LibraryCellSelectionForm (QWidget *parent, db::Layout *layout, const char *name, bool all_cells, bool top_cells_only) - : QDialog (parent), Ui::LibraryCellSelectionForm (), + : QDialog (parent), mp_lib (0), mp_layout (layout), m_name_cb_enabled (true), m_cells_cb_enabled (true), @@ -549,32 +553,33 @@ LibraryCellSelectionForm::LibraryCellSelectionForm (QWidget *parent, db::Layout m_all_cells (all_cells), m_top_cells_only (top_cells_only) { + mp_ui = new Ui::LibraryCellSelectionForm (); setObjectName (QString::fromUtf8 (name)); - Ui::LibraryCellSelectionForm::setupUi (this); + mp_ui->setupUi (this); // no library selection - lib_label->hide (); - lib_cb->hide (); + mp_ui->lib_label->hide (); + mp_ui->lib_cb->hide (); // signals and slots connections - connect (cancel_button, SIGNAL(clicked()), this, SLOT(reject())); - connect (ok_button, SIGNAL(clicked()), this, SLOT(accept())); - connect (le_cell_name, SIGNAL(textChanged(const QString&)), this, SLOT(name_changed(const QString&))); - connect (find_next, SIGNAL(clicked()), this, SLOT(find_next_clicked())); - connect (cb_show_all_cells, SIGNAL(clicked()), this, SLOT(show_all_changed())); + connect (mp_ui->cancel_button, SIGNAL(clicked()), this, SLOT(reject())); + connect (mp_ui->ok_button, SIGNAL(clicked()), this, SLOT(accept())); + connect (mp_ui->le_cell_name, SIGNAL(textChanged(const QString&)), this, SLOT(name_changed(const QString&))); + connect (mp_ui->find_next, SIGNAL(clicked()), this, SLOT(find_next_clicked())); + connect (mp_ui->cb_show_all_cells, SIGNAL(clicked()), this, SLOT(show_all_changed())); - lv_cells->header ()->hide (); - lv_cells->setRootIsDecorated (false); + mp_ui->lv_cells->header ()->hide (); + mp_ui->lv_cells->setRootIsDecorated (false); - ok_button->setText (QObject::tr ("Ok")); - cancel_button->setText (QObject::tr ("Cancel")); + mp_ui->ok_button->setText (QObject::tr ("Ok")); + mp_ui->cancel_button->setText (QObject::tr ("Cancel")); update_cell_list (); } LibraryCellSelectionForm::LibraryCellSelectionForm (QWidget *parent, const char *name, bool all_cells, bool top_cells_only) - : QDialog (parent), Ui::LibraryCellSelectionForm (), + : QDialog (parent), mp_lib (0), mp_layout (0), m_name_cb_enabled (true), m_cells_cb_enabled (true), @@ -584,28 +589,30 @@ LibraryCellSelectionForm::LibraryCellSelectionForm (QWidget *parent, const char m_all_cells (all_cells), m_top_cells_only (top_cells_only) { + mp_ui = new Ui::LibraryCellSelectionForm (); + mp_lib = db::LibraryManager::instance ().lib_ptr_by_name ("Basic"); mp_layout = &mp_lib->layout (); setObjectName (QString::fromUtf8 (name)); - Ui::LibraryCellSelectionForm::setupUi (this); + mp_ui->setupUi (this); - lib_cb->set_current_library (mp_lib); + mp_ui->lib_cb->set_current_library (mp_lib); // signals and slots connections - connect (cancel_button, SIGNAL(clicked()), this, SLOT(reject())); - connect (ok_button, SIGNAL(clicked()), this, SLOT(accept())); - connect (le_cell_name, SIGNAL(textChanged(const QString&)), this, SLOT(name_changed(const QString&))); - connect (find_next, SIGNAL(clicked()), this, SLOT(find_next_clicked())); - connect (lib_cb, SIGNAL(currentIndexChanged(int)), this, SLOT(lib_changed())); - connect (cb_show_all_cells, SIGNAL(clicked()), this, SLOT(show_all_changed())); + connect (mp_ui->cancel_button, SIGNAL(clicked()), this, SLOT(reject())); + connect (mp_ui->ok_button, SIGNAL(clicked()), this, SLOT(accept())); + connect (mp_ui->le_cell_name, SIGNAL(textChanged(const QString&)), this, SLOT(name_changed(const QString&))); + connect (mp_ui->find_next, SIGNAL(clicked()), this, SLOT(find_next_clicked())); + connect (mp_ui->lib_cb, SIGNAL(currentIndexChanged(int)), this, SLOT(lib_changed())); + connect (mp_ui->cb_show_all_cells, SIGNAL(clicked()), this, SLOT(show_all_changed())); - lv_cells->header ()->hide (); - lv_cells->setRootIsDecorated (false); + mp_ui->lv_cells->header ()->hide (); + mp_ui->lv_cells->setRootIsDecorated (false); - ok_button->setText (QObject::tr ("Ok")); - cancel_button->setText (QObject::tr ("Cancel")); + mp_ui->ok_button->setText (QObject::tr ("Ok")); + mp_ui->cancel_button->setText (QObject::tr ("Cancel")); update_cell_list (); } @@ -613,14 +620,14 @@ LibraryCellSelectionForm::LibraryCellSelectionForm (QWidget *parent, const char void LibraryCellSelectionForm::show_all_changed () { - m_all_cells = cb_show_all_cells->isChecked (); + m_all_cells = mp_ui->cb_show_all_cells->isChecked (); update_cell_list (); } void LibraryCellSelectionForm::lib_changed () { - mp_lib = lib_cb->current_library (); + mp_lib = mp_ui->lib_cb->current_library (); mp_layout = mp_lib ? &mp_lib->layout () : 0; update_cell_list (); } @@ -675,11 +682,11 @@ END_PROTECTED void LibraryCellSelectionForm::update_cell_list () { - if (lv_cells->model ()) { - delete lv_cells->model (); + if (mp_ui->lv_cells->model ()) { + delete mp_ui->lv_cells->model (); } - cb_show_all_cells->setChecked (m_all_cells); + mp_ui->cb_show_all_cells->setChecked (m_all_cells); if (mp_layout) { @@ -692,11 +699,11 @@ LibraryCellSelectionForm::update_cell_list () } // TODO: get rid of that const_cast - lay::CellTreeModel *model = new lay::CellTreeModel (lv_cells, const_cast (mp_layout), flags); + lay::CellTreeModel *model = new lay::CellTreeModel (mp_ui->lv_cells, const_cast (mp_layout), flags); - lv_cells->setModel (model); + mp_ui->lv_cells->setModel (model); // connect can only happen after setModel() - connect (lv_cells->selectionModel (), SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(cell_changed(const QModelIndex &, const QModelIndex &))); + connect (mp_ui->lv_cells->selectionModel (), SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(cell_changed(const QModelIndex &, const QModelIndex &))); select_entry (std::numeric_limits::max ()); @@ -710,7 +717,7 @@ LibraryCellSelectionForm::cell_changed (const QModelIndex ¤t, const QModel m_name_cb_enabled = false; - lay::CellTreeModel *model = dynamic_cast (lv_cells->model ()); + lay::CellTreeModel *model = dynamic_cast (mp_ui->lv_cells->model ()); if (model) { m_is_pcell = model->is_pcell (current); if (m_is_pcell) { @@ -718,7 +725,7 @@ LibraryCellSelectionForm::cell_changed (const QModelIndex ¤t, const QModel } else { m_cell_index = model->cell_index (current); } - le_cell_name->setText (tl::to_qstring (model->cell_name (current))); + mp_ui->le_cell_name->setText (tl::to_qstring (model->cell_name (current))); model->clear_locate (); } else { m_cell_index = -1; @@ -738,7 +745,7 @@ LibraryCellSelectionForm::select_pcell_entry (db::pcell_id_type pci) m_pcell_id = pci; m_is_pcell = true; - lay::CellTreeModel *model = dynamic_cast (lv_cells->model ()); + lay::CellTreeModel *model = dynamic_cast (mp_ui->lv_cells->model ()); if (! model) { return; } @@ -756,12 +763,12 @@ LibraryCellSelectionForm::select_pcell_entry (db::pcell_id_type pci) if (mi.isValid ()) { m_cells_cb_enabled = false; - lv_cells->selectionModel ()->setCurrentIndex (mi, QItemSelectionModel::Clear | QItemSelectionModel::SelectCurrent); - lv_cells->scrollTo (mi); + mp_ui->lv_cells->selectionModel ()->setCurrentIndex (mi, QItemSelectionModel::Clear | QItemSelectionModel::SelectCurrent); + mp_ui->lv_cells->scrollTo (mi); m_cells_cb_enabled = true; m_name_cb_enabled = false; - le_cell_name->setText (tl::to_qstring (model->cell_name (mi))); + mp_ui->le_cell_name->setText (tl::to_qstring (model->cell_name (mi))); model->clear_locate (); m_name_cb_enabled = true; @@ -777,7 +784,7 @@ LibraryCellSelectionForm::select_entry (lay::CellView::cell_index_type ci) m_cell_index = ci; m_is_pcell = false; - lay::CellTreeModel *model = dynamic_cast (lv_cells->model ()); + lay::CellTreeModel *model = dynamic_cast (mp_ui->lv_cells->model ()); if (! model) { return; } @@ -795,12 +802,12 @@ LibraryCellSelectionForm::select_entry (lay::CellView::cell_index_type ci) if (mi.isValid ()) { m_cells_cb_enabled = false; - lv_cells->selectionModel ()->setCurrentIndex (mi, QItemSelectionModel::Clear | QItemSelectionModel::SelectCurrent); - lv_cells->scrollTo (mi); + mp_ui->lv_cells->selectionModel ()->setCurrentIndex (mi, QItemSelectionModel::Clear | QItemSelectionModel::SelectCurrent); + mp_ui->lv_cells->scrollTo (mi); m_cells_cb_enabled = true; m_name_cb_enabled = false; - le_cell_name->setText (tl::to_qstring (model->cell_name (mi))); + mp_ui->le_cell_name->setText (tl::to_qstring (model->cell_name (mi))); model->clear_locate (); m_name_cb_enabled = true; @@ -812,7 +819,7 @@ LibraryCellSelectionForm::select_entry (lay::CellView::cell_index_type ci) void LibraryCellSelectionForm::find_next_clicked () { - lay::CellTreeModel *model = dynamic_cast (lv_cells->model ()); + lay::CellTreeModel *model = dynamic_cast (mp_ui->lv_cells->model ()); if (! model) { return; } @@ -821,8 +828,8 @@ LibraryCellSelectionForm::find_next_clicked () if (mi.isValid ()) { m_cells_cb_enabled = false; - lv_cells->selectionModel ()->setCurrentIndex (mi, QItemSelectionModel::SelectCurrent); - lv_cells->scrollTo (mi); + mp_ui->lv_cells->selectionModel ()->setCurrentIndex (mi, QItemSelectionModel::SelectCurrent); + mp_ui->lv_cells->scrollTo (mi); m_is_pcell = model->is_pcell (mi); if (m_is_pcell) { @@ -845,7 +852,7 @@ LibraryCellSelectionForm::name_changed (const QString &s) { if (m_name_cb_enabled) { - lay::CellTreeModel *model = dynamic_cast (lv_cells->model ()); + lay::CellTreeModel *model = dynamic_cast (mp_ui->lv_cells->model ()); if (! model) { return; } @@ -854,8 +861,8 @@ LibraryCellSelectionForm::name_changed (const QString &s) if (mi.isValid ()) { m_cells_cb_enabled = false; - lv_cells->selectionModel ()->setCurrentIndex (mi, QItemSelectionModel::SelectCurrent); - lv_cells->scrollTo (mi); + mp_ui->lv_cells->selectionModel ()->setCurrentIndex (mi, QItemSelectionModel::SelectCurrent); + mp_ui->lv_cells->scrollTo (mi); m_is_pcell = model->is_pcell (mi); if (m_is_pcell) { diff --git a/src/layui/layui/layCellSelectionForm.h b/src/layui/layui/layCellSelectionForm.h index f878e9116..b65769c0b 100644 --- a/src/layui/layui/layCellSelectionForm.h +++ b/src/layui/layui/layCellSelectionForm.h @@ -27,14 +27,21 @@ #include -#include "ui_CellSelectionForm.h" -#include "ui_LibraryCellSelectionForm.h" +#include "layuiCommon.h" #include "layCellView.h" #include "tlDeferredExecution.h" #include #include +#include + +namespace Ui +{ + class CellSelectionForm; + class LibraryCellSelectionForm; +} + namespace lay { @@ -45,7 +52,7 @@ class LayoutView; * @brief A form to select a cell and a cell view index */ class LAYUI_PUBLIC CellSelectionForm - : public QDialog, private Ui::CellSelectionForm + : public QDialog { Q_OBJECT @@ -77,6 +84,7 @@ public slots: void find_prev_clicked(); private: + Ui::CellSelectionForm *mp_ui; lay::LayoutViewBase *mp_view; std::vector m_cellviews; int m_current_cv; @@ -104,7 +112,7 @@ private: * @brief A form to select a cell from a library */ class LAYUI_PUBLIC LibraryCellSelectionForm - : public QDialog, private Ui::LibraryCellSelectionForm + : public QDialog { Q_OBJECT @@ -182,6 +190,7 @@ public slots: void show_all_changed (); private: + Ui::LibraryCellSelectionForm *mp_ui; db::Library *mp_lib; const db::Layout *mp_layout; bool m_name_cb_enabled; diff --git a/src/layui/layui/layHierarchyControlPanel.h b/src/layui/layui/layHierarchyControlPanel.h index 8ac5a69a5..1387d9c9a 100644 --- a/src/layui/layui/layHierarchyControlPanel.h +++ b/src/layui/layui/layHierarchyControlPanel.h @@ -32,6 +32,7 @@ #include #include +#include "layuiCommon.h" #include "dbLayout.h" #include "layCanvasPlane.h" #include "layViewOp.h" @@ -96,7 +97,7 @@ protected: * The class communicates with a Layout interface for * retrieval of the cell hierarchy */ -class HierarchyControlPanel +class LAYUI_PUBLIC HierarchyControlPanel : public QFrame, public tl::Object { diff --git a/src/layui/layui/layLayerControlPanel.h b/src/layui/layui/layLayerControlPanel.h index 872e0b691..f82371b27 100644 --- a/src/layui/layui/layLayerControlPanel.h +++ b/src/layui/layui/layLayerControlPanel.h @@ -26,17 +26,7 @@ #define HDR_layLayerControlPanel -#include -#include -#include -#include - -#include -#include -#include -#include -#include - +#include "layuiCommon.h" #include "layCanvasPlane.h" #include "layViewOp.h" #include "layLayoutViewBase.h" @@ -49,6 +39,17 @@ #include "dbObject.h" #include "tlDeferredExecution.h" +#include +#include +#include +#include + +#include +#include +#include +#include +#include + class QTreeView; class QModelIndex; class QMenu; @@ -108,7 +109,7 @@ private: * The class communicates with a Layout interface for * retrieval and changing of layer properties. */ -class LayerControlPanel +class LAYUI_PUBLIC LayerControlPanel : public QFrame, public db::Object, public tl::Object diff --git a/src/layui/layui/layLibrariesView.h b/src/layui/layui/layLibrariesView.h index 4017e611d..5eb2dbdad 100644 --- a/src/layui/layui/layLibrariesView.h +++ b/src/layui/layui/layLibrariesView.h @@ -25,13 +25,7 @@ #ifndef HDR_layLibrariesView #define HDR_layLibrariesView -#include -#include -#include - -#include -#include - +#include "layuiCommon.h" #include "dbLayout.h" #include "layCanvasPlane.h" #include "layViewOp.h" @@ -40,6 +34,13 @@ #include "layWidgets.h" #include "tlDeferredExecution.h" +#include +#include +#include + +#include +#include + class QModelIndex; class QComboBox; class QMenu; @@ -95,7 +96,7 @@ protected: * The class communicates with a Layout interface for * retrieval of the cell hierarchy */ -class LibrariesView +class LAYUI_PUBLIC LibrariesView : public QFrame, public tl::Object { diff --git a/src/layui/layui/layNetlistBrowserDialog.h b/src/layui/layui/layNetlistBrowserDialog.h index d7cf015fb..6c7021fb5 100644 --- a/src/layui/layui/layNetlistBrowserDialog.h +++ b/src/layui/layui/layNetlistBrowserDialog.h @@ -25,6 +25,7 @@ #ifndef HDR_layNetlistBrowserDialog #define HDR_layNetlistBrowserDialog +#include "layuiCommon.h" #include "layBrowser.h" #include "layNetlistBrowser.h" #include "layViewObject.h" @@ -47,7 +48,7 @@ namespace lay class NetlistObjectPath; class NetlistObjectsPath; -class NetlistBrowserDialog +class LAYUI_PUBLIC NetlistBrowserDialog : public lay::Browser, public lay::ViewService { diff --git a/src/layui/layui/rdbMarkerBrowserDialog.h b/src/layui/layui/rdbMarkerBrowserDialog.h index 118aac720..6bfcf642c 100644 --- a/src/layui/layui/rdbMarkerBrowserDialog.h +++ b/src/layui/layui/rdbMarkerBrowserDialog.h @@ -25,6 +25,7 @@ #ifndef HDR_rdbMarkerBrowserDialog #define HDR_rdbMarkerBrowserDialog +#include "layuiCommon.h" #include "layBrowser.h" #include "layColor.h" #include "rdbMarkerBrowser.h" @@ -37,7 +38,7 @@ namespace Ui namespace rdb { -class MarkerBrowserDialog +class LAYUI_PUBLIC MarkerBrowserDialog : public lay::Browser { Q_OBJECT diff --git a/src/plugins/lay_plugin.pri b/src/plugins/lay_plugin.pri index be3655cd2..3710c7ff7 100644 --- a/src/plugins/lay_plugin.pri +++ b/src/plugins/lay_plugin.pri @@ -3,9 +3,9 @@ include($$PWD/../klayout.pri) TEMPLATE = lib -INCLUDEPATH += $$DB_INC $$TL_INC $$GSI_INC $$LAYBASIC_INC $$LAY_INC $$PWD/common -DEPENDPATH += $$DB_INC $$TL_INC $$GSI_INC $$LAYBASIC_INC $$LAY_INC $$PWD/common -LIBS += -L$$DESTDIR/.. -lklayout_db -lklayout_tl -lklayout_gsi -lklayout_laybasic -lklayout_lay +INCLUDEPATH += $$DB_INC $$TL_INC $$GSI_INC $$LAYBASIC_INC $$LAYUI_INC $$LAYVIEW_INC $$LAYUI_INC $$LAY_INC $$PWD/common +DEPENDPATH += $$DB_INC $$TL_INC $$GSI_INC $$LAYBASIC_INC $$LAYUI_INC $$LAYVIEW_INC $$LAYUI_INC $$LAY_INC $$PWD/common +LIBS += -L$$DESTDIR/.. -lklayout_db -lklayout_tl -lklayout_gsi -lklayout_laybasic -lklayout_layui -lklayout_layview -lklayout_lay -lklayout_lay DEFINES += MAKE_LAY_PLUGIN_LIBRARY diff --git a/src/plugins/streamers/lefdef/lay_plugin/layLEFDEFImport.cc b/src/plugins/streamers/lefdef/lay_plugin/layLEFDEFImport.cc index b8b92a68e..82e93d64e 100644 --- a/src/plugins/streamers/lefdef/lay_plugin/layLEFDEFImport.cc +++ b/src/plugins/streamers/lefdef/lay_plugin/layLEFDEFImport.cc @@ -28,6 +28,7 @@ #include "layPlugin.h" #include "layMainWindow.h" #include "layFileDialog.h" +#include "dbTechnology.h" #include "tlLog.h" #include "tlTimer.h" #include "tlXMLParser.h" diff --git a/src/plugins/tools/bool/lay_plugin/layBooleanOperationsDialogs.cc b/src/plugins/tools/bool/lay_plugin/layBooleanOperationsDialogs.cc index e5f0c966f..ffb1e3574 100644 --- a/src/plugins/tools/bool/lay_plugin/layBooleanOperationsDialogs.cc +++ b/src/plugins/tools/bool/lay_plugin/layBooleanOperationsDialogs.cc @@ -62,7 +62,7 @@ BooleanOptionsDialog::cv_changed (int) } bool -BooleanOptionsDialog::exec_dialog (lay::LayoutView *view, int &cv_a, int &layer_a, int &cv_b, int &layer_b, int &cv_r, int &layer_r, int &mode, int &hier_mode, bool &min_coherence) +BooleanOptionsDialog::exec_dialog (lay::LayoutViewBase *view, int &cv_a, int &layer_a, int &cv_b, int &layer_b, int &cv_r, int &layer_r, int &mode, int &hier_mode, bool &min_coherence) { mp_view = view; @@ -183,7 +183,7 @@ SizingOptionsDialog::cv_changed (int) } bool -SizingOptionsDialog::exec_dialog (lay::LayoutView *view, int &cv, int &layer, int &cv_r, int &layer_r, double &dx, double &dy, unsigned int &size_mode, int &hier_mode, bool &min_coherence) +SizingOptionsDialog::exec_dialog (lay::LayoutViewBase *view, int &cv, int &layer, int &cv_r, int &layer_r, double &dx, double &dy, unsigned int &size_mode, int &hier_mode, bool &min_coherence) { mp_view = view; @@ -309,7 +309,7 @@ MergeOptionsDialog::cv_changed (int) } bool -MergeOptionsDialog::exec_dialog (lay::LayoutView *view, int &cv, int &layer, int &cv_r, int &layer_r, unsigned int &min_wc, int &hier_mode, bool &min_coherence) +MergeOptionsDialog::exec_dialog (lay::LayoutViewBase *view, int &cv, int &layer, int &cv_r, int &layer_r, unsigned int &min_wc, int &hier_mode, bool &min_coherence) { mp_view = view; diff --git a/src/plugins/tools/bool/lay_plugin/layBooleanOperationsDialogs.h b/src/plugins/tools/bool/lay_plugin/layBooleanOperationsDialogs.h index ae53f9849..875c42054 100644 --- a/src/plugins/tools/bool/lay_plugin/layBooleanOperationsDialogs.h +++ b/src/plugins/tools/bool/lay_plugin/layBooleanOperationsDialogs.h @@ -37,7 +37,7 @@ namespace lay { class CellView; -class LayoutView; +class LayoutViewBase; /** * @brief The boolean operation options @@ -52,7 +52,7 @@ public: BooleanOptionsDialog (QWidget *parent); virtual ~BooleanOptionsDialog (); - bool exec_dialog (lay::LayoutView *view, int &cv_a, int &layer_a, int &cv_b, int &layer_b, int &cv_res, int &layer_res, int &mode, int &hier_mode, bool &min_coherence); + bool exec_dialog (lay::LayoutViewBase *view, int &cv_a, int &layer_a, int &cv_b, int &layer_b, int &cv_res, int &layer_res, int &mode, int &hier_mode, bool &min_coherence); public slots: void cv_changed (int); @@ -60,7 +60,7 @@ public slots: private: virtual void accept (); - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; }; /** @@ -76,7 +76,7 @@ public: SizingOptionsDialog (QWidget *parent); virtual ~SizingOptionsDialog (); - bool exec_dialog (lay::LayoutView *view, int &cv, int &layer, int &cv_res, int &layer_res, double &dx, double &dy, unsigned int &size_mode, int &hier_mode, bool &min_coherence); + bool exec_dialog (lay::LayoutViewBase *view, int &cv, int &layer, int &cv_res, int &layer_res, double &dx, double &dy, unsigned int &size_mode, int &hier_mode, bool &min_coherence); public slots: void cv_changed (int); @@ -84,7 +84,7 @@ public slots: private: virtual void accept (); - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; }; /** @@ -100,7 +100,7 @@ public: MergeOptionsDialog (QWidget *parent); virtual ~MergeOptionsDialog (); - bool exec_dialog (lay::LayoutView *view, int &cv, int &layer, int &cv_res, int &layer_res, unsigned int &min_wc, int &hier_mode, bool &min_coherence); + bool exec_dialog (lay::LayoutViewBase *view, int &cv, int &layer, int &cv_res, int &layer_res, unsigned int &min_wc, int &hier_mode, bool &min_coherence); public slots: void cv_changed (int); @@ -108,7 +108,7 @@ public slots: private: virtual void accept (); - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; }; } diff --git a/src/plugins/tools/bool/lay_plugin/layBooleanOperationsPlugin.cc b/src/plugins/tools/bool/lay_plugin/layBooleanOperationsPlugin.cc index 7202d66e1..f8ccfd1ba 100644 --- a/src/plugins/tools/bool/lay_plugin/layBooleanOperationsPlugin.cc +++ b/src/plugins/tools/bool/lay_plugin/layBooleanOperationsPlugin.cc @@ -26,7 +26,7 @@ #include "layPlugin.h" #include "layTipDialog.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "dbShapeProcessor.h" @@ -39,7 +39,7 @@ class BooleanOperationsPlugin : public lay::Plugin { public: - BooleanOperationsPlugin (Plugin *parent, lay::LayoutView *view) + BooleanOperationsPlugin (Plugin *parent, lay::LayoutViewBase *view) : lay::Plugin (parent), mp_view (view) { m_boolean_cva = -1; @@ -100,7 +100,7 @@ public: } - lay::BooleanOptionsDialog dialog (mp_view); + lay::BooleanOptionsDialog dialog (mp_view->widget ()); if (dialog.exec_dialog (mp_view, m_boolean_cva, m_boolean_layera, m_boolean_cvb, m_boolean_layerb, m_boolean_cvr, m_boolean_layerr, m_boolean_mode, m_boolean_hier_mode, m_boolean_mincoh)) { mp_view->cancel (); @@ -237,7 +237,7 @@ public: } - lay::MergeOptionsDialog dialog (mp_view); + lay::MergeOptionsDialog dialog (mp_view->widget ()); if (dialog.exec_dialog (mp_view, m_boolean_cva, m_boolean_layera, m_boolean_cvr, m_boolean_layerr, m_boolean_minwc, m_boolean_hier_mode, m_boolean_mincoh)) { mp_view->cancel (); @@ -352,7 +352,7 @@ public: } - lay::SizingOptionsDialog dialog (mp_view); + lay::SizingOptionsDialog dialog (mp_view->widget ()); if (dialog.exec_dialog (mp_view, m_boolean_cva, m_boolean_layera, m_boolean_cvr, m_boolean_layerr, m_boolean_sizex, m_boolean_sizey, m_boolean_size_mode, m_boolean_hier_mode, m_boolean_mincoh)) { mp_view->cancel (); @@ -445,7 +445,7 @@ public: } private: - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; int m_boolean_cva, m_boolean_cvb, m_boolean_cvr; int m_boolean_layera, m_boolean_layerb, m_boolean_layerr; int m_boolean_hier_mode, m_boolean_mode; diff --git a/src/plugins/tools/diff/lay_plugin/layDiffPlugin.cc b/src/plugins/tools/diff/lay_plugin/layDiffPlugin.cc index cde5bed10..8d22390ed 100644 --- a/src/plugins/tools/diff/lay_plugin/layDiffPlugin.cc +++ b/src/plugins/tools/diff/lay_plugin/layDiffPlugin.cc @@ -24,7 +24,7 @@ #include "layDispatcher.h" #include "layPlugin.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" namespace lay { @@ -33,7 +33,7 @@ class DiffPlugin : public lay::Plugin { public: - DiffPlugin (Plugin *parent, lay::LayoutView *view) + DiffPlugin (Plugin *parent, lay::LayoutViewBase *view) : lay::Plugin (parent), mp_view (view) { mp_dialog = new lay::DiffToolDialog (0); @@ -59,7 +59,7 @@ public: } private: - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; lay::DiffToolDialog *mp_dialog; }; diff --git a/src/plugins/tools/diff/lay_plugin/layDiffToolDialog.cc b/src/plugins/tools/diff/lay_plugin/layDiffToolDialog.cc index e85ae117b..c56f6e7da 100644 --- a/src/plugins/tools/diff/lay_plugin/layDiffToolDialog.cc +++ b/src/plugins/tools/diff/lay_plugin/layDiffToolDialog.cc @@ -30,7 +30,7 @@ #include "tlTimer.h" #include "tlProgress.h" #include "layCellView.h" -#include "layLayoutView.h" +#include "layLayoutViewBase.h" #include "tlExceptions.h" #include "ui_DiffToolDialog.h" @@ -608,7 +608,7 @@ DiffToolDialog::~DiffToolDialog () } int -DiffToolDialog::exec_dialog (lay::LayoutView *view) +DiffToolDialog::exec_dialog (lay::LayoutViewBase *view) { mp_view = view; diff --git a/src/plugins/tools/diff/lay_plugin/layDiffToolDialog.h b/src/plugins/tools/diff/lay_plugin/layDiffToolDialog.h index b91744c50..e823f3b13 100644 --- a/src/plugins/tools/diff/lay_plugin/layDiffToolDialog.h +++ b/src/plugins/tools/diff/lay_plugin/layDiffToolDialog.h @@ -36,7 +36,7 @@ namespace Ui namespace lay { - class LayoutView; + class LayoutViewBase; } namespace lay @@ -57,7 +57,7 @@ public: DiffToolDialog (QWidget *parent); ~DiffToolDialog (); - int exec_dialog (lay::LayoutView *view); + int exec_dialog (lay::LayoutViewBase *view); protected slots: void xor_changed () { update (); } @@ -69,7 +69,7 @@ protected: private: Ui::DiffToolDialog *mp_ui; - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; }; } diff --git a/src/plugins/tools/net_tracer/lay_plugin/layNetTracerDialog.cc b/src/plugins/tools/net_tracer/lay_plugin/layNetTracerDialog.cc index d9b50d85a..cbbf1c069 100644 --- a/src/plugins/tools/net_tracer/lay_plugin/layNetTracerDialog.cc +++ b/src/plugins/tools/net_tracer/lay_plugin/layNetTracerDialog.cc @@ -53,7 +53,7 @@ namespace lay // ----------------------------------------------------------------------------------- // NetTracerDialog implementation -NetTracerDialog::NetTracerDialog (lay::Dispatcher *root, lay::LayoutView *view) +NetTracerDialog::NetTracerDialog (lay::Dispatcher *root, LayoutViewBase *view) : lay::Browser (root, view, "net_tracer_dialog"), lay::ViewService (view->view_object_widget ()), m_cv_index (0), diff --git a/src/plugins/tools/net_tracer/lay_plugin/layNetTracerDialog.h b/src/plugins/tools/net_tracer/lay_plugin/layNetTracerDialog.h index 8e072dbf1..63e2a2236 100644 --- a/src/plugins/tools/net_tracer/lay_plugin/layNetTracerDialog.h +++ b/src/plugins/tools/net_tracer/lay_plugin/layNetTracerDialog.h @@ -57,7 +57,7 @@ class NetTracerDialog Q_OBJECT public: - NetTracerDialog (lay::Dispatcher *root, lay::LayoutView *view); + NetTracerDialog (lay::Dispatcher *root, lay::LayoutViewBase *view); virtual ~NetTracerDialog (); virtual bool mouse_move_event (const db::DPoint &p, unsigned int buttons, bool prio); @@ -108,7 +108,7 @@ private: lay::FileDialog *mp_export_file_dialog; std::string m_export_file_name; - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; void commit (); size_t get_trace_depth (); @@ -124,7 +124,7 @@ private: bool get_net_tracer_setup (const lay::CellView &cv, db::NetTracerData &data); void trace_all_nets (db::LayoutToNetlist *l2ndb, const lay::CellView &cv, bool flat); - lay::LayoutView *view () + lay::LayoutViewBase *view () { return mp_view; } diff --git a/src/plugins/tools/view_25d/lay_plugin/layD25View.cc b/src/plugins/tools/view_25d/lay_plugin/layD25View.cc index f7f885da3..026864e70 100644 --- a/src/plugins/tools/view_25d/lay_plugin/layD25View.cc +++ b/src/plugins/tools/view_25d/lay_plugin/layD25View.cc @@ -38,7 +38,7 @@ namespace lay const double initial_elevation = 15.0; -D25View::D25View (lay::Dispatcher *root, LayoutView *view) +D25View::D25View (lay::Dispatcher *root, LayoutViewBase *view) : lay::Browser (root, view, "d25_view"), dm_rerun_macro (this, &D25View::rerun_macro), dm_fit (this, &D25View::fit) @@ -146,7 +146,7 @@ D25View::menu_activated (const std::string &symbol) } D25View * -D25View::open (lay::LayoutView *view) +D25View::open (lay::LayoutViewBase *view) { D25View *d25_view = view->get_plugin (); if (d25_view) { diff --git a/src/plugins/tools/view_25d/lay_plugin/layD25View.h b/src/plugins/tools/view_25d/lay_plugin/layD25View.h index 724c14e25..62847e787 100644 --- a/src/plugins/tools/view_25d/lay_plugin/layD25View.h +++ b/src/plugins/tools/view_25d/lay_plugin/layD25View.h @@ -37,7 +37,7 @@ namespace Ui namespace lay { - class LayoutView; + class LayoutViewBase; } namespace db @@ -57,14 +57,14 @@ class D25View Q_OBJECT public: - D25View (lay::Dispatcher *root, lay::LayoutView *view); + D25View (lay::Dispatcher *root, lay::LayoutViewBase *view); ~D25View (); virtual void menu_activated (const std::string &symbol); virtual void deactivated (); virtual void activated (); - static D25View *open (lay::LayoutView *view); + static D25View *open (lay::LayoutViewBase *view); void close (); void clear (); void begin (const std::string &generator); diff --git a/src/plugins/tools/view_25d/lay_plugin/layD25ViewWidget.cc b/src/plugins/tools/view_25d/lay_plugin/layD25ViewWidget.cc index 45194bca0..475953c1e 100644 --- a/src/plugins/tools/view_25d/lay_plugin/layD25ViewWidget.cc +++ b/src/plugins/tools/view_25d/lay_plugin/layD25ViewWidget.cc @@ -711,7 +711,7 @@ D25ViewWidget::finish () } void -D25ViewWidget::attach_view (LayoutView *view) +D25ViewWidget::attach_view (LayoutViewBase *view) { mp_view = view; } diff --git a/src/plugins/tools/view_25d/lay_plugin/layD25ViewWidget.h b/src/plugins/tools/view_25d/lay_plugin/layD25ViewWidget.h index af5dd0a54..180a9cb89 100644 --- a/src/plugins/tools/view_25d/lay_plugin/layD25ViewWidget.h +++ b/src/plugins/tools/view_25d/lay_plugin/layD25ViewWidget.h @@ -57,7 +57,7 @@ namespace tl namespace lay { -class LayoutView; +class LayoutViewBase; class LayerPropertiesNode; class D25ViewWidget; @@ -106,7 +106,7 @@ public: void mouseReleaseEvent (QMouseEvent *event); void mouseMoveEvent (QMouseEvent *event); - void attach_view(lay::LayoutView *view); + void attach_view(lay::LayoutViewBase *view); QVector3D hit_point_with_scene(const QVector3D &line_dir); void refresh (); @@ -187,7 +187,7 @@ private: double m_scale_factor; double m_vscale_factor; QVector3D m_displacement; - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; db::DBox m_bbox; double m_zmin, m_zmax; bool m_zset; diff --git a/src/plugins/tools/xor/lay_plugin/layXORPlugin.cc b/src/plugins/tools/xor/lay_plugin/layXORPlugin.cc index 0a3f60b65..6c38c4d85 100644 --- a/src/plugins/tools/xor/lay_plugin/layXORPlugin.cc +++ b/src/plugins/tools/xor/lay_plugin/layXORPlugin.cc @@ -35,7 +35,7 @@ class XORPlugin : public lay::Plugin { public: - XORPlugin (Plugin *parent, lay::LayoutView *view) + XORPlugin (Plugin *parent, lay::LayoutViewBase *view) : lay::Plugin (parent), mp_view (view) { mp_dialog = new lay::XORToolDialog (0); @@ -61,7 +61,7 @@ public: } private: - lay::LayoutView *mp_view; + lay::LayoutViewBase *mp_view; lay::XORToolDialog *mp_dialog; }; diff --git a/src/plugins/tools/xor/lay_plugin/layXORToolDialog.cc b/src/plugins/tools/xor/lay_plugin/layXORToolDialog.cc index ff8c7888b..f5141f114 100644 --- a/src/plugins/tools/xor/lay_plugin/layXORToolDialog.cc +++ b/src/plugins/tools/xor/lay_plugin/layXORToolDialog.cc @@ -186,7 +186,7 @@ XORToolDialog::~XORToolDialog () } int -XORToolDialog::exec_dialog (lay::LayoutView *view) +XORToolDialog::exec_dialog (lay::LayoutViewBase *view) { mp_view = view; diff --git a/src/plugins/tools/xor/lay_plugin/layXORToolDialog.h b/src/plugins/tools/xor/lay_plugin/layXORToolDialog.h index adeb9fb1b..e2178ee62 100644 --- a/src/plugins/tools/xor/lay_plugin/layXORToolDialog.h +++ b/src/plugins/tools/xor/lay_plugin/layXORToolDialog.h @@ -34,7 +34,7 @@ namespace Ui namespace lay { - class LayoutView; + class LayoutViewBase; } namespace lay @@ -61,7 +61,7 @@ public: XORToolDialog (QWidget *parent); ~XORToolDialog (); - int exec_dialog (lay::LayoutView *view); + int exec_dialog (lay::LayoutViewBase *view); protected: void accept (); @@ -74,7 +74,7 @@ protected slots: private: Ui::XORToolDialog *mp_ui; - tl::weak_ptr mp_view; + tl::weak_ptr mp_view; }; } diff --git a/src/with_all_libs.pri b/src/with_all_libs.pri index b3bed76b0..23ea4963e 100644 --- a/src/with_all_libs.pri +++ b/src/with_all_libs.pri @@ -1,20 +1,15 @@ -INCLUDEPATH += $$RBA_INC $$PYA_INC $$TL_INC $$GSI_INC $$DB_INC $$RDB_INC $$LYM_INC $$LAYBASIC_INC $$LAY_INC $$ANT_INC $$IMG_INC $$EDT_INC $$LIB_INC $$VERSION_INC -DEPENDPATH += $$RBA_INC $$PYA_INC $$TL_INC $$GSI_INC $$DB_INC $$RDB_INC $$LYM_INC $$LAYBASIC_INC $$LAY_INC $$ANT_INC $$IMG_INC $$EDT_INC $$LIB_INC $$VERSION_INC +INCLUDEPATH += $$RBA_INC $$PYA_INC $$TL_INC $$GSI_INC $$DB_INC $$RDB_INC $$LYM_INC $$LAYBASIC_INC $$LAYVIEW_INC $$ANT_INC $$IMG_INC $$EDT_INC $$LIB_INC $$VERSION_INC +DEPENDPATH += $$RBA_INC $$PYA_INC $$TL_INC $$GSI_INC $$DB_INC $$RDB_INC $$LYM_INC $$LAYBASIC_INC $$LAYVIEW_INC $$ANT_INC $$IMG_INC $$EDT_INC $$LIB_INC $$VERSION_INC -LIBS += "$$PYTHONLIBFILE" "$$RUBYLIBFILE" -L$$DESTDIR -lklayout_tl -lklayout_gsi -lklayout_db -lklayout_rdb -lklayout_lib +LIBS += "$$PYTHONLIBFILE" "$$RUBYLIBFILE" -L$$DESTDIR -lklayout_tl -lklayout_gsi -lklayout_db -lklayout_rdb -lklayout_lym -lklayout_laybasic -lklayout_layview -lklayout_ant -lklayout_img -lklayout_edt -lklayout_lib !equals(HAVE_QT, "0") { - INCLUDEPATH += $$LYM_INC $$LAYBASIC_INC $$LAY_INC $$ANT_INC $$IMG_INC $$EDT_INC - DEPENDPATH += $$LYM_INC $$LAYBASIC_INC $$LAY_INC $$ANT_INC $$IMG_INC $$EDT_INC + INCLUDEPATH += $$LAYUI_INC $$LAY_INC + DEPENDPATH += $$LAYUI_INC $$LAY_INC - LIBS += -L$$DESTDIR -lklayout_lym -lklayout_laybasic -lklayout_lay -lklayout_ant -lklayout_img -lklayout_edt - - # Note: this accounts for UI-generated headers placed into the output folders in - # shadow builds: - INCLUDEPATH += $$DESTDIR/laybasic $$DESTDIR/lay $$DESTDIR/ext - DEPENDPATH += $$DESTDIR/laybasic $$DESTDIR/lay $$DESTDIR/ext + LIBS += -L$$DESTDIR -lklayout_layui -lklayout_lay equals(HAVE_QTBINDINGS, "1") { LIBS += -lklayout_qtbasic -lklayout_QtGui -lklayout_QtCore From f0dcd59060076729113ff2707ca7e273e5aa4fb8 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 15 May 2022 17:29:08 +0200 Subject: [PATCH 69/88] WIP --- src/klayout.pro | 4 ++-- src/laybasic/laybasic/layLayoutViewBase.cc | 24 +++++++++++----------- src/laybasic/laybasic/layLayoutViewBase.h | 10 ++++----- src/layview/layview/layLayoutView_qt.cc | 6 ++---- src/layview/layview/layLayoutView_qt.h | 4 +--- 5 files changed, 22 insertions(+), 26 deletions(-) diff --git a/src/klayout.pro b/src/klayout.pro index a2ece4bb7..4a17bdc57 100644 --- a/src/klayout.pro +++ b/src/klayout.pro @@ -101,9 +101,9 @@ equals(HAVE_RUBY, "1") { } - layui.depends += rdb + layui.depends += laybasic layview.depends += layui - lay.depends += laybasic ant img edt layui + lay.depends += ant img edt layui plugins.depends += lay diff --git a/src/laybasic/laybasic/layLayoutViewBase.cc b/src/laybasic/laybasic/layLayoutViewBase.cc index cd8af3a8c..f6f1da238 100644 --- a/src/laybasic/laybasic/layLayoutViewBase.cc +++ b/src/laybasic/laybasic/layLayoutViewBase.cc @@ -235,11 +235,11 @@ struct OpDeleteLayerProps const double animation_interval = 0.5; -LayoutViewBase::LayoutViewBase (db::Manager *manager, bool editable, lay::Plugin *plugin_parent, unsigned int options) - : lay::Dispatcher (plugin_parent, false /*not standalone*/), +LayoutViewBase::LayoutViewBase (db::Manager *manager, bool editable, lay::Plugin *plugin_parent, unsigned int options) : #if defined(HAVE_QT) - mp_widget (0), + QFrame (0), #endif + lay::Dispatcher (plugin_parent, false /*not standalone*/), mp_ui (0), m_editable (editable), m_options (options), @@ -252,14 +252,14 @@ LayoutViewBase::LayoutViewBase (db::Manager *manager, bool editable, lay::Plugin } #if defined(HAVE_QT) -LayoutViewBase::LayoutViewBase (QWidget *widget, lay::LayoutView *ui, db::Manager *manager, bool editable, lay::Plugin *plugin_parent, unsigned int options) +LayoutViewBase::LayoutViewBase (QWidget *parent, lay::LayoutView *ui, db::Manager *manager, bool editable, lay::Plugin *plugin_parent, unsigned int options) : #else -LayoutViewBase::LayoutViewBase (lay::LayoutView *ui, db::Manager *manager, bool editable, lay::Plugin *plugin_parent, unsigned int options) +LayoutViewBase::LayoutViewBase (lay::LayoutView *ui, db::Manager *manager, bool editable, lay::Plugin *plugin_parent, unsigned int options) : #endif - : lay::Dispatcher (plugin_parent, false /*not standalone*/), #if defined(HAVE_QT) - mp_widget (widget), + QFrame (parent), #endif + lay::Dispatcher (plugin_parent, false /*not standalone*/), mp_ui (ui), m_editable (editable), m_options (options), @@ -272,14 +272,14 @@ LayoutViewBase::LayoutViewBase (lay::LayoutView *ui, db::Manager *manager, bool } #if defined(HAVE_QT) -LayoutViewBase::LayoutViewBase (QWidget *widget, lay::LayoutView *ui, lay::LayoutViewBase *source, db::Manager *manager, bool editable, lay::Plugin *plugin_parent, unsigned int options) +LayoutViewBase::LayoutViewBase (QWidget *parent, lay::LayoutView *ui, lay::LayoutViewBase *source, db::Manager *manager, bool editable, lay::Plugin *plugin_parent, unsigned int options) : #else -LayoutViewBase::LayoutViewBase (lay::LayoutView *ui, lay::LayoutViewBase *source, db::Manager *manager, bool editable, lay::Plugin *plugin_parent, unsigned int options) +LayoutViewBase::LayoutViewBase (lay::LayoutView *ui, lay::LayoutViewBase *source, db::Manager *manager, bool editable, lay::Plugin *plugin_parent, unsigned int options) : #endif - : lay::Dispatcher (plugin_parent, false /*not standalone*/), #if defined(HAVE_QT) - mp_widget (widget), + QFrame (parent), #endif + lay::Dispatcher (plugin_parent, false /*not standalone*/), mp_ui (ui), m_editable (editable), m_options (options), @@ -3375,7 +3375,7 @@ LayoutViewBase::box () const QWidget * LayoutViewBase::widget () { - return mp_widget; + return this; } #endif diff --git a/src/laybasic/laybasic/layLayoutViewBase.h b/src/laybasic/laybasic/layLayoutViewBase.h index 0c41cf425..46ede53ed 100644 --- a/src/laybasic/laybasic/layLayoutViewBase.h +++ b/src/laybasic/laybasic/layLayoutViewBase.h @@ -54,7 +54,7 @@ #include "dbInstElement.h" #if defined(HAVE_QT) -class QWidget; +# include #endif namespace rdb { @@ -155,6 +155,9 @@ struct LAYBASIC_PUBLIC LayerDisplayProperties * It manages the layer display list, bookmark list etc. */ class LAYBASIC_PUBLIC LayoutViewBase : +#if defined(HAVE_QT) + public QFrame, +#endif public lay::Editables, public lay::Dispatcher { @@ -193,7 +196,7 @@ public: * @brief Constructor */ #if defined(HAVE_QT) - LayoutViewBase (QWidget *widget, lay::LayoutView *ui, db::Manager *mgr, bool editable, lay::Plugin *plugin_parent, unsigned int options = (unsigned int) LV_Normal); + LayoutViewBase (QWidget *parent, lay::LayoutView *ui, db::Manager *mgr, bool editable, lay::Plugin *plugin_parent, unsigned int options = (unsigned int) LV_Normal); #else LayoutViewBase (lay::LayoutView *ui, db::Manager *mgr, bool editable, lay::Plugin *plugin_parent, unsigned int options = (unsigned int) LV_Normal); #endif @@ -2667,9 +2670,6 @@ private: void signal_apply_technology (lay::LayoutHandle *layout_handle); private: -#if defined(HAVE_QT) - QWidget *mp_widget; -#endif lay::LayoutView *mp_ui; bool m_editable; int m_disabled_edits; diff --git a/src/layview/layview/layLayoutView_qt.cc b/src/layview/layview/layLayoutView_qt.cc index 3606f56ce..9c41b9f4b 100644 --- a/src/layview/layview/layLayoutView_qt.cc +++ b/src/layview/layview/layLayoutView_qt.cc @@ -93,8 +93,7 @@ const int timer_interval = 10; static LayoutView *ms_current = 0; LayoutView::LayoutView (db::Manager *manager, bool editable, lay::Plugin *plugin_parent, QWidget *parent, const char *name, unsigned int options) - : QFrame (parent), - LayoutViewBase (this, this, manager, editable, plugin_parent, options), + : LayoutViewBase (parent, this, manager, editable, plugin_parent, options), dm_setup_editor_option_pages (this, &LayoutView::do_setup_editor_options_pages) { // ensures the deferred method scheduler is present @@ -105,8 +104,7 @@ LayoutView::LayoutView (db::Manager *manager, bool editable, lay::Plugin *plugin } LayoutView::LayoutView (lay::LayoutView *source, db::Manager *manager, bool editable, lay::Plugin *plugin_parent, QWidget *parent, const char *name, unsigned int options) - : QFrame (parent), - LayoutViewBase (this, this, source, manager, editable, plugin_parent, options), + : LayoutViewBase (parent, this, source, manager, editable, plugin_parent, options), dm_setup_editor_option_pages (this, &LayoutView::do_setup_editor_options_pages) { // ensures the deferred method scheduler is present diff --git a/src/layview/layview/layLayoutView_qt.h b/src/layview/layview/layLayoutView_qt.h index 486abc108..9d2378218 100644 --- a/src/layview/layview/layLayoutView_qt.h +++ b/src/layview/layview/layLayoutView_qt.h @@ -54,7 +54,6 @@ #include #include -#include #include class QSpinBox; @@ -94,8 +93,7 @@ class EditorOptionsPages; * It manages the layer display list, bookmark list etc. */ class LAYVIEW_PUBLIC LayoutView - : public QFrame, - public LayoutViewBase + : public LayoutViewBase { Q_OBJECT From 856635bc82bfb88f77d206dcea426eacbe29e0b3 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 15 May 2022 18:45:07 +0200 Subject: [PATCH 70/88] WIP: debugging, enabled pymod builds ... --- setup.py | 125 +++++++----------- .../laybasic/gsiDeclLayLayoutViewBase.cc | 28 ---- src/layui/layui/layui.pro | 6 - .../layview}/GridNetConfigPage.ui | 0 .../layview/gsiDeclLayLayoutView_noqt.cc | 31 +++++ .../layview/gsiDeclLayLayoutView_qt.cc | 3 + .../layui => layview/layview}/layGridNet.cc | 0 .../layui => layview/layview}/layGridNet.h | 0 .../layview}/layGridNetConfigPage.cc | 0 .../layview}/layGridNetConfigPage.h | 0 src/layview/layview/layLayoutView_noqt.cc | 4 + src/layview/layview/layLayoutView_noqt.h | 3 + src/layview/layview/layLayoutView_qt.cc | 5 + src/layview/layview/layLayoutView_qt.h | 3 + src/layview/layview/layview.pro | 11 +- 15 files changed, 108 insertions(+), 111 deletions(-) rename src/{layui/layui => layview/layview}/GridNetConfigPage.ui (100%) rename src/{layui/layui => layview/layview}/layGridNet.cc (100%) rename src/{layui/layui => layview/layview}/layGridNet.h (100%) rename src/{layui/layui => layview/layview}/layGridNetConfigPage.cc (100%) rename src/{layui/layui => layview/layview}/layGridNetConfigPage.h (100%) diff --git a/setup.py b/setup.py index bf826a911..d2105dd64 100644 --- a/setup.py +++ b/setup.py @@ -524,21 +524,38 @@ _rdb = Library(config.root + '._rdb', config.add_extension(_rdb) # ------------------------------------------------------------------ -# _lay dependency library +# _laybasic dependency library -_lay_path = os.path.join("src", "laybasic", "laybasic") -_lay_sources = set(glob.glob(os.path.join(_lay_path, "*.cc"))) +_laybasic_path = os.path.join("src", "laybasic", "laybasic") +_laybasic_sources = set(glob.glob(os.path.join(_laybasic_path, "*.cc"))) -_lay = Library(config.root + '._lay', +_laybasic = Library(config.root + '._laybasic', define_macros=config.macros() + [('MAKE_LAYBASIC_LIBRARY', 1)], include_dirs=[_rdb_path, _db_path, _tl_path, _gsi_path], extra_objects=[config.path_of('_rdb', _rdb_path), config.path_of('_tl', _tl_path), config.path_of('_gsi', _gsi_path), config.path_of('_db', _db_path)], language='c++', - libraries=config.libraries('_lay'), - extra_link_args=config.link_args('_lay'), - extra_compile_args=config.compile_args('_lay'), - sources=list(_lay_sources)) -config.add_extension(_lay) + libraries=config.libraries('_laybasic'), + extra_link_args=config.link_args('_laybasic'), + extra_compile_args=config.compile_args('_laybasic'), + sources=list(_laybasic_sources)) +config.add_extension(_laybasic) + +# ------------------------------------------------------------------ +# _layview dependency library + +_layview_path = os.path.join("src", "layview", "layview") +_layview_sources = set(glob.glob(os.path.join(_layview_path, "*.cc"))) + +_layview = Library(config.root + '._layview', + define_macros=config.macros() + [('MAKE_LAYVIEW_LIBRARY', 1)], + include_dirs=[_laybasic_path, _rdb_path, _db_path, _tl_path, _gsi_path], + extra_objects=[config.path_of('_laybasic', _laybasic_path), config.path_of('_rdb', _rdb_path), config.path_of('_tl', _tl_path), config.path_of('_gsi', _gsi_path), config.path_of('_db', _db_path)], + language='c++', + libraries=config.libraries('_layview'), + extra_link_args=config.link_args('_layview'), + extra_compile_args=config.compile_args('_layview'), + sources=list(_layview_sources)) +config.add_extension(_layview) # ------------------------------------------------------------------ # _lym dependency library @@ -565,8 +582,8 @@ _ant_sources = set(glob.glob(os.path.join(_ant_path, "*.cc"))) _ant = Library(config.root + '._ant', define_macros=config.macros() + [('MAKE_ANT_LIBRARY', 1)], - include_dirs=[_lay_path, _rdb_path, _db_path, _tl_path, _gsi_path], - extra_objects=[config.path_of('_lay', _lay_path), config.path_of('_rdb', _rdb_path), config.path_of('_tl', _tl_path), config.path_of('_gsi', _gsi_path), config.path_of('_db', _db_path)], + include_dirs=[_laybasic_path, _layview_path, _rdb_path, _db_path, _tl_path, _gsi_path], + extra_objects=[config.path_of('_laybasic', _laybasic_path), config.path_of('_layview', _layview_path), config.path_of('_rdb', _rdb_path), config.path_of('_tl', _tl_path), config.path_of('_gsi', _gsi_path), config.path_of('_db', _db_path)], language='c++', libraries=config.libraries('_ant'), extra_link_args=config.link_args('_ant'), @@ -582,8 +599,8 @@ _img_sources = set(glob.glob(os.path.join(_img_path, "*.cc"))) _img = Library(config.root + '._img', define_macros=config.macros() + [('MAKE_ANT_LIBRARY', 1)], - include_dirs=[_lay_path, _rdb_path, _db_path, _tl_path, _gsi_path], - extra_objects=[config.path_of('_lay', _lay_path), config.path_of('_rdb', _rdb_path), config.path_of('_tl', _tl_path), config.path_of('_gsi', _gsi_path), config.path_of('_db', _db_path)], + include_dirs=[_laybasic_path, _layview_path, _rdb_path, _db_path, _tl_path, _gsi_path], + extra_objects=[config.path_of('_laybasic', _laybasic_path), config.path_of('_layview', _layview_path), config.path_of('_rdb', _rdb_path), config.path_of('_tl', _tl_path), config.path_of('_gsi', _gsi_path), config.path_of('_db', _db_path)], language='c++', libraries=config.libraries('_img'), extra_link_args=config.link_args('_img'), @@ -599,8 +616,8 @@ _edt_sources = set(glob.glob(os.path.join(_edt_path, "*.cc"))) _edt = Library(config.root + '._edt', define_macros=config.macros() + [('MAKE_ANT_LIBRARY', 1)], - include_dirs=[_lay_path, _rdb_path, _db_path, _tl_path, _gsi_path], - extra_objects=[config.path_of('_lay', _lay_path), config.path_of('_rdb', _rdb_path), config.path_of('_tl', _tl_path), config.path_of('_gsi', _gsi_path), config.path_of('_db', _db_path)], + include_dirs=[_laybasic_path, _layview_path, _rdb_path, _db_path, _tl_path, _gsi_path], + extra_objects=[config.path_of('_laybasic', _laybasic_path), config.path_of('_layview', _layview_path), config.path_of('_rdb', _rdb_path), config.path_of('_tl', _tl_path), config.path_of('_gsi', _gsi_path), config.path_of('_db', _db_path)], language='c++', libraries=config.libraries('_edt'), extra_link_args=config.link_args('_edt'), @@ -699,68 +716,28 @@ lay_sources = set(glob.glob(os.path.join(lay_path, "*.cc"))) lay = Extension(config.root + '.laycore', define_macros=config.macros(), - include_dirs=[_lay_path, _img_path, _ant_path, _edt_path, _lym_path, _tl_path, _gsi_path, _pya_path], - extra_objects=[config.path_of('_lay', _lay_path), config.path_of('_img', _img_path), config.path_of('_ant', _ant_path), config.path_of('_edt', _edt_path), config.path_of('_lym', _lym_path), config.path_of('_tl', _tl_path), config.path_of('_gsi', _gsi_path), config.path_of('_pya', _pya_path)], + include_dirs=[_laybasic_path, + _layview_path, + _img_path, + _ant_path, + _edt_path, + _lym_path, + _tl_path, + _gsi_path, + _pya_path], + extra_objects=[config.path_of('_laybasic', _laybasic_path), + config.path_of('_layview', _layview_path), + config.path_of('_img', _img_path), + config.path_of('_ant', _ant_path), + config.path_of('_edt', _edt_path), + config.path_of('_lym', _lym_path), + config.path_of('_tl', _tl_path), + config.path_of('_gsi', _gsi_path), + config.path_of('_pya', _pya_path)], extra_link_args=config.link_args('laycore'), extra_compile_args=config.compile_args('laycore'), sources=list(lay_sources)) -# ------------------------------------------------------------------ -# ant extension library - -ant_path = os.path.join("src", "pymod", "ant") -ant_sources = set(glob.glob(os.path.join(ant_path, "*.cc"))) - -ant = Extension(config.root + '.antcore', - define_macros=config.macros(), - include_dirs=[_ant_path, _tl_path, _gsi_path, _pya_path], - extra_objects=[config.path_of('_ant', _ant_path), config.path_of('_tl', _tl_path), config.path_of('_gsi', _gsi_path), config.path_of('_pya', _pya_path)], - extra_link_args=config.link_args('antcore'), - extra_compile_args=config.compile_args('antcore'), - sources=list(ant_sources)) - -# ------------------------------------------------------------------ -# edt extension library - -edt_path = os.path.join("src", "pymod", "edt") -edt_sources = set(glob.glob(os.path.join(edt_path, "*.cc"))) - -edt = Extension(config.root + '.edtcore', - define_macros=config.macros(), - include_dirs=[_edt_path, _tl_path, _gsi_path, _pya_path], - extra_objects=[config.path_of('_edt', _edt_path), config.path_of('_tl', _tl_path), config.path_of('_gsi', _gsi_path), config.path_of('_pya', _pya_path)], - extra_link_args=config.link_args('edtcore'), - extra_compile_args=config.compile_args('edtcore'), - sources=list(edt_sources)) - -# ------------------------------------------------------------------ -# img extension library - -img_path = os.path.join("src", "pymod", "img") -img_sources = set(glob.glob(os.path.join(img_path, "*.cc"))) - -img = Extension(config.root + '.imgcore', - define_macros=config.macros(), - include_dirs=[_img_path, _tl_path, _gsi_path, _pya_path], - extra_objects=[config.path_of('_img', _img_path), config.path_of('_tl', _tl_path), config.path_of('_gsi', _gsi_path), config.path_of('_pya', _pya_path)], - extra_link_args=config.link_args('imgcore'), - extra_compile_args=config.compile_args('imgcore'), - sources=list(img_sources)) - -# ------------------------------------------------------------------ -# lym extension library - -lym_path = os.path.join("src", "pymod", "lym") -lym_sources = set(glob.glob(os.path.join(lym_path, "*.cc"))) - -lym = Extension(config.root + '.lymcore', - define_macros=config.macros(), - include_dirs=[_lym_path, _tl_path, _gsi_path, _pya_path], - extra_objects=[config.path_of('_lym', _lym_path), config.path_of('_tl', _tl_path), config.path_of('_gsi', _gsi_path), config.path_of('_pya', _pya_path)], - extra_link_args=config.link_args('lymcore'), - extra_compile_args=config.compile_args('lymcore'), - sources=list(lym_sources)) - # ------------------------------------------------------------------ # Core setup function @@ -786,4 +763,4 @@ if __name__ == '__main__': url='https://github.com/klayout/klayout', packages=find_packages('src/pymod/distutils_src'), package_dir={'': 'src/pymod/distutils_src'}, # https://github.com/pypa/setuptools/issues/230 - ext_modules=[_tl, _gsi, _pya, _rba, _db, _lib, _rdb, _lym, _lay, _ant, _edt, _img] + db_plugins + [tl, db, lib, rdb, lay, ant, edt, img, lym]) + ext_modules=[_tl, _gsi, _pya, _rba, _db, _lib, _rdb, _lym, _laybasic, _layview, _ant, _edt, _img] + db_plugins + [tl, db, lib, rdb, lay]) diff --git a/src/laybasic/laybasic/gsiDeclLayLayoutViewBase.cc b/src/laybasic/laybasic/gsiDeclLayLayoutViewBase.cc index 765271b88..b13ae2f36 100644 --- a/src/laybasic/laybasic/gsiDeclLayLayoutViewBase.cc +++ b/src/laybasic/laybasic/gsiDeclLayLayoutViewBase.cc @@ -1546,34 +1546,6 @@ LAYBASIC_PUBLIC Class decl_LayoutViewBase (QT_EXTERNAL_BASE "Returns an array of \\LayerPropertiesIterator objects pointing to the currently selected layers. " "If no layer view is selected currently, an empty array is returned.\n" ) + -#if !defined(HAVE_QT) - gsi::event ("on_image_updated_event", static_cast (&lay::LayoutViewBase::image_updated_event), - "@brief An event indicating that the image (\"screenshot\") was updated\n" - "\n" - "This event is triggered when calling \\timer." - "\n" - "This event has been introduced in version 0.28." - ) + - gsi::event ("on_drawing_finished_event", static_cast (&lay::LayoutViewBase::drawing_finished_event), - "@brief An event indicating that the image is fully drawn\n" - "\n" - "This event is triggered when calling \\timer. " - "Before this event is issue, a final \\on_image_updated_event may be issued.\n" - "\n" - "This event has been introduced in version 0.28." - ) + - gsi::method ("timer", static_cast (&lay::LayoutViewBase::timer), - "@brief A callback required to be called regularily in the non-Qt case.\n" - "\n" - "This callback eventually implements the event loop in the non-Qt case. The main task " - "is to indicate new versions of the layout image while it is drawn. " - "When a new image has arrived, this method will issue an \\on_image_updated_event. " - "In the implementation of the latter, \"screenshot\" may be called to retrieve the current image.\n" - "When drawing has finished, the \\on_drawing_finished_event will be triggered.\n" - "\n" - "This method has been introduced in version 0.28." - ) + -#endif gsi::event ("on_active_cellview_changed", static_cast (&lay::LayoutViewBase::active_cellview_changed_event), "@brief An event indicating that the active cellview has changed\n" "\n" diff --git a/src/layui/layui/layui.pro b/src/layui/layui/layui.pro index 733082897..0b2e9f730 100644 --- a/src/layui/layui/layui.pro +++ b/src/layui/layui/layui.pro @@ -23,7 +23,6 @@ FORMS = \ DuplicateLayerDialog.ui \ EditStipplesForm.ui \ FlattenInstOptionsDialog.ui \ - GridNetConfigPage.ui \ LayerMappingWidget.ui \ LayerSourceDialog.ui \ LayoutProperties.ui \ @@ -105,8 +104,6 @@ SOURCES = \ layEditorOptionsPage.cc \ layEditorOptionsPages.cc \ layFileDialog.cc \ - layGridNetConfigPage.cc \ - layGridNet.cc \ layGenericSyntaxHighlighter.cc \ layHierarchyControlPanel.cc \ layIndexedNetlistModel.cc \ @@ -165,8 +162,6 @@ HEADERS = \ layEditorOptionsPages.h \ layFileDialog.h \ layGenericSyntaxHighlighter.h \ - layGridNetConfigPage.h \ - layGridNet.h \ layHierarchyControlPanel.h \ layIndexedNetlistModel.h \ layItemDelegates.h \ @@ -196,7 +191,6 @@ HEADERS = \ layTechnology.h \ layTipDialog.h \ layWidgets.h \ - laybasicConfig.h \ rdbInfoWidget.h \ rdbMarkerBrowser.h \ rdbMarkerBrowserDialog.h \ diff --git a/src/layui/layui/GridNetConfigPage.ui b/src/layview/layview/GridNetConfigPage.ui similarity index 100% rename from src/layui/layui/GridNetConfigPage.ui rename to src/layview/layview/GridNetConfigPage.ui diff --git a/src/layview/layview/gsiDeclLayLayoutView_noqt.cc b/src/layview/layview/gsiDeclLayLayoutView_noqt.cc index 528636548..c3162124f 100644 --- a/src/layview/layview/gsiDeclLayLayoutView_noqt.cc +++ b/src/layview/layview/gsiDeclLayLayoutView_noqt.cc @@ -20,7 +20,10 @@ */ +#if !defined(HAVE_QT) + #include "gsiDecl.h" +#include "gsiSignals.h" #include "layLayoutView.h" namespace gsi @@ -46,6 +49,32 @@ Class decl_LayoutView (decl_LayoutViewBase, "lay", "LayoutView" "\n" "This constructor has been introduced in version 0.25.\n" "It has been enhanced with the arguments in version 0.27.\n" + ) + + gsi::event ("on_image_updated_event", static_cast (&lay::LayoutView::image_updated_event), + "@brief An event indicating that the image (\"screenshot\") was updated\n" + "\n" + "This event is triggered when calling \\timer." + "\n" + "This event has been introduced in version 0.28." + ) + + gsi::event ("on_drawing_finished_event", static_cast (&lay::LayoutView::drawing_finished_event), + "@brief An event indicating that the image is fully drawn\n" + "\n" + "This event is triggered when calling \\timer. " + "Before this event is issue, a final \\on_image_updated_event may be issued.\n" + "\n" + "This event has been introduced in version 0.28." + ) + + gsi::method ("timer", static_cast (&lay::LayoutView::timer), + "@brief A callback required to be called regularily in the non-Qt case.\n" + "\n" + "This callback eventually implements the event loop in the non-Qt case. The main task " + "is to indicate new versions of the layout image while it is drawn. " + "When a new image has arrived, this method will issue an \\on_image_updated_event. " + "In the implementation of the latter, \"screenshot\" may be called to retrieve the current image.\n" + "When drawing has finished, the \\on_drawing_finished_event will be triggered.\n" + "\n" + "This method has been introduced in version 0.28." ), "@brief The view object presenting one or more layout objects\n" "\n" @@ -82,3 +111,5 @@ static ClassExt extdecl_LayerPropertiesNode ( } +#endif + diff --git a/src/layview/layview/gsiDeclLayLayoutView_qt.cc b/src/layview/layview/gsiDeclLayLayoutView_qt.cc index 7ea2ef2e2..aac221373 100644 --- a/src/layview/layview/gsiDeclLayLayoutView_qt.cc +++ b/src/layview/layview/gsiDeclLayLayoutView_qt.cc @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #include "gsiDecl.h" #include "gsiSignals.h" @@ -221,3 +222,5 @@ static ClassExt extdecl_LayerPropertiesNode ( ); } + +#endif diff --git a/src/layui/layui/layGridNet.cc b/src/layview/layview/layGridNet.cc similarity index 100% rename from src/layui/layui/layGridNet.cc rename to src/layview/layview/layGridNet.cc diff --git a/src/layui/layui/layGridNet.h b/src/layview/layview/layGridNet.h similarity index 100% rename from src/layui/layui/layGridNet.h rename to src/layview/layview/layGridNet.h diff --git a/src/layui/layui/layGridNetConfigPage.cc b/src/layview/layview/layGridNetConfigPage.cc similarity index 100% rename from src/layui/layui/layGridNetConfigPage.cc rename to src/layview/layview/layGridNetConfigPage.cc diff --git a/src/layui/layui/layGridNetConfigPage.h b/src/layview/layview/layGridNetConfigPage.h similarity index 100% rename from src/layui/layui/layGridNetConfigPage.h rename to src/layview/layview/layGridNetConfigPage.h diff --git a/src/layview/layview/layLayoutView_noqt.cc b/src/layview/layview/layLayoutView_noqt.cc index 20c612067..6b8743a40 100644 --- a/src/layview/layview/layLayoutView_noqt.cc +++ b/src/layview/layview/layLayoutView_noqt.cc @@ -20,6 +20,8 @@ */ +#if !defined(HAVE_QT) + #include "layLayoutView.h" namespace lay @@ -58,3 +60,5 @@ LayoutView::timer () } } // namespace lay + +#endif diff --git a/src/layview/layview/layLayoutView_noqt.h b/src/layview/layview/layLayoutView_noqt.h index 9c1d16c52..0288d6081 100644 --- a/src/layview/layview/layLayoutView_noqt.h +++ b/src/layview/layview/layLayoutView_noqt.h @@ -20,6 +20,7 @@ */ +#if !defined(HAVE_QT) #ifndef HDR_layLayoutViewNoQt #define HDR_layLayoutViewNoQt @@ -78,3 +79,5 @@ private: } #endif + +#endif diff --git a/src/layview/layview/layLayoutView_qt.cc b/src/layview/layview/layLayoutView_qt.cc index 9c41b9f4b..e8805b1b3 100644 --- a/src/layview/layview/layLayoutView_qt.cc +++ b/src/layview/layview/layLayoutView_qt.cc @@ -20,6 +20,8 @@ */ +#if defined(HAVE_QT) + #include #include #include @@ -1083,3 +1085,6 @@ LayoutView::sizeHint () const } } // namespace lay + +#endif + diff --git a/src/layview/layview/layLayoutView_qt.h b/src/layview/layview/layLayoutView_qt.h index 9d2378218..fe65fde62 100644 --- a/src/layview/layview/layLayoutView_qt.h +++ b/src/layview/layview/layLayoutView_qt.h @@ -20,6 +20,7 @@ */ +#if defined(HAVE_QT) #ifndef HDR_layLayoutViewQt #define HDR_layLayoutViewQt @@ -738,3 +739,5 @@ private: } #endif + +#endif diff --git a/src/layview/layview/layview.pro b/src/layview/layview/layview.pro index eb6211e0a..ed2df8454 100644 --- a/src/layview/layview/layview.pro +++ b/src/layview/layview/layview.pro @@ -6,22 +6,27 @@ include($$PWD/../../lib.pri) DEFINES += MAKE_LAYVIEW_LIBRARY -FORMS = \ - RESOURCES = \ SOURCES = \ + layGridNet.cc \ HEADERS = \ - layLayoutView.h + layGridNet.h \ + layLayoutView.h \ !equals(HAVE_QT, "0") { + FORMS = \ + GridNetConfigPage.ui \ + SOURCES += \ + layGridNetConfigPage.cc \ layLayoutView_qt.cc \ gsiDeclLayLayoutView_qt.cc \ HEADERS += \ + layGridNetConfigPage.h \ layLayoutView_qt.h \ } else { From 104975a14eb4907b557998dacdb82d755034c32c Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 15 May 2022 19:34:46 +0200 Subject: [PATCH 71/88] WIP: fixed pymod --- setup.py | 4 +- src/laybasic/laybasic/laybasicForceLink.h | 2 +- src/layui/layui/layui.pro | 230 +++++++++++----------- src/layui/layui/layuiForceLink.cc | 32 +++ src/layui/layui/layuiForceLink.h | 40 ++++ src/layview/layview/layview.pro | 2 + src/layview/layview/layviewForceLink.cc | 32 +++ src/layview/layview/layviewForceLink.h | 40 ++++ src/pymod/lay/layMain.cc | 10 +- 9 files changed, 267 insertions(+), 125 deletions(-) create mode 100644 src/layui/layui/layuiForceLink.cc create mode 100644 src/layui/layui/layuiForceLink.h create mode 100644 src/layview/layview/layviewForceLink.cc create mode 100644 src/layview/layview/layviewForceLink.h diff --git a/setup.py b/setup.py index d2105dd64..305249a07 100644 --- a/setup.py +++ b/setup.py @@ -287,12 +287,12 @@ class Config(object): if platform.system() == "Windows": if mod == "_tl": return [ "libcurl", "expat", "pthreadVCE2", "zlib", "wsock32" ] - elif mod == "_lay": + elif mod == "_laybasic": return [ "libpng" ] else: if mod == "_tl": return ['curl', 'expat'] - elif mod == "_lay": + elif mod == "_laybasic": return [ 'png' ] return [] diff --git a/src/laybasic/laybasic/laybasicForceLink.h b/src/laybasic/laybasic/laybasicForceLink.h index 1f84613ce..af2188be3 100644 --- a/src/laybasic/laybasic/laybasicForceLink.h +++ b/src/laybasic/laybasic/laybasicForceLink.h @@ -27,7 +27,7 @@ #include "laybasicCommon.h" /** - * @file Include this function to force linking of the lay module + * @file Include this function to force linking of the laybasic module */ namespace laybasic diff --git a/src/layui/layui/layui.pro b/src/layui/layui/layui.pro index 0b2e9f730..086291e28 100644 --- a/src/layui/layui/layui.pro +++ b/src/layui/layui/layui.pro @@ -79,122 +79,124 @@ RESOURCES = \ layLayoutStatistics.qrc \ SOURCES = \ - gsiDeclLayDialogs.cc \ - gsiDeclLayMenu.cc \ - gsiDeclLayNetlistBrowserDialog.cc \ - gsiDeclLayStream.cc \ - layBackgroundAwareTreeStyle.cc \ - layBookmarkManagementForm.cc \ - layBookmarksView.cc \ - layBrowseInstancesForm.cc \ - layBrowseShapesForm.cc \ - layBrowser.cc \ - layBrowserDialog.cc \ - layBrowserPanel.cc \ - layBusy.cc \ - layCellSelectionForm.cc \ - layCellTreeModel.cc \ - layConfigurationDialog.cc \ - layDialogs.cc \ - layEditLineStyleWidget.cc \ - layEditLineStylesForm.cc \ - layEditStippleWidget.cc \ - layEditStipplesForm.cc \ - layEditorOptionsFrame.cc \ - layEditorOptionsPage.cc \ - layEditorOptionsPages.cc \ - layFileDialog.cc \ - layGenericSyntaxHighlighter.cc \ - layHierarchyControlPanel.cc \ - layIndexedNetlistModel.cc \ - layItemDelegates.cc \ - layLayerControlPanel.cc \ - layLayerMappingWidget.cc \ - layLayerToolbox.cc \ - layLayerTreeModel.cc \ - layLayoutPropertiesForm.cc \ - layLayoutStatisticsForm.cc \ - layLayoutViewConfigPages.cc \ - layLayoutViewFunctions.cc \ - layLibrariesView.cc \ - layLoadLayoutOptionsDialog.cc \ - layNetExportDialog.cc \ - layNetInfoDialog.cc \ - layNetlistBrowser.cc \ - layNetlistBrowserDialog.cc \ - layNetlistBrowserModel.cc \ - layNetlistBrowserPage.cc \ - layNetlistBrowserTreeModel.cc \ - layNetlistCrossReferenceModel.cc \ - layQtTools.cc \ - laySaveLayoutOptionsDialog.cc \ - laySelectCellViewForm.cc \ - laySelectLineStyleForm.cc \ - laySelectStippleForm.cc \ - layTechnology.cc \ - layTipDialog.cc \ - layWidgets.cc \ - rdbInfoWidget.cc \ - rdbMarkerBrowser.cc \ - rdbMarkerBrowserDialog.cc \ - rdbMarkerBrowserPage.cc \ + gsiDeclLayDialogs.cc \ + gsiDeclLayMenu.cc \ + gsiDeclLayNetlistBrowserDialog.cc \ + gsiDeclLayStream.cc \ + layuiForceLink.cc \ + layBackgroundAwareTreeStyle.cc \ + layBookmarkManagementForm.cc \ + layBookmarksView.cc \ + layBrowseInstancesForm.cc \ + layBrowseShapesForm.cc \ + layBrowser.cc \ + layBrowserDialog.cc \ + layBrowserPanel.cc \ + layBusy.cc \ + layCellSelectionForm.cc \ + layCellTreeModel.cc \ + layConfigurationDialog.cc \ + layDialogs.cc \ + layEditLineStyleWidget.cc \ + layEditLineStylesForm.cc \ + layEditStippleWidget.cc \ + layEditStipplesForm.cc \ + layEditorOptionsFrame.cc \ + layEditorOptionsPage.cc \ + layEditorOptionsPages.cc \ + layFileDialog.cc \ + layGenericSyntaxHighlighter.cc \ + layHierarchyControlPanel.cc \ + layIndexedNetlistModel.cc \ + layItemDelegates.cc \ + layLayerControlPanel.cc \ + layLayerMappingWidget.cc \ + layLayerToolbox.cc \ + layLayerTreeModel.cc \ + layLayoutPropertiesForm.cc \ + layLayoutStatisticsForm.cc \ + layLayoutViewConfigPages.cc \ + layLayoutViewFunctions.cc \ + layLibrariesView.cc \ + layLoadLayoutOptionsDialog.cc \ + layNetExportDialog.cc \ + layNetInfoDialog.cc \ + layNetlistBrowser.cc \ + layNetlistBrowserDialog.cc \ + layNetlistBrowserModel.cc \ + layNetlistBrowserPage.cc \ + layNetlistBrowserTreeModel.cc \ + layNetlistCrossReferenceModel.cc \ + layQtTools.cc \ + laySaveLayoutOptionsDialog.cc \ + laySelectCellViewForm.cc \ + laySelectLineStyleForm.cc \ + laySelectStippleForm.cc \ + layTechnology.cc \ + layTipDialog.cc \ + layWidgets.cc \ + rdbInfoWidget.cc \ + rdbMarkerBrowser.cc \ + rdbMarkerBrowserDialog.cc \ + rdbMarkerBrowserPage.cc \ HEADERS = \ - layBackgroundAwareTreeStyle.h \ - layBookmarkManagementForm.h \ - layBookmarksView.h \ - layBrowseInstancesForm.h \ - layBrowseShapesForm.h \ - layBrowser.h \ - layBrowserDialog.h \ - layBrowserPanel.h \ - layBusy.h \ - layCellSelectionForm.h \ - layCellTreeModel.h \ - layConfigurationDialog.h \ - layDialogs.h \ - layEditLineStyleWidget.h \ - layEditLineStylesForm.h \ - layEditStippleWidget.h \ - layEditStipplesForm.h \ - layEditorOptionsFrame.h \ - layEditorOptionsPage.h \ - layEditorOptionsPages.h \ - layFileDialog.h \ - layGenericSyntaxHighlighter.h \ - layHierarchyControlPanel.h \ - layIndexedNetlistModel.h \ - layItemDelegates.h \ - layLayerControlPanel.h \ - layLayerMappingWidget.h \ - layLayerToolbox.h \ - layLayerTreeModel.h \ - layLayoutPropertiesForm.h \ - layLayoutStatisticsForm.h \ - layLayoutViewConfigPages.h \ - layLayoutViewFunctions.h \ - layLibrariesView.h \ - layLoadLayoutOptionsDialog.h \ - layNetExportDialog.h \ - layNetInfoDialog.h \ - layNetlistBrowser.h \ - layNetlistBrowserDialog.h \ - layNetlistBrowserModel.h \ - layNetlistBrowserPage.h \ - layNetlistBrowserTreeModel.h \ - layNetlistCrossReferenceModel.h \ - layQtTools.h \ - laySaveLayoutOptionsDialog.h \ - laySelectCellViewForm.h \ - laySelectLineStyleForm.h \ - laySelectStippleForm.h \ - layTechnology.h \ - layTipDialog.h \ - layWidgets.h \ - rdbInfoWidget.h \ - rdbMarkerBrowser.h \ - rdbMarkerBrowserDialog.h \ - rdbMarkerBrowserPage.h \ + layuiForceLink.h \ + layBackgroundAwareTreeStyle.h \ + layBookmarkManagementForm.h \ + layBookmarksView.h \ + layBrowseInstancesForm.h \ + layBrowseShapesForm.h \ + layBrowser.h \ + layBrowserDialog.h \ + layBrowserPanel.h \ + layBusy.h \ + layCellSelectionForm.h \ + layCellTreeModel.h \ + layConfigurationDialog.h \ + layDialogs.h \ + layEditLineStyleWidget.h \ + layEditLineStylesForm.h \ + layEditStippleWidget.h \ + layEditStipplesForm.h \ + layEditorOptionsFrame.h \ + layEditorOptionsPage.h \ + layEditorOptionsPages.h \ + layFileDialog.h \ + layGenericSyntaxHighlighter.h \ + layHierarchyControlPanel.h \ + layIndexedNetlistModel.h \ + layItemDelegates.h \ + layLayerControlPanel.h \ + layLayerMappingWidget.h \ + layLayerToolbox.h \ + layLayerTreeModel.h \ + layLayoutPropertiesForm.h \ + layLayoutStatisticsForm.h \ + layLayoutViewConfigPages.h \ + layLayoutViewFunctions.h \ + layLibrariesView.h \ + layLoadLayoutOptionsDialog.h \ + layNetExportDialog.h \ + layNetInfoDialog.h \ + layNetlistBrowser.h \ + layNetlistBrowserDialog.h \ + layNetlistBrowserModel.h \ + layNetlistBrowserPage.h \ + layNetlistBrowserTreeModel.h \ + layNetlistCrossReferenceModel.h \ + layQtTools.h \ + laySaveLayoutOptionsDialog.h \ + laySelectCellViewForm.h \ + laySelectLineStyleForm.h \ + laySelectStippleForm.h \ + layTechnology.h \ + layTipDialog.h \ + layWidgets.h \ + rdbInfoWidget.h \ + rdbMarkerBrowser.h \ + rdbMarkerBrowserDialog.h \ + rdbMarkerBrowserPage.h \ INCLUDEPATH += $$LAYBASIC_INC $$TL_INC $$GSI_INC $$DB_INC $$RDB_INC DEPENDPATH += $$LAYBASIC_INC $$TL_INC $$GSI_INC $$DB_INC $$RDB_INC diff --git a/src/layui/layui/layuiForceLink.cc b/src/layui/layui/layuiForceLink.cc new file mode 100644 index 000000000..488f478f9 --- /dev/null +++ b/src/layui/layui/layuiForceLink.cc @@ -0,0 +1,32 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 "layuiForceLink.h" + +namespace layui +{ + int _force_link_f () + { + return 0; + } +} + diff --git a/src/layui/layui/layuiForceLink.h b/src/layui/layui/layuiForceLink.h new file mode 100644 index 000000000..86ed0eb11 --- /dev/null +++ b/src/layui/layui/layuiForceLink.h @@ -0,0 +1,40 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 + +*/ + + +#ifndef HDR_layuiForceLink +#define HDR_layuiForceLink + +#include "layuiCommon.h" + +/** + * @file Include this function to force linking of the layui module + */ + +namespace layui +{ + LAYUI_PUBLIC int _force_link_f (); + static int _force_link_target = _force_link_f (); +} + +#endif + diff --git a/src/layview/layview/layview.pro b/src/layview/layview/layview.pro index ed2df8454..30d92982f 100644 --- a/src/layview/layview/layview.pro +++ b/src/layview/layview/layview.pro @@ -10,10 +10,12 @@ RESOURCES = \ SOURCES = \ layGridNet.cc \ + layviewForceLink.cc \ HEADERS = \ layGridNet.h \ layLayoutView.h \ + layviewForceLink.h \ !equals(HAVE_QT, "0") { diff --git a/src/layview/layview/layviewForceLink.cc b/src/layview/layview/layviewForceLink.cc new file mode 100644 index 000000000..400307cba --- /dev/null +++ b/src/layview/layview/layviewForceLink.cc @@ -0,0 +1,32 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 "layviewForceLink.h" + +namespace layview +{ + int _force_link_f () + { + return 0; + } +} + diff --git a/src/layview/layview/layviewForceLink.h b/src/layview/layview/layviewForceLink.h new file mode 100644 index 000000000..f7cdf749d --- /dev/null +++ b/src/layview/layview/layviewForceLink.h @@ -0,0 +1,40 @@ + +/* + + KLayout Layout Viewer + Copyright (C) 2006-2022 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 + +*/ + + +#ifndef HDR_layviewForceLink +#define HDR_layviewForceLink + +#include "layviewCommon.h" + +/** + * @file Include this function to force linking of the layview module + */ + +namespace layview +{ + LAYVIEW_PUBLIC int _force_link_f (); + static int _force_link_target = _force_link_f (); +} + +#endif + diff --git a/src/pymod/lay/layMain.cc b/src/pymod/lay/layMain.cc index 0547098ca..f952ea9bb 100644 --- a/src/pymod/lay/layMain.cc +++ b/src/pymod/lay/layMain.cc @@ -22,14 +22,8 @@ #include "../pymodHelper.h" -#if defined(HAVE_QT) -// to force linking of the lay module -# include "../../lay/lay/layForceLink.h" -#else -// to force linking of the laybasic module -// NOTE: without Qt we can only utilize the core view classes from laybasic -# include "../../laybasic/laybasic/laybasicForceLink.h" -#endif +// to force linking of the layview module +# include "../../layview/layview/layviewForceLink.h" // Force-include other dependencies // NOTE: these libraries contribute to the "lay" module space. Hence we have to include them. From 249642d5f372f09bd3681d73babeed896cfba434 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 15 May 2022 20:17:23 +0200 Subject: [PATCH 72/88] Python module tests generalized --- pyproject.toml | 3 +- src/pymod/distutils_src/pya/__init__.py | 1 + testdata/pymod/import_lay.py | 18 ++--- testdata/pymod/pya_tests.py | 8 +++ testdata/python/dbLayoutVsSchematic.py | 2 +- testdata/python/dbNetlistCrossReference.py | 2 +- testdata/python/layLayers.py | 78 ++++++++-------------- 7 files changed, 45 insertions(+), 67 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 5e3833538..422f75739 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,6 +5,7 @@ test-command = [ "python {package}/testdata/pymod/import_rdb.py", "python {package}/testdata/pymod/import_tl.py", "python {package}/testdata/pymod/import_lib.py", + "python {package}/testdata/pymod/import_lay.py", "python {package}/testdata/pymod/pya_tests.py" ] # Disable building PyPy wheels on all platforms @@ -24,4 +25,4 @@ environment-pass = ["HOST_CCACHE_DIR"] [tool.cibuildwheel.macos] # Don't repair macOS wheels -repair-wheel-command = "" \ No newline at end of file +repair-wheel-command = "" diff --git a/src/pymod/distutils_src/pya/__init__.py b/src/pymod/distutils_src/pya/__init__.py index 08879d72b..ff9d59e2e 100644 --- a/src/pymod/distutils_src/pya/__init__.py +++ b/src/pymod/distutils_src/pya/__init__.py @@ -6,3 +6,4 @@ from klayout.db import * # noqa from klayout.lib import * # noqa from klayout.tl import * # noqa from klayout.rdb import * # noqa +from klayout.lay import * # noqa diff --git a/testdata/pymod/import_lay.py b/testdata/pymod/import_lay.py index bb5127a93..990bbe2eb 100755 --- a/testdata/pymod/import_lay.py +++ b/testdata/pymod/import_lay.py @@ -16,10 +16,7 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA import testprep -import klayout.QtCore -import klayout.QtGui -if not "QApplication" in klayout.QtGui.__all__: - import klayout.QtWidgets # Qt5 +import klayout.db as db import klayout.lay as lay import unittest import sys @@ -29,15 +26,12 @@ import sys class BasicTest(unittest.TestCase): def test_1(self): - self.assertEqual("Annotation" in lay.__all__, True) - def test_2(self): - # Some smoke test - ant = lay.Annotation() - ant.style = lay.Annotation.StyleRuler - self.assertEqual(str(ant.style), str(lay.Annotation.StyleRuler)) - ant.fmt_x = "abc" - self.assertEqual(ant.fmt_x, "abc") + lv = lay.LayoutView() + lv.resize(800, 600) + lv.zoom_box(db.DBox(-42, -17, 142, 117)) + bx = lv.box() + self.assertEqual(str(bx), "(-42.09,-19.09;141.91,118.91)") # run unit tests if __name__ == '__main__': diff --git a/testdata/pymod/pya_tests.py b/testdata/pymod/pya_tests.py index c026e721b..a0c12e856 100644 --- a/testdata/pymod/pya_tests.py +++ b/testdata/pymod/pya_tests.py @@ -18,6 +18,10 @@ import dbPolygonTest import dbReaders import dbRegionTest import dbTransTest +import dbLayoutToNetlist +import dbLayoutVsSchematic +import dbNetlistCrossReference +import layLayers if __name__ == '__main__': suite = unittest.TestLoader().loadTestsFromTestCase(tlTest.TLTest) @@ -27,6 +31,10 @@ if __name__ == '__main__': suite = unittest.TestLoader().loadTestsFromTestCase(dbReaders.DBReadersTests) suite = unittest.TestLoader().loadTestsFromTestCase(dbRegionTest.DBRegionTest) suite = unittest.TestLoader().loadTestsFromTestCase(dbTransTest.DBTransTests) + suite = unittest.TestLoader().loadTestsFromTestCase(dbLayoutToNetlist.DBLayoutToNetlistTests) + suite = unittest.TestLoader().loadTestsFromTestCase(dbLayoutVsSchematic.DBLayoutVsSchematicTests) + suite = unittest.TestLoader().loadTestsFromTestCase(dbNetlistCrossReference.DBNetlistCrossReferenceTests) + suite = unittest.TestLoader().loadTestsFromTestCase(layLayers.LAYLayersTests) if not unittest.TextTestRunner(verbosity = 1).run(suite).wasSuccessful(): sys.exit(1) diff --git a/testdata/python/dbLayoutVsSchematic.py b/testdata/python/dbLayoutVsSchematic.py index 3b67b9fbf..ea17abbec 100644 --- a/testdata/python/dbLayoutVsSchematic.py +++ b/testdata/python/dbLayoutVsSchematic.py @@ -23,7 +23,7 @@ import unittest import sys import os -class DBLayoutToNetlistTests(unittest.TestCase): +class DBLayoutVsSchematicTests(unittest.TestCase): def test_1_Basic(self): diff --git a/testdata/python/dbNetlistCrossReference.py b/testdata/python/dbNetlistCrossReference.py index bc9f26055..25ffecd80 100644 --- a/testdata/python/dbNetlistCrossReference.py +++ b/testdata/python/dbNetlistCrossReference.py @@ -23,7 +23,7 @@ import unittest import sys import os -class DBLayoutToNetlistTests(unittest.TestCase): +class DBNetlistCrossReferenceTests(unittest.TestCase): def test_1_Basic(self): diff --git a/testdata/python/layLayers.py b/testdata/python/layLayers.py index d636b772e..6db38847e 100644 --- a/testdata/python/layLayers.py +++ b/testdata/python/layLayers.py @@ -27,7 +27,7 @@ def astr(a): astr.append(str(i)) return "[" + ", ".join(astr) + "]" -class LAYLayersTest(unittest.TestCase): +class LAYLayersTests(unittest.TestCase): def lnode_str(self, space, l): return space + l.current().source_(True) + "\n"; @@ -57,14 +57,9 @@ class LAYLayersTest(unittest.TestCase): def test_1(self): - app = pya.Application.instance() - mw = app.main_window() - mw.close_all() - - mw.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t11.gds", 1) - mw.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t10.gds", 2) - - cv = mw.current_view() + cv = pya.LayoutView() + cv.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t11.gds", True) + cv.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t10.gds", True) cv.clear_layers() @@ -203,18 +198,15 @@ class LAYLayersTest(unittest.TestCase): self.assertEqual(self.lnodes_str("", cv.begin_layers()), "*/*@*\n 1/0@1\n 1/0@2\n%5@2\n %5@2\n") - mw.close_all() + cv._destroy() def test_1a(self): - app = pya.Application.instance() - mw = app.main_window() - mw.close_all() + mgr = pya.Manager() - mw.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t11.gds", 1) - mw.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t10.gds", 2) - - cv = mw.current_view() + cv = pya.LayoutView(False, mgr) + cv.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t11.gds", True) + cv.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t10.gds", True) cv.clear_layers() @@ -396,7 +388,7 @@ class LAYLayersTest(unittest.TestCase): cv.delete_layers(0, a) self.assertEqual(cv.begin_layers(0).at_end(), True) cv.commit() - mw.cm_undo() + mgr.undo() self.assertEqual(cv.begin_layers(0).at_end(), False) cv.transaction("Delete") @@ -407,10 +399,10 @@ class LAYLayersTest(unittest.TestCase): self.assertEqual(i, 2) self.assertEqual(cv.begin_layers(0).at_end(), True) cv.commit() - mw.cm_undo() + mgr.undo() self.assertEqual(cv.begin_layers(0).at_end(), False) - mw.close_all() + cv._destroy() def test_2(self): @@ -655,14 +647,10 @@ class LAYLayersTest(unittest.TestCase): # direct replacement of objects and attributes def test_3(self): - app = pya.Application.instance() - mw = app.main_window() - mw.close_all() + cv = pya.LayoutView() + cv.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t11.gds", pya.LoadLayoutOptions(), "", True) + cv.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t10.gds", pya.LoadLayoutOptions(), "", True) - mw.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t11.gds", pya.LoadLayoutOptions(), "", 1) - mw.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t10.gds", pya.LoadLayoutOptions(), "", 2) - - cv = mw.current_view() self.assertEqual(self.lnodes_str("", cv.begin_layers()), "1/0@1\n2/0@1\n1/0@2\n2/0@2\n3/0@2\n3/1@2\n4/0@2\n5/0@2\n6/0@2\n6/1@2\n7/0@2\n8/0@2\n8/1@2\n") cv.clear_layers() @@ -772,19 +760,14 @@ class LAYLayersTest(unittest.TestCase): self.assertEqual(self.lnodes_str("", cv.begin_layers()), "TOP@1\n nn1@1\n nn1@1\n") self.assertEqual(self.lnodes_str2(cv), "TOP@1\nnn1@1\nnn1@1") - mw.close_all() + cv._destroy() # propagation of "real" attributes through the hierarchy def test_4(self): - app = pya.Application.instance() - mw = app.main_window() - mw.close_all() - - mw.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t11.gds", 1) - mw.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t10.gds", 2) - - cv = mw.current_view() + cv = pya.LayoutView() + cv.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t11.gds", True) + cv.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t10.gds", True) cv.clear_layers() @@ -807,18 +790,14 @@ class LAYLayersTest(unittest.TestCase): self.assertEqual(pos.first_child().current().visible_(True), False) self.assertEqual(pos.first_child().current().visible_(False), True) - mw.close_all() + cv._destroy() # delete method of iterator def test_5(self): - app = pya.Application.instance() - mw = app.main_window() - mw.close_all() + cv = pya.LayoutView() + cv.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t11.gds", True) - mw.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t11.gds", 1) - - cv = mw.current_view() cv.clear_layers() new_p = pya.LayerProperties() @@ -899,18 +878,13 @@ class LAYLayersTest(unittest.TestCase): self.assertEqual(pc.at_end(), True) self.assertEqual(pc.current().is_valid(), False) - mw.close_all() + cv._destroy() # custom stipples and line styles def test_6(self): - app = pya.Application.instance() - mw = app.main_window() - mw.close_all() - - mw.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t11.gds", 1) - - cv = mw.current_view() + cv = pya.LayoutView() + cv.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t11.gds", True) cv.clear_stipples() @@ -944,7 +918,7 @@ class LAYLayersTest(unittest.TestCase): cv.clear_line_styles() self.assertEqual(cv.get_line_style(index), "") - mw.close_all() + cv._destroy() # run unit tests From bdc8fc2801029292061ac49ab3be689aa99c805c Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 15 May 2022 21:47:15 +0200 Subject: [PATCH 73/88] WIP: some fixes at unit test level --- ci-scripts/docker/docker_prepare.sh | 4 +- pyproject.toml | 2 +- src/pymod/lay/lay.pro | 9 +++-- src/pymod/lay/layMain.cc | 5 ++- src/pymod/unit_tests/pymod_tests.cc | 5 --- testdata/pymod/import_lay.py | 20 +++++++++ testdata/pymod/import_lay_noqt.py | 47 ---------------------- testdata/python/dbLayoutVsSchematic.py | 2 +- testdata/python/dbNetlistCrossReference.py | 2 +- testdata/python/layLayers.py | 36 ++++++++++++++++- 10 files changed, 69 insertions(+), 63 deletions(-) delete mode 100755 testdata/pymod/import_lay_noqt.py diff --git a/ci-scripts/docker/docker_prepare.sh b/ci-scripts/docker/docker_prepare.sh index e380fdc45..4fb6e50c5 100644 --- a/ci-scripts/docker/docker_prepare.sh +++ b/ci-scripts/docker/docker_prepare.sh @@ -5,7 +5,7 @@ set -xe if [[ -f "/etc/centos-release" ]]; then # sometimes the epel server is down. retry 5 times for i in $(seq 1 5); do - yum install -y zlib-devel curl-devel expat-devel ccache && s=0 && break || s=$? && sleep 15; + yum install -y zlib-devel curl-devel expat-devel libpng-devel ccache && s=0 && break || s=$? && sleep 15; done [ $s -eq 0 ] || exit $s @@ -27,7 +27,7 @@ if [[ -f "/etc/centos-release" ]]; then elif [[ -f "/etc/alpine-release" ]]; then # musllinux prep # ccache already present - apk add curl-dev expat-dev zlib-dev ccache + apk add curl-dev expat-dev zlib-dev libpng-dev ccache export PATH="/usr/lib/ccache/bin:$PATH" fi diff --git a/pyproject.toml b/pyproject.toml index 422f75739..60f5b05e8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ test-command = [ "python {package}/testdata/pymod/import_rdb.py", "python {package}/testdata/pymod/import_tl.py", "python {package}/testdata/pymod/import_lib.py", - "python {package}/testdata/pymod/import_lay.py", + "python {package}/testdata/pymod/import_lay_noqt.py", "python {package}/testdata/pymod/pya_tests.py" ] # Disable building PyPy wheels on all platforms diff --git a/src/pymod/lay/lay.pro b/src/pymod/lay/lay.pro index 789393308..d62c2c847 100644 --- a/src/pymod/lay/lay.pro +++ b/src/pymod/lay/lay.pro @@ -9,12 +9,13 @@ SOURCES = \ HEADERS += \ -equals(HAVE_QT, "0") { - LIBS += -lklayout_laybasic -} else { +LIBS += -lklayout_layview + +!equals(HAVE_QT, "0") { + LIBS += -lklayout_layui LIBS += -lklayout_lay } # hard linked as they contribute GSI classes to "lay" module: -LIBS += -lklayout_img -lklayout_edt -lklayout_ant -lklayout_lym +LIBS += -lklayout_laybasic -lklayout_img -lklayout_edt -lklayout_ant -lklayout_lym diff --git a/src/pymod/lay/layMain.cc b/src/pymod/lay/layMain.cc index f952ea9bb..a622fc2f2 100644 --- a/src/pymod/lay/layMain.cc +++ b/src/pymod/lay/layMain.cc @@ -23,7 +23,11 @@ #include "../pymodHelper.h" // to force linking of the layview module +#if defined(HAVE_QT) +# include "../../lay/lay/layForceLink.h" +#else # include "../../layview/layview/layviewForceLink.h" +#endif // Force-include other dependencies // NOTE: these libraries contribute to the "lay" module space. Hence we have to include them. @@ -33,4 +37,3 @@ #include "../../lym/lym/lymForceLink.h" DEFINE_PYMOD(laycore, "lay", "KLayout core module 'lay'") - diff --git a/src/pymod/unit_tests/pymod_tests.cc b/src/pymod/unit_tests/pymod_tests.cc index 8f4b352f9..b9dd8ae03 100644 --- a/src/pymod/unit_tests/pymod_tests.cc +++ b/src/pymod/unit_tests/pymod_tests.cc @@ -87,12 +87,7 @@ PYMODTEST (bridge, "bridge.py") PYMODTEST (import_tl, "import_tl.py") PYMODTEST (import_db, "import_db.py") PYMODTEST (import_rdb, "import_rdb.py") - -#if defined(HAVE_QT) && defined(HAVE_QTBINDINGS) PYMODTEST (import_lay, "import_lay.py") -#else -PYMODTEST (import_lay, "import_lay_noqt.py") -#endif #if defined(HAVE_QT) && defined(HAVE_QTBINDINGS) diff --git a/testdata/pymod/import_lay.py b/testdata/pymod/import_lay.py index 990bbe2eb..3d37f0e5e 100755 --- a/testdata/pymod/import_lay.py +++ b/testdata/pymod/import_lay.py @@ -21,18 +21,38 @@ import klayout.lay as lay import unittest import sys +def can_create_layoutview(): + if not "MainWindow" in lay.__dict__: + return True # Qt-less + elif not "Application" in lay.__dict__: + return False # cannot instantiate Application + elif lay.__dict__["Application"].instance() is None: + return False # Application is not present + else: + return True + # Tests the basic abilities of the module class BasicTest(unittest.TestCase): def test_1(self): + if not can_create_layoutview(): + print("Skipped test as LayoutView cannot be instantiated") + return + lv = lay.LayoutView() lv.resize(800, 600) lv.zoom_box(db.DBox(-42, -17, 142, 117)) bx = lv.box() self.assertEqual(str(bx), "(-42.09,-19.09;141.91,118.91)") + def test_2(self): + + p = lay.LayerPropertiesNode() + p.name = "u" + self.assertEqual(p.name, "u") + # run unit tests if __name__ == '__main__': suite = unittest.TestSuite() diff --git a/testdata/pymod/import_lay_noqt.py b/testdata/pymod/import_lay_noqt.py deleted file mode 100755 index f12c4b34c..000000000 --- a/testdata/pymod/import_lay_noqt.py +++ /dev/null @@ -1,47 +0,0 @@ -# KLayout Layout Viewer -# Copyright (C) 2006-2022 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 - -import testprep -import klayout.db as db -import klayout.lay as lay -import unittest -import sys - -# Tests the basic abilities of the module - -class BasicTest(unittest.TestCase): - - def test_1(self): - self.assertEqual("Annotation" in lay.__all__, True) - - def test_2(self): - # Some smoke test - ant = lay.Annotation() - ant.style = lay.Annotation.StyleRuler - self.assertEqual(str(ant.style), str(lay.Annotation.StyleRuler)) - ant.fmt_x = "abc" - self.assertEqual(ant.fmt_x, "abc") - -# run unit tests -if __name__ == '__main__': - suite = unittest.TestSuite() - suite = unittest.TestLoader().loadTestsFromTestCase(BasicTest) - - if not unittest.TextTestRunner(verbosity = 1).run(suite).wasSuccessful(): - sys.exit(1) - - diff --git a/testdata/python/dbLayoutVsSchematic.py b/testdata/python/dbLayoutVsSchematic.py index ea17abbec..3e8f0f0d4 100644 --- a/testdata/python/dbLayoutVsSchematic.py +++ b/testdata/python/dbLayoutVsSchematic.py @@ -177,7 +177,7 @@ class DBLayoutVsSchematicTests(unittest.TestCase): # run unit tests if __name__ == '__main__': - suite = unittest.TestLoader().loadTestsFromTestCase(DBLayoutToNetlistTests) + suite = unittest.TestLoader().loadTestsFromTestCase(DBLayoutVsSchematicTests) if not unittest.TextTestRunner(verbosity = 1).run(suite).wasSuccessful(): sys.exit(1) diff --git a/testdata/python/dbNetlistCrossReference.py b/testdata/python/dbNetlistCrossReference.py index 25ffecd80..7ed25ea57 100644 --- a/testdata/python/dbNetlistCrossReference.py +++ b/testdata/python/dbNetlistCrossReference.py @@ -179,7 +179,7 @@ class DBNetlistCrossReferenceTests(unittest.TestCase): # run unit tests if __name__ == '__main__': - suite = unittest.TestLoader().loadTestsFromTestCase(DBLayoutToNetlistTests) + suite = unittest.TestLoader().loadTestsFromTestCase(DBNetlistCrossReferenceTests) if not unittest.TextTestRunner(verbosity = 1).run(suite).wasSuccessful(): sys.exit(1) diff --git a/testdata/python/layLayers.py b/testdata/python/layLayers.py index 6db38847e..b0af39c26 100644 --- a/testdata/python/layLayers.py +++ b/testdata/python/layLayers.py @@ -21,6 +21,16 @@ import unittest import os import sys +def can_create_layoutview(): + if not "MainWindow" in pya.__dict__: + return True # Qt-less + elif not "Application" in pya.__dict__: + return False # cannot instantiate Application + elif pya.__dict__["Application"].instance() is None: + return False # Application is not present + else: + return True + def astr(a): astr = [] for i in a: @@ -57,6 +67,10 @@ class LAYLayersTests(unittest.TestCase): def test_1(self): + if not can_create_layoutview(): + print("Skipped test as LayoutView cannot be created.") + return + cv = pya.LayoutView() cv.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t11.gds", True) cv.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t10.gds", True) @@ -202,6 +216,10 @@ class LAYLayersTests(unittest.TestCase): def test_1a(self): + if not can_create_layoutview(): + print("Skipped test as LayoutView cannot be created.") + return + mgr = pya.Manager() cv = pya.LayoutView(False, mgr) @@ -647,6 +665,10 @@ class LAYLayersTests(unittest.TestCase): # direct replacement of objects and attributes def test_3(self): + if not can_create_layoutview(): + print("Skipped test as LayoutView cannot be created.") + return + cv = pya.LayoutView() cv.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t11.gds", pya.LoadLayoutOptions(), "", True) cv.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t10.gds", pya.LoadLayoutOptions(), "", True) @@ -765,6 +787,10 @@ class LAYLayersTests(unittest.TestCase): # propagation of "real" attributes through the hierarchy def test_4(self): + if not can_create_layoutview(): + print("Skipped test as LayoutView cannot be created.") + return + cv = pya.LayoutView() cv.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t11.gds", True) cv.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t10.gds", True) @@ -795,6 +821,10 @@ class LAYLayersTests(unittest.TestCase): # delete method of iterator def test_5(self): + if not can_create_layoutview(): + print("Skipped test as LayoutView cannot be created.") + return + cv = pya.LayoutView() cv.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t11.gds", True) @@ -883,6 +913,10 @@ class LAYLayersTests(unittest.TestCase): # custom stipples and line styles def test_6(self): + if not can_create_layoutview(): + print("Skipped test as LayoutView cannot be created.") + return + cv = pya.LayoutView() cv.load_layout(os.getenv("TESTSRC") + "/testdata/gds/t11.gds", True) @@ -926,7 +960,7 @@ if __name__ == '__main__': suite = unittest.TestSuite() # NOTE: Use this instead of loadTestsfromTestCase to select a specific test: # suite.addTest(BasicTest("test_26")) - suite = unittest.TestLoader().loadTestsFromTestCase(LAYLayersTest) + suite = unittest.TestLoader().loadTestsFromTestCase(LAYLayersTests) # Only runs with Application available if "Application" in pya.__all__ and not unittest.TextTestRunner(verbosity = 1).run(suite).wasSuccessful(): From f536cc40da9eeb0d1102589b40298660a08faa0a Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 15 May 2022 22:05:44 +0200 Subject: [PATCH 74/88] Fixed test configuration --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 60f5b05e8..422f75739 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ test-command = [ "python {package}/testdata/pymod/import_rdb.py", "python {package}/testdata/pymod/import_tl.py", "python {package}/testdata/pymod/import_lib.py", - "python {package}/testdata/pymod/import_lay_noqt.py", + "python {package}/testdata/pymod/import_lay.py", "python {package}/testdata/pymod/pya_tests.py" ] # Disable building PyPy wheels on all platforms From e9b613b550379434764b4907873da2a08f5a1e45 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 15 May 2022 22:39:43 +0200 Subject: [PATCH 75/88] Added TESTSRC for pymod test --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 422f75739..3e5701d78 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ test-command = [ "python {package}/testdata/pymod/import_rdb.py", "python {package}/testdata/pymod/import_tl.py", "python {package}/testdata/pymod/import_lib.py", - "python {package}/testdata/pymod/import_lay.py", + "TESTSRC={package} python {package}/testdata/pymod/import_lay.py", "python {package}/testdata/pymod/pya_tests.py" ] # Disable building PyPy wheels on all platforms From baae3796a728cead9b2c1e773bd12cc906a13b1c Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 15 May 2022 22:58:42 +0200 Subject: [PATCH 76/88] Fixed an build issue with forward-declared QColor --- src/laybasic/laybasic/gsiDeclLayPixelBuffer.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/laybasic/laybasic/gsiDeclLayPixelBuffer.cc b/src/laybasic/laybasic/gsiDeclLayPixelBuffer.cc index c40fd39be..26d02c6b8 100644 --- a/src/laybasic/laybasic/gsiDeclLayPixelBuffer.cc +++ b/src/laybasic/laybasic/gsiDeclLayPixelBuffer.cc @@ -25,6 +25,7 @@ #if defined(HAVE_QT) # include +# include #endif namespace gsi From 0a6ac1a22660045b174e24f0e9add5d69f095694 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Sun, 15 May 2022 23:01:37 +0200 Subject: [PATCH 77/88] Fixed test config for PyPI module --- pyproject.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 3e5701d78..a97cc10fe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,8 +5,8 @@ test-command = [ "python {package}/testdata/pymod/import_rdb.py", "python {package}/testdata/pymod/import_tl.py", "python {package}/testdata/pymod/import_lib.py", - "TESTSRC={package} python {package}/testdata/pymod/import_lay.py", - "python {package}/testdata/pymod/pya_tests.py" + "python {package}/testdata/pymod/import_lay.py", + "TESTSRC={package} python {package}/testdata/pymod/pya_tests.py" ] # Disable building PyPy wheels on all platforms skip = "pp*" From d8f51a5ef0032e0ee1fb9af51719273955078071 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Mon, 16 May 2022 00:07:31 +0200 Subject: [PATCH 78/88] Qt4 compatibility --- azure-pipelines.yml | 19 ++----------------- src/laybasic/laybasic/layPixelBuffer.cc | 8 ++++++++ src/layui/layui/layCellSelectionForm.h | 4 ++-- src/lym/lym/lym.pro | 1 - src/pymod/tl/tlMain.cc | 1 - 5 files changed, 12 insertions(+), 21 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 2cfe0c5ad..57b5f1c41 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -14,11 +14,6 @@ jobs: vmImage: 'windows-2019' # other options: 'macOS-10.13', 'ubuntu-16.04' strategy: matrix: - # Python27: - # python.version: '2.7' - # cp35-cp35m-win_amd64.whl: - # python.version: '3.5' - # python.architecture: 'x64' cp36-cp36m-win_amd64.whl: python.version: '3.6' python.architecture: 'x64' @@ -34,9 +29,6 @@ jobs: cp310-cp310-win_amd64.whl: python.version: '3.10' python.architecture: 'x64' - # cp35-cp35m-win32.whl: - # python.version: '3.5' - # python.architecture: 'x86' cp36-cp36m-win32.whl: python.version: '3.6' python.architecture: 'x86' @@ -81,15 +73,6 @@ jobs: #workingDirectory: # Optional displayName: 'Download and Extract KLayout bits' - # - script: | - # curl https://download.microsoft.com/download/7/9/6/796EF2E4-801B-4FC4-AB28-B59FBF6D907B/VCForPython27.msi -o VCForPython27.msi - # msiexec /i VCForPython27.msi /quiet - # set "VS90COMNTOOLS=C:\Users\VssAdministrator\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC" - # curl https://raw.githubusercontent.com/mattn/gntp-send/master/include/msinttypes/stdint.h -o "%VS90COMNTOOLS%\Include\stdint.h" - # dir "%VS90COMNTOOLS%\Include" - # condition: eq(variables['python.version'], '2.7') - # displayName: 'Install Microsoft Visual C++ Compiler for Python 2.7' - - script: | python -m pip install --upgrade pip setuptools wheel displayName: 'Update pip, setuptools and wheel' @@ -107,11 +90,13 @@ jobs: - script: | echo PATH=%PATH% + set TESTSRC=. pip install klayout --no-index -f dist python testdata/pymod/import_db.py python testdata/pymod/import_rdb.py python testdata/pymod/import_tl.py python testdata/pymod/import_lib.py + python testdata/pymod/import_lay.py python testdata/pymod/pya_tests.py displayName: 'Test KLayout pymod' diff --git a/src/laybasic/laybasic/layPixelBuffer.cc b/src/laybasic/laybasic/layPixelBuffer.cc index 90d7eafdd..f5584d0e2 100644 --- a/src/laybasic/laybasic/layPixelBuffer.cc +++ b/src/laybasic/laybasic/layPixelBuffer.cc @@ -290,7 +290,11 @@ QImage PixelBuffer::to_image_copy () const { QImage img (m_width, m_height, m_transparent ? QImage::Format_ARGB32 : QImage::Format_RGB32); +#if QT_VERSION < 0x050000 + memcpy (img.bits (), data (), img.byteCount ()); +#else memcpy (img.bits (), data (), img.sizeInBytes ()); +#endif return img; } @@ -703,7 +707,11 @@ QImage BitmapBuffer::to_image_copy () const { QImage img (m_width, m_height, QImage::Format_MonoLSB); +#if QT_VERSION < 0x050000 + memcpy (img.bits (), data (), img.byteCount ()); +#else memcpy (img.bits (), data (), img.sizeInBytes ()); +#endif return img; } diff --git a/src/layui/layui/layCellSelectionForm.h b/src/layui/layui/layCellSelectionForm.h index b65769c0b..15c00dc2d 100644 --- a/src/layui/layui/layCellSelectionForm.h +++ b/src/layui/layui/layCellSelectionForm.h @@ -25,8 +25,6 @@ #ifndef HDR_layCellSelectionForm #define HDR_layCellSelectionForm -#include - #include "layuiCommon.h" #include "layCellView.h" #include "tlDeferredExecution.h" @@ -34,7 +32,9 @@ #include #include +#include #include +#include namespace Ui { diff --git a/src/lym/lym/lym.pro b/src/lym/lym/lym.pro index 0284fb201..c05c34e79 100644 --- a/src/lym/lym/lym.pro +++ b/src/lym/lym/lym.pro @@ -16,7 +16,6 @@ SOURCES = \ HEADERS = \ lymCommon.h \ lymForceLink.h \ - lymInclude.h \ lymMacroInterpreter.h \ lymMacroCollection.h \ lymMacro.h \ diff --git a/src/pymod/tl/tlMain.cc b/src/pymod/tl/tlMain.cc index d1f69e21d..b9617364e 100644 --- a/src/pymod/tl/tlMain.cc +++ b/src/pymod/tl/tlMain.cc @@ -23,4 +23,3 @@ #include "../pymodHelper.h" DEFINE_PYMOD(tlcore, "tl", "KLayout core module 'tl'") - From beb5af55a738b55e815e9c96a0c0708cfa392049 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Mon, 16 May 2022 20:08:05 +0200 Subject: [PATCH 79/88] Fixed lay::Color test for Qt4 --- src/laybasic/unit_tests/layColorTests.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/laybasic/unit_tests/layColorTests.cc b/src/laybasic/unit_tests/layColorTests.cc index 8da8e208b..3a8b308c6 100644 --- a/src/laybasic/unit_tests/layColorTests.cc +++ b/src/laybasic/unit_tests/layColorTests.cc @@ -88,7 +88,7 @@ TEST(5) EXPECT_EQ (lay::Color ("#80102030").to_string (), "#80102030"); EXPECT_EQ (lay::Color ("#80102030").rgb (), 0x80102030); -#if defined(HAVE_QT) +#if defined(HAVE_QT) && QT_VERSION >= 0x50000 // no alpha support in Qt EXPECT_EQ (QColor (tl::to_qstring ("#80102030")).isValid (), true); EXPECT_EQ (tl::to_string (QColor (tl::to_qstring ("#80102030")).name ()), "#102030"); From 0d7e07295fd65f0a6235b1cef9836aa4a0a5afd0 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Mon, 16 May 2022 20:10:27 +0200 Subject: [PATCH 80/88] Use new microbits archive (4.0) with libpng for Azure --- azure-pipelines.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 57b5f1c41..7daf2454d 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -62,9 +62,9 @@ jobs: #arguments: # Optional script: | # Required when targetType == Inline pwd - Invoke-WebRequest -Uri "https://www.klayout.org/downloads/klayout-microbits-1.0.zip" -OutFile klayout-microbits-1.0.zip + Invoke-WebRequest -Uri "https://www.klayout.org/downloads/klayout-microbits-4.0.zip" -OutFile klayout-microbits-4.0.zip dir - Expand-Archive klayout-microbits-1.0.zip -DestinationPath klayout-microbits + Expand-Archive klayout-microbits-4.0.zip -DestinationPath klayout-microbits dir klayout-microbits #errorActionPreference: 'stop' # Optional. Options: stop, continue, silentlyContinue #failOnStderr: false # Optional @@ -79,13 +79,13 @@ jobs: - script: | python -V - set "KLAYOUT_BITS=%cd%\klayout-microbits\klayout-microbits-1.0\msvc2017\%PYTHON_ARCHITECTURE%" + set "KLAYOUT_BITS=%cd%\klayout-microbits\klayout-microbits-4.0\msvc2017\%PYTHON_ARCHITECTURE%" echo KLAYOUT_BITS=%KLAYOUT_BITS% python setup.py bdist_wheel displayName: 'Build KLayout' - bash: | - bash `pwd`/ci-scripts/windows/fix_wheel.sh `pwd`/dist/*.whl "`pwd`/klayout-microbits/klayout-microbits-1.0/msvc2017/$PYTHON_ARCHITECTURE" + bash `pwd`/ci-scripts/windows/fix_wheel.sh `pwd`/dist/*.whl "`pwd`/klayout-microbits/klayout-microbits-4.0/msvc2017/$PYTHON_ARCHITECTURE" displayName: 'Copy klayout bits dlls into wheel' - script: | From b5c3d6981be044c12c67d61bed62f103fab48580 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Mon, 16 May 2022 21:14:23 +0200 Subject: [PATCH 81/88] Adjusted setup.py to klayout-microbits-4.0 --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 305249a07..42585261c 100644 --- a/setup.py +++ b/setup.py @@ -304,7 +304,7 @@ class Config(object): args = ["/DLL"] bits = os.getenv("KLAYOUT_BITS") if bits: - args += [quote_path("/LIBPATH:" + os.path.join(bits, "zlib", "libraries")), + args += [quote_path("/LIBPATH:" + os.path.join(bits, "zlib", "lib")), quote_path("/LIBPATH:" + os.path.join(bits, "ptw", "libraries")), quote_path("/LIBPATH:" + os.path.join(bits, "png", "libraries")), quote_path("/LIBPATH:" + os.path.join(bits, "expat", "libraries")), From b352ec4933864aa8e2e2bd21fd3adca190e35f94 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Mon, 16 May 2022 21:48:37 +0200 Subject: [PATCH 82/88] Specific name for libpng in setup.py to match all platforms --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 42585261c..8b80235a3 100644 --- a/setup.py +++ b/setup.py @@ -288,7 +288,7 @@ class Config(object): if mod == "_tl": return [ "libcurl", "expat", "pthreadVCE2", "zlib", "wsock32" ] elif mod == "_laybasic": - return [ "libpng" ] + return [ "libpng16" ] else: if mod == "_tl": return ['curl', 'expat'] From 9763659bfeedcf44ca34527fc4b47b4048b1921f Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Mon, 16 May 2022 22:18:22 +0200 Subject: [PATCH 83/88] Fixed Windows build (hopefully) --- src/layview/layview/gsiDeclLayLayoutView_noqt.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/layview/layview/gsiDeclLayLayoutView_noqt.cc b/src/layview/layview/gsiDeclLayLayoutView_noqt.cc index c3162124f..d49f02fba 100644 --- a/src/layview/layview/gsiDeclLayLayoutView_noqt.cc +++ b/src/layview/layview/gsiDeclLayLayoutView_noqt.cc @@ -25,6 +25,7 @@ #include "gsiDecl.h" #include "gsiSignals.h" #include "layLayoutView.h" +#include "laybasicCommon.h" namespace gsi { @@ -34,7 +35,7 @@ static lay::LayoutView *new_view2 (bool editable, db::Manager *manager, unsigned return new lay::LayoutView (manager, editable, 0 /*plugin parent*/, options); } -extern Class decl_LayoutViewBase; +LAYBASIC_PUBLIC Class decl_LayoutViewBase; Class decl_LayoutView (decl_LayoutViewBase, "lay", "LayoutView", gsi::constructor ("new", &new_view2, gsi::arg ("editable", false), gsi::arg ("manager", (db::Manager *) 0, "nil"), gsi::arg ("options", (unsigned int) 0), From 1f24458acd9dcbb7229bf538fc3690ad966385e2 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Mon, 16 May 2022 23:08:02 +0200 Subject: [PATCH 84/88] Fixed setup.py (from defines) --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 8b80235a3..37c56c99f 100644 --- a/setup.py +++ b/setup.py @@ -598,7 +598,7 @@ _img_path = os.path.join("src", "img", "img") _img_sources = set(glob.glob(os.path.join(_img_path, "*.cc"))) _img = Library(config.root + '._img', - define_macros=config.macros() + [('MAKE_ANT_LIBRARY', 1)], + define_macros=config.macros() + [('MAKE_IMG_LIBRARY', 1)], include_dirs=[_laybasic_path, _layview_path, _rdb_path, _db_path, _tl_path, _gsi_path], extra_objects=[config.path_of('_laybasic', _laybasic_path), config.path_of('_layview', _layview_path), config.path_of('_rdb', _rdb_path), config.path_of('_tl', _tl_path), config.path_of('_gsi', _gsi_path), config.path_of('_db', _db_path)], language='c++', @@ -615,7 +615,7 @@ _edt_path = os.path.join("src", "edt", "edt") _edt_sources = set(glob.glob(os.path.join(_edt_path, "*.cc"))) _edt = Library(config.root + '._edt', - define_macros=config.macros() + [('MAKE_ANT_LIBRARY', 1)], + define_macros=config.macros() + [('MAKE_EDT_LIBRARY', 1)], include_dirs=[_laybasic_path, _layview_path, _rdb_path, _db_path, _tl_path, _gsi_path], extra_objects=[config.path_of('_laybasic', _laybasic_path), config.path_of('_layview', _layview_path), config.path_of('_rdb', _rdb_path), config.path_of('_tl', _tl_path), config.path_of('_gsi', _gsi_path), config.path_of('_db', _db_path)], language='c++', From a42b7d211ea94d2c04185dfb82de07967df00e16 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Mon, 16 May 2022 23:53:16 +0200 Subject: [PATCH 85/88] More fixes. --- ci-scripts/windows/fix_wheel.sh | 1 + src/layview/layview/gsiDeclLayLayoutView_noqt.cc | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ci-scripts/windows/fix_wheel.sh b/ci-scripts/windows/fix_wheel.sh index 3ac9593c9..8890b98a6 100644 --- a/ci-scripts/windows/fix_wheel.sh +++ b/ci-scripts/windows/fix_wheel.sh @@ -70,6 +70,7 @@ cp -v $KLAYOUT_BITS/curl/bin/* . cp -v $KLAYOUT_BITS/expat/bin/* . cp -v $KLAYOUT_BITS/ptw/bin/* . cp -v $KLAYOUT_BITS/zlib/bin/* . +cp -v $KLAYOUT_BITS/png/bin/* . # if [ $? -ne 0 ]; then # >&2 echo "ERROR: lib not found. Quitting." # exit 1 diff --git a/src/layview/layview/gsiDeclLayLayoutView_noqt.cc b/src/layview/layview/gsiDeclLayLayoutView_noqt.cc index d49f02fba..a0eaf8235 100644 --- a/src/layview/layview/gsiDeclLayLayoutView_noqt.cc +++ b/src/layview/layview/gsiDeclLayLayoutView_noqt.cc @@ -35,7 +35,7 @@ static lay::LayoutView *new_view2 (bool editable, db::Manager *manager, unsigned return new lay::LayoutView (manager, editable, 0 /*plugin parent*/, options); } -LAYBASIC_PUBLIC Class decl_LayoutViewBase; +extern LAYBASIC_PUBLIC Class decl_LayoutViewBase; Class decl_LayoutView (decl_LayoutViewBase, "lay", "LayoutView", gsi::constructor ("new", &new_view2, gsi::arg ("editable", false), gsi::arg ("manager", (db::Manager *) 0, "nil"), gsi::arg ("options", (unsigned int) 0), From 130f4d70407be5e2158a4a817e239e1db7a89e2e Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Tue, 17 May 2022 20:19:57 +0200 Subject: [PATCH 86/88] Don't error when upload to PyPi-test fails --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d65f09686..d9598516d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -88,6 +88,7 @@ jobs: path: dist - uses: pypa/gh-action-pypi-publish@v1.4.2 + continue-on-error: true # might fail if we don't bump the version with: user: __token__ password: ${{ secrets.test_pypi_password }} From d4a981cc574aa0e85c609825daab4a08c2e00131 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Tue, 17 May 2022 22:34:38 +0200 Subject: [PATCH 87/88] Added a missing dependency in .pro --- src/klayout.pro | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/klayout.pro b/src/klayout.pro index 4a17bdc57..3286b667f 100644 --- a/src/klayout.pro +++ b/src/klayout.pro @@ -74,6 +74,10 @@ ant.depends += layview img.depends += layview edt.depends += layview +equals(HAVE_PYTHON, "1") { + pymod.depends += layview ant img edt lym +} + plugins.depends += lib rdb db ant equals(HAVE_RUBY, "1") { From 375b98e62101f13cd83f7ba746128d9c52da1a66 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Tue, 17 May 2022 22:39:33 +0200 Subject: [PATCH 88/88] Fixed an issue with type detection for GSI in non-QT case --- src/gsi/gsi/gsiTypes.h | 10 +++++----- src/klayout.pro | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/gsi/gsi/gsiTypes.h b/src/gsi/gsi/gsiTypes.h index ad806fcca..bdc66b928 100644 --- a/src/gsi/gsi/gsiTypes.h +++ b/src/gsi/gsi/gsiTypes.h @@ -448,7 +448,6 @@ template struct type_traits > : generic_type_trait template <> struct type_traits : generic_type_traits { }; template <> struct type_traits : generic_type_traits { }; template <> struct type_traits : generic_type_traits { }; -template <> struct type_traits > : generic_type_traits { }; template <> struct type_traits : generic_type_traits { }; #if QT_VERSION >= 0x50000 template struct type_traits > : generic_type_traits { }; @@ -459,6 +458,7 @@ template <> struct type_traits : generic_type_trait template <> struct type_traits : generic_type_traits { }; #endif #endif +template <> struct type_traits > : generic_type_traits { }; template <> struct type_traits : generic_type_traits { }; template <> struct type_traits : generic_type_traits { }; @@ -492,7 +492,6 @@ template struct type_traits &> : generic_ty template <> struct type_traits : generic_type_traits { }; template <> struct type_traits : generic_type_traits { }; template <> struct type_traits : generic_type_traits { }; -template <> struct type_traits &> : generic_type_traits { }; template <> struct type_traits : generic_type_traits { }; #if QT_VERSION >= 0x50000 template struct type_traits &> : generic_type_traits { }; @@ -503,6 +502,7 @@ template <> struct type_traits : generic_type_trait template <> struct type_traits : generic_type_traits { }; #endif #endif +template <> struct type_traits &> : generic_type_traits { }; template <> struct type_traits : generic_type_traits { }; template <> struct type_traits : generic_type_traits { }; template <> struct type_traits : generic_type_traits { }; @@ -533,7 +533,6 @@ template struct type_traits &> : generic_type_tra template <> struct type_traits : generic_type_traits { }; template <> struct type_traits : generic_type_traits { }; template <> struct type_traits : generic_type_traits { }; -template <> struct type_traits &> : generic_type_traits { }; template <> struct type_traits : generic_type_traits { }; #if QT_VERSION >= 0x50000 template struct type_traits &> : generic_type_traits { }; @@ -544,6 +543,7 @@ template <> struct type_traits : generic_type_trait template <> struct type_traits : generic_type_traits { }; #endif #endif +template <> struct type_traits &> : generic_type_traits { }; template <> struct type_traits : generic_type_traits { }; template <> struct type_traits : generic_type_traits { }; template <> struct type_traits : generic_type_traits { }; @@ -575,7 +575,6 @@ template struct type_traits *> : generic_ty template <> struct type_traits : generic_type_traits { }; template <> struct type_traits : generic_type_traits { }; template <> struct type_traits : generic_type_traits { }; -template <> struct type_traits *> : generic_type_traits { }; template <> struct type_traits : generic_type_traits { }; #if QT_VERSION >= 0x50000 template struct type_traits *> : generic_type_traits { }; @@ -586,6 +585,7 @@ template <> struct type_traits : generic_type_trait template <> struct type_traits : generic_type_traits { }; #endif #endif +template <> struct type_traits *> : generic_type_traits { }; template <> struct type_traits : generic_type_traits { }; template <> struct type_traits : generic_type_traits { }; template <> struct type_traits : generic_type_traits { }; @@ -617,7 +617,6 @@ template struct type_traits *> : generic_type_t template <> struct type_traits : generic_type_traits { }; template <> struct type_traits : generic_type_traits { }; template <> struct type_traits : generic_type_traits { }; -template <> struct type_traits *> : generic_type_traits { }; template <> struct type_traits : generic_type_traits { }; #if QT_VERSION >= 0x50000 template struct type_traits *> : generic_type_traits { }; @@ -628,6 +627,7 @@ template <> struct type_traits : generic_type_trait template <> struct type_traits : generic_type_traits { }; #endif #endif +template <> struct type_traits *> : generic_type_traits { }; template <> struct type_traits : generic_type_traits { }; template <> struct type_traits : generic_type_traits { }; template <> struct type_traits : generic_type_traits { }; diff --git a/src/klayout.pro b/src/klayout.pro index 3286b667f..228db95b3 100644 --- a/src/klayout.pro +++ b/src/klayout.pro @@ -74,12 +74,12 @@ ant.depends += layview img.depends += layview edt.depends += layview +plugins.depends += lib rdb db ant + equals(HAVE_PYTHON, "1") { pymod.depends += layview ant img edt lym } -plugins.depends += lib rdb db ant - equals(HAVE_RUBY, "1") { MAIN_DEPENDS += drc lvs drc.depends += rdb lym