ngscopeclient 0.1-dev+51fbda87c
Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
WaveformArea Class Reference

A WaveformArea is a plot that displays one or more OscilloscopeChannel's worth of data. More...

#include <WaveformArea.h>

Collaboration diagram for WaveformArea:
Collaboration graph
[legend]

Public Member Functions

 WaveformArea (StreamDescriptor stream, std::shared_ptr< WaveformGroup > group, MainWindow *parent)
 
bool Render (int iArea, int numAreas, ImVec2 clientArea)
 Renders a waveform area. More...
 
void RenderWaveformTextures (vk::raii::CommandBuffer &cmdbuf, std::vector< std::shared_ptr< DisplayedChannel > > &channels, bool clearPersistence)
 Runs the rendering shader on all of our waveforms. More...
 
void ReferenceWaveformTextures ()
 Marks all of our waveform textures as being used this frame.
 
void ToneMapAllWaveforms (vk::raii::CommandBuffer &cmdbuf)
 Tone map our waveforms.
 
size_t GetStreamCount ()
 
StreamDescriptor GetStream (size_t i)
 
std::shared_ptr< DisplayedChannelGetDisplayedChannel (size_t i)
 
bool IsStreamBeingDisplayed (StreamDescriptor target)
 Checks if this area is currently displaying a provided stream.
 
void AddStream (StreamDescriptor desc, bool persistence=false, const std::string &ramp="eye-gradient-viridis")
 Adds a new stream to this plot.
 
bool IsCompatible (StreamDescriptor desc)
 Checks if this area is compatible with a provided stream.
 
void RemoveStream (size_t i)
 Removes the stream at a specified index.
 
void ClearPersistence ()
 
void ClearPersistenceOfChannel (OscilloscopeChannel *chan)
 Clear persistence iff we are displaying the specified channel. More...
 
bool IsChannelBeingDragged ()
 Returns true if a channel is currently being dragged.
 
StreamDescriptor GetChannelBeingDragged ()
 Returns the channel being dragged, if one exists.
 
std::shared_ptr< WaveformGroupGetGroup ()
 Gets the WaveformGroup for this area.
 
TimePoint GetWaveformTimestamp ()
 Gets the timestamp of our current waveform (if we have one)
 
StreamDescriptor GetFirstAnalogStream ()
 Returns the first analog stream displayed in this area. More...
 
StreamDescriptor GetFirstEyeStream ()
 Returns the first eye pattern displayed in this area. More...
 
StreamDescriptor GetFirstConstellationStream ()
 Returns the first constellation diagram displayed in this area. More...
 
StreamDescriptor GetFirstDensityFunctionStream ()
 Returns the first density plot displayed in this area. More...
 
StreamDescriptor GetFirstAnalogOrDensityStream ()
 Returns the first analog, spectrogram or eye pattern stream displayed in this area. More...
 
bool IsMouseOverButtonAtEndOfRender ()
 Returns true if the mouse is over a button, rather than the plot area. More...
 

Protected Types

enum  DragState {
  DRAG_STATE_NONE , DRAG_STATE_CHANNEL , DRAG_STATE_CHANNEL_LAST , DRAG_STATE_Y_AXIS ,
  DRAG_STATE_TRIGGER_LEVEL , DRAG_STATE_TRIGGER_SECONDARY_LEVEL , DRAG_STATE_BER_LEVEL , DRAG_STATE_BER_BOTH ,
  DRAG_STATE_PEAK_MARKER
}
 Drag and drop of UI elements.
 

Protected Member Functions

void ChannelButton (std::shared_ptr< DisplayedChannel > chan, size_t index)
 Handles a button for a channel.
 
void RenderBackgroundGradient (ImVec2 start, ImVec2 size)
 Renders the background of the main plot area. More...
 
void RenderGrid (ImVec2 start, ImVec2 size, std::map< float, float > &gridmap, float &vbot, float &vtop)
 Renders grid lines.
 
void RenderYAxis (ImVec2 size, std::map< float, float > &gridmap, float vbot, float vtop)
 Renders the Y axis scale.
 
void RenderTriggerLevelArrows (ImVec2 start, ImVec2 size)
 Arrows pointing to trigger levels.
 
void RenderBERLevelArrows (ImVec2 start, ImVec2 size)
 Arrows pointing to BERT sampling level.
 
void RenderCursors (ImVec2 start, ImVec2 size)
 Cursors and related stuff.
 
void RenderBERSamplingPoint (ImVec2 start, ImVec2 size)
 Sampling point for BER.
 
void CheckForScaleMismatch (ImVec2 start, ImVec2 size)
 Look for mismatched vertical scales and display warning message.
 
void RenderEyePatternTooltip (ImVec2 start, ImVec2 size)
 Draw the tooltip on an eye pattern.
 
void RenderWaveforms (ImVec2 start, ImVec2 size)
 Renders our waveforms.
 
void RenderAnalogWaveform (std::shared_ptr< DisplayedChannel > channel, ImVec2 start, ImVec2 size)
 Renders a single analog waveform.
 
void RenderEyeWaveform (std::shared_ptr< DisplayedChannel > channel, ImVec2 start, ImVec2 size)
 Renders a single eye pattern.
 
void RenderConstellationWaveform (std::shared_ptr< DisplayedChannel > channel, ImVec2 start, ImVec2 size)
 Renders a single constellation diagram.
 
void RenderWaterfallWaveform (std::shared_ptr< DisplayedChannel > channel, ImVec2 start, ImVec2 size)
 Renders a single waterfall.
 
void RenderSpectrogramWaveform (std::shared_ptr< DisplayedChannel > channel, ImVec2 start, ImVec2 size)
 Renders a single spectrogram (same as waterfall for now)
 
void RenderSpectrumPeaks (ImDrawList *list, std::shared_ptr< DisplayedChannel > channel)
 Draw peaks from a FFT or similar waveform.
 
void RenderDigitalWaveform (std::shared_ptr< DisplayedChannel > channel, ImVec2 start, ImVec2 size)
 Renders a single digital waveform.
 
void RenderProtocolWaveform (std::shared_ptr< DisplayedChannel > channel, ImVec2 start, ImVec2 size)
 Renders a single protocol waveform (assume it's sparse) More...
 
void RenderComplexSignal (ImDrawList *list, int visleft, int visright, float xstart, float xend, float xoff, float ybot, float ymid, float ytop, std::string str, ImU32 color)
 
void MakePathSignalBody (ImDrawList *list, float xstart, float xend, float ybot, float ymid, float ytop)
 
void ToneMapAnalogOrDigitalWaveform (std::shared_ptr< DisplayedChannel > channel, vk::raii::CommandBuffer &cmdbuf)
 Tone maps an analog or digital waveform by converting the internal fp32 buffer to RGBA.
 
void ToneMapEyeWaveform (std::shared_ptr< DisplayedChannel > channel, vk::raii::CommandBuffer &cmdbuf)
 Tone maps an eye waveform by converting the internal fp32 buffer to RGBA.
 
void ToneMapConstellationWaveform (std::shared_ptr< DisplayedChannel > channel, vk::raii::CommandBuffer &cmdbuf)
 Tone maps a constellation waveform by converting the internal fp32 buffer to RGBA.
 
void ToneMapWaterfallWaveform (std::shared_ptr< DisplayedChannel > channel, vk::raii::CommandBuffer &cmdbuf)
 Tone maps a density function waveform by converting the internal fp32 buffer to RGBA and cropping/scaling.
 
void ToneMapSpectrogramWaveform (std::shared_ptr< DisplayedChannel > channel, vk::raii::CommandBuffer &cmdbuf)
 Tone maps a spectrogram waveform by converting the internal fp32 buffer to RGBA and cropping/scaling.
 
void RasterizeAnalogOrDigitalWaveform (std::shared_ptr< DisplayedChannel > channel, vk::raii::CommandBuffer &cmdbuf, bool clearPersistence)
 
void PlotContextMenu ()
 Run the context menu for the main plot area.
 
void DrawDropRangeMismatchMessage (ImDrawList *list, ImVec2 center, StreamDescriptor ourStream, StreamDescriptor theirStream)
 Display a warning message about mismatched vertical scale.
 
void DragDropOverlays (ImVec2 start, ImVec2 size, int iArea, int numAreas)
 Drag-and-drop overlay areas.
 
void CenterLeftDropArea (ImVec2 start, ImVec2 size)
 Drop area for the middle of the plot. More...
 
void CenterRightDropArea (ImVec2 start, ImVec2 size)
 Drop area for the middle of the plot. More...
 
void EdgeDropArea (const std::string &name, ImVec2 start, ImVec2 size, ImGuiDir splitDir)
 Drop area for edge of the plot. More...
 
void FilterMenu (std::shared_ptr< DisplayedChannel > chan)
 
void FilterSubmenu (std::shared_ptr< DisplayedChannel > chan, const std::string &name, Filter::Category cat)
 Run the submenu for a single filter category.
 
float PixelsToYAxisUnits (float pix)
 
float YAxisUnitsToPixels (float volt)
 
float YAxisUnitsToYPosition (float volt)
 
float YPositionToYAxisUnits (float y)
 
float PickStepSize (float volts_per_half_span, int min_steps=2, int max_steps=5)
 
void OnMouseWheelPlotArea (float delta, float delta_h)
 Handles a mouse wheel scroll step on the plot area. More...
 
void OnMouseWheelYAxis (float delta)
 Handles a mouse wheel scroll step on the Y axis.
 
void OnMouseUp ()
 
void OnDragUpdate ()
 
ImVec2 ClosestPointOnLineSegment (ImVec2 lineA, ImVec2 lineB, ImVec2 pt)
 Computes the closest point on a line segment (given the endpoints) to a given point. More...
 

Protected Attributes

float m_width
 Cached plot width (excluding Y axis)
 
float m_height
 Cached plot height.
 
float m_yAxisOffset
 Cached Y axis offset.
 
float m_ymid
 Cached midpoint of the plot.
 
float m_pixelsPerYAxisUnit
 Cached Y axis scale.
 
Unit m_yAxisUnit
 Cached Y axis unit.
 
enum WaveformArea::DragState m_dragState
 
StreamDescriptor m_dragStream
 The stream currently being dragged (invalid if m_dragState != DRAG_STATE_CHANNEL)
 
std::vector< std::shared_ptr< DisplayedChannel > > m_displayedChannels
 The channels currently living within this WaveformArea. More...
 
std::shared_ptr< WaveformGroupm_group
 Waveform group containing us.
 
MainWindowm_parent
 Top level window object containing us.
 
double m_tLastMouseMove
 Time of last mouse movement.
 
bool m_mouseOverTriggerArrow
 True if mouse is over a trigger level arrow.
 
bool m_mouseOverBERTarget
 True if mouse is over the BER sampling location.
 
float m_triggerLevelDuringDrag
 Current trigger level, if dragging.
 
int64_t m_xAxisPosDuringDrag
 Current X axis position during drag.
 
Triggerm_triggerDuringDrag
 The trigger we're configuring.
 
BERTInputChannelm_bertChannelDuringDrag
 The BERT channel we're configuring.
 
std::vector< std::shared_ptr< DisplayedChannel > > m_channelsToRemove
 Channels we're in the process of removing.
 
int64_t m_lastRightClickOffset
 X axis position of the mouse at the most recent right click.
 
std::atomic< bool > m_clearPersistence
 True if clearing persistence next render.
 
float m_channelButtonHeight
 Height of a channel button.
 
PeakLabelm_dragPeakLabel
 Peak label being dragged, if any.
 
ImVec2 m_dragPeakAnchorOffset
 Offset, in pixels, from mouse to anchor point of peak being dragged.
 
bool m_mouseOverButton
 True if the mouse cursor is over a channel button.
 

Detailed Description

A WaveformArea is a plot that displays one or more OscilloscopeChannel's worth of data.

WaveformArea's auto resize, and will collectively fill the entire client area of their parent window.

Member Function Documentation

◆ CenterLeftDropArea()

void WaveformArea::CenterLeftDropArea ( ImVec2  start,
ImVec2  size 
)
protected

Drop area for the middle of the plot.

Dropping a waveform in here adds it to the plot

◆ CenterRightDropArea()

void WaveformArea::CenterRightDropArea ( ImVec2  start,
ImVec2  size 
)
protected

Drop area for the middle of the plot.

Dropping a waveform in here adds it to a new plot in the same group

◆ ClearPersistenceOfChannel()

void WaveformArea::ClearPersistenceOfChannel ( OscilloscopeChannel chan)

Clear persistence iff we are displaying the specified channel.

TODO: can we clear only that channel and nothing else? TODO: clear if we have any dependency chain leading to the specified channel

◆ ClosestPointOnLineSegment()

ImVec2 WaveformArea::ClosestPointOnLineSegment ( ImVec2  lineA,
ImVec2  lineB,
ImVec2  pt 
)
protected

Computes the closest point on a line segment (given the endpoints) to a given point.

Reference: https://en.wikibooks.org/wiki/Linear_Algebra/Orthogonal_Projection_Onto_a_Line

◆ EdgeDropArea()

void WaveformArea::EdgeDropArea ( const std::string &  name,
ImVec2  start,
ImVec2  size,
ImGuiDir  splitDir 
)
protected

Drop area for edge of the plot.

Dropping a waveform in here splits and forms a new group

◆ GetFirstAnalogOrDensityStream()

StreamDescriptor WaveformArea::GetFirstAnalogOrDensityStream ( )

Returns the first analog, spectrogram or eye pattern stream displayed in this area.

(this really means "has a useful Y axis")

If no suitable waveforms returns a null stream.

◆ GetFirstAnalogStream()

StreamDescriptor WaveformArea::GetFirstAnalogStream ( )

Returns the first analog stream displayed in this area.

If no analog waveforms are visible, returns a null stream.

◆ GetFirstConstellationStream()

StreamDescriptor WaveformArea::GetFirstConstellationStream ( )

Returns the first constellation diagram displayed in this area.

If no constellation diagrams are visible, returns a null stream.

◆ GetFirstDensityFunctionStream()

StreamDescriptor WaveformArea::GetFirstDensityFunctionStream ( )

Returns the first density plot displayed in this area.

If none are visible, returns a null stream.

◆ GetFirstEyeStream()

StreamDescriptor WaveformArea::GetFirstEyeStream ( )

Returns the first eye pattern displayed in this area.

If no eye patterns are visible, returns a null stream.

◆ IsMouseOverButtonAtEndOfRender()

bool WaveformArea::IsMouseOverButtonAtEndOfRender ( )
inline

Returns true if the mouse is over a button, rather than the plot area.

Only valid after rendering is complete before start of the next render cycle

◆ OnMouseWheelPlotArea()

void WaveformArea::OnMouseWheelPlotArea ( float  delta,
float  delta_h 
)
protected

Handles a mouse wheel scroll step on the plot area.

Parameters
deltaVertical scroll steps
delta_hHorizontal scroll steps

◆ Render()

bool WaveformArea::Render ( int  iArea,
int  numAreas,
ImVec2  clientArea 
)

Renders a waveform area.

Returns false if the area should be closed (no more waveforms visible in it)

◆ RenderBackgroundGradient()

void WaveformArea::RenderBackgroundGradient ( ImVec2  start,
ImVec2  size 
)
protected

Renders the background of the main plot area.

For now, simple gray gradient.

◆ RenderProtocolWaveform()

void WaveformArea::RenderProtocolWaveform ( std::shared_ptr< DisplayedChannel channel,
ImVec2  start,
ImVec2  size 
)
protected

Renders a single protocol waveform (assume it's sparse)

TODO: should we ever support uniform protocol data? maybe coming off some kind of analyzer?

◆ RenderWaveformTextures()

void WaveformArea::RenderWaveformTextures ( vk::raii::CommandBuffer &  cmdbuf,
std::vector< std::shared_ptr< DisplayedChannel > > &  channels,
bool  clearPersistence 
)

Runs the rendering shader on all of our waveforms.

Called from WaveformThread

Parameters
cmdbufCommand buffer to record rendering commands into
chansSet of channels we rendered into Used to keep references active until rendering completes if we close them this frame
clearPersistenceTrue if persistence maps should be erased before rendering

Member Data Documentation

◆ m_displayedChannels

std::vector<std::shared_ptr<DisplayedChannel> > WaveformArea::m_displayedChannels
protected

The channels currently living within this WaveformArea.

TODO: make this a FlowGraphNode and just hook up inputs??


The documentation for this class was generated from the following files: