mirror of https://github.com/KLayout/klayout.git
Decoupling tl, gsi and rdb libraries from Qt bindings to enable lean strmrun application
This commit is contained in:
parent
ef8f4fbba5
commit
91b642285d
|
|
@ -25,7 +25,6 @@
|
|||
|
||||
#if defined(HAVE_QT)
|
||||
# include <QBuffer>
|
||||
# include <QColor>
|
||||
#endif
|
||||
|
||||
namespace gsi
|
||||
|
|
@ -39,13 +38,6 @@ static tl::PixelBuffer *create_pixel_buffer (unsigned int w, unsigned int h)
|
|||
return new tl::PixelBuffer (w, h);
|
||||
}
|
||||
|
||||
#if defined(HAVE_QT) && defined(HAVE_QTBINDINGS)
|
||||
static void fill_with_qcolor (tl::PixelBuffer *pb, QColor c)
|
||||
{
|
||||
pb->fill (c.rgb ());
|
||||
}
|
||||
#endif
|
||||
|
||||
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 ()) {
|
||||
|
|
@ -161,11 +153,6 @@ Class<tl::PixelBuffer> decl_PixelBuffer ("lay", "PixelBuffer",
|
|||
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", &tl::PixelBuffer::swap, gsi::arg ("other"),
|
||||
"@brief Swaps data with another PixelBuffer object\n"
|
||||
) +
|
||||
|
|
@ -181,14 +168,6 @@ Class<tl::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", &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"
|
||||
) +
|
||||
#endif
|
||||
gsi::method ("read_png", &read_pixel_buffer, gsi::arg ("file"),
|
||||
"@brief Reads the pixel buffer from a PNG file"
|
||||
"\n"
|
||||
|
|
@ -353,11 +332,6 @@ Class<tl::BitmapBuffer> decl_BitmapBuffer ("lay", "BitmapBuffer",
|
|||
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", &tl::BitmapBuffer::swap, gsi::arg ("other"),
|
||||
"@brief Swaps data with another BitmapBuffer object\n"
|
||||
) +
|
||||
|
|
@ -373,14 +347,6 @@ Class<tl::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", &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
|
||||
gsi::method ("read_png", &read_bitmap_buffer, gsi::arg ("file"),
|
||||
"@brief Reads the pixel buffer from a PNG file"
|
||||
"\n"
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
}
|
||||
|
|
@ -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
|
||||
|
||||
}
|
||||
|
|
@ -36,6 +36,8 @@ SOURCES += \
|
|||
gsiDeclLayLayoutViewBase.cc \
|
||||
gsiDeclLayMarker.cc \
|
||||
gsiDeclLayPlugin.cc \
|
||||
gsiDeclLayTlAdded.cc \
|
||||
gsiDeclLayRdbAdded.cc \
|
||||
laybasicForceLink.cc \
|
||||
layAnnotationShapes.cc \
|
||||
layBitmap.cc \
|
||||
|
|
|
|||
|
|
@ -821,18 +821,6 @@ Class<rdb::Item> decl_RdbItem ("rdb", "RdbItem",
|
|||
"@brief Sets the image from a string\n"
|
||||
"@param image A base64-encoded image file (preferably in PNG format)\n"
|
||||
) +
|
||||
#if defined(HAVE_QTBINDINGS)
|
||||
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
|
||||
#if defined(HAVE_PNG)
|
||||
gsi::method ("image_pixels", &rdb::Item::image_pixels,
|
||||
"@brief Gets the attached image as a PixelBuffer object\n"
|
||||
|
|
|
|||
Loading…
Reference in New Issue