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

Top level application window. More...

#include <MainWindow.h>

Inheritance diagram for MainWindow:
Inheritance graph
[legend]
Collaboration diagram for MainWindow:
Collaboration graph
[legend]

Public Member Functions

 MainWindow (std::shared_ptr< QueueHandle > queue)
 
bool OnMemoryPressure (MemoryPressureLevel level, MemoryPressureType type, size_t requestedSize)
 
void LogMemoryUsage ()
 
void AddDialog (std::shared_ptr< Dialog > dlg)
 
void RemoveFunctionGenerator (std::shared_ptr< SCPIFunctionGenerator > gen)
 Closes the function generator dialog, if we have one.
 
void OnScopeAdded (std::shared_ptr< Oscilloscope > scope, bool createViews)
 Handles creation of a new oscilloscope. More...
 
void QueueSplitGroup (std::shared_ptr< WaveformGroup > group, ImGuiDir direction, StreamDescriptor stream)
 
void ShowChannelProperties (OscilloscopeChannel *channel)
 
void ShowInstrumentProperties (std::shared_ptr< Instrument > instrumet)
 
void ShowTimebaseProperties ()
 
void ShowTriggerProperties ()
 
void ShowManageInstruments ()
 
void ShowSyncWizard (std::shared_ptr< TriggerGroup > group, std::shared_ptr< Oscilloscope > secondary)
 
void OnCursorMoved (int64_t offset)
 Called when a cursor is moved, so protocol analyzers can move highlights as needed.
 
void NavigateToTimestamp (int64_t stamp, int64_t duration=0, StreamDescriptor target=StreamDescriptor(nullptr, 0))
 Scrolls all waveform groups so that the specified timestamp is visible.
 
void RefreshTimebasePropertiesDialog ()
 Update the timebase properties dialog.
 
void RefreshTriggerPropertiesDialog ()
 Update the trigger properties dialog.
 
void ToneMapAllWaveforms (vk::raii::CommandBuffer &cmdbuf)
 Run the tone-mapping shader on all of our waveforms. More...
 
void RenderWaveformTextures (vk::raii::CommandBuffer &cmdbuf, std::vector< std::shared_ptr< DisplayedChannel > > &channels)
 
void SetNeedRender ()
 
void ClearPersistence ()
 
virtual void Render ()
 
void QueueCloseSession ()
 
SessionGetSession ()
 
float GetTraceAlpha ()
 
float GetPersistDecay ()
 
void SetPersistDecay (float f)
 
FilterCreateFilter (const std::string &name, WaveformArea *area, StreamDescriptor initialStream, bool showProperties=true, bool addToArea=true)
 Creates a filter optionally and adds all of its streams to the best waveform area. More...
 
void FindAreaForStream (WaveformArea *area, StreamDescriptor stream)
 Given a stream and optionally a WaveformArea, adds the stream to some area. More...
 
void OnFilterReconfigured (Filter *f)
 Handle a filter being reconfigured. More...
 
const std::vector< std::string > & GetEyeGradients ()
 
std::string GetEyeGradientFriendlyName (std::string internalName)
 
std::shared_ptr< MeasurementsDialogGetMeasurementsDialog (bool createIfNotExisting)
 Return the measurements dialog, if we have one.
 
void AddAreaForStreamIfNotAlreadyVisible (StreamDescriptor stream)
 Makes sure we have at least one waveform area displaying a given stream.
 
std::map< uintptr_t, std::string > GetGraphEditorGroups ()
 Returns the groups we have configured for our graph editor.
 
bool LoadUIConfiguration (int version, const YAML::Node &node)
 
void OnGraphEditorConfigModified (const std::string &blob)
 
const std::string & GetGraphEditorConfigBlob ()
 
std::string GetDataDir ()
 
void AddToRecentInstrumentList (std::shared_ptr< SCPIInstrument > inst)
 
void ShowErrorPopup (const std::string &title, const std::string &msg)
 Opens the error popup.
 
ImFont * GetFontPref (const std::string &name)
 Returns a font, given the name of a preference setting.
 
ImU32 GetColorPref (const std::string &name)
 
ImTextureID GetTexture (const std::string &name)
 
TextureManagerGetTextureManager ()
 
std::string GetIconForFilter (Filter *f)
 Gets the icon to use for a filter.
 
std::string GetIconForWaveformShape (FunctionGenerator::WaveShape shape)
 Gets the icon to use for a given wave shape.
 
void AddStatusHelp (const std::string &icon, const std::string &text)
 
int64_t GetToneMapTime ()
 
- Public Member Functions inherited from VulkanWindow
 VulkanWindow (const std::string &title, std::shared_ptr< QueueHandle > queue)
 Creates a new top level window with the specified title.
 
virtual ~VulkanWindow ()
 Destroys a VulkanWindow.
 
GLFWwindow * GetWindow ()
 
float GetContentScale ()
 
virtual void Render ()
 
std::shared_ptr< QueueHandleGetRenderQueue ()
 
void AddTextureUsedThisFrame (std::shared_ptr< Texture > tex)
 
bool IsFullscreen ()
 

Static Public Member Functions

static bool OnMemoryPressureStatic (MemoryPressureLevel level, MemoryPressureType type, size_t requestedSize)
 Static wrapper for calling OnMemoryPressure.
 

Protected Types

enum  { BROWSE_OPEN_SESSION , BROWSE_SAVE_SESSION }
 

Protected Member Functions

virtual void DoRender (vk::raii::CommandBuffer &cmdBuf)
 
void CloseSession ()
 
void InitializeDefaultSession ()
 Creates a new session initialized with some default windows.
 
virtual void RenderUI ()
 
void MainMenu ()
 Run the top level menu bar.
 
void FileMenu ()
 Run the File menu.
 
void FileRecentMenu ()
 Runs the File | Recent menu.
 
void ViewMenu ()
 Run the View menu.
 
void AddMenu ()
 Run the Add menu.
 
void DoAddSubMenu (std::vector< time_t > &timestamps, std::map< time_t, std::vector< std::string > > &reverseMap, const std::string &typePretty, const std::string &defaultName, const std::string &typeInternal)
 Run the Add | (instrument type) submenu.
 
void AddChannelsMenu ()
 Run the Add | Channels menu.
 
void AddImportMenu ()
 Run the Add | Import menu.
 
void AddGenerateMenu ()
 Run the Add | Generate menu.
 
void SetupMenu ()
 Run the Setup menu.
 
void WindowMenu ()
 Run the Window menu.
 
void WindowAnalyzerMenu ()
 Run the Window | Analyzer menu. More...
 
void WindowGeneratorMenu ()
 Run the Window | Generator menu. More...
 
void WindowPSUMenu ()
 Run the Window | Power Supply menu. More...
 
void WindowMultimeterMenu ()
 Run the Window | Multimeter menu.
 
void DebugMenu ()
 Run the Debug menu.
 
void DebugSCPIConsoleMenu ()
 Runs the Debug | SCPI Console menu.
 
void HelpMenu ()
 Run the Help menu.
 
void Toolbar ()
 
void LoadToolbarIcons ()
 Load toolbar icons from disk if preferences changed.
 
void ToolbarButtons ()
 
void TriggerStartDropdown (float buttonsize)
 
void TriggerSingleDropdown (float buttonsize)
 
void TriggerForceDropdown (float buttonsize)
 
void TriggerStopDropdown (float buttonsize)
 
void DoTriggerDropdown (const char *action, std::shared_ptr< TriggerGroup > &group, bool &all)
 
void DockingArea ()
 
void StatusBar (float height)
 
void LoadGradients ()
 Load gradient images.
 
void LoadGradient (const std::string &friendlyName, const std::string &internalName)
 Load a single gradient.
 
void LoadFilterIcons ()
 Load icons for the filter graph.
 
void LoadStatusBarIcons ()
 Load icons for the status bar.
 
void LoadWaveformShapeIcons ()
 Load icons for wave shape preview.
 
std::string NameNewWaveformGroup ()
 
void OnDialogClosed (const std::shared_ptr< Dialog > &dlg)
 
std::shared_ptr< WaveformGroupGetBestGroupForWaveform (StreamDescriptor stream)
 Figure out what group to use for a newly added stream, based on unit compatibility etc.
 
SCPITransportMakeTransport (const std::string &trans, const std::string &args)
 Helper function for creating a transport and printing an error if the connection is unsuccessful.
 
void OnOpenFile (bool online)
 Handler for file | open menu. Spawns the browser dialog.
 
void DoOpenFile (const std::string &sessionPath, bool online)
 Actually open a file (may be triggered by dialog, command line request, or recent file menu)
 
bool PreLoadSessionFromYaml (const YAML::Node &node, const std::string &dataDir, bool online)
 Sanity check a YAML::Node (and associated data directory) to the current session without fully loading. More...
 
bool LoadSessionFromYaml (const YAML::Node &node, const std::string &dataDir, bool online)
 Deserialize a YAML::Node (and associated data directory) to the current session. More...
 
void OnSaveAs ()
 Handler for file | save as menu. Spawns the browser dialog.
 
void DoSaveFile (std::string sessionPath)
 Actually save a file (may be triggered by file|save or file|save as)
 
bool SaveSessionToYaml (YAML::Node &node, const std::string &dataDir)
 Serialize the current session to a YAML::Node. More...
 
void SaveLabNotes (const std::string &dataDir)
 Saves the lab notes to Markdown files in the data directory.
 
void LoadLabNotes (const std::string &dataDir)
 Loads the lab notes from Markdown files in the data directory.
 
bool SetupDataDirectory (const std::string &dataDir)
 Make sure the data directory exists.
 
YAML::Node SerializeUIConfiguration ()
 Serialize waveform areas etc to a YAML::Node.
 
YAML::Node SerializeDialogs ()
 Serializes the list of open dialogs.
 
bool LoadDialogs (const YAML::Node &node)
 Load dialog configuration.
 
void RenderFileBrowser ()
 Runs the file browser dialog.
 
void LoadRecentInstrumentList ()
 
void SaveRecentInstrumentList ()
 
void LoadRecentFileList ()
 
void SaveRecentFileList ()
 
void RenderErrorPopup ()
 Popup message when something big goes wrong.
 
void RenderLoadWarningPopup ()
 Popup message when loading a file that might not match the current hardware setup.
 
bool DropdownButton (const char *id, float height)
 
void UpdateFonts ()
 Font.
 
- Protected Member Functions inherited from VulkanWindow
bool UpdateFramebuffer ()
 Updates the framebuffer.
 
void SetFullscreen (bool fullscreen)
 
virtual void DoRender (vk::raii::CommandBuffer &cmdBuf)
 
virtual void RenderUI ()
 

Protected Attributes

std::map< std::string, std::string > m_eyeGradientFriendlyNames
 
std::vector< std::string > m_eyeGradients
 
bool m_showDemo
 Enable flag for main imgui demo window.
 
ImVec2 m_workPos
 Start position of the viewport minus the menu and toolbar.
 
ImVec2 m_workSize
 Size position of the viewport minus the menu and toolbar.
 
std::set< std::shared_ptr< Workspace > > m_workspaces
 Workspaces (can't be with other dialogs because they can contain other stuff)
 
std::set< std::shared_ptr< Dialog > > m_dialogs
 All dialogs and other pop-up UI elements.
 
std::map< std::shared_ptr< SCPIMultimeter >, std::shared_ptr< Dialog > > m_meterDialogs
 Map of multimeters to meter control dialogs.
 
std::map< std::shared_ptr< SCPIPowerSupply >, std::shared_ptr< Dialog > > m_psuDialogs
 Map of PSUs to power supply control dialogs.
 
std::map< std::shared_ptr< SCPIFunctionGenerator >, std::shared_ptr< Dialog > > m_generatorDialogs
 Map of generators to generator control dialogs.
 
std::map< std::shared_ptr< SCPIBERT >, std::shared_ptr< Dialog > > m_bertDialogs
 Map of BERTs to BERT control dialogs.
 
std::map< std::shared_ptr< SCPIRFSignalGenerator >, std::shared_ptr< Dialog > > m_rfgeneratorDialogs
 Map of RF generators to generator control dialogs.
 
std::map< std::shared_ptr< SCPILoad >, std::shared_ptr< Dialog > > m_loadDialogs
 Map of loads to control dialogs.
 
std::map< std::shared_ptr< SCPIInstrument >, std::shared_ptr< Dialog > > m_scpiConsoleDialogs
 Map of instruments to SCPI console dialogs.
 
std::map< InstrumentChannel *, std::shared_ptr< Dialog > > m_channelPropertiesDialogs
 Map of channels to properties dialogs.
 
std::map< PacketDecoder *, std::shared_ptr< ProtocolAnalyzerDialog > > m_protocolAnalyzerDialogs
 Map of filters to analyzer dialogs.
 
std::vector< std::shared_ptr< WaveformGroup > > m_waveformGroups
 Waveform groups.
 
std::recursive_mutex m_waveformGroupsMutex
 Mutex for controlling access to m_waveformGroups.
 
std::vector< std::shared_ptr< WaveformGroup > > m_newWaveformGroups
 Set of newly created waveform groups that aren't yet docked.
 
int m_nextWaveformGroup
 Name for next autogenerated waveform group.
 
std::shared_ptr< Dialogm_logViewerDialog
 Logfile viewer.
 
std::shared_ptr< Dialogm_metricsDialog
 Performance metrics.
 
std::shared_ptr< Dialogm_preferenceDialog
 Preferences.
 
std::shared_ptr< HistoryDialogm_historyDialog
 History.
 
std::shared_ptr< TimebasePropertiesDialogm_timebaseDialog
 Timebase properties.
 
std::shared_ptr< TriggerPropertiesDialogm_triggerDialog
 Trigger properties.
 
std::shared_ptr< ManageInstrumentsDialogm_manageInstrumentsDialog
 Manage instruments.
 
std::shared_ptr< Dialogm_persistenceDialog
 Persistence settings.
 
std::shared_ptr< Dialogm_notesDialog
 Lab notes.
 
std::shared_ptr< FilterGraphEditorm_graphEditor
 Filter graph editor.
 
std::shared_ptr< StreamBrowserDialogm_streamBrowser
 Stream browser.
 
std::shared_ptr< CreateFilterBrowserm_filterPalette
 Filter palette.
 
std::string m_graphEditorConfigBlob
 Config blob for filter graph editor.
 
std::map< uintptr_t, std::string > m_graphEditorGroups
 Group IDs and names for the graph editor.
 
std::shared_ptr< MeasurementsDialogm_measurementsDialog
 Measurements dialog.
 
std::vector< SplitGroupRequestm_splitRequests
 Pending requests to split waveform groups.
 
std::shared_ptr< Workspacem_initialWorkspaceDockRequest
 Pending requests to dock initial stuff.
 
std::vector< size_t > m_groupsToClose
 Pending requests to close waveform groups.
 
int m_toolbarIconSize
 Cached toolbar icon size.
 
float m_traceAlpha
 Trace alpha.
 
float m_persistenceDecay
 Persistence decay factor.
 
std::set< std::pair< OscilloscopeChannel *, WaveformArea * > > m_pendingChannelDisplayRequests
 Pending requests to display a channel in a waveform area (from CreateFilter())
 
Session m_session
 Our session object.
 
bool m_sessionClosing
 True if a close-session request came in this frame.
 
enum MainWindow:: { ... }  m_fileBrowserMode
 
std::shared_ptr< FileBrowserm_fileBrowser
 Browser for pending file loads.
 
std::vector< YAML::Node > m_fileBeingLoaded
 YAML structure for file we're currently loading.
 
bool m_fileLoadInProgress
 True if we're actively loading a file.
 
std::string m_sessionFileName
 Current session file path.
 
std::string m_sessionDataDir
 Current session data directory.
 
bool m_openOnline
 True if the pending file is to be opened online.
 
std::map< std::string, time_t > m_recentInstruments
 List of recently used instruments.
 
std::map< std::string, time_t > m_recentFiles
 List of recently used files.
 
std::string m_errorPopupTitle
 
std::string m_errorPopupMessage
 
bool m_showingLoadWarnings
 
bool m_loadConfirmationChecked
 
TextureManager m_texmgr
 
bool m_needRender
 True if a resize or other event this frame requires we re-rasterize waveforms. More...
 
std::atomic< bool > m_clearPersistence
 True if we should clear persistence on the next render pass.
 
std::unique_ptr< vk::raii::CommandPool > m_cmdPool
 Command pool for allocating our command buffers.
 
std::unique_ptr< vk::raii::CommandBuffer > m_cmdBuffer
 Command buffer used during rendering operations.
 
FontManager m_fontmgr
 
std::map< std::type_index, std::string > m_filterIconMap
 Map of filter types to class names.
 
std::map< FunctionGenerator::WaveShape, std::string > m_waveformShapeIconMap
 Map of Waveform Shapes to icons.
 
std::map< std::string, std::string > m_statusHelp
 
int64_t m_toneMapTime
 
- Protected Attributes inherited from VulkanWindow
GLFWwindow * m_window
 The underlying GLFW window object.
 
ImGuiContext * m_context
 ImGui context for GUI objects.
 
std::shared_ptr< vk::raii::SurfaceKHR > m_surface
 Surface for drawing onto.
 
std::shared_ptr< vk::raii::DescriptorPool > m_imguiDescriptorPool
 Descriptor pool for ImGui.
 
std::shared_ptr< QueueHandlem_renderQueue
 Queue for rendering to.
 
bool m_resizeEventPending
 Set true if we have to handle a resize event.
 
bool m_softwareResizeRequested
 Set true if a resize was requested by software (i.e. we need to resize to m_pendingWidth / m_pendingHeight)
 
int m_pendingWidth
 Requested width for software resize.
 
int m_pendingHeight
 Requested height for software resize.
 
std::unique_ptr< vk::raii::CommandPool > m_cmdPool
 Frame command pool.
 
std::vector< std::unique_ptr< vk::raii::CommandBuffer > > m_cmdBuffers
 Frame command buffers.
 
std::vector< std::unique_ptr< vk::raii::Semaphore > > m_imageAcquiredSemaphores
 Semaphore indicating framebuffer is ready.
 
std::vector< std::unique_ptr< vk::raii::Semaphore > > m_renderCompleteSemaphores
 Semaphore indicating frame is complete.
 
uint32_t m_semaphoreIndex
 Frame semaphore number for double buffering.
 
uint32_t m_frameIndex
 Frame number for double buffering.
 
uint32_t m_lastFrameIndex
 Frame number for double buffering.
 
std::vector< std::unique_ptr< vk::raii::Fence > > m_fences
 Frame fences.
 
std::vector< std::unique_ptr< vk::raii::ImageView > > m_backBufferViews
 Back buffer view.
 
std::vector< std::unique_ptr< vk::raii::Framebuffer > > m_framebuffers
 Framebuffer.
 
std::unique_ptr< vk::raii::RenderPass > m_renderPass
 Render pass for drawing everything.
 
std::unique_ptr< vk::raii::SwapchainKHR > m_swapchain
 Swapchain for presenting to the screen.
 
std::vector< VkImage > m_backBuffers
 Back buffer images. More...
 
int m_minImageCount
 The minimum image count for the backbuffer allowed by this GPU.
 
int m_width
 Current window width.
 
int m_height
 Current window height.
 
bool m_fullscreen
 Fullscreen flag.
 
int m_windowedX
 Saved position before we went fullscreen.
 
int m_windowedY
 Saved position before we went fullscreen.
 
int m_windowedWidth
 Saved size before we went fullscreen.
 
int m_windowedHeight
 Saved size before we went fullscreen.
 
std::vector< std::set< std::shared_ptr< Texture > > > m_texturesUsedThisFrame
 Textures used this frame.
 

Detailed Description

Top level application window.

Member Function Documentation

◆ CreateFilter()

Filter * MainWindow::CreateFilter ( const std::string &  name,
WaveformArea area,
StreamDescriptor  initialStream,
bool  showProperties = true,
bool  addToArea = true 
)

Creates a filter optionally and adds all of its streams to the best waveform area.

Parameters
nameName of the filter
areaWaveform area we launched the context menu from (if any)
initialStreamStream we launched the context menu from (if any)
showPropertiesTrue to show the properties dialog
addtoAreaTrue to add to a waveform area

◆ DoRender()

void MainWindow::DoRender ( vk::raii::CommandBuffer &  cmdBuf)
protectedvirtual

Reimplemented from VulkanWindow.

◆ FindAreaForStream()

void MainWindow::FindAreaForStream ( WaveformArea area,
StreamDescriptor  stream 
)

Given a stream and optionally a WaveformArea, adds the stream to some area.

The provided area is considered first; if it's not a good fit then another area is selected. If no compatible area can be found, a new one is created.

◆ LoadSessionFromYaml()

bool MainWindow::LoadSessionFromYaml ( const YAML::Node &  node,
const std::string &  dataDir,
bool  online 
)
protected

Deserialize a YAML::Node (and associated data directory) to the current session.

You must call PreLoadSessionFromYaml before calling this function.

Parameters
nodeRoot YAML node of the file
dataDirPath to the _data directory associated with the session
onlineTrue if we should reconnect to instruments
Returns
True if successful, false on error

◆ OnFilterReconfigured()

void MainWindow::OnFilterReconfigured ( Filter f)

Handle a filter being reconfigured.

TODO: push this to a background thread to avoid hanging the UI thread

◆ OnScopeAdded()

void MainWindow::OnScopeAdded ( std::shared_ptr< Oscilloscope scope,
bool  createViews 
)

Handles creation of a new oscilloscope.

Parameters
scopeThe scope to add
createViewsTrue if we should add waveform areas for each enabled channel

◆ PreLoadSessionFromYaml()

bool MainWindow::PreLoadSessionFromYaml ( const YAML::Node &  node,
const std::string &  dataDir,
bool  online 
)
protected

Sanity check a YAML::Node (and associated data directory) to the current session without fully loading.

Parameters
nodeRoot YAML node of the file
dataDirPath to the _data directory associated with the session
onlineTrue if we should reconnect to instruments
Returns
True if successful, false on error

◆ Render()

void MainWindow::Render ( )
virtual

Reimplemented from VulkanWindow.

◆ RenderUI()

void MainWindow::RenderUI ( )
protectedvirtual

Reimplemented from VulkanWindow.

◆ SaveSessionToYaml()

bool MainWindow::SaveSessionToYaml ( YAML::Node &  node,
const std::string &  dataDir 
)
protected

Serialize the current session to a YAML::Node.

Parameters
nodeNode for the main .scopesession
dataDirPath to the _data directory (may not have been created yet)
Returns
True if successful, false on error

◆ ToneMapAllWaveforms()

void MainWindow::ToneMapAllWaveforms ( vk::raii::CommandBuffer &  cmdbuf)

Run the tone-mapping shader on all of our waveforms.

Called by Session::CheckForWaveforms() at the start of each frame if new data is ready to render

◆ WindowAnalyzerMenu()

void MainWindow::WindowAnalyzerMenu ( )
protected

Run the Window | Analyzer menu.

This menu is used for displaying protocol analyzers

◆ WindowGeneratorMenu()

void MainWindow::WindowGeneratorMenu ( )
protected

Run the Window | Generator menu.

This menu is used for connecting to a function generator that is part of an oscilloscope or other instrument.

◆ WindowPSUMenu()

void MainWindow::WindowPSUMenu ( )
protected

Run the Window | Power Supply menu.

This menu is used for controlling a power supply that is already open in the session but has had the dialog closed.

Member Data Documentation

◆ m_needRender

bool MainWindow::m_needRender
protected

True if a resize or other event this frame requires we re-rasterize waveforms.

(even if data has not changed)


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