Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   Examples  

qsplot.h

00001 /***************************************************************************
00002                                    qsplot.h
00003                              -------------------
00004     version              : 0.1
00005     begin                : 01-January-2000
00006     copyright            : (C) 2000 by Kamil Dobkowski
00007     email                : kamildobk@poczta.onet.pl
00008  ***************************************************************************/
00009 
00010 /***************************************************************************
00011  *                                                                         *
00012  *   This program is free software; you can redistribute it and/or modify  *
00013  *   it under the terms of the GNU General Public License as published by  *
00014  *   the Free Software Foundation; either version 2 of the License, or     *
00015  *   (at your option) any later version.                                   *
00016  *                                                                         *
00017  ***************************************************************************/
00018 
00019 
00020 #ifndef QSPLOT_H
00021 #define QSPLOT_H
00022 
00023 #ifdef HAVE_CONFIG_H
00024 #include <config.h>
00025 #endif
00026 
00027 #include"qsaxes.h"
00028 #include"qsaxis.h"
00029 #include"qsdrv.h"
00030 #include<qstring.h>
00031 #include<math.h>
00032 
00033 
00034 
00046 class QSPlot : public QSAxesChild
00047    {
00048     Q_OBJECT
00049     friend QSAxes;
00050     Q_PROPERTY( int defaultXAxis READ defaultXAxis WRITE setDefaultXAxis )
00051     Q_PROPERTY( int defaultYAxis READ defaultYAxis WRITE setDefaultYAxis )
00052     Q_PROPERTY( int defaultZAxis READ defaultZAxis WRITE setDefaultZAxis )
00053     Q_PROPERTY( int defaultVAxis READ defaultVAxis WRITE setDefaultVAxis )
00054     Q_PROPERTY( bool legendItemVisible READ legendItemVisible WRITE setLegendItemVisible )
00055     Q_PROPERTY( QString gradient READ gradientProperty WRITE setGradientProperty )
00056     public:
00061      QSPlot( QSAxes *parentAxes=0, const char *name=0 );
00065      virtual ~QSPlot();
00069      void setDefaultAxis( QSAxis *axis );
00073     void setDefaultXAxis( int axisIndex );
00077     void setDefaultYAxis( int axisIndex );
00081     void setDefaultZAxis( int axisIndex );
00085     void setDefaultVAxis( int axisIndex );
00089     int defaultXAxis() const { return m_axes->axisIndex(m_daxes[QSAxis::XAxisType]); }
00093     int defaultYAxis() const { return m_axes->axisIndex(m_daxes[QSAxis::YAxisType]); }
00097     int defaultZAxis() const { return m_axes->axisIndex(m_daxes[QSAxis::ZAxisType]); }
00101     int defaultVAxis() const { return m_axes->axisIndex(m_daxes[QSAxis::VAxisType]); }
00106      QSAxis *defaultAxis( int axisType ) const { return m_daxes[axisType]; }
00110      void setGradient( const QSGGradient& gradient );
00114      const QSGGradient gradient() const { return m_gradient; }
00118      void setLegendItemVisible( bool visible );
00122      bool legendItemVisible() const { return m_is_legend; }
00126      virtual QString posInfo( QSPt2f& pos );
00130      virtual QSPt2f legendItemSize( QSDrv *drv );
00134      virtual void drawLegendItem( const QSPt2f& pos, QSDrv *drv );
00138      QSPt2f dataToWorld( const QSPt2f& p ) const;
00142      QSPt3f dataToWorld( const QSPt3f& p ) const;
00146      QSPt3f dataToWorldV( const QSPt3f& p ) const;
00150      QSPt2f worldToData( const QSPt2f& p ) const;
00154      QSPt3f worldToData( const QSPt3f& p ) const;
00158      QSPt3f worldToDataV( const QSPt3f& p ) const;
00162     void setGradientProperty( const QString& string );
00166     QString gradientProperty() const { return toQString(m_gradient); }
00167 
00168     virtual void loadStateFromStream( QDataStream& stream, QSObjectFactory *factory );
00169     virtual void saveStateToStream( QDataStream& stream, QSObjectFactory *factory );
00170 
00171     protected slots:
00177       virtual void axisRemoved( QSData *object );   
00178 
00179     protected:
00185       virtual bool getAxisRange( QSAxis *axis, double& min, double& max );
00194       virtual bool start();
00202       virtual bool step();
00207       virtual void end();
00213       virtual void allocRuntimeData();
00217       virtual void freeRuntimeData();
00218 
00219       static const int work_steps = 30;
00220 
00221        bool    m_busy;
00222        bool    m_is_legend;
00223        int     m_bkg_handler;
00224        double  m_curr_dpi;
00225        QSDrv  *m_drv;
00226        QSPt2f  m_csize;
00227        QSPt2f  m_cpos;
00228        QSAxis *m_daxes[5];  
00229        QSAxes *m_axes;
00230        QSGGradient m_gradient;
00231        const QSProjection *m_proj;
00232    };
00233 
00234 //--------------------------------------------------------------------------------------//
00235 
00242 class QSPlot2D : public QSPlot
00243  {
00244   Q_OBJECT
00245     public:
00249      QSPlot2D( QSAxes *parentAxes, const char *name=0 );
00253      virtual ~QSPlot2D();
00254   };
00255 
00256 //--------------------------------------------------------------------------------------//
00257 
00258 
00259 
00268 class QSPlot3D : public QSPlot
00269  {
00270   Q_OBJECT
00271     Q_PROPERTY( bool colored READ colored WRITE setColored )
00272     Q_PROPERTY( bool topBottom READ topBottom WRITE setTopBottom )
00273     Q_PROPERTY( bool autoDivide READ autoDivide WRITE setAutoDivide )
00274         Q_PROPERTY( int edgeAutoColor READ edgeAutoColor WRITE setEdgeAutoColor )
00275 
00276     public:
00280      QSPlot3D( QSAxes *parentAxes, const char *name=0 );
00284      virtual ~QSPlot3D();
00288      void setColored( bool enabled );
00292      void setTopBottom( bool enabled );
00296      void setAutoDivide( bool enabled );
00300      void setEdgeAutoColor( int value );    
00304      void setClipping( bool clipping );
00308      bool topBottom() const { return m_topbottom; }
00312      bool autoDivide() const { return m_divide; }
00316      int edgeAutoColor() const { return m_edge_auto_color; }
00320      bool clipping() { return m_clipping; }
00324      bool colored() const { return m_colored; }
00325 
00326     virtual void loadStateFromStream( QDataStream& stream, QSObjectFactory *factory );
00327     virtual void saveStateToStream( QDataStream& stream, QSObjectFactory *factory );
00331      enum FillElement {
00332                         TMeshFill,
00333                         BMeshFill
00334                        };
00338      enum LineElement {
00339                         MeshLine
00340                       };
00344      enum PointElement {
00345                         PointMark
00346                       };
00347 
00348    protected:
00349 
00350      bool m_clipping;
00351      bool m_colored;
00352      int m_edge_auto_color;
00353      bool m_divide;
00354      bool m_topbottom;
00355      QSDrv::CNormals  m_cnormals;
00356      QSDrv::CColors   m_ccolors;
00357      QSDrv::COrdering m_corder;
00362      void drawPolygon( const QSPt3f pts[], int npoints, QSPt3f *norm, const double *values=NULL, const bool *edges=NULL );
00366      virtual void allocRuntimeData();
00370      virtual void freeRuntimeData();
00374      virtual QSPt2f standardLegendItemSize( QSDrv *drv, QSAxis *axis, const QString& title );
00378      virtual void drawStandardLegendItem( const QSPt2f& pos, QSDrv *drv, QSAxis *axis, const QString& title, const QSGGradient *gradient );
00379 
00380   private:
00381     struct plot3d_runtime_data;
00382      struct plot3d_runtime_data *d;
00383  };
00384 
00385 #endif
00386 
00387 
00388 

Generated on Mon Mar 18 19:16:33 2002 for KMatplot library by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002