Updraft  1.0
Open source glider flight visualisation tool.
plotpainters.h
Go to the documentation of this file.
00001 #ifndef UPDRAFT_SRC_PLUGINS_IGCVIEWER_PLOTPAINTERS_H_
00002 #define UPDRAFT_SRC_PLUGINS_IGCVIEWER_PLOTPAINTERS_H_
00003 
00004 #include <QPolygonF>
00005 #include <QPointF>
00006 
00007 #include "igcinfo.h"
00008 #include "plotaxes.h"
00009 
00010 namespace Updraft {
00011 namespace IgcViewer {
00012 
00014 struct Data {
00015   int pixel;
00016   qreal value;
00017 };
00018 
00021 class PlotPainter : public QObject {
00022   Q_OBJECT
00023 
00024  public:
00025   virtual ~PlotPainter() {}
00026   void init(PlotAxes *axes, FixInfo *info);
00027 
00028   virtual void draw(QPainter* painter);
00029 
00031   virtual void getRangeAtPixel(int x,
00032     int* startIndex, int* endIndex);
00033 
00034   int getMinX();
00035   int getMaxX();
00036 
00037  public slots:
00038   void updateBuffer();
00039 
00040  protected:
00044   virtual void flushBuffer() = 0;
00045   virtual void computePoints();
00046   virtual void computeDrawingData();
00047 
00048   QPainter *painter;
00049   PlotAxes *axes;
00050   FixInfo *info;
00051 
00052   QPolygonF buffer;
00053   QVector<Data> dataValues;
00054   QVector<int> indexes;
00055 };
00056 
00058 class AltitudePlotPainter: public PlotPainter {
00059  protected:
00060   void flushBuffer();
00061 };
00062 
00066 class VerticalSpeedPlotPainter: public PlotPainter {
00067  protected:
00068   void flushBuffer();
00069   void computeDrawingData();
00070  private:
00071   QVector<QPolygon> positivePolygons;
00072   QVector<QPolygon> negativePolygons;
00073 
00074   static const QBrush POSITIVE_BRUSH;
00075   static const QBrush NEGATIVE_BRUSH;
00076   static const QPen POSITIVE_PEN;
00077   static const QPen NEGATIVE_PEN;
00078 };
00079 
00081 class GroundSpeedPlotPainter: public PlotPainter {
00082  protected:
00083   void flushBuffer();
00084 };
00085 
00086 }  // End namespace IgcViewer
00087 }  // End namespace Updraft
00088 
00089 #endif  // UPDRAFT_SRC_PLUGINS_IGCVIEWER_PLOTPAINTERS_H_
00090 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines