Kstars

fitshistogram.h
1 /*
2  SPDX-FileCopyrightText: 2015 Jasem Mutlaq <[email protected]>
3 
4  SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #pragma once
8 
9 #include "fitscommon.h"
10 #include "fitsdata.h"
11 #include "ui_fitshistogramui.h"
12 
13 #include <QDialog>
14 #include <QUndoCommand>
15 
16 class QMouseEvent;
17 
18 class FITSTab;
19 
20 class histogramUI : public QDialog, public Ui::FITSHistogramUI
21 {
22  Q_OBJECT
23 
24  public:
25  explicit histogramUI(QDialog * parent = nullptr);
26 };
27 
28 class FITSHistogram : public QDialog
29 {
30  Q_OBJECT
31 
32  friend class histDrawArea;
33 
34  public:
35  explicit FITSHistogram(QWidget * parent);
36 
37  enum { RED_CHANNEL, GREEN_CHANNEL, BLUE_CHANNEL };
38 
39  void constructHistogram();
40  void syncGUI();
41  void reset()
42  {
43  m_Constructed = false;
44  }
45 
46  void applyFilter(FITSScale ftype);
47 
48  double getBinWidth(int channel = 0)
49  {
50  return binWidth[channel];
51  }
52 
53  QVector<uint32_t> getCumulativeFrequency(int channel = 0) const;
54 
55  double getJMIndex() const;
56 
57  bool isConstructed()
58  {
59  return m_Constructed;
60  }
61 
62 
63  protected:
64  void showEvent(QShowEvent * event) override;
65  void driftMouseOverLine(QMouseEvent * event);
66 
67  public slots:
68  void applyScale();
69  void resizePlot();
70 
71  private:
72  template <typename T>
73  void constructHistogram();
74  double cutMin;
75  double cutMax;
76 
77  histogramUI * ui { nullptr };
78  FITSTab * tab { nullptr };
79 
80  QVector<QVector<uint32_t>> cumulativeFrequency;
81  QVector<QVector<double>> intensity;
82  QVector<QVector<double>> frequency;
83  QVector<QVector<QWidget *>> rgbWidgets;
85  QVector<QDoubleSpinBox *> minBoxes, maxBoxes;
86 
87  QVector<double> FITSMin;
88  QVector<double> FITSMax;
89  QVector<double> sliderScale, sliderTick;
90  QVector<int> numDecimals;
91 
92  QVector<QCPGraph *> graphs;
93  QVector<double> binWidth;
94  uint16_t binCount { 0 };
95  double JMIndex { 0 };
96 
97  int maxFrequency {0};
98  FITSScale type { FITS_AUTO };
99  bool isGUISynced { false};
100  bool m_Constructed { false };
101  QCustomPlot * customPlot { nullptr };
102 };
103 
104 class FITSHistogramCommand : public QUndoCommand
105 {
106  public:
107  FITSHistogramCommand(QWidget * parent, FITSHistogram * inHisto, FITSScale newType, const QVector<double> &lmin, const QVector<double> &lmax);
108  virtual ~FITSHistogramCommand();
109 
110  virtual void redo() override;
111  virtual void undo() override;
112  virtual QString text() const;
113 
114  private:
115  bool calculateDelta(const uint8_t * buffer);
116  bool reverseDelta();
117 
118  FITSImage::Statistic stats;
119  FITSHistogram * histogram { nullptr };
120  FITSScale type;
121  QVector<double> min, max;
122 
123  unsigned char * delta { nullptr };
124  unsigned long compressedBytes { 0 };
125  FITSTab * tab { nullptr };
126 };
Q_OBJECTQ_OBJECT
virtual void redo()
Type type(const QSqlDatabase &db)
QString text() const const
virtual void undo()
The FITSTab class holds information on the current view (drawing area) in addition to the undo/redo s...
Definition: fitstab.h:37
virtual void showEvent(QShowEvent *event) override
The central class of the library. This is the QWidget which displays the plot and interacts with the ...
Definition: qcustomplot.h:3731
KGuiItem reset()
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sat Sep 30 2023 04:02:42 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.