bpp-core  2.1.0
bpp::PgfGraphicDevice Class Reference

LaTeX Portable Graphic Format (Pgf) plotting format. More...

#include <Bpp/Graphics/Latex/PgfGraphicDevice.h>

+ Inheritance diagram for bpp::PgfGraphicDevice:
+ Collaboration diagram for bpp::PgfGraphicDevice:

List of all members.

Public Member Functions

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

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::string fgColorStr_
std::string bgColorStr_
std::vector< std::string > content_
std::vector< int > layers_
std::map< const RGBColor,
std::string > 
colorIndex_
unsigned int colorCount_
bool useLayers_
bool contentStarted_
std::map< short int, std::string > fontShapes_
std::map< short int, std::string > fontSeries_

Detailed Description

LaTeX Portable Graphic Format (Pgf) plotting format.

Definition at line 57 of file PgfGraphicDevice.h.


Constructor & Destructor Documentation

PgfGraphicDevice::PgfGraphicDevice ( std::ostream &  out,
double  unit 
)

Build a new Pgf device object.

Coordinates in Pgf are the same as in LaTeX, so it can be any of cm, mm, in, pt, px, etc. For compatibility with other devices, the constructor takes as input the scale of the drawing, as cm per points. All coordinates and widths will be multiplied by the factor in the output file.

Parameters:
outThe output stream.
unitThe unit length.

Definition at line 47 of file PgfGraphicDevice.cpp.

References bpp::ColorTools::BLACK, bpp::ColorTools::BLUE, colorIndex_, bpp::ColorTools::CYAN, fontSeries_, fontShapes_, bpp::ColorTools::GREEN, bpp::ColorTools::MAGENTA, bpp::ColorTools::RED, setCurrentFont(), bpp::AbstractGraphicDevice::setXUnit(), bpp::AbstractGraphicDevice::setYUnit(), bpp::Font::STYLE_ITALIC, bpp::Font::STYLE_NORMAL, bpp::Font::WEIGHT_BOLD, bpp::Font::WEIGHT_NORMAL, bpp::ColorTools::WHITE, and bpp::ColorTools::YELLOW.

virtual bpp::PgfGraphicDevice::~PgfGraphicDevice ( ) [inline, virtual]

Definition at line 86 of file PgfGraphicDevice.h.


Member Function Documentation

void PgfGraphicDevice::begin ( ) [virtual]

Start the painting.

Implements bpp::GraphicDevice.

Definition at line 79 of file PgfGraphicDevice.cpp.

References colorCount_, colorIndex_, content_, contentStarted_, layers_, and useLayers_.

void bpp::PgfGraphicDevice::comment ( const std::string &  comment) [inline, virtual]

Add a comment in the output.

Parameters:
commentComment text.

Implements bpp::GraphicDevice.

Definition at line 103 of file PgfGraphicDevice.h.

References content_.

void PgfGraphicDevice::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 263 of file PgfGraphicDevice.cpp.

References content_, contentStarted_, and bpp::GraphicDevice::FILL_FILLED.

void PgfGraphicDevice::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 240 of file PgfGraphicDevice.cpp.

References content_, and contentStarted_.

void PgfGraphicDevice::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 251 of file PgfGraphicDevice.cpp.

References content_, contentStarted_, and bpp::GraphicDevice::FILL_FILLED.

void PgfGraphicDevice::drawText ( double  x,
double  y,
const std::string &  text,
short  hpos = TEXT_HORIZONTAL_LEFT,
short  vpos = TEXT_VERTICAL_BOTTOM,
double  angle = 0 
) throw (UnvalidFlagException) [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 275 of file PgfGraphicDevice.cpp.

void PgfGraphicDevice::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 90 of file PgfGraphicDevice.cpp.

References colorIndex_, comp(), content_, bpp::AbstractGraphicDevice::getCurrentLayer(), bpp::AbstractGraphicDevice::getXUnit(), bpp::AbstractGraphicDevice::getYUnit(), layers_, out_, bpp::TextTools::toString(), and useLayers_.

const RGBColor& bpp::AbstractGraphicDevice::getCurrentBackgroundColor ( ) const [inline, virtual, inherited]

Implements bpp::GraphicDevice.

Definition at line 93 of file AbstractGraphicDevice.h.

References bpp::AbstractGraphicDevice::bgColor_.

const Font& bpp::AbstractGraphicDevice::getCurrentFont ( ) const [inline, virtual, inherited]

Implements bpp::GraphicDevice.

Definition at line 94 of file AbstractGraphicDevice.h.

References bpp::AbstractGraphicDevice::font_.

const RGBColor& bpp::AbstractGraphicDevice::getCurrentForegroundColor ( ) const [inline, virtual, inherited]

Implements bpp::GraphicDevice.

Definition at line 92 of file AbstractGraphicDevice.h.

References bpp::AbstractGraphicDevice::fgColor_.

int bpp::AbstractGraphicDevice::getCurrentLayer ( ) const [inline, virtual, inherited]
short bpp::AbstractGraphicDevice::getCurrentLineType ( ) const [inline, virtual, inherited]

Implements bpp::GraphicDevice.

Definition at line 96 of file AbstractGraphicDevice.h.

References bpp::AbstractGraphicDevice::lineType_.

unsigned int bpp::AbstractGraphicDevice::getCurrentPointSize ( ) const [inline, virtual, inherited]

Implements bpp::GraphicDevice.

Definition at line 95 of file AbstractGraphicDevice.h.

References bpp::AbstractGraphicDevice::pointSize_.

const std::string& bpp::PgfGraphicDevice::getFontShape ( const Font font)
double bpp::AbstractGraphicDevice::getXUnit ( ) const [inline, virtual, inherited]
Returns:
The x expansion factor. The actual unit actually depends on the implementation.

Implements bpp::GraphicDevice.

Definition at line 76 of file AbstractGraphicDevice.h.

References bpp::AbstractGraphicDevice::xUnit_.

Referenced by end().

double bpp::AbstractGraphicDevice::getYUnit ( ) const [inline, virtual, inherited]
Returns:
The y expansion factor. The actual unit actually depends on the implementation.

Implements bpp::GraphicDevice.

Definition at line 77 of file AbstractGraphicDevice.h.

References bpp::AbstractGraphicDevice::yUnit_.

Referenced by end().

double bpp::AbstractGraphicDevice::revx_ ( double  x) const [inline, protected, inherited]

Definition at line 104 of file AbstractGraphicDevice.h.

References bpp::AbstractGraphicDevice::xUnit_.

double bpp::AbstractGraphicDevice::revy_ ( double  y) const [inline, protected, inherited]

Definition at line 105 of file AbstractGraphicDevice.h.

References bpp::AbstractGraphicDevice::yUnit_.

void PgfGraphicDevice::setCurrentBackgroundColor ( const RGBColor color) [virtual]
void PgfGraphicDevice::setCurrentForegroundColor ( const RGBColor color) [virtual]
void PgfGraphicDevice::setCurrentLineType ( short  type) throw (Exception) [virtual]
void PgfGraphicDevice::setCurrentPointSize ( unsigned int  size) [virtual]

Reimplemented from bpp::AbstractGraphicDevice.

Definition at line 190 of file PgfGraphicDevice.cpp.

References content_, and bpp::AbstractGraphicDevice::x_().

void bpp::AbstractGraphicDevice::setXUnit ( double  xu) [inline, virtual, inherited]
Parameters:
xuThe x expansion factor. The actual unit actually depends on the implementation.

Implements bpp::GraphicDevice.

Definition at line 74 of file AbstractGraphicDevice.h.

References bpp::AbstractGraphicDevice::xUnit_.

Referenced by PgfGraphicDevice().

void bpp::AbstractGraphicDevice::setYUnit ( double  yu) [inline, virtual, inherited]
Parameters:
yuThe y expansion factor. The actual unit actually depends on the implementation.

Implements bpp::GraphicDevice.

Definition at line 75 of file AbstractGraphicDevice.h.

References bpp::AbstractGraphicDevice::yUnit_.

Referenced by PgfGraphicDevice().

double bpp::AbstractGraphicDevice::x_ ( double  x) const [inline, protected, inherited]

Definition at line 101 of file AbstractGraphicDevice.h.

References bpp::AbstractGraphicDevice::xUnit_.

Referenced by setCurrentPointSize().

double bpp::AbstractGraphicDevice::y_ ( double  y) const [inline, protected, inherited]

Definition at line 102 of file AbstractGraphicDevice.h.

References bpp::AbstractGraphicDevice::yUnit_.


Member Data Documentation

std::string bpp::PgfGraphicDevice::bgColorStr_ [private]

Definition at line 63 of file PgfGraphicDevice.h.

Referenced by setCurrentBackgroundColor(), and setCurrentLayer().

unsigned int bpp::PgfGraphicDevice::colorCount_ [private]

Definition at line 67 of file PgfGraphicDevice.h.

Referenced by begin(), setCurrentBackgroundColor(), and setCurrentForegroundColor().

std::map<const RGBColor, std::string> bpp::PgfGraphicDevice::colorIndex_ [private]
std::string bpp::PgfGraphicDevice::fgColorStr_ [private]

Definition at line 62 of file PgfGraphicDevice.h.

Referenced by setCurrentForegroundColor(), and setCurrentLayer().

short GraphicDevice::FILL_EMPTY = 10 [static, inherited]

Definition at line 186 of file GraphicDevice.h.

short GraphicDevice::FILL_FILLED = 11 [static, inherited]

Definition at line 187 of file GraphicDevice.h.

Referenced by drawCircle(), and drawRect().

short GraphicDevice::FILL_PATTERN = 12 [static, inherited]

Definition at line 188 of file GraphicDevice.h.

std::map<short int, std::string> bpp::PgfGraphicDevice::fontSeries_ [mutable, private]

Definition at line 71 of file PgfGraphicDevice.h.

Referenced by PgfGraphicDevice(), and setCurrentFont().

std::map<short int, std::string> bpp::PgfGraphicDevice::fontShapes_ [mutable, private]

Definition at line 70 of file PgfGraphicDevice.h.

Referenced by PgfGraphicDevice(), and setCurrentFont().

std::vector<int> bpp::PgfGraphicDevice::layers_ [private]

Definition at line 65 of file PgfGraphicDevice.h.

Referenced by begin(), end(), and setCurrentLayer().

std::ostream& bpp::PgfGraphicDevice::out_ [private]

Definition at line 61 of file PgfGraphicDevice.h.

Referenced by end().

short GraphicDevice::TEXT_HORIZONTAL_CENTER = 0 [static, inherited]

Definition at line 179 of file GraphicDevice.h.

short GraphicDevice::TEXT_HORIZONTAL_LEFT = 1 [static, inherited]

Definition at line 180 of file GraphicDevice.h.

short GraphicDevice::TEXT_HORIZONTAL_RIGHT = 2 [static, inherited]

Definition at line 181 of file GraphicDevice.h.

short GraphicDevice::TEXT_VERTICAL_BOTTOM = 4 [static, inherited]

Definition at line 183 of file GraphicDevice.h.

short GraphicDevice::TEXT_VERTICAL_CENTER = 3 [static, inherited]

Definition at line 182 of file GraphicDevice.h.

short GraphicDevice::TEXT_VERTICAL_TOP = 5 [static, inherited]

Definition at line 184 of file GraphicDevice.h.

Definition at line 68 of file PgfGraphicDevice.h.

Referenced by begin(), end(), and setCurrentLayer().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Friends