Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

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/ViewBase.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 
00044 class MDL_QTHIPPOPLOT_API QtViewImp : public ViewBase
00045 {
00046 private:
00047 
00050   static std::map < hippodraw::Line::Style, Qt::PenStyle > s_line_style;
00051 
00054   QPen createPen ( const Color & color, 
00055                    float size, 
00056                    hippodraw::Line::Style style );
00057 
00058 protected:
00059 
00062   QObject * m_inspector;
00063 
00065   QPainter * m_painter;
00066   
00067   /* The font to be used unless overridden by drawing member function.
00068    */
00069   QFont m_font_default;
00070 
00073   virtual void update ( const Observable * display );
00074   
00075 private:
00076 
00078   virtual int toCanvasX ( double dx ) const = 0;
00079 
00081   virtual int toCanvasY ( double dy ) const = 0;
00082 
00088   void transformAndFill ( QPointArray & array, 
00089                           const std::vector < double > & x,
00090                           const std::vector < double > & y,
00091                           int (QtViewImp::* xfunc ) ( double ) const,
00092                           int (QtViewImp::* yfunc ) ( double ) const );
00093 
00096   void drawMethod ( const std::vector< double > & x,
00097                     const std::vector< double > & y,
00098                     int opt1, 
00099                     int opt2 );
00100 
00101   virtual void drawPoints ( const std::vector<double> & x,
00102                             const std::vector<double> & y,
00103                             hippodraw::Symbol::Type type, 
00104                             float sym_size, 
00105                             const Color & color );
00106 
00113   void drawViewMethod ( const std::vector< double > & x,
00114                         const std::vector< double > & y,
00115                         int opt1, 
00116                         int opt2 );
00117 
00118 public:
00119 
00126   QtViewImp ( PlotterBase * plotter );
00127 
00129   QtViewImp ( const QtViewImp & );
00130 
00135   void setInspector ( QObject * );
00136 
00140   virtual HippoRectangle getMarginRect() const;
00141 
00143   virtual void endPlot ();
00144 
00146   virtual int toViewX ( double datX ) const = 0;
00147 
00149   virtual int toViewY ( double datY ) const = 0;
00150 
00155   virtual void fillPickedPoint ( double x, double y, 
00156                                  std::vector < double > & picked ) const = 0;
00157 
00160   inline int toView ( double x ) const;
00161 
00162   virtual void drawLines ( const std::vector< double > & x,
00163                            const std::vector< double > & y,
00164                            hippodraw::Line::Style style,
00165                            const Color & color,
00166                            float size );
00167 
00168   virtual void drawColorLines ( const std::vector< double > & x,
00169                                 const std::vector< double > & y,
00170                                 hippodraw::Line::Style style,
00171                                 const std::vector < Color > & colors,
00172                                 float size );
00173 
00174   virtual void drawViewLines ( const std::vector< double > & x,
00175                                const std::vector< double > & y,
00176                                hippodraw::Line::Style style,
00177                                bool color,
00178                                float size );
00179 
00180   virtual void drawViewLines ( const std::vector< double > & x,
00181                                const std::vector< double > & y,
00182                                hippodraw::Line::Style style,
00183                                const Color & color,
00184                                float size );
00185 
00186   virtual void drawPolyLine ( const std::vector< double > & xpoints,
00187                               const std::vector< double > & ypoints, 
00188                               hippodraw::Line::Style style,
00189                               const Color & color,
00190                               float size );
00191 
00193   void setCrossX ( double val );
00194 
00196   void setCrossY ( double val );
00197 
00198 protected:
00199 
00200   virtual void draw_Text ( const std::string &s, 
00201                            float x, float y,
00202                            float fontsize, float angle, 
00203                            char xp, char yp,
00204                            bool resize,
00205                            QFont & font );
00206 
00207 public:
00208 
00209   virtual void drawText ( const std::string &s, float x, float y,
00210                           float fontsize, float angle, char xp, char yp,
00211                           bool resize );
00212 
00213   virtual void drawText ( const std::string &s, float x, float y,
00214                           float fontsize, float angle, char xp, char yp,
00215                           bool resize,
00216                           const FontBase * font );
00217 
00218   virtual void drawUserText ( const std::string &s, float x, float y,
00219                               float fontsize, float angle, char xp, char yp );
00220 
00221   virtual void drawMag ( float x, float y, int mag, float fontsize );
00222   virtual void drawMag ( float x, float y, int mag, float fontsize, QFont & );
00223 
00224   virtual void drawPoints ( const std::vector<double> & x,
00225                             const std::vector<double> & y,
00226                             hippodraw::Symbol::Type type, 
00227                             float sym_size );
00228 
00229   virtual void drawPoints ( const std::vector< double > & x,
00230                             const std::vector< double > & y, 
00231                             const std::vector< Color > & colors,
00232                             hippodraw::Symbol::Type type, 
00233                             float sym_size );
00234 
00235   virtual void drawSquare ( double x1, double y1, double x2, double y2,
00236                             int red, int green, int blue );
00237 
00238   virtual void drawViewSquare ( float x1, float y1, float x2, float y2,
00239                                 int red, int green, int blue );
00240 
00241   float userToDrawX ( double x ) const;
00242   float userToDrawY ( double x ) const;
00243   float userToDrawColor ( double c ) const;
00244   
00245   virtual void setDefaultFont( const QFont& font );
00246   
00247   virtual const QFont & defaultFont();
00248   
00249 };
00250 
00251 inline int QtViewImp::toView ( double x ) const
00252 {
00253   return static_cast< int > ( x );
00254 }
00255 
00256 #endif // _QtViewImp_H_

Generated for HippoDraw-1.14.8.5 by doxygen 1.4.3