ngscopeclient v0.1-rc1
StreamBrowserDialog.h
Go to the documentation of this file.
1/***********************************************************************************************************************
2* *
3* ngscopeclient *
4* *
5* Copyright (c) 2012-2025 Andrew D. Zonenberg and contributors *
6* All rights reserved. *
7* *
8* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
9* following conditions are met: *
10* *
11* * Redistributions of source code must retain the above copyright notice, this list of conditions, and the *
12* following disclaimer. *
13* *
14* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the *
15* following disclaimer in the documentation and/or other materials provided with the distribution. *
16* *
17* * Neither the name of the author nor the names of any contributors may be used to endorse or promote products *
18* derived from this software without specific prior written permission. *
19* *
20* THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
21* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
22* THE AUTHORS BE HELD LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
23* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR *
24* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
25* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
26* POSSIBILITY OF SUCH DAMAGE. *
27* *
28***********************************************************************************************************************/
29
35#ifndef StreamBrowserDialog_h
36#define StreamBrowserDialog_h
37
38#include <map>
39
40#include "Dialog.h"
41#include "Session.h"
42
43class MainWindow;
44
46{
47public:
48 StreamBrowserTimebaseInfo(std::shared_ptr<Oscilloscope> scope);
49
50 bool m_interleaving;
51
52 //Sample rate
53 std::vector<uint64_t> m_rates;
54 std::vector<std::string> m_rateNames;
55 int m_rate;
56
57 //Memory depth
58 std::vector<uint64_t> m_depths;
59 std::vector<std::string> m_depthNames;
60 int m_depth;
61
62 //Sampling mode
63 //(only valid if both RT and equivalent are available)
64 int m_samplingMode;
65
66 //Resolution Bandwidth
67 std::string m_rbwText;
68 int64_t m_rbw;
69
70 //Frequency domain controls
71 std::string m_centerText;
72 double m_center;
73
74 std::string m_spanText;
75 double m_span;
76
77 std::string m_startText;
78 double m_start;
79
80 std::string m_endText;
81 double m_end;
82
83 //Spectrometer controls
84 std::string m_integrationText;
85 double m_integrationTime;
86};
87
89{
90public:
91 StreamBrowserDialog(Session& session, MainWindow* parent);
92 virtual ~StreamBrowserDialog();
93
94 virtual bool DoRender() override;
95
96 void FlushConfigCache();
97
98protected:
103 {
104 BADGE_ARMED,
105 BADGE_STOPPED,
106 BADGE_TRIGGERED,
107 BADGE_BUSY,
108 BADGE_AUTO
109 };
110
111 void DoItemHelp();
112
113 // Rendeding of StreamBrowserDialog elements
114 void renderInfoLink(const char *label, const char *linktext, bool &clicked, bool &hovered);
115 void startBadgeLine();
116 void renderBadge(ImVec4 color, ... /* labels, ending in NULL */);
117 void renderInstrumentBadge(std::shared_ptr<Instrument> inst, bool latched, InstrumentBadge badge);
118 bool renderCombo(
119 const char* label,
120 bool alignRight,
121 ImVec4 color,
122 int &selected,
123 const std::vector<std::string>& values,
124 bool useColorForText = false,
125 uint8_t cropTextTo = 0);
126 bool renderCombo(
127 const char* label,
128 bool alignRight,
129 ImVec4 color,
130 int* selected,
131 ...);
132 bool renderToggle(
133 const char* label,
134 bool alignRight,
135 ImVec4 color,
136 bool curValue);
137 bool renderOnOffToggle(const char* label, bool alignRight, bool curValue);
138 void renderDownloadProgress(std::shared_ptr<Instrument> inst, InstrumentChannel *chan, bool isLast);
139 void renderPsuRows(bool isVoltage, bool cc, PowerSupplyChannel* chan,const char *setValue, const char *measuredValue, bool &clicked, bool &hovered);
140 void renderAwgProperties(std::shared_ptr<FunctionGenerator> awg, FunctionGeneratorChannel* awgchan);
141
142 // Rendering of an instrument node
143 void renderInstrumentNode(std::shared_ptr<Instrument> instrument);
144 void DoTimebaseSettings(std::shared_ptr<Oscilloscope> scope);
145 void DoFrequencySettings(std::shared_ptr<Oscilloscope> scope);
146 void DoSpectrometerSettings(std::shared_ptr<SCPISpectrometer> spec);
147
148 // Rendering of a channel node
149 void renderChannelNode(std::shared_ptr<Instrument> instrument, size_t channelIndex, bool isLast);
150
151 // Rendering of a stream node
152 void renderStreamNode(std::shared_ptr<Instrument> instrument, InstrumentChannel* channel, size_t streamIndex, bool renderName, bool renderProps, bool isLast);
153
154 // Rendering of an Filter node
155 void renderFilterNode(Filter* filter);
156
157 Session& m_session;
158 MainWindow* m_parent;
159
161 float m_badgeXMin; // left edge over which we must not overrun
162 float m_badgeXCur; // right edge to render the next badge against
163
164 std::map<std::shared_ptr<Instrument>, bool> m_instrumentDownloadIsSlow;
166 std::map<std::shared_ptr<Instrument>, std::pair<double, InstrumentBadge>> m_instrumentLastBadge;
167
169 std::map<std::shared_ptr<Instrument>, std::shared_ptr<StreamBrowserTimebaseInfo> > m_timebaseConfig;
170
172 void SmallDisabledButton(const char* label)
173 {
174 ImGui::PushStyleVar(ImGuiStyleVar_DisabledAlpha, 1);
175 ImGui::BeginDisabled();
176 ImGui::SmallButton(label);
177 ImGui::EndDisabled();
178 ImGui::PopStyleVar();
179 }
180};
181
182#endif
Declaration of Dialog.
Declaration of Session.
Generic dialog box or other popup window.
Definition: Dialog.h:44
Abstract base class for all filter graph blocks which are not physical instrument channels.
Definition: Filter.h:95
A single channel of a function generator.
Definition: FunctionGeneratorChannel.h:45
A single channel of an instrument.
Definition: InstrumentChannel.h:63
Top level application window.
Definition: MainWindow.h:114
A single channel of a power supply.
Definition: PowerSupplyChannel.h:37
A Session stores all of the instrument configuration and other state the user has open.
Definition: Session.h:95
Definition: StreamBrowserDialog.h:89
void startBadgeLine()
prepare rendering context to display a badge at the end of current line
Definition: StreamBrowserDialog.cpp:149
InstrumentBadge
State of badges used in intrument node rendering.
Definition: StreamBrowserDialog.h:103
bool renderOnOffToggle(const char *label, bool alignRight, bool curValue)
Render an on/off toggle button combo.
Definition: StreamBrowserDialog.cpp:387
virtual bool DoRender() override
Renders the dialog and handles UI events.
Definition: StreamBrowserDialog.cpp:1502
float m_badgeXMin
Positions for badge display.
Definition: StreamBrowserDialog.h:161
void renderDownloadProgress(std::shared_ptr< Instrument > inst, InstrumentChannel *chan, bool isLast)
Render a download progress bar for a given instrument channel.
Definition: StreamBrowserDialog.cpp:404
void renderPsuRows(bool isVoltage, bool cc, PowerSupplyChannel *chan, const char *setValue, const char *measuredValue, bool &clicked, bool &hovered)
Render a PSU properties row.
Definition: StreamBrowserDialog.cpp:552
void renderChannelNode(std::shared_ptr< Instrument > instrument, size_t channelIndex, bool isLast)
Rendering of a channel node.
Definition: StreamBrowserDialog.cpp:1126
void renderInstrumentBadge(std::shared_ptr< Instrument > inst, bool latched, InstrumentBadge badge)
render a badge for an instrument node
Definition: StreamBrowserDialog.cpp:164
void renderFilterNode(Filter *filter)
Rendering of a Filter node.
Definition: StreamBrowserDialog.cpp:1426
std::map< std::shared_ptr< Instrument >, std::shared_ptr< StreamBrowserTimebaseInfo > > m_timebaseConfig
Map of instruments to timebase settings.
Definition: StreamBrowserDialog.h:169
void SmallDisabledButton(const char *label)
Helper to render a small button that's non-interactive.
Definition: StreamBrowserDialog.h:172
bool renderToggle(const char *label, bool alignRight, ImVec4 color, bool curValue)
Render a toggle button combo.
Definition: StreamBrowserDialog.cpp:374
void renderAwgProperties(std::shared_ptr< FunctionGenerator > awg, FunctionGeneratorChannel *awgchan)
Render AWG channel properties.
Definition: StreamBrowserDialog.cpp:625
void renderStreamNode(std::shared_ptr< Instrument > instrument, InstrumentChannel *channel, size_t streamIndex, bool renderName, bool renderProps, bool isLast)
Rendering of a stream node.
Definition: StreamBrowserDialog.cpp:1325
void renderInfoLink(const char *label, const char *linktext, bool &clicked, bool &hovered)
Render a link of the "Sample rate: 4 GSa/s" type that shows up in the scope properties box.
Definition: StreamBrowserDialog.cpp:136
void DoTimebaseSettings(std::shared_ptr< Oscilloscope > scope)
Add nodes for timebase controls under an instrument.
Definition: StreamBrowserDialog.cpp:1042
void renderBadge(ImVec4 color,...)
render a badge at the end of current line with provided color and text
Definition: StreamBrowserDialog.cpp:218
void renderInstrumentNode(std::shared_ptr< Instrument > instrument)
Rendering of an instrument node.
Definition: StreamBrowserDialog.cpp:806
std::map< std::shared_ptr< Instrument >, std::pair< double, InstrumentBadge > > m_instrumentLastBadge
Store the last state of an intrument badge (used for badge state latching)
Definition: StreamBrowserDialog.h:166
Definition: StreamBrowserDialog.h:46