ngscopeclient v0.3
Loading...
Searching...
No Matches
StreamBrowserDialog.h
Go to the documentation of this file.
1/***********************************************************************************************************************
2* *
3* ngscopeclient *
4* *
5* Copyright (c) 2012-2026 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 uint64_t GetRate()
58 {
59 if(m_rates.empty())
60 return 0;
61 return m_rates[m_rate];
62 }
63
64 //Memory depth
65 std::vector<uint64_t> m_depths;
66 std::vector<std::string> m_depthNames;
67 int m_depth;
68
69 //Sampling mode
70 //(only valid if both RT and equivalent are available)
71 int m_samplingMode;
72
73 //Resolution Bandwidth
74 std::string m_rbwText;
75 int64_t m_rbw;
76
77 //Frequency domain controls
78 std::string m_centerText;
79 double m_center;
80
81 std::string m_spanText;
82 double m_span;
83
84 std::string m_startText;
85 double m_start;
86
87 std::string m_endText;
88 double m_end;
89
90 //Spectrometer controls
91 std::string m_integrationText;
92 double m_integrationTime;
93
94 //ADC mode controls
95 std::vector<std::string> m_adcmodeNames;
96 int m_adcmode;
97};
98
100{
101public:
103 virtual ~StreamBrowserDialog();
104
105 virtual bool DoRender() override;
106
107 void FlushConfigCache();
108
109protected:
114 {
115 BADGE_ARMED,
116 BADGE_STOPPED,
117 BADGE_TRIGGERED,
118 BADGE_BUSY,
119 BADGE_AUTO
120 };
121
122 void DoItemHelp();
123
124 // Block handling
125 bool BeginBlock(const char *label, bool withButton = false, const char* tooltip = nullptr);
126 void EndBlock();
127
128 // Rendeding of StreamBrowserDialog elements
129 void startBadgeLine();
130 void renderBadge(ImU32 color, ... /* labels, ending in nullptr */);
131 void renderInstrumentBadge(std::shared_ptr<Instrument> inst, bool latched, InstrumentBadge badge);
132 bool renderCombo(
133 const char* label,
134 bool alignRight,
136 int &selected,
137 const std::vector<std::string>& values,
138 bool useColorForText = false,
140 bool hideArrow = true,
141 float paddingRight = 0);
142 bool renderCombo(
143 const char* label,
144 bool alignRight,
146 int* selected,
147 ...);
148 bool renderToggle(
149 const char* label,
150 bool alignRight,
152 bool& curValue,
153 const char* valueOff = "OFF",
154 const char* valueOn = "ON",
156 float paddingRight = 0);
157 bool renderOnOffToggle(const char* label, bool alignRight, bool& curValue, const char* valueOff = "OFF", const char* valueOn = "ON", uint8_t cropTextTo = 0, float paddingRight = 0);
158 bool renderDownloadProgress(std::shared_ptr<Instrument> inst, InstrumentChannel *chan, bool isLast);
159 bool renderPsuRows(bool isVoltage, bool cc, PowerSupplyChannel* chan, std::string& currentValue, float& committedValue, std::string& measuredValue, bool &clicked, bool &hovered);
160 void renderAwgProperties(std::shared_ptr<FunctionGenerator> awg, FunctionGeneratorChannel* awgchan);
161 void renderDmmProperties(std::shared_ptr<Multimeter> dmm, MultimeterChannel* dmmchan, bool isMain, bool &clicked, bool &hovered);
162
163 // Rendering of an instrument node
164 void renderInstrumentNode(std::shared_ptr<Instrument> instrument);
165 std::shared_ptr<StreamBrowserTimebaseInfo> GetTimebaseInfoFor(std::shared_ptr<Oscilloscope>& scope);
166 void DoTimebaseSettings(std::shared_ptr<Oscilloscope> scope);
167 void DoFrequencySettings(std::shared_ptr<Oscilloscope> scope);
168 void DoSpectrometerSettings(std::shared_ptr<SCPISpectrometer> spec);
169
170 // Rendering of a channel node
171 void renderChannelNode(std::shared_ptr<Instrument> instrument, size_t channelIndex, bool isLast);
172
173 void renderChannelProperties(std::shared_ptr<Oscilloscope> scope, OscilloscopeChannel* scopechan, size_t channelIndex, std::shared_ptr<OscilloscopeState> scopeState);
174
175 // Rendering of a stream node
176 void renderStreamNode(std::shared_ptr<Instrument> instrument, InstrumentChannel* channel, size_t streamIndex, bool renderName, bool renderProps);
177
178 // Rendering of an Filter node
180
182 float m_badgeXMin; // left edge over which we must not overrun
183 float m_badgeXCur; // right edge to render the next badge against
184
185 std::map<std::shared_ptr<Instrument>, bool> m_instrumentDownloadIsSlow;
187 std::map<std::shared_ptr<Instrument>, std::pair<double, InstrumentBadge>> m_instrumentLastBadge;
188
190 std::map<std::shared_ptr<Instrument>, std::shared_ptr<StreamBrowserTimebaseInfo> > m_timebaseConfig;
191
193 std::shared_ptr<StreamGroupDescriptor> m_streamGroupDesciptor;
194
196 void SmallDisabledButton(const char* label)
197 {
198 ImGui::PushStyleVar(ImGuiStyleVar_DisabledAlpha, 1);
199 ImGui::BeginDisabled();
200 ImGui::SmallButton(label);
201 ImGui::EndDisabled();
202 ImGui::PopStyleVar();
203 }
204};
205
206#endif
Declaration of Dialog.
Declaration of Session.
Definition AcceleratorBuffer.h:204
Generic dialog box or other popup window.
Definition Dialog.h:46
Abstract base class for all filter graph blocks which are not physical instrument channels.
Definition Filter.h:105
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:168
A single channel of a multimeter.
Definition MultimeterChannel.h:45
A single channel on an oscilloscope.
Definition OscilloscopeChannel.h:49
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:126
Definition StreamBrowserDialog.h:100
void startBadgeLine()
prepare rendering context to display a badge at the end of current line
Definition StreamBrowserDialog.cpp:143
InstrumentBadge
State of badges used in intrument node rendering.
Definition StreamBrowserDialog.h:114
virtual bool DoRender() override
Renders the dialog and handles UI events.
Definition StreamBrowserDialog.cpp:2291
float m_badgeXMin
Positions for badge display.
Definition StreamBrowserDialog.h:182
std::shared_ptr< StreamGroupDescriptor > m_streamGroupDesciptor
Reference to currently dragged StreamGroupDesciptor.
Definition StreamBrowserDialog.h:193
void renderChannelNode(std::shared_ptr< Instrument > instrument, size_t channelIndex, bool isLast)
Rendering of a channel node.
Definition StreamBrowserDialog.cpp:1558
void renderInstrumentBadge(std::shared_ptr< Instrument > inst, bool latched, InstrumentBadge badge)
render a badge for an instrument node
Definition StreamBrowserDialog.cpp:158
void renderFilterNode(Filter *filter)
Rendering of a Filter node.
Definition StreamBrowserDialog.cpp:2189
std::map< std::shared_ptr< Instrument >, std::shared_ptr< StreamBrowserTimebaseInfo > > m_timebaseConfig
Map of instruments to timebase settings.
Definition StreamBrowserDialog.h:190
void SmallDisabledButton(const char *label)
Helper to render a small button that's non-interactive.
Definition StreamBrowserDialog.h:196
void renderAwgProperties(std::shared_ptr< FunctionGenerator > awg, FunctionGeneratorChannel *awgchan)
Render AWG channel properties.
Definition StreamBrowserDialog.cpp:803
void renderStreamNode(std::shared_ptr< Instrument > instrument, InstrumentChannel *channel, size_t streamIndex, bool renderName, bool renderProps)
Rendering of a stream node.
Definition StreamBrowserDialog.cpp:2035
bool renderToggle(const char *label, bool alignRight, ImVec4 color, bool &curValue, const char *valueOff="OFF", const char *valueOn="ON", uint8_t cropTextTo=0, float paddingRight=0)
Render a toggle button combo.
Definition StreamBrowserDialog.cpp:410
void renderDmmProperties(std::shared_ptr< Multimeter > dmm, MultimeterChannel *dmmchan, bool isMain, bool &clicked, bool &hovered)
Render DMM channel properties.
Definition StreamBrowserDialog.cpp:690
void renderChannelProperties(std::shared_ptr< Oscilloscope > scope, OscilloscopeChannel *scopechan, size_t channelIndex, std::shared_ptr< OscilloscopeState > scopeState)
Rendering of channel properties.
Definition StreamBrowserDialog.cpp:1910
void DoTimebaseSettings(std::shared_ptr< Oscilloscope > scope)
Add nodes for timebase controls under an instrument.
Definition StreamBrowserDialog.cpp:1417
void renderBadge(ImU32 color,...)
render a badge at the end of current line with provided color and text
Definition StreamBrowserDialog.cpp:235
bool renderDownloadProgress(std::shared_ptr< Instrument > inst, InstrumentChannel *chan, bool isLast)
Render a download progress bar for a given instrument channel.
Definition StreamBrowserDialog.cpp:452
bool renderOnOffToggle(const char *label, bool alignRight, bool &curValue, const char *valueOff="OFF", const char *valueOn="ON", uint8_t cropTextTo=0, float paddingRight=0)
Render an on/off toggle button combo.
Definition StreamBrowserDialog.cpp:433
bool renderPsuRows(bool isVoltage, bool cc, PowerSupplyChannel *chan, std::string &currentValue, float &committedValue, std::string &measuredValue, bool &clicked, bool &hovered)
Render a PSU properties row.
Definition StreamBrowserDialog.cpp:604
void renderInstrumentNode(std::shared_ptr< Instrument > instrument)
Rendering of an instrument node.
Definition StreamBrowserDialog.cpp:1028
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:187
Definition StreamBrowserDialog.h:46