diff --git a/src/gsi/gsi/gsiDeclTlPixelBuffer.cc b/src/gsi/gsi/gsiDeclTlPixelBuffer.cc index d4157b198..ef76af9e1 100644 --- a/src/gsi/gsi/gsiDeclTlPixelBuffer.cc +++ b/src/gsi/gsi/gsiDeclTlPixelBuffer.cc @@ -25,7 +25,6 @@ #if defined(HAVE_QT) # include -# include #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 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 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 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 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" diff --git a/src/laybasic/laybasic/gsiDeclLayRdbAdded.cc b/src/laybasic/laybasic/gsiDeclLayRdbAdded.cc new file mode 100644 index 000000000..39a9504f1 --- /dev/null +++ b/src/laybasic/laybasic/gsiDeclLayRdbAdded.cc @@ -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 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 (&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 + +} diff --git a/src/laybasic/laybasic/gsiDeclLayTlAdded.cc b/src/laybasic/laybasic/gsiDeclLayTlAdded.cc new file mode 100644 index 000000000..ba2c85f43 --- /dev/null +++ b/src/laybasic/laybasic/gsiDeclLayTlAdded.cc @@ -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 +#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 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 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 + +} diff --git a/src/laybasic/laybasic/laybasic.pro b/src/laybasic/laybasic/laybasic.pro index ba68de57c..24f737974 100644 --- a/src/laybasic/laybasic/laybasic.pro +++ b/src/laybasic/laybasic/laybasic.pro @@ -36,6 +36,8 @@ SOURCES += \ gsiDeclLayLayoutViewBase.cc \ gsiDeclLayMarker.cc \ gsiDeclLayPlugin.cc \ + gsiDeclLayTlAdded.cc \ + gsiDeclLayRdbAdded.cc \ laybasicForceLink.cc \ layAnnotationShapes.cc \ layBitmap.cc \ diff --git a/src/rdb/rdb/gsiDeclRdb.cc b/src/rdb/rdb/gsiDeclRdb.cc index 22a99bca0..e42c3d02b 100644 --- a/src/rdb/rdb/gsiDeclRdb.cc +++ b/src/rdb/rdb/gsiDeclRdb.cc @@ -821,18 +821,6 @@ Class 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 (&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"