QtViewImp.h
Go to the documentation of this file.
1 /* -*- mode: c++ -*- */
2 
14 #ifndef _QtViewImp_H_
15 #define _QtViewImp_H_
16 
17 #include "libqthippo.h"
18 
19 #include "graphics/DataView.h"
20 
21 #ifdef _MSC_VER
22 #include <msdevstudio/MSconfig.h>
23 #endif
24 
25 #include <qfont.h>
26 #include <qnamespace.h>
27 
28 #include <map>
29 
30 class QObject;
31 class QPainter;
32 class QPointArray;
33 class QRect;
34 
35 namespace hippodraw {
36 
48 {
49 private:
50 
53  static std::map < hippodraw::Line::Style, Qt::PenStyle > s_line_style;
54 
57  std::map <const std::string, std::string> m_eq_png;
58 
61  QPen createPen ( const Color & color,
62  float size,
63  hippodraw::Line::Style style );
64 
65  std::string m_tmpDirName;
66 
67  void setTmpDirName();
68 
69 protected:
70 
74 
77 
78  /* The font to be used unless overridden by drawing member function.
79  */
81 
84  virtual void update ( const Observable * display );
85 
86 private:
87 
89  virtual int toCanvasX ( double dx ) const = 0;
90 
92  virtual int toCanvasY ( double dy ) const = 0;
93 
99 #if QT_VERSION < 0x040000
100  void transformAndFill ( QPointArray & array,
101 #else
102  void transformAndFill ( QPolygon & array,
103 #endif
104  const std::vector < double > & x,
105  const std::vector < double > & y,
106  int (QtViewImp::* xfunc ) ( double ) const,
107  int (QtViewImp::* yfunc ) ( double ) const );
108 
111  void drawMethod ( const std::vector< double > & x,
112  const std::vector< double > & y,
113  int opt1,
114  int opt2 );
115 
116  virtual void drawPoints ( const std::vector<double> & x,
117  const std::vector<double> & y,
119  float sym_size,
120  const Color & color );
121 
128  void drawViewMethod ( const std::vector< double > & x,
129  const std::vector< double > & y,
130  int opt1,
131  int opt2 );
132 
133 public:
134 
141  QtViewImp ( PlotterBase * plotter );
142 
143  QtViewImp ();
144 
149  void setInspector ( QObject * );
150 
152  virtual int toViewX ( double datX ) const = 0;
153 
155  virtual int toViewY ( double datY ) const = 0;
156 
161  virtual void fillPickedPoint ( double x, double y,
162  std::vector < double > & picked ) const = 0;
163 
166  inline int toView ( double x ) const;
167 
168  virtual void drawLines ( const std::vector< double > & x,
169  const std::vector< double > & y,
171  const Color & color,
172  float size );
173 
174  virtual void drawColorLines ( const std::vector< double > & x,
175  const std::vector< double > & y,
177  const std::vector < Color > & colors,
178  float size );
179 
180  virtual void drawViewLines ( const std::vector< double > & x,
181  const std::vector< double > & y,
183  bool color,
184  float size );
185 
186  virtual void drawViewLines ( const std::vector< double > & x,
187  const std::vector< double > & y,
189  const Color & color,
190  float size );
191 
192  virtual void drawPolyLine ( const std::vector< double > & xpoints,
193  const std::vector< double > & ypoints,
195  const Color & color,
196  float size );
197 
198  virtual void drawPolygon ( const std::vector < double > & x,
199  const std::vector < double > & y,
200  const Color & color,
201  const Color & edge );
202 
204  void setCrossX ( double val );
205 
207  void setCrossY ( double val );
208 
209 protected:
210 
211  virtual void draw_Text ( const std::string &s,
212  float x, float y,
213  float fontsize, float angle,
214  char xp, char yp,
215  bool resize,
216  QFont & font,
217  const QColor & color );
218 
219 public:
220 
221  virtual void drawImage ( const std::string &filename, int position = 0 );
222 
223  virtual void drawLatex ( const std::string &eq, int position = 0 );
224 
225  virtual void drawText ( const std::string &s, float x, float y,
226  float fontsize, float angle, char xp, char yp,
227  bool resize );
228 
229  virtual void drawText ( const std::string &s, float x, float y,
230  float fontsize, float angle, char xp, char yp,
231  bool resize,
232  const FontBase * font,
233  const Color * color );
234 
235  virtual void drawPoints ( const std::vector<double> & x,
236  const std::vector<double> & y,
238  float sym_size );
239 
240  virtual void drawPoints ( const std::vector< double > & x,
241  const std::vector< double > & y,
242  const std::vector< Color > & colors,
244  float sym_size );
245 
246  virtual void drawSquare ( double x1, double y1, double x2, double y2,
247  int red, int green, int blue );
248 
249  virtual void drawViewSquare ( float x1, float y1, float x2, float y2,
250  int red, int green, int blue );
251 
252  float userToDrawX ( double x ) const;
253  float userToDrawXAutoInv ( double x ) const;
254  float userToDrawY ( double x ) const;
255  float userToDrawColor ( double c ) const;
256 
257  virtual void setDefaultFont( const QFont& font );
258 
259  virtual const QFont & defaultFont();
260 
261 };
262 
263 inline int QtViewImp::toView ( double x ) const
264 {
265  return static_cast< int > ( x );
266 }
267 
268 } // namespace hippodraw
269 
270 #endif // _QtViewImp_H_
Part of an implementation of the Observable-Observer pattern based on the example in the GOF Patterns...
Definition: Observable.h:39
#define MDL_QTHIPPOPLOT_API
Definition: libqthippo.h:36
static std::map< hippodraw::Line::Style, Qt::PenStyle > s_line_style
The mapping from LineStyle::Type to QPen PenStyle.
Definition: QtViewImp.h:53
QPainter * m_painter
The current Qt QPainter object.
Definition: QtViewImp.h:76
Type
Enumeration of the type of symbols supported by this class.
Definition: SymbolType.h:28
QObject * m_inspector
The receiver of update messages.
Definition: QtViewImp.h:73
int toView(double x) const
Converts the view space coordinate x expressed as a double to one expressed as an int...
Definition: QtViewImp.h:263
A abstract base class for font handling.
Definition: FontBase.h:32
The abstract base class for views that have a region for drawing data points with area around it for ...
Definition: DataView.h:30
A Color class for creating the color object following the standard RGB color space.
Definition: Color.h:37
The class of derived from ViewBase for drawing to the screen and PostScript generation using Qt toolk...
Definition: QtViewImp.h:47
The base class for the PlotterBase hierarchy.
Definition: PlotterBase.h:55
PyArray_TYPES type(numeric::array arr)
Definition: num_util.cpp:249
hippodraw::DataView class interface
intp size(numeric::array arr)
Definition: num_util.cpp:296
Style
Line style constants.
Definition: LineStyle.h:25
std::string m_tmpDirName
Definition: QtViewImp.h:65
std::map< const std::string, std::string > m_eq_png
The mapping from LaTex equation to PNG filename.
Definition: QtViewImp.h:57

Generated for HippoDraw Class Library by doxygen