1 /********************************************************************************************** 2 Copyright (C) 2015 Christian Eichler <code@christian-eichler.de> 3 4 This program is free software: you can redistribute it and/or modify 5 it under the terms of the GNU General Public License as published by 6 the Free Software Foundation, either version 3 of the License, or 7 (at your option) any later version. 8 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU General Public License for more details. 13 14 You should have received a copy of the GNU General Public License 15 along with this program. If not, see <http://www.gnu.org/licenses/>. 16 17 **********************************************************************************************/ 18 19 #ifndef CCOLORLEGEND_H 20 #define CCOLORLEGEND_H 21 22 23 #include <QWidget> 24 25 #include "gis/trk/CGisItemTrk.h" 26 27 class CColorLegend : public QWidget, public INotifyTrk 28 { 29 Q_OBJECT 30 public: 31 CColorLegend(QWidget* parent, CGisItemTrk* trk = nullptr); 32 ~CColorLegend(); 33 34 void setMinimum(qreal min); 35 void setMaximum(qreal max); 36 37 void setUnit(const QString& unit); 38 39 void updateData() override; 40 void setMouseFocus(const CTrackData::trkpt_t* pt) override; setMouseRangeFocus(const CTrackData::trkpt_t *,const CTrackData::trkpt_t *)41 void setMouseRangeFocus(const CTrackData::trkpt_t*/*pt1*/, const CTrackData::trkpt_t*/*pt2*/) override {} setMouseClickFocus(const CTrackData::trkpt_t *)42 void setMouseClickFocus(const CTrackData::trkpt_t*/*pt*/) override {} 43 44 45 protected: 46 void paintEvent(QPaintEvent* event) override; 47 void resizeEvent(QResizeEvent* event) override; 48 49 private: 50 int paintLabel(QPainter& p, qreal value); 51 52 const int colorWidth = 18; 53 const int colorHeight = 256; 54 55 QRect colorRect; 56 QString unit; 57 qreal minimum = 0; 58 qreal maximum = 0; 59 bool background = false; 60 int xOffset = 1; 61 CGisItemTrk* trk = nullptr; 62 qreal val = NOFLOAT; 63 }; 64 65 #endif // CCOLORLEGEND_H 66 67