bpp-core3  3.0.0
bpp::SvgGraphicDevice Class Reference

SVG plotting format. More...

#include <Bpp/Graphics/Svg/SvgGraphicDevice.h>

+ Inheritance diagram for bpp::SvgGraphicDevice:
+ Collaboration diagram for bpp::SvgGraphicDevice:

Public Member Functions

 SvgGraphicDevice (std::ostream &out, bool inkscapeEnabled=false)
 
virtual ~SvgGraphicDevice ()
 
void begin ()
 Start the painting. More...
 
void end ()
 End the painting. More...
 
void drawLine (double x1, double y1, double x2, double y2)
 Draw a line between two points. More...
 
void drawRect (double x, double y, double width, double height, short fill=FILL_EMPTY)
 Draw a rectangle. More...
 
void drawCircle (double x, double y, double radius, short fill=FILL_EMPTY)
 Draw a circle. More...
 
void drawText (double x, double y, const std::string &text, short hpos=TEXT_HORIZONTAL_LEFT, short vpos=TEXT_VERTICAL_BOTTOM, double angle=0)
 Draw some characters. More...
 
void comment (const std::string &text)
 Add a comment in the output. More...
 
void setXUnit (double xu)
 
void setYUnit (double yu)
 
double getXUnit () const
 
double getYUnit () const
 
void setCurrentForegroundColor (const RGBColor &color)
 
void setCurrentBackgroundColor (const RGBColor &color)
 
void setCurrentFont (const Font &font)
 
void setCurrentPointSize (unsigned int size)
 
void setCurrentLineType (short type)
 
void setCurrentLayer (int layerIndex)
 
const RGBColorgetCurrentForegroundColor () const
 
const RGBColorgetCurrentBackgroundColor () const
 
const FontgetCurrentFont () const
 
unsigned int getCurrentPointSize () const
 
short getCurrentLineType () const
 
int getCurrentLayer () const
 

Static Public Member Functions

static std::string colorToText (const RGBColor &color)
 

Static Public Attributes

static short TEXT_HORIZONTAL_CENTER = 0
 
static short TEXT_HORIZONTAL_LEFT = 1
 
static short TEXT_HORIZONTAL_RIGHT = 2
 
static short TEXT_VERTICAL_CENTER = 3
 
static short TEXT_VERTICAL_BOTTOM = 4
 
static short TEXT_VERTICAL_TOP = 5
 
static short FILL_EMPTY = 10
 
static short FILL_FILLED = 11
 
static short FILL_PATTERN = 12
 
static short LINE_SOLID = 20
 
static short LINE_DASHED = 21
 
static short LINE_DOTTED = 22
 

Protected Member Functions

double x_ (double x) const
 
double y_ (double y) const
 
double revx_ (double x) const
 
double revy_ (double y) const
 

Private Attributes

std::ostream & out_
 
std::map< int, std::vector< std::string >, std::greater< int > > layers_
 
bool inkscapeEnabled_
 
double minx_
 
double maxx_
 
double miny_
 
double maxy_
 
std::map< short int, std::string > fontStyles_
 
std::map< short int, std::string > fontWeights_
 
double xUnit_
 
double yUnit_
 
RGBColor fgColor_
 
RGBColor bgColor_
 
Font font_
 
unsigned int pointSize_
 
short lineType_
 
int currentLayer_
 

Detailed Description

SVG plotting format.

Definition at line 56 of file SvgGraphicDevice.h.

Constructor & Destructor Documentation

◆ SvgGraphicDevice()

bpp::SvgGraphicDevice::SvgGraphicDevice ( std::ostream &  out,
bool  inkscapeEnabled = false 
)
inline

◆ ~SvgGraphicDevice()

virtual bpp::SvgGraphicDevice::~SvgGraphicDevice ( )
inlinevirtual

Definition at line 81 of file SvgGraphicDevice.h.

Member Function Documentation

◆ begin()

void SvgGraphicDevice::begin ( )
virtual

Start the painting.

Implements bpp::GraphicDevice.

Definition at line 47 of file SvgGraphicDevice.cpp.

◆ colorToText()

static std::string bpp::SvgGraphicDevice::colorToText ( const RGBColor color)
inlinestatic

Definition at line 97 of file SvgGraphicDevice.h.

References bpp::TextTools::toString().

◆ comment()

void bpp::SvgGraphicDevice::comment ( const std::string &  comment)
inlinevirtual

Add a comment in the output.

Parameters
commentComment text.

Implements bpp::GraphicDevice.

Definition at line 91 of file SvgGraphicDevice.h.

References bpp::AbstractGraphicDevice::getCurrentLayer(), and layers_.

◆ drawCircle()

void SvgGraphicDevice::drawCircle ( double  x,
double  y,
double  radius,
short  fill = FILL_EMPTY 
)
virtual

Draw a circle.

This method uses the current foreground color and the current line type for drawing the stroke of the circle, and the current background color for filling the circle.

Parameters
xx coordinate of the center
yy coordinate of the center
radiusThe circle radius
fillFilling type (one of FILL_EMPTY, FILL_FILLED or FILL_PATTERN).

Implements bpp::GraphicDevice.

Definition at line 143 of file SvgGraphicDevice.cpp.

References bpp::TextTools::toString().

◆ drawLine()

void SvgGraphicDevice::drawLine ( double  x1,
double  y1,
double  x2,
double  y2 
)
virtual

Draw a line between two points.

This method uses the current foreground color and the current line type.

Parameters
x1x coordinate 1
y1y coordinate 1
x2x coordinate 2
y2y coordinate 2

Implements bpp::GraphicDevice.

Definition at line 87 of file SvgGraphicDevice.cpp.

References bpp::TextTools::toString().

◆ drawRect()

void SvgGraphicDevice::drawRect ( double  x,
double  y,
double  width,
double  height,
short  fill = FILL_EMPTY 
)
virtual

Draw a rectangle.

This method uses the current foreground color and the current line type for drawing the stroke of the rectangle, and the current background color for filling the rectangle.

Parameters
xx coordinate
yy coordinate
widthThe rectangle width
heightThe rectangle height
fillFilling type (one of FILL_EMPTY, FILL_FILLED or FILL_PATTERN).

Implements bpp::GraphicDevice.

Definition at line 119 of file SvgGraphicDevice.cpp.

References bpp::TextTools::toString().

◆ drawText()

void SvgGraphicDevice::drawText ( double  x,
double  y,
const std::string &  text,
short  hpos = TEXT_HORIZONTAL_LEFT,
short  vpos = TEXT_VERTICAL_BOTTOM,
double  angle = 0 
)
virtual

Draw some characters.

This method uses the current foreground color.

Parameters
xx coordinate
yy coordinate
textThe characters to draw
hposHorizontal adjustment, one of TEXT_HORIZONTAL_LEFT, TEXT_HORIZONTAL_CENTER or TEXT_HORIZONTAL_RIGHT.
vposVertical adjustment, one of TEXT_VERTICAL_LEFT, TEXT_VERTICAL_CENTER or TEXT_VERTICAL_RIGHT.
angleAngle i radian to rotate the text.

Implements bpp::GraphicDevice.

Definition at line 158 of file SvgGraphicDevice.cpp.

References bpp::TextTools::toString().

◆ end()

void SvgGraphicDevice::end ( )
virtual

End the painting.

Depending on the implementation of the device, the call of this method might be required before the plotting commands become visible.

Implements bpp::GraphicDevice.

Definition at line 53 of file SvgGraphicDevice.cpp.

◆ getCurrentBackgroundColor()

const RGBColor& bpp::AbstractGraphicDevice::getCurrentBackgroundColor ( ) const
inlinevirtualinherited

Implements bpp::GraphicDevice.

Definition at line 94 of file AbstractGraphicDevice.h.

References bpp::AbstractGraphicDevice::bgColor_.

◆ getCurrentFont()

const Font& bpp::AbstractGraphicDevice::getCurrentFont ( ) const
inlinevirtualinherited

Implements bpp::GraphicDevice.

Definition at line 95 of file AbstractGraphicDevice.h.

References bpp::AbstractGraphicDevice::font_.

◆ getCurrentForegroundColor()

const RGBColor& bpp::AbstractGraphicDevice::getCurrentForegroundColor ( ) const
inlinevirtualinherited

Implements bpp::GraphicDevice.

Definition at line 93 of file AbstractGraphicDevice.h.

References bpp::AbstractGraphicDevice::fgColor_.

◆ getCurrentLayer()

int bpp::AbstractGraphicDevice::getCurrentLayer ( ) const
inlinevirtualinherited

◆ getCurrentLineType()

short bpp::AbstractGraphicDevice::getCurrentLineType ( ) const
inlinevirtualinherited

Implements bpp::GraphicDevice.

Definition at line 97 of file AbstractGraphicDevice.h.

References bpp::AbstractGraphicDevice::lineType_.

◆ getCurrentPointSize()

unsigned int bpp::AbstractGraphicDevice::getCurrentPointSize ( ) const
inlinevirtualinherited

◆ getXUnit()

double bpp::AbstractGraphicDevice::getXUnit ( ) const
inlinevirtualinherited
Returns
The x expansion factor. The actual unit actually depends on the implementation.

Implements bpp::GraphicDevice.

Definition at line 77 of file AbstractGraphicDevice.h.

References bpp::AbstractGraphicDevice::xUnit_.

Referenced by bpp::PgfGraphicDevice::end().

◆ getYUnit()

double bpp::AbstractGraphicDevice::getYUnit ( ) const
inlinevirtualinherited
Returns
The y expansion factor. The actual unit actually depends on the implementation.

Implements bpp::GraphicDevice.

Definition at line 78 of file AbstractGraphicDevice.h.

References bpp::AbstractGraphicDevice::yUnit_.

Referenced by bpp::PgfGraphicDevice::end().

◆ revx_()

double bpp::AbstractGraphicDevice::revx_ ( double  x) const
inlineprotectedinherited

Definition at line 104 of file AbstractGraphicDevice.h.

References bpp::AbstractGraphicDevice::xUnit_.

◆ revy_()

double bpp::AbstractGraphicDevice::revy_ ( double  y) const
inlineprotectedinherited

Definition at line 105 of file AbstractGraphicDevice.h.

References bpp::AbstractGraphicDevice::yUnit_.

◆ setCurrentBackgroundColor()

void bpp::AbstractGraphicDevice::setCurrentBackgroundColor ( const RGBColor color)
inlinevirtualinherited

◆ setCurrentFont()

void bpp::AbstractGraphicDevice::setCurrentFont ( const Font font)
inlinevirtualinherited

◆ setCurrentForegroundColor()

void bpp::AbstractGraphicDevice::setCurrentForegroundColor ( const RGBColor color)
inlinevirtualinherited

◆ setCurrentLayer()

void bpp::AbstractGraphicDevice::setCurrentLayer ( int  layerIndex)
inlinevirtualinherited

◆ setCurrentLineType()

◆ setCurrentPointSize()

void bpp::AbstractGraphicDevice::setCurrentPointSize ( unsigned int  size)
inlinevirtualinherited

◆ setXUnit()

void bpp::AbstractGraphicDevice::setXUnit ( double  xu)
inlinevirtualinherited
Parameters
xuThe x expansion factor. The actual unit actually depends on the implementation.

Implements bpp::GraphicDevice.

Definition at line 75 of file AbstractGraphicDevice.h.

References bpp::AbstractGraphicDevice::xUnit_.

Referenced by bpp::PgfGraphicDevice::PgfGraphicDevice().

◆ setYUnit()

void bpp::AbstractGraphicDevice::setYUnit ( double  yu)
inlinevirtualinherited
Parameters
yuThe y expansion factor. The actual unit actually depends on the implementation.

Implements bpp::GraphicDevice.

Definition at line 76 of file AbstractGraphicDevice.h.

References bpp::AbstractGraphicDevice::yUnit_.

Referenced by bpp::PgfGraphicDevice::PgfGraphicDevice().

◆ x_()

double bpp::AbstractGraphicDevice::x_ ( double  x) const
inlineprotectedinherited

◆ y_()

double bpp::AbstractGraphicDevice::y_ ( double  y) const
inlineprotectedinherited

Definition at line 102 of file AbstractGraphicDevice.h.

References bpp::AbstractGraphicDevice::yUnit_.

Member Data Documentation

◆ bgColor_

RGBColor bpp::AbstractGraphicDevice::bgColor_
privateinherited

◆ currentLayer_

int bpp::AbstractGraphicDevice::currentLayer_
privateinherited

◆ fgColor_

RGBColor bpp::AbstractGraphicDevice::fgColor_
privateinherited

◆ FILL_EMPTY

short GraphicDevice::FILL_EMPTY = 10
staticinherited

Definition at line 186 of file GraphicDevice.h.

◆ FILL_FILLED

short GraphicDevice::FILL_FILLED = 11
staticinherited

◆ FILL_PATTERN

short GraphicDevice::FILL_PATTERN = 12
staticinherited

Definition at line 188 of file GraphicDevice.h.

◆ font_

Font bpp::AbstractGraphicDevice::font_
privateinherited

◆ fontStyles_

std::map<short int, std::string> bpp::SvgGraphicDevice::fontStyles_
private

Definition at line 64 of file SvgGraphicDevice.h.

Referenced by SvgGraphicDevice().

◆ fontWeights_

std::map<short int, std::string> bpp::SvgGraphicDevice::fontWeights_
private

Definition at line 65 of file SvgGraphicDevice.h.

Referenced by SvgGraphicDevice().

◆ inkscapeEnabled_

bool bpp::SvgGraphicDevice::inkscapeEnabled_
private

Definition at line 62 of file SvgGraphicDevice.h.

◆ layers_

std::map<int, std::vector<std::string>, std::greater<int> > bpp::SvgGraphicDevice::layers_
private

Definition at line 61 of file SvgGraphicDevice.h.

Referenced by comment().

◆ LINE_DASHED

short GraphicDevice::LINE_DASHED = 21
staticinherited

◆ LINE_DOTTED

short GraphicDevice::LINE_DOTTED = 22
staticinherited

◆ LINE_SOLID

short GraphicDevice::LINE_SOLID = 20
staticinherited

◆ lineType_

short bpp::AbstractGraphicDevice::lineType_
privateinherited

◆ maxx_

double bpp::SvgGraphicDevice::maxx_
private

Definition at line 63 of file SvgGraphicDevice.h.

◆ maxy_

double bpp::SvgGraphicDevice::maxy_
private

Definition at line 63 of file SvgGraphicDevice.h.

◆ minx_

double bpp::SvgGraphicDevice::minx_
private

Definition at line 63 of file SvgGraphicDevice.h.

◆ miny_

double bpp::SvgGraphicDevice::miny_
private

Definition at line 63 of file SvgGraphicDevice.h.

◆ out_

std::ostream& bpp::SvgGraphicDevice::out_
private

Definition at line 60 of file SvgGraphicDevice.h.

◆ pointSize_

unsigned int bpp::AbstractGraphicDevice::pointSize_
privateinherited

◆ TEXT_HORIZONTAL_CENTER

short GraphicDevice::TEXT_HORIZONTAL_CENTER = 0
staticinherited

Definition at line 179 of file GraphicDevice.h.

Referenced by bpp::PgfGraphicDevice::drawText().

◆ TEXT_HORIZONTAL_LEFT

short GraphicDevice::TEXT_HORIZONTAL_LEFT = 1
staticinherited

Definition at line 180 of file GraphicDevice.h.

Referenced by bpp::PgfGraphicDevice::drawText().

◆ TEXT_HORIZONTAL_RIGHT

short GraphicDevice::TEXT_HORIZONTAL_RIGHT = 2
staticinherited

Definition at line 181 of file GraphicDevice.h.

Referenced by bpp::PgfGraphicDevice::drawText().

◆ TEXT_VERTICAL_BOTTOM

short GraphicDevice::TEXT_VERTICAL_BOTTOM = 4
staticinherited

Definition at line 183 of file GraphicDevice.h.

Referenced by bpp::PgfGraphicDevice::drawText().

◆ TEXT_VERTICAL_CENTER

short GraphicDevice::TEXT_VERTICAL_CENTER = 3
staticinherited

Definition at line 182 of file GraphicDevice.h.

Referenced by bpp::PgfGraphicDevice::drawText().

◆ TEXT_VERTICAL_TOP

short GraphicDevice::TEXT_VERTICAL_TOP = 5
staticinherited

Definition at line 184 of file GraphicDevice.h.

Referenced by bpp::PgfGraphicDevice::drawText().

◆ xUnit_

double bpp::AbstractGraphicDevice::xUnit_
privateinherited

◆ yUnit_

double bpp::AbstractGraphicDevice::yUnit_
privateinherited

The documentation for this class was generated from the following files: