summaryrefslogtreecommitdiff
path: root/navit/graphics
diff options
context:
space:
mode:
authorStefan Wildemann <metalstrolch@users.noreply.github.com>2020-04-26 00:59:36 +0200
committerGitHub <noreply@github.com>2020-04-26 00:59:36 +0200
commit54fd092de942f12133b67bc0118ba6de879d39d7 (patch)
tree15de360d3f57821eb712e253c9dd7f037d96467b /navit/graphics
parentf82ea8d97d5f10433197306e8afd6b6c10e294f2 (diff)
downloadnavit-54fd092de942f12133b67bc0118ba6de879d39d7.tar.gz
Add:Core+Graphics+Qt5:Add support for textured polygons (#989)
This pull request adds the basic support for textured polygons. It adds a function to graphics plugins to set texture. It enhances itemgra configuration that allows to set a picture to polygon map elements Basic support for Qt5 graphics. Some example textures added to car layout. Texture files have own resource directory.
Diffstat (limited to 'navit/graphics')
-rw-r--r--navit/graphics/qt5/graphics_qt5.cpp22
-rw-r--r--navit/graphics/qt5/graphics_qt5.h3
2 files changed, 23 insertions, 2 deletions
diff --git a/navit/graphics/qt5/graphics_qt5.cpp b/navit/graphics/qt5/graphics_qt5.cpp
index cb9b4c456..c87479219 100644
--- a/navit/graphics/qt5/graphics_qt5.cpp
+++ b/navit/graphics/qt5/graphics_qt5.cpp
@@ -268,12 +268,32 @@ static void gc_set_background(struct graphics_gc_priv* gc, struct color* c) {
//gc->brush->setColor(col);
}
+void gc_set_texture (struct graphics_gc_priv *gc, struct graphics_image_priv *img) {
+ if(img == NULL) {
+ //disable texture mode
+ gc->brush->setStyle(Qt::SolidPattern);
+ } else {
+ //set and enable texture
+ //Use a new pixmap
+ QPixmap background(img->pixmap->size());
+ //Use fill color
+ background.fill(gc->brush->color());
+ //Get a painter
+ QPainter painter(&background);
+ //Blit the (transparent) image on pixmap.
+ painter.drawPixmap(0, 0, *(img->pixmap));
+ //Set the texture to the brush.
+ gc->brush->setTexture(background);
+ }
+}
+
static struct graphics_gc_methods gc_methods = {
gc_destroy,
gc_set_linewidth,
gc_set_dashes,
gc_set_foreground,
- gc_set_background
+ gc_set_background,
+ gc_set_texture
};
static struct graphics_gc_priv* gc_new(struct graphics_priv* gr, struct graphics_gc_methods* meth) {
diff --git a/navit/graphics/qt5/graphics_qt5.h b/navit/graphics/qt5/graphics_qt5.h
index 0eed89510..8d7d5ab19 100644
--- a/navit/graphics/qt5/graphics_qt5.h
+++ b/navit/graphics/qt5/graphics_qt5.h
@@ -61,7 +61,8 @@ struct graphics_priv;
#if USE_QML
class GraphicsPriv : public QObject {
Q_OBJECT
-public: GraphicsPriv(struct graphics_priv* gp);
+public:
+ GraphicsPriv(struct graphics_priv* gp);
~GraphicsPriv();
void emit_update();