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 protected:
66 
70 
73 
74  /* The font to be used unless overridden by drawing member function.
75  */
77 
80  virtual void update ( const Observable * display );
81 
82 private:
83 
85  virtual int toCanvasX ( double dx ) const = 0;
86 
88  virtual int toCanvasY ( double dy ) const = 0;
89 
95 #if QT_VERSION < 0x040000
96  void transformAndFill ( QPointArray & array,
97 #else
98  void transformAndFill ( QPolygon & array,
99 #endif
100  const std::vector < double > & x,
101  const std::vector < double > & y,
102  int (QtViewImp::* xfunc ) ( double ) const,
103  int (QtViewImp::* yfunc ) ( double ) const );
104 
107  void drawMethod ( const std::vector< double > & x,
108  const std::vector< double > & y,
109  int opt1,
110  int opt2 );
111 
112  virtual void drawPoints ( const std::vector<double> & x,
113  const std::vector<double> & y,
115  float sym_size,
116  const Color & color );
117 
124  void drawViewMethod ( const std::vector< double > & x,
125  const std::vector< double > & y,
126  int opt1,
127  int opt2 );
128 
129 public:
130 
137  QtViewImp ( PlotterBase * plotter );
138 
139  QtViewImp ();
140 
145  void setInspector ( QObject * );
146 
148  virtual int toViewX ( double datX ) const = 0;
149 
151  virtual int toViewY ( double datY ) const = 0;
152 
157  virtual void fillPickedPoint ( double x, double y,
158  std::vector < double > & picked ) const = 0;
159 
162  inline int toView ( double x ) const;
163 
164  virtual void drawLines ( const std::vector< double > & x,
165  const std::vector< double > & y,
167  const Color & color,
168  float size );
169 
170  virtual void drawColorLines ( const std::vector< double > & x,
171  const std::vector< double > & y,
173  const std::vector < Color > & colors,
174  float size );
175 
176  virtual void drawViewLines ( const std::vector< double > & x,
177  const std::vector< double > & y,
179  bool color,
180  float size );
181 
182  virtual void drawViewLines ( const std::vector< double > & x,
183  const std::vector< double > & y,
185  const Color & color,
186  float size );
187 
188  virtual void drawPolyLine ( const std::vector< double > & xpoints,
189  const std::vector< double > & ypoints,
191  const Color & color,
192  float size );
193 
194  virtual void drawPolygon ( const std::vector < double > & x,
195  const std::vector < double > & y,
196  const Color & color,
197  const Color & edge );
198 
200  void setCrossX ( double val );
201 
203  void setCrossY ( double val );
204 
205 protected:
206 
207  virtual void draw_Text ( const std::string &s,
208  float x, float y,
209  float fontsize, float angle,
210  char xp, char yp,
211  bool resize,
212  QFont & font,
213  const QColor & color );
214 
215 public:
216 
217  virtual void drawImage ( const std::string &filename, int position = 0 );
218 
219  virtual void drawLatex ( const std::string &eq, int position = 0 );
220 
221  virtual void drawText ( const std::string &s, float x, float y,
222  float fontsize, float angle, char xp, char yp,
223  bool resize );
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  const FontBase * font,
229  const Color * color );
230 
231  virtual void drawPoints ( const std::vector<double> & x,
232  const std::vector<double> & y,
234  float sym_size );
235 
236  virtual void drawPoints ( const std::vector< double > & x,
237  const std::vector< double > & y,
238  const std::vector< Color > & colors,
240  float sym_size );
241 
242  virtual void drawSquare ( double x1, double y1, double x2, double y2,
243  int red, int green, int blue );
244 
245  virtual void drawViewSquare ( float x1, float y1, float x2, float y2,
246  int red, int green, int blue );
247 
248  float userToDrawX ( double x ) const;
249  float userToDrawXAutoInv ( double x ) const;
250  float userToDrawY ( double x ) const;
251  float userToDrawColor ( double c ) const;
252 
253  virtual void setDefaultFont( const QFont& font );
254 
255  virtual const QFont & defaultFont();
256 
257 };
258 
259 inline int QtViewImp::toView ( double x ) const
260 {
261  return static_cast< int > ( x );
262 }
263 
264 } // namespace hippodraw
265 
266 #endif // _QtViewImp_H_

Generated for HippoDraw Class Library by doxygen