OpenCPN Partial API docs
Loading...
Searching...
No Matches
svg_utils.cpp File Reference

Implement svg_utils.h – SVG Utility functions. More...

#include <wx/filename.h>
#include <wx/dir.h>
#include "model/svg_utils.h"
#include "model/base_platform.h"
#include "model/routeman.h"
#include "pugixml.hpp"

Go to the source code of this file.

Macros

#define SVG_IN_TO_PT   72
 
#define SVG_IN_TO_PX   96
 
#define SVG_PT_TO_IN   1 / 72
 
#define SVG_PX_TO_IN   1 / 96
 
#define SVG_PT_TO_PX   96 / 72
 
#define SVG_MM_TO_PX   3.7795275591
 
#define SVG_PX_TO_MM   0.2645833333
 
#define SVG_MM_TO_PT   2.8346456693
 
#define SVG_PT_TO_MM   0.3527777778
 
#define SVG_CM_TO_PX   37.795275591
 
#define SVG_CM_TO_PT   28.346456693
 
#define SVG_MM_TO_IN   25.4
 

Functions

wxBitmap LoadSVG (const wxString filename, const unsigned int width, const unsigned int height, wxBitmap *default_bitmap, bool use_cache)
 Load SVG file and return it's bitmap representation of requested size In case file can't be loaded an empty bitmap of desired size or a provided default bitmap is returned.
 
int str_ends_with (const char *str, const char *suffix)
 
unsigned int get_px_length (const char *val)
 
bool SVGDocumentPixelSize (const wxString filename, unsigned int &width, unsigned int &height)
 Return the size of the SVG document in standard 96 DPI pixels https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#length Percentage, em and ex make no sense without being able to relate them to something, so we just return the numerical value as we do for px.
 
unsigned int SVGPixelsToDisplay (unsigned int svg_px)
 Recalculate the length in standard 96 DPI pixels to actual display pixels.
 
wxBitmap LoadSvgStdIcon (const std::string &svg_file, const wxWindow *w, bool touch)
 Load an svg icon from standard path, roughly scaled to the height of a char.
 

Detailed Description

Implement svg_utils.h – SVG Utility functions.

Definition in file svg_utils.cpp.

Macro Definition Documentation

◆ SVG_CM_TO_PT

#define SVG_CM_TO_PT   28.346456693

Definition at line 56 of file svg_utils.cpp.

◆ SVG_CM_TO_PX

#define SVG_CM_TO_PX   37.795275591

Definition at line 55 of file svg_utils.cpp.

◆ SVG_IN_TO_PT

#define SVG_IN_TO_PT   72

Definition at line 46 of file svg_utils.cpp.

◆ SVG_IN_TO_PX

#define SVG_IN_TO_PX   96

Definition at line 47 of file svg_utils.cpp.

◆ SVG_MM_TO_IN

#define SVG_MM_TO_IN   25.4

Definition at line 57 of file svg_utils.cpp.

◆ SVG_MM_TO_PT

#define SVG_MM_TO_PT   2.8346456693

Definition at line 53 of file svg_utils.cpp.

◆ SVG_MM_TO_PX

#define SVG_MM_TO_PX   3.7795275591

Definition at line 51 of file svg_utils.cpp.

◆ SVG_PT_TO_IN

#define SVG_PT_TO_IN   1 / 72

Definition at line 48 of file svg_utils.cpp.

◆ SVG_PT_TO_MM

#define SVG_PT_TO_MM   0.3527777778

Definition at line 54 of file svg_utils.cpp.

◆ SVG_PT_TO_PX

#define SVG_PT_TO_PX   96 / 72

Definition at line 50 of file svg_utils.cpp.

◆ SVG_PX_TO_IN

#define SVG_PX_TO_IN   1 / 96

Definition at line 49 of file svg_utils.cpp.

◆ SVG_PX_TO_MM

#define SVG_PX_TO_MM   0.2645833333

Definition at line 52 of file svg_utils.cpp.

Function Documentation

◆ get_px_length()

unsigned int get_px_length ( const char *  val)

Definition at line 123 of file svg_utils.cpp.

◆ LoadSVG()

wxBitmap LoadSVG ( const wxString  filename,
const unsigned int  width,
const unsigned int  height,
wxBitmap *  default_bitmap,
bool  use_cache 
)

Load SVG file and return it's bitmap representation of requested size In case file can't be loaded an empty bitmap of desired size or a provided default bitmap is returned.

Definition at line 59 of file svg_utils.cpp.

◆ LoadSvgStdIcon()

wxBitmap LoadSvgStdIcon ( const std::string &  svg_file,
const wxWindow *  w,
bool  touch 
)

Load an svg icon from standard path, roughly scaled to the height of a char.

Parameters
touchIf true ensures icon is "big enough" for touch screens

Definition at line 207 of file svg_utils.cpp.

◆ str_ends_with()

int str_ends_with ( const char *  str,
const char *  suffix 
)

Definition at line 108 of file svg_utils.cpp.

◆ SVGDocumentPixelSize()

bool SVGDocumentPixelSize ( const wxString  filename,
unsigned int &  width,
unsigned int &  height 
)

Return the size of the SVG document in standard 96 DPI pixels https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#length Percentage, em and ex make no sense without being able to relate them to something, so we just return the numerical value as we do for px.

Definition at line 148 of file svg_utils.cpp.

◆ SVGPixelsToDisplay()

unsigned int SVGPixelsToDisplay ( unsigned int  svg_px)

Recalculate the length in standard 96 DPI pixels to actual display pixels.

Definition at line 202 of file svg_utils.cpp.