OpenASIP 2.2
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
EPSDC Class Reference

#include <EPSDC.hh>

Inheritance diagram for EPSDC:
Inheritance graph
Collaboration diagram for EPSDC:
Collaboration graph

Public Member Functions

 EPSDC ()
 
virtual ~EPSDC ()
 
virtual bool Ok () const
 
virtual void BeginDrawing ()
 
virtual void EndDrawing ()
 
virtual void DoDrawText (const wxString &text, wxCoord x, wxCoord y)
 
virtual void DoDrawLine (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
 
virtual void DoCrossHair (wxCoord x, wxCoord y)
 
virtual void DoDrawPoint (wxCoord x, wxCoord y)
 
virtual void DoDrawIcon (const wxIcon &icon, wxCoord x, wxCoord y)
 
virtual void DoDrawLines (int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset)
 
virtual void DoDrawArc (wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord xc, wxCoord yc)
 
virtual void DoDrawEllipticArc (wxCoord x, wxCoord y, wxCoord width, wxCoord height, double start, double end)
 
virtual bool DoFloodFill (wxCoord x, wxCoord y, const wxColour &colour, int style)
 
virtual void DoDrawBitmap (const wxBitmap &bitmap, wxCoord x, wxCoord y, bool transparent)
 
virtual void DoDrawPolygon (int n, wxPoint points[], wxCoord xoffset=0, wxCoord yoffset=0, int fillStyle=wxODDEVEN_RULE)
 
virtual void DoDrawRectangle (wxCoord x, wxCoord y, wxCoord width, wxCoord height)
 
virtual void DoDrawRoundedRectangle (wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius=20)
 
virtual void DoDrawEllipse (wxCoord x, wxCoord y, wxCoord width, wxCoord height)
 
virtual void DoDrawRotatedText (const wxString &text, wxCoord x, wxCoord y, double angle)
 
virtual bool DoBlit (wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, wxDC *source, wxCoord xsrc, wxCoord ysrc, int logicalFunc=wxCOPY, bool useMask=false, wxCoord xsrcMask=-1, wxCoord ysrcMask=-1)
 
virtual void DoGetSize (wxCoord *width, wxCoord *height) const
 
virtual void DoGetTextExtent (const wxString &text, wxCoord *w, wxCoord *h, wxCoord *descent=NULL, wxCoord *externalLeading=NULL, wxFont *font=NULL) const
 
virtual bool DoGetPixel (wxCoord x, wxCoord y, wxColour *colour) const
 
virtual void DoSetClippingRegionAsRegion (const wxRegion &region)
 
virtual bool CanDrawBitmap () const
 
virtual bool CanGetTextExtent () const
 
virtual void Clear ()
 
virtual void SetFont (const wxFont &font)
 
virtual void SetPen (const wxPen &pen)
 
virtual void SetBrush (const wxBrush &brush)
 
virtual void SetBackground (const wxBrush &brush)
 
virtual void SetBackgroundMode (int mode)
 
virtual void SetPalette (const wxPalette &palette)
 
virtual void SetLogicalFunction (int function)
 
virtual wxCoord GetCharHeight () const
 
virtual wxCoord GetCharWidth () const
 
virtual int GetDepth () const
 
virtual bool StartDoc (const wxString &message)
 
virtual void EndDoc ()
 
virtual void StartPage ()
 
virtual void EndPage ()
 
void setTitle (const std::string &title)
 
void setCreator (const std::string &creator)
 
void writeToStream (std::ostream &stream)
 

Private Member Functions

void setLineColour (const wxColour &colour)
 
void setFillColour (const wxColour &colour)
 
void drawCircle (int x, int y, unsigned radius)
 

Private Attributes

EPSGenerator eps_
 EPSGenerator generating the postscript code.
 
bool fill_
 True, if background brush is set to fill the shapes.
 
unsigned fontSize_
 Current font size.
 

Detailed Description

Encapsulated postscript device context.

EPSDC is a wxWidgets device context for drawing graphics and text to an eps file.

Definition at line 48 of file EPSDC.hh.

Constructor & Destructor Documentation

◆ EPSDC()

EPSDC::EPSDC ( )

The Constructor.

Definition at line 42 of file EPSDC.cc.

42 : wxDC(), fill_(false), fontSize_(0) {
43}
bool fill_
True, if background brush is set to fill the shapes.
Definition EPSDC.hh:191
unsigned fontSize_
Current font size.
Definition EPSDC.hh:193

◆ ~EPSDC()

EPSDC::~EPSDC ( )
virtual

The Destructor.

Definition at line 48 of file EPSDC.cc.

48 {
49}

Member Function Documentation

◆ BeginDrawing()

void EPSDC::BeginDrawing ( )
virtual

Called before the drawing ends.

Definition at line 300 of file EPSDC.cc.

300 {
301 // Do nothing.
302}

◆ CanDrawBitmap()

bool EPSDC::CanDrawBitmap ( ) const
virtual

Bitmap drawing not implemented.

Returns
Always false.

Definition at line 220 of file EPSDC.cc.

220 {
221 return false;
222}

◆ CanGetTextExtent()

bool EPSDC::CanGetTextExtent ( ) const
virtual

NOT IMPLEMENTED

Returns
Always false.

Definition at line 490 of file EPSDC.cc.

490 {
491 return false;
492}

◆ Clear()

void EPSDC::Clear ( )
virtual

Clears all drawings on the canvas.

Definition at line 136 of file EPSDC.cc.

136 {
138}
EPSGenerator eps_
EPSGenerator generating the postscript code.
Definition EPSDC.hh:189

References EPSGenerator::clearBuffer(), and eps_.

Here is the call graph for this function:

◆ DoBlit()

bool EPSDC::DoBlit ( wxCoord  xdest,
wxCoord  ydest,
wxCoord  width,
wxCoord  height,
wxDC *  source,
wxCoord  xsrc,
wxCoord  ysrc,
int  logicalFunc = wxCOPY,
bool  useMask = false,
wxCoord  xsrcMask = -1,
wxCoord  ysrcMask = -1 
)
virtual

NOT IMPLEMENTED

Definition at line 386 of file EPSDC.cc.

397 {
398
399 return false;
400}

◆ DoCrossHair()

void EPSDC::DoCrossHair ( wxCoord  x,
wxCoord  y 
)
virtual

NOT IMPLEMENTED

Definition at line 285 of file EPSDC.cc.

285 {
286}

◆ DoDrawArc()

void EPSDC::DoDrawArc ( wxCoord  x1,
wxCoord  y1,
wxCoord  x2,
wxCoord  y2,
wxCoord  xc,
wxCoord  yc 
)
virtual

NOT IMPLEMENTED

Definition at line 271 of file EPSDC.cc.

271 {
272}

◆ DoDrawBitmap()

void EPSDC::DoDrawBitmap ( const wxBitmap &  bitmap,
wxCoord  x,
wxCoord  y,
bool  transparent 
)
virtual

NOT IMPLEMENTED

Definition at line 293 of file EPSDC.cc.

293 {
294}

◆ DoDrawEllipse()

void EPSDC::DoDrawEllipse ( wxCoord  x,
wxCoord  y,
wxCoord  width,
wxCoord  height 
)
virtual

Draws an ellipse on the dc.

Parameters
xEllipse bounding box lower left corner x-coordinate.
yEllipse bounding box lower left corner y-coordinate.
widthEllipse width.
heightEllipse height.

Definition at line 361 of file EPSDC.cc.

361 {
362
363 y = -1 * y -height;
364
365 // Check if the ellipse is actually circle, which will generated more
366 // simple postscript-code.
367 if (width == height) {
368 x += width / 2;
369 y += width / 2;
370 drawCircle(x, y, width / 2);
371 return;
372 }
373
374 if (fill_) {
375 eps_.drawFilledEllipse(x, y, width, height);
376 } else {
377 eps_.drawEllipse(x, y, width, height);
378 }
379}
void drawCircle(int x, int y, unsigned radius)
Definition EPSDC.cc:437
void drawEllipse(int x, int y, unsigned width, unsigned height)
void drawFilledEllipse(int x, int y, unsigned width, unsigned height)

References drawCircle(), EPSGenerator::drawEllipse(), EPSGenerator::drawFilledEllipse(), eps_, and fill_.

Here is the call graph for this function:

◆ DoDrawEllipticArc()

void EPSDC::DoDrawEllipticArc ( wxCoord  x,
wxCoord  y,
wxCoord  width,
wxCoord  height,
double  start,
double  end 
)
virtual

NOT IMPLEMENTED

Definition at line 330 of file EPSDC.cc.

336 {
337}

◆ DoDrawIcon()

void EPSDC::DoDrawIcon ( const wxIcon &  icon,
wxCoord  x,
wxCoord  y 
)
virtual

NOT IMPLEMENTED

Definition at line 278 of file EPSDC.cc.

278 {
279}

◆ DoDrawLine()

void EPSDC::DoDrawLine ( wxCoord  x1,
wxCoord  y1,
wxCoord  x2,
wxCoord  y2 
)
virtual

Draws a line on the dc.

Parameters
x1x-coordinate of the first end of the line.
y1y-coordinate of the first end of the line.
x2x-coordinate of the second end of the line.
y2y-coordinate of the second end of the line.

Definition at line 70 of file EPSDC.cc.

70 {
71 eps_.drawLine(x1, -1 * y1, x2, -1 * y2);
72}
void drawLine(int llx, int lly, int urx, int ury)

References EPSGenerator::drawLine(), and eps_.

Here is the call graph for this function:

◆ DoDrawLines()

void EPSDC::DoDrawLines ( int  n,
wxPoint  points[],
wxCoord  xoffset,
wxCoord  yoffset 
)
virtual

NOT IMPLEMENTED

Definition at line 318 of file EPSDC.cc.

322 {
323}

◆ DoDrawPoint()

void EPSDC::DoDrawPoint ( wxCoord  x,
wxCoord  y 
)
virtual

NOT IMPLEMENTED.

Definition at line 248 of file EPSDC.cc.

248 {
249}

◆ DoDrawPolygon()

void EPSDC::DoDrawPolygon ( int  n,
wxPoint  vertices[],
wxCoord  xOffset = 0,
wxCoord  yOffset = 0,
int  fillStyle = wxODDEVEN_RULE 
)
virtual

Draws a polygon on the dc.

Parameters
nNumber of vertices.
verticesVertices.
xOffsetOffset for x-coordinates.
yOffsetOffset for y-coordinates.

Definition at line 83 of file EPSDC.cc.

88 {
89
90 // Create VertexList of the vertices.
91 VertexList list;
92 for (int i = 0; i < n; i++) {
93 list.addVertex(vertices[i].x + xOffset, -1 * (vertices[i].y + yOffset));
94 }
95
96 if (fill_) {
98 } else {
99 eps_.drawPolygon(list);
100 }
101
102}
void drawPolygon(const VertexList &vertices)
void drawFilledPolygon(const VertexList &vertices)
void addVertex(int x, int y)
Definition VertexList.cc:57

References VertexList::addVertex(), EPSGenerator::drawFilledPolygon(), EPSGenerator::drawPolygon(), eps_, and fill_.

Here is the call graph for this function:

◆ DoDrawRectangle()

void EPSDC::DoDrawRectangle ( wxCoord  x,
wxCoord  y,
wxCoord  width,
wxCoord  height 
)
virtual

Draws a rectangle on the dc.

Parameters
xLower left corner x-coordinate of the canvas.
yLower left corner y-coordinate of the canvas.

Definition at line 111 of file EPSDC.cc.

111 {
112 if (fill_) {
113 eps_.drawFilledRectangle(x, (-1 * y - height), width, height);
114 } else {
115 eps_.drawRectangle(x, (-1 * y - height), width, height);
116 }
117}
void drawRectangle(int x, int y, unsigned width, unsigned height)
void drawFilledRectangle(int x, int y, unsigned width, unsigned height)

References EPSGenerator::drawFilledRectangle(), EPSGenerator::drawRectangle(), eps_, and fill_.

Referenced by DoDrawRoundedRectangle().

Here is the call graph for this function:

◆ DoDrawRotatedText()

void EPSDC::DoDrawRotatedText ( const wxString &  text,
wxCoord  x,
wxCoord  y,
double  angle 
)
virtual

NOT IMPLEMENTED.

Definition at line 240 of file EPSDC.cc.

241 {
242}

◆ DoDrawRoundedRectangle()

void EPSDC::DoDrawRoundedRectangle ( wxCoord  x,
wxCoord  y,
wxCoord  width,
wxCoord  height,
double  radius = 20 
)
virtual

Not implemented, falls back to a rectangle.

Definition at line 343 of file EPSDC.cc.

348 {
349 DoDrawRectangle(x, y, width, height);
350}
virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
Definition EPSDC.cc:111

References DoDrawRectangle().

Here is the call graph for this function:

◆ DoDrawText()

void EPSDC::DoDrawText ( const wxString &  text,
wxCoord  x,
wxCoord  y 
)
virtual

Draws text on the dc.

Parameters
textText to draw.
xx-coordinate of the lower left corner of the text.
yy-coordinate of the lower left corner of the text.

Definition at line 127 of file EPSDC.cc.

127 {
128 std::string textStr = WxConversion::toString(text);
129 eps_.drawText(x, -1 * y - 12, textStr);
130}
void drawText(int x, int y, std::string text)
static std::string toString(const wxString &source)

References EPSGenerator::drawText(), eps_, and WxConversion::toString().

Here is the call graph for this function:

◆ DoFloodFill()

bool EPSDC::DoFloodFill ( wxCoord  x,
wxCoord  y,
const wxColour &  colour,
int  style 
)
virtual

NOT IMPLEMENTED

Definition at line 255 of file EPSDC.cc.

255 {
256 return false;
257}

◆ DoGetPixel()

bool EPSDC::DoGetPixel ( wxCoord  x,
wxCoord  y,
wxColour *  colour 
) const
virtual

NOT IMPLEMENTED

Returns
Always false.

Definition at line 472 of file EPSDC.cc.

472 {
473 return false;
474}

◆ DoGetSize()

void EPSDC::DoGetSize ( wxCoord *  width,
wxCoord *  height 
) const
virtual

NOT IMPLEMENTED

Definition at line 264 of file EPSDC.cc.

264 {
265}

◆ DoGetTextExtent()

void EPSDC::DoGetTextExtent ( const wxString &  text,
wxCoord *  w,
wxCoord *  h,
wxCoord *  descent = NULL,
wxCoord *  externalLeading = NULL,
wxFont *  font = NULL 
) const
virtual

Returns crude approximation of the width and height of a text on the dc.

Parameters
wApproximation of width is set as the value of w.
hApproximation of height is set as the value of h.

Definition at line 453 of file EPSDC.cc.

459 {
460
461 // TODO: find a better way to approximate text extent.
462 *h = fontSize_;
463 *w = Conversion::toInt((fontSize_ * 72.0 / 120) * text.Length());
464}
static int toInt(const T &source)

References fontSize_, and Conversion::toInt().

Here is the call graph for this function:

◆ DoSetClippingRegionAsRegion()

void EPSDC::DoSetClippingRegionAsRegion ( const wxRegion &  region)
virtual

NOT IMPLEMENTED

Definition at line 480 of file EPSDC.cc.

480 {
481}

◆ drawCircle()

void EPSDC::drawCircle ( int  x,
int  y,
unsigned  radius 
)
private

Draws a circle.

Parameters
xX-coordinate of the circle centre.
yY-coordinate of the circle centre.
radiusRadius of the circle.

Definition at line 437 of file EPSDC.cc.

437 {
438
439 if (fill_) {
440 eps_.drawFilledCircle(x, y, radius);
441 } else {
442 eps_.drawCircle(x, y, radius);
443 }
444}
void drawFilledCircle(int x, int y, unsigned radius)
void drawCircle(int x, int y, unsigned radius)

References EPSGenerator::drawCircle(), EPSGenerator::drawFilledCircle(), eps_, and fill_.

Referenced by DoDrawEllipse().

Here is the call graph for this function:

◆ EndDoc()

void EPSDC::EndDoc ( )
virtual

Ends the document that is being drawn on.

Definition at line 576 of file EPSDC.cc.

576 {
577 // Do nothing.
578}

◆ EndDrawing()

void EPSDC::EndDrawing ( )
virtual

Called when the drawing ends.

Definition at line 308 of file EPSDC.cc.

308 {
309 // Do nothing.
310}

◆ EndPage()

void EPSDC::EndPage ( )
virtual

Ends current page.

Definition at line 568 of file EPSDC.cc.

568 {
569 // Do nothing.
570}

Referenced by MachineCanvas::saveEPS().

◆ GetCharHeight()

wxCoord EPSDC::GetCharHeight ( ) const
virtual

NOT IMPLEMENTED

Returns
Always zero.

Definition at line 532 of file EPSDC.cc.

532 {
533 return 0;
534}

◆ GetCharWidth()

wxCoord EPSDC::GetCharWidth ( ) const
virtual

NOT IMPLEMENTED

Returns
Always zero.

Definition at line 542 of file EPSDC.cc.

542 {
543 return 0;
544}

◆ GetDepth()

int EPSDC::GetDepth ( ) const
virtual

NOT IMPLEMENTED

Returns
Always zero.

Definition at line 552 of file EPSDC.cc.

552 {
553 return 0;
554}

◆ Ok()

bool EPSDC::Ok ( ) const
virtual

Returns true, if the DC is ok to use.

Returns
always true

Definition at line 57 of file EPSDC.cc.

57 {
58 return true;
59}

◆ SetBackground()

void EPSDC::SetBackground ( const wxBrush &  brush)
virtual

NOT IMPLEMENTED

Definition at line 499 of file EPSDC.cc.

499 {
500}

◆ SetBackgroundMode()

void EPSDC::SetBackgroundMode ( int  mode)
virtual

NOT IMPLEMENTED

Definition at line 507 of file EPSDC.cc.

507 {
508}

◆ SetBrush()

void EPSDC::SetBrush ( const wxBrush &  brush)
virtual

Sets the brush used for filling shapes with colour.

Only solid and transparent brushes are supported. Everything else is interpreted as transparent brush.

Definition at line 171 of file EPSDC.cc.

171 {
172 if (brush.GetStyle() == wxSOLID) {
173 fill_ = true;
174 wxColour fillColour = brush.GetColour();
175 setFillColour(fillColour);
176 } else {
177 fill_ = false;
178 }
179}
void setFillColour(const wxColour &colour)
Definition EPSDC.cc:421

References fill_, and setFillColour().

Here is the call graph for this function:

◆ setCreator()

void EPSDC::setCreator ( const std::string &  creator)

Sets the eps-file creator string.

Parameters
creatorString describin the eps file creator.

Definition at line 199 of file EPSDC.cc.

199 {
200 eps_.setCreator(creator);
201}
void setCreator(std::string creator)

References eps_, and EPSGenerator::setCreator().

Referenced by MachineCanvas::saveEPS().

Here is the call graph for this function:

◆ setFillColour()

void EPSDC::setFillColour ( const wxColour &  colour)
private

Sets the filling colour of the eps generator.

Parameters
colourNew filing colour.

Definition at line 421 of file EPSDC.cc.

421 {
422 double redC = (double)colour.Red() / 255;
423 double greenC = (double)colour.Green() / 255;
424 double blueC = (double)colour.Blue() / 255;
425 eps_.setFillColour(redC, greenC, blueC);
426}
void setFillColour(double r, double g, double b)

References eps_, and EPSGenerator::setFillColour().

Referenced by SetBrush().

Here is the call graph for this function:

◆ SetFont()

void EPSDC::SetFont ( const wxFont &  font)
virtual

Sets the dc font.

Only font size is currently set.

Parameters
fontFont to set.

Definition at line 148 of file EPSDC.cc.

148 {
149 fontSize_ = font.GetPointSize();
151}
void setFont(unsigned size, std::string fontName="Courier-Bold")

References eps_, fontSize_, and EPSGenerator::setFont().

Here is the call graph for this function:

◆ setLineColour()

void EPSDC::setLineColour ( const wxColour &  colour)
private

Sets the line drawing colour of the eps generator.

Parameters
colourNew line drawing colour.

Definition at line 408 of file EPSDC.cc.

408 {
409 double redC = (double)colour.Red() / 255;
410 double greenC = (double)colour.Green() / 255;
411 double blueC = (double)colour.Blue() / 255;
412 eps_.setLineColour(redC, greenC, blueC);
413}
void setLineColour(double r, double g, double b)

References eps_, and EPSGenerator::setLineColour().

Referenced by SetPen().

Here is the call graph for this function:

◆ SetLogicalFunction()

void EPSDC::SetLogicalFunction ( int  function)
virtual

NOT IMPLEMENTED

Definition at line 522 of file EPSDC.cc.

522 {
523}

◆ SetPalette()

void EPSDC::SetPalette ( const wxPalette &  palette)
virtual

NOT IMPLEMENTED

Definition at line 515 of file EPSDC.cc.

515 {
516}

◆ SetPen()

void EPSDC::SetPen ( const wxPen &  pen)
virtual

NOT IMPLEMENTED

Definition at line 158 of file EPSDC.cc.

158 {
159 wxColour lineColour = pen.GetColour();
160 eps_.setLineWidth(pen.GetWidth());
161 setLineColour(lineColour);
162}
void setLineColour(const wxColour &colour)
Definition EPSDC.cc:408
void setLineWidth(unsigned width)

References eps_, setLineColour(), and EPSGenerator::setLineWidth().

Here is the call graph for this function:

◆ setTitle()

void EPSDC::setTitle ( const std::string &  title)

Sets the eps-file title.

Parameters
titleString which will be set as the eps file title.

Definition at line 189 of file EPSDC.cc.

189 {
190 eps_.setTitle(title);
191}
void setTitle(std::string title)

References eps_, and EPSGenerator::setTitle().

Referenced by MachineCanvas::saveEPS().

Here is the call graph for this function:

◆ StartDoc()

bool EPSDC::StartDoc ( const wxString &  message)
virtual

Called by the device context client before the drawing is started.

Returns
Always true.

Definition at line 231 of file EPSDC.cc.

231 {
232 return true;
233}

◆ StartPage()

void EPSDC::StartPage ( )
virtual

Starts a new page in the document.

Definition at line 560 of file EPSDC.cc.

560 {
561 // Do nothing.
562}

Referenced by MachineCanvas::saveEPS().

◆ writeToStream()

void EPSDC::writeToStream ( std::ostream &  stream)

Writes the generated eps file to an output stream.

Parameters
streamOutput stream where the eps file contents will be written.

Definition at line 209 of file EPSDC.cc.

209 {
210 eps_.writeEPS(stream);
211}
void writeEPS(std::ostream &stream)

References eps_, and EPSGenerator::writeEPS().

Referenced by MachineCanvas::saveEPS().

Here is the call graph for this function:

Member Data Documentation

◆ eps_

EPSGenerator EPSDC::eps_
private

◆ fill_

bool EPSDC::fill_
private

True, if background brush is set to fill the shapes.

Definition at line 191 of file EPSDC.hh.

Referenced by DoDrawEllipse(), DoDrawPolygon(), DoDrawRectangle(), drawCircle(), and SetBrush().

◆ fontSize_

unsigned EPSDC::fontSize_
private

Current font size.

Definition at line 193 of file EPSDC.hh.

Referenced by DoGetTextExtent(), and SetFont().


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