ngscopeclient v0.2.2
Loading...
Searching...
No Matches
WaveformGroup.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 WaveformGroup_h
36#define WaveformGroup_h
37
38#include "WaveformArea.h"
39
44{
45public:
46 WaveformGroup(MainWindow* parent, const std::string& title);
47 virtual ~WaveformGroup();
48
49 void Clear();
50
51 bool Render();
52 void ToneMapAllWaveforms(vk::raii::CommandBuffer& cmdbuf, std::vector<vk::ImageMemoryBarrier>& barriers);
53 void ReferenceWaveformTextures();
54
55 void RenderWaveformTextures(
56 vk::raii::CommandBuffer& cmdbuf,
57 std::vector<std::shared_ptr<InputDescriptor> >& channels,
58 bool clearPersistence);
59
60 const std::string GetID()
61 { return m_title + "###" + m_id; }
62
63 const std::string& GetRawID()
64 { return m_id; }
65
66 const std::string& GetTitle()
67 { return m_title; }
68
69 void AddArea(std::shared_ptr<WaveformArea>& area);
70
71 void AddArea(std::shared_ptr<WaveformArea>& area, size_t position);
72
74
76
77 void OnZoomInHorizontal(int64_t target, float step);
78 void OnZoomOutHorizontal(int64_t target, float step);
79 void OnPanHorizontal(float step);
82 int64_t duration = 0,
84
86
91 { return m_xAxisUnit; }
92
98
104
110
116
117 float GetPixelsPerXUnit()
118 { return m_pixelsPerXUnit; }
119
120 int64_t GetXAxisOffset()
121 { return m_xAxisOffset; }
122
123 void ClearPersistence();
124
125 float GetYAxisWidth()
126 {
127 //Hex numbers need more space to draw
128 //Check if we have any UNIT_HEXNUM areas in the group and scale it up
129 for(auto a : m_areas)
130 {
131 if(a->GetYAxisUnit() == Unit::UNIT_HEXNUM)
132 return 10 * ImGui::GetFontSize();
133 }
134 return 6 * ImGui::GetFontSize();
135 }
136
137 float GetSpacing()
138 { return ImGui::GetFrameHeightWithSpacing() - ImGui::GetFrameHeight(); }
139
141 std::vector< std::shared_ptr<WaveformArea> > GetWaveformAreas()
142 {
143 std::lock_guard<std::mutex> lock(m_areaMutex);
144 return m_areas;
145 }
146
147 //Serialization
148 bool LoadConfiguration(const YAML::Node& node);
149 YAML::Node SerializeConfiguration(IDTable& table);
150
151 bool IsDraggingTrigger()
152 { return m_dragState == DRAG_STATE_TRIGGER; }
153
154 bool IsDraggingXCursor()
155 { return (m_dragState == DRAG_STATE_X_CURSOR0) || (m_dragState == DRAG_STATE_X_CURSOR1); }
156
157 bool IsDraggingMarker()
158 { return (m_dragState == DRAG_STATE_MARKER); }
159
160 bool IsDraggingSomething()
161 { return (m_dragState != DRAG_STATE_NONE); }
162
163 bool IsMouseOverXCursor(int iCursor);
164 bool IsMouseOverYCursorInChild(bool ignoreCursorsPlacedThisFrame);
165
166 bool IsMouseOverAnyXCursor()
167 { return IsMouseOverXCursor(0) || IsMouseOverXCursor(1); }
168
169 void AutofitHorizontal(float width);
170
171protected:
172 void RenderTimeline(float width, float height);
173 void RenderTriggerPositionArrows(ImVec2 pos, float height);
175 void RenderMarkers(ImVec2 pos, ImVec2 size);
176 void DoCursorReadouts();
177
178 void TitleHoverHelp();
179
181
183
184 enum DragState
185 {
186 DRAG_STATE_NONE,
187 DRAG_STATE_TIMELINE,
188 DRAG_STATE_X_CURSOR0,
189 DRAG_STATE_X_CURSOR1,
190 DRAG_STATE_MARKER,
191 DRAG_STATE_TRIGGER
192 };
193
194 void DoCursor(int iCursor, DragState state);
195
197 void OnMouseWheel(float delta);
198
201
203 float m_xpos;
204
206 float m_width;
207
210
213
215 std::string m_title;
216
218 std::string m_id;
219
222
224 std::vector< std::shared_ptr<WaveformArea> > m_areas;
225
226 //Mutex for controlling access to m_areas
227 std::mutex m_areaMutex;
228
230 DragState m_dragState;
231
234
237
239 std::vector< std::shared_ptr<WaveformArea> > m_areasToClose;
240
243
245 std::atomic<bool> m_clearPersistence;
246
249
252
254 std::shared_ptr<Oscilloscope> m_scopeTriggerDuringDrag;
255
258
259public:
260
263 {
264 X_CURSOR_NONE,
265 X_CURSOR_SINGLE,
266 X_CURSOR_DUAL
267 } m_xAxisCursorMode;
268
271};
272
273#endif
274
Declaration of WaveformArea.
Definition AcceleratorBuffer.h:204
Bidirectional table mapping integer IDs in scopesession files to object pointers.
Definition IDTable.h:49
Top level application window.
Definition MainWindow.h:168
Data for a marker.
Definition Marker.h:85
A single channel on an oscilloscope.
Definition OscilloscopeChannel.h:49
Definition SerializableObject.h:40
Descriptor for a single stream coming off a channel.
Definition StreamDescriptor.h:47
A unit of measurement, plus conversion to pretty-printed output.
Definition Unit.h:59
A WaveformArea is a plot that displays one or more OscilloscopeChannel's worth of data.
Definition WaveformArea.h:464
Base class for all Waveform specializations.
Definition Waveform.h:59
A WaveformGroup is a container for one or more WaveformArea's.
Definition WaveformGroup.h:44
void NavigateToTimestamp(int64_t timestamp, int64_t duration=0, StreamDescriptor target=StreamDescriptor(nullptr, 0))
Scrolls the group so the specified timestamp is visible.
Definition WaveformGroup.cpp:1402
void RenderMarkers(ImVec2 pos, ImVec2 size)
Render our markers (and the hovered-packet indicator if any)
Definition WaveformGroup.cpp:579
CursorMode_t
Type of X axis cursor we're displaying.
Definition WaveformGroup.h:263
float m_pixelsPerXUnit
Display scale factor.
Definition WaveformGroup.h:209
double m_tLastMouseMove
Time of last mouse movement.
Definition WaveformGroup.h:236
DragState m_dragState
Description of item being dragged, if any.
Definition WaveformGroup.h:230
void ClearPersistenceOfChannel(OscilloscopeChannel *chan)
Clear saved persistence waveforms of any WaveformArea's within this group containing a stream of one ...
Definition WaveformGroup.cpp:1343
void DoCursorReadouts()
Run the popup window with cursor values.
Definition WaveformGroup.cpp:337
int64_t m_xAxisOffset
X axis position of the left edge of our view.
Definition WaveformGroup.h:212
float XAxisUnitsToPixels(int64_t t)
Converts a distance measurement in X axis units to pixels.
Definition WaveformGroup.h:108
bool m_mouseOverTriggerArrow
True if mouse is over a trigger arrow.
Definition WaveformGroup.h:248
std::string m_title
Display title of the group.
Definition WaveformGroup.h:215
void RenderXAxisCursors(ImVec2 pos, ImVec2 size)
Render our cursors.
Definition WaveformGroup.cpp:745
std::shared_ptr< Oscilloscope > m_scopeTriggerDuringDrag
The scope whose trigger being dragged when in DRAG_STATE_TRIGGER.
Definition WaveformGroup.h:254
float m_width
Width of the window (used for autoscaling)
Definition WaveformGroup.h:206
float GetInBandPower(WaveformBase *wfm, Unit yunit, int64_t t1, int64_t t2)
Calculates the in-band power between two frequencies.
Definition WaveformGroup.cpp:533
int64_t PixelsToXAxisUnits(float pix)
Converts a distance measurement in pixels to X axis units.
Definition WaveformGroup.h:102
bool m_mouseOverMarker
True if mouse is over a marker.
Definition WaveformGroup.h:251
bool m_displayingEye
True if we're displaying an eye pattern (fixed x axis scale)
Definition WaveformGroup.h:257
std::vector< std::shared_ptr< WaveformArea > > GetWaveformAreas()
Gets an atomic snapshot of the waveform areas in this group.
Definition WaveformGroup.h:141
float m_timelineHeight
Height of the timeline.
Definition WaveformGroup.h:242
void ClearPersistence()
Clear saved persistence waveforms.
Definition WaveformGroup.cpp:1332
std::vector< std::shared_ptr< WaveformArea > > m_areas
The set of waveform areas within this group.
Definition WaveformGroup.h:224
int64_t GetRoundingDivisor(int64_t width_xunits)
Decide on reasonable rounding intervals for X axis scale ticks.
Definition WaveformGroup.cpp:1290
void MoveArea(WaveformArea &area, size_t newPosition)
Move a waveform are to another position in this group.
Definition WaveformGroup.cpp:156
std::atomic< bool > m_clearPersistence
True if clearing persistence.
Definition WaveformGroup.h:245
void OnMouseWheel(float delta)
Handles a mouse wheel scroll step.
Definition WaveformGroup.cpp:1259
void ToneMapAllWaveforms(vk::raii::CommandBuffer &cmdbuf, std::vector< vk::ImageMemoryBarrier > &barriers)
Run the tone-mapping shader on all of our waveforms.
Definition WaveformGroup.cpp:195
void RenderTriggerPositionArrows(ImVec2 pos, float height)
Draws an arrow for each scope's trigger position.
Definition WaveformGroup.cpp:1136
int64_t XPositionToXAxisUnits(float pix)
Converts a position in pixels (relative to left side of plot) to X axis units (relative to time zero)
Definition WaveformGroup.h:96
Unit m_xAxisUnit
X axis unit.
Definition WaveformGroup.h:221
float XAxisUnitsToXPosition(int64_t t)
Converts a position in X axis units to pixels (in window coordinates)
Definition WaveformGroup.h:114
Unit GetXAxisUnit()
Gets the X axis unit for this group.
Definition WaveformGroup.h:90
std::string m_id
Internal ImGui ID of the group.
Definition WaveformGroup.h:218
int64_t m_xAxisCursorPositions[2]
Position (in X axis units) of each cursor.
Definition WaveformGroup.h:270
MainWindow * m_parent
Top level window we're attached to.
Definition WaveformGroup.h:200
float m_xpos
X position of our child windows.
Definition WaveformGroup.h:203
std::vector< std::shared_ptr< WaveformArea > > m_areasToClose
List of waveform areas to close next frame.
Definition WaveformGroup.h:239
bool IsMouseOverButtonInWaveformArea()
Returns true if the mouse is over a channel button or similar UI element in a WaveformArea.
Definition WaveformGroup.cpp:731
Marker * m_dragMarker
Marker being dragged, if any.
Definition WaveformGroup.h:233
void OnZoomInHorizontal(int64_t target, float step)
Zoom in, keeping timestamp "target" at the same pixel position.
Definition WaveformGroup.cpp:1356
size_t GetAreaPosition(WaveformArea &area)
Definition WaveformGroup.cpp:134