CalcMySky  v0.3.1
RadiancePlot.hpp
1 #ifndef INCLUDE_ONCE_BA229016_D8DA_4EB4_89B7_7F5CCD722A60
2 #define INCLUDE_ONCE_BA229016_D8DA_4EB4_89B7_7F5CCD722A60
3 
4 #include <cmath>
5 #include <memory>
6 #include <QWidget>
7 
8 class QLabel;
9 class QTextDocument;
10 class RadiancePlot : public QWidget
11 {
12  QLabel* statusBar=nullptr;
13  QTransform coordTransform;
14  std::vector<float> wavelengths, radiances;
15  float luminance;
16  float azimuth=NAN, elevation=NAN;
17  int focusedPoint=-1;
18 public:
19  RadiancePlot(QLabel* statusBar, QWidget* parent=nullptr);
20  void setData(const float* wavelengths, const float* radiances, unsigned size,
21  float azimuth, float elevation);
22 
23 protected:
24  void paintEvent(QPaintEvent *event) override;
25  void keyPressEvent(QKeyEvent* event) override;
26  void mouseMoveEvent(QMouseEvent* event) override;
27  void leaveEvent(QEvent* event) override;
28 
29 private:
30  QMarginsF calcPlotMargins(QPainter const& p, std::vector<std::pair<float,QString>> const& ticksY) const;
31  void drawAxes(QPainter& p, std::vector<std::pair<float,QString>> const& ticksX,
32  std::vector<std::pair<float,QString>> const& ticksY,
33  float xMin, float xMax, float yMin, float yMax) const;
34  std::vector<std::pair<float,QString>> genTicks(std::vector<float> const& values, const float min=NAN) const;
35  std::unique_ptr<QTextDocument> makeQTextDoc() const;
36  void saveSpectrum();
37  float calcLuminance() const;
38 };
39 
40 #endif
Definition: RadiancePlot.hpp:10