Merge pull request #1087 from KLayout/qtless-canvas2

Qtless canvas2
This commit is contained in:
Matthias Köfferlein 2022-06-14 22:51:57 +02:00 committed by GitHub
commit 7a5737d55f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
208 changed files with 5165 additions and 2857 deletions

View File

@ -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"

154
scripts/pyqrc.py Executable file
View File

@ -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()

View File

@ -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):

View File

@ -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<ant::Template> make_standard_templates ()
{
std::vector<ant::Template> 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<std::string, std::string> > &options) const
{
options.push_back (std::pair<std::string, std::string> (cfg_max_number_of_rulers, "-1"));
options.push_back (std::pair<std::string, std::string> (cfg_ruler_snap_range, "8"));
options.push_back (std::pair<std::string, std::string> (cfg_ruler_color, lay::ColorConverter ().to_string (lay::Color ())));
options.push_back (std::pair<std::string, std::string> (cfg_ruler_color, lay::ColorConverter ().to_string (tl::Color ())));
options.push_back (std::pair<std::string, std::string> (cfg_ruler_halo, "true"));
options.push_back (std::pair<std::string, std::string> (cfg_ruler_snap_mode, ACConverter ().to_string (lay::AC_Any)));
options.push_back (std::pair<std::string, std::string> (cfg_ruler_obj_snap, tl::to_string (true)));
options.push_back (std::pair<std::string, std::string> (cfg_ruler_grid_snap, tl::to_string (false)));
options.push_back (std::pair<std::string, std::string> (cfg_ruler_templates, ""));
options.push_back (std::pair<std::string, std::string> (cfg_ruler_templates, ant::TemplatesConverter ().to_string (make_standard_templates ())));
options.push_back (std::pair<std::string, std::string> (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<ant::Template> 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<lay::PluginDeclaration> config_decl (new ant::PluginDeclaration (), 3000, "ant::Plugin");

View File

@ -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<ant::Template> m_templates;
int m_current_template;
#if defined(HAVE_QT)
tl::weak_collection<lay::ConfigureAction> m_actions;
#endif
bool m_current_template_updated;
bool m_templates_updated;
};

View File

@ -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);

View File

@ -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 <lay::ViewOp>
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);

View File

@ -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<ant::Template> &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 <lay::ViewOp> get_view_ops (lay::RedrawThreadCanvas &canvas, lay::Color background, lay::Color foreground, lay::Color active) const;
std::vector <lay::ViewOp> get_view_ops (lay::RedrawThreadCanvas &canvas, tl::Color background, tl::Color foreground, tl::Color active) const;
/**
* @brief Update m_rulers to reflect the selection

View File

@ -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"),

View File

@ -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
*

View File

@ -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<ant::Object> decl_BasicAnnotation ("lay", "BasicAnnotation", gsi::Methods (), "@hide\n@alias Annotation");
gsi::Class<AnnotationRef> 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<AnnotationRef> decl_Annotation (decl_BasicAnnotation, "lay", "Annotat
"@/code\n"
);
static std::vector<std::vector<tl::Variant> > get_annotation_templates (lay::LayoutViewBase *view)
{
ant::Service *ant_service = view->get_plugin <ant::Service> ();
tl_assert (ant_service != 0);
std::vector<std::vector<tl::Variant> > ant_objects;
const std::vector<ant::Template> &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<tl::Variant> ());
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<lay::LayoutViewBase> layout_view_decl (
gsi::method_ext ("clear_annotations", &gsi::clear_annotations,
@ -1063,6 +1103,42 @@ gsi::ClassExt<lay::LayoutViewBase> 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."
),
""
);

View File

@ -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;

View File

@ -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)
{

View File

@ -392,7 +392,7 @@ HEADERS = \
dbShapeCollection.h \
dbShapeCollectionUtils.h
!equals(HAVE_QT, "0") {
!equals(HAVE_QT, "0") || !equals(HAVE_PYTHON, "0") {
RESOURCES = \
dbResources.qrc \

View File

@ -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)

View File

@ -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

View File

@ -65,12 +65,11 @@ static std::vector<const db::TextGenerator *> generators ()
}
Class<db::TextGenerator> 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."

View File

@ -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

View File

@ -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

View File

@ -19,7 +19,7 @@ module DRC
# Installs the home menu entries (needs to be done on autorun, not autorun-early)
if RBA::Application::instance &amp;&amp; RBA::Application::instance.main_window
if RBA.constants.member?(:Application) &amp;&amp; RBA::Application::instance &amp;&amp; RBA::Application::instance.main_window
cat = "drc"

View File

@ -88,7 +88,7 @@ module DRC
create_template(":/drc-templates/drc.lym")
# if available, create a menu branch
if RBA::Application::instance &amp;&amp; RBA::Application::instance.main_window
if RBA.constants.member?(:Application) &amp;&amp; RBA::Application::instance &amp;&amp; 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) &amp;&amp; RBA::Application::instance
RBA::Application::instance.add_macro_category("drc", "DRC", [ "drc" ])
end

View File

@ -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

View File

@ -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<std::pair<unsigned int, unsigned int> > 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<lay::LayerPropertiesConstIterator>::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<edt::Service *> (view ()->view_object_widget ()->active_service ());
edt::Service *es = dynamic_cast<edt::Service *> (view ()->canvas ()->active_service ());
if (es) {
es->tap (pt);
}

View File

@ -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::pair <db::cell_index_type, std::pair <unsigned int, unsigned int> >, std::vector <partial_objects::const_iterator> > 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

View File

@ -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)

View File

@ -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

View File

@ -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;

View File

@ -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

View File

@ -21,41 +21,33 @@
*/
#include "gsiDecl.h"
#include "layPixelBuffer.h"
#include "tlPixelBuffer.h"
#if defined(HAVE_QT)
# include <QBuffer>
# include <QColor>
#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<char> &data)
static tl::PixelBuffer pixel_buffer_from_png (const std::vector<char> &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<int>::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<char> pixel_buffer_to_png (const lay::PixelBuffer *pb)
static std::vector<char> pixel_buffer_to_png (const tl::PixelBuffer *pb)
{
#if defined(HAVE_PNG)
tl::OutputMemoryStream data_stream;
@ -135,7 +127,7 @@ static std::vector<char> pixel_buffer_to_png (const lay::PixelBuffer *pb)
}
Class<lay::PixelBuffer> decl_PixelBuffer ("lay", "PixelBuffer",
Class<tl::PixelBuffer> 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<lay::PixelBuffer> 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<lay::PixelBuffer> 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<lay::PixelBuffer> 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<lay::PixelBuffer> 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<char> &data)
static tl::BitmapBuffer bitmap_buffer_from_png (const std::vector<char> &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<int>::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<char> bitmap_buffer_to_png (const lay::BitmapBuffer *pb)
static std::vector<char> bitmap_buffer_to_png (const tl::BitmapBuffer *pb)
{
#if defined(HAVE_PNG)
tl::OutputMemoryStream data_stream;
@ -335,7 +314,7 @@ static std::vector<char> bitmap_buffer_to_png (const lay::BitmapBuffer *pb)
}
Class<lay::BitmapBuffer> decl_BitmapBuffer ("lay", "BitmapBuffer",
Class<tl::BitmapBuffer> 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<lay::BitmapBuffer> 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<lay::BitmapBuffer> 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"

View File

@ -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 ();

View File

@ -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*/)
{
// ...
}

View File

@ -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

View File

@ -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 <double, std::pair<lay::Color, lay::Color> > &a, const std::pair <double, std::pair<lay::Color, lay::Color> > &b) const
bool operator() (const std::pair <double, std::pair<tl::Color, tl::Color> > &a, const std::pair <double, std::pair<tl::Color, tl::Color> > &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<std::pair<double, std::pair<lay::Color, lay::Color> > >::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<std::pair<double, std::pair<tl::Color, tl::Color> > >::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<lay::Color, lay::Color> &clr = data_mapping ().false_color_nodes[i].second;
const std::pair<tl::Color, tl::Color> &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) {

View File

@ -33,7 +33,7 @@
#include "dbMatrix.h"
#include "dbPolygon.h"
#include "tlDataMapping.h"
#include "layColor.h"
#include "tlColor.h"
#include <string>
#include <vector>
@ -50,7 +50,7 @@ class DataHeader;
struct IMG_PUBLIC DataMapping
{
public:
typedef std::vector< std::pair<double, std::pair<lay::Color, lay::Color> > > false_color_nodes_type;
typedef std::vector< std::pair<double, std::pair<tl::Color, tl::Color> > > 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 <db::DPoint> m_landmarks;
int m_z_position;
bool m_updates_enabled;

View File

@ -736,9 +736,9 @@ PropertiesPage::blue_spinbox_changed (double value)
void
PropertiesPage::black_to_white ()
{
std::vector <std::pair <double, std::pair<lay::Color, lay::Color> > > 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 <std::pair <double, std::pair<tl::Color, tl::Color> > > 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 <std::pair <double, std::pair<lay::Color, lay::Color> > > 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 <std::pair <double, std::pair<tl::Color, tl::Color> > > 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 <std::pair <double, std::pair<lay::Color, lay::Color> > > 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 <std::pair <double, std::pair<tl::Color, tl::Color> > > 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 <std::pair <double, std::pair<lay::Color, lay::Color> > > 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 <std::pair <double, std::pair<tl::Color, tl::Color> > > 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 <std::pair <double, std::pair<lay::Color, lay::Color> > > nodes (false_color_control->nodes ());
std::vector <std::pair <double, std::pair<tl::Color, tl::Color> > > 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);

View File

@ -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),

View File

@ -373,7 +373,7 @@ namespace {
struct ColorMapConverter
{
std::string to_string (const std::pair<double, std::pair<lay::Color, lay::Color> > &cm) const
std::string to_string (const std::pair<double, std::pair<tl::Color, tl::Color> > &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<double, std::pair<lay::Color, lay::Color> > &cm) const
void from_string (const std::string &s, std::pair<double, std::pair<tl::Color, tl::Color> > &cm) const
{
tl::Extractor ex (s.c_str ());
@ -427,7 +427,7 @@ tl::XMLStruct<ImageProxy> 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<std::pair<double, std::pair<lay::Color, lay::Color> >, 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<std::pair<double, std::pair<tl::Color, tl::Color> >, 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") +

View File

@ -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<QColor, QColor> 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 <double, std::pair<lay::Color, lay::Color> > &a, const std::pair <double, std::pair<lay::Color, lay::Color> > &b) const
bool operator() (const std::pair <double, std::pair<tl::Color, tl::Color> > &a, const std::pair <double, std::pair<tl::Color, tl::Color> > &b) const
{
return a.first < b.first;
}
@ -229,21 +229,21 @@ struct compare_first_of_node
}
void
ColorBar::set_nodes (const std::vector<std::pair<double, std::pair<lay::Color, lay::Color> > > &nodes)
ColorBar::set_nodes (const std::vector<std::pair<double, std::pair<tl::Color, tl::Color> > > &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 <std::pair <double, std::pair<lay::Color, lay::Color> > >::iterator w = m_nodes.begin ();
std::vector <std::pair <double, std::pair<lay::Color, lay::Color> > >::const_iterator nn = m_nodes.begin ();
for (std::vector <std::pair <double, std::pair<lay::Color, lay::Color> > >::const_iterator n = m_nodes.begin () + 1; n != m_nodes.end (); ++n) {
std::vector <std::pair <double, std::pair<tl::Color, tl::Color> > >::iterator w = m_nodes.begin ();
std::vector <std::pair <double, std::pair<tl::Color, tl::Color> > >::const_iterator nn = m_nodes.begin ();
for (std::vector <std::pair <double, std::pair<tl::Color, tl::Color> > >::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<std::pair<double, std::pair<lay::Color, l
if (m_nodes.back ().first > 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<std::pair<double, std::pair<lay::Color, lay::Color> > >::const_iterator pmin = m_nodes.end ();
for (std::vector<std::pair<double, std::pair<lay::Color, lay::Color> > >::const_iterator p = m_nodes.begin (); p != m_nodes.end (); ++p) {
std::vector<std::pair<double, std::pair<tl::Color, tl::Color> > >::const_iterator pmin = m_nodes.end ();
for (std::vector<std::pair<double, std::pair<tl::Color, tl::Color> > >::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<std::pair<double, std::pair<lay::Color, lay::Color> > >::const_iterator (m_nodes.begin ()), pmin));
m_selected = int (std::distance (std::vector<std::pair<double, std::pair<tl::Color, tl::Color> > >::const_iterator (m_nodes.begin ()), pmin));
emit selection_changed ();
std::pair<lay::Color, lay::Color> cp = m_nodes [m_selected].second;
std::pair<tl::Color, tl::Color> 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<std::pair<double, std::pair<lay::Color, lay::Color> > >::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<std::pair<double, std::pair<tl::Color, tl::Color> > >::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<lay::Color, lay::Color> cp = m_nodes [m_selected].second;
std::pair<tl::Color, tl::Color> 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 ())));

View File

@ -26,7 +26,7 @@
#define HDR_imgWidgets
#include "layWidgets.h"
#include "layColor.h"
#include "tlColor.h"
#include "imgObject.h"
#include <QObject>
@ -111,9 +111,9 @@ public:
return m_selected >= 0;
}
void set_nodes (const std::vector <std::pair <double, std::pair<lay::Color, lay::Color> > > &nodes);
void set_nodes (const std::vector <std::pair <double, std::pair<tl::Color, tl::Color> > > &nodes);
const std::vector <std::pair <double, std::pair<lay::Color, lay::Color> > > &nodes () const
const std::vector <std::pair <double, std::pair<tl::Color, tl::Color> > > &nodes () const
{
return m_nodes;
}
@ -132,7 +132,7 @@ signals:
private:
bool m_dragging;
int m_selected;
std::vector <std::pair <double, std::pair<lay::Color, lay::Color> > > m_nodes;
std::vector <std::pair <double, std::pair<tl::Color, tl::Color> > > m_nodes;
std::vector <size_t> m_histogram;
};

View File

@ -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);

View File

@ -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);

View File

@ -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

View File

@ -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;

View File

@ -547,7 +547,7 @@ Class<lay::MainWindow> 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<lay::MainWindow> 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<lay::MainWindow> 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<lay::MainWindow> 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<lay::MainWindow> 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"

View File

@ -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 <tech file> Technology file (.lyt) to use for next layout(s) on command line")) + "\n";
r += tl::to_string (QObject::tr (" -p <plugin> Load the plugin (can be used multiple times)")) + "\n";
r += tl::to_string (QObject::tr (" -r <script> Execute main script on startup (after having loaded files etc.)")) + "\n";
r += tl::to_string (QObject::tr (" -rm <script> Execute module on startup (can be used multiple times)")) + "\n";
r += tl::to_string (QObject::tr (" -rr <script> Like -r, but does not exit after executing the script")) + "\n";
r += tl::to_string (QObject::tr (" -rm <script> Execute script on startup before loading files (can be used multiple times)")) + "\n";
r += tl::to_string (QObject::tr (" -rd <name>=<value> Specify script variable")) + "\n";
r += tl::to_string (QObject::tr (" -rx Ignore all implicit macros (*.rbm, rbainit, *.lym)")) + "\n";
r += tl::to_string (QObject::tr (" -s Load files into same view")) + "\n";
@ -1091,6 +1104,10 @@ ApplicationBase::run ()
// Run plugin and macro specific initializations
autorun ();
// Some objects we need during batch mode view generation
db::Manager batch_mode_manager;
tl::shared_ptr<LayoutView> batch_mode_view;
if (mw) {
for (std::vector <std::pair<file_type, std::pair<std::string, std::string> > >::const_iterator f = m_files.begin (); f != m_files.end (); ++f) {
@ -1141,11 +1158,7 @@ ApplicationBase::run ()
if (! m_layer_props_file.empty ()) {
if (m_lyp_map_all_cvs && mw->is_single_cv_layer_properties_file (m_layer_props_file)) {
mw->load_layer_properties (m_layer_props_file, -1, true /*all views*/, m_lyp_add_default);
} else {
mw->load_layer_properties (m_layer_props_file, true /*all views*/, m_lyp_add_default);
}
mw->load_layer_properties (m_layer_props_file, true /*all views*/, m_lyp_add_default);
tl::log << "Layer properties loaded '" << m_layer_props_file << "'";
@ -1165,25 +1178,79 @@ ApplicationBase::run ()
player.replay (m_gtf_replay_rate, m_gtf_replay_stop);
}
// Give the plugins a change to do some last-minute initialisation and checks
for (tl::Registrar<lay::PluginDeclaration>::iterator cls = tl::Registrar<lay::PluginDeclaration>::begin (); cls != tl::Registrar<lay::PluginDeclaration>::end (); ++cls) {
lay::PluginDeclaration *pd = const_cast<lay::PluginDeclaration *> (&*cls);
pd->initialized (dispatcher ());
}
if (! m_no_gui && m_gtf_replay.empty () && m_gtf_record.empty ()) {
// Show initial tip window if required
mw->about_to_exec ();
}
} else if (dispatcher ()) {
// Give the plugins a change to do some last-minute initialisation and checks
} else {
// in batch mode create at least one
for (std::vector <std::pair<file_type, std::pair<std::string, std::string> > >::const_iterator f = m_files.begin (); f != m_files.end (); ++f) {
if (f->first == layout_file || f->first == layout_file_with_tech) {
std::string filename = f->second.first;
if (batch_mode_view.get () != 0 && ! m_same_view) {
tl::warn << tl::sprintf (tl::to_string (tr ("Ignoring additional views in batch mode (file %s)")), filename);
continue;
}
if (! batch_mode_view) {
batch_mode_view.reset (create_view (batch_mode_manager));
}
if (f->first != layout_file_with_tech) {
batch_mode_view->load_layout (f->second.first, true);
} else {
batch_mode_view->load_layout (f->second.first, f->second.second, true);
}
// Make the first one loaded the active one.
batch_mode_view->set_active_cellview_index (0);
} else if (f->first == rdb_file) {
if (! batch_mode_view) {
batch_mode_view.reset (create_view (batch_mode_manager));
}
std::unique_ptr <rdb::Database> db (new rdb::Database ());
db->load (f->second.first);
batch_mode_view->add_rdb (db.release ());
} else if (f->first == l2ndb_file) {
if (! batch_mode_view) {
batch_mode_view.reset (create_view (batch_mode_manager));
}
batch_mode_view->add_l2ndb (db::LayoutToNetlist::create_from_file (f->second.first));
}
}
if (! m_layer_props_file.empty () && batch_mode_view.get ()) {
batch_mode_view->load_layer_props (m_layer_props_file, m_lyp_add_default);
tl::log << "Layer properties loaded '" << m_layer_props_file << "'";
// because the layer may carry transformations, we need to refit the cellviews.
batch_mode_view->zoom_fit ();
}
}
// Give the plugins a change to do some last-minute initialisation and checks
if (dispatcher ()) {
for (tl::Registrar<lay::PluginDeclaration>::iterator cls = tl::Registrar<lay::PluginDeclaration>::begin (); cls != tl::Registrar<lay::PluginDeclaration>::end (); ++cls) {
lay::PluginDeclaration *pd = const_cast<lay::PluginDeclaration *> (&*cls);
pd->initialized (dispatcher ());
}
}
if (mw && ! m_no_gui && m_gtf_replay.empty () && m_gtf_record.empty ()) {
// Show initial tip window if required
mw->about_to_exec ();
}
if (! m_run_macro.empty ()) {
@ -1194,15 +1261,39 @@ ApplicationBase::run ()
macro.set_file_path (m_run_macro);
result = macro.run ();
if (result == 0 && ! m_run_macro_and_exit) {
result = exec ();
}
} else {
result = exec ();
}
finish ();
batch_mode_view.reset (0);
return result;
}
lay::LayoutView *
ApplicationBase::create_view (db::Manager &manager)
{
// create a new view
lay::LayoutView *view = new lay::LayoutView (&manager, lay::ApplicationBase::instance ()->is_editable (), dispatcher (), 0 /*parent*/);
// set initial attributes
view->set_synchronous (m_sync_mode);
int tl = 0;
dispatcher ()->config_get (cfg_initial_hier_depth, tl);
view->set_hier_levels (std::make_pair (0, tl));
view->set_current ();
return view;
}
void
ApplicationBase::autorun ()
{
@ -1250,7 +1341,8 @@ dump_children (QObject *obj, int level = 0)
void
ApplicationBase::process_events_impl (QEventLoop::ProcessEventsFlags /*flags*/, bool /*silent*/)
{
// The base class implementation does nothing ..
// in the non-UI case there are no events, but we can at least schedule deferred method calls.
tl::DeferredMethodScheduler::execute ();
}
bool

View File

@ -54,6 +54,11 @@ namespace lym
class MacroCollection;
}
namespace db
{
class Manager;
}
namespace lay
{
@ -61,6 +66,7 @@ class MainWindow;
class Dispatcher;
class ProgressReporter;
class ProgressBar;
class LayoutView;
/**
* @brief The application base class
@ -324,6 +330,7 @@ protected:
private:
std::vector<std::string> scan_global_modules ();
lay::LayoutView *create_view (db::Manager &manager);
enum file_type {
layout_file,
@ -339,6 +346,7 @@ private:
bool m_lyp_map_all_cvs, m_lyp_add_default;
std::string m_session_file;
std::string m_run_macro;
bool m_run_macro_and_exit;
std::vector<std::pair<std::string, std::string> > m_custom_macro_paths;
std::vector<std::string> m_load_macros;
std::vector <std::string> m_package_inst;

View File

@ -28,6 +28,7 @@
#include "tlException.h"
#include "tlString.h"
#include "tlExceptions.h"
#include "layUtils.h"
namespace lay
{
@ -55,10 +56,14 @@ public:
menu_entries.push_back (lay::menu_item ("clip_tool::show", "clip_tool:edit_mode", "edit_menu.utils_menu.end", tl::to_string (QObject::tr ("Clip Tool"))));
}
virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutViewBase *view) const
{
return new ClipDialog (root, view);
}
virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutViewBase *view) const
{
if (lay::has_gui ()) {
return new ClipDialog (root, view);
} else {
return 0;
}
}
};
static tl::RegisteredClass<lay::PluginDeclaration> config_decl (new ClipDialogPluginDeclaration (), 20000, "ClipDialogPlugin");

View File

@ -34,6 +34,7 @@
#include "tlExceptions.h"
#include "layMainWindow.h"
#include "layCellSelectionForm.h"
#include "layUtils.h"
#include "edtService.h"
namespace lay
@ -64,7 +65,11 @@ public:
virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutViewBase *view) const
{
return new FillDialog (root, view);
if (lay::has_gui ()) {
return new FillDialog (root, view);
} else {
return 0;
}
}
};

View File

@ -25,6 +25,7 @@
#include "tlException.h"
#include "tlScriptError.h"
#include "tlString.h"
#include "gsiInspector.h"
#include <cstdio>
@ -71,18 +72,17 @@ pretty_print (const tl::Variant &v)
} else if (v.is_double ()) {
QString res (QString::fromUtf8 ("%.12g").arg (v.to_double ()));
return res;
return tl::to_qstring (tl::sprintf ("%.12g", v.to_double ()));
} else if (v.is_char ()) {
QString details (QString::fromUtf8 ("#%d (0x%x)").arg (v.to_int ()).arg (v.to_uint ()));
return tl::to_qstring (std::string ("'") + v.to_string () + "' ") + details;
std::string details = tl::sprintf ("#%d (0x%x)", v.to_int (), v.to_uint ());
return tl::to_qstring (std::string ("'") + v.to_string () + "' " + details);
} else if (v.is_ulong () || v.is_long () || v.is_ulonglong () || v.is_longlong ()) {
QString details (QString::fromUtf8 ("(0x%llx)").arg (v.to_ulonglong ()));
return tl::to_qstring (v.to_string ()) + details;
std::string details = tl::sprintf (" (0x%llx)", v.to_ulonglong ());
return tl::to_qstring (v.to_string () + details);
} else {
return tl::to_qstring (v.to_parsable_string ());

View File

@ -180,6 +180,7 @@ MainWindow::MainWindow (QApplication *app, const char *name, bool undo_enabled)
m_manager (undo_enabled)
{
m_dispatcher.set_menu_parent_widget (this);
m_dispatcher.make_menu ();
// ensures the deferred method scheduler is present
tl::DeferredMethodScheduler::instance ();
@ -1985,38 +1986,6 @@ MainWindow::load_layer_properties (const std::string &fn, int cv_index, bool all
}
}
bool
MainWindow::is_single_cv_layer_properties_file (const std::string &fn)
{
// If the file contains information for a single layout but we have multiple ones,
// show the dialog to determine what layout to apply the information to.
std::vector<lay::LayerPropertiesList> props;
try {
tl::XMLFileSource in (fn);
props.push_back (lay::LayerPropertiesList ());
props.back ().load (in);
} catch (...) {
props.clear ();
tl::XMLFileSource in (fn);
lay::LayerPropertiesList::load (in, props);
}
// Collect all cv indices in the layer properties
std::set <int> cv;
for (std::vector<lay::LayerPropertiesList>::const_iterator p = props.begin (); p != props.end (); ++p) {
for (lay::LayerPropertiesConstIterator lp = p->begin_const_recursive (); ! lp.at_end (); ++lp) {
if (! lp->has_children ()) {
cv.insert (lp->source (true).cv_index ());
if (cv.size () >= 2) {
break;
}
}
}
}
return (cv.size () == 1);
}
void
MainWindow::cm_save_layer_props ()
{
@ -2054,7 +2023,7 @@ MainWindow::load_layer_props_from_file (const std::string &fn)
int target_cv_index = -2;
if (current_view ()->cellviews () > 1 && is_single_cv_layer_properties_file (fn)) {
if (current_view ()->cellviews () > 1 && lay::LayoutView::is_single_cv_layer_properties_file (fn)) {
QStringList items;
items << QString (QObject::tr ("Take it as it is"));
@ -3368,21 +3337,23 @@ MainWindow::create_layout (const std::string &technology, int mode)
void
MainWindow::add_view (lay::LayoutView *view)
{
connect (view, SIGNAL (title_changed ()), this, SLOT (view_title_changed ()));
connect (view, SIGNAL (dirty_changed ()), this, SLOT (view_title_changed ()));
connect (view, SIGNAL (edits_enabled_changed ()), this, SLOT (edits_enabled_changed ()));
connect (view, SIGNAL (menu_needs_update ()), this, SLOT (menu_needs_update ()));
connect (view, SIGNAL (show_message (const std::string &, int)), this, SLOT (message (const std::string &, int)));
connect (view, SIGNAL (current_pos_changed (double, double, bool)), this, SLOT (current_pos (double, double, bool)));
connect (view, SIGNAL (clear_current_pos ()), this, SLOT (clear_current_pos ()));
connect (view, SIGNAL (mode_change (int)), this, SLOT (select_mode (int)));
tl_assert (view->widget ());
connect (view->widget (), SIGNAL (title_changed ()), this, SLOT (view_title_changed ()));
connect (view->widget (), SIGNAL (dirty_changed ()), this, SLOT (view_title_changed ()));
connect (view->widget (), SIGNAL (edits_enabled_changed ()), this, SLOT (edits_enabled_changed ()));
connect (view->widget (), SIGNAL (menu_needs_update ()), this, SLOT (menu_needs_update ()));
connect (view->widget (), SIGNAL (show_message (const std::string &, int)), this, SLOT (message (const std::string &, int)));
connect (view->widget (), SIGNAL (current_pos_changed (double, double, bool)), this, SLOT (current_pos (double, double, bool)));
connect (view->widget (), SIGNAL (clear_current_pos ()), this, SLOT (clear_current_pos ()));
connect (view->widget (), SIGNAL (mode_change (int)), this, SLOT (select_mode (int)));
mp_views.push_back (view);
// we must resize the widget here to set the geometry properly.
// This is required to make zoom_fit work.
view->setGeometry (0, 0, mp_view_stack->width (), mp_view_stack->height ());
view->show ();
view->widget ()->setGeometry (0, 0, mp_view_stack->width (), mp_view_stack->height ());
view->widget ()->show ();
}
int
@ -3563,7 +3534,7 @@ MainWindow::view_title_changed ()
update_tab_title (i);
}
if (sender () == current_view ()) {
if (current_view () && sender () == current_view ()->widget ()) {
update_window_title ();
}
}

View File

@ -239,13 +239,6 @@ public:
*/
void clone_current_view ();
/**
* @brief Determine whether a given layer properties file is a single-layout file
*
* @return True, if the file contains definitions of a single layout only.
*/
bool is_single_cv_layer_properties_file (const std::string &fn);
/**
* @brief Load a layer definition file
*

View File

@ -50,7 +50,7 @@ public:
};
NavigatorService (LayoutView *view)
: ViewService (view->view_object_widget ()),
: ViewService (view->canvas ()),
mp_view (view), mp_source_view (0),
mp_viewport_marker (0),
m_drag_mode (DM_none),
@ -72,18 +72,22 @@ public:
void background_color_changed ()
{
lay::Color c = mp_view->background_color ();
tl::Color c = mp_view->background_color ();
// replace by "real" background color if required
if (! c.is_valid ()) {
c = lay::Color (mp_view->palette ().color (QPalette::Normal, QPalette::Base).rgb ());
if (mp_view->widget ()) {
c = tl::Color (mp_view->widget ()->palette ().color (QPalette::Normal, QPalette::Base).rgb ());
} else {
c = tl::Color (0xffffff); // white
}
}
lay::Color contrast;
tl::Color contrast;
if (c.to_mono ()) {
contrast = lay::Color (0, 0, 0);
contrast = tl::Color (0, 0, 0);
} else {
contrast = lay::Color (255, 255, 255);
contrast = tl::Color (255, 255, 255);
}
set_colors (c, contrast);
@ -97,7 +101,7 @@ public:
delete mp_box;
mp_box = 0;
widget ()->ungrab_mouse (this);
ui ()->ungrab_mouse (this);
if (mp_source_view) {
mp_source_view->zoom_box (db::DBox (m_p1, m_p2));
@ -108,7 +112,7 @@ public:
} else if (m_dragging) {
m_dragging = false;
widget ()->ungrab_mouse (this);
ui ()->ungrab_mouse (this);
return true;
} else {
@ -119,7 +123,7 @@ public:
bool mouse_click_event (const db::DPoint &p, unsigned int buttons, bool prio)
{
if (! prio && (buttons & lay::RightButton) != 0) {
db::DBox vp = widget ()->mouse_event_viewport ();
db::DBox vp = ui ()->mouse_event_viewport ();
if (mp_source_view && vp.contains (p)) {
db::DVector d = (vp.p2 () - vp.p1 ()) * 0.5;
mp_source_view->zoom_box (db::DBox (p - d, p + d));
@ -152,7 +156,7 @@ public:
m_dragging = true;
m_p0 = p;
m_b0 = m_box;
widget ()->grab_mouse (this, true);
ui ()->grab_mouse (this, true);
return true;
} else {
@ -385,10 +389,10 @@ public:
delete mp_box;
mp_box = 0;
}
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)
{
// set zoom box color
m_color = color.rgb ();
@ -422,9 +426,9 @@ private:
mp_box = 0;
m_p1 = pos;
m_vp = widget ()->mouse_event_viewport ();
m_vp = ui ()->mouse_event_viewport ();
widget ()->grab_mouse (this, true);
ui ()->grab_mouse (this, true);
}
void begin (const db::DPoint &pos)
@ -435,9 +439,9 @@ private:
m_p1 = pos;
m_p2 = pos;
mp_box = new lay::RubberBox (widget (), m_color, pos, pos);
mp_box = new lay::RubberBox (ui (), m_color, pos, pos);
widget ()->grab_mouse (this, true);
ui ()->grab_mouse (this, true);
}
};
@ -626,8 +630,8 @@ Navigator::view_closed (int index)
void
Navigator::resizeEvent (QResizeEvent *)
{
if (mp_view) {
mp_view->setGeometry (mp_placeholder_label->geometry ());
if (mp_view && mp_view->widget ()) {
mp_view->widget ()->setGeometry (mp_placeholder_label->geometry ());
}
}
@ -652,14 +656,15 @@ Navigator::attach_view (LayoutView *view)
if (mp_source_view) {
mp_view = new LayoutView (0, false, mp_source_view, this, "navigator", LayoutView::LV_Naked + LayoutView::LV_NoZoom + LayoutView::LV_NoServices + LayoutView::LV_NoGrid);
mp_view->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Expanding);
mp_view->setMinimumWidth (100);
mp_view->setMinimumHeight (100);
mp_view->setGeometry (mp_placeholder_label->geometry ());
mp_view->show ();
tl_assert (mp_view->widget ());
mp_view->widget ()->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Expanding);
mp_view->widget ()->setMinimumWidth (100);
mp_view->widget ()->setMinimumHeight (100);
mp_view->widget ()->setGeometry (mp_placeholder_label->geometry ());
mp_view->widget ()->show ();
mp_service = new NavigatorService (mp_view);
mp_view->view_object_widget ()->activate (mp_service);
mp_view->canvas ()->activate (mp_service);
mp_source_view->cellviews_changed_event.add (this, &Navigator::content_changed);
mp_source_view->cellview_changed_event.add (this, &Navigator::content_changed_with_int);

View File

@ -26,6 +26,7 @@
#include "layMainWindow.h"
#include "layApplication.h"
#include "layUtils.h"
namespace lay
{
@ -65,7 +66,11 @@ public:
virtual lay::Plugin *create_plugin (db::Manager *, lay::Dispatcher *root, lay::LayoutViewBase *view) const
{
return new SearchReplaceDialog (root, view);
if (lay::has_gui ()) {
return new SearchReplaceDialog (root, view);
} else {
return 0;
}
}
};

View File

@ -42,8 +42,10 @@ ViewWidgetStack::ViewWidgetStack (QWidget *parent, const char *name)
void ViewWidgetStack::add_widget (LayoutView *w)
{
tl_assert (w->widget ());
m_widgets.push_back (w);
w->setParent (this);
w->widget ()->setParent (this);
resize_children ();
raise_widget (m_widgets.size () - 1);
@ -64,7 +66,7 @@ void ViewWidgetStack::raise_widget (size_t index)
{
if (index < m_widgets.size ()) {
mp_bglabel->hide ();
m_widgets [index]->show ();
m_widgets [index]->widget ()->show ();
} else {
mp_bglabel->show ();
}
@ -72,7 +74,7 @@ void ViewWidgetStack::raise_widget (size_t index)
size_t i = 0;
for (std::vector <LayoutView *>::iterator child = m_widgets.begin (); child != m_widgets.end (); ++child, ++i) {
if (i != index) {
(*child)->hide ();
(*child)->widget ()->hide ();
}
}
}
@ -95,7 +97,7 @@ void ViewWidgetStack::resize_children ()
{
// set the geometry of all children
for (std::vector <LayoutView *>::iterator child = m_widgets.begin (); child != m_widgets.end (); ++child) {
(*child)->setGeometry (0, 0, width (), height ());
(*child)->widget ()->setGeometry (0, 0, width (), height ());
}
mp_bglabel->setGeometry (0, 0, width (), height ());
}

View File

@ -299,22 +299,22 @@ static void clear_lower_hier_level (lay::LayerProperties *n)
n->set_source (s);
}
static lay::color_t get_eff_frame_color_1 (const lay::LayerProperties *n)
static tl::color_t get_eff_frame_color_1 (const lay::LayerProperties *n)
{
return n->eff_frame_color (true);
}
static lay::color_t get_eff_fill_color_1 (const lay::LayerProperties *n)
static tl::color_t get_eff_fill_color_1 (const lay::LayerProperties *n)
{
return n->eff_fill_color (true);
}
static lay::color_t get_frame_color_1 (const lay::LayerProperties *n)
static tl::color_t get_frame_color_1 (const lay::LayerProperties *n)
{
return n->frame_color (true);
}
static lay::color_t get_fill_color_1 (const lay::LayerProperties *n)
static tl::color_t get_fill_color_1 (const lay::LayerProperties *n)
{
return n->fill_color (true);
}

View File

@ -327,25 +327,25 @@ static void save_as2 (lay::LayoutViewBase *view, unsigned int index, const std::
view->save_as (index, filename, tl::OutputStream::OM_Auto, options, true, 0);
}
static lay::PixelBuffer get_pixels_with_options (lay::LayoutViewBase *view, unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, const db::DBox &target_box)
static tl::PixelBuffer get_pixels_with_options (lay::LayoutViewBase *view, unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, const db::DBox &target_box)
{
return view->get_pixels_with_options (width, height, linewidth, oversampling, resolution, lay::Color (), lay::Color (), lay::Color (), target_box);
return view->get_pixels_with_options (width, height, linewidth, oversampling, resolution, tl::Color (), tl::Color (), tl::Color (), target_box);
}
static lay::BitmapBuffer get_pixels_with_options_mono (lay::LayoutViewBase *view, unsigned int width, unsigned int height, int linewidth, const db::DBox &target_box)
static tl::BitmapBuffer get_pixels_with_options_mono (lay::LayoutViewBase *view, unsigned int width, unsigned int height, int linewidth, const db::DBox &target_box)
{
return view->get_pixels_with_options_mono (width, height, linewidth, lay::Color (), lay::Color (), lay::Color (), target_box);
return view->get_pixels_with_options_mono (width, height, linewidth, tl::Color (), tl::Color (), tl::Color (), target_box);
}
static void save_image_with_options (lay::LayoutViewBase *view, const std::string &fn, unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, const db::DBox &target_box, bool monochrome)
{
view->save_image_with_options (fn, width, height, linewidth, oversampling, resolution, lay::Color (), lay::Color (), lay::Color (), target_box, monochrome);
view->save_image_with_options (fn, width, height, linewidth, oversampling, resolution, tl::Color (), tl::Color (), tl::Color (), target_box, monochrome);
}
#if defined(HAVE_QTBINDINGS)
static QImage get_image_with_options (lay::LayoutViewBase *view, unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, const db::DBox &target_box, bool monochrome)
{
return view->get_image_with_options (width, height, linewidth, oversampling, resolution, lay::Color (), lay::Color (), lay::Color (), target_box, monochrome);
return view->get_image_with_options (width, height, linewidth, oversampling, resolution, tl::Color (), tl::Color (), tl::Color (), target_box, monochrome);
}
#endif
@ -360,49 +360,49 @@ get_config_names (lay::LayoutViewBase *view)
static void
send_key_press_event (lay::LayoutViewBase *view, unsigned int key, unsigned int buttons)
{
view->view_object_widget ()->send_key_press_event (key, buttons);
view->canvas ()->send_key_press_event (key, buttons);
}
static void
send_mouse_move_event (lay::LayoutViewBase *view, const db::DPoint &pt, unsigned int buttons)
{
view->view_object_widget ()->send_mouse_move_event (pt, buttons);
view->canvas ()->send_mouse_move_event (pt, buttons);
}
static void
send_leave_event (lay::LayoutViewBase *view)
{
view->view_object_widget ()->send_leave_event ();
view->canvas ()->send_leave_event ();
}
static void
send_enter_event (lay::LayoutViewBase *view)
{
view->view_object_widget ()->send_enter_event ();
view->canvas ()->send_enter_event ();
}
static void
send_mouse_press_event (lay::LayoutViewBase *view, const db::DPoint &pt, unsigned int buttons)
{
view->view_object_widget ()->send_mouse_press_event (pt, buttons);
view->canvas ()->send_mouse_press_event (pt, buttons);
}
static void
send_mouse_double_clicked_event (lay::LayoutViewBase *view, const db::DPoint &pt, unsigned int buttons)
{
view->view_object_widget ()->send_mouse_double_clicked_event (pt, buttons);
view->canvas ()->send_mouse_double_clicked_event (pt, buttons);
}
static void
send_mouse_release_event (lay::LayoutViewBase *view, const db::DPoint &pt, unsigned int buttons)
{
view->view_object_widget ()->send_mouse_release_event (pt, buttons);
view->canvas ()->send_mouse_release_event (pt, buttons);
}
static void
send_wheel_event (lay::LayoutViewBase *view, int delta, bool horizontal, const db::DPoint &pt, unsigned int buttons)
{
view->view_object_widget ()->send_wheel_event (delta, horizontal, pt, buttons);
view->canvas ()->send_wheel_event (delta, horizontal, pt, buttons);
}
namespace {
@ -461,6 +461,11 @@ static LayerPropertiesConstIteratorWrapper each_layer2 (lay::LayoutViewBase *vie
return LayerPropertiesConstIteratorWrapper (view->begin_layers (list_index));
}
static lay::AbstractMenu *menu (lay::LayoutViewBase *view)
{
return view->menu ();
}
#if defined(HAVE_QT)
LAYBASIC_PUBLIC Class<lay::LayoutViewBase> decl_LayoutViewBase (QT_EXTERNAL_BASE (QWidget) "lay", "LayoutViewBase",
#else
@ -771,7 +776,7 @@ LAYBASIC_PUBLIC Class<lay::LayoutViewBase> decl_LayoutViewBase (QT_EXTERNAL_BASE
"If a layout is shared between multiple cellviews (which may happen due to a clone of the layout view\n"
"for example), all cellviews are renamed.\n"
) +
gsi::method ("load_layout", static_cast<unsigned int (lay::LayoutViewBase::*) (const std::string &, const db::LoadLayoutOptions &, const std::string &, bool)> (&lay::LayoutViewBase::load_layout), gsi::arg ("filename"), gsi::arg ("options"), gsi::arg ("technology"), gsi::arg ("add_cellview"),
gsi::method ("load_layout", static_cast<unsigned int (lay::LayoutViewBase::*) (const std::string &, const db::LoadLayoutOptions &, const std::string &, bool)> (&lay::LayoutViewBase::load_layout), gsi::arg ("filename"), gsi::arg ("options"), gsi::arg ("technology"), gsi::arg ("add_cellview", true),
"@brief Loads a (new) file into the layout view with the given technology\n"
"\n"
"Loads the file given by the \"filename\" parameter and associates it with the given technology.\n"
@ -781,9 +786,9 @@ LAYBASIC_PUBLIC Class<lay::LayoutViewBase> decl_LayoutViewBase (QT_EXTERNAL_BASE
"\n"
"@return The index of the cellview loaded.\n"
"\n"
"This version has been introduced in version 0.22.\n"
"This version has been introduced in version 0.22. The 'add_cellview' argument has been made optional in version 0.28.\n"
) +
gsi::method ("load_layout", static_cast<unsigned int (lay::LayoutViewBase::*) (const std::string &, const db::LoadLayoutOptions &, bool)> (&lay::LayoutViewBase::load_layout), gsi::arg ("filename"), gsi::arg ("options"), gsi::arg ("add_cellview"),
gsi::method ("load_layout", static_cast<unsigned int (lay::LayoutViewBase::*) (const std::string &, const db::LoadLayoutOptions &, bool)> (&lay::LayoutViewBase::load_layout), gsi::arg ("filename"), gsi::arg ("options"), gsi::arg ("add_cellview", true),
"@brief Loads a (new) file into the layout view\n"
"\n"
"Loads the file given by the \"filename\" parameter.\n"
@ -793,9 +798,9 @@ LAYBASIC_PUBLIC Class<lay::LayoutViewBase> decl_LayoutViewBase (QT_EXTERNAL_BASE
"\n"
"@return The index of the cellview loaded.\n"
"\n"
"This method has been introduced in version 0.18.\n"
"This method has been introduced in version 0.18. The 'add_cellview' argument has been made optional in version 0.28.\n"
) +
gsi::method ("load_layout", static_cast<unsigned int (lay::LayoutViewBase::*) (const std::string &, const std::string &, bool)> (&lay::LayoutViewBase::load_layout), gsi::arg ("filename"), gsi::arg ("technology"), gsi::arg ("add_cellview"),
gsi::method ("load_layout", static_cast<unsigned int (lay::LayoutViewBase::*) (const std::string &, const std::string &, bool)> (&lay::LayoutViewBase::load_layout), gsi::arg ("filename"), gsi::arg ("technology"), gsi::arg ("add_cellview", true),
"@brief Loads a (new) file into the layout view with the given technology\n"
"\n"
"Loads the file given by the \"filename\" parameter and associates it with the given technology.\n"
@ -804,16 +809,16 @@ LAYBASIC_PUBLIC Class<lay::LayoutViewBase> decl_LayoutViewBase (QT_EXTERNAL_BASE
"\n"
"@return The index of the cellview loaded.\n"
"\n"
"This version has been introduced in version 0.22.\n"
"This version has been introduced in version 0.22. The 'add_cellview' argument has been made optional in version 0.28.\n"
) +
gsi::method ("load_layout", static_cast<unsigned int (lay::LayoutViewBase::*) (const std::string &filename, bool add_cellview)> (&lay::LayoutViewBase::load_layout), gsi::arg ("filename"), gsi::arg ("add_cellview"),
gsi::method ("load_layout", static_cast<unsigned int (lay::LayoutViewBase::*) (const std::string &filename, bool add_cellview)> (&lay::LayoutViewBase::load_layout), gsi::arg ("filename"), gsi::arg ("add_cellview", true),
"@brief Loads a (new) file into the layout view\n"
"\n"
"Loads the file given by the \"filename\" parameter.\n"
"The add_cellview param controls whether to create a new cellview (true)\n"
"or clear all cellviews before (false).\n"
"\n"
"@return The index of the cellview loaded.\n"
"@return The index of the cellview loaded. The 'add_cellview' argument has been made optional in version 0.28.\n"
) +
gsi::method ("active_cellview", static_cast<lay::CellViewRef (lay::LayoutViewBase::*) ()> (&lay::LayoutViewBase::active_cellview_ref),
"@brief Gets the active cellview (shown in hierarchy browser)\n"
@ -952,6 +957,50 @@ LAYBASIC_PUBLIC Class<lay::LayoutViewBase> decl_LayoutViewBase (QT_EXTERNAL_BASE
"\n"
"@param props The layer properties object to initialize."
) +
gsi::method ("switch_mode", static_cast<void (lay::LayoutViewBase::*) (const std::string &)> (&lay::LayoutViewBase::switch_mode),
"@brief Switches the mode.\n"
"\n"
"See \\mode_name about a method to get the name of the current mode and \\mode_names for a method "
"to retrieve all available mode names.\n"
"\n"
"This method has been introduced in version 0.28."
) +
gsi::method ("mode_name", &lay::LayoutViewBase::mode_name,
"@brief Gets the name of the current mode.\n"
"\n"
"See \\switch_mode about a method to change the mode and \\mode_names for a method "
"to retrieve all available mode names.\n"
"\n"
"This method has been introduced in version 0.28."
) +
gsi::method ("mode_names", &lay::LayoutViewBase::mode_names,
"@brief Gets the names of the available modes.\n"
"\n"
"This method allows asking the view for the available mode names for \\switch_mode and "
"for the value returned by \\mode.\n"
"\n"
"This method has been introduced in version 0.28."
) +
gsi::method_ext ("menu", &menu,
"@brief Gets the \\AbstractMenu associated with this view.\n"
"\n"
"In normal UI application mode this is the main window's view. For a detached view or in non-UI "
"applications this is the view's private menu.\n"
"\n"
"This method has been introduced in version 0.28."
) +
gsi::method ("call_menu", &lay::LayoutViewBase::menu_activated, gsi::arg ("symbol"),
"@brief Calls the menu item with the provided symbol.\n"
"To obtain all symbols, use \\menu_symbols.\n"
"\n"
"This method has been introduced in version 0.28."
) +
gsi::method ("menu_symbols", &lay::LayoutViewBase::menu_symbols,
"@brief Gets all available menu symbols.\n"
"NOTE: currently this method delivers a superset of all available symbols. Depending on the context, no all symbols may trigger actual functionality.\n"
"\n"
"This method has been introduced in version 0.28."
) +
gsi::method ("cancel", &lay::LayoutViewBase::cancel,
"@brief Cancels all edit operations\n"
"\n"
@ -1129,7 +1178,7 @@ LAYBASIC_PUBLIC Class<lay::LayoutViewBase> decl_LayoutViewBase (QT_EXTERNAL_BASE
"This method has been introduced in 0.23.10.\n"
) +
#endif
gsi::method ("get_screenshot_pixels", static_cast<lay::PixelBuffer (lay::LayoutViewBase::*) ()> (&lay::LayoutViewBase::get_screenshot_pb),
gsi::method ("get_screenshot_pixels", static_cast<tl::PixelBuffer (lay::LayoutViewBase::*) ()> (&lay::LayoutViewBase::get_screenshot_pb),
"@brief Gets a screenshot as a \\PixelBuffer\n"
"\n"
"Getting the image requires the drawing to be complete. Ideally, synchronous mode is switched on "
@ -1138,7 +1187,7 @@ LAYBASIC_PUBLIC Class<lay::LayoutViewBase> decl_LayoutViewBase (QT_EXTERNAL_BASE
"\n"
"This method has been introduced in 0.28.\n"
) +
gsi::method ("get_pixels", static_cast<lay::PixelBuffer (lay::LayoutViewBase::*) (unsigned int, unsigned int)> (&lay::LayoutViewBase::get_pixels), gsi::arg ("width"), gsi::arg ("height"),
gsi::method ("get_pixels", static_cast<tl::PixelBuffer (lay::LayoutViewBase::*) (unsigned int, unsigned int)> (&lay::LayoutViewBase::get_pixels), gsi::arg ("width"), gsi::arg ("height"),
"@brief Gets the layout image as a \\PixelBuffer\n"
"\n"
"@param width The width of the image to render in pixel.\n"

View File

@ -37,13 +37,13 @@ lay::DMarker *create_marker (lay::LayoutViewBase *view)
static
void reset_frame_color (lay::DMarker *marker)
{
marker->set_frame_color (lay::Color ());
marker->set_frame_color (tl::Color ());
}
static
void set_frame_color (lay::DMarker *marker, unsigned int color)
{
marker->set_frame_color (lay::Color (color));
marker->set_frame_color (tl::Color (color));
}
static
@ -61,13 +61,13 @@ bool has_frame_color (const lay::DMarker *marker)
static
void reset_color (lay::DMarker *marker)
{
marker->set_color (lay::Color ());
marker->set_color (tl::Color ());
}
static
void set_color (lay::DMarker *marker, unsigned int color)
{
marker->set_color (lay::Color (color));
marker->set_color (tl::Color (color));
}
static

View File

@ -20,8 +20,6 @@
*/
#if defined(HAVE_QT)
#include "gsiDecl.h"
#include "gsiSignals.h"
#include "layAbstractMenu.h"
@ -411,5 +409,3 @@ Class<ActionStub> decl_Action (decl_ActionBase, "lay", "Action",
);
}
#endif

View File

@ -48,7 +48,7 @@ class PluginBase
{
public:
PluginBase ()
: lay::Plugin (sp_dispatcher), lay::ViewService (sp_view ? sp_view->view_object_widget () : 0)
: lay::Plugin (sp_dispatcher), lay::ViewService (sp_view ? sp_view->canvas () : 0)
{
if (! s_in_create_plugin) {
throw tl::Exception (tl::to_string (tr ("A PluginBase object can only be created in the PluginFactory's create_plugin method")));
@ -57,21 +57,21 @@ public:
void grab_mouse ()
{
if (widget ()) {
widget ()->grab_mouse (this, false);
if (ui ()) {
ui ()->grab_mouse (this, false);
}
}
void ungrab_mouse ()
{
if (widget ()) {
widget ()->ungrab_mouse (this);
if (ui ()) {
ui ()->ungrab_mouse (this);
}
}
void set_cursor (int c)
{
if (widget ()) {
if (ui ()) {
lay::ViewService::set_cursor ((enum lay::Cursor::cursor_shape) c);
}
}

View File

@ -0,0 +1,46 @@
/*
KLayout Layout Viewer
Copyright (C) 2006-2022 Matthias Koefferlein
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "gsiDecl.h"
#include "rdb.h"
namespace gsi
{
#if defined(HAVE_QTBINDINGS)
ClassExt<rdb::Item> decl_RdbItem (
gsi::method ("image", &rdb::Item::image,
"@brief Gets the attached image as a QImage object\n"
"\n"
"This method has been added in version 0.28."
) +
gsi::method ("image=", static_cast<void (rdb::Item::*) (const QImage &)> (&rdb::Item::set_image),
"@brief Sets the attached image from a QImage object\n"
"\n"
"This method has been added in version 0.28."
)
);
#endif
}

View File

@ -0,0 +1,68 @@
/*
KLayout Layout Viewer
Copyright (C) 2006-2022 Matthias Koefferlein
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "gsiDecl.h"
#include "tlPixelBuffer.h"
#if defined(HAVE_QT)
# include <QColor>
#endif
namespace gsi
{
#if defined(HAVE_QT) && defined(HAVE_QTBINDINGS)
static void fill_with_qcolor (tl::PixelBuffer *pb, QColor c)
{
pb->fill (c.rgb ());
}
// NOTE: we add the Qt-Bindings-related methods of tl::PixelBuffer and tl::BitmapBuffer
// here instead of inside gsiDeclTl.
// Reasoning: by doing so, gsi and tl remain independent of the Qt binding library which
// is good for lean applications such as strmrun
ClassExt<tl::PixelBuffer> decl_PixelBuffer (
gsi::method_ext ("fill", &fill_with_qcolor, gsi::arg ("color"),
"@brief Fills the pixel buffer with the given QColor\n"
) +
gsi::method ("to_qimage", &tl::PixelBuffer::to_image_copy,
"@brief Converts the pixel buffer to a \\QImage object"
) +
gsi::method ("from_qimage", &tl::PixelBuffer::from_image, gsi::arg ("qimage"),
"@brief Creates a pixel buffer object from a QImage object\n"
)
);
ClassExt<tl::BitmapBuffer> decl_BitmapBuffer (
gsi::method ("to_qimage", &tl::BitmapBuffer::to_image_copy,
"@brief Converts the pixel buffer to a \\QImage object"
) +
gsi::method ("from_qimage", &tl::BitmapBuffer::from_image, gsi::arg ("qimage"),
"@brief Creates a pixel buffer object from a QImage object\n"
)
);
#endif
}

View File

@ -20,27 +20,28 @@
*/
#if defined(HAVE_QT)
#include "layAbstractMenu.h"
#include "layDispatcher.h"
#include "layPlugin.h"
#include "layUtils.h"
#include "tlExceptions.h"
#include "tlAssert.h"
#include "gtf.h"
#include "gsi.h"
#include <QAction>
#include <QActionGroup>
#include <QMenu>
#include <QMenuBar>
#include <QShortcutEvent>
#include <QToolBar>
#include <QToolButton>
#include <QApplication>
#include <QMessageBox>
#include <QHBoxLayout>
#include <QFrame>
#if defined(HAVE_QT)
# include <QAction>
# include <QActionGroup>
# include <QMenu>
# include <QMenuBar>
# include <QShortcutEvent>
# include <QToolBar>
# include <QToolButton>
# include <QApplication>
# include <QMessageBox>
# include <QHBoxLayout>
# include <QFrame>
#endif
#include <ctype.h>
@ -245,12 +246,14 @@ AbstractMenuItem::set_action (Action *a, bool copy_properties)
a->keep ();
#if defined(HAVE_QT)
if (copy_properties && mp_action->qaction () && a->qaction ()) {
a->qaction ()->setIcon (mp_action->qaction ()->icon ());
a->qaction ()->setToolTip (mp_action->qaction ()->toolTip ());
a->qaction ()->setShortcut (mp_action->qaction ()->shortcut ());
a->qaction ()->setIconText (mp_action->qaction ()->iconText ());
}
#endif
bool enabled = mp_action.get () ? mp_action->is_enabled () : true;
bool visible = mp_action.get () ? mp_action->is_visible () : true;
@ -261,9 +264,11 @@ AbstractMenuItem::set_action (Action *a, bool copy_properties)
mp_action->set_dispatcher (mp_dispatcher);
mp_action->set_object_name (m_basename);
#if defined(HAVE_QT)
if (mp_action->menu ()) {
mp_action->menu ()->setObjectName (tl::to_qstring (m_basename));
}
#endif
}
void
@ -289,30 +294,8 @@ AbstractMenuItem::set_remove_on_empty ()
static std::set<Action *> *sp_actionHandles = 0;
static void
configure_action_from_title (Action *ah, const std::string &s)
{
std::string title;
std::string shortcut;
std::string res;
std::string tool_tip;
parse_menu_title (s, title, shortcut, res, tool_tip);
ah->qaction ()->setText (tl::to_qstring (title));
if (! tool_tip.empty ()) {
ah->qaction ()->setToolTip (tl::to_qstring (tool_tip));
}
if (! res.empty ()) {
ah->qaction ()->setIcon (QIcon (tl::to_qstring (res)));
}
if (! shortcut.empty ()) {
ah->set_default_shortcut (shortcut);
}
}
#if defined(HAVE_QT)
namespace {
/**
* @brief A specialization that provides a way to catch ambiguous key shortcuts
@ -370,6 +353,8 @@ private:
size_t m_id;
};
}
static size_t
id_from_action (QAction *action)
{
@ -377,9 +362,17 @@ id_from_action (QAction *action)
return ao ? ao->id () : 0;
}
Action::Action ()
: mp_menu (0),
mp_action (new ActionObject (0)),
#endif
Action::Action () :
#if defined(HAVE_QT)
mp_menu (0),
mp_action (lay::has_gui () ? new ActionObject (0) : 0),
#endif
m_checked (false),
m_checkable (false),
m_enabled (true),
m_separator (false),
mp_dispatcher (0),
m_owned (true),
m_visible (true),
@ -391,14 +384,23 @@ Action::Action ()
}
sp_actionHandles->insert (this);
#if defined(HAVE_QT)
// catch the destroyed signal to tell if the QAction object is deleted.
connect (mp_action, SIGNAL (destroyed (QObject *)), this, SLOT (destroyed (QObject *)));
connect (mp_action, SIGNAL (triggered ()), this, SLOT (qaction_triggered ()));
if (mp_action) {
connect (mp_action, SIGNAL (destroyed (QObject *)), this, SLOT (destroyed (QObject *)));
connect (mp_action, SIGNAL (triggered ()), this, SLOT (qaction_triggered ()));
}
#endif
}
#if defined(HAVE_QT)
Action::Action (QAction *action, bool owned)
: mp_menu (0),
mp_action (action),
m_checked (false),
m_checkable (false),
m_enabled (true),
m_separator (false),
mp_dispatcher (0),
m_owned (owned),
m_visible (true),
@ -418,6 +420,10 @@ Action::Action (QAction *action, bool owned)
Action::Action (QMenu *menu, bool owned)
: mp_menu (menu),
mp_action (menu->menuAction ()),
m_checked (false),
m_checkable (false),
m_enabled (true),
m_separator (false),
mp_dispatcher (0),
m_owned (owned),
m_visible (true),
@ -433,10 +439,17 @@ Action::Action (QMenu *menu, bool owned)
connect (mp_menu, SIGNAL (destroyed (QObject *)), this, SLOT (destroyed (QObject *)));
connect (mp_action, SIGNAL (triggered ()), this, SLOT (qaction_triggered ()));
}
#endif
Action::Action (const std::string &title)
: mp_menu (0),
mp_action (new QAction (0)),
Action::Action (const std::string &title) :
#if defined(HAVE_QT)
mp_menu (0),
mp_action (lay::has_gui () ? new ActionObject (0) : 0),
#endif
m_checked (false),
m_checkable (false),
m_enabled (true),
m_separator (false),
mp_dispatcher (0),
m_owned (true),
m_visible (true),
@ -448,11 +461,15 @@ Action::Action (const std::string &title)
}
sp_actionHandles->insert (this);
configure_action_from_title (this, title);
configure_from_title (title);
#if defined(HAVE_QT)
// catch the destroyed signal to tell if the QAction object is deleted.
connect (mp_action, SIGNAL (destroyed (QObject *)), this, SLOT (destroyed (QObject *)));
connect (mp_action, SIGNAL (triggered ()), this, SLOT (qaction_triggered ()));
if (mp_action) {
connect (mp_action, SIGNAL (destroyed (QObject *)), this, SLOT (destroyed (QObject *)));
connect (mp_action, SIGNAL (triggered ()), this, SLOT (qaction_triggered ()));
}
#endif
}
Action::~Action ()
@ -465,6 +482,7 @@ Action::~Action ()
}
}
#if defined(HAVE_QT)
if (mp_menu) {
if (m_owned) {
delete mp_menu;
@ -479,19 +497,46 @@ Action::~Action ()
}
mp_action = 0;
}
#endif
}
void
Action::set_dispatcher (Dispatcher *dispatcher)
{
if (mp_dispatcher != dispatcher) {
#if defined(HAVE_QT)
if (mp_action && m_owned) {
mp_action->setParent (dispatcher ? dispatcher->menu_parent_widget () : 0);
}
#endif
mp_dispatcher = dispatcher;
}
}
void
Action::configure_from_title (const std::string &s)
{
std::string title;
std::string shortcut;
std::string res;
std::string tool_tip;
parse_menu_title (s, title, shortcut, res, tool_tip);
set_title (title);
if (! shortcut.empty ()) {
set_default_shortcut (shortcut);
}
if (! tool_tip.empty ()) {
set_tool_tip (tool_tip);
}
if (! res.empty ()) {
set_icon (res);
}
}
#if defined(HAVE_QT)
void
Action::qaction_triggered ()
{
@ -499,13 +544,18 @@ Action::qaction_triggered ()
triggered ();
END_PROTECTED
}
#endif
void
Action::trigger ()
{
#if defined(HAVE_QT)
if (qaction ()) {
qaction ()->trigger ();
}
#else
triggered ();
#endif
}
void
@ -514,6 +564,7 @@ Action::triggered ()
// .. no action yet, the reimplementation must provide some ..
}
#if defined(HAVE_QT)
QAction *
Action::qaction () const
{
@ -538,16 +589,19 @@ Action::destroyed (QObject *obj)
}
m_owned = false;
}
#endif
void
Action::set_visible (bool v)
{
if (m_visible != v) {
m_visible = v;
#if defined(HAVE_QT)
if (mp_action) {
mp_action->setVisible (is_effective_visible ());
mp_action->setShortcut (get_key_sequence ());
}
#endif
}
}
@ -556,10 +610,12 @@ Action::set_hidden (bool h)
{
if (m_hidden != h) {
m_hidden = h;
#if defined(HAVE_QT)
if (mp_action) {
mp_action->setVisible (is_effective_visible ());
mp_action->setShortcut (get_key_sequence ());
}
#endif
}
}
@ -586,10 +642,12 @@ Action::set_default_shortcut (const std::string &sc)
{
if (m_default_shortcut != sc) {
m_default_shortcut = sc;
#if defined(HAVE_QT)
m_default_key_sequence = QKeySequence (tl::to_qstring (sc));
if (mp_action) {
mp_action->setShortcut (get_key_sequence ());
}
#endif
}
}
@ -599,25 +657,28 @@ Action::set_shortcut (const std::string &sc)
if (m_shortcut != sc) {
m_shortcut = sc;
m_no_key_sequence = (sc == Action::no_shortcut ());
#if defined(HAVE_QT)
m_key_sequence = m_no_key_sequence ? QKeySequence () : QKeySequence (tl::to_qstring (m_shortcut));
if (mp_action) {
mp_action->setShortcut (get_key_sequence ());
}
#endif
}
}
std::string
Action::get_default_shortcut () const
{
return tl::to_string (m_default_key_sequence.toString ());
return m_default_shortcut;
}
std::string
Action::get_shortcut () const
{
return m_no_key_sequence ? Action::no_shortcut () : tl::to_string (m_key_sequence.toString ());
return m_no_key_sequence ? Action::no_shortcut () : m_shortcut;
}
#if defined(HAVE_QT)
QKeySequence
Action::get_key_sequence () const
{
@ -647,6 +708,7 @@ Action::get_key_sequence_for (const std::string &sc) const
return QKeySequence::fromString (tl::to_qstring (sc));
}
}
#endif
const std::string &
Action::no_shortcut ()
@ -658,100 +720,139 @@ Action::no_shortcut ()
void
Action::set_title (const std::string &t)
{
#if defined(HAVE_QT)
if (qaction ()) {
qaction ()->setText (tl::to_qstring (t));
}
#endif
m_title = t;
}
std::string
Action::get_title () const
{
if (qaction ()) {
return tl::to_string (qaction ()->text ());
} else {
return std::string ();
}
return m_title;
}
std::string
Action::get_effective_shortcut () const
{
return tl::to_string (get_key_sequence ().toString ());
if (m_hidden || m_no_key_sequence) {
// A hidden menu item does not have a key sequence too.
return std::string ();
} else if (m_shortcut.empty ()) {
return m_default_shortcut;
} else {
return m_shortcut;
}
}
std::string
Action::get_effective_shortcut_for (const std::string &sc) const
{
return tl::to_string (get_key_sequence_for (sc).toString ());
if (m_hidden) {
// A hidden menu item does not have a key sequence too.
return std::string ();
} else if (sc.empty ()) {
return m_default_shortcut;
} else if (sc == Action::no_shortcut ()) {
return std::string ();
} else {
return sc;
}
}
void
Action::add_to_exclusive_group (lay::AbstractMenu *menu, const std::string &group_name)
{
// NOTE: this feature does not work without Qt
#if defined(HAVE_QT)
if (qaction ()) {
menu->make_exclusive_group (group_name)->addAction (qaction ());
}
#endif
}
bool
Action::is_checkable () const
{
return qaction () && qaction ()->isCheckable ();
return m_checkable;
}
bool
Action::is_checked () const
{
return qaction () && qaction ()->isChecked ();
#if defined(HAVE_QT)
return qaction () ? qaction ()->isChecked () : m_checked;
#else
return m_checked;
#endif
}
bool
Action::is_enabled () const
{
return qaction () && qaction ()->isEnabled ();
#if defined(HAVE_QT)
return qaction () ? qaction ()->isEnabled () : m_enabled;
#else
return m_enabled;
#endif
}
bool
Action::is_separator () const
{
return qaction () && qaction ()->isSeparator ();
return m_separator;
}
void
Action::set_enabled (bool b)
{
#if defined(HAVE_QT)
if (qaction ()) {
qaction ()->setEnabled (b);
}
#endif
m_enabled = b;
}
void
Action::set_checked (bool c)
{
#if defined(HAVE_QT)
if (qaction ()) {
qaction ()->setChecked (c);
}
#endif
m_checked = c;
}
void
Action::set_checkable (bool c)
{
#if defined(HAVE_QT)
if (qaction ()) {
qaction ()->setCheckable (c);
}
#endif
m_checkable = c;
}
void
Action::set_separator (bool s)
{
#if defined(HAVE_QT)
if (qaction ()) {
qaction ()->setSeparator (s);
}
#endif
m_separator = s;
}
void
Action::set_icon (const std::string &filename)
{
#if defined(HAVE_QT)
if (qaction ()) {
if (filename.empty ()) {
qaction ()->setIcon (QIcon ());
@ -759,21 +860,20 @@ Action::set_icon (const std::string &filename)
qaction ()->setIcon (QIcon (tl::to_qstring (filename)));
}
}
#endif
m_icon = filename;
}
std::string
Action::get_tool_tip () const
{
if (qaction ()) {
return tl::to_string (qaction ()->toolTip ());
} else {
return std::string ();
}
return m_tooltip;
}
void
Action::set_tool_tip (const std::string &text)
{
#if defined(HAVE_QT)
if (qaction ()) {
if (text.empty ()) {
qaction ()->setToolTip (QString ());
@ -781,21 +881,20 @@ Action::set_tool_tip (const std::string &text)
qaction ()->setToolTip (tl::to_qstring (text));
}
}
#endif
m_tooltip = text;
}
std::string
Action::get_icon_text () const
{
if (qaction ()) {
return tl::to_string (qaction ()->iconText ());
} else {
return std::string ();
}
return m_icontext;
}
void
Action::set_icon_text (const std::string &icon_text)
{
#if defined(HAVE_QT)
if (qaction ()) {
if (icon_text.empty ()) {
qaction ()->setIconText (QString ());
@ -803,14 +902,18 @@ Action::set_icon_text (const std::string &icon_text)
qaction ()->setIconText (tl::to_qstring (icon_text));
}
}
#endif
m_icontext = icon_text;
}
void
Action::set_object_name (const std::string &name)
{
#if defined(HAVE_QT)
if (qaction ()) {
qaction ()->setObjectName (tl::to_qstring (name));
}
#endif
}
// ---------------------------------------------------------------
@ -895,6 +998,7 @@ AbstractMenu::~AbstractMenu ()
// .. nothing yet ..
}
#if defined(HAVE_QT)
QActionGroup *
AbstractMenu::make_exclusive_group (const std::string &name)
{
@ -1195,6 +1299,7 @@ AbstractMenu::menu (const std::string &path)
return 0;
}
}
#endif
bool
AbstractMenu::is_valid (const std::string &path) const
@ -1645,7 +1750,9 @@ void
AbstractMenu::emit_changed ()
{
m_config_actions_valid = false;
#if defined(HAVE_QT)
emit changed ();
#endif
}
std::vector<ConfigureAction *> AbstractMenu::configure_actions (const std::string &name)
@ -1703,5 +1810,3 @@ AbstractMenu::get_shortcuts (const std::string &root, std::map<std::string, std:
}
}
#endif

View File

@ -20,16 +20,16 @@
*/
#if defined(HAVE_QT)
#ifndef HDR_layAbstractMenu
#define HDR_layAbstractMenu
#include <QKeySequence>
#include <QShortcut>
#include <QAction>
#include <QMenu>
#include <QObject>
#if defined(HAVE_QT)
# include <QKeySequence>
# include <QShortcut>
# include <QAction>
# include <QMenu>
# include <QObject>
#endif
#include <string>
#include <set>
@ -43,10 +43,12 @@
#include "tlObject.h"
#include "laybasicCommon.h"
#if defined(HAVE_QT)
class QFrame;
class QMenuBar;
class QToolBar;
class QMenu;
#endif
namespace lay
{
@ -85,12 +87,16 @@ LAYBASIC_PUBLIC std::string pack_menu_items_hidden (const std::vector<std::pair<
*
* This object is typically owned by the AbstractMenu and cannot be copied or assigned.
*/
class LAYBASIC_PUBLIC Action
: public QObject,
class LAYBASIC_PUBLIC Action :
#if defined(HAVE_QT)
public QObject,
#endif
public tl::Object,
public gsi::ObjectBase
{
#if defined(HAVE_QT)
Q_OBJECT
#endif
public:
/**
@ -98,6 +104,7 @@ public:
*/
Action ();
#if defined(HAVE_QT)
/**
* @brief Creates an action from the given QAction
* If "owned" is true, the QAction will become owned by the Action object.
@ -109,6 +116,7 @@ public:
* If "owned" is true, the QAction will become owned by the Action object.
*/
Action (QMenu *menu, bool owned = true);
#endif
/**
* @brief Creates an action with the given title (icon, keyboard shortcut)
@ -310,6 +318,7 @@ public:
return false;
}
#if defined(HAVE_QT)
/**
* @brief Get the underlying QAction object
*
@ -321,6 +330,7 @@ public:
* @brief Gets the QMenu object if the action is a menu action
*/
QMenu *menu () const;
#endif
/**
* @brief Gets the dispatcher object this action is connected to
@ -330,29 +340,47 @@ public:
return mp_dispatcher;
}
#if defined(HAVE_QT)
protected slots:
void destroyed (QObject *obj);
void qaction_triggered ();
#endif
private:
friend struct AbstractMenuItem;
#if defined(HAVE_QT)
QMenu *mp_menu;
QAction *mp_action;
#endif
std::string m_title;
std::string m_icon;
std::string m_icontext;
std::string m_tooltip;
bool m_checked;
bool m_checkable;
bool m_enabled;
bool m_separator;
lay::Dispatcher *mp_dispatcher;
bool m_owned;
bool m_visible;
bool m_hidden;
std::string m_default_shortcut;
QKeySequence m_default_key_sequence;
std::string m_shortcut;
std::string m_symbol;
#if defined(HAVE_QT)
QKeySequence m_default_key_sequence;
QKeySequence m_key_sequence;
#endif
bool m_no_key_sequence;
void set_dispatcher (Dispatcher *dispatcher);
#if defined(HAVE_QT)
QKeySequence get_key_sequence () const;
QKeySequence get_key_sequence_for (const std::string &sc) const;
#endif
void configure_from_title (const std::string &s);
// no copying
Action (const Action &);
@ -501,10 +529,12 @@ struct LAYBASIC_PUBLIC AbstractMenuItem
return mp_action.get ();
}
#if defined(HAVE_QT)
QMenu *menu ()
{
return mp_action->menu ();
}
#endif
void set_has_submenu ();
@ -575,11 +605,15 @@ private:
* QMenu's created so far (except the detached menus), clear the QMenuBar, recreate the QMenu objects (note, that the
* addresses will change this way!) and refill the QToolBar and QMenuBar.
*/
class LAYBASIC_PUBLIC AbstractMenu
: public QObject,
class LAYBASIC_PUBLIC AbstractMenu :
#if defined(HAVE_QT)
public QObject,
#endif
public gsi::ObjectBase
{
#if defined(HAVE_QT)
Q_OBJECT
#endif
public:
/**
@ -592,6 +626,7 @@ public:
*/
~AbstractMenu ();
#if defined(HAVE_QT)
/**
* @brief Rebuild the QMenu's and refill the QMenuBar object
*/
@ -616,6 +651,29 @@ public:
*/
QMenu *menu (const std::string &path);
/**
* @brief Get the detached menu
*
* This will return a QMenu pointer to a detached menu that is created
* with a "@.." top level entry. In any case, a valid QMenu object is returned
* which never changes, even if the menu hierarchy is rebuilt. The QMenu returned
* may be empty.
*
* @param name The name of the detached menu, without the "@"
* @return a valid QMenu object
*/
QMenu *detached_menu (const std::string &name);
/**
* @brief Creates a new exclusive action group
*
* If a group with that name already exists, this method does nothing.
*
* @return The QActionGroup object of that group
*/
QActionGroup *make_exclusive_group (const std::string &name);
#endif
/**
* @brief Get the Action object for a given item
*
@ -752,28 +810,6 @@ public:
*/
std::vector<lay::ConfigureAction *> configure_actions (const std::string &name);
/**
* @brief Get the detached menu
*
* This will return a QMenu pointer to a detached menu that is created
* with a "@.." top level entry. In any case, a valid QMenu object is returned
* which never changes, even if the menu hierarchy is rebuilt. The QMenu returned
* may be empty.
*
* @param name The name of the detached menu, without the "@"
* @return a valid QMenu object
*/
QMenu *detached_menu (const std::string &name);
/**
* @brief Creates a new exclusive action group
*
* If a group with that name already exists, this method does nothing.
*
* @return The QActionGroup object of that group
*/
QActionGroup *make_exclusive_group (const std::string &name);
/**
* @brief Gets the keyboard shortcuts
* @param with_defaults Returns the default shortcuts if true. Otherwise returns the effective shortcut.
@ -794,11 +830,13 @@ public:
return m_root;
}
#if defined(HAVE_QT)
signals:
/**
* @brief this signal is emitted whenever something changes on the menu
*/
void changed ();
#endif
private:
friend class Action;
@ -806,8 +844,10 @@ private:
std::vector<std::pair<AbstractMenuItem *, std::list<AbstractMenuItem>::iterator> > find_item (tl::Extractor &extr);
const AbstractMenuItem *find_item_exact (const std::string &path) const;
AbstractMenuItem *find_item_exact (const std::string &path);
#if defined(HAVE_QT)
void build (QMenu *menu, std::list<AbstractMenuItem> &items);
void build (QToolBar *tbar, std::list<AbstractMenuItem> &items);
#endif
void collect_group (std::vector<std::string> &grp, const std::string &name, const AbstractMenuItem &item) const;
void collect_configure_actions (std::vector<ConfigureAction *> &ca, AbstractMenuItem &item);
void emit_changed ();
@ -815,8 +855,10 @@ private:
Dispatcher *mp_dispatcher;
AbstractMenuItem m_root;
#if defined(HAVE_QT)
tl::stable_vector<QMenu> m_helper_menu_items;
std::map<std::string, QActionGroup *> m_action_groups;
#endif
std::map<std::string, std::vector<ConfigureAction *> > m_config_action_by_name;
bool m_config_actions_valid;
};
@ -824,5 +866,3 @@ private:
}
#endif
#endif // defined(HAVE_QT)

View File

@ -25,7 +25,7 @@
#include "layBitmap.h"
#include "layDitherPattern.h"
#include "layLineStyles.h"
#include "layPixelBuffer.h"
#include "tlPixelBuffer.h"
#include "tlTimer.h"
#include "tlAssert.h"
#include "tlThreads.h"
@ -426,7 +426,7 @@ bitmaps_to_image (const std::vector<lay::ViewOp> &view_ops_in,
const std::vector<lay::Bitmap *> &pbitmaps_in,
const lay::DitherPattern &dp,
const lay::LineStyles &ls,
PixelBuffer *pimage, unsigned int width, unsigned int height,
tl::PixelBuffer *pimage, unsigned int width, unsigned int height,
bool use_bitmap_index,
tl::Mutex *mutex)
{
@ -462,7 +462,7 @@ bitmaps_to_image (const std::vector<lay::ViewOp> &view_ops_in,
std::vector<lay::ViewOp> view_ops;
std::vector<const lay::Bitmap *> pbitmaps;
std::vector<std::pair <lay::color_t, lay::color_t> > masks;
std::vector<std::pair <tl::color_t, tl::color_t> > masks;
std::vector<uint32_t> non_empty_sls;
view_ops.reserve (n_in);
@ -588,13 +588,13 @@ bitmaps_to_image (const std::vector<lay::ViewOp> &view_ops_in,
if (masks.size () > 0) {
lay::color_t *pt = (lay::color_t *) pimage->scan_line (height - 1 - y);
tl::color_t *pt = (tl::color_t *) pimage->scan_line (height - 1 - y);
uint32_t *dptr_end = dptr;
unsigned int i = 0;
for (unsigned int x = 0; x < width; x += 32, ++i) {
lay::color_t y[32];
tl::color_t y[32];
if (transparent) {
for (int i = 0; i < 32; ++i) {
y[i] = 0;
@ -605,7 +605,7 @@ bitmaps_to_image (const std::vector<lay::ViewOp> &view_ops_in,
}
};
lay::color_t z[32] = {
tl::color_t z[32] = {
lay::wordones, lay::wordones, lay::wordones, lay::wordones,
lay::wordones, lay::wordones, lay::wordones, lay::wordones,
lay::wordones, lay::wordones, lay::wordones, lay::wordones,
@ -666,7 +666,7 @@ bitmaps_to_image (const std::vector<lay::ViewOp> &view_ops_in,
const std::vector<lay::Bitmap *> &pbitmaps_in,
const lay::DitherPattern &dp,
const lay::LineStyles &ls,
lay::BitmapBuffer *pimage, unsigned int width, unsigned int height,
tl::BitmapBuffer *pimage, unsigned int width, unsigned int height,
bool use_bitmap_index,
tl::Mutex *mutex)
{
@ -700,7 +700,7 @@ bitmaps_to_image (const std::vector<lay::ViewOp> &view_ops_in,
std::vector<lay::ViewOp> view_ops;
std::vector<const lay::Bitmap *> pbitmaps;
std::vector<std::pair <lay::color_t, lay::color_t> > masks;
std::vector<std::pair <tl::color_t, tl::color_t> > masks;
std::vector<uint32_t> non_empty_sls;
view_ops.reserve (n_in);
@ -825,7 +825,7 @@ bitmaps_to_image (const std::vector<lay::ViewOp> &view_ops_in,
if (masks.size () > 0) {
lay::color_t *pt = (lay::color_t *) pimage->scan_line (height - 1 - y);
tl::color_t *pt = (tl::color_t *) pimage->scan_line (height - 1 - y);
uint32_t *dptr_end = dptr;
unsigned int i = 0;

View File

@ -29,14 +29,18 @@
#include <vector>
namespace tl
{
class PixelBuffer;
class BitmapBuffer;
}
namespace lay
{
class DitherPattern;
class LineStyles;
class Bitmap;
class PixelBuffer;
class BitmapBuffer;
/**
* @brief This function converts the given set of bitmaps to a PixelBuffer
@ -58,7 +62,7 @@ bitmaps_to_image (const std::vector <lay::ViewOp> &view_ops,
const std::vector <lay::Bitmap *> &pbitmaps,
const lay::DitherPattern &dp,
const lay::LineStyles &ls,
lay::PixelBuffer *pimage, unsigned int width, unsigned int height,
tl::PixelBuffer *pimage, unsigned int width, unsigned int height,
bool use_bitmap_index,
tl::Mutex *mutex);
@ -72,12 +76,12 @@ bitmaps_to_image (const std::vector <lay::ViewOp> &view_ops,
const std::vector <lay::Bitmap *> &pbitmaps,
const lay::DitherPattern &dp,
const lay::LineStyles &ls,
lay::BitmapBuffer *pimage, unsigned int width, unsigned int height,
tl::BitmapBuffer *pimage, unsigned int width, unsigned int height,
bool use_bitmap_index,
tl::Mutex *mutex);
/**
* @brief Convert a lay::Bitmap to a unsigned char * data field to be passed to lay::BitmapBuffer
* @brief Convert a lay::Bitmap to a unsigned char * data field to be passed to tl::BitmapBuffer
*
* This function converts the bitmap given the view_op into a raw byte data
* field that can be passed to a QBitmap constructor. The data field is not

View File

@ -87,7 +87,7 @@ ColorPalette::ColorPalette ()
// .. nothing yet ..
}
ColorPalette::ColorPalette (const std::vector<lay::color_t> &colors, const std::vector<unsigned int> &luminous_colors)
ColorPalette::ColorPalette (const std::vector<tl::color_t> &colors, const std::vector<unsigned int> &luminous_colors)
: m_colors (colors), m_luminous_color_indices (luminous_colors)
{
// .. nothing yet ..
@ -115,7 +115,7 @@ ColorPalette::operator== (const ColorPalette &d) const
return m_colors == d.m_colors && m_luminous_color_indices == d.m_luminous_color_indices;
}
lay::color_t
tl::color_t
ColorPalette::color_by_index (unsigned int n) const
{
return m_colors [n % colors ()];
@ -140,7 +140,7 @@ ColorPalette::luminous_colors () const
}
void
ColorPalette::set_color (unsigned int n, lay::color_t c)
ColorPalette::set_color (unsigned int n, tl::color_t c)
{
while (m_colors.size () <= n) {
m_colors.push_back (0);
@ -180,7 +180,7 @@ ColorPalette::to_string () const
res += " ";
}
lay::color_t c = m_colors [i];
tl::color_t c = m_colors [i];
res += tl::sprintf ("%d,%d,%d", (c >> 16) & 0xff, (c >> 8) & 0xff, c & 0xff);
for (unsigned int j = 0; j < m_luminous_color_indices.size (); ++j) {
@ -217,7 +217,7 @@ ColorPalette::from_string (const std::string &s, bool simple)
}
x.expect (",").read (g).expect (",").read (b);
m_colors.push_back (0xff000000 | (lay::color_t (r & 0xff) << 16) | (lay::color_t (g & 0xff) << 8) | lay::color_t (b & 0xff));
m_colors.push_back (0xff000000 | (tl::color_t (r & 0xff) << 16) | (tl::color_t (g & 0xff) << 8) | tl::color_t (b & 0xff));
if (x.test ("[")) {
x.read (lc).expect ("]");

View File

@ -51,7 +51,7 @@ public:
* @param color The colors as a vector
* @param luminous_colors The list of indices of luminous colors as a vector
*/
ColorPalette (const std::vector<lay::color_t> &colors, const std::vector<unsigned int> &luminous_colors);
ColorPalette (const std::vector<tl::color_t> &colors, const std::vector<unsigned int> &luminous_colors);
/**
* @brief Copy constructor
@ -79,7 +79,7 @@ public:
/**
* @brief Change a specific color
*/
void set_color (unsigned int n, lay::color_t c);
void set_color (unsigned int n, tl::color_t c);
/**
* @brief Clear the colors list
@ -99,7 +99,7 @@ public:
/**
* @brief Retrieve the color by index
*/
lay::color_t color_by_index (unsigned int n) const;
tl::color_t color_by_index (unsigned int n) const;
/**
* @brief Retrieve the number of colors in the palette
@ -111,7 +111,7 @@ public:
/**
* @brief Retrieve the luminous color by index
*/
lay::color_t
tl::color_t
luminous_color_by_index (unsigned int n) const
{
return color_by_index (luminous_color_index_by_index (n));
@ -157,7 +157,7 @@ public:
static ColorPalette default_palette ();
private:
std::vector <lay::color_t> m_colors;
std::vector <tl::color_t> m_colors;
std::vector <unsigned int> m_luminous_color_indices;
};

View File

@ -44,7 +44,7 @@ ColorConverter::to_string (const QColor &c) const
#endif
std::string
ColorConverter::to_string (const lay::Color &c) const
ColorConverter::to_string (const tl::Color &c) const
{
if (! c.is_valid ()) {
return "auto";
@ -67,13 +67,13 @@ ColorConverter::from_string (const std::string &s, QColor &c) const
#endif
void
ColorConverter::from_string (const std::string &s, lay::Color &c) const
ColorConverter::from_string (const std::string &s, tl::Color &c) const
{
std::string t (tl::trim (s));
if (t == "auto") {
c = lay::Color ();
c = tl::Color ();
} else {
c = lay::Color (t);
c = tl::Color (t);
}
}

View File

@ -25,7 +25,7 @@
#define HDR_layConverters
#include "laybasicCommon.h"
#include "layColor.h"
#include "tlColor.h"
#if defined(HAVE_QT)
# include <QColor>
@ -43,8 +43,8 @@ struct LAYBASIC_PUBLIC ColorConverter
std::string to_string (const QColor &c) const;
void from_string (const std::string &s, QColor &c) const;
#endif
std::string to_string (const lay::Color &c) const;
void from_string (const std::string &s, lay::Color &c) const;
std::string to_string (const tl::Color &c) const;
void from_string (const std::string &s, tl::Color &c) const;
};
}

View File

@ -22,6 +22,7 @@
#include "layDispatcher.h"
#include "layAbstractMenu.h"
#include "tlXMLParser.h"
#include "tlXMLWriter.h"
@ -69,25 +70,23 @@ Dispatcher::~Dispatcher ()
void Dispatcher::set_menu_parent_widget (QWidget *menu_parent_widget)
{
mp_menu_parent_widget = menu_parent_widget;
if (mp_menu_parent_widget) {
mp_menu.reset (new lay::AbstractMenu (this));
} else {
mp_menu.reset (0);
}
}
#endif
void Dispatcher::make_menu ()
{
mp_menu.reset (new lay::AbstractMenu (this));
}
bool
Dispatcher::configure (const std::string &name, const std::string &value)
{
#if defined(HAVE_QT)
if (mp_menu) {
std::vector<lay::ConfigureAction *> ca = mp_menu->configure_actions (name);
for (std::vector<lay::ConfigureAction *>::const_iterator a = ca.begin (); a != ca.end (); ++a) {
(*a)->configure (value);
}
}
#endif
if (mp_delegate) {
return mp_delegate->configure (name, value);

View File

@ -222,6 +222,20 @@ public:
*/
bool has_ui () { return menu_parent_widget () != 0; }
#else
/**
* @brief Returns true, if the dispatcher supplies a user interface
*/
bool has_ui () { return false; }
#endif
/**
* @brief Creates the menu object
*
* This method will only have an effect on the root dispatcher.
*/
void make_menu ();
/**
* @brief Gets the AbstractMenu object
*
@ -231,14 +245,6 @@ public:
{
return (dispatcher () == this) ? mp_menu.get () : dispatcher ()->menu ();
}
#else
/**
* @brief Returns true, if the dispatcher supplies a user interface
*/
bool has_ui () { return false; }
#endif
protected:
// capture the configuration events so we can change the value of the configuration actions
@ -249,8 +255,8 @@ private:
Dispatcher (const Dispatcher &);
Dispatcher &operator= (const Dispatcher &);
#if defined(HAVE_QT)
std::unique_ptr<lay::AbstractMenu> mp_menu;
#if defined(HAVE_QT)
QWidget *mp_menu_parent_widget;
#endif
DispatcherDelegate *mp_delegate;

View File

@ -121,7 +121,7 @@ public:
/**
* @brief Get the current appearance
*/
virtual std::vector <lay::ViewOp> get_view_ops (lay::RedrawThreadCanvas &canvas, lay::Color background, lay::Color foreground, lay::Color active) const = 0;
virtual std::vector <lay::ViewOp> get_view_ops (lay::RedrawThreadCanvas &canvas, tl::Color background, tl::Color foreground, tl::Color active) const = 0;
private:
unsigned int m_num_planes;

View File

@ -57,13 +57,13 @@ class TrackingCursorBase
: public lay::ViewObject
{
public:
TrackingCursorBase (lay::EditorServiceBase *service, lay::ViewObjectWidget *widget)
TrackingCursorBase (lay::EditorServiceBase *service, lay::ViewObjectUI *widget)
: lay::ViewObject (widget, false), mp_service (service)
{ }
uint32_t cursor_color (lay::ViewObjectCanvas &canvas) const
{
lay::Color color;
tl::Color color;
if (mp_service) {
color = mp_service->tracking_cursor_color ();
}
@ -91,7 +91,7 @@ class MouseCursorViewObject
: public TrackingCursorBase
{
public:
MouseCursorViewObject (lay::EditorServiceBase *service, lay::ViewObjectWidget *widget, const db::DPoint &pt, bool solid)
MouseCursorViewObject (lay::EditorServiceBase *service, lay::ViewObjectUI *widget, const db::DPoint &pt, bool solid)
: TrackingCursorBase (service, widget), m_pt (pt), m_solid (solid)
{ }
@ -139,7 +139,7 @@ class EdgeMarkerViewObject
: public TrackingCursorBase
{
public:
EdgeMarkerViewObject (lay::EditorServiceBase *service, lay::ViewObjectWidget *widget, const db::DEdge &edge, bool solid)
EdgeMarkerViewObject (lay::EditorServiceBase *service, lay::ViewObjectUI *widget, const db::DEdge &edge, bool solid)
: TrackingCursorBase (service, widget), m_edge (edge), m_solid (solid)
{ }
@ -207,7 +207,7 @@ private:
// --------------------------------------------------------------------------------------
EditorServiceBase::EditorServiceBase (LayoutViewBase *view)
: lay::ViewService (view->view_object_widget ()),
: lay::ViewService (view->canvas ()),
lay::Editable (view),
lay::Plugin (view),
m_cursor_enabled (true),
@ -226,13 +226,13 @@ EditorServiceBase::add_mouse_cursor (const db::DPoint &pt, bool emphasize)
{
m_has_tracking_position = true;
m_tracking_position = pt;
m_mouse_cursor_markers.push_back (new MouseCursorViewObject (this, widget (), pt, emphasize));
m_mouse_cursor_markers.push_back (new MouseCursorViewObject (this, ui (), pt, emphasize));
}
void
EditorServiceBase::add_edge_marker (const db::DEdge &e, bool emphasize)
{
m_mouse_cursor_markers.push_back (new EdgeMarkerViewObject (this, widget (), e, emphasize));
m_mouse_cursor_markers.push_back (new EdgeMarkerViewObject (this, ui (), e, emphasize));
}
void
@ -267,7 +267,7 @@ EditorServiceBase::configure (const std::string &name, const std::string &value)
if (name == cfg_tracking_cursor_color) {
lay::Color color;
tl::Color color;
lay::ColorConverter ().from_string (value, color);
if (color != m_cursor_color) {
@ -307,7 +307,7 @@ EditorServiceBase::show_error (tl::Exception &ex)
{
tl::error << ex.msg ();
#if defined(HAVE_QT)
QMessageBox::critical (widget (), tr ("Error"), tl::to_qstring (ex.msg ()));
QMessageBox::critical (ui ()->widget (), tr ("Error"), tl::to_qstring (ex.msg ()));
#endif
}

View File

@ -92,7 +92,7 @@ public:
/**
* @brief Gets the tracking cursor color
*/
lay::Color tracking_cursor_color () const
tl::Color tracking_cursor_color () const
{
return m_cursor_color;
}
@ -133,7 +133,7 @@ protected:
private:
// The marker representing the mouse cursor
std::vector<lay::ViewObject *> m_mouse_cursor_markers;
lay::Color m_cursor_color;
tl::Color m_cursor_color;
bool m_cursor_enabled;
bool m_has_tracking_position;
db::DPoint m_tracking_position;

View File

@ -48,8 +48,8 @@ namespace lay
* All channels are scaled the same way in order not to change the
* color but the brightness alone.
*/
color_t
LayerProperties::brighter (color_t in, int x)
tl::color_t
LayerProperties::brighter (tl::color_t in, int x)
{
// shortcut for no correction
if (x == 0) {
@ -248,25 +248,25 @@ LayerProperties::is_visual () const
return valid (true) && visible (true) && (layer_index () >= 0 || is_cell_box_layer ());
}
color_t
tl::color_t
LayerProperties::eff_frame_color (bool real) const
{
return brighter (frame_color (real) & 0xffffff, frame_brightness (real));
}
color_t
tl::color_t
LayerProperties::eff_fill_color (bool real) const
{
return brighter (fill_color (real) & 0xffffff, fill_brightness (real));
}
color_t
tl::color_t
LayerProperties::eff_frame_color_brighter (bool real, int plus_brightness) const
{
return brighter (frame_color (real) & 0xffffff, frame_brightness (real) + plus_brightness);
}
color_t
tl::color_t
LayerProperties::eff_fill_color_brighter (bool real, int plus_brightness) const
{
return brighter (fill_color (real) & 0xffffff, fill_brightness (real) + plus_brightness);
@ -1645,21 +1645,21 @@ LayerPropertiesList::back () const
struct UIntColorConverter
: private ColorConverter
{
std::string to_string (const color_t &c) const
std::string to_string (const tl::color_t &c) const
{
if (c == 0) {
return "";
} else {
return ColorConverter::to_string (lay::Color (c | 0xff000000));
return ColorConverter::to_string (tl::Color (c | 0xff000000));
}
}
void from_string (const std::string &s, color_t &c) const
void from_string (const std::string &s, tl::color_t &c) const
{
if (s.empty ()) {
c = 0;
} else {
lay::Color qc;
tl::Color qc;
ColorConverter::from_string (s, qc);
c = qc.rgb () | 0xff000000;
}
@ -1767,8 +1767,8 @@ struct LineStyleIndexConverter
static const tl::XMLElementList layer_element = tl::XMLElementList (
// HINT: these make_member calls want to be qualified: otherwise an internal error
// was observed ..
tl::make_member<lay::color_t, LayerPropertiesNode> (&LayerPropertiesNode::frame_color_loc, &LayerPropertiesNode::set_frame_color_code, "frame-color", UIntColorConverter ()) +
tl::make_member<lay::color_t, LayerPropertiesNode> (&LayerPropertiesNode::fill_color_loc, &LayerPropertiesNode::set_fill_color_code, "fill-color", UIntColorConverter ()) +
tl::make_member<tl::color_t, LayerPropertiesNode> (&LayerPropertiesNode::frame_color_loc, &LayerPropertiesNode::set_frame_color_code, "frame-color", UIntColorConverter ()) +
tl::make_member<tl::color_t, LayerPropertiesNode> (&LayerPropertiesNode::fill_color_loc, &LayerPropertiesNode::set_fill_color_code, "fill-color", UIntColorConverter ()) +
tl::make_member<int, LayerPropertiesNode> (&LayerPropertiesNode::frame_brightness_loc, &LayerPropertiesNode::set_frame_brightness, "frame-brightness") +
tl::make_member<int, LayerPropertiesNode> (&LayerPropertiesNode::fill_brightness_loc, &LayerPropertiesNode::set_fill_brightness, "fill-brightness") +
tl::make_member<int, LayerPropertiesNode> (&LayerPropertiesNode::dither_pattern_loc, &LayerPropertiesNode::set_dither_pattern, "dither-pattern", DitherPatternIndexConverter ()) +

View File

@ -137,7 +137,7 @@ public:
/**
* @brief Utility: compute the effective color from a color with brightness correction
*/
static color_t brighter (color_t in, int b);
static tl::color_t brighter (tl::color_t in, int b);
/**
* @brief render the effective frame color
@ -145,7 +145,7 @@ public:
* The effective frame color is computed from the frame color brightness and the
* frame color.
*/
color_t eff_frame_color (bool real) const;
tl::color_t eff_frame_color (bool real) const;
/**
* @brief render the effective fill color
@ -153,7 +153,7 @@ public:
* The effective fill color is computed from the frame color brightness and the
* frame color.
*/
color_t eff_fill_color (bool real) const;
tl::color_t eff_fill_color (bool real) const;
/**
* @brief render the effective frame color plus an additional brightness adjustment
@ -161,7 +161,7 @@ public:
* This method returns the effective frame color with an additional brightness adjustment
* applied.
*/
color_t eff_frame_color_brighter (bool real, int plus_brightness) const;
tl::color_t eff_frame_color_brighter (bool real, int plus_brightness) const;
/**
* @brief render the effective frame color plus an additional brightness adjustment
@ -169,14 +169,14 @@ public:
* This method returns the effective fill color with an additional brightness adjustment
* applied.
*/
color_t eff_fill_color_brighter (bool real, int plus_brightness) const;
tl::color_t eff_fill_color_brighter (bool real, int plus_brightness) const;
/**
* @brief Get the frame color
*
* This method may return an invalid color if the color is not set.
*/
color_t frame_color (bool real) const
tl::color_t frame_color (bool real) const
{
if (real) {
ensure_visual_realized ();
@ -193,7 +193,7 @@ public:
* To clear the frame color, pass 0 to this method. Valid colors have the
* upper 8 bits set.
*/
void set_frame_color_code (color_t c)
void set_frame_color_code (tl::color_t c)
{
refresh ();
if (m_frame_color != c) {
@ -205,7 +205,7 @@ public:
/**
* @brief Set the frame color to the given value
*/
void set_frame_color (color_t c)
void set_frame_color (tl::color_t c)
{
set_frame_color_code (c | 0xff000000);
}
@ -231,7 +231,7 @@ public:
*
* This method may return an invalid color if the color is not set.
*/
color_t fill_color (bool real) const
tl::color_t fill_color (bool real) const
{
if (real) {
ensure_visual_realized ();
@ -248,7 +248,7 @@ public:
* To clear the fill color, pass 0 to this method. Valid colors have the
* upper 8 bits set.
*/
void set_fill_color_code (color_t c)
void set_fill_color_code (tl::color_t c)
{
refresh ();
if (m_fill_color != c) {
@ -260,7 +260,7 @@ public:
/**
* @brief Set the fill color to the given value
*/
void set_fill_color (color_t c)
void set_fill_color (tl::color_t c)
{
set_fill_color_code (c | 0xff000000);
}
@ -844,8 +844,8 @@ public:
/**
* @brief Adaptors required for the XML reader
*/
color_t frame_color_loc () const { return frame_color (false); }
color_t fill_color_loc () const { return fill_color (false); }
tl::color_t frame_color_loc () const { return frame_color (false); }
tl::color_t fill_color_loc () const { return fill_color (false); }
int frame_brightness_loc () const { return frame_brightness (false); }
int fill_brightness_loc () const { return fill_brightness (false); }
int dither_pattern_loc () const { return dither_pattern (false); }
@ -928,10 +928,10 @@ private:
// the generation number
size_t m_gen_id;
// display styles
color_t m_frame_color;
mutable color_t m_frame_color_real;
color_t m_fill_color;
mutable color_t m_fill_color_real;
tl::color_t m_frame_color;
mutable tl::color_t m_frame_color_real;
tl::color_t m_fill_color;
mutable tl::color_t m_fill_color_real;
int m_frame_brightness;
mutable int m_frame_brightness_real;
int m_fill_brightness;

View File

@ -132,7 +132,7 @@ std::string ImageCacheEntry::to_string () const
// ----------------------------------------------------------------------------
static void
blowup (const lay::PixelBuffer &src, lay::PixelBuffer &dest, unsigned int os)
blowup (const tl::PixelBuffer &src, tl::PixelBuffer &dest, unsigned int os)
{
unsigned int ymax = src.height ();
unsigned int xmax = src.width ();
@ -152,7 +152,7 @@ blowup (const lay::PixelBuffer &src, lay::PixelBuffer &dest, unsigned int os)
}
static void
subsample (const lay::PixelBuffer &src, lay::PixelBuffer &dest, unsigned int os, double g)
subsample (const tl::PixelBuffer &src, tl::PixelBuffer &dest, unsigned int os, double g)
{
// TODO: this is probably not compatible with the endianess of SPARC ..
@ -274,13 +274,8 @@ invert (unsigned char *data, unsigned int width, unsigned int height)
}
}
#if defined(HAVE_QT)
LayoutCanvas::LayoutCanvas (QWidget *parent, lay::LayoutViewBase *view, const char *name)
: lay::ViewObjectWidget (parent, name),
#else
LayoutCanvas::LayoutCanvas (lay::LayoutViewBase *view)
: lay::ViewObjectWidget (),
#endif
: lay::ViewObjectUI (),
mp_view (view),
mp_image (0), mp_image_bg (0),
mp_image_fg (0),
@ -296,10 +291,25 @@ LayoutCanvas::LayoutCanvas (lay::LayoutViewBase *view)
m_do_end_of_drawing_dm (this, &LayoutCanvas::do_end_of_drawing),
m_image_cache_size (1)
{
tl::Color bg (0xffffffff), fg (0xff000000), active (0xffc0c0c0);
#if defined(HAVE_QT)
if (widget ()) {
#if QT_VERSION > 0x050000
m_dpr = devicePixelRatio ();
m_dpr = widget ()->devicePixelRatio ();
#endif
widget ()->setObjectName (QString::fromUtf8 ("canvas"));
widget ()->setBackgroundRole (QPalette::NoRole);
bg = tl::Color (widget ()->palette ().color (QPalette::Normal, QPalette::Window).rgb ());
fg = tl::Color (widget ()->palette ().color (QPalette::Normal, QPalette::Text).rgb ());
active = tl::Color (widget ()->palette ().color (QPalette::Normal, QPalette::Mid).rgb ());
widget ()->setAttribute (Qt::WA_NoSystemBackground);
}
#endif
// The gamma value used for subsampling: something between 1.8 and 2.2.
@ -311,15 +321,7 @@ LayoutCanvas::LayoutCanvas (lay::LayoutViewBase *view)
mp_redraw_thread = new lay::RedrawThread (this, view);
#if defined(HAVE_QT)
setBackgroundRole (QPalette::NoRole);
set_colors (lay::Color (palette ().color (QPalette::Normal, QPalette::Window).rgb ()),
lay::Color (palette ().color (QPalette::Normal, QPalette::Text).rgb ()),
lay::Color (palette ().color (QPalette::Normal, QPalette::Mid).rgb ()));
setAttribute (Qt::WA_NoSystemBackground);
#else
set_colors (0xffffffff, 0xff000000, 0xffc0c0c0);
#endif
set_colors (bg, fg, active);
}
LayoutCanvas::~LayoutCanvas ()
@ -391,7 +393,7 @@ LayoutCanvas::set_oversampling (unsigned int os)
}
void
LayoutCanvas::set_colors (lay::Color background, lay::Color foreground, lay::Color active)
LayoutCanvas::set_colors (tl::Color background, tl::Color foreground, tl::Color active)
{
m_background = background.rgb ();
m_foreground = foreground.rgb ();
@ -446,7 +448,7 @@ LayoutCanvas::prepare_drawing ()
if (mp_image) {
delete mp_image;
}
mp_image = new lay::PixelBuffer (m_viewport_l.width (), m_viewport_l.height ());
mp_image = new tl::PixelBuffer (m_viewport_l.width (), m_viewport_l.height ());
if (mp_image_fg) {
delete mp_image_fg;
mp_image_fg = 0;
@ -564,7 +566,7 @@ LayoutCanvas::free_resources ()
#if defined(HAVE_QT)
void
LayoutCanvas::paintEvent (QPaintEvent *)
LayoutCanvas::paint_event ()
{
// this is the update image request
tl::SelfTimer timer_info (tl::verbosity () >= 41, tl::to_string (QObject::tr ("PaintEvent")));
@ -587,7 +589,7 @@ LayoutCanvas::paintEvent (QPaintEvent *)
if (mp_image_bg) {
delete mp_image_bg;
}
mp_image_bg = new lay::PixelBuffer (*mp_image);
mp_image_bg = new tl::PixelBuffer (*mp_image);
} else {
// else reuse the saved image
@ -620,18 +622,18 @@ LayoutCanvas::paintEvent (QPaintEvent *)
clear_fg_bitmaps ();
do_render (m_viewport_l, *this, true);
mp_image_fg = new lay::PixelBuffer ();
mp_image_fg = new tl::PixelBuffer ();
if (fg_bitmaps () > 0) {
lay::PixelBuffer full_image (*mp_image);
tl::PixelBuffer full_image (*mp_image);
bitmaps_to_image (fg_view_op_vector (), fg_bitmap_vector (), dither_pattern (), line_styles (), &full_image, m_viewport_l.width (), m_viewport_l.height (), false, &m_mutex);
// render the foreground parts ..
if (m_oversampling == 1) {
*mp_image_fg = full_image;
} else {
lay::PixelBuffer subsampled_image (m_viewport.width (), m_viewport.height ());
tl::PixelBuffer subsampled_image (m_viewport.width (), m_viewport.height ());
subsampled_image.set_transparent (mp_image->transparent ());
subsample (full_image, subsampled_image, m_oversampling, m_gamma);
*mp_image_fg = subsampled_image;
@ -643,7 +645,7 @@ LayoutCanvas::paintEvent (QPaintEvent *)
} else {
lay::PixelBuffer subsampled_image (m_viewport.width (), m_viewport.height ());
tl::PixelBuffer subsampled_image (m_viewport.width (), m_viewport.height ());
subsampled_image.set_transparent (mp_image->transparent ());
subsample (*mp_image, subsampled_image, m_oversampling, m_gamma);
*mp_image_fg = subsampled_image;
@ -659,7 +661,7 @@ LayoutCanvas::paintEvent (QPaintEvent *)
do_render (m_viewport_l, *this, false);
// produce the pixmap first and then overdraw with dynamic content.
QPainter painter (this);
QPainter painter (widget ());
QImage img = mp_image_fg->to_image ();
#if QT_VERSION > 0x050000
img.setDevicePixelRatio (double (m_dpr));
@ -668,7 +670,7 @@ LayoutCanvas::paintEvent (QPaintEvent *)
if (fg_bitmaps () > 0) {
lay::PixelBuffer full_image (mp_image->width (), mp_image->height ());
tl::PixelBuffer full_image (mp_image->width (), mp_image->height ());
full_image.set_transparent (true);
full_image.fill (0);
@ -682,7 +684,7 @@ LayoutCanvas::paintEvent (QPaintEvent *)
#endif
painter.drawImage (QPoint (0, 0), img);
} else {
lay::PixelBuffer subsampled_image (m_viewport.width (), m_viewport.height ());
tl::PixelBuffer subsampled_image (m_viewport.width (), m_viewport.height ());
subsampled_image.set_transparent (true);
subsample (full_image, subsampled_image, m_oversampling, m_gamma);
QImage img = subsampled_image.to_image ();
@ -710,7 +712,7 @@ class DetachedViewObjectCanvas
: public BitmapViewObjectCanvas
{
public:
DetachedViewObjectCanvas (lay::Color bg, lay::Color fg, lay::Color ac, unsigned int width_l, unsigned int height_l, double resolution, lay::PixelBuffer *img)
DetachedViewObjectCanvas (tl::Color bg, tl::Color fg, tl::Color ac, unsigned int width_l, unsigned int height_l, double resolution, tl::PixelBuffer *img)
: BitmapViewObjectCanvas (width_l, height_l, resolution),
m_bg (bg), m_fg (fg), m_ac (ac), mp_image (img)
{
@ -718,7 +720,7 @@ public:
m_gamma = 2.0;
if (img->width () != width_l || img->height () != height_l) {
mp_image_l = new lay::PixelBuffer (width_l, height_l);
mp_image_l = new tl::PixelBuffer (width_l, height_l);
mp_image_l->set_transparent (img->transparent ());
mp_image_l->fill (bg.rgb ());
} else {
@ -736,22 +738,22 @@ public:
}
}
lay::Color background_color () const
tl::Color background_color () const
{
return m_bg;
}
lay::Color foreground_color () const
tl::Color foreground_color () const
{
return m_fg;
}
lay::Color active_color () const
tl::Color active_color () const
{
return m_ac;
}
virtual lay::PixelBuffer *bg_image ()
virtual tl::PixelBuffer *bg_image ()
{
return mp_image_l ? mp_image_l : mp_image;
}
@ -778,9 +780,9 @@ public:
}
private:
lay::Color m_bg, m_fg, m_ac;
lay::PixelBuffer *mp_image;
lay::PixelBuffer *mp_image_l;
tl::Color m_bg, m_fg, m_ac;
tl::PixelBuffer *mp_image;
tl::PixelBuffer *mp_image_l;
double m_gamma;
};
@ -807,17 +809,17 @@ public:
clear_fg_bitmaps ();
}
lay::Color background_color () const
tl::Color background_color () const
{
return m_bg ? 0xffffffff : 0;
}
lay::Color foreground_color () const
tl::Color foreground_color () const
{
return m_fg ? 0xffffffff : 0;
}
lay::Color active_color () const
tl::Color active_color () const
{
return m_ac ? 0xffffffff : 0;
}
@ -826,14 +828,14 @@ private:
bool m_bg, m_fg, m_ac;
};
lay::PixelBuffer
tl::PixelBuffer
LayoutCanvas::image (unsigned int width, unsigned int height)
{
return image_with_options (width, height, -1, -1, -1.0, lay::Color (), lay::Color (), lay::Color (), db::DBox ());
return image_with_options (width, height, -1, -1, -1.0, tl::Color (), tl::Color (), tl::Color (), db::DBox ());
}
lay::PixelBuffer
LayoutCanvas::image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, lay::Color background, lay::Color foreground, lay::Color active, const db::DBox &target_box)
tl::PixelBuffer
LayoutCanvas::image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, tl::Color background, tl::Color foreground, tl::Color active, const db::DBox &target_box)
{
if (oversampling <= 0) {
oversampling = m_oversampling;
@ -855,7 +857,7 @@ LayoutCanvas::image_with_options (unsigned int width, unsigned int height, int l
}
// TODO: for other architectures MonoLSB may not be the right format
lay::PixelBuffer img (width, height);
tl::PixelBuffer img (width, height);
// this may happen for BIG images:
if (img.width () != width || img.height () != height) {
@ -908,8 +910,8 @@ LayoutCanvas::image_with_options (unsigned int width, unsigned int height, int l
return img;
}
lay::BitmapBuffer
LayoutCanvas::image_with_options_mono (unsigned int width, unsigned int height, int linewidth, lay::Color background_c, lay::Color foreground_c, lay::Color active_c, const db::DBox &target_box)
tl::BitmapBuffer
LayoutCanvas::image_with_options_mono (unsigned int width, unsigned int height, int linewidth, tl::Color background_c, tl::Color foreground_c, tl::Color active_c, const db::DBox &target_box)
{
if (linewidth <= 0) {
linewidth = 1;
@ -944,7 +946,7 @@ LayoutCanvas::image_with_options_mono (unsigned int width, unsigned int height,
redraw_thread.start (0 /*synchronous*/, m_layers, vp, 1.0, true);
redraw_thread.stop (); // safety
lay::BitmapBuffer img (width, height);
tl::BitmapBuffer img (width, height);
img.fill (background);
rd_canvas.to_image_mono (view_ops, dither_pattern (), line_styles (), background, foreground, active, this, img, vp.width (), vp.height ());
@ -952,13 +954,13 @@ LayoutCanvas::image_with_options_mono (unsigned int width, unsigned int height,
return img;
}
lay::PixelBuffer
tl::PixelBuffer
LayoutCanvas::screenshot ()
{
// if required, start the redraw thread ..
prepare_drawing ();
lay::PixelBuffer img (m_viewport.width (), m_viewport.height ());
tl::PixelBuffer img (m_viewport.width (), m_viewport.height ());
img.fill (m_background);
DetachedViewObjectCanvas vo_canvas (background_color (), foreground_color (), active_color (), m_viewport_l.width (), m_viewport_l.height (), 1.0 / double (m_oversampling * m_dpr), &img);
@ -982,27 +984,8 @@ LayoutCanvas::screenshot ()
return img;
}
#if defined(HAVE_QT)
void
LayoutCanvas::resizeEvent (QResizeEvent *)
{
do_resize (width (), height ());
}
#endif
void
LayoutCanvas::resize (unsigned int width, unsigned int height)
{
// pass down to the basic view object canvas
lay::ViewObjectWidget::resize (width, height);
// don't wait until the layout system informs us - which may never take place when
// the widget isn't shown.
do_resize (width, height);
}
void
LayoutCanvas::do_resize (unsigned int width, unsigned int height)
LayoutCanvas::resize_event (unsigned int width, unsigned int height)
{
unsigned int w = width * m_dpr, h = height * m_dpr;
unsigned int wl = width * m_oversampling * m_dpr, hl = height * m_oversampling * m_dpr;
@ -1103,22 +1086,11 @@ LayoutCanvas::do_update_image ()
}
#if defined(HAVE_QT)
bool
LayoutCanvas::event (QEvent *e)
void
LayoutCanvas::gtf_probe ()
{
if (e->type () == QEvent::MaxUser) {
// GTF probe event
// record the contents (the screenshot) as ASCII text
if (gtf::Recorder::instance () && gtf::Recorder::instance ()->recording ()) {
gtf::Recorder::instance ()->probe (this, gtf::image_to_variant (screenshot ().to_image_copy ()));
}
e->accept ();
return true;
} else {
return QWidget::event (e);
if (gtf::Recorder::instance () && gtf::Recorder::instance ()->recording ()) {
gtf::Recorder::instance ()->probe (widget (), gtf::image_to_variant (screenshot ().to_image_copy ()));
}
}
#endif

View File

@ -31,7 +31,7 @@
#include "layViewOp.h"
#include "layViewObject.h"
#include "layBitmap.h"
#include "layColor.h"
#include "tlColor.h"
#include "layDrawing.h"
#include "layDitherPattern.h"
#include "layLineStyles.h"
@ -134,24 +134,16 @@ private:
*/
class LAYBASIC_PUBLIC LayoutCanvas
: public lay::ViewObjectWidget,
: public lay::ViewObjectUI,
public lay::BitmapViewObjectCanvas,
public lay::BitmapRedrawThreadCanvas,
public lay::Drawings
{
#if defined(HAVE_QT)
Q_OBJECT
#endif
public:
#if defined(HAVE_QT)
LayoutCanvas (QWidget *parent, lay::LayoutViewBase *view, const char *name = "canvas");
#else
LayoutCanvas (lay::LayoutViewBase *view);
#endif
~LayoutCanvas ();
void set_colors (lay::Color background, lay::Color foreground, lay::Color active);
void set_colors (tl::Color background, tl::Color foreground, tl::Color active);
/**
* @brief Set the view ops for the layers
@ -172,10 +164,10 @@ public:
return m_view_ops;
}
lay::PixelBuffer screenshot ();
lay::PixelBuffer image (unsigned int width, unsigned int height);
lay::PixelBuffer image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, lay::Color background, lay::Color foreground, lay::Color active_color, const db::DBox &target_box);
lay::BitmapBuffer image_with_options_mono (unsigned int width, unsigned int height, int linewidth, lay::Color background, lay::Color foreground, lay::Color active, const db::DBox &target_box);
tl::PixelBuffer screenshot ();
tl::PixelBuffer image (unsigned int width, unsigned int height);
tl::PixelBuffer image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, tl::Color background, tl::Color foreground, tl::Color active_color, const db::DBox &target_box);
tl::BitmapBuffer image_with_options_mono (unsigned int width, unsigned int height, int linewidth, tl::Color background, tl::Color foreground, tl::Color active, const db::DBox &target_box);
void update_image ();
@ -296,31 +288,31 @@ public:
/**
* @brief Reimplementation of ViewObjectCanvas: Background color
*/
lay::Color background_color () const
tl::Color background_color () const
{
return lay::Color (m_background);
return tl::Color (m_background);
}
/**
* @brief Reimplementation of ViewObjectCanvas: Foreground color
*/
lay::Color foreground_color () const
tl::Color foreground_color () const
{
return lay::Color (m_foreground);
return tl::Color (m_foreground);
}
/**
* @brief Reimplementation of ViewObjectCanvas: Active color
*/
lay::Color active_color () const
tl::Color active_color () const
{
return lay::Color (m_active);
return tl::Color (m_active);
}
/**
* @brief Reimplementation of ViewObjectCanvas: background image
*/
lay::PixelBuffer *bg_image ()
tl::PixelBuffer *bg_image ()
{
return mp_image;
}
@ -343,11 +335,6 @@ public:
return m_viewport;
}
/**
* @brief Resizes the canvas object in the Qt-less case
*/
void resize (unsigned int width, unsigned int height);
/**
* @brief Gets (and resets) a flag indicating that drawing has finished
*/
@ -371,14 +358,14 @@ public:
private:
lay::LayoutViewBase *mp_view;
lay::PixelBuffer *mp_image;
lay::PixelBuffer *mp_image_bg;
lay::PixelBuffer *mp_image_fg;
tl::PixelBuffer *mp_image;
tl::PixelBuffer *mp_image_bg;
tl::PixelBuffer *mp_image_fg;
db::DBox m_precious_box;
lay::Viewport m_viewport, m_viewport_l;
lay::color_t m_background;
lay::color_t m_foreground;
lay::color_t m_active;
tl::color_t m_background;
tl::color_t m_foreground;
tl::color_t m_active;
std::vector <lay::ViewOp> m_view_ops;
lay::DitherPattern m_dither_pattern;
lay::LineStyles m_line_styles;
@ -403,13 +390,12 @@ private:
tl::Mutex m_mutex;
#if defined(HAVE_QT)
virtual void paintEvent (QPaintEvent *);
virtual void resizeEvent (QResizeEvent *);
virtual bool event (QEvent *e);
#endif
virtual void key_event (unsigned int key, unsigned int buttons);
virtual void resize_event (unsigned int width, unsigned int height);
#if defined(HAVE_QT)
virtual void gtf_probe ();
virtual void paint_event ();
#endif
// implementation of the lay::Drawings interface
void update_drawings ();
@ -420,7 +406,6 @@ private:
void do_update_image ();
void do_end_of_drawing ();
void do_redraw_all (bool force_redraw = true);
void do_resize (unsigned int width, unsigned int height);
void prepare_drawing ();
};

View File

@ -235,11 +235,8 @@ struct OpDeleteLayerProps
const double animation_interval = 0.5;
LayoutViewBase::LayoutViewBase (db::Manager *manager, bool editable, lay::Plugin *plugin_parent, unsigned int options) :
#if defined(HAVE_QT)
QFrame (0),
#endif
lay::Dispatcher (plugin_parent, false /*not standalone*/),
LayoutViewBase::LayoutViewBase (db::Manager *manager, bool editable, lay::Plugin *plugin_parent, unsigned int options)
: lay::Dispatcher (plugin_parent, false /*not standalone*/),
mp_ui (0),
m_editable (editable),
m_options (options),
@ -251,15 +248,8 @@ LayoutViewBase::LayoutViewBase (db::Manager *manager, bool editable, lay::Plugin
init (manager);
}
#if defined(HAVE_QT)
LayoutViewBase::LayoutViewBase (QWidget *parent, lay::LayoutView *ui, db::Manager *manager, bool editable, lay::Plugin *plugin_parent, unsigned int options) :
#else
LayoutViewBase::LayoutViewBase (lay::LayoutView *ui, db::Manager *manager, bool editable, lay::Plugin *plugin_parent, unsigned int options) :
#endif
#if defined(HAVE_QT)
QFrame (parent),
#endif
lay::Dispatcher (plugin_parent, false /*not standalone*/),
LayoutViewBase::LayoutViewBase (lay::LayoutView *ui, db::Manager *manager, bool editable, lay::Plugin *plugin_parent, unsigned int options)
: lay::Dispatcher (plugin_parent, false /*not standalone*/),
mp_ui (ui),
m_editable (editable),
m_options (options),
@ -271,15 +261,8 @@ LayoutViewBase::LayoutViewBase (lay::LayoutView *ui, db::Manager *manager, bool
init (manager);
}
#if defined(HAVE_QT)
LayoutViewBase::LayoutViewBase (QWidget *parent, lay::LayoutView *ui, lay::LayoutViewBase *source, db::Manager *manager, bool editable, lay::Plugin *plugin_parent, unsigned int options) :
#else
LayoutViewBase::LayoutViewBase (lay::LayoutView *ui, lay::LayoutViewBase *source, db::Manager *manager, bool editable, lay::Plugin *plugin_parent, unsigned int options) :
#endif
#if defined(HAVE_QT)
QFrame (parent),
#endif
lay::Dispatcher (plugin_parent, false /*not standalone*/),
LayoutViewBase::LayoutViewBase (lay::LayoutView *ui, lay::LayoutViewBase *source, db::Manager *manager, bool editable, lay::Plugin *plugin_parent, unsigned int options)
: lay::Dispatcher (plugin_parent, false /*not standalone*/),
mp_ui (ui),
m_editable (editable),
m_options (options),
@ -344,7 +327,7 @@ LayoutViewBase::init (db::Manager *mgr)
m_paste_display_mode = 2;
m_guiding_shape_visible = true;
m_guiding_shape_line_width = 1;
m_guiding_shape_color = lay::Color ();
m_guiding_shape_color = tl::Color ();
m_guiding_shape_vertex_size = 5;
m_to_level = 0;
m_ctx_dimming = 50;
@ -405,11 +388,7 @@ LayoutViewBase::init (db::Manager *mgr)
m_layer_properties_lists.back ()->attach_view (this, (unsigned int) (m_layer_properties_lists.size () - 1));
m_current_layer_list = 0;
#if defined(HAVE_QT)
mp_canvas = new lay::LayoutCanvas (widget (), this);
#else
mp_canvas = new lay::LayoutCanvas (this);
#endif
// occupy services and editables:
// these services get deleted by the canvas destructor automatically:
@ -429,7 +408,47 @@ LayoutViewBase::init (db::Manager *mgr)
create_plugins ();
}
LayoutViewBase::~LayoutViewBase ()
void
LayoutViewBase::finish ()
{
// if we're the root dispatcher initialize the menu and build the context menus. No other menus are built so far.
if (dispatcher () == this) {
#if defined(HAVE_QT)
set_menu_parent_widget (widget ());
init_menu ();
if (widget ()) {
menu ()->build (0, 0);
}
#else
init_menu ();
#endif
}
}
void
LayoutViewBase::init_menu ()
{
make_menu ();
// make the plugins create their menu items
for (tl::Registrar<lay::PluginDeclaration>::iterator cls = tl::Registrar<lay::PluginDeclaration>::begin (); cls != tl::Registrar<lay::PluginDeclaration>::end (); ++cls) {
// TODO: get rid of the const_cast hack
const_cast <lay::PluginDeclaration *> (&*cls)->init_menu (dispatcher ());
}
// if not in editable mode, hide all entries from "edit_mode" group and show all from the "view_mode" group and vice versa
std::vector<std::string> edit_mode_grp = menu ()->group ("edit_mode");
for (std::vector<std::string>::const_iterator g = edit_mode_grp.begin (); g != edit_mode_grp.end (); ++g) {
menu ()->action (*g)->set_visible (is_editable ());
}
std::vector<std::string> view_mode_grp = menu ()->group ("view_mode");
for (std::vector<std::string>::const_iterator g = view_mode_grp.begin (); g != view_mode_grp.end (); ++g) {
menu ()->action (*g)->set_visible (! is_editable ());
}
}
void
LayoutViewBase::shutdown ()
{
// detach all observers
// This is to prevent signals to partially destroyed observers that own a LayoutViewBase
@ -478,10 +497,15 @@ LayoutViewBase::~LayoutViewBase ()
delete *p;
}
// detach from the manager, so we can safely delete the manager
// detach from the manager, so we can safely delete the manager
manager (0);
stop ();
}
LayoutViewBase::~LayoutViewBase ()
{
shutdown ();
// because LayoutViewBase and LayoutCanvas both control lifetimes of
// ruler objects for example, it is safer to explicitly delete the
@ -728,7 +752,7 @@ LayoutViewBase::configure (const std::string &name, const std::string &value)
} else if (name == cfg_background_color) {
lay::Color color;
tl::Color color;
ColorConverter ().from_string (value, color);
background_color (color);
// do not take - let others receive the background color events as well
@ -773,7 +797,7 @@ LayoutViewBase::configure (const std::string &name, const std::string &value)
} else if (name == cfg_ctx_color) {
lay::Color color;
tl::Color color;
ColorConverter ().from_string (value, color);
ctx_color (color);
return true;
@ -794,7 +818,7 @@ LayoutViewBase::configure (const std::string &name, const std::string &value)
} else if (name == cfg_child_ctx_color) {
lay::Color color;
tl::Color color;
ColorConverter ().from_string (value, color);
child_ctx_color (color);
return true;
@ -878,14 +902,14 @@ LayoutViewBase::configure (const std::string &name, const std::string &value)
} else if (name == cfg_cell_box_color) {
lay::Color color;
tl::Color color;
ColorConverter ().from_string (value, color);
cell_box_color (color);
return true;
} else if (name == cfg_text_color) {
lay::Color color;
tl::Color color;
ColorConverter ().from_string (value, color);
text_color (color);
return true;
@ -1004,14 +1028,14 @@ LayoutViewBase::configure (const std::string &name, const std::string &value)
} else if (name == cfg_guiding_shape_color) {
lay::Color color;
tl::Color color;
ColorConverter ().from_string (value, color);
guiding_shapes_color (color);
return true;
} else if (name == cfg_guiding_shape_color) {
lay::Color color;
tl::Color color;
ColorConverter ().from_string (value, color);
guiding_shapes_color (color);
return true;
@ -1166,7 +1190,7 @@ LayoutViewBase::configure (const std::string &name, const std::string &value)
} else if (name == cfg_sel_color) {
lay::Color color;
tl::Color color;
lay::ColorConverter ().from_string (value, color);
// Change the color
@ -2308,6 +2332,38 @@ LayoutViewBase::bookmark_view (const std::string &name)
bookmarks_changed ();
}
bool
LayoutViewBase::is_single_cv_layer_properties_file (const std::string &fn)
{
// If the file contains information for a single layout but we have multiple ones,
// show the dialog to determine what layout to apply the information to.
std::vector<lay::LayerPropertiesList> props;
try {
tl::XMLFileSource in (fn);
props.push_back (lay::LayerPropertiesList ());
props.back ().load (in);
} catch (...) {
props.clear ();
tl::XMLFileSource in (fn);
lay::LayerPropertiesList::load (in, props);
}
// Collect all cv indices in the layer properties
std::set <int> cv;
for (std::vector<lay::LayerPropertiesList>::const_iterator p = props.begin (); p != props.end (); ++p) {
for (lay::LayerPropertiesConstIterator lp = p->begin_const_recursive (); ! lp.at_end (); ++lp) {
if (! lp->has_children ()) {
cv.insert (lp->source (true).cv_index ());
if (cv.size () >= 2) {
break;
}
}
}
}
return (cv.size () == 1);
}
void
LayoutViewBase::load_layer_props (const std::string &fn)
{
@ -2486,7 +2542,7 @@ LayoutViewBase::init_layer_properties (LayerProperties &p) const
void
LayoutViewBase::init_layer_properties (LayerProperties &p, const LayerPropertiesList &lp_list) const
{
lay::color_t c = 0;
tl::color_t c = 0;
if (m_palette.luminous_colors () > 0) {
c = m_palette.luminous_color_by_index (p.source (true /*real*/).color_index ());
}
@ -2517,7 +2573,7 @@ LayoutViewBase::get_screenshot ()
}
#endif
lay::PixelBuffer
tl::PixelBuffer
LayoutViewBase::get_screenshot_pb ()
{
tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Save screenshot")));
@ -2570,7 +2626,7 @@ LayoutViewBase::save_screenshot (const std::string &fn)
tl::log << "Saved screen shot to " << fn;
}
#else
#elif defined(HAVE_PNG)
void
LayoutViewBase::save_screenshot (const std::string &fn)
{
@ -2580,12 +2636,18 @@ LayoutViewBase::save_screenshot (const std::string &fn)
tl::DeferredMethodScheduler::execute ();
tl::OutputStream stream (fn);
lay::PixelBuffer img = mp_canvas->screenshot ();
tl::PixelBuffer img = mp_canvas->screenshot ();
img.set_texts (png_texts (this, box ()));
img.write_png (stream);
tl::log << "Saved screen shot to " << fn;
}
#else
void
LayoutViewBase::save_screenshot (const std::string &)
{
throw tl::Exception (tl::to_string (tr ("Unable to write screenshot - PNG library not compiled in")));
}
#endif
#if defined(HAVE_QT)
@ -2601,7 +2663,7 @@ LayoutViewBase::get_image (unsigned int width, unsigned int height)
}
#endif
lay::PixelBuffer
tl::PixelBuffer
LayoutViewBase::get_pixels (unsigned int width, unsigned int height)
{
tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Get image")));
@ -2615,7 +2677,7 @@ LayoutViewBase::get_pixels (unsigned int width, unsigned int height)
#if defined(HAVE_QT)
QImage
LayoutViewBase::get_image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution,
lay::Color background, lay::Color foreground, lay::Color active, const db::DBox &target_box, bool monochrome)
tl::Color background, tl::Color foreground, tl::Color active, const db::DBox &target_box, bool monochrome)
{
tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Get image")));
@ -2630,9 +2692,9 @@ LayoutViewBase::get_image_with_options (unsigned int width, unsigned int height,
}
#endif
lay::PixelBuffer
tl::PixelBuffer
LayoutViewBase::get_pixels_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution,
lay::Color background, lay::Color foreground, lay::Color active, const db::DBox &target_box)
tl::Color background, tl::Color foreground, tl::Color active, const db::DBox &target_box)
{
tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Get image")));
@ -2642,9 +2704,9 @@ LayoutViewBase::get_pixels_with_options (unsigned int width, unsigned int height
return mp_canvas->image_with_options (width, height, linewidth, oversampling, resolution, background, foreground, active, target_box);
}
lay::BitmapBuffer
tl::BitmapBuffer
LayoutViewBase::get_pixels_with_options_mono (unsigned int width, unsigned int height, int linewidth,
lay::Color background, lay::Color foreground, lay::Color active, const db::DBox &target_box)
tl::Color background, tl::Color foreground, tl::Color active, const db::DBox &target_box)
{
tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Get image")));
@ -2677,7 +2739,7 @@ LayoutViewBase::save_image (const std::string &fn, unsigned int width, unsigned
tl::log << "Saved image to " << fn;
}
#else
#elif defined(HAVE_PNG)
void
LayoutViewBase::save_image (const std::string &fn, unsigned int width, unsigned int height)
{
@ -2689,20 +2751,26 @@ LayoutViewBase::save_image (const std::string &fn, unsigned int width, unsigned
tl::DeferredMethodScheduler::execute ();
tl::OutputStream stream (fn);
lay::PixelBuffer img = mp_canvas->image (width, height);
tl::PixelBuffer img = mp_canvas->image (width, height);
std::vector<std::pair<std::string, std::string> > texts = png_texts (this, vp.box ());
img.set_texts (texts);
img.write_png (stream);
tl::log << "Saved image to " << fn;
}
#else
void
LayoutViewBase::save_image (const std::string &, unsigned int, unsigned int)
{
throw tl::Exception (tl::to_string (tr ("Unable to save image - PNG library not compiled in")));
}
#endif
#if defined(HAVE_QT) && !defined(PREFER_LIBPNG_FOR_SAVE)
void
LayoutViewBase::save_image_with_options (const std::string &fn,
unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution,
lay::Color background, lay::Color foreground, lay::Color active, const db::DBox &target_box, bool monochrome)
tl::Color background, tl::Color foreground, tl::Color active, const db::DBox &target_box, bool monochrome)
{
tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Save image")));
@ -2729,11 +2797,11 @@ LayoutViewBase::save_image_with_options (const std::string &fn,
tl::log << "Saved image to " << fn;
}
#else
#elif defined(HAVE_PNG)
void
LayoutViewBase::save_image_with_options (const std::string &fn,
unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution,
lay::Color background, lay::Color foreground, lay::Color active, const db::DBox &target_box, bool monochrome)
tl::Color background, tl::Color foreground, tl::Color active, const db::DBox &target_box, bool monochrome)
{
tl::SelfTimer timer (tl::verbosity () >= 11, tl::to_string (tr ("Save image")));
@ -2746,13 +2814,13 @@ LayoutViewBase::save_image_with_options (const std::string &fn,
tl::OutputStream stream (fn);
if (monochrome) {
lay::BitmapBuffer img = mp_canvas->image_with_options_mono (width, height, linewidth, background, foreground, active, target_box);
tl::BitmapBuffer img = mp_canvas->image_with_options_mono (width, height, linewidth, background, foreground, active, target_box);
img.set_texts (texts);
img.write_png (stream);
} else {
lay::PixelBuffer img = mp_canvas->image_with_options (width, height, linewidth, oversampling, resolution, background, foreground, active, target_box);
tl::PixelBuffer img = mp_canvas->image_with_options (width, height, linewidth, oversampling, resolution, background, foreground, active, target_box);
img.set_texts (texts);
img.write_png (stream);
@ -2760,6 +2828,14 @@ LayoutViewBase::save_image_with_options (const std::string &fn,
tl::log << "Saved image to " << fn;
}
#else
void
LayoutViewBase::save_image_with_options (const std::string &,
unsigned int, unsigned int, int, int, double,
tl::Color, tl::Color, tl::Color, const db::DBox &, bool)
{
throw tl::Exception (tl::to_string (tr ("Unable to save image - PNG library not compiled in")));
}
#endif
void
@ -3375,7 +3451,7 @@ LayoutViewBase::box () const
QWidget *
LayoutViewBase::widget ()
{
return this;
return 0;
}
#endif
@ -3391,7 +3467,7 @@ LayoutViewBase::timer ()
{
bool dirty = false;
for (std::list<lay::CellView>::const_iterator i = m_cellviews.begin (); i != m_cellviews.end () && ! dirty; ++i) {
dirty = (*i)->layout ().is_editable () && (*i)->is_dirty ();
dirty = (*i).is_valid () && (*i)->layout ().is_editable () && (*i)->is_dirty ();
}
if (dirty != m_dirty) {
@ -3758,7 +3834,7 @@ LayoutViewBase::set_view_ops ()
std::vector <lay::ViewOp> view_ops;
view_ops.reserve (nlayers * planes_per_layer + special_planes_before + special_planes_after);
lay::Color box_color;
tl::Color box_color;
if (! m_box_color.is_valid ()) {
box_color = mp_canvas->foreground_color ();
} else {
@ -3817,7 +3893,7 @@ LayoutViewBase::set_view_ops ()
// produce the ViewOps for the guiding shapes
color_t gs_color = box_color.rgb ();
tl::color_t gs_color = box_color.rgb ();
if (m_guiding_shape_color.is_valid ()) {
gs_color = m_guiding_shape_color.rgb ();
}
@ -3826,7 +3902,7 @@ LayoutViewBase::set_view_ops ()
lay::ViewOp::Mode mode = lay::ViewOp::Copy;
color_t fill_color, frame_color, text_color;
tl::color_t fill_color, frame_color, text_color;
int dp = 1; // no stipples for guiding shapes
if (ctx == 0) {
@ -3941,7 +4017,7 @@ LayoutViewBase::set_view_ops ()
}
}
color_t fill_color, frame_color, text_color;
tl::color_t fill_color, frame_color, text_color;
int dp = m_no_stipples ? 1 : l->dither_pattern (true /*real*/);
int ls = l->line_style (true /*real*/);
@ -4044,7 +4120,7 @@ LayoutViewBase::guiding_shapes_visible (bool v)
}
void
LayoutViewBase::guiding_shapes_color (lay::Color c)
LayoutViewBase::guiding_shapes_color (tl::Color c)
{
if (c != m_guiding_shape_color) {
m_guiding_shape_color = c;
@ -4107,7 +4183,7 @@ LayoutViewBase::drop_small_cells_cond (drop_small_cells_cond_type t)
}
void
LayoutViewBase::cell_box_color (lay::Color c)
LayoutViewBase::cell_box_color (tl::Color c)
{
if (c != m_box_color) {
m_box_color = c;
@ -4229,7 +4305,7 @@ LayoutViewBase::set_palette (const lay::LineStylePalette &p)
}
void
LayoutViewBase::ctx_color (lay::Color c)
LayoutViewBase::ctx_color (tl::Color c)
{
if (c != m_ctx_color) {
m_ctx_color = c;
@ -4256,7 +4332,7 @@ LayoutViewBase::ctx_hollow (bool h)
}
void
LayoutViewBase::child_ctx_color (lay::Color c)
LayoutViewBase::child_ctx_color (tl::Color c)
{
if (c != m_child_ctx_color) {
m_child_ctx_color = c;
@ -4312,20 +4388,20 @@ LayoutViewBase::abstract_mode_enabled (bool e)
}
}
lay::Color
tl::Color
LayoutViewBase::default_background_color ()
{
return lay::Color (0, 0, 0); // black.
return tl::Color (0, 0, 0); // black.
}
void
LayoutViewBase::do_set_background_color (lay::Color /*color*/, lay::Color /*contrast*/)
LayoutViewBase::do_set_background_color (tl::Color /*color*/, tl::Color /*contrast*/)
{
// .. nothing yet ..
}
void
LayoutViewBase::background_color (lay::Color c)
LayoutViewBase::background_color (tl::Color c)
{
if (c == mp_canvas->background_color ()) {
return;
@ -4336,11 +4412,11 @@ LayoutViewBase::background_color (lay::Color c)
c = default_background_color ();
}
lay::Color contrast;
tl::Color contrast;
if (c.to_mono ()) {
contrast = lay::Color (0, 0, 0);
contrast = tl::Color (0, 0, 0);
} else {
contrast = lay::Color (255, 255, 255);
contrast = tl::Color (255, 255, 255);
}
do_set_background_color (c, contrast);
@ -4950,7 +5026,7 @@ LayoutViewBase::show_markers (bool f)
}
void
LayoutViewBase::text_color (lay::Color c)
LayoutViewBase::text_color (tl::Color c)
{
if (m_text_color != c) {
m_text_color = c;
@ -5332,6 +5408,110 @@ LayoutViewBase::default_mode ()
return 0; // TODO: any generic scheme? is select, should be ruler..
}
static std::string
name_from_title (const std::string &title)
{
std::string s = title;
std::string::size_type tab = s.find ('\t');
if (tab != std::string::npos) {
s = std::string (s, 0, tab);
}
std::string::size_type colon = s.find (':');
if (colon != std::string::npos) {
s = std::string (s, 0, colon);
}
return s;
}
static bool
edit_mode_from_title (const std::string &title)
{
std::string s = title;
std::string::size_type tab = s.find ('\t');
if (tab != std::string::npos) {
s = std::string (s, 0, tab);
}
std::vector<std::string> parts = tl::split (s, ":");
for (auto i = parts.begin (); i != parts.end (); ++i) {
if (*i == "edit_mode") {
return true;
}
}
return false;
}
std::vector<std::string>
LayoutViewBase::mode_names () const
{
std::vector<std::string> names;
std::vector<std::string> intrinsic_modes;
intrinsic_mouse_modes (&intrinsic_modes);
for (auto i = intrinsic_modes.begin (); i != intrinsic_modes.end (); ++i) {
names.push_back (name_from_title (*i));
}
for (auto i = mp_plugins.begin (); i != mp_plugins.end (); ++i) {
std::string title;
if ((*i) && (*i)->plugin_declaration () && (*i)->plugin_declaration ()->implements_mouse_mode (title)) {
if (is_editable () || !edit_mode_from_title (title)) {
names.push_back (name_from_title (title));
}
}
}
return names;
}
std::string
LayoutViewBase::mode_name () const
{
if (m_mode <= 0) {
std::vector<std::string> intrinsic_modes;
intrinsic_mouse_modes (&intrinsic_modes);
if (int (intrinsic_modes.size ()) > -m_mode) {
return name_from_title (intrinsic_modes [-m_mode]);
}
} else {
for (auto i = mp_plugins.begin (); i != mp_plugins.end (); ++i) {
std::string title;
if ((*i) && (*i)->plugin_declaration () && (*i)->plugin_declaration ()->id () == m_mode && (*i)->plugin_declaration ()->implements_mouse_mode (title)) {
return name_from_title (title);
}
}
}
return std::string ();
}
void
LayoutViewBase::switch_mode (const std::string &name)
{
std::vector<std::string> intrinsic_modes;
intrinsic_mouse_modes (&intrinsic_modes);
for (auto i = intrinsic_modes.begin (); i != intrinsic_modes.end (); ++i) {
if (name_from_title (*i) == name) {
switch_mode (int (0 - int (i - intrinsic_modes.begin ())));
return;
}
}
for (auto i = mp_plugins.begin (); i != mp_plugins.end (); ++i) {
std::string title;
if ((*i) && (*i)->plugin_declaration () && (*i)->plugin_declaration ()->implements_mouse_mode (title)) {
if (name_from_title (title) == name) {
switch_mode ((*i)->plugin_declaration ()->id ());
return;
}
}
}
}
std::vector<std::string>
LayoutViewBase::menu_symbols ()
{

View File

@ -123,7 +123,7 @@ struct LAYBASIC_PUBLIC LayerDisplayProperties
* The effective frame color is computed from the frame color brightness and the
* frame color.
*/
color_t eff_frame_color () const;
tl::color_t eff_frame_color () const;
/**
* @brief render the effective frame color
@ -131,11 +131,11 @@ struct LAYBASIC_PUBLIC LayerDisplayProperties
* The effective frame color is computed from the frame color brightness and the
* frame color.
*/
color_t eff_fill_color () const;
tl::color_t eff_fill_color () const;
// display styles
color_t frame_color;
color_t fill_color;
tl::color_t frame_color;
tl::color_t fill_color;
int frame_brightness;
int fill_brightness;
unsigned int dither_pattern;
@ -155,9 +155,6 @@ struct LAYBASIC_PUBLIC LayerDisplayProperties
* It manages the layer display list, bookmark list etc.
*/
class LAYBASIC_PUBLIC LayoutViewBase :
#if defined(HAVE_QT)
public QFrame,
#endif
public lay::Editables,
public lay::Dispatcher
{
@ -195,20 +192,12 @@ public:
/**
* @brief Constructor
*/
#if defined(HAVE_QT)
LayoutViewBase (QWidget *parent, lay::LayoutView *ui, db::Manager *mgr, bool editable, lay::Plugin *plugin_parent, unsigned int options = (unsigned int) LV_Normal);
#else
LayoutViewBase (lay::LayoutView *ui, db::Manager *mgr, bool editable, lay::Plugin *plugin_parent, unsigned int options = (unsigned int) LV_Normal);
#endif
/**
* @brief Constructor (clone from another view)
*/
#if defined(HAVE_QT)
LayoutViewBase (QWidget *widget, lay::LayoutView *ui, lay::LayoutViewBase *source, db::Manager *mgr, bool editable, lay::Plugin *plugin_parent, unsigned int options = (unsigned int) LV_Normal);
#else
LayoutViewBase (lay::LayoutView *ui, lay::LayoutViewBase *source, db::Manager *mgr, bool editable, lay::Plugin *plugin_parent, unsigned int options = (unsigned int) LV_Normal);
#endif
/**
* @brief Destructor
@ -231,6 +220,23 @@ public:
*/
virtual void switch_mode (int m);
/**
* @brief Gets the name of the active mode
*/
std::string mode_name () const;
/**
* @brief Switches the mode according to the given name
*
* The name must be one of the names provided by "mode_names".
*/
void switch_mode (const std::string &name);
/**
* @brief Gets the names of the available modes
*/
std::vector<std::string> mode_names () const;
/**
* @brief Determine if there is something to copy
*
@ -810,6 +816,13 @@ public:
*/
void load_layer_props (const std::string &fn, int cv_index, bool add_default);
/**
* @brief Determine whether a given layer properties file is a single-layout file
*
* @return True, if the file contains definitions of a single layout only.
*/
static bool is_single_cv_layer_properties_file (const std::string &fn);
/**
* @brief Bookmark the current view under the given name
*/
@ -841,9 +854,9 @@ public:
#endif
/**
* @brief Gets the screen content as a lay::PixelBuffer object
* @brief Gets the screen content as a tl::PixelBuffer object
*/
lay::PixelBuffer get_screenshot_pb ();
tl::PixelBuffer get_screenshot_pb ();
/**
* @brief Save an image file with the given width and height
@ -859,13 +872,13 @@ public:
* @param linewidth The width of a line in pixels (usually 1) or 0 for default
* @param oversampling The oversampling factor (1..3) or 0 for default
* @param resolution The resolution (pixel size compared to a screen pixel size, i.e 1/oversampling) or 0 for default
* @param background The background color or lay::Color() for default
* @param foreground The foreground color or lay::Color() for default
* @param active The active color or lay::Color() for default
* @param background The background color or tl::Color() for default
* @param foreground The foreground color or tl::Color() for default
* @param active The active color or tl::Color() for default
* @param target_box The box to draw or db::DBox() for default
* @param monochrome If true, monochrome images will be produced
*/
void save_image_with_options (const std::string &fn, unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, Color background, Color foreground, Color active_color, const db::DBox &target_box, bool monochrome);
void save_image_with_options (const std::string &fn, unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, tl::Color background, tl::Color foreground, tl::Color active_color, const db::DBox &target_box, bool monochrome);
#if defined(HAVE_QT)
/**
@ -875,9 +888,9 @@ public:
#endif
/**
* @brief Gets the screen content as a lay::PixelBuffer object
* @brief Gets the screen content as a tl::PixelBuffer object
*/
lay::PixelBuffer get_pixels (unsigned int width, unsigned int height);
tl::PixelBuffer get_pixels (unsigned int width, unsigned int height);
#if defined(HAVE_QT)
/**
@ -888,46 +901,46 @@ public:
* @param linewidth The width of a line in pixels (usually 1) or 0 for default
* @param oversampling The oversampling factor (1..3) or 0 for default
* @param resolution The resolution (pixel size compared to a screen pixel size, i.e 1/oversampling) or 0 for default
* @param background The background color or lay::Color() for default
* @param foreground The foreground color or lay::Color() for default
* @param active The active color or lay::Color() for default
* @param background The background color or tl::Color() for default
* @param foreground The foreground color or tl::Color() for default
* @param active The active color or tl::Color() for default
* @param target_box The box to draw or db::DBox() for default
* @param monochrome If true, monochrome images will be produced
*/
QImage get_image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, lay::Color background, lay::Color foreground, lay::Color active_color, const db::DBox &target_box, bool monochrome);
QImage get_image_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, tl::Color background, tl::Color foreground, tl::Color active_color, const db::DBox &target_box, bool monochrome);
#endif
/**
* @brief Get the screen content as a lay::PixelBuffer object with the given width and height
* @brief Get the screen content as a tl::PixelBuffer object with the given width and height
*
* @param width The width of the image in pixels
* @param height The height of the image
* @param linewidth The width of a line in pixels (usually 1) or 0 for default
* @param oversampling The oversampling factor (1..3) or 0 for default
* @param resolution The resolution (pixel size compared to a screen pixel size, i.e 1/oversampling) or 0 for default
* @param background The background color or lay::Color() for default
* @param foreground The foreground color or lay::Color() for default
* @param active The active color or lay::Color() for default
* @param background The background color or tl::Color() for default
* @param foreground The foreground color or tl::Color() for default
* @param active The active color or tl::Color() for default
* @param target_box The box to draw or db::DBox() for default
*/
lay::PixelBuffer get_pixels_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, lay::Color background, lay::Color foreground, lay::Color active_color, const db::DBox &target_box);
tl::PixelBuffer get_pixels_with_options (unsigned int width, unsigned int height, int linewidth, int oversampling, double resolution, tl::Color background, tl::Color foreground, tl::Color active_color, const db::DBox &target_box);
/**
* @brief Get the screen content as a monochrome lay::BitmapBuffer object with the given options
* @brief Get the screen content as a monochrome tl::BitmapBuffer object with the given options
*
* @param width The width of the image in pixels
* @param height The height of the image
* @param linewidth The width of a line in pixels (usually 1) or 0 for default
* @param oversampling The oversampling factor (1..3) or 0 for default
* @param resolution The resolution (pixel size compared to a screen pixel size, i.e 1/oversampling) or 0 for default
* @param background The background color or lay::Color() for default
* @param foreground The foreground color or lay::Color() for default
* @param active The active color or lay::Color() for default
* @param background The background color or tl::Color() for default
* @param foreground The foreground color or tl::Color() for default
* @param active The active color or tl::Color() for default
* @param target_box The box to draw or db::DBox() for default
*
* The colors will are converted to "on" pixels with a green channel value >= 50%.
*/
lay::BitmapBuffer get_pixels_with_options_mono (unsigned int width, unsigned int height, int linewidth, lay::Color background, lay::Color foreground, lay::Color active_color, const db::DBox &target_box);
tl::BitmapBuffer get_pixels_with_options_mono (unsigned int width, unsigned int height, int linewidth, tl::Color background, tl::Color foreground, tl::Color active_color, const db::DBox &target_box);
/**
* @brief Hierarchy level selection setter
@ -984,12 +997,12 @@ public:
/**
* @brief Cell box/label color setter
*/
void cell_box_color (lay::Color c);
void cell_box_color (tl::Color c);
/**
* @brief Cell box/label getter
*/
lay::Color cell_box_color () const
tl::Color cell_box_color () const
{
return m_box_color;
}
@ -1182,12 +1195,12 @@ public:
/**
* @brief Text object color
*/
void text_color (lay::Color c);
void text_color (tl::Color c);
/**
* @brief Text object color
*/
lay::Color text_color () const
tl::Color text_color () const
{
return m_text_color;
}
@ -1648,13 +1661,13 @@ public:
void absolute_coordinates (bool f);
/**
* @brief Get the view object widget
* @brief Gets the canvas object (where the layout is drawn and view objects are placed)
*
* This method intentionally delivers the ViewObjectWidget, not the
* LayoutCanvas to emphasize that the LayoutCanvas object shall not
* be modified.
*/
lay::ViewObjectWidget *view_object_widget ()
lay::LayoutCanvas *canvas ()
{
return mp_canvas;
}
@ -1701,7 +1714,7 @@ public:
/**
* @brief Background color property
*/
lay::Color background_color () const
tl::Color background_color () const
{
return mp_canvas->background_color ();
}
@ -1709,7 +1722,7 @@ public:
/**
* @brief Foreground color property
*/
lay::Color foreground_color () const
tl::Color foreground_color () const
{
return mp_canvas->foreground_color ();
}
@ -1717,7 +1730,7 @@ public:
/**
* @brief Active color property
*/
lay::Color active_color () const
tl::Color active_color () const
{
return mp_canvas->active_color ();
}
@ -1777,7 +1790,7 @@ public:
/**
* @brief Gets the guiding shapes color
*/
lay::Color guiding_shapes_color () const
tl::Color guiding_shapes_color () const
{
return m_guiding_shape_color;
}
@ -1785,7 +1798,7 @@ public:
/**
* @brief Sets the guiding shapes color
*/
void guiding_shapes_color (lay::Color c);
void guiding_shapes_color (tl::Color c);
/**
* @brief Gets the guiding shapes line width
@ -2209,7 +2222,7 @@ public:
/**
* @brief Get the default color for markers
*/
lay::Color default_marker_color () const
tl::Color default_marker_color () const
{
return m_marker_color;
}
@ -2638,7 +2651,7 @@ public:
/**
* @brief Gets the QWidget interface
*/
QWidget *widget ();
virtual QWidget *widget ();
#endif
/**
@ -2691,15 +2704,15 @@ private:
int m_paste_display_mode;
int m_wheel_mode;
bool m_guiding_shape_visible;
lay::Color m_guiding_shape_color;
tl::Color m_guiding_shape_color;
int m_guiding_shape_line_width;
int m_guiding_shape_vertex_size;
lay::Color m_ctx_color;
tl::Color m_ctx_color;
int m_ctx_dimming;
bool m_ctx_hollow;
lay::Color m_child_ctx_color;
tl::Color m_child_ctx_color;
int m_child_ctx_dimming;
bool m_child_ctx_hollow;
bool m_child_ctx_enabled;
@ -2707,13 +2720,13 @@ private:
double m_abstract_mode_width;
bool m_abstract_mode_enabled;
lay::Color m_box_color;
tl::Color m_box_color;
bool m_box_text_transform;
unsigned int m_box_font;
int m_min_size_for_label;
bool m_cell_box_visible;
lay::Color m_marker_color;
tl::Color m_marker_color;
int m_marker_line_width;
int m_marker_vertex_size;
int m_marker_dither_pattern;
@ -2731,7 +2744,7 @@ private:
bool m_text_lazy_rendering;
bool m_bitmap_caching;
bool m_show_properties;
lay::Color m_text_color;
tl::Color m_text_color;
bool m_apply_text_trans;
double m_default_text_size;
unsigned int m_text_font;
@ -2801,11 +2814,11 @@ private:
void do_redraw ();
void set_view_ops ();
void background_color (lay::Color c);
void ctx_color (lay::Color c);
void background_color (tl::Color c);
void ctx_color (tl::Color c);
void ctx_dimming (int percent);
void ctx_hollow (bool h);
void child_ctx_color (lay::Color c);
void child_ctx_color (tl::Color c);
void child_ctx_dimming (int percent);
void child_ctx_hollow (bool h);
void child_ctx_enabled (bool e);
@ -2836,11 +2849,6 @@ protected:
virtual LayoutView *get_ui ();
lay::LayoutCanvas *canvas ()
{
return mp_canvas;
}
bool configure (const std::string &name, const std::string &value);
void config_finalize ();
@ -2852,9 +2860,12 @@ protected:
virtual void create_plugins (const lay::PluginDeclaration *except_this = 0);
void free_resources ();
void shutdown ();
void finish ();
void init_menu ();
virtual lay::Color default_background_color ();
virtual void do_set_background_color (lay::Color color, lay::Color contrast);
virtual tl::Color default_background_color ();
virtual void do_set_background_color (tl::Color color, tl::Color contrast);
virtual void do_paste ();
virtual void begin_layer_updates ();
virtual void end_layer_updates ();

View File

@ -0,0 +1,123 @@
/*
KLayout Layout Viewer
Copyright (C) 2006-2022 Matthias Koefferlein
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "laybasicConfig.h"
#include "layConverters.h"
#include "layColorPalette.h"
#include "layStipplePalette.h"
#include "layLineStylePalette.h"
#include "layPlugin.h"
#include "tlColor.h"
namespace lay
{
// ------------------------------------------------------------
// The dummy plugin declaration to register the configuration options
class LayoutViewBasicConfigDeclaration
: public lay::PluginDeclaration
{
public:
virtual void get_options (std::vector < std::pair<std::string, std::string> > &options) const
{
lay::ColorConverter cc;
options.push_back (std::pair<std::string, std::string> (cfg_default_lyp_file, ""));
options.push_back (std::pair<std::string, std::string> (cfg_default_add_other_layers, "false"));
options.push_back (std::pair<std::string, std::string> (cfg_layers_always_show_source, "false"));
options.push_back (std::pair<std::string, std::string> (cfg_layers_always_show_ld, "true"));
options.push_back (std::pair<std::string, std::string> (cfg_layers_always_show_layout_index, "false"));
options.push_back (std::pair<std::string, std::string> (cfg_test_shapes_in_view, "false"));
options.push_back (std::pair<std::string, std::string> (cfg_flat_cell_list, "false"));
options.push_back (std::pair<std::string, std::string> (cfg_split_cell_list, "false"));
options.push_back (std::pair<std::string, std::string> (cfg_cell_list_sorting, "by-name"));
options.push_back (std::pair<std::string, std::string> (cfg_split_lib_views, "false"));
options.push_back (std::pair<std::string, std::string> (cfg_current_lib_view, ""));
options.push_back (std::pair<std::string, std::string> (cfg_hide_empty_layers, "false"));
options.push_back (std::pair<std::string, std::string> (cfg_min_inst_label_size, "16"));
options.push_back (std::pair<std::string, std::string> (cfg_cell_box_text_font, "0"));
options.push_back (std::pair<std::string, std::string> (cfg_cell_box_text_transform, "true"));
options.push_back (std::pair<std::string, std::string> (cfg_cell_box_color, "auto"));
options.push_back (std::pair<std::string, std::string> (cfg_cell_box_visible, "true"));
options.push_back (std::pair<std::string, std::string> (cfg_text_color, "auto"));
options.push_back (std::pair<std::string, std::string> (cfg_text_visible, "true"));
options.push_back (std::pair<std::string, std::string> (cfg_text_lazy_rendering, "true"));
options.push_back (std::pair<std::string, std::string> (cfg_bitmap_caching, "true"));
options.push_back (std::pair<std::string, std::string> (cfg_show_properties, "false"));
options.push_back (std::pair<std::string, std::string> (cfg_apply_text_trans, "true"));
options.push_back (std::pair<std::string, std::string> (cfg_global_trans, "r0"));
options.push_back (std::pair<std::string, std::string> (cfg_default_text_size, "0.1"));
options.push_back (std::pair<std::string, std::string> (cfg_text_font, "0"));
options.push_back (std::pair<std::string, std::string> (cfg_sel_color, cc.to_string (tl::Color ())));
options.push_back (std::pair<std::string, std::string> (cfg_sel_line_width, "1"));
options.push_back (std::pair<std::string, std::string> (cfg_sel_vertex_size, "3"));
options.push_back (std::pair<std::string, std::string> (cfg_sel_dither_pattern, "1"));
options.push_back (std::pair<std::string, std::string> (cfg_sel_halo, "true"));
options.push_back (std::pair<std::string, std::string> (cfg_sel_transient_mode, "true"));
options.push_back (std::pair<std::string, std::string> (cfg_sel_inside_pcells_mode, "false"));
options.push_back (std::pair<std::string, std::string> (cfg_tracking_cursor_enabled, "true"));
options.push_back (std::pair<std::string, std::string> (cfg_tracking_cursor_color, cc.to_string (tl::Color ())));
options.push_back (std::pair<std::string, std::string> (cfg_background_color, cc.to_string (tl::Color ())));
options.push_back (std::pair<std::string, std::string> (cfg_ctx_color, cc.to_string (tl::Color ())));
options.push_back (std::pair<std::string, std::string> (cfg_ctx_dimming, "50"));
options.push_back (std::pair<std::string, std::string> (cfg_ctx_hollow, "false"));
options.push_back (std::pair<std::string, std::string> (cfg_child_ctx_color, cc.to_string (tl::Color ())));
options.push_back (std::pair<std::string, std::string> (cfg_child_ctx_dimming, "50"));
options.push_back (std::pair<std::string, std::string> (cfg_child_ctx_hollow, "false"));
options.push_back (std::pair<std::string, std::string> (cfg_child_ctx_enabled, "false"));
options.push_back (std::pair<std::string, std::string> (cfg_search_range, "5"));
options.push_back (std::pair<std::string, std::string> (cfg_search_range_box, "0"));
options.push_back (std::pair<std::string, std::string> (cfg_abstract_mode_width, "10.0"));
options.push_back (std::pair<std::string, std::string> (cfg_abstract_mode_enabled, "false"));
options.push_back (std::pair<std::string, std::string> (cfg_fit_new_cell, "true"));
options.push_back (std::pair<std::string, std::string> (cfg_full_hier_new_cell, "false"));
options.push_back (std::pair<std::string, std::string> (cfg_initial_hier_depth, "1"));
options.push_back (std::pair<std::string, std::string> (cfg_clear_ruler_new_cell, "false"));
options.push_back (std::pair<std::string, std::string> (cfg_mouse_wheel_mode, "0"));
options.push_back (std::pair<std::string, std::string> (cfg_pan_distance, "0.15"));
options.push_back (std::pair<std::string, std::string> (cfg_paste_display_mode, "2"));
options.push_back (std::pair<std::string, std::string> (cfg_guiding_shape_visible, "true"));
options.push_back (std::pair<std::string, std::string> (cfg_guiding_shape_line_width, "1"));
options.push_back (std::pair<std::string, std::string> (cfg_guiding_shape_color, cc.to_string (tl::Color ())));
options.push_back (std::pair<std::string, std::string> (cfg_guiding_shape_vertex_size, "5"));
options.push_back (std::pair<std::string, std::string> (cfg_abs_units, "false"));
options.push_back (std::pair<std::string, std::string> (cfg_dbu_units, "false"));
options.push_back (std::pair<std::string, std::string> (cfg_drawing_workers, "1"));
options.push_back (std::pair<std::string, std::string> (cfg_drop_small_cells, "false"));
options.push_back (std::pair<std::string, std::string> (cfg_drop_small_cells_cond, "0"));
options.push_back (std::pair<std::string, std::string> (cfg_drop_small_cells_value, "10"));
options.push_back (std::pair<std::string, std::string> (cfg_array_border_instances, "false"));
options.push_back (std::pair<std::string, std::string> (cfg_bitmap_oversampling, "1"));
options.push_back (std::pair<std::string, std::string> (cfg_image_cache_size, "1"));
options.push_back (std::pair<std::string, std::string> (cfg_default_font_size, "0"));
options.push_back (std::pair<std::string, std::string> (cfg_color_palette, lay::ColorPalette ().to_string ()));
options.push_back (std::pair<std::string, std::string> (cfg_stipple_palette, lay::StipplePalette ().to_string ()));
options.push_back (std::pair<std::string, std::string> (cfg_stipple_offset, "true"));
options.push_back (std::pair<std::string, std::string> (cfg_line_style_palette, lay::LineStylePalette ().to_string ()));
options.push_back (std::pair<std::string, std::string> (cfg_no_stipple, "false"));
options.push_back (std::pair<std::string, std::string> (cfg_markers_visible, "true"));
}
};
static tl::RegisteredClass<lay::PluginDeclaration> config_decl (new LayoutViewBasicConfigDeclaration (), 1990, "LayoutViewBasicConfig");
}

View File

@ -189,14 +189,14 @@ void render_cell_inst (const db::Layout &layout, const db::CellInstArray &inst,
// ------------------------------------------------------------------------
MarkerBase::MarkerBase (lay::LayoutViewBase *view)
: lay::ViewObject (view->view_object_widget ()),
: lay::ViewObject (view->canvas ()),
m_line_width (-1), m_vertex_size (-1), m_halo (-1), m_text_enabled (true), m_vertex_shape (lay::ViewOp::Rect), m_line_style (-1), m_dither_pattern (-1), m_frame_pattern (0), mp_view (view)
{
// .. nothing yet ..
}
void
MarkerBase::set_frame_color (lay::Color color)
MarkerBase::set_frame_color (tl::Color color)
{
if (color != m_frame_color) {
m_frame_color = color;
@ -205,7 +205,7 @@ MarkerBase::set_frame_color (lay::Color color)
}
void
MarkerBase::set_color (lay::Color color)
MarkerBase::set_color (tl::Color color)
{
if (color != m_color) {
m_color = color;
@ -292,7 +292,7 @@ MarkerBase::get_bitmaps (const Viewport & /*vp*/, ViewObjectCanvas &canvas, lay:
int basic_width = int(0.5 + 1.0 / resolution);
// obtain bitmaps
lay::Color color = m_color;
tl::Color color = m_color;
if (! color.is_valid ()) {
color = mp_view->default_marker_color ();
}
@ -300,7 +300,7 @@ MarkerBase::get_bitmaps (const Viewport & /*vp*/, ViewObjectCanvas &canvas, lay:
color = canvas.foreground_color ();
}
lay::Color frame_color = m_frame_color;
tl::Color frame_color = m_frame_color;
if (! frame_color.is_valid ()) {
frame_color = color;
}

View File

@ -66,7 +66,7 @@ public:
*
* If the color is invalid, the marker is drawn with the canvases foreground color.
*/
lay::Color get_color () const
tl::Color get_color () const
{
return m_color;
}
@ -76,14 +76,14 @@ public:
*
* If the color is invalid, the marker is drawn with the canvases foreground color.
*/
void set_color (lay::Color color);
void set_color (tl::Color color);
/**
* @brief Get the color by which the marker's frame is drawn
*
* If the color is invalid, the marker's frame is drawn with the fill color.
*/
lay::Color get_frame_color () const
tl::Color get_frame_color () const
{
return m_frame_color;
}
@ -93,7 +93,7 @@ public:
*
* If the color is invalid, the marker's frame is drawn with the fill color.
*/
void set_frame_color (lay::Color color);
void set_frame_color (tl::Color color);
/**
* @brief Get the line width with which the marker is drawn
@ -226,8 +226,8 @@ public:
protected:
void get_bitmaps (const Viewport &vp, ViewObjectCanvas &canvas, lay::CanvasPlane *&fill, lay::CanvasPlane *&frame, lay::CanvasPlane *&vertex, lay::CanvasPlane *&text);
lay::Color m_color;
lay::Color m_frame_color;
tl::Color m_color;
tl::Color m_frame_color;
char m_line_width, m_vertex_size, m_halo;
bool m_text_enabled;
lay::ViewOp::Shape m_vertex_shape;

View File

@ -29,9 +29,9 @@ namespace lay
{
MouseTracker::MouseTracker (lay::LayoutViewBase *view)
: lay::ViewService (view->view_object_widget ()), mp_view (view)
: lay::ViewService (view->canvas ()), mp_view (view)
{
widget ()->grab_mouse (this, false);
ui ()->grab_mouse (this, false);
}
bool
@ -42,7 +42,7 @@ MouseTracker::mouse_move_event (const db::DPoint &p, unsigned int /*buttons*/, b
// NOTE: because the tracker grabs first and grabbers are registered first gets served last, the
// tracker will receive the event after all other mouse grabbers have been served and had their
// chance to set the tracking position.
lay::ViewService *vs = mp_view->view_object_widget ()->active_service ();
lay::ViewService *vs = mp_view->canvas ()->active_service ();
db::DPoint tp = p;
if (vs && vs->enabled () && vs->has_tracking_position ()) {
tp = vs->tracking_position ();

View File

@ -35,7 +35,7 @@ namespace lay
// MoveService implementation
MoveService::MoveService (lay::LayoutViewBase *view)
: lay::ViewService (view->view_object_widget ()),
: lay::ViewService (view->canvas ()),
m_dragging (false),
m_dragging_transient (false),
mp_editables (view),
@ -102,7 +102,7 @@ MoveService::key_event (unsigned int key, unsigned int /*buttons*/)
if (! m_dragging && fabs (dx + dy) > 0.0 && mp_editables->has_selection ()) {
// determine a shift distance which is 2, 5 or 10 times the grid and is more than 5 pixels
double dmin = double (5 /*pixels min shift*/) / widget ()->mouse_event_trans ().mag ();
double dmin = double (5 /*pixels min shift*/) / ui ()->mouse_event_trans ().mag ();
double d = m_global_grid;
while (d < dmin) {
d *= 2.0;
@ -302,7 +302,7 @@ MoveService::handle_click (const db::DPoint &p, unsigned int buttons, bool drag_
m_dragging = true;
m_dragging_transient = drag_transient;
widget ()->grab_mouse (this, false);
ui ()->grab_mouse (this, false);
m_shift = db::DPoint ();
@ -314,7 +314,7 @@ MoveService::handle_click (const db::DPoint &p, unsigned int buttons, bool drag_
m_dragging = false;
widget ()->ungrab_mouse (this);
ui ()->ungrab_mouse (this);
mp_editables->end_move (p, ac_from_buttons (buttons), mp_transaction.release ());
if (m_dragging_transient) {
@ -334,7 +334,7 @@ MoveService::drag_cancel ()
if (m_dragging) {
mp_editables->edit_cancel ();
widget ()->ungrab_mouse (this);
ui ()->ungrab_mouse (this);
m_dragging = false;

View File

@ -38,7 +38,7 @@ NetColorizer::NetColorizer ()
}
void
NetColorizer::configure (const lay::Color &marker_color, const lay::ColorPalette *auto_colors)
NetColorizer::configure (const tl::Color &marker_color, const lay::ColorPalette *auto_colors)
{
m_marker_color = marker_color;
if (auto_colors) {
@ -58,7 +58,7 @@ NetColorizer::has_color_for_net (const db::Net *net)
}
void
NetColorizer::set_color_of_net (const db::Net *net, const lay::Color &color)
NetColorizer::set_color_of_net (const db::Net *net, const tl::Color &color)
{
m_custom_color[net] = color;
emit_colors_changed ();
@ -110,14 +110,14 @@ NetColorizer::emit_colors_changed ()
}
}
lay::Color
tl::Color
NetColorizer::color_of_net (const db::Net *net) const
{
if (! net) {
return lay::Color ();
return tl::Color ();
}
std::map<const db::Net *, lay::Color>::const_iterator c = m_custom_color.find (net);
std::map<const db::Net *, tl::Color>::const_iterator c = m_custom_color.find (net);
if (c != m_custom_color.end ()) {
return c->second;
}
@ -146,7 +146,7 @@ NetColorizer::color_of_net (const db::Net *net) const
return m_auto_colors.color_by_index ((unsigned int) index);
} else {
return lay::Color ();
return tl::Color ();
}
}

View File

@ -26,7 +26,7 @@
#include "laybasicCommon.h"
#include "layColorPalette.h"
#include "layColor.h"
#include "tlColor.h"
#include "tlEvents.h"
#include <map>
@ -49,15 +49,15 @@ class LAYBASIC_PUBLIC NetColorizer
public:
NetColorizer ();
void configure (const lay::Color &marker_color, const lay::ColorPalette *auto_colors);
void configure (const tl::Color &marker_color, const lay::ColorPalette *auto_colors);
bool has_color_for_net (const db::Net *net);
void set_color_of_net (const db::Net *net, const lay::Color &color);
void set_color_of_net (const db::Net *net, const tl::Color &color);
void reset_color_of_net (const db::Net *net);
void clear ();
lay::Color color_of_net (const db::Net *net) const;
tl::Color color_of_net (const db::Net *net) const;
const lay::Color &marker_color () const
const tl::Color &marker_color () const
{
return m_marker_color;
}
@ -68,10 +68,10 @@ public:
tl::Event colors_changed;
private:
lay::Color m_marker_color;
tl::Color m_marker_color;
lay::ColorPalette m_auto_colors;
bool m_auto_colors_enabled;
std::map<const db::Net *, lay::Color> m_custom_color;
std::map<const db::Net *, tl::Color> m_custom_color;
bool m_update_needed;
bool m_signals_enabled;
mutable std::map<const db::Net *, size_t> m_net_index_by_object;

View File

@ -23,12 +23,12 @@
#include "layPixelBufferPainter.h"
#include "layFixedFont.h"
#include "layPixelBuffer.h"
#include "tlPixelBuffer.h"
namespace lay
{
PixelBufferPainter::PixelBufferPainter (lay::PixelBuffer &img, unsigned int width, unsigned int height, double resolution)
PixelBufferPainter::PixelBufferPainter (tl::PixelBuffer &img, unsigned int width, unsigned int height, double resolution)
: mp_img (&img),
m_resolution (resolution), m_width (width), m_height (height)
{
@ -36,7 +36,7 @@ PixelBufferPainter::PixelBufferPainter (lay::PixelBuffer &img, unsigned int widt
}
void
PixelBufferPainter::set (const db::Point &p, lay::Color c)
PixelBufferPainter::set (const db::Point &p, tl::Color c)
{
if (p.x () >= 0 && p.x () < m_width && p.y () >= 0 && p.y () < m_height) {
((unsigned int *) mp_img->scan_line (p.y ())) [p.x ()] = c.rgb ();
@ -44,7 +44,7 @@ PixelBufferPainter::set (const db::Point &p, lay::Color c)
}
void
PixelBufferPainter::draw_line (const db::Point &p1, const db::Point &p2, lay::Color c)
PixelBufferPainter::draw_line (const db::Point &p1, const db::Point &p2, tl::Color c)
{
if (p1.x () == p2.x ()) {
@ -79,7 +79,7 @@ PixelBufferPainter::draw_line (const db::Point &p1, const db::Point &p2, lay::Co
}
void
PixelBufferPainter::fill_rect (const db::Point &p1, const db::Point &p2, lay::Color c)
PixelBufferPainter::fill_rect (const db::Point &p1, const db::Point &p2, tl::Color c)
{
int y1 = std::min (p1.y (), p2.y ());
int y2 = std::max (p1.y (), p2.y ());
@ -89,7 +89,7 @@ PixelBufferPainter::fill_rect (const db::Point &p1, const db::Point &p2, lay::Co
}
void
PixelBufferPainter::draw_rect (const db::Point &p1, const db::Point &p2, lay::Color c)
PixelBufferPainter::draw_rect (const db::Point &p1, const db::Point &p2, tl::Color c)
{
int y1 = std::min (p1.y (), p2.y ());
int y2 = std::max (p1.y (), p2.y ());
@ -102,7 +102,7 @@ PixelBufferPainter::draw_rect (const db::Point &p1, const db::Point &p2, lay::Co
}
void
PixelBufferPainter::draw_text (const char *t, const db::Point &p, lay::Color c, int halign, int valign)
PixelBufferPainter::draw_text (const char *t, const db::Point &p, tl::Color c, int halign, int valign)
{
const lay::FixedFont &ff = lay::FixedFont::get_font (m_resolution);
int x = p.x (), y = p.y ();

View File

@ -25,15 +25,18 @@
#include "laybasicCommon.h"
#include "layColor.h"
#include "tlColor.h"
#include "dbPoint.h"
namespace tl
{
class PixelBuffer;
}
namespace lay {
class PixelBuffer;
/**
* @brief A very simplistic painter for lay::PixelBuffer
* @brief A very simplistic painter for tl::PixelBuffer
*
* This painter supports very few primitives currently and is used to paint the
* background grid for example.
@ -41,16 +44,16 @@ class PixelBuffer;
class LAYBASIC_PUBLIC PixelBufferPainter
{
public:
PixelBufferPainter (lay::PixelBuffer &img, unsigned int width, unsigned int height, double resolution);
PixelBufferPainter (tl::PixelBuffer &img, unsigned int width, unsigned int height, double resolution);
void set (const db::Point &p, lay::Color c);
void draw_line (const db::Point &p1, const db::Point &p2, lay::Color c);
void fill_rect (const db::Point &p1, const db::Point &p2, lay::Color c);
void draw_rect (const db::Point &p1, const db::Point &p2, lay::Color c);
void draw_text (const char *t, const db::Point &p, lay::Color c, int halign, int valign);
void set (const db::Point &p, tl::Color c);
void draw_line (const db::Point &p1, const db::Point &p2, tl::Color c);
void fill_rect (const db::Point &p1, const db::Point &p2, tl::Color c);
void draw_rect (const db::Point &p1, const db::Point &p2, tl::Color c);
void draw_text (const char *t, const db::Point &p, tl::Color c, int halign, int valign);
private:
lay::PixelBuffer *mp_img;
tl::PixelBuffer *mp_img;
double m_resolution;
int m_width, m_height;
};

View File

@ -96,8 +96,6 @@ PluginDeclaration::menu_symbols ()
return symbols;
}
#if defined(HAVE_QT)
namespace {
class GenericMenuAction
@ -173,7 +171,9 @@ PluginDeclaration::init_menu (lay::Dispatcher *dispatcher)
}
mp_editable_mode_action.reset (new Action (title));
#if defined(HAVE_QT)
gtf::action_connect (mp_editable_mode_action->qaction (), SIGNAL (triggered ()), this, SLOT (toggle_editable_enabled ()));
#endif
mp_editable_mode_action->set_checkable (true);
mp_editable_mode_action->set_checked (m_editable_enabled);
@ -281,18 +281,14 @@ PluginDeclaration::remove_menu_items (Dispatcher *dispatcher)
m_menu_actions.clear ();
}
#endif
void
PluginDeclaration::set_editable_enabled (bool f)
{
if (f != m_editable_enabled) {
m_editable_enabled = f;
#if defined(HAVE_QT)
if (mp_editable_mode_action.get ()) {
mp_editable_mode_action->set_checked (f);
}
#endif
editable_enabled_changed_event ();
}
}
@ -443,17 +439,6 @@ Plugin::dispatcher ()
return dynamic_cast<Dispatcher *> (p);
}
Dispatcher *
Plugin::dispatcher_maybe_null ()
{
Plugin *p = this;
while (p->mp_parent) {
p = p->mp_parent;
}
return dynamic_cast<Dispatcher *> (p);
}
void
Plugin::do_config_setup (Plugin *target)
{

View File

@ -30,9 +30,7 @@
#include "tlClassRegistry.h"
#include "tlDeferredExecution.h"
#include "gsiObject.h"
#if defined(HAVE_QT)
# include "layAbstractMenu.h"
#endif
#include "layAbstractMenu.h"
#include <map>
#include <vector>
@ -393,7 +391,6 @@ public:
*/
static std::vector<std::string> menu_symbols ();
#if defined(HAVE_QT)
/**
* @brief Creates the menu resources for this plugin
*
@ -407,7 +404,6 @@ public:
* @brief Removes the menu resources associated with this plugin
*/
void remove_menu_items (lay::Dispatcher *dispatcher);
#endif
/**
* @brief Enables this editable part of the plugin
@ -462,24 +458,36 @@ private slots:
private:
int m_id;
#if defined(HAVE_QT)
tl::weak_ptr<lay::Action> mp_editable_mode_action;
tl::weak_ptr<lay::Action> mp_mouse_mode_action;
tl::weak_collection<lay::Action> m_menu_actions;
#endif
bool m_editable_enabled;
};
/**
* @brief The plugin interface
*
* Each configurable object must be derived from this interface.
* An configurable object can have a parent. This way, a hierarchy
* of configurable objects is created. The root object not having a
* parent acts as the main entry point: it will try to dispatch
* This is a basic interface providing several services in a
* hierarchically organized fashion. It also provides a configuration
* space (key/value pairs).
*
* Each object participating in the plugin scheme must be derived from this interface.
* An plugin can have a parent. This way, a hierarchy of plugin objects is created.
* The root object not having a parent acts as the main entry point: it will try to dispatch
* configuration requests to the children.
* A node may have a local configuration - it will override any
* parent configurations.
*
* Each node has a local configuration space which overrides the configuration changes
* made to be parent.
*
* Each plugin also has a static or global configuration space inside the
* "plugin declaration". Configuration changes made to top level nodes are
* reflected in the static space too.
*
* A "standalone" node is one without a parent, but which does not communicate
* with the static configuration space.
*
* The "Dispatcher" adds the concept of a (singleton) root plugin to this hierarchical
* configuration tree.
*/
class LAYBASIC_PUBLIC Plugin
@ -687,13 +695,6 @@ public:
*/
Dispatcher *dispatcher ();
/**
* @brief Gets the dispatcher (the top level end of the plugin chain)
* This version may return null, if the plugin is instantiated without a
* root.
*/
Dispatcher *dispatcher_maybe_null ();
/**
* @brief Menu command handler
*

View File

@ -392,7 +392,7 @@ BitmapRedrawThreadCanvas::initialize_plane (lay::CanvasPlane *plane, unsigned in
}
void
BitmapRedrawThreadCanvas::to_image (const std::vector <lay::ViewOp> &view_ops, const lay::DitherPattern &dp, const lay::LineStyles &ls, lay::Color background, lay::Color foreground, lay::Color active, const lay::Drawings *drawings, lay::PixelBuffer &img, unsigned int width, unsigned int height)
BitmapRedrawThreadCanvas::to_image (const std::vector <lay::ViewOp> &view_ops, const lay::DitherPattern &dp, const lay::LineStyles &ls, tl::Color background, tl::Color foreground, tl::Color active, const lay::Drawings *drawings, tl::PixelBuffer &img, unsigned int width, unsigned int height)
{
if (width > m_width) {
width = m_width;
@ -412,7 +412,7 @@ BitmapRedrawThreadCanvas::to_image (const std::vector <lay::ViewOp> &view_ops, c
}
void
BitmapRedrawThreadCanvas::to_image_mono (const std::vector <lay::ViewOp> &view_ops, const lay::DitherPattern &dp, const lay::LineStyles &ls, bool background, bool foreground, bool active, const lay::Drawings *drawings, lay::BitmapBuffer &img, unsigned int width, unsigned int height)
BitmapRedrawThreadCanvas::to_image_mono (const std::vector <lay::ViewOp> &view_ops, const lay::DitherPattern &dp, const lay::LineStyles &ls, bool background, bool foreground, bool active, const lay::Drawings *drawings, tl::BitmapBuffer &img, unsigned int width, unsigned int height)
{
if (width > m_width) {
width = m_width;

View File

@ -29,7 +29,7 @@
#include "dbTrans.h"
#include "layViewOp.h"
#include "layBitmapRenderer.h"
#include "layPixelBuffer.h"
#include "tlPixelBuffer.h"
#include "tlThreads.h"
#include <vector>
@ -319,12 +319,12 @@ public:
/**
* @brief Transfer the content to a PixelBuffer
*/
void to_image (const std::vector <lay::ViewOp> &view_ops, const lay::DitherPattern &dp, const lay::LineStyles &ls, lay::Color background, lay::Color foreground, lay::Color active, const lay::Drawings *drawings, PixelBuffer &img, unsigned int width, unsigned int height);
void to_image (const std::vector <lay::ViewOp> &view_ops, const lay::DitherPattern &dp, const lay::LineStyles &ls, tl::Color background, tl::Color foreground, tl::Color active, const lay::Drawings *drawings, tl::PixelBuffer &img, unsigned int width, unsigned int height);
/**
* @brief Transfer the content to a BitmapBuffer (monochrome)
*/
void to_image_mono (const std::vector <lay::ViewOp> &view_ops, const lay::DitherPattern &dp, const lay::LineStyles &ls, bool background, bool foreground, bool active, const lay::Drawings *drawings, lay::BitmapBuffer &img, unsigned int width, unsigned int height);
void to_image_mono (const std::vector <lay::ViewOp> &view_ops, const lay::DitherPattern &dp, const lay::LineStyles &ls, bool background, bool foreground, bool active, const lay::Drawings *drawings, tl::BitmapBuffer &img, unsigned int width, unsigned int height);
/**
* @brief Gets the current bitmap data as a BitmapCanvasData object

View File

@ -32,7 +32,7 @@ namespace lay
// -------------------------------------------------------------
// RubberBox implementation
RubberBox::RubberBox (lay::ViewObjectWidget *widget, unsigned int color, const db::DPoint &p1, const db::DPoint &p2)
RubberBox::RubberBox (lay::ViewObjectUI *widget, unsigned int color, const db::DPoint &p1, const db::DPoint &p2)
: lay::ViewObject (widget, false /*not static*/),
m_p1 (p1), m_p2 (p2), m_color (color), m_stipple (0)
{ }

View File

@ -34,7 +34,7 @@ class LAYBASIC_PUBLIC RubberBox
: public lay::ViewObject
{
public:
RubberBox (lay::ViewObjectWidget *canvas, unsigned int color, const db::DPoint &p1, const db::DPoint &p2);
RubberBox (lay::ViewObjectUI *canvas, unsigned int color, const db::DPoint &p1, const db::DPoint &p2);
void set_color (unsigned int color);
void set_stipple (unsigned int s);

View File

@ -43,7 +43,7 @@ SelectionService::SelectionService (lay::LayoutViewBase *view) :
#if defined(HAVE_QT)
QObject (),
#endif
lay::ViewService (view->view_object_widget ()),
lay::ViewService (view->canvas ()),
mp_view (view),
mp_box (0),
m_color (0),
@ -68,7 +68,7 @@ SelectionService::~SelectionService ()
}
void
SelectionService::set_colors (lay::Color /*background*/, lay::Color color)
SelectionService::set_colors (tl::Color /*background*/, tl::Color color)
{
m_color = color.rgb ();
if (mp_box) {
@ -114,7 +114,7 @@ SelectionService::reset_box ()
{
if (mp_box) {
widget ()->ungrab_mouse (this);
ui ()->ungrab_mouse (this);
delete mp_box;
mp_box = 0;
@ -223,7 +223,7 @@ SelectionService::mouse_click_event (const db::DPoint &p, unsigned int buttons,
reset_box ();
}
if (prio && mp_view && widget ()->mouse_event_viewport ().contains (p) && (buttons & lay::LeftButton) != 0) {
if (prio && mp_view && ui ()->mouse_event_viewport ().contains (p) && (buttons & lay::LeftButton) != 0) {
lay::Editable::SelectionMode mode = lay::Editable::Replace;
bool shift = ((buttons & lay::ShiftButton) != 0);
@ -314,10 +314,10 @@ SelectionService::begin (const db::DPoint &pos)
m_p1 = pos;
m_p2 = pos;
mp_box = new lay::RubberBox (widget (), m_color, pos, pos);
mp_box = new lay::RubberBox (ui (), m_color, pos, pos);
mp_box->set_stipple (6); // coarse hatched
widget ()->grab_mouse (this, true);
ui ()->grab_mouse (this, true);
}
}

View File

@ -55,7 +55,7 @@ public:
SelectionService (lay::LayoutViewBase *view);
~SelectionService ();
void set_colors (lay::Color background, lay::Color color);
void set_colors (tl::Color background, tl::Color color);
void begin (const db::DPoint &pos);
bool dragging () const { return mp_box != 0; }

View File

@ -0,0 +1,45 @@
/*
KLayout Layout Viewer
Copyright (C) 2006-2022 Matthias Koefferlein
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "layUtils.h"
#if defined(HAVE_QT)
# include <QApplication>
#endif
namespace lay {
bool
has_gui ()
{
#if defined(HAVE_QT)
#if QT_VERSION < 0x50000
return (QApplication::type () != QApplication::Tty);
#else
return (dynamic_cast<QGuiApplication *> (QCoreApplication::instance ()) != 0);
#endif
#else
return false;
#endif
}
}

View File

@ -0,0 +1,38 @@
/*
KLayout Layout Viewer
Copyright (C) 2006-2022 Matthias Koefferlein
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef HDR_layUtils
#define HDR_layUtils
#include "laybasicCommon.h"
namespace lay {
/**
* @brief Returns true, if GUI is enabled
*/
LAYBASIC_PUBLIC bool has_gui ();
}
#endif

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More