chart.h

00001 
00002 /***************************************************************************
00003  *   This file is part of Aspect, a simple PEC tool.                       *
00004  *                                                                         *
00005  *   Copyright (C) 2006-2007 by Wolfgang Hoffmann <woho@woho.de>           *
00006  *                                                                         *
00007  *   This program is free software, licensed under the GPL v2.             *
00008  *   See the file COPYING for more details.                                *
00009  ***************************************************************************/
00010 
00011 
00012 #ifndef ASPECT_CHART_H
00013 #define ASPECT_CHART_H
00014 
00015 
00016 #include <QGraphicsView>
00017 #include <QPainterPath>
00018 
00019 class QGraphicsScene;
00020 class QGraphicsItem;
00021 
00022 
00023 class Graph
00024     {
00025 public:
00026     enum Style { dot, tick, line, stairLeft, stairRight };
00027     Graph(Style eStyle, double dfXBeg = 0., double dfXEnd = 256.,
00028         double dfYBeg = -1000., double dfYEnd = 1000.);
00029     void addData(double dfX, double dfY, bool bNewSubPath = false);
00030     void render(QGraphicsScene *pScene,
00031         double dfXScale, double dfYZero, double dfYScale,
00032         double dfZValue = 0., const QPen &oPen = QPen());
00033     double minX() const { return m_dfXMin; };
00034     double maxX() const { return m_dfXMax; };
00035     double minY() const { return m_dfYMin; };
00036     double maxY() const { return m_dfYMax; };
00037 private:
00038     Style m_eStyle;
00039     double m_dfXBeg;
00040     double m_dfXEnd;
00041     double m_dfYBeg;
00042     double m_dfYEnd;
00043     double m_dfXMin;
00044     double m_dfXMax;
00045     double m_dfYMin;
00046     double m_dfYMax;
00047     bool m_bFirst;
00048     QPainterPath m_oPath;
00049     };
00050 
00051 
00052 class Grid
00053     {
00054 public:
00055     enum Lines { none = 0, minor = 1, major = 2, both = minor | major };
00056     enum Numbers { undec = 0, min = 1, max = 2, minmax = min | max };
00057     Grid();
00058     void addData(double dfX, double dfY);
00059     void addGraph(const Graph &oGraph);
00060     void render(QGraphicsScene *pScene,
00061         double dfXScale, double dfYZero, double dfYScale,
00062         Lines eLineX, Lines eLineY, Numbers eNumX, Numbers eNumY,
00063         double dfMajorX, double dfMinorX, double dfMajorY, double dfMinorY,
00064         double dfMajorZ = -1., double dfMinorZ = -2., const QColor &oNumberColor = Qt::black,
00065         const QPen &oMajorPen = QPen(Qt::gray), const QPen &oMinorPen = QPen(Qt::lightGray));
00066     double minX() const { return m_dfXMin; };
00067     double maxX() const { return m_dfXMax; };
00068     double minY() const { return m_dfYMin; };
00069     double maxY() const { return m_dfYMax; };
00070     double minYSanitized() const;
00071     double maxYSanitized() const;
00072 private:
00073     double m_dfXMin;
00074     double m_dfXMax;
00075     double m_dfYMin;
00076     double m_dfYMax;
00077     };
00078 
00079 
00080 class Chart: public QGraphicsView
00081     {
00082     Q_OBJECT
00083 
00084 public:
00085     Chart(QWidget *pParent = 0);
00086 
00087     void clear();
00088     void requestSceneRender();
00089 
00090 protected:
00091     void resizeEvent(QResizeEvent *pEvent);
00092 
00093 private slots:
00094     void performSceneRender();
00095 
00096 private:
00097     QTimer *m_pRenderTimer;
00098     bool m_bNeedSceneRender;
00099     };
00100 
00101 
00102 #endif // ASPECT_CHART_H
00103 
00104 

Generated on Sun Jun 3 16:45:46 2007 for Aspect by  doxygen 1.5.1