bpp-core3  3.0.0
GraphicDevice.h
Go to the documentation of this file.
1 //
2 // File: GraphicDevice.h
3 // Authors:
4 // Julien Dutheil
5 // Created: 2008-03-03 00:00:00
6 //
7 
8 /*
9  Copyright or © or Copr. Bio++ Development Team, (November 16, 2006)
10 
11  This software is a computer program whose purpose is to provide utilitary
12  classes. This file belongs to the Bio++ Project.
13 
14  This software is governed by the CeCILL license under French law and
15  abiding by the rules of distribution of free software. You can use,
16  modify and/ or redistribute the software under the terms of the CeCILL
17  license as circulated by CEA, CNRS and INRIA at the following URL
18  "http://www.cecill.info".
19 
20  As a counterpart to the access to the source code and rights to copy,
21  modify and redistribute granted by the license, users are provided only
22  with a limited warranty and the software's author, the holder of the
23  economic rights, and the successive licensors have only limited
24  liability.
25 
26  In this respect, the user's attention is drawn to the risks associated
27  with loading, using, modifying and/or developing or reproducing the
28  software by the user in light of its specific status of free software,
29  that may mean that it is complicated to manipulate, and that also
30  therefore means that it is reserved for developers and experienced
31  professionals having in-depth computer knowledge. Users are therefore
32  encouraged to load and test the software's suitability as regards their
33  requirements in conditions enabling the security of their systems and/or
34  data to be ensured and, more generally, to use and operate it in the
35  same conditions as regards security.
36 
37  The fact that you are presently reading this means that you have had
38  knowledge of the CeCILL license and that you accept its terms.
39 */
40 
41 #ifndef BPP_GRAPHICS_GRAPHICDEVICE_H
42 #define BPP_GRAPHICS_GRAPHICDEVICE_H
43 
44 
45 #include "Font/Font.h"
46 #include "RgbColor.h"
47 
48 namespace bpp
49 {
50 class UnvalidFlagException : public virtual Exception
51 {
52 public:
53  UnvalidFlagException(const std::string& text) : Exception(text) {}
54 };
55 
56 
63 {
64 public:
66  virtual ~GraphicDevice() {}
67 
68 public:
72  virtual void begin() = 0;
73 
81  virtual void end() = 0;
82 
86  virtual void setXUnit(double xu) = 0;
87 
91  virtual void setYUnit(double yu) = 0;
92 
96  virtual double getXUnit() const = 0;
97 
101  virtual double getYUnit() const = 0;
102 
103  virtual void setCurrentForegroundColor(const RGBColor& color) = 0;
104  virtual void setCurrentBackgroundColor(const RGBColor& color) = 0;
105  virtual void setCurrentFont(const Font& font) = 0;
106  virtual void setCurrentPointSize(unsigned int size) = 0;
107  virtual void setCurrentLineType(short type) = 0;
108  virtual void setCurrentLayer(int layerIndex) = 0;
109 
110  virtual const RGBColor& getCurrentForegroundColor() const = 0;
111  virtual const RGBColor& getCurrentBackgroundColor() const = 0;
112  virtual const Font& getCurrentFont() const = 0;
113  virtual unsigned int getCurrentPointSize() const = 0;
114  virtual short getCurrentLineType() const = 0;
115  virtual int getCurrentLayer() const = 0;
116 
117 
128  virtual void drawLine(double x1, double y1, double x2, double y2) = 0;
129 
142  virtual void drawRect(double x, double y, double width, double height, short fill = FILL_EMPTY) = 0;
143 
155  virtual void drawCircle(double x, double y, double radius, short fill = FILL_EMPTY) = 0;
156 
169  virtual void drawText(double x, double y, const std::string& text, short hpos = TEXT_HORIZONTAL_LEFT, short vpos = TEXT_VERTICAL_BOTTOM, double angle = 0) = 0;
170 
176  virtual void comment(const std::string& comment) = 0;
177 
178 public:
180  static short TEXT_HORIZONTAL_LEFT;
181  static short TEXT_HORIZONTAL_RIGHT;
182  static short TEXT_VERTICAL_CENTER;
183  static short TEXT_VERTICAL_BOTTOM;
184  static short TEXT_VERTICAL_TOP;
185 
186  static short FILL_EMPTY;
187  static short FILL_FILLED;
188  static short FILL_PATTERN;
189 
190  static short LINE_SOLID;
191  static short LINE_DASHED;
192  static short LINE_DOTTED;
193 };
194 } // end of namespace bpp.
195 #endif // BPP_GRAPHICS_GRAPHICDEVICE_H
Exception base class. Overload exception constructor (to control the exceptions mechanism)....
Definition: Exceptions.h:59
Data structure for fonts.
Definition: Font.h:59
Interface for all plotting devices.
Definition: GraphicDevice.h:63
virtual void setCurrentFont(const Font &font)=0
static short LINE_DOTTED
static short FILL_FILLED
virtual void drawText(double x, double y, const std::string &text, short hpos=TEXT_HORIZONTAL_LEFT, short vpos=TEXT_VERTICAL_BOTTOM, double angle=0)=0
Draw some characters.
static short TEXT_HORIZONTAL_LEFT
virtual void setCurrentLayer(int layerIndex)=0
virtual void setCurrentForegroundColor(const RGBColor &color)=0
virtual void setCurrentPointSize(unsigned int size)=0
static short LINE_DASHED
virtual void drawRect(double x, double y, double width, double height, short fill=FILL_EMPTY)=0
Draw a rectangle.
virtual void begin()=0
Start the painting.
static short TEXT_HORIZONTAL_CENTER
virtual ~GraphicDevice()
Definition: GraphicDevice.h:66
static short TEXT_VERTICAL_TOP
virtual int getCurrentLayer() const =0
virtual void setXUnit(double xu)=0
static short TEXT_HORIZONTAL_RIGHT
virtual unsigned int getCurrentPointSize() const =0
static short FILL_PATTERN
virtual void comment(const std::string &comment)=0
Add a comment in the output.
virtual void setCurrentLineType(short type)=0
virtual void end()=0
End the painting.
virtual void setCurrentBackgroundColor(const RGBColor &color)=0
virtual double getXUnit() const =0
static short FILL_EMPTY
static short TEXT_VERTICAL_CENTER
virtual void drawLine(double x1, double y1, double x2, double y2)=0
Draw a line between two points.
virtual double getYUnit() const =0
virtual const RGBColor & getCurrentBackgroundColor() const =0
virtual short getCurrentLineType() const =0
virtual void drawCircle(double x, double y, double radius, short fill=FILL_EMPTY)=0
Draw a circle.
virtual const Font & getCurrentFont() const =0
virtual void setYUnit(double yu)=0
virtual const RGBColor & getCurrentForegroundColor() const =0
static short TEXT_VERTICAL_BOTTOM
static short LINE_SOLID
Describe a color according to its red, green and blue componants.
Definition: RgbColor.h:60
UnvalidFlagException(const std::string &text)
Definition: GraphicDevice.h:53