JS8Call-Improved master
Loading...
Searching...
No Matches
WF.h
1#ifndef W_F_HPP__
2#define W_F_HPP__
3
4#include "JS8_Include/commons.h"
5
6#include <QColor>
7#include <QFlags>
8#include <QList>
9#include <QMetaType>
10#include <QVector>
11
12class QString;
13
14namespace WF {
15Q_NAMESPACE
16
17// Spectrum type, defines the types of waterfall spectrum displays.
18
19enum class Spectrum { Current, Cumulative, LinearAvg };
20Q_ENUM_NS(Spectrum)
21
22// Maximum width of the screen in pixels.
23
24static constexpr std::size_t MaxScreenWidth = 2048;
25
26// Waterfall data storage types.
27
28using SPlot = std::array<float, JS8_NSMAX>;
29using SWide = std::array<float, MaxScreenWidth>;
30
31// The wide graph class drains into the plotter class, driven by a
32// timer based on the desired frames per second that the waterfall
33// should display. Since the wide graph itself acts as a sink for
34// the detector, and we may or may not have averaging in play, we
35// end up with sink states that the waterfall might be in:
36//
37// 1. Drained - No new data has arrived in the wide graph sink
38// since it was last drained to the plotter. Any
39// frame of data sent to the plotter in this state
40// is a duplicate of the last frame.
41//
42// 2. Summary - New data arrived in the wide graph sink; adjunct
43// summary data referenced by the plotter will have
44// changed. If Current isn't set, then the frame is
45// a duplicate of the last frame.
46//
47// 3. Current - Averaging has completed; data is current and not
48// a duplicate of the last frame.
49
50enum class Sink { Drained = 0x0, Summary = 0x1, Current = 0x2 };
51
52Q_DECLARE_FLAGS(State, Sink)
53
54//
55// Class Palette
56//
57// Encapsulates a waterfall palette description. A colour gradient
58// over 256 intervals is described by a list of RGB colour triplets.
59// The list of colours are use to interpolate the full 256 interval
60// waterfall colour gradient.
61//
62// Responsibilities
63//
64// Construction from a string which is a path to a file containing
65// colour descriptions in the form rrr;ggg;bbb on up to 256
66// consecutive lines, where rrr, ggg and, bbb are integral numbers in
67// the range 0<=n<256.
68//
69// Construction from a list of QColor instances. Up to the first 256
70// list elements are used.
71//
72// Includes a design GUI to create or adjust a Palette.
73//
74class Palette {
75 public:
76 using Colours = QList<QColor>;
77
78 Palette() = default;
79 explicit Palette(Colours const &);
80 explicit Palette(QString const &file_path);
81 Palette(Palette const &) = default;
82 Palette &operator=(Palette const &) = default;
83
84 Colours colours() const { return colours_; }
85
86 // interpolate a gradient over 256 steps
87 QVector<QColor> interpolate() const;
88
89 // returns true if colours have been modified
90 bool design();
91
92 private:
93 Colours colours_;
94};
95} // namespace WF
96
97Q_DECLARE_METATYPE(WF::Spectrum)
98Q_DECLARE_METATYPE(WF::Palette::Colours)
99Q_DECLARE_OPERATORS_FOR_FLAGS(WF::State)
100
101#endif
Definition qpriorityqueue.h:39