Updraft
1.0
Open source glider flight visualisation tool.
|
00001 #ifndef UPDRAFT_SRC_PLUGINS_IGCVIEWER_GRAPHLABELS_H_ 00002 #define UPDRAFT_SRC_PLUGINS_IGCVIEWER_GRAPHLABELS_H_ 00003 00004 #include <QLayoutItem> 00005 #include <QPainter> 00006 00007 namespace Updraft { 00008 namespace IgcViewer { 00009 00010 class PlotAxes; 00011 00013 class Label : public QLayoutItem { 00014 public: 00017 virtual Qt::Orientations expandingDirections() const; 00018 virtual bool isEmpty() const; 00019 virtual QRect geometry() const; 00020 virtual QSize maximumSize() const; 00021 virtual QSize minimumSize() const; 00022 virtual QSize sizeHint() const; 00023 virtual void setGeometry(const QRect& rect); 00025 virtual void draw(QPainter* painter) = 0; 00026 protected: 00027 QRect rect; 00028 }; 00029 00031 class AxisLabel : public Label { 00032 public: 00035 Qt::Orientations expandingDirections() const; 00036 QSize maximumSize() const; 00037 QSize minimumSize() const; 00038 QSize sizeHint() const; 00040 00042 void draw(QPainter *painter); 00043 00044 explicit AxisLabel(PlotAxes* axis, QString unitsDescription); 00045 00046 private: 00047 PlotAxes* axis; 00048 QString unitsDescription; 00049 00050 static const int MIN_WIDTH = 20; 00051 static const int MIN_HEIGHT = 20; 00052 static const int OFFSET_X = 3; 00053 static const int TEXT_HEIGHT = 10; 00054 00055 static const QPen LABEL_PEN; 00056 }; 00057 00059 class TextLabel : public Label { 00060 public: 00063 Qt::Orientations expandingDirections() const; 00064 QSize maximumSize() const; 00065 QSize minimumSize() const; 00066 QSize sizeHint() const; 00068 00070 void draw(QPainter *painter); 00071 00072 explicit TextLabel(QString text_); 00073 00074 private: 00075 QString text; 00076 00077 static const int MIN_WIDTH = 100; 00078 static const int MIN_HEIGHT = 15; 00079 00080 static const QPen LABEL_PEN; 00081 }; 00082 00084 class TimeLabel : public Label { 00085 public: 00088 Qt::Orientations expandingDirections() const; 00089 QSize maximumSize() const; 00090 QSize minimumSize() const; 00091 QSize sizeHint() const; 00093 00095 void draw(QPainter *painter); 00096 00097 explicit TimeLabel(PlotAxes* axis); 00098 00099 private: 00100 PlotAxes* axis; 00101 00102 static const int MIN_WIDTH = 100; 00103 static const int MIN_HEIGHT = 15; 00104 static const int TEXT_WIDTH_HEIGHT_RATIO = 4; 00105 static const int TEXT_MIN_WIDTH = 20; 00106 00107 static const QPen LABEL_PEN; 00108 }; 00109 } 00110 } 00111 00112 #endif // UPDRAFT_SRC_PLUGINS_IGCVIEWER_GRAPHLABELS_H_