KDEUI
kplotwidget.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef KPLOTWIDGET_H
00022 #define KPLOTWIDGET_H
00023
00024 #include <kdeui_export.h>
00025
00026 #include <QtGui/QFrame>
00027 #include <QtCore/QList>
00028
00029 class KPlotAxis;
00030 class KPlotObject;
00031 class KPlotPoint;
00032
00080 class KDEUI_EXPORT KPlotWidget : public QFrame {
00081 Q_OBJECT
00082 Q_PROPERTY(int leftPadding READ leftPadding)
00083 Q_PROPERTY(int rightPadding READ rightPadding)
00084 Q_PROPERTY(int topPadding READ topPadding)
00085 Q_PROPERTY(int bottomPadding READ bottomPadding)
00086 Q_PROPERTY(QColor backgroundColor READ backgroundColor WRITE setBackgroundColor)
00087 Q_PROPERTY(QColor foregroundColor READ foregroundColor WRITE setForegroundColor)
00088 Q_PROPERTY(QColor gridColor READ gridColor WRITE setGridColor)
00089 Q_PROPERTY(bool grid READ isGridShown WRITE setShowGrid)
00090 Q_PROPERTY(bool objectToolTip READ isObjectToolTipShown WRITE setObjectToolTipShown)
00091 public:
00096 explicit KPlotWidget( QWidget * parent = 0 );
00097
00101 virtual ~KPlotWidget();
00102
00106 enum Axis
00107 {
00108 LeftAxis = 0,
00109 BottomAxis,
00110 RightAxis,
00111 TopAxis
00112 };
00113
00117 virtual QSize minimumSizeHint() const;
00118
00122 virtual QSize sizeHint() const;
00123
00131 void setLimits( double x1, double x2, double y1, double y2 );
00132
00154 void setSecondaryLimits( double x1, double x2, double y1, double y2 );
00155
00161 void clearSecondaryLimits();
00162
00168 QRectF dataRect() const;
00169
00176 QRectF secondaryDataRect() const;
00177
00182 QRect pixRect() const;
00183
00190 void addPlotObject( KPlotObject *object );
00191
00196 void addPlotObjects( const QList< KPlotObject* >& objects );
00197
00201 QList< KPlotObject* > plotObjects() const;
00202
00206 void removeAllPlotObjects();
00207
00212 void resetPlotMask();
00213
00217 void resetPlot();
00218
00224 void replacePlotObject( int i, KPlotObject *o );
00225
00231 QColor backgroundColor() const;
00232
00239 QColor foregroundColor() const;
00240
00246 QColor gridColor() const;
00247
00252 void setBackgroundColor( const QColor &bg );
00253
00258 void setForegroundColor( const QColor &fg );
00259
00264 void setGridColor( const QColor &gc );
00265
00270 bool isGridShown() const;
00271
00276 bool isObjectToolTipShown() const;
00277
00282 bool antialiasing() const;
00283
00288 void setAntialiasing( bool b );
00289
00297 int leftPadding() const;
00298
00305 int rightPadding() const;
00306
00313 int topPadding() const;
00314
00321 int bottomPadding() const;
00322
00327 void setLeftPadding( int padding );
00328
00333 void setRightPadding( int padding );
00334
00339 void setTopPadding( int padding );
00340
00345 void setBottomPadding( int padding );
00346
00351 void setDefaultPaddings();
00352
00360 QPointF mapToWidget( const QPointF& p ) const;
00361
00373 void maskRect( const QRectF &r, float value=1.0 );
00374
00386 void maskAlongLine( const QPointF &p1, const QPointF &p2, float value=1.0 );
00387
00400 void placeLabel( QPainter *painter, KPlotPoint *pp );
00401
00406 KPlotAxis* axis( Axis type );
00407
00412 const KPlotAxis* axis( Axis type ) const;
00413
00414
00415 public Q_SLOTS:
00421 void setShowGrid( bool show );
00422
00428 void setObjectToolTipShown( bool show );
00429
00430 protected:
00434 virtual bool event( QEvent* );
00435
00439 virtual void paintEvent( QPaintEvent* );
00440
00444 virtual void resizeEvent( QResizeEvent* );
00445
00452 virtual void drawAxes( QPainter *p );
00453
00458 void setPixRect();
00459
00465 QList<KPlotPoint*> pointsUnderPoint( const QPoint& p ) const;
00466
00467 private:
00468 class Private;
00469 Private * const d;
00470
00471 Q_DISABLE_COPY( KPlotWidget )
00472 };
00473
00474 #endif