bpp-core  2.2.0
GraphicDevice.h
Go to the documentation of this file.
1 //
2 // File: GraphicDevice.h
3 // Created by: Julien Dutheil
4 // Created on: Mon Mar 03 2008
5 //
6 
7 /*
8 Copyright or © or Copr. Bio++ Development Team, (November 16, 2006)
9 
10 This software is a computer program whose purpose is to provide utilitary
11 classes. This file belongs to the Bio++ Project.
12 
13 This software is governed by the CeCILL license under French law and
14 abiding by the rules of distribution of free software. You can use,
15 modify and/ or redistribute the software under the terms of the CeCILL
16 license as circulated by CEA, CNRS and INRIA at the following URL
17 "http://www.cecill.info".
18 
19 As a counterpart to the access to the source code and rights to copy,
20 modify and redistribute granted by the license, users are provided only
21 with a limited warranty and the software's author, the holder of the
22 economic rights, and the successive licensors have only limited
23 liability.
24 
25 In this respect, the user's attention is drawn to the risks associated
26 with loading, using, modifying and/or developing or reproducing the
27 software by the user in light of its specific status of free software,
28 that may mean that it is complicated to manipulate, and that also
29 therefore means that it is reserved for developers and experienced
30 professionals having in-depth computer knowledge. Users are therefore
31 encouraged to load and test the software's suitability as regards their
32 requirements in conditions enabling the security of their systems and/or
33 data to be ensured and, more generally, to use and operate it in the
34 same conditions as regards security.
35 
36 The fact that you are presently reading this means that you have had
37 knowledge of the CeCILL license and that you accept its terms.
38 */
39 
40 #ifndef _GRAPHICDEVICE_H_
41 #define _GRAPHICDEVICE_H_
42 
43 #include "RgbColor.h"
44 #include "Font/Font.h"
45 
46 namespace bpp
47 {
48 
49  class UnvalidFlagException: public virtual Exception
50  {
51  public:
52  UnvalidFlagException(const std::string& message): Exception(message) {}
53  };
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) throw (UnvalidFlagException) = 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 
195 } // end of namespace bpp.
196 
197 #endif //_GRAPHICDEVICE_H_
198 
199 
UnvalidFlagException(const std::string &message)
Definition: GraphicDevice.h:52
virtual void setCurrentBackgroundColor(const RGBColor &color)=0
virtual void setCurrentForegroundColor(const RGBColor &color)=0
virtual const RGBColor & getCurrentForegroundColor() const =0
virtual void drawCircle(double x, double y, double radius, short fill=FILL_EMPTY)=0
Draw a circle.
Data structure for fonts.
Definition: Font.h:56
static short TEXT_VERTICAL_TOP
virtual void end()=0
End the painting.
virtual void begin()=0
Start the painting.
This class allows to perform a correspondence analysis.
virtual double getXUnit() const =0
static short LINE_SOLID
virtual void setCurrentFont(const Font &font)=0
STL namespace.
Describe a color according to its red, green and blue componants.
Definition: RgbColor.h:56
static short LINE_DOTTED
virtual void drawLine(double x1, double y1, double x2, double y2)=0
Draw a line between two points.
virtual const Font & getCurrentFont() const =0
static short TEXT_HORIZONTAL_RIGHT
static short FILL_PATTERN
virtual int getCurrentLayer() const =0
Interface for all plotting devices.
Definition: GraphicDevice.h:62
virtual const RGBColor & getCurrentBackgroundColor() const =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 setXUnit(double xu)=0
static short FILL_EMPTY
static short TEXT_HORIZONTAL_CENTER
virtual void setCurrentLayer(int layerIndex)=0
static short FILL_FILLED
virtual ~GraphicDevice()
Definition: GraphicDevice.h:66
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.
Exception base class.
Definition: Exceptions.h:57
virtual void setCurrentPointSize(unsigned int size)=0
static short TEXT_VERTICAL_BOTTOM
virtual unsigned int getCurrentPointSize() const =0
virtual short getCurrentLineType() const =0
virtual void comment(const std::string &comment)=0
Add a comment in the output.
virtual double getYUnit() const =0
static short TEXT_VERTICAL_CENTER
virtual void setYUnit(double yu)=0
virtual void setCurrentLineType(short type)=0
static short TEXT_HORIZONTAL_LEFT