diff --git a/build.sh b/build.sh index daafa8c93..c2a7bd11a 100755 --- a/build.sh +++ b/build.sh @@ -36,6 +36,7 @@ HAVE_QT_DESIGNER=1 HAVE_QT_XML=1 HAVE_64BIT_COORD=0 HAVE_QT=1 +HAVE_PNG=0 HAVE_CURL=0 HAVE_EXPAT=0 @@ -199,6 +200,9 @@ while [ "$*" != "" ]; do -dry-run) RUN_MAKE=0 ;; + -libpng) + HAVE_PNG=1 + ;; -libcurl) HAVE_CURL=1 ;; @@ -260,6 +264,7 @@ while [ "$*" != "" ]; do echo "" echo " -libcurl Use libcurl instead of QtNetwork (for Qt<4.7)" echo " -libexpat Use libexpat instead of QtXml" + echo " -libpng Use libpng instead of Qt for PNG generation" echo "" echo "Environment Variables:" echo "" @@ -487,6 +492,9 @@ fi if [ $HAVE_CURL != 0 ]; then echo " Uses libcurl for network access" fi +if [ $HAVE_PNG != 0 ]; then + echo " Uses libpng for PNG generation" +fi if [ "$RPATH" = "" ]; then RPATH="$BIN" fi @@ -622,6 +630,7 @@ qmake_options=( HAVE_QT="$HAVE_QT" HAVE_CURL="$HAVE_CURL" HAVE_EXPAT="$HAVE_EXPAT" + HAVE_PNG="$HAVE_PNG" PREFIX="$BIN" RPATH="$RPATH" KLAYOUT_VERSION="$KLAYOUT_VERSION" diff --git a/scripts/pyqrc.py b/scripts/pyqrc.py new file mode 100755 index 000000000..168748e30 --- /dev/null +++ b/scripts/pyqrc.py @@ -0,0 +1,154 @@ + +# A lean substitute for QRC which is employed in the non-Qt case + +import xml.etree.ElementTree as et +import argparse +import zlib +import os + + +# A class providing the generator + +class RCFile(object): + + def __init__(self, alias, path): + self.path = path + self.alias = alias + + def write(self, file, index): + + f = open(self.path, "rb") + raw_data = f.read() + f.close() + + data = zlib.compress(raw_data) + compressed = "true" + + cb = "{" + bc = "}" + cls = "Resource" + str(index) + file.write(f"\n// Resource file {self.path} as {self.alias}\n") + file.write( "namespace {\n") + file.write( "\n") + file.write(f" struct {cls}\n") + file.write( " {\n") + file.write(f" {cls}() {cb}\n") + file.write(f" static bool compressed = {compressed};\n") + file.write(f" static const char *name = \"{self.alias}\";\n") + file.write( " static const unsigned char data[] = {") + n = 0 + for b in data: + if n == 0: + file.write("\n ") + file.write("0x%02x," % b) + n += 1 + if n == 16: + n = 0 + file.write( "\n") + file.write( " };\n") + file.write( " m_id = tl::register_resource(name, compressed, data, sizeof(data) / sizeof(data[0]));\n") + file.write( " }\n") + file.write(f" ~{cls}() {cb}\n") + file.write( " tl::unregister_resource(m_id);\n") + file.write( " }\n") + file.write( " tl::resource_id_type m_id;\n") + file.write(f" {bc} resource_instance{index};\n") + file.write( "\n") + file.write( "}\n") + + +class RCGenerator(object): + + def __init__(self): + self.files = [] + + def append(self, path, alias): + self.files.append(RCFile(path, alias)) + + def dump_files(self): + for f in self.files: + print(f.path) + + def write(self, file): + file.write(f""" +/* + + 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 + +*/ + +/** +* DO NOT EDIT THIS FILE. +* This file has been created automatically +*/ + +#include "tlResources.h" +""") + i = 1 + for f in self.files: + f.write(file, i) + i += 1 + + +# The main code + +generator = RCGenerator() + +# argument parsing + +parser = argparse.ArgumentParser(description='Lean QRC parser') +parser.add_argument('input', type=str, nargs='+', + help='The QRC input file') +parser.add_argument('--output', '-o', type=str, nargs='?', + help='The C++ output file') +parser.add_argument('--path', '-p', type=str, nargs='?', + help='Path to the input files (default is current directory)') + +args = parser.parse_args() + +# read the input file + +for input in args.input: + + root_node = et.parse(input).getroot() + + for qresource in root_node.findall('qresource'): + prefix = qresource.get('prefix') + for file in qresource.findall('file'): + alias = file.get('alias') + path = file.text + if alias is None: + alias = path + if prefix is not None: + alias = prefix + "/" + alias + if args.path is not None: + path = os.path.join(args.path, path) + else: + path = os.path.join(os.path.dirname(input), path) + generator.append(alias, path) + +# produce the output file + +if args.output is not None: + f = open(args.output, "w") + generator.write(f) + f.close() +else: + generator.dump_files() + + diff --git a/setup.py b/setup.py index 37c56c99f..59461c867 100644 --- a/setup.py +++ b/setup.py @@ -286,14 +286,10 @@ class Config(object): """ if platform.system() == "Windows": if mod == "_tl": - return [ "libcurl", "expat", "pthreadVCE2", "zlib", "wsock32" ] - elif mod == "_laybasic": - return [ "libpng16" ] + return [ "libcurl", "expat", "pthreadVCE2", "zlib", "wsock32", "libpng16" ] else: if mod == "_tl": - return ['curl', 'expat'] - elif mod == "_laybasic": - return [ 'png' ] + return [ "curl", "expat", "png" ] return [] def link_args(self, mod): diff --git a/src/ant/ant/antPlugin.cc b/src/ant/ant/antPlugin.cc index 4ad479762..488809029 100644 --- a/src/ant/ant/antPlugin.cc +++ b/src/ant/ant/antPlugin.cc @@ -24,10 +24,10 @@ #include "layPlugin.h" #include "layConverters.h" #include "layDispatcher.h" -#include "layColor.h" +#include "layAbstractMenu.h" +#include "tlColor.h" #if defined(HAVE_QT) # include "layConfigurationDialog.h" -# include "layAbstractMenu.h" #endif #include "antConfig.h" #if defined(HAVE_QT) @@ -62,17 +62,36 @@ PluginDeclaration::instance () return sp_instance; } +static std::vector make_standard_templates () +{ + std::vector templates; + + 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")); + + 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")); + templates.back ().set_mode (ant::Template::RulerSingleClick); + + 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")); + templates.back ().set_mode (ant::Template::RulerAutoMetric); + + 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 ())); + + 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 ())); + + return templates; +} + void PluginDeclaration::get_options (std::vector < std::pair > &options) const { options.push_back (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 (lay::Color ()))); + options.push_back (std::pair (cfg_ruler_color, lay::ColorConverter ().to_string (tl::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))); options.push_back (std::pair (cfg_ruler_grid_snap, tl::to_string (false))); - options.push_back (std::pair (cfg_ruler_templates, "")); + options.push_back (std::pair (cfg_ruler_templates, ant::TemplatesConverter ().to_string (make_standard_templates ()))); options.push_back (std::pair (cfg_current_ruler_template, "0")); // grid-micron is not configured here since some other entity is supposed to do this. } @@ -189,21 +208,7 @@ PluginDeclaration::initialized (lay::Dispatcher *root) // This is the migration path from <= 0.24 to 0.25: clear all templates unless we // have categorized ones there. Those can't be deleted, so we know we have a 0.25 // setup if there are some - m_templates.clear (); - - // Set up the templates we want to see (plus some non-categorized templates) - - 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 (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 (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 (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 ("Box")), "W=$(abs(X))", "H=$(abs(Y))", "", ant::Object::STY_line, ant::Object::OL_box, true, lay::AC_Global, std::string ())); + m_templates = make_standard_templates (); root->config_set (cfg_ruler_templates, ant::TemplatesConverter ().to_string (m_templates)); root->config_end (); @@ -214,15 +219,12 @@ 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; @@ -248,13 +250,11 @@ 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; @@ -294,11 +294,10 @@ PluginDeclaration::update_menu () } } } -#endif } void -PluginDeclaration::register_annotation_template (const ant::Template &t) +PluginDeclaration::register_annotation_template (const ant::Template &t, lay::Plugin *plugin) { if (t.category ().empty ()) { return; @@ -311,8 +310,38 @@ PluginDeclaration::register_annotation_template (const ant::Template &t) } m_templates.push_back (t); - lay::Dispatcher::instance ()->config_set (cfg_ruler_templates, ant::TemplatesConverter ().to_string (m_templates)); - lay::Dispatcher::instance ()->config_end (); + + if (! plugin) { + plugin = lay::Dispatcher::instance (); + } + if (plugin) { + plugin->config_set (cfg_ruler_templates, ant::TemplatesConverter ().to_string (m_templates)); + plugin->config_end (); + } +} + +void +PluginDeclaration::unregister_annotation_template (const std::string &category, lay::Plugin *plugin) +{ + std::vector tpl; + + if (! category.empty ()) { + for (auto i = m_templates.begin (); i != m_templates.end (); ++i) { + if (i->category () != category) { + tpl.push_back (*i); + } + } + } + + m_templates.swap (tpl); + + if (! plugin) { + plugin = lay::Dispatcher::instance (); + } + if (plugin) { + plugin->config_set (cfg_ruler_templates, ant::TemplatesConverter ().to_string (m_templates)); + plugin->config_end (); + } } static tl::RegisteredClass config_decl (new ant::PluginDeclaration (), 3000, "ant::Plugin"); diff --git a/src/ant/ant/antPlugin.h b/src/ant/ant/antPlugin.h index 0b8b4ac05..5cc70f3ae 100644 --- a/src/ant/ant/antPlugin.h +++ b/src/ant/ant/antPlugin.h @@ -54,7 +54,8 @@ public: virtual void uninitialize (lay::Dispatcher *); virtual bool menu_activated (const std::string &symbol) const; - void register_annotation_template (const ant::Template &t); + void register_annotation_template (const ant::Template &t, lay::Plugin *plugin = 0); + void unregister_annotation_template (const std::string &category, lay::Plugin *plugin = 0); static PluginDeclaration *instance (); @@ -64,9 +65,7 @@ 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/antPropertiesPage.cc b/src/ant/ant/antPropertiesPage.cc index 1c7794db4..b381c9c11 100644 --- a/src/ant/ant/antPropertiesPage.cc +++ b/src/ant/ant/antPropertiesPage.cc @@ -205,7 +205,7 @@ PropertiesPage::snap_to_layout_clicked () bool snap_p1 = sender () == p1_to_layout; - double snap_range = service->widget ()->mouse_event_trans ().inverted ().ctrans (service->snap_range ()); + double snap_range = service->ui ()->mouse_event_trans ().inverted ().ctrans (service->snap_range ()); double max_range = 1000 * snap_range; while (snap_range < max_range) { @@ -237,7 +237,7 @@ PropertiesPage::snap_to_layout_clicked () } else { - double snap_range = service->widget ()->mouse_event_trans ().inverted ().ctrans (service->snap_range ()); + double snap_range = service->ui ()->mouse_event_trans ().inverted ().ctrans (service->snap_range ()); snap_range *= 0.5; lay::TwoPointSnapToObjectResult ee = lay::obj_snap2 (service->view (), p1, p2, g, ac, snap_range, snap_range * 1000.0); diff --git a/src/ant/ant/antService.cc b/src/ant/ant/antService.cc index e9d6401c5..50668a4d0 100644 --- a/src/ant/ant/antService.cc +++ b/src/ant/ant/antService.cc @@ -727,7 +727,7 @@ is_selected (const ant::Object &ruler, const db::DBox &box, double /*enl*/) // ------------------------------------------------------------- View::View (ant::Service *rulers, const ant::Object *ruler, bool selected) - : lay::ViewObject (rulers->widget ()), + : lay::ViewObject (rulers->ui ()), mp_rulers (rulers), m_selected (selected), mp_ruler (ruler) { // .. nothing else .. @@ -763,7 +763,7 @@ View::render (const lay::Viewport &vp, lay::ViewObjectCanvas &canvas) int basic_width = int(0.5 + 1.0 / canvas.resolution ()); - lay::Color c (mp_rulers->color ()); + tl::Color c (mp_rulers->color ()); if (! c.is_valid ()) { c = canvas.foreground_color (); } @@ -823,12 +823,12 @@ Service::configure (const std::string &name, const std::string &value) if (name == cfg_ruler_color) { - lay::Color color; + tl::Color color; lay::ColorConverter ().from_string (value, color); // make the color available for the dynamic view objects too. if (lay::test_and_set (m_color, color)) { - widget ()->touch (); + ui ()->touch (); } } else if (name == cfg_ruler_halo) { @@ -838,7 +838,7 @@ Service::configure (const std::string &name, const std::string &value) // make the color available for the dynamic view objects too. if (lay::test_and_set (m_halo, halo)) { - widget ()->touch (); + ui ()->touch (); } } else if (name == cfg_ruler_grid_micron) { @@ -914,7 +914,7 @@ Service::annotations_changed () } std::vector -Service::get_view_ops (lay::RedrawThreadCanvas &canvas, lay::Color background, lay::Color foreground, lay::Color /*active*/) const +Service::get_view_ops (lay::RedrawThreadCanvas &canvas, tl::Color background, tl::Color foreground, tl::Color /*active*/) const { int basic_width = int(0.5 + 1.0 / canvas.resolution ()); @@ -967,20 +967,20 @@ Service::clear_rulers () double Service::catch_distance () { - return double (view ()->search_range ()) / widget ()->mouse_event_trans ().mag (); + return double (view ()->search_range ()) / ui ()->mouse_event_trans ().mag (); } double Service::catch_distance_box () { - return double (view ()->search_range_box ()) / widget ()->mouse_event_trans ().mag (); + return double (view ()->search_range_box ()) / ui ()->mouse_event_trans ().mag (); } void Service::drag_cancel () { if (m_drawing) { - widget ()->ungrab_mouse (this); + ui ()->ungrab_mouse (this); m_drawing = false; } @@ -1110,7 +1110,7 @@ bool Service::begin_move (lay::Editable::MoveMode mode, const db::DPoint &p, lay::angle_constraint_type /*ac*/) { // cancel any pending move or drag operations, reset mp_active_ruler - widget ()->drag_cancel (); // KLUDGE: every service does this to the same service manager + ui ()->drag_cancel (); // KLUDGE: every service does this to the same service manager clear_transient_selection (); @@ -1558,7 +1558,7 @@ Service::mouse_click_event (const db::DPoint &p, unsigned int buttons, bool prio g = db::DVector (m_grid, m_grid); } - double snap_range = widget ()->mouse_event_trans ().inverted ().ctrans (m_snap_range); + double snap_range = ui ()->mouse_event_trans ().inverted ().ctrans (m_snap_range); snap_range *= 0.5; lay::TwoPointSnapToObjectResult ee = lay::obj_snap2 (mp_view, p, g, ac, snap_range, snap_range * 1000.0); @@ -1592,7 +1592,7 @@ Service::mouse_click_event (const db::DPoint &p, unsigned int buttons, bool prio mp_active_ruler->thaw (); m_drawing = true; - widget ()->grab_mouse (this, false); + ui ()->grab_mouse (this, false); } @@ -1627,7 +1627,7 @@ Service::mouse_click_event (const db::DPoint &p, unsigned int buttons, bool prio ant::Object Service::create_measure_ruler (const db::DPoint &pt, lay::angle_constraint_type ac) { - double snap_range = widget ()->mouse_event_trans ().inverted ().ctrans (m_snap_range); + double snap_range = ui ()->mouse_event_trans ().inverted ().ctrans (m_snap_range); snap_range *= 0.5; ant::Template tpl; @@ -1687,7 +1687,7 @@ Service::snap1_details (const db::DPoint &p, bool obj_snap) g = db::DVector (m_grid, m_grid); } - double snap_range = widget ()->mouse_event_trans ().inverted ().ctrans (m_snap_range); + double snap_range = ui ()->mouse_event_trans ().inverted ().ctrans (m_snap_range); return lay::obj_snap (obj_snap ? mp_view : 0, p, g, snap_range); } @@ -1707,7 +1707,7 @@ Service::snap2_details (const db::DPoint &p1, const db::DPoint &p2, const ant::O g = db::DVector (m_grid, m_grid); } - double snap_range = widget ()->mouse_event_trans ().inverted ().ctrans (m_snap_range); + double snap_range = ui ()->mouse_event_trans ().inverted ().ctrans (m_snap_range); lay::angle_constraint_type snap_mode = ac == lay::AC_Global ? (obj->angle_constraint () == lay::AC_Global ? m_snap_mode : obj->angle_constraint ()) : ac; return lay::obj_snap (m_obj_snap && obj->snap () ? mp_view : 0, p1, p2, g, snap_mode, snap_range); diff --git a/src/ant/ant/antService.h b/src/ant/ant/antService.h index c52c4d138..6b4c5be9d 100644 --- a/src/ant/ant/antService.h +++ b/src/ant/ant/antService.h @@ -389,7 +389,7 @@ public: /** * @brief Color accessor */ - lay::Color color () const + tl::Color color () const { return m_color; } @@ -481,6 +481,14 @@ public: */ ant::Object create_measure_ruler(const db::DPoint &pt, lay::angle_constraint_type ac); + /** + * @brief Gets the annotation templates + */ + const std::vector &ruler_templates () const + { + return m_ruler_templates; + } + /** * @brief An event triggered when the annotations changed * When an annotation is added or removed, this event is triggered. @@ -500,7 +508,7 @@ public: private: // Ruler display and snapping configuration - lay::Color m_color; + tl::Color m_color; bool m_halo; lay::angle_constraint_type m_snap_mode; double m_grid; @@ -601,7 +609,7 @@ private: /** * @brief implementation of the "Drawing" interface: configuration */ - std::vector get_view_ops (lay::RedrawThreadCanvas &canvas, lay::Color background, lay::Color foreground, lay::Color active) const; + std::vector get_view_ops (lay::RedrawThreadCanvas &canvas, tl::Color background, tl::Color foreground, tl::Color active) const; /** * @brief Update m_rulers to reflect the selection diff --git a/src/ant/ant/antTemplate.cc b/src/ant/ant/antTemplate.cc index 390a4b8a9..84590a2e2 100644 --- a/src/ant/ant/antTemplate.cc +++ b/src/ant/ant/antTemplate.cc @@ -30,6 +30,32 @@ namespace ant { +ant::Template +Template::from_object (const ant::Object &a, const std::string &title, int mode) +{ + ant::Template t; + + t.angle_constraint (a.angle_constraint ()); + t.category (a.category ()); + t.fmt (a.fmt ()); + t.fmt_x (a.fmt_x ()); + t.fmt_y (a.fmt_y ()); + t.set_main_position (a.main_position ()); + t.set_main_xalign (a.main_xalign ()); + t.set_main_yalign (a.main_yalign ()); + t.set_xlabel_xalign (a.xlabel_xalign ()); + t.set_xlabel_yalign (a.xlabel_yalign ()); + t.set_ylabel_xalign (a.ylabel_xalign ()); + t.set_ylabel_yalign (a.ylabel_yalign ()); + t.outline (a.outline ()); + t.style (a.style ()); + t.title (title); + + t.set_mode (ant::Template::ruler_mode_type (mode)); + + return t; +} + Template::Template () : m_title (tl::to_string (tr ("Ruler"))), m_fmt_x ("$X"), m_fmt_y ("$Y"), m_fmt ("$D"), diff --git a/src/ant/ant/antTemplate.h b/src/ant/ant/antTemplate.h index fbc326680..0d8b921f5 100644 --- a/src/ant/ant/antTemplate.h +++ b/src/ant/ant/antTemplate.h @@ -65,6 +65,14 @@ public: RulerAutoMetric = 2 }; + /** + * @brief Creates a template from a ruler object + * + * This will ignore the positions of the ruler but use the properties to + * initialize the template. + */ + static ant::Template from_object (const ant::Object &object, const std::string &title, int mode); + /** * @brief Default constructor * diff --git a/src/ant/ant/gsiDeclAnt.cc b/src/ant/ant/gsiDeclAnt.cc index 8889af167..a1284d3ff 100644 --- a/src/ant/ant/gsiDeclAnt.cc +++ b/src/ant/ant/gsiDeclAnt.cc @@ -427,47 +427,68 @@ static int ruler_mode_auto_metric () static void register_annotation_template (const ant::Object &a, const std::string &title, int mode) { - ant::Template t; - - t.angle_constraint (a.angle_constraint ()); - t.category (a.category ()); - t.fmt (a.fmt ()); - t.fmt_x (a.fmt_x ()); - t.fmt_y (a.fmt_y ()); - t.set_main_position (a.main_position ()); - t.set_main_xalign (a.main_xalign ()); - t.set_main_yalign (a.main_yalign ()); - t.set_xlabel_xalign (a.xlabel_xalign ()); - t.set_xlabel_yalign (a.xlabel_yalign ()); - t.set_ylabel_xalign (a.ylabel_xalign ()); - t.set_ylabel_yalign (a.ylabel_yalign ()); - t.outline (a.outline ()); - t.style (a.style ()); - t.title (title); - - t.set_mode (ant::Template::ruler_mode_type (mode)); + ant::Template t = ant::Template::from_object (a, title, mode); if (ant::PluginDeclaration::instance ()) { ant::PluginDeclaration::instance ()->register_annotation_template (t); } } +static void register_annotation_template2 (lay::LayoutViewBase *view, const ant::Object &a, const std::string &title, int mode) +{ + ant::Template t = ant::Template::from_object (a, title, mode); + + if (ant::PluginDeclaration::instance ()) { + ant::PluginDeclaration::instance ()->register_annotation_template (t, view); + } +} + +static void unregister_annotation_template (const std::string &category) +{ + if (ant::PluginDeclaration::instance ()) { + ant::PluginDeclaration::instance ()->unregister_annotation_template (category); + } +} + +static void unregister_annotation_template2 (lay::LayoutViewBase *view, const std::string &category) +{ + if (ant::PluginDeclaration::instance ()) { + ant::PluginDeclaration::instance ()->unregister_annotation_template (category, view); + } +} + // NOTE: ant::Object is available as "BasicAnnotation" to allow binding for other methods. gsi::Class decl_BasicAnnotation ("lay", "BasicAnnotation", gsi::Methods (), "@hide\n@alias Annotation"); gsi::Class decl_Annotation (decl_BasicAnnotation, "lay", "Annotation", gsi::method ("register_template", &gsi::register_annotation_template, gsi::arg ("annotation"), gsi::arg ("title"), gsi::arg ("mode", ruler_mode_normal (), "\\RulerModeNormal"), - "@brief Registers the given annotation as a template\n" + "@brief Registers the given annotation as a template globally\n" + "@annotation The annotation to use for the template (positions are ignored)\n" "@param title The title to use for the ruler template\n" "@param mode The mode the ruler will be created in (see Ruler... constants)\n" "\n" - "In order to register a system template, the category string of the annotation should be " + "In order to register a system template, the category string of the annotation has to be " "a unique and non-empty string. The annotation is added to the list of annotation templates " "and becomes available as a new template in the ruler drop-down menu.\n" "\n" + "The new annotation template is registered on all views.\n" + "\n" + "NOTE: this setting is persisted and the the application configuration is updated.\n" + "\n" "This method has been added in version 0.25." ) + + gsi::method ("unregister_templates", &gsi::unregister_annotation_template, + gsi::arg ("category"), + "@brief Unregisters the template or templates with the given category string globally\n" + "\n" + "This method will remove all templates with the given category string. If the category string is empty, " + "all templates are removed.\n" + "\n" + "NOTE: this setting is persisted and the the application configuration is updated.\n" + "\n" + "This method has been added in version 0.28." + ) + gsi::method ("RulerModeNormal", &gsi::ruler_mode_normal, "@brief Specifies normal ruler mode for the \\register_template method\n" "\n" @@ -988,6 +1009,25 @@ gsi::Class decl_Annotation (decl_BasicAnnotation, "lay", "Annotat "@/code\n" ); +static std::vector > get_annotation_templates (lay::LayoutViewBase *view) +{ + ant::Service *ant_service = view->get_plugin (); + tl_assert (ant_service != 0); + + std::vector > ant_objects; + const std::vector &ruler_templates = ant_service->ruler_templates (); + + ant_objects.reserve (ruler_templates.size ()); + for (auto i = ruler_templates.begin (); i != ruler_templates.end (); ++i) { + ant_objects.push_back (std::vector ()); + ant_objects.back ().push_back (tl::Variant (gsi::AnnotationRef (ant::Object (db::DPoint (), db::DPoint (), 0, *i), 0))); + ant_objects.back ().push_back (tl::Variant (i->title ())); + ant_objects.back ().push_back (tl::Variant (int (i->mode ()))); + } + + return ant_objects; +} + static gsi::ClassExt layout_view_decl ( gsi::method_ext ("clear_annotations", &gsi::clear_annotations, @@ -1063,6 +1103,42 @@ gsi::ClassExt layout_view_decl ( "@return The new ruler object\n" "\n" "This method was introduced in version 0.26." + ) + + gsi::method_ext ("register_annotation_template", &gsi::register_annotation_template2, + gsi::arg ("annotation"), gsi::arg ("title"), gsi::arg ("mode", ruler_mode_normal (), "\\RulerModeNormal"), + "@brief Registers the given annotation as a template for this particular view\n" + "@annotation The annotation to use for the template (positions are ignored)\n" + "@param title The title to use for the ruler template\n" + "@param mode The mode the ruler will be created in (see Ruler... constants)\n" + "\n" + "See \\Annotation#register_template for a method doing the same on application level. " + "This method is hardly useful normally, but can be used when customizing layout views as " + "individual widgets.\n" + "\n" + "This method has been added in version 0.28." + ) + + gsi::method_ext ("unregister_annotation_templates", &gsi::unregister_annotation_template2, + gsi::arg ("category"), + "@brief Unregisters the template or templates with the given category string on this particular view\n" + "\n" + "See \\Annotation#unregister_template for a method doing the same on application level." + "This method is hardly useful normally, but can be used when customizing layout views as " + "individual widgets.\n" + "\n" + "This method has been added in version 0.28." + ) + + gsi::method_ext ("annotation_templates", &get_annotation_templates, + "@brief Gets a list of \\Annotation objects representing the annotation templates.\n" + "\n" + "Annotation templates are the rulers available in the ruler drop-down (preset ruler types). " + "This method will fetch the templates available. This method returns triplets '(annotation, title, mode)'. " + "The first member of the triplet is the annotation object representing the template. The second " + "member is the title string displayed in the menu for this templates. The third member is the mode " + "value (one of the RulerMode... constants - e.g \\RulerModeNormal).\n" + "\n" + "The positions of the returned annotation objects are undefined.\n" + "\n" + "This method has been introduced in version 0.28." ), "" ); diff --git a/src/buddies/src/bd/strmrun.cc b/src/buddies/src/bd/strmrun.cc index 0d58374a9..92b522afa 100644 --- a/src/buddies/src/bd/strmrun.cc +++ b/src/buddies/src/bd/strmrun.cc @@ -35,6 +35,7 @@ #include "libForceLink.h" #include "rdbForceLink.h" #include "lymMacro.h" +#include "lymMacroCollection.h" struct RunnerData { @@ -83,6 +84,14 @@ BD_PUBLIC int strmrun (int argc, char *argv[]) python.define_variable (v->first, v->second); } + // install the built-in macros so we can run DRC and LVS scripts + lym::MacroCollection &lym_root = lym::MacroCollection::root (); + lym_root.add_folder (tl::to_string (tr ("Built-In")), ":/built-in-macros", "macros", true); + lym_root.add_folder (tl::to_string (tr ("Built-In")), ":/built-in-pymacros", "pymacros", true); + + lym_root.autorun_early (); + lym_root.autorun (); + std::string script = tl::absolute_file_path (data.script); lym::Macro macro; diff --git a/src/buddies/unit_tests/buddies_main.cc b/src/buddies/unit_tests/buddies_main.cc index a8bbd4e25..1f26d86f8 100644 --- a/src/buddies/unit_tests/buddies_main.cc +++ b/src/buddies/unit_tests/buddies_main.cc @@ -28,9 +28,8 @@ #include "rba.h" #include "gsiDecl.h" -// On Windows, ruby.h is not compatible with windows.h which is included by utHead - at least not if -// windows.h is included before ruby.h ... #include "tlUnitTest.h" +#include "tlFileUtils.h" void run_rubytest (tl::TestBase * /*_this*/, const std::string &fn) { diff --git a/src/db/db/db.pro b/src/db/db/db.pro index 35293190d..16f2caffb 100644 --- a/src/db/db/db.pro +++ b/src/db/db/db.pro @@ -392,7 +392,7 @@ HEADERS = \ dbShapeCollection.h \ dbShapeCollectionUtils.h -!equals(HAVE_QT, "0") { +!equals(HAVE_QT, "0") || !equals(HAVE_PYTHON, "0") { RESOURCES = \ dbResources.qrc \ diff --git a/src/db/db/dbGlyphs.cc b/src/db/db/dbGlyphs.cc index 362de0dd2..a61c9722e 100644 --- a/src/db/db/dbGlyphs.cc +++ b/src/db/db/dbGlyphs.cc @@ -147,20 +147,11 @@ TextGenerator::text_as_region (const std::string &t, double target_dbu, double m return region; } -#if defined(HAVE_QT) void TextGenerator::load_from_resource (const std::string &name) { - QResource res (tl::to_qstring (name)); - if (res.size () == 0) { - throw tl::Exception (tl::to_string (tr ("Unable to load font resource from ")) + name); - } - - QByteArray data = qUncompress (QByteArray ((const char *) res.data (), int (res.size ()))); - - load_from_data (data.constData (), data.size (), tl::to_string (QFileInfo (tl::to_qstring (name)).baseName ()), name); + load_from_file (name); } -#endif void TextGenerator::load_from_data (const char *data, size_t ndata, const std::string &name, const std::string &description) diff --git a/src/db/db/dbGlyphs.h b/src/db/db/dbGlyphs.h index a3073984f..c42e186fd 100644 --- a/src/db/db/dbGlyphs.h +++ b/src/db/db/dbGlyphs.h @@ -76,12 +76,10 @@ public: */ TextGenerator (); -#if defined(HAVE_QT) /** * @brief Loads the font from the given resource */ void load_from_resource (const std::string &name); -#endif /** * @brief Loads from the given binary data diff --git a/src/db/db/gsiDeclDbGlyphs.cc b/src/db/db/gsiDeclDbGlyphs.cc index 95f2fd02e..f471f79d9 100644 --- a/src/db/db/gsiDeclDbGlyphs.cc +++ b/src/db/db/gsiDeclDbGlyphs.cc @@ -65,12 +65,11 @@ static std::vector generators () } Class decl_TextGenerator ("db", "TextGenerator", -#if defined(HAVE_QT) method ("load_from_resource", &db::TextGenerator::load_from_resource, arg ("resource_path"), "@brief Loads the given resource data (as layout data) into the generator\n" + "The resource path has to start with a colon, i.e. ':/my/resource.gds'. " "See the description of the class how the layout data is read." ) + -#endif method ("load_from_file", &db::TextGenerator::load_from_file, arg ("path"), "@brief Loads the given file into the generator\n" "See the description of the class how the layout data is read." diff --git a/src/drc/drc/built-in-macros/_drc_engine.rb b/src/drc/drc/built-in-macros/_drc_engine.rb index a168a5442..1382f2524 100644 --- a/src/drc/drc/built-in-macros/_drc_engine.rb +++ b/src/drc/drc/built-in-macros/_drc_engine.rb @@ -2685,7 +2685,7 @@ CODE end def _process_events - if RBA::Application.instance + if RBA.constants.member?(:Application) && RBA::Application.instance RBA::Application.instance.process_events end end diff --git a/src/drc/drc/built-in-macros/_drc_layer.rb b/src/drc/drc/built-in-macros/_drc_layer.rb index bde1c2ee7..8432a1890 100644 --- a/src/drc/drc/built-in-macros/_drc_layer.rb +++ b/src/drc/drc/built-in-macros/_drc_layer.rb @@ -3265,6 +3265,15 @@ CODE self.data.is_a?(RBA::EdgePairs) end + # %DRC% + # @name texts? + # @brief Returns true, if the layer is a text collection + # @synopsis layer.texts? + + def texts? + self.data.is_a?(RBA::Texts) + end + # %DRC% # @name is_deep? # @brief Returns true, if the layer is a deep (hierarchical) layer diff --git a/src/drc/drc/built-in-macros/drc_install.lym b/src/drc/drc/built-in-macros/drc_install.lym index 78d1ef3b0..24f67c2f4 100644 --- a/src/drc/drc/built-in-macros/drc_install.lym +++ b/src/drc/drc/built-in-macros/drc_install.lym @@ -19,7 +19,7 @@ module DRC # Installs the home menu entries (needs to be done on autorun, not autorun-early) - if RBA::Application::instance && RBA::Application::instance.main_window + if RBA.constants.member?(:Application) && RBA::Application::instance && RBA::Application::instance.main_window cat = "drc" diff --git a/src/drc/drc/built-in-macros/drc_interpreters.lym b/src/drc/drc/built-in-macros/drc_interpreters.lym index a5c4d13ed..dbd8591dd 100644 --- a/src/drc/drc/built-in-macros/drc_interpreters.lym +++ b/src/drc/drc/built-in-macros/drc_interpreters.lym @@ -88,7 +88,7 @@ module DRC create_template(":/drc-templates/drc.lym") # if available, create a menu branch - if RBA::Application::instance && RBA::Application::instance.main_window + if RBA.constants.member?(:Application) && RBA::Application::instance && RBA::Application::instance.main_window mw = RBA::Application::instance.main_window mw.menu.insert_menu("tools_menu.verification_group+", "drc", "DRC") end @@ -160,7 +160,7 @@ module DRC DRCPlainTextInterpreter::new(drc_recipe) # Creates a new macro category - if RBA::Application::instance + if RBA.constants.member?(:Application) && RBA::Application::instance RBA::Application::instance.add_macro_category("drc", "DRC", [ "drc" ]) end diff --git a/src/drc/drc/drc.pro b/src/drc/drc/drc.pro index 9f0f97cb6..c43e875d0 100644 --- a/src/drc/drc/drc.pro +++ b/src/drc/drc/drc.pro @@ -13,8 +13,10 @@ HEADERS = \ drcCommon.h \ drcForceLink.h \ -RESOURCES = \ - drcResources.qrc +!equals(HAVE_QT, "0") || !equals(HAVE_PYTHON, "0") { + RESOURCES = \ + drcResources.qrc +} INCLUDEPATH += $$TL_INC $$DB_INC $$GSI_INC $$LYM_INC $$RDB_INC DEPENDPATH += $$TL_INC $$DB_INC $$GSI_INC $$LYM_INC $$RDB_INC diff --git a/src/edt/edt/edtMainService.cc b/src/edt/edt/edtMainService.cc index 3ccc53648..3a0f52992 100644 --- a/src/edt/edt/edtMainService.cc +++ b/src/edt/edt/edtMainService.cc @@ -2158,7 +2158,13 @@ MainService::cm_tap () tl_assert (false); // see TODO #endif - if (! view ()->view_object_widget ()->mouse_in_window ()) { +#if defined(HAVE_QT) + if (! view ()->canvas ()->widget ()) { + return; + } +#endif + + if (! view ()->canvas ()->mouse_in_window ()) { return; } @@ -2168,7 +2174,7 @@ MainService::cm_tap () finder.set_catch_all (true); // go through all visible layers of all cellviews - db::DPoint pt = view ()->view_object_widget ()->mouse_position_um (); + db::DPoint pt = view ()->canvas ()->mouse_position_um (); finder.find (view (), db::DBox (pt, pt)); std::set > layers_in_selection; @@ -2201,8 +2207,8 @@ MainService::cm_tap () int icon_size = menu->style ()->pixelMetric (QStyle::PM_ButtonIconSize); - db::DPoint mp_local = view ()->view_object_widget ()->mouse_position (); - QPoint mp = view ()->view_object_widget ()->mapToGlobal (QPoint (mp_local.x (), mp_local.y ())); + db::DPoint mp_local = view ()->canvas ()->mouse_position (); + QPoint mp = view ()->canvas ()->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*/))); @@ -2216,7 +2222,7 @@ MainService::cm_tap () lay::LayerPropertiesConstIterator iter = tapped_layers [index]; view ()->set_current_layer (iter); - edt::Service *es = dynamic_cast (view ()->view_object_widget ()->active_service ()); + edt::Service *es = dynamic_cast (view ()->canvas ()->active_service ()); if (es) { es->tap (pt); } diff --git a/src/edt/edt/edtPartialService.cc b/src/edt/edt/edtPartialService.cc index 7f89ef2fa..aeec8335c 100644 --- a/src/edt/edt/edtPartialService.cc +++ b/src/edt/edt/edtPartialService.cc @@ -1230,7 +1230,7 @@ PartialService::clear_partial_transient_selection () } void -PartialService::set_colors (lay::Color /*background*/, lay::Color color) +PartialService::set_colors (tl::Color /*background*/, tl::Color color) { m_color = color.rgb (); if (mp_box) { @@ -1308,7 +1308,7 @@ const int sr_pixels = 8; // TODO: make variable lay::PointSnapToObjectResult PartialService::snap2 (const db::DPoint &p) const { - double snap_range = widget ()->mouse_event_trans ().inverted ().ctrans (sr_pixels); + double snap_range = ui ()->mouse_event_trans ().inverted ().ctrans (sr_pixels); return lay::obj_snap (m_snap_to_objects ? view () : 0, p, m_edit_grid == db::DVector () ? m_global_grid : m_edit_grid, snap_range); } @@ -1526,7 +1526,7 @@ PartialService::edit_cancel () mp_box = 0; } - widget ()->ungrab_mouse (this); + ui ()->ungrab_mouse (this); selection_to_view (); } @@ -1654,10 +1654,10 @@ PartialService::mouse_press_event (const db::DPoint &p, unsigned int buttons, bo m_p1 = p; m_p2 = p; - mp_box = new lay::RubberBox (widget (), m_color, p, p); + mp_box = new lay::RubberBox (ui (), m_color, p, p); mp_box->set_stipple (6); // coarse hatched - widget ()->grab_mouse (this, true); + ui ()->grab_mouse (this, true); } else { @@ -1673,7 +1673,7 @@ PartialService::mouse_press_event (const db::DPoint &p, unsigned int buttons, bo m_current = m_start = p; } - widget ()->grab_mouse (this, true); + ui ()->grab_mouse (this, true); } @@ -1712,7 +1712,7 @@ PartialService::mouse_click_event (const db::DPoint &p, unsigned int buttons, bo if (m_current != m_start) { // stop dragging - widget ()->ungrab_mouse (this); + ui ()->ungrab_mouse (this); manager ()->transaction (tl::to_string (tr ("Partial move"))); @@ -1743,7 +1743,7 @@ PartialService::mouse_click_event (const db::DPoint &p, unsigned int buttons, bo return true; - } else if (widget ()->mouse_event_viewport ().contains (p)) { + } else if (ui ()->mouse_event_viewport ().contains (p)) { // clear other selection when this mode gets active // (save the selection so our own selection does not get cleared) @@ -1901,7 +1901,7 @@ PartialService::mouse_double_click_event (const db::DPoint &p, unsigned int butt m_alt_ac = ac_from_buttons (buttons); // stop dragging - widget ()->ungrab_mouse (this); + ui ()->ungrab_mouse (this); m_dragging = false; partial_select (db::DBox (p, p), lay::Editable::Replace); @@ -2006,12 +2006,12 @@ PartialService::mouse_release_event (const db::DPoint &p, unsigned int buttons, m_alt_ac = ac_from_buttons (buttons); - widget ()->ungrab_mouse (this); + ui ()->ungrab_mouse (this); delete mp_box; mp_box = 0; - if (widget ()->mouse_event_viewport ().contains (p)) { + if (ui ()->mouse_event_viewport ().contains (p)) { lay::Editable::SelectionMode mode = lay::Editable::Replace; bool shift = ((m_buttons & lay::ShiftButton) != 0); @@ -2067,7 +2067,7 @@ void PartialService::del () { // stop dragging - widget ()->ungrab_mouse (this); + ui ()->ungrab_mouse (this); std::map >, std::vector > shapes_to_delete_by_cell; @@ -2358,13 +2358,13 @@ PartialService::enter_edge (const EdgeWithIndex &e, size_t &nmarker, partial_obj double PartialService::catch_distance () { - return double (view ()->search_range ()) / widget ()->mouse_event_trans ().mag (); + return double (view ()->search_range ()) / ui ()->mouse_event_trans ().mag (); } double PartialService::catch_distance_box () { - return double (view ()->search_range_box ()) / widget ()->mouse_event_trans ().mag (); + return double (view ()->search_range_box ()) / ui ()->mouse_event_trans ().mag (); } db::DPoint diff --git a/src/edt/edt/edtPartialService.h b/src/edt/edt/edtPartialService.h index a0f7b0e78..22ab958ac 100644 --- a/src/edt/edt/edtPartialService.h +++ b/src/edt/edt/edtPartialService.h @@ -288,7 +288,7 @@ public: /** * @brief Reimplementation of the ViewService interface: set the colors */ - virtual void set_colors (lay::Color background, lay::Color text); + virtual void set_colors (tl::Color background, tl::Color text); /** * @brief Cancel any edit operations (in this case, unselect all & cancel any drag operation) diff --git a/src/edt/edt/edtService.cc b/src/edt/edt/edtService.cc index 7e3320bee..7ff291a1b 100644 --- a/src/edt/edt/edtService.cc +++ b/src/edt/edt/edtService.cc @@ -179,7 +179,7 @@ const int sr_pixels = 8; // TODO: make variable lay::PointSnapToObjectResult Service::snap2_details (const db::DPoint &p) const { - double snap_range = widget ()->mouse_event_trans ().inverted ().ctrans (sr_pixels); + double snap_range = ui ()->mouse_event_trans ().inverted ().ctrans (sr_pixels); return lay::obj_snap (m_snap_to_objects ? view () : 0, p, m_edit_grid == db::DVector () ? m_global_grid : m_edit_grid, snap_range); } @@ -192,7 +192,7 @@ Service::snap2 (const db::DPoint &p) const db::DPoint Service::snap2 (const db::DPoint &p, const db::DPoint &plast, bool connect) const { - double snap_range = widget ()->mouse_event_trans ().inverted ().ctrans (sr_pixels); + double snap_range = ui ()->mouse_event_trans ().inverted ().ctrans (sr_pixels); return lay::obj_snap (m_snap_to_objects ? view () : 0, plast, p, m_edit_grid == db::DVector () ? m_global_grid : m_edit_grid, connect ? connect_ac () : move_ac (), snap_range).snapped_point; } @@ -922,13 +922,13 @@ Service::has_transient_selection () double Service::catch_distance () { - return double (view ()->search_range ()) / widget ()->mouse_event_trans ().mag (); + return double (view ()->search_range ()) / ui ()->mouse_event_trans ().mag (); } double Service::catch_distance_box () { - return double (view ()->search_range_box ()) / widget ()->mouse_event_trans ().mag (); + return double (view ()->search_range_box ()) / ui ()->mouse_event_trans ().mag (); } double diff --git a/src/edt/edt/edtService.h b/src/edt/edt/edtService.h index cd05cd739..81f3ea400 100644 --- a/src/edt/edt/edtService.h +++ b/src/edt/edt/edtService.h @@ -32,7 +32,7 @@ #include "layMarker.h" #include "laySnap.h" #include "layObjectInstPath.h" -#include "layColor.h" +#include "tlColor.h" #include "dbLayout.h" #include "dbShape.h" #include "edtUtils.h" @@ -220,7 +220,7 @@ public: /** * @brief Color accessor */ - lay::Color color () const + tl::Color color () const { return m_color; } @@ -593,7 +593,7 @@ private: db::ShapeIterator::flags_type m_flags; // The look of the markers - lay::Color m_color; + tl::Color m_color; // The current transformation on movement db::DTrans m_move_trans; diff --git a/src/gsi/gsi/gsi.pro b/src/gsi/gsi/gsi.pro index e02314d09..83cf1217b 100644 --- a/src/gsi/gsi/gsi.pro +++ b/src/gsi/gsi/gsi.pro @@ -47,7 +47,9 @@ HEADERS = \ # Note: unlike other modules, the tl declarations have to go here # since gsi is dependent on tl -SOURCES += gsiDeclTl.cc +SOURCES += \ + gsiDeclTl.cc \ + gsiDeclTlPixelBuffer.cc INCLUDEPATH += $$TL_INC DEPENDPATH += $$TL_INC diff --git a/src/laybasic/laybasic/gsiDeclLayPixelBuffer.cc b/src/gsi/gsi/gsiDeclTlPixelBuffer.cc similarity index 73% rename from src/laybasic/laybasic/gsiDeclLayPixelBuffer.cc rename to src/gsi/gsi/gsiDeclTlPixelBuffer.cc index 26d02c6b8..ef76af9e1 100644 --- a/src/laybasic/laybasic/gsiDeclLayPixelBuffer.cc +++ b/src/gsi/gsi/gsiDeclTlPixelBuffer.cc @@ -21,41 +21,33 @@ */ #include "gsiDecl.h" -#include "layPixelBuffer.h" +#include "tlPixelBuffer.h" #if defined(HAVE_QT) # include -# include #endif namespace gsi { // ------------------------------------------------------------------------------------- -// lay::BitmapBuffer +// tl::BitmapBuffer -static lay::PixelBuffer *create_pixel_buffer (unsigned int w, unsigned int h) +static tl::PixelBuffer *create_pixel_buffer (unsigned int w, unsigned int h) { - return new lay::PixelBuffer (w, h); + return new tl::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) +tl::color_t get_pixel_from_pixel_buffer (const tl::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); + return tl::color_t (0); } } -void set_pixel_in_pixel_buffer (lay::PixelBuffer *pb, unsigned int x, unsigned int y, lay::color_t c) +void set_pixel_in_pixel_buffer (tl::PixelBuffer *pb, unsigned int x, unsigned int y, tl::color_t c) { if (! pb->transparent ()) { c |= 0xff000000; // ensures that alpha is set properly even if not required @@ -65,41 +57,41 @@ void set_pixel_in_pixel_buffer (lay::PixelBuffer *pb, unsigned int x, unsigned i } } -static lay::PixelBuffer read_pixel_buffer (const std::string &file) +static tl::PixelBuffer read_pixel_buffer (const std::string &file) { #if defined(HAVE_PNG) tl::InputStream stream (file); - return lay::PixelBuffer::read_png (stream); + return tl::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); + return tl::PixelBuffer::from_image (img); #else throw tl::Exception (tl::to_string (tr ("No PNG support compiled in for PixelBuffer"))); - return lay::PixelBuffer (); + return tl::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) +static tl::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); + return tl::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); + return tl::PixelBuffer::from_image (img); #else throw tl::Exception (tl::to_string (tr ("No PNG support compiled in for PixelBuffer"))); - return lay::PixelBuffer (); + return tl::PixelBuffer (); #endif } -static void write_pixel_buffer (const lay::PixelBuffer *pb, const std::string &file) +static void write_pixel_buffer (const tl::PixelBuffer *pb, const std::string &file) { #if defined(HAVE_PNG) tl::OutputStream stream (file); @@ -114,7 +106,7 @@ static void write_pixel_buffer (const lay::PixelBuffer *pb, const std::string &f } // 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) +static std::vector pixel_buffer_to_png (const tl::PixelBuffer *pb) { #if defined(HAVE_PNG) tl::OutputMemoryStream data_stream; @@ -135,7 +127,7 @@ static std::vector pixel_buffer_to_png (const lay::PixelBuffer *pb) } -Class decl_PixelBuffer ("lay", "PixelBuffer", +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" @@ -144,35 +136,30 @@ 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"), + gsi::method ("==", &tl::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"), + gsi::method ("!=", &tl::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"), + gsi::method ("transparent=", &tl::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, + gsi::method ("transparent", &tl::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"), + gsi::method ("fill", &tl::PixelBuffer::fill, gsi::arg ("color"), "@brief Fills the pixel buffer with the given pixel value\n" ) + -#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" - ) + -#endif - gsi::method ("swap", &lay::PixelBuffer::swap, gsi::arg ("other"), + gsi::method ("swap", &tl::PixelBuffer::swap, gsi::arg ("other"), "@brief Swaps data with another PixelBuffer object\n" ) + - gsi::method ("width", &lay::PixelBuffer::width, + gsi::method ("width", &tl::PixelBuffer::width, "@brief Gets the width of the pixel buffer in pixels\n" ) + - gsi::method ("height", &lay::PixelBuffer::height, + gsi::method ("height", &tl::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"), @@ -181,14 +168,6 @@ Class decl_PixelBuffer ("lay", "PixelBuffer", 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" @@ -209,14 +188,14 @@ Class decl_PixelBuffer ("lay", "PixelBuffer", "\n" "This method may not be available if PNG support is not compiled into KLayout." ) + - gsi::method ("patch", &lay::PixelBuffer::patch, gsi::arg ("other"), + gsi::method ("patch", &tl::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"), + gsi::method ("diff", &tl::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. " @@ -238,14 +217,14 @@ Class decl_PixelBuffer ("lay", "PixelBuffer", // ------------------------------------------------------------------------------------- -// lay::BitmapBuffer +// tl::BitmapBuffer -static lay::BitmapBuffer *create_bitmap_buffer (unsigned int w, unsigned int h) +static tl::BitmapBuffer *create_bitmap_buffer (unsigned int w, unsigned int h) { - return new lay::BitmapBuffer (w, h); + return new tl::BitmapBuffer (w, h); } -bool get_pixel_from_bitmap_buffer (const lay::BitmapBuffer *pb, unsigned int x, unsigned int y) +bool get_pixel_from_bitmap_buffer (const tl::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; @@ -254,7 +233,7 @@ bool get_pixel_from_bitmap_buffer (const lay::BitmapBuffer *pb, unsigned int x, } } -void set_pixel_in_bitmap_buffer (lay::BitmapBuffer *pb, unsigned int x, unsigned int y, bool c) +void set_pixel_in_bitmap_buffer (tl::BitmapBuffer *pb, unsigned int x, unsigned int y, bool c) { if (x < pb->width () && y < pb->height ()) { if (c) { @@ -265,41 +244,41 @@ void set_pixel_in_bitmap_buffer (lay::BitmapBuffer *pb, unsigned int x, unsigned } } -static lay::BitmapBuffer read_bitmap_buffer (const std::string &file) +static tl::BitmapBuffer read_bitmap_buffer (const std::string &file) { #if defined(HAVE_PNG) tl::InputStream stream (file); - return lay::BitmapBuffer::read_png (stream); + return tl::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); + return tl::BitmapBuffer::from_image (img); #else throw tl::Exception (tl::to_string (tr ("No PNG support compiled in for BitmapBuffer"))); - return lay::BitmapBuffer (); + return tl::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) +static tl::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); + return tl::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); + return tl::BitmapBuffer::from_image (img); #else throw tl::Exception (tl::to_string (tr ("No PNG support compiled in for BitmapBuffer"))); - return lay::BitmapBuffer (); + return tl::BitmapBuffer (); #endif } -static void write_bitmap_buffer (const lay::BitmapBuffer *pb, const std::string &file) +static void write_bitmap_buffer (const tl::BitmapBuffer *pb, const std::string &file) { #if defined(HAVE_PNG) tl::OutputStream stream (file); @@ -314,7 +293,7 @@ static void write_bitmap_buffer (const lay::BitmapBuffer *pb, const std::string } // 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) +static std::vector bitmap_buffer_to_png (const tl::BitmapBuffer *pb) { #if defined(HAVE_PNG) tl::OutputMemoryStream data_stream; @@ -335,7 +314,7 @@ static std::vector bitmap_buffer_to_png (const lay::BitmapBuffer *pb) } -Class decl_BitmapBuffer ("lay", "BitmapBuffer", +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" @@ -344,27 +323,22 @@ 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"), + gsi::method ("==", &tl::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"), + gsi::method ("!=", &tl::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"), + gsi::method ("fill", &tl::BitmapBuffer::fill, gsi::arg ("color"), "@brief Fills the pixel buffer with the given pixel value\n" ) + -#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" - ) + -#endif - gsi::method ("swap", &lay::BitmapBuffer::swap, gsi::arg ("other"), + gsi::method ("swap", &tl::BitmapBuffer::swap, gsi::arg ("other"), "@brief Swaps data with another BitmapBuffer object\n" ) + - gsi::method ("width", &lay::BitmapBuffer::width, + gsi::method ("width", &tl::BitmapBuffer::width, "@brief Gets the width of the pixel buffer in pixels\n" ) + - gsi::method ("height", &lay::BitmapBuffer::height, + gsi::method ("height", &tl::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"), @@ -373,14 +347,6 @@ Class decl_BitmapBuffer ("lay", "BitmapBuffer", 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" diff --git a/src/img/img/gsiDeclImg.cc b/src/img/img/gsiDeclImg.cc index 01bc8fefa..2a7b436f1 100644 --- a/src/img/img/gsiDeclImg.cc +++ b/src/img/img/gsiDeclImg.cc @@ -43,14 +43,14 @@ static void clear_colormap (img::DataMapping *dm) dm->false_color_nodes.clear (); } -static void add_colormap (img::DataMapping *dm, double value, lay::color_t color) +static void add_colormap (img::DataMapping *dm, double value, tl::color_t color) { - dm->false_color_nodes.push_back (std::make_pair (value, std::make_pair (lay::Color (color), lay::Color (color)))); + dm->false_color_nodes.push_back (std::make_pair (value, std::make_pair (tl::Color (color), tl::Color (color)))); } -static void add_colormap2 (img::DataMapping *dm, double value, lay::color_t lcolor, lay::color_t rcolor) +static void add_colormap2 (img::DataMapping *dm, double value, tl::color_t lcolor, tl::color_t rcolor) { - dm->false_color_nodes.push_back (std::make_pair (value, std::make_pair (lay::Color (lcolor), lay::Color (rcolor)))); + dm->false_color_nodes.push_back (std::make_pair (value, std::make_pair (tl::Color (lcolor), tl::Color (rcolor)))); } static size_t num_colormap_entries (const img::DataMapping *dm) @@ -58,7 +58,7 @@ static size_t num_colormap_entries (const img::DataMapping *dm) return dm->false_color_nodes.size (); } -static lay::color_t colormap_color (const img::DataMapping *dm, size_t i) +static tl::color_t colormap_color (const img::DataMapping *dm, size_t i) { if (i < dm->false_color_nodes.size ()) { return dm->false_color_nodes [i].second.first.rgb (); @@ -67,7 +67,7 @@ static lay::color_t colormap_color (const img::DataMapping *dm, size_t i) } } -static lay::color_t colormap_lcolor (const img::DataMapping *dm, size_t i) +static tl::color_t colormap_lcolor (const img::DataMapping *dm, size_t i) { if (i < dm->false_color_nodes.size ()) { return dm->false_color_nodes [i].second.first.rgb (); @@ -76,7 +76,7 @@ static lay::color_t colormap_lcolor (const img::DataMapping *dm, size_t i) } } -static lay::color_t colormap_rcolor (const img::DataMapping *dm, size_t i) +static tl::color_t colormap_rcolor (const img::DataMapping *dm, size_t i) { if (i < dm->false_color_nodes.size ()) { return dm->false_color_nodes [i].second.second.rgb (); diff --git a/src/img/img/imgLandmarksDialog.cc b/src/img/img/imgLandmarksDialog.cc index 4be4ba291..7d4c15ce5 100644 --- a/src/img/img/imgLandmarksDialog.cc +++ b/src/img/img/imgLandmarksDialog.cc @@ -40,7 +40,7 @@ public: * @brief Constructor attaching to a certain object */ LandmarkMarker (lay::ViewService *service, const db::DPoint &pos, bool selected) - : lay::ViewObject (service->widget ()), + : lay::ViewObject (service->ui ()), mp_service (service), m_pos (pos), m_selected (selected), m_position_set (true) { // .. nothing yet .. @@ -50,7 +50,7 @@ public: * @brief Constructor attaching to a certain object */ LandmarkMarker (lay::ViewService *service, bool selected) - : lay::ViewObject (service->widget ()), + : lay::ViewObject (service->ui ()), mp_service (service), m_pos (), m_selected (selected), m_position_set (false) { // .. nothing yet .. @@ -146,7 +146,7 @@ class LandmarkEditorService { public: LandmarkEditorService (lay::LayoutViewBase *view, img::Object *img) - : lay::ViewService (view->view_object_widget ()), + : lay::ViewService (view->canvas ()), mp_image (img), m_selected (-1), m_dragging (false), m_mode (LandmarksDialog::None) { @@ -182,7 +182,7 @@ public: update (); - widget ()->grab_mouse (this, false); + ui ()->grab_mouse (this, false); m_dragging = true; } else if (m_mode == LandmarksDialog::Delete) { @@ -227,7 +227,7 @@ public: update (); - widget ()->grab_mouse (this, false); + ui ()->grab_mouse (this, false); m_dragging = false; } @@ -235,7 +235,7 @@ public: } else { int search_range = 5; // TODO: make_variable? - double l = double (search_range) / widget ()->mouse_event_trans ().mag (); + double l = double (search_range) / ui ()->mouse_event_trans ().mag (); db::DBox search_box = db::DBox (p, p).enlarged (db::DVector (l, l)); int li = 0; @@ -307,7 +307,7 @@ public: } else if (! m_dragging) { int search_range = 5; // TODO: make_variable? - double l = double (search_range) / widget ()->mouse_event_trans ().mag (); + double l = double (search_range) / ui ()->mouse_event_trans ().mag (); db::DBox search_box = db::DBox (p, p).enlarged (db::DVector (l, l)); int li = 0; @@ -343,10 +343,10 @@ public: m_dragging = false; } - widget ()->ungrab_mouse (this); + ui ()->ungrab_mouse (this); } - void set_colors (lay::Color /*background*/, lay::Color /*color*/) + void set_colors (tl::Color /*background*/, tl::Color /*color*/) { // ... } diff --git a/src/img/img/imgNavigator.cc b/src/img/img/imgNavigator.cc index 634b8bd1e..b9ce6bb92 100644 --- a/src/img/img/imgNavigator.cc +++ b/src/img/img/imgNavigator.cc @@ -52,13 +52,14 @@ img::Object * Navigator::setup (lay::Dispatcher *root, img::Object *img) { mp_view = new lay::LayoutView (0, false, root, this, "img_navigator_view", lay::LayoutView::LV_Naked + lay::LayoutView::LV_NoZoom + lay::LayoutView::LV_NoServices + lay::LayoutView::LV_NoGrid); - mp_view->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Expanding); - mp_view->setMinimumWidth (100); - mp_view->setMinimumHeight (100); + tl_assert (mp_view->widget ()); + mp_view->widget ()->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Expanding); + mp_view->widget ()->setMinimumWidth (100); + mp_view->widget ()->setMinimumHeight (100); QVBoxLayout *layout = new QVBoxLayout (this); - layout->addWidget (mp_view); - layout->setStretchFactor (mp_view, 1); + layout->addWidget (mp_view->widget ()); + layout->setStretchFactor (mp_view->widget (), 1); layout->setContentsMargins (0, 0, 0, 0); layout->setSpacing (0); setLayout (layout); @@ -93,7 +94,7 @@ Navigator::~Navigator () void Navigator::activate_service (lay::ViewService *service) { - mp_view->view_object_widget ()->activate (service); + mp_view->canvas ()->activate (service); } void diff --git a/src/img/img/imgObject.cc b/src/img/img/imgObject.cc index e2912b2d1..2fcdef1b2 100644 --- a/src/img/img/imgObject.cc +++ b/src/img/img/imgObject.cc @@ -27,7 +27,7 @@ #include "tlTimer.h" #include "layPlugin.h" #include "layConverters.h" -#include "layPixelBuffer.h" +#include "tlPixelBuffer.h" #include "dbPolygonTools.h" #include "tlFileUtils.h" #include "tlUri.h" @@ -53,8 +53,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 (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)))); + false_color_nodes.push_back (std::make_pair (0.0, std::make_pair (tl::Color (0, 0, 0), tl::Color (0, 0, 0)))); + false_color_nodes.push_back (std::make_pair (1.0, std::make_pair (tl::Color (255, 255, 255), tl::Color (255, 255, 255)))); } bool @@ -212,7 +212,7 @@ DataMapping::create_data_mapping (bool monochrome, double xmin, double xmax, uns for (int j = 0; j < n; ++j) { - lay::Color c = interpolated_color (false_color_nodes, x); + tl::Color c = interpolated_color (false_color_nodes, x); double y = 0.0; if (channel == 0) { @@ -273,7 +273,7 @@ namespace struct compare_first_of_node { - bool operator() (const std::pair > &a, const std::pair > &b) const + bool operator() (const std::pair > &a, const std::pair > &b) const { return a.first < b.first; } @@ -281,16 +281,16 @@ struct compare_first_of_node } -lay::Color +tl::Color interpolated_color (const DataMapping::false_color_nodes_type &nodes, double x) { if (nodes.size () < 1) { - return lay::Color (); + return tl::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 ()); + std::vector > >::const_iterator p = std::lower_bound (nodes.begin (), nodes.end (), std::make_pair (x, std::make_pair (tl::Color (), tl::Color ())), compare_first_of_node ()); if (p == nodes.end ()) { return nodes.back ().second.second; } else if (p == nodes.begin ()) { @@ -310,7 +310,7 @@ interpolated_color (const DataMapping::false_color_nodes_type &nodes, double x) 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); + return tl::Color::from_hsv ((unsigned int) h, (unsigned int) s, (unsigned int) v); } @@ -1340,7 +1340,7 @@ Object::from_string (const char *str, const char *base_dir) double x = 0.0; lay::ColorConverter cc; - lay::Color cl, cr; + tl::Color cl, cr; std::string s; m_data_mapping.false_color_nodes.clear (); @@ -1628,19 +1628,19 @@ Object::read_file () #elif defined(HAVE_PNG) - lay::PixelBuffer img; + tl::PixelBuffer img; { tl::InputStream stream (m_filename); - img = lay::PixelBuffer::read_png (stream); + img = tl::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 (); + const tl::color_t *d = img.scan_line (i); + const tl::color_t *dd = d + img.width (); while (! is_color && d != dd) { - lay::color_t c = *d++; + tl::color_t c = *d++; is_color = (((c >> 8) ^ c) & 0xffff) != 0; } } @@ -1669,15 +1669,15 @@ Object::read_file () 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 (); + const tl::color_t *d = img.scan_line (h - y - 1); + const tl::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); + tl::color_t rgb = *d++; + *red++ = tl::red (rgb); + *green++ = tl::green (rgb); + *blue++ = tl::blue (rgb); if (msk) { - *msk++ = lay::alpha (rgb) > 128; + *msk++ = tl::alpha (rgb) > 128; } } } @@ -1688,13 +1688,13 @@ Object::read_file () 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 (); + const tl::color_t *d = img.scan_line (h - y - 1); + const tl::color_t *dd = d + img.width (); while (d != dd) { - lay::color_t rgb = *d++; - *mono++ = lay::green (rgb); + tl::color_t rgb = *d++; + *mono++ = tl::green (rgb); if (msk) { - *msk++ = lay::alpha (rgb) > 128; + *msk++ = tl::alpha (rgb) > 128; } } } @@ -1702,7 +1702,7 @@ Object::read_file () } #else - throw tl::Exception (tl::to_string ("No PNG support compiled in - cannot load PNG files")); + throw tl::Exception ("No PNG support compiled in - cannot load PNG files"); #endif } @@ -1792,7 +1792,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 << ","; @@ -2223,7 +2223,7 @@ Object::validate_pixel_data () const size_t n = data_length (); - lay::color_t *nc_pixel_data = new lay::color_t [n]; + tl::color_t *nc_pixel_data = new tl::color_t [n]; mp_pixel_data = nc_pixel_data; double min = 0.0, max = 255.0; @@ -2248,7 +2248,7 @@ Object::validate_pixel_data () const if (mp_data->is_color ()) { - lay::color_t *pixel_data = nc_pixel_data; + tl::color_t *pixel_data = nc_pixel_data; const unsigned char *f = mp_data->byte_data (0); const tl::DataMappingLookupTable *l = &lut[0]; for (size_t j = 0; j < n; ++j) { @@ -2271,7 +2271,7 @@ Object::validate_pixel_data () const } else { - lay::color_t *pixel_data = nc_pixel_data; + tl::color_t *pixel_data = nc_pixel_data; const unsigned char *f = mp_data->byte_data (); const tl::DataMappingLookupTable *l = &lut[0]; for (size_t j = 0; j < n; ++j) { @@ -2298,7 +2298,7 @@ Object::validate_pixel_data () const if (mp_data->is_color ()) { - lay::color_t *pixel_data = nc_pixel_data; + tl::color_t *pixel_data = nc_pixel_data; const float *f = mp_data->float_data (0); const tl::DataMappingLookupTable *l = &lut[0]; for (size_t j = 0; j < n; ++j) { @@ -2321,7 +2321,7 @@ Object::validate_pixel_data () const } else { - lay::color_t *pixel_data = nc_pixel_data; + tl::color_t *pixel_data = nc_pixel_data; const float *f = mp_data->float_data (); const tl::DataMappingLookupTable *l = &lut[0]; for (size_t j = 0; j < n; ++j) { diff --git a/src/img/img/imgObject.h b/src/img/img/imgObject.h index 1d3f734e1..ed04de582 100644 --- a/src/img/img/imgObject.h +++ b/src/img/img/imgObject.h @@ -33,7 +33,7 @@ #include "dbMatrix.h" #include "dbPolygon.h" #include "tlDataMapping.h" -#include "layColor.h" +#include "tlColor.h" #include #include @@ -50,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 @@ -140,7 +140,7 @@ public: /** * @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); +tl::Color interpolated_color (const DataMapping::false_color_nodes_type &nodes, double x); /** * @brief A image object @@ -883,7 +883,7 @@ public: /** * @brief Get the RGB pixel data sets obtained by applying the LUT's */ - const lay::color_t *pixel_data () const + const tl::color_t *pixel_data () const { validate_pixel_data (); return mp_pixel_data; @@ -974,7 +974,7 @@ private: bool m_min_value_set, m_max_value_set; DataMapping m_data_mapping; bool m_visible; - mutable const lay::color_t *mp_pixel_data; + mutable const tl::color_t *mp_pixel_data; std::vector m_landmarks; int m_z_position; bool m_updates_enabled; diff --git a/src/img/img/imgPropertiesPage.cc b/src/img/img/imgPropertiesPage.cc index c53d36d77..7107a0a90 100644 --- a/src/img/img/imgPropertiesPage.cc +++ b/src/img/img/imgPropertiesPage.cc @@ -736,9 +736,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 (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)))); + std::vector > > nodes; + nodes.push_back (std::make_pair (0.0, std::make_pair (tl::Color (0, 0, 0), tl::Color (0, 0, 0)))); + nodes.push_back (std::make_pair (1.0, std::make_pair (tl::Color (255, 255, 255), tl::Color (255, 255, 255)))); false_color_control->set_nodes (nodes); emit edited (); } @@ -746,9 +746,9 @@ PropertiesPage::black_to_white () void PropertiesPage::white_to_black () { - 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)))); + std::vector > > nodes; + nodes.push_back (std::make_pair (0.0, std::make_pair (tl::Color (255, 255, 255), tl::Color (255, 255, 255)))); + nodes.push_back (std::make_pair (1.0, std::make_pair (tl::Color (0, 0, 0), tl::Color (0, 0, 0)))); false_color_control->set_nodes (nodes); emit edited (); } @@ -756,9 +756,9 @@ PropertiesPage::white_to_black () void PropertiesPage::red_to_blue () { - 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)))); + std::vector > > nodes; + nodes.push_back (std::make_pair (0.0, std::make_pair (tl::Color (255, 0, 0), tl::Color (255, 0, 0)))); + nodes.push_back (std::make_pair (1.0, std::make_pair (tl::Color (0, 0, 255), tl::Color (0, 0, 255)))); false_color_control->set_nodes (nodes); emit edited (); } @@ -766,9 +766,9 @@ PropertiesPage::red_to_blue () void PropertiesPage::blue_to_red () { - 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)))); + std::vector > > nodes; + nodes.push_back (std::make_pair (0.0, std::make_pair (tl::Color (0, 0, 255), tl::Color (0, 0, 255)))); + nodes.push_back (std::make_pair (1.0, std::make_pair (tl::Color (255, 0, 0), tl::Color (255, 0, 0)))); false_color_control->set_nodes (nodes); emit edited (); } @@ -776,7 +776,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/imgService.cc b/src/img/img/imgService.cc index de9fd331f..6c9e2ec78 100644 --- a/src/img/img/imgService.cc +++ b/src/img/img/imgService.cc @@ -90,7 +90,7 @@ private: // ------------------------------------------------------------- static void -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) +draw_scanline (unsigned int level, const img::Object &image_object, tl::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 (); @@ -122,8 +122,8 @@ draw_scanline (unsigned int level, const img::Object &image_object, lay::PixelBu double dpx = (p2.x () - p1.x ()) / double (xstop - xstart); double dpy = (p2.y () - p1.y ()) / double (xstop - xstart); - 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 (); + tl::color_t *scanline_data = pxbuffer.scan_line (pxbuffer.height () - y - 1) + xstart; + tl::color_t *pixel_data = (tl::color_t *) image_object.pixel_data (); const unsigned char *mask_data = image_object.mask (); for (int x = xstart; x < xstop; ++x) { @@ -155,7 +155,7 @@ draw_image (const img::Object &image_object, const lay::Viewport &vp, lay::ViewO return; } - lay::PixelBuffer &image = *bmp_canvas->bg_image (); + tl::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. @@ -410,7 +410,7 @@ View::render (const lay::Viewport &vp, lay::ViewObjectCanvas &canvas) // img::Service implementation Service::Service (db::Manager *manager, lay::LayoutViewBase *view) - : lay::BackgroundViewObject (view->view_object_widget ()), + : lay::BackgroundViewObject (view->canvas ()), lay::Editable (view), lay::Plugin (view), db::Object (manager), diff --git a/src/img/img/imgStream.cc b/src/img/img/imgStream.cc index cb84b63b6..f9e2b2193 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 32d85fdae..59e662d2b 100644 --- a/src/img/img/imgWidgets.cc +++ b/src/img/img/imgWidgets.cc @@ -128,8 +128,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 (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)))); + m_nodes.push_back (std::make_pair (0.0, std::make_pair (tl::Color (0, 0, 0), tl::Color (0, 0, 0)))); + m_nodes.push_back (std::make_pair (1.0, std::make_pair (tl::Color (255, 255, 255), tl::Color (255, 255, 255)))); } ColorBar::~ColorBar () @@ -161,7 +161,7 @@ void ColorBar::set_current_color (std::pair c) { if (has_selection ()) { - m_nodes [m_selected].second = std::make_pair (lay::Color (c.first.rgb ()), lay::Color (c.second.rgb ())); + m_nodes [m_selected].second = std::make_pair (tl::Color (c.first.rgb ()), tl::Color (c.second.rgb ())); emit color_mapping_changed (); update (); } @@ -220,7 +220,7 @@ namespace struct compare_first_of_node { - bool operator() (const std::pair > &a, const std::pair > &b) const + bool operator() (const std::pair > &a, const std::pair > &b) const { return a.first < b.first; } @@ -229,21 +229,21 @@ struct compare_first_of_node } 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 (lay::Color (0, 0, 0), lay::Color (0, 0, 0)))); + m_nodes.insert (m_nodes.begin (), std::make_pair (0.0, std::make_pair (tl::Color (0, 0, 0), tl::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; @@ -256,7 +256,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 (lay::Color (255, 255, 255), lay::Color (255, 255, 255)))); + m_nodes.push_back (std::make_pair (1.0, std::make_pair (tl::Color (255, 255, 255), tl::Color (255, 255, 255)))); } m_selected = -1; @@ -281,8 +281,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; @@ -291,9 +291,9 @@ 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 (); - std::pair cp = 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 (); @@ -328,13 +328,13 @@ 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 (lay::Color (), lay::Color ())), compare_first_of_node ()); + std::vector > >::iterator p = std::lower_bound (m_nodes.begin (), m_nodes.end (), std::make_pair (xx, std::make_pair (tl::Color (), tl::Color ())), compare_first_of_node ()); if (p != m_nodes.begin () && p != m_nodes.end ()) { m_selected = int (std::distance (m_nodes.begin (), p)); - lay::Color ci = interpolated_color (m_nodes, xx); + tl::Color ci = interpolated_color (m_nodes, xx); m_nodes.insert (p, std::make_pair (xx, std::make_pair (ci, ci))); emit selection_changed (); - std::pair cp = 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 (); @@ -410,7 +410,7 @@ ColorBar::paintEvent (QPaintEvent *) if (xr != xl) { xx = double (x - xl) / double (xr - xl); } - lay::Color c = interpolated_color (m_nodes, xx); + tl::Color c = interpolated_color (m_nodes, xx); 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 b44a8e0b0..ffc01bbe7 100644 --- a/src/img/img/imgWidgets.h +++ b/src/img/img/imgWidgets.h @@ -26,7 +26,7 @@ #define HDR_imgWidgets #include "layWidgets.h" -#include "layColor.h" +#include "tlColor.h" #include "imgObject.h" #include @@ -111,9 +111,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; } @@ -132,7 +132,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 5daf917f2..126335dcb 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 (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)))); + dm.false_color_nodes.push_back (std::make_pair (0.0, std::make_pair (tl::Color (0, 0, 0), tl::Color (0, 0, 0)))); + dm.false_color_nodes.push_back (std::make_pair (0.5, std::make_pair (tl::Color (255, 0, 0), tl::Color (0, 255, 0)))); + dm.false_color_nodes.push_back (std::make_pair (1.0, std::make_pair (tl::Color (255, 255, 255), tl::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 1dfabda0c..857742e77 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; - lay::Color c (128, 255, 64); - lay::Color c2 (64, 32, 192); + tl::Color c (128, 255, 64); + tl::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; - lay::Color c (128, 255, 64); + tl::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/klayout.pri b/src/klayout.pri index 9bf6debac..ad0504dd2 100644 --- a/src/klayout.pri +++ b/src/klayout.pri @@ -182,6 +182,17 @@ equals(HAVE_QT, "0") { QT = + # fake qrc made with python + !equals(HAVE_PYTHON, "0") { + new_qrc.output = qrc_${QMAKE_FILE_BASE}.cc + new_qrc.commands = $$PYTHON $$PWD/../scripts/pyqrc.py ${QMAKE_FILE_NAME} -o ${QMAKE_FILE_OUT} + new_qrc.depend_command = $$PYTHON $$PWD/../scripts/pyqrc.py ${QMAKE_FILE_NAME} + new_qrc.input = RESOURCES + new_qrc.variable_out = SOURCES + new_qrc.CONFIG += dep_lines + QMAKE_EXTRA_COMPILERS += new_qrc + } + } else { DEFINES += HAVE_QT @@ -290,3 +301,4 @@ DEFINES += \ KLAYOUT_TINY_VERSION=$$KLAYOUT_TINY_VERSION \ VERSION = $$KLAYOUT_VERSION + diff --git a/src/klayout_main/klayout_main/klayout.cc b/src/klayout_main/klayout_main/klayout.cc index 1e23482ce..54086adc0 100644 --- a/src/klayout_main/klayout_main/klayout.cc +++ b/src/klayout_main/klayout_main/klayout.cc @@ -154,14 +154,16 @@ main(int a_argc, const char **a_argv) #endif #if QT_VERSION >= 0x050000 -void myMessageOutput(QtMsgType type, const QMessageLogContext & /*ctx*/, const QString &msg) +void custom_message_handler(QtMsgType type, const QMessageLogContext & /*ctx*/, const QString &msg) { switch (type) { case QtDebugMsg: fprintf(stderr, "Debug: %s\n", msg.toLocal8Bit ().constData ()); break; case QtWarningMsg: - fprintf(stderr, "Warning: %s\n", msg.toLocal8Bit ().constData ()); + if (tl::verbosity () > 0) { + fprintf(stderr, "Warning: %s\n", msg.toLocal8Bit ().constData ()); + } break; case QtCriticalMsg: fprintf(stderr, "Critical: %s\n", msg.toLocal8Bit ().constData ()); @@ -175,14 +177,16 @@ void myMessageOutput(QtMsgType type, const QMessageLogContext & /*ctx*/, const Q } } #else -void myMessageOutput(QtMsgType type, const char *msg) +void custom_message_handler(QtMsgType type, const char *msg) { switch (type) { case QtDebugMsg: fprintf(stderr, "Debug: %s\n", msg); break; case QtWarningMsg: - fprintf(stderr, "Warning: %s\n", msg); + if (tl::verbosity () > 0) { + fprintf(stderr, "Warning: %s\n", msg); + } break; case QtCriticalMsg: fprintf(stderr, "Critical: %s\n", msg); @@ -223,7 +227,9 @@ klayout_main (int &argc, char **argv) about_text += prg_about_text; lay::Version::set_about_text (about_text.c_str ()); - // Capture the shortcut command line arguments + // Capture the shortcut command line arguments and the verbosity settings + // for early errors and warnings + for (int i = 1; i < argc; ++i) { if (argv [i] == std::string ("-v")) { @@ -236,6 +242,15 @@ klayout_main (int &argc, char **argv) tl::info << lay::ApplicationBase::usage () << tl::noendl; return 0; + } else if (argv [i] == std::string ("-d") && (i + 1) < argc) { + + int v = 0; + tl::from_string (argv [++i], v); + if (v < 0) { + v = 0; + } + tl::verbosity (v); + } } @@ -255,9 +270,9 @@ int klayout_main_cont (int &argc, char **argv) { #if QT_VERSION >= 0x050000 - qInstallMessageHandler (myMessageOutput); + qInstallMessageHandler (custom_message_handler); #else - qInstallMsgHandler (myMessageOutput); + qInstallMsgHandler (custom_message_handler); #endif int result = 0; diff --git a/src/lay/lay/gsiDeclLayMainWindow.cc b/src/lay/lay/gsiDeclLayMainWindow.cc index 17fa2f064..6443f694b 100644 --- a/src/lay/lay/gsiDeclLayMainWindow.cc +++ b/src/lay/lay/gsiDeclLayMainWindow.cc @@ -547,7 +547,7 @@ Class decl_MainWindow (QT_EXTERNAL_BASE (QMainWindow) "lay", "M "This version was introduced in version 0.22.\n" "Starting with version 0.25, this method returns a cellview object that can be modified to configure the cellview.\n" ) + - gsi::method ("load_layout", (lay::CellViewRef (lay::MainWindow::*) (const std::string &, int)) &lay::MainWindow::load_layout, gsi::arg ("filename"), gsi::arg ("mode"), + gsi::method ("load_layout", (lay::CellViewRef (lay::MainWindow::*) (const std::string &, int)) &lay::MainWindow::load_layout, gsi::arg ("filename"), gsi::arg ("mode", 1), "@brief Loads a new layout\n" "\n" "@param filename The name of the file to load\n" @@ -561,9 +561,9 @@ Class decl_MainWindow (QT_EXTERNAL_BASE (QMainWindow) "lay", "M "This version will use the initial technology and the default reader options. " "Others versions are provided which allow specification of technology and reader options explicitly.\n" "\n" - "Starting with version 0.25, this method returns a cellview object that can be modified to configure the cellview.\n" + "Starting with version 0.25, this method returns a cellview object that can be modified to configure the cellview. The 'mode' argument has been made optional in version 0.28.\n" ) + - gsi::method ("load_layout", (lay::CellViewRef (lay::MainWindow::*) (const std::string &, const std::string &, int)) &lay::MainWindow::load_layout, gsi::arg ("filename"), gsi::arg ("tech"), gsi::arg ("mode"), + gsi::method ("load_layout", (lay::CellViewRef (lay::MainWindow::*) (const std::string &, const std::string &, int)) &lay::MainWindow::load_layout, gsi::arg ("filename"), gsi::arg ("tech"), gsi::arg ("mode", 1), "@brief Loads a new layout and associate it with the given technology\n" "\n" "@param filename The name of the file to load\n" @@ -575,12 +575,12 @@ Class decl_MainWindow (QT_EXTERNAL_BASE (QMainWindow) "lay", "M "into a new view (mode 1) or adding the layout to the current view (mode 2).\n" "In mode 1, the new view is made the current one.\n" "\n" - "If the technology name is not a valid technology name, the default technology will be used.\n" + "If the technology name is not a valid technology name, the default technology will be used. The 'mode' argument has been made optional in version 0.28.\n" "\n" "This version was introduced in version 0.22.\n" "Starting with version 0.25, this method returns a cellview object that can be modified to configure the cellview.\n" ) + - gsi::method ("load_layout", (lay::CellViewRef (lay::MainWindow::*) (const std::string &, const db::LoadLayoutOptions &, int)) &lay::MainWindow::load_layout, gsi::arg ("filename"), gsi::arg ("options"), gsi::arg ("mode"), + gsi::method ("load_layout", (lay::CellViewRef (lay::MainWindow::*) (const std::string &, const db::LoadLayoutOptions &, int)) &lay::MainWindow::load_layout, gsi::arg ("filename"), gsi::arg ("options"), gsi::arg ("mode", 1), "@brief Loads a new layout with the given options\n" "\n" "@param filename The name of the file to load\n" @@ -593,9 +593,9 @@ Class decl_MainWindow (QT_EXTERNAL_BASE (QMainWindow) "lay", "M "In mode 1, the new view is made the current one.\n" "\n" "This version was introduced in version 0.22.\n" - "Starting with version 0.25, this method returns a cellview object that can be modified to configure the cellview.\n" + "Starting with version 0.25, this method returns a cellview object that can be modified to configure the cellview. The 'mode' argument has been made optional in version 0.28.\n" ) + - gsi::method ("load_layout", (lay::CellViewRef (lay::MainWindow::*) (const std::string &, const db::LoadLayoutOptions &, const std::string &, int)) &lay::MainWindow::load_layout, gsi::arg ("filename"), gsi::arg ("options"), gsi::arg ("tech"), gsi::arg ("mode"), + gsi::method ("load_layout", (lay::CellViewRef (lay::MainWindow::*) (const std::string &, const db::LoadLayoutOptions &, const std::string &, int)) &lay::MainWindow::load_layout, gsi::arg ("filename"), gsi::arg ("options"), gsi::arg ("tech"), gsi::arg ("mode", 1), "@brief Loads a new layout with the given options and associate it with the given technology\n" "\n" "@param filename The name of the file to load\n" @@ -611,7 +611,7 @@ Class decl_MainWindow (QT_EXTERNAL_BASE (QMainWindow) "lay", "M "If the technology name is not a valid technology name, the default technology will be used.\n" "\n" "This version was introduced in version 0.22.\n" - "Starting with version 0.25, this method returns a cellview object that can be modified to configure the cellview.\n" + "Starting with version 0.25, this method returns a cellview object that can be modified to configure the cellview. The 'mode' argument has been made optional in version 0.28.\n" ) + gsi::method ("clone_current_view", &lay::MainWindow::clone_current_view, "@brief Clones the current view and make it current\n" diff --git a/src/lay/lay/layApplication.cc b/src/lay/lay/layApplication.cc index 1ed3c8285..46b7648f4 100644 --- a/src/lay/lay/layApplication.cc +++ b/src/lay/lay/layApplication.cc @@ -185,6 +185,7 @@ ApplicationBase::ApplicationBase (bool non_ui_mode) : gsi::ObjectBase (), m_lyp_map_all_cvs (true), m_lyp_add_default (false), + m_run_macro_and_exit (true), m_packages_with_dep (false), m_write_config_file (false), m_gtf_replay_rate (0), @@ -353,8 +354,19 @@ ApplicationBase::parse_cmd (int &argc, char **argv) } else if (a == "-r" && (i + 1) < argc) { + if (! m_run_macro.empty ()) { + throw tl::Exception (tl::to_string (QObject::tr ("Option -r or -rr can only be used once"))); + } m_run_macro = args [++i]; + } else if (a == "-rr" && (i + 1) < argc) { + + if (! m_run_macro.empty ()) { + throw tl::Exception (tl::to_string (QObject::tr ("Option -r or -rr can only be used once"))); + } + m_run_macro = args [++i]; + m_run_macro_and_exit = false; + } else if (a == "-rx") { m_no_macros = true; @@ -998,7 +1010,8 @@ ApplicationBase::usage () r += tl::to_string (QObject::tr (" -nn Technology file (.lyt) to use for next layout(s) on command line")) + "\n"; r += tl::to_string (QObject::tr (" -p Load the plugin (can be used multiple times)")) + "\n"; r += tl::to_string (QObject::tr (" -r