ngscopeclient 0.1-dev+51fbda87c
StreamBrowserDialog.h
Go to the documentation of this file.
1/***********************************************************************************************************************
2* *
3* ngscopeclient *
4* *
5* Copyright (c) 2012-2024 Andrew D. Zonenberg *
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
43using namespace std;
44
45class MainWindow;
46
48{
49public:
50 StreamBrowserDialog(Session& session, MainWindow* parent);
51 virtual ~StreamBrowserDialog();
52
53 virtual bool DoRender() override;
54
55protected:
60 {
61 BADGE_ARMED,
62 BADGE_STOPPED,
63 BADGE_TRIGGERED,
64 BADGE_BUSY,
65 BADGE_AUTO
66 };
67
68 void DoItemHelp();
69
70 // Rendeding of StreamBorwserDialog elements
71 void renderInfoLink(const char *label, const char *linktext, bool &clicked, bool &hovered);
72 void startBadgeLine();
73 bool renderBadge(ImVec4 color, ... /* labels, ending in NULL */);
74 bool renderInstrumentBadge(std::shared_ptr<Instrument> inst, bool latched, InstrumentBadge badge);
75 bool renderCombo(ImVec4 color,int &selected, const std::vector<string> &values, bool useColorForText = false, uint8_t cropTextTo = 0);
76 bool renderCombo(ImVec4 color,int* selected, ... /* values, ending in NULL */);
77 bool renderToggle(ImVec4 color, bool curValue);
78 bool renderOnOffToggle(bool curValue);
79 void renderDownloadProgress(std::shared_ptr<Instrument> inst, InstrumentChannel *chan, bool isLast);
80 void renderPsuRows(bool isVoltage, bool cc, PowerSupplyChannel* chan,const char *setValue, const char *measuredValue, bool &clicked, bool &hovered);
81 void renderAwgProperties(std::shared_ptr<FunctionGenerator> awg, FunctionGeneratorChannel* awgchan, bool &clicked, bool &hovered);
82
83 // Rendering of an instrument node
84 void renderInstrumentNode(shared_ptr<Instrument> instrument);
85
86 // Rendering of a channel node
87 void renderChannelNode(shared_ptr<Instrument> instrument, size_t channelIndex, bool isLast);
88
89 // Rendering of a stream node
90 void renderStreamNode(shared_ptr<Instrument> instrument, InstrumentChannel* channel, size_t streamIndex, bool renderName, bool renderProps, bool isLast);
91
92 // Rendering of an Filter node
93 void renderFilterNode(Filter* filter);
94
95 Session& m_session;
96 MainWindow* m_parent;
97
98 // @brief Positions for badge display
99 float m_badgeXMin; // left edge over which we must not overrun
100 float m_badgeXCur; // right edge to render the next badge against
101
102 std::map<std::shared_ptr<Instrument>, bool> m_instrumentDownloadIsSlow;
103 // @brief Store the last state of an intrument badge (used for badge state latching)
104 std::map<std::shared_ptr<Instrument>, pair<double, InstrumentBadge>> m_instrumentLastBadge;
105};
106
107#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:115
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:48
void startBadgeLine()
prepare rendering context to display a badge at the end of current line
Definition: StreamBrowserDialog.cpp:77
void renderStreamNode(shared_ptr< Instrument > instrument, InstrumentChannel *channel, size_t streamIndex, bool renderName, bool renderProps, bool isLast)
Rendering of a stream node.
Definition: StreamBrowserDialog.cpp:1011
InstrumentBadge
State of badges used in intrument node rendering.
Definition: StreamBrowserDialog.h:60
virtual bool DoRender() override
Renders the dialog and handles UI events.
Definition: StreamBrowserDialog.cpp:1180
void renderDownloadProgress(std::shared_ptr< Instrument > inst, InstrumentChannel *chan, bool isLast)
Render a download progress bar for a given instrument channel.
Definition: StreamBrowserDialog.cpp:311
bool renderCombo(ImVec4 color, int &selected, const std::vector< string > &values, bool useColorForText=false, uint8_t cropTextTo=0)
Render a combo box with provded color and values.
Definition: StreamBrowserDialog.cpp:183
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:459
void renderChannelNode(shared_ptr< Instrument > instrument, size_t channelIndex, bool isLast)
Rendering of a channel node.
Definition: StreamBrowserDialog.cpp:802
bool renderBadge(ImVec4 color,...)
render a badge at the end of current line with provided color and text
Definition: StreamBrowserDialog.cpp:149
void renderFilterNode(Filter *filter)
Rendering of a Filter node.
Definition: StreamBrowserDialog.cpp:1107
bool renderToggle(ImVec4 color, bool curValue)
Render a toggle button combo.
Definition: StreamBrowserDialog.cpp:284
bool renderInstrumentBadge(std::shared_ptr< Instrument > inst, bool latched, InstrumentBadge badge)
render a badge for an instrument node
Definition: StreamBrowserDialog.cpp:92
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:64
void renderInstrumentNode(shared_ptr< Instrument > instrument)
Rendering of an instrument node.
Definition: StreamBrowserDialog.cpp:637
bool renderOnOffToggle(bool curValue)
Render an on/off toggle button combo.
Definition: StreamBrowserDialog.cpp:297
void renderAwgProperties(std::shared_ptr< FunctionGenerator > awg, FunctionGeneratorChannel *awgchan, bool &clicked, bool &hovered)
Render AWG channel properties.
Definition: StreamBrowserDialog.cpp:527