navit  0.5.3-trunk
graphics_qt5.cpp File Reference
#include <glib.h>
#include "config.h"
#include "item.h"
#include "callback.h"
#include "color.h"
#include "debug.h"
#include "event.h"
#include "point.h"
#include "graphics.h"
#include "plugin.h"
#include "window.h"
#include "event_qt5.h"
#include "graphics_qt5.h"
#include <QDBusConnection>
#include <QDBusInterface>
#include <QFile>
#include <QFont>
#include <QGuiApplication>
#include <QPainter>
#include <QPainterPath>
#include <QPixmap>
#include <QScreen>
#include <QSvgRenderer>
#include "QNavitWidget.h"
#include <QApplication>

Data Structures

struct  graphics_font_priv
 
struct  graphics_image_priv
 

Functions

static void graphics_destroy (struct graphics_priv *gr)
 
static void font_destroy (struct graphics_font_priv *font)
 
static struct graphics_font_privfont_new (struct graphics_priv *gr, struct graphics_font_methods *meth, char *font, int size, int flags)
 Allocate a font context. More...
 
static void gc_destroy (struct graphics_gc_priv *gc)
 
static void gc_set_linewidth (struct graphics_gc_priv *gc, int w)
 
static void gc_set_dashes (struct graphics_gc_priv *gc, int w, int offset, unsigned char *dash_list, int n)
 
static void gc_set_foreground (struct graphics_gc_priv *gc, struct color *c)
 
static void gc_set_background (struct graphics_gc_priv *gc, struct color *c)
 
void gc_set_texture (struct graphics_gc_priv *gc, struct graphics_image_priv *img)
 
static struct graphics_gc_privgc_new (struct graphics_priv *gr, struct graphics_gc_methods *meth)
 
static void image_destroy (struct graphics_image_priv *img)
 
static struct graphics_image_privimage_new (struct graphics_priv *gr, struct graphics_image_methods *meth, char *path, int *w, int *h, struct point *hot, int rotation)
 
static void draw_lines (struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count)
 
static void draw_polygon (struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count)
 
static void draw_polygon_with_holes (struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count, int hole_count, int *ccount, struct point **holes)
 
static void draw_rectangle (struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int w, int h)
 
static void draw_circle (struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int r)
 
static void draw_text (struct graphics_priv *gr, struct graphics_gc_priv *fg, struct graphics_gc_priv *bg, struct graphics_font_priv *font, char *text, struct point *p, int dx, int dy)
 Render given text. More...
 
static void draw_image (struct graphics_priv *gr, struct graphics_gc_priv *fg, struct point *p, struct graphics_image_priv *img)
 
static void draw_drag (struct graphics_priv *gr, struct point *p)
 Drag layer. More...
 
static void background_gc (struct graphics_priv *gr, struct graphics_gc_priv *gc)
 
static void draw_mode (struct graphics_priv *gr, enum draw_mode_num mode)
 
static struct graphics_privoverlay_new (struct graphics_priv *gr, struct graphics_methods *meth, struct point *p, int w, int h, int wraparound)
 
void resize_callback (struct graphics_priv *gr, int w, int h)
 
static int graphics_qt5_fullscreen (struct window *w, int on)
 
static void keep_display_on (struct graphics_priv *priv)
 
static void graphics_qt5_disable_suspend (struct window *w)
 
static void * get_data (struct graphics_priv *this_priv, char const *type)
 
static void image_free (struct graphics_priv *gr, struct graphics_image_priv *priv)
 
static void get_text_bbox (struct graphics_priv *gr, struct graphics_font_priv *font, char *text, int dx, int dy, struct point *ret, int estimate)
 Calculate pixel space required for font display. More...
 
static void overlay_disable (struct graphics_priv *gr, int disable)
 
static void overlay_resize (struct graphics_priv *gr, struct point *p, int w, int h, int wraparound)
 
static navit_float get_dpi (struct graphics_priv *gr)
 Return number of dots per inch. More...
 
static struct graphics_privgraphics_qt5_new (struct navit *nav, struct graphics_methods *meth, struct attr **attrs, struct callback_list *cbl)
 
void plugin_init (void)
 

Variables

QGuiApplication * navit_app = NULL
 
static struct graphics_font_methods font_methods
 font interface structure This structure is preset with all function pointers provided by this implemention to be returned as interface. More...
 
static const char * fontfamilies []
 
static struct graphics_gc_methods gc_methods
 
struct graphics_image_methods image_methods
 
static struct graphics_methods graphics_methods
 

Function Documentation

◆ background_gc()

static void background_gc ( struct graphics_priv gr,
struct graphics_gc_priv gc 
)
static

◆ draw_circle()

static void draw_circle ( struct graphics_priv gr,
struct graphics_gc_priv gc,
struct point p,
int  r 
)
static

◆ draw_drag()

static void draw_drag ( struct graphics_priv gr,
struct point p 
)
static

Drag layer.

Parameters
grprivate handle
pvector the bitmap is moved from base, or NULL to indicate 0:0 vector

Move layer to new position. If drag_bitmap is enabled this may also be called for root layer. There the content of the root layer is to be moved by given vector. On root layer, NULL indicates the end of a drag.

References dbg, lvl_debug, p, graphics_priv::pixmap, graphics_priv::root, graphics_priv::scroll_x, graphics_priv::scroll_y, graphics_priv::widget, graphics_priv::x, point::x, graphics_priv::y, and point::y.

◆ draw_image()

static void draw_image ( struct graphics_priv gr,
struct graphics_gc_priv fg,
struct point p,
struct graphics_image_priv img 
)
static

◆ draw_lines()

static void draw_lines ( struct graphics_priv gr,
struct graphics_gc_priv gc,
struct point p,
int  count 
)
static

◆ draw_mode()

◆ draw_polygon()

static void draw_polygon ( struct graphics_priv gr,
struct graphics_gc_priv gc,
struct point p,
int  count 
)
static

◆ draw_polygon_with_holes()

static void draw_polygon_with_holes ( struct graphics_priv gr,
struct graphics_gc_priv gc,
struct point p,
int  count,
int  hole_count,
int *  ccount,
struct point **  holes 
)
static

◆ draw_rectangle()

static void draw_rectangle ( struct graphics_priv gr,
struct graphics_gc_priv gc,
struct point p,
int  w,
int  h 
)
static

◆ draw_text()

static void draw_text ( struct graphics_priv gr,
struct graphics_gc_priv fg,
struct graphics_gc_priv bg,
struct graphics_font_priv font,
char *  text,
struct point p,
int  dx,
int  dy 
)
static

Render given text.

Parameters
grown private context
fgforeground drawing context (for color)
bgbackground drawing context (for color)
fontfont context to use (allocated by font_new)
textString to calculate bbox for
poffset on gr context to place this text.
dxtransformation matrix (16.16 fixpoint)
dytransformation matrix (16.16 fixpoint)

Renders given text on gr surface. Draws nice contrast outline around text.

References color::a, color::b, data, dbg, graphics_font_priv::font, graphics_priv::freetype_methods, color::g, font_freetype_methods::get_glyph, font_freetype_methods::get_shadow, font_freetype_text::glyph, font_freetype_text::glyph_count, lvl_debug, p, graphics_priv::painter, graphics_gc_priv::pen, color::r, font_freetype_methods::text_destroy, and font_freetype_methods::text_new.

◆ font_destroy()

static void font_destroy ( struct graphics_font_priv font)
static

◆ font_new()

static struct graphics_font_priv* font_new ( struct graphics_priv gr,
struct graphics_font_methods meth,
char *  font,
int  size,
int  flags 
)
static

Allocate a font context.

Parameters
grown private context
methfill this structure with correct functions to be called with handle as interface to font
fontfont family e.g. "Arial"
sizeFont size in 16.6 fractional points @ 300dpi. This is bullsh***. The encoding is freetypes 16.6 fixed point format usually giving points. One point is usually 72th part of an inch. But navit does not honor dpi correct. It's traditionally used freetype backend is fixed to 300 dpi. So this value is (300/72) pixels
flagsFont flags (currently 1 if bold and 0 if not)
Returns
font handle

Allocates a font handle and returnes filled interface stucture

References font_priv::data, dbg, graphics_font_priv::font, font_methods, fontfamilies, lvl_debug, and size.

◆ gc_destroy()

static void gc_destroy ( struct graphics_gc_priv gc)
static

◆ gc_new()

◆ gc_set_background()

static void gc_set_background ( struct graphics_gc_priv gc,
struct color c 
)
static

References c.

◆ gc_set_dashes()

static void gc_set_dashes ( struct graphics_gc_priv gc,
int  w,
int  offset,
unsigned char *  dash_list,
int  n 
)
static

◆ gc_set_foreground()

static void gc_set_foreground ( struct graphics_gc_priv gc,
struct color c 
)
static

◆ gc_set_linewidth()

static void gc_set_linewidth ( struct graphics_gc_priv gc,
int  w 
)
static

References graphics_gc_priv::pen.

◆ gc_set_texture()

void gc_set_texture ( struct graphics_gc_priv gc,
struct graphics_image_priv img 
)

◆ get_data()

◆ get_dpi()

static navit_float get_dpi ( struct graphics_priv gr)
static

Return number of dots per inch.

Parameters
grself handle
Returns
dpi value

References navit_app.

◆ get_text_bbox()

static void get_text_bbox ( struct graphics_priv gr,
struct graphics_font_priv font,
char *  text,
int  dx,
int  dy,
struct point ret,
int  estimate 
)
static

Calculate pixel space required for font display.

Parameters
grown private context
fontfont context to use (allocated by font_new)
textString to calculate bbox for
dxtransformation matrix (16.16 fixpoint)
dytransformation matrix (16.16 fixpoint)
retpoint array to fill. (low left, top left, top right, low right)
estimate???

Calculates the bounding box around the given text.

References graphics_font_priv::font, point::x, and point::y.

◆ graphics_destroy()

◆ graphics_qt5_disable_suspend()

static void graphics_qt5_disable_suspend ( struct window w)
static

◆ graphics_qt5_fullscreen()

static int graphics_qt5_fullscreen ( struct window w,
int  on 
)
static

◆ graphics_qt5_new()

◆ image_destroy()

static void image_destroy ( struct graphics_image_priv img)
static

◆ image_free()

static void image_free ( struct graphics_priv gr,
struct graphics_image_priv priv 
)
static

References window::priv.

◆ image_new()

static struct graphics_image_priv* image_new ( struct graphics_priv gr,
struct graphics_image_methods meth,
char *  path,
int *  w,
int *  h,
struct point hot,
int  rotation 
)
static

◆ keep_display_on()

static void keep_display_on ( struct graphics_priv priv)
static

◆ overlay_disable()

static void overlay_disable ( struct graphics_priv gr,
int  disable 
)
static

◆ overlay_new()

◆ overlay_resize()

static void overlay_resize ( struct graphics_priv gr,
struct point p,
int  w,
int  h,
int  wraparound 
)
static

◆ plugin_init()

void plugin_init ( void  )

◆ resize_callback()

void resize_callback ( struct graphics_priv gr,
int  w,
int  h 
)

Variable Documentation

◆ font_methods

struct graphics_font_methods font_methods
static
Initial value:
= {
}
static void font_destroy(struct graphics_font_priv *font)
Definition: graphics_qt5.cpp:142

font interface structure This structure is preset with all function pointers provided by this implemention to be returned as interface.

Referenced by font_new().

◆ fontfamilies

const char* fontfamilies[]
static
Initial value:
= {
"Liberation Sans",
"Arial",
"NcrBI4nh",
"luximbi",
"FreeSans",
"DejaVu Sans",
NULL,
}

List of font families to use, in order of preference

Referenced by font_new().

◆ gc_methods

struct graphics_gc_methods gc_methods
static
Initial value:
= {
}
void gc_set_texture(struct graphics_gc_priv *gc, struct graphics_image_priv *img)
Definition: graphics_qt5.cpp:272
static void gc_destroy(struct graphics_gc_priv *gc)
Definition: graphics_qt5.cpp:225
static void gc_set_foreground(struct graphics_gc_priv *gc, struct color *c)
Definition: graphics_qt5.cpp:257
static void gc_set_background(struct graphics_gc_priv *gc, struct color *c)
Definition: graphics_qt5.cpp:265
static void gc_set_dashes(struct graphics_gc_priv *gc, int w, int offset, unsigned char *dash_list, int n)
Definition: graphics_qt5.cpp:237
static void gc_set_linewidth(struct graphics_gc_priv *gc, int w)
Definition: graphics_qt5.cpp:232

Referenced by gc_new().

◆ graphics_methods

Initial value:
= {
NULL,
NULL,
NULL,
NULL,
}
static void * get_data(struct graphics_priv *this_priv, char const *type)
Definition: graphics_qt5.cpp:744
static struct graphics_priv * overlay_new(struct graphics_priv *gr, struct graphics_methods *meth, struct point *p, int w, int h, int wraparound)
Definition: graphics_qt5.cpp:902
static void draw_drag(struct graphics_priv *gr, struct point *p)
Drag layer.
Definition: graphics_qt5.cpp:605
static void overlay_disable(struct graphics_priv *gr, int disable)
Definition: graphics_qt5.cpp:817
static void draw_rectangle(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int w, int h)
Definition: graphics_qt5.cpp:467
static void draw_image(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct point *p, struct graphics_image_priv *img)
Definition: graphics_qt5.cpp:587
static void draw_text(struct graphics_priv *gr, struct graphics_gc_priv *fg, struct graphics_gc_priv *bg, struct graphics_font_priv *font, char *text, struct point *p, int dx, int dy)
Render given text.
Definition: graphics_qt5.cpp:495
static void background_gc(struct graphics_priv *gr, struct graphics_gc_priv *gc)
Definition: graphics_qt5.cpp:641
static struct graphics_image_priv * image_new(struct graphics_priv *gr, struct graphics_image_methods *meth, char *path, int *w, int *h, struct point *hot, int rotation)
Definition: graphics_qt5.cpp:323
static void draw_lines(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count)
Definition: graphics_qt5.cpp:408
static void get_text_bbox(struct graphics_priv *gr, struct graphics_font_priv *font, char *text, int dx, int dy, struct point *ret, int estimate)
Calculate pixel space required for font display.
Definition: graphics_qt5.cpp:783
static void draw_mode(struct graphics_priv *gr, enum draw_mode_num mode)
Definition: graphics_qt5.cpp:646
static void draw_polygon_with_holes(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count, int hole_count, int *ccount, struct point **holes)
Definition: graphics_qt5.cpp:436
static navit_float get_dpi(struct graphics_priv *gr)
Return number of dots per inch.
Definition: graphics_qt5.cpp:864
static void draw_polygon(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int count)
Definition: graphics_qt5.cpp:421
static void image_free(struct graphics_priv *gr, struct graphics_image_priv *priv)
Definition: graphics_qt5.cpp:765
static struct graphics_gc_priv * gc_new(struct graphics_priv *gr, struct graphics_gc_methods *meth)
Definition: graphics_qt5.cpp:300
static void overlay_resize(struct graphics_priv *gr, struct point *p, int w, int h, int wraparound)
Definition: graphics_qt5.cpp:832
static void draw_circle(struct graphics_priv *gr, struct graphics_gc_priv *gc, struct point *p, int r)
Definition: graphics_qt5.cpp:474
static void graphics_destroy(struct graphics_priv *gr)
Definition: graphics_qt5.cpp:89
static struct graphics_font_priv * font_new(struct graphics_priv *gr, struct graphics_font_methods *meth, char *font, int size, int flags)
Allocate a font context.
Definition: graphics_qt5.cpp:186

Referenced by graphics_qt5_new(), and overlay_new().

◆ image_methods

struct graphics_image_methods image_methods
Initial value:
= {
}
static void image_destroy(struct graphics_image_priv *img)
Definition: graphics_qt5.cpp:312

Referenced by image_new().

◆ navit_app

QGuiApplication* navit_app = NULL

Navit, a modular navigation system. Copyright (C) 2005-2017 Navit Team

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation.

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 Street, Fifth Floor, Boston, MA 02110-1301, USA.

Referenced by event_qt5_main_loop_run(), get_dpi(), graphics_destroy(), and graphics_qt5_new().