Go to the documentation of this file.
33 #include <boost/format.hpp>
52 hasTitle_(
false), title_(
""), creator_(
"TCE EPS Generator"),
53 lineWidth_(1), minX_(0), minY_(0), maxX_(0), maxY_(0),
54 scale_(1) ,boundsSet_(
false), xMargin_(DEFAULT_MARGIN),
55 yMargin_(DEFAULT_MARGIN) {
121 int x,
int y,
unsigned width,
unsigned height) {
142 int x,
int y,
unsigned width,
unsigned height) {
150 format line3 = format(
FMT_RLINETO) % (-1 * (int)width) % 0;
240 for (
unsigned i = 1; i < vertices.
size(); i++) {
301 std::string fmtCircle =
" %1% %2% %3% 0 360 arc";
303 boost::format circle = format(fmtCircle) % x % y % radius;
333 int x,
int y,
unsigned width,
unsigned height) {
349 int x,
int y,
unsigned width,
unsigned height,
bool fill) {
356 format fmtScale = format(
"1 %1% %2% div scale");
357 format fmtTranslate = format(
"%1% %2% translate");
358 fmtScale % width % height;
359 fmtTranslate % (x + width / 2) % (y + height / 2);
362 buffer_.push(fmtTranslate.str());
366 std::string fmtEllipse =
" 0 0 %4% 2 div 0 360 arc";
368 boost::format ellipse = format(fmtEllipse) % x % y % width % height;
394 format fmtMoveTo(
"%1% %2% moveto");
395 format fmtShowText(
" (%1%) show");
402 buffer_.push(fmtShowText.str());
430 if (title.length() > 0) {
447 std::string setlinewidth =
"%1% setlinewidth";
448 buffer_.push(str(format(setlinewidth) % width));
461 format
setFont = format(
"/%2% findfont %1% scalefont setfont");
476 if (r < 0 || g < 0 || b < 0 || r > 1 || g > 1 || b > 1) {
478 "Colour component values must be between 0 and 1.";
479 std::string proc =
"EPSGenerator::setLineColour";
480 OutOfRange e(__FILE__, __LINE__, proc, error);
500 if (r < 0 || g < 0 || b < 0 || r > 1 || g > 1 || b > 1) {
502 "Colour component values must be between 0 and 1.";
503 std::string proc =
"EPSGenerator::setFillColour";
504 OutOfRange e(__FILE__, __LINE__, proc, error);
535 ostream <<
"%!PS-Adobe-3.0 EPSF-3.0" << endl;
536 ostream <<
"%%BoundingBox: 0 0 " << w <<
" " << h <<
" " << endl;
538 ostream <<
"%%Title: (" <<
title_ <<
")" << endl;
540 ostream <<
"%%Creator: " <<
creator_ << endl;
542 ostream <<
"%%EndComments" << endl;
555 std::string line =
buffer_.front();
557 ostream << line << endl;
559 ostream << endl <<
"showpage" << endl << endl;
562 ostream <<
"%%EOF" << endl;
578 std::string error =
"Scaling factor must be greater than zero.";
579 std::string proc =
"EPSGenerator::setScale";
580 OutOfRange e(__FILE__, __LINE__, proc, error);
605 format setColour(
"%1% %2% %3% setrgbcolor");
615 format setColour(
"%1% %2% %3% setrgbcolor");
int minY_
Minimum y-coordinate used before scaling & translation.
std::queue< std::string > buffer_
Buffer for the .eps code to be written.
void appendToBounds(int x, int y)
void drawRectanglePath(int x, int y, unsigned width, unsigned height)
void drawFilledRectangle(int x, int y, unsigned width, unsigned height)
static const std::string FMT_RLINETO
Format string for postscript rlineto command.
bool boundsSet_
True, if a point has been added to the bounds.
double scale_
Final scaling factor for the eps file.
void setFont(unsigned size, std::string fontName="Courier-Bold")
static const std::string FMT_MOVETO
Format string for postscript moveto command.
colour lineColour_
Current drawing colour for lines.
void setTitle(std::string title)
void drawEllipse(int x, int y, unsigned width, unsigned height)
void drawFilledCircle(int x, int y, unsigned radius)
void drawRectangle(int x, int y, unsigned width, unsigned height)
void drawPolygonPath(const VertexList &vertices)
void drawCirclePath(int x, int y, unsigned radius)
int maxY_
Maximum y-coordinate used before scaling & translation.
#define assert(condition)
void drawFilledPolygon(const VertexList &vertices)
static const std::string FMT_LINETO
Format string for postscript lineto command.
void setScale(double scale)
int vertexY(size_t index) const
int vertexX(size_t index) const
void setMargins(unsigned x, unsigned y)
void drawText(int x, int y, std::string text)
int minX_
Minimum x-coordinate used before scaling & translation.
void setLineWidth(unsigned width)
static const unsigned DEFAULT_MARGIN
Default margin width.
unsigned xMargin_
Margin to add on the left and right side of the figure in pixels.
std::string creator_
String describing the creator of the document.
std::string title_
Title of the EPS file.
void drawFilledEllipse(int x, int y, unsigned width, unsigned height)
void setFillColour(double r, double g, double b)
void setLineColour(double r, double g, double b)
find Finds info of the inner loops in the false
void drawLine(int llx, int lly, int urx, int ury)
void drawCircle(int x, int y, unsigned radius)
unsigned lineWidth_
Current width of the lines drawn.
void doDrawEllipse(int x, int y, unsigned width, unsigned height, bool fill)
std::string creationDate_
String describing the creation date of the EPS file.
int maxX_
Maximum x-coordinate used before scaling & translation.
bool hasTitle_
True, if the EPS file has a title.
unsigned yMargin_
Margin to add on the top and bottom side of the figure in pixels.
void writeEPS(std::ostream &stream)
void drawPolygon(const VertexList &vertices)
void setCreator(std::string creator)
colour fillColour_
Current colour for filling shape backgrounds.