QtViewImp.h

Go to the documentation of this file.
00001 /* -*- mode: c++ -*- */
00002 
00014 #ifndef _QtViewImp_H_
00015 #define _QtViewImp_H_
00016 
00017 #include "libqthippo.h"
00018 
00019 #include "graphics/DataView.h"
00020 
00021 #ifdef _MSC_VER
00022 #include <msdevstudio/MSconfig.h>
00023 #endif
00024 
00025 #include <qfont.h>
00026 #include <qnamespace.h>
00027 
00028 #include <map>
00029 
00030 class QObject;
00031 class QPainter;
00032 class QPointArray;
00033 class QRect;
00034 
00035 namespace hippodraw {
00036 
00047 class MDL_QTHIPPOPLOT_API QtViewImp : public DataView
00048 {
00049 private:
00050 
00053   static std::map < hippodraw::Line::Style, Qt::PenStyle > s_line_style;
00054 
00057   std::map <const std::string, std::string> m_eq_png;
00058   
00061   QPen createPen ( const Color & color, 
00062                    float size, 
00063                    hippodraw::Line::Style style );
00064   
00065 protected:
00066 
00069   QObject * m_inspector;
00070 
00072   QPainter * m_painter;
00073   
00074   /* The font to be used unless overridden by drawing member function.
00075    */
00076   QFont m_font_default;
00077 
00080   virtual void update ( const Observable * display );
00081   
00082 private:
00083 
00085   virtual int toCanvasX ( double dx ) const = 0;
00086 
00088   virtual int toCanvasY ( double dy ) const = 0;
00089   
00095 #if QT_VERSION < 0x040000
00096   void transformAndFill ( QPointArray & array, 
00097 #else
00098   void transformAndFill ( QPolygon & array, 
00099 #endif
00100                           const std::vector < double > & x,
00101                           const std::vector < double > & y,
00102                           int (QtViewImp::* xfunc ) ( double ) const,
00103                           int (QtViewImp::* yfunc ) ( double ) const );
00104 
00107   void drawMethod ( const std::vector< double > & x,
00108                     const std::vector< double > & y,
00109                     int opt1, 
00110                     int opt2 );
00111                           
00112   virtual void drawPoints ( const std::vector<double> & x,
00113                             const std::vector<double> & y,
00114                             hippodraw::Symbol::Type type, 
00115                             float sym_size, 
00116                             const Color & color );
00117 
00124   void drawViewMethod ( const std::vector< double > & x,
00125                         const std::vector< double > & y,
00126                         int opt1, 
00127                         int opt2 );
00128 
00129 public:
00130 
00137   QtViewImp ( PlotterBase * plotter );
00138 
00139   QtViewImp ();
00140 
00145   void setInspector ( QObject * );
00146 
00148   virtual int toViewX ( double datX ) const = 0;
00149 
00151   virtual int toViewY ( double datY ) const = 0;
00152 
00157   virtual void fillPickedPoint ( double x, double y, 
00158                                  std::vector < double > & picked ) const = 0;
00159 
00162   inline int toView ( double x ) const;
00163 
00164   virtual void drawLines ( const std::vector< double > & x,
00165                            const std::vector< double > & y,
00166                            hippodraw::Line::Style style,
00167                            const Color & color,
00168                            float size );
00169 
00170   virtual void drawColorLines ( const std::vector< double > & x,
00171                                 const std::vector< double > & y,
00172                                 hippodraw::Line::Style style,
00173                                 const std::vector < Color > & colors,
00174                                 float size );
00175 
00176   virtual void drawViewLines ( const std::vector< double > & x,
00177                                const std::vector< double > & y,
00178                                hippodraw::Line::Style style,
00179                                bool color,
00180                                float size );
00181 
00182   virtual void drawViewLines ( const std::vector< double > & x,
00183                                const std::vector< double > & y,
00184                                hippodraw::Line::Style style,
00185                                const Color & color,
00186                                float size );
00187 
00188   virtual void drawPolyLine ( const std::vector< double > & xpoints,
00189                               const std::vector< double > & ypoints, 
00190                               hippodraw::Line::Style style,
00191                               const Color & color,
00192                               float size );
00193 
00194   virtual void drawPolygon ( const std::vector < double > & x,
00195                              const std::vector < double > & y,
00196                              const Color & color,
00197                              const Color & edge );
00198 
00200   void setCrossX ( double val );
00201 
00203   void setCrossY ( double val );
00204 
00205 protected:
00206 
00207   virtual void draw_Text ( const std::string &s, 
00208                            float x, float y,
00209                            float fontsize, float angle, 
00210                            char xp, char yp,
00211                            bool resize,
00212                            QFont & font,
00213                            const QColor & color );
00214 
00215 public:
00216 
00217   virtual void drawImage ( const std::string &filename, int position = 0 );
00218 
00219   virtual void drawLatex ( const std::string &eq, int position = 0 );
00220                           
00221   virtual void drawText ( const std::string &s, float x, float y,
00222                           float fontsize, float angle, char xp, char yp,
00223                           bool resize );
00224 
00225   virtual void drawText ( const std::string &s, float x, float y,
00226                           float fontsize, float angle, char xp, char yp,
00227                           bool resize,
00228                           const FontBase * font,
00229                           const Color * color );
00230 
00231   virtual void drawPoints ( const std::vector<double> & x,
00232                             const std::vector<double> & y,
00233                             hippodraw::Symbol::Type type, 
00234                             float sym_size );
00235 
00236   virtual void drawPoints ( const std::vector< double > & x,
00237                             const std::vector< double > & y, 
00238                             const std::vector< Color > & colors,
00239                             hippodraw::Symbol::Type type, 
00240                             float sym_size );
00241 
00242   virtual void drawSquare ( double x1, double y1, double x2, double y2,
00243                             int red, int green, int blue );
00244 
00245   virtual void drawViewSquare ( float x1, float y1, float x2, float y2,
00246                                 int red, int green, int blue );
00247 
00248   float userToDrawX ( double x ) const;
00249   float userToDrawXAutoInv ( double x ) const;
00250   float userToDrawY ( double x ) const;
00251   float userToDrawColor ( double c ) const;
00252   
00253   virtual void setDefaultFont( const QFont& font );
00254   
00255   virtual const QFont & defaultFont();
00256   
00257 };
00258 
00259 inline int QtViewImp::toView ( double x ) const
00260 {
00261   return static_cast< int > ( x );
00262 }
00263 
00264 } // namespace hippodraw
00265 
00266 #endif // _QtViewImp_H_

Generated for HippoDraw Class Library by doxygen