35#ifndef FilterGraphEditor_h
36#define FilterGraphEditor_h
43#include <imgui_node_editor.h>
44#include <imgui_node_editor_internal.h>
53 bool operator()(
const T& a,
const T& b)
const
54 {
return a.AsPointer() < b.AsPointer(); }
61 const std::pair<ax::NodeEditor::PinId, ax::NodeEditor::PinId>& a,
62 const std::pair<ax::NodeEditor::PinId, ax::NodeEditor::PinId>& b)
const
64 auto fpa = a.first.AsPointer();
65 auto fpb = b.first.AsPointer();
71 return a.second.AsPointer() < b.second.AsPointer();
87 ax::NodeEditor::NodeId
m_id;
96 std::set<ax::NodeEditor::NodeId, lessID<ax::NodeEditor::NodeId> >
m_children;
107 ax::NodeEditor::PinId,
108 std::less<StreamDescriptor>,
114 ax::NodeEditor::PinId,
115 std::less<StreamDescriptor>,
121 ax::NodeEditor::LinkId,
122 std::less<StreamDescriptor>,
127 std::pair<FlowGraphNode*, int>,
128 ax::NodeEditor::PinId,
129 std::less< std::pair<FlowGraphNode*, int> >,
134 std::pair<FlowGraphNode*, int>,
135 ax::NodeEditor::PinId,
136 std::less< std::pair<FlowGraphNode*, int> >,
141 std::pair<FlowGraphNode*, int>,
142 ax::NodeEditor::LinkId,
143 std::less< std::pair<FlowGraphNode*, int> >,
148 void MoveBy(ImVec2 displacement);
178 void DoNodeForGroup(std::shared_ptr<FilterGraphGroup> group);
180 void DoNodeForGroupOutputs(std::shared_ptr<FilterGraphGroup> group);
181 void DoNodeForGroupInputs(std::shared_ptr<FilterGraphGroup> group);
184 std::shared_ptr<Instrument> inst,
197 const std::vector<ax::NodeEditor::NodeId>& nodes,
198 const std::vector<bool>& isgroup,
199 const std::vector<bool>& dragging,
200 const std::vector<bool>& nocollide,
201 const std::vector<ImVec2>& positions,
202 const std::vector<ImVec2>& sizes,
203 std::vector<ImVec2>& forces);
205 const std::vector<ax::NodeEditor::NodeId>& nodes,
206 const std::vector<bool>& isgroup,
207 const std::vector<bool>& dragging,
208 const std::vector<ImVec2>& positions,
209 std::vector<ImVec2>& forces);
234 ax::NodeEditor::PinId,
235 std::less<StreamDescriptor>,
240 std::pair<FlowGraphNode*, int>,
241 ax::NodeEditor::PinId,
242 std::less< std::pair<FlowGraphNode*, int> >,
247 std::pair<ax::NodeEditor::PinId, ax::NodeEditor::PinId>,
248 ax::NodeEditor::LinkId,
263 ax::NodeEditor::NodeId GetID(
Trigger* trig)
266 ax::NodeEditor::NodeId
GetID(std::shared_ptr<FilterGraphGroup> group)
271 ax::NodeEditor::PinId
GetID(std::pair<FlowGraphNode*, size_t> input);
272 ax::NodeEditor::LinkId
GetID(std::pair<ax::NodeEditor::PinId, ax::NodeEditor::PinId> link);
282 ax::NodeEditor::NodeId,
283 std::shared_ptr<EmbeddableDialog>,
289 ImVec2 m_createMousePos;
296 std::shared_ptr<FilterGraphGroup>,
297 ax::NodeEditor::NodeId,
298 std::less< std::shared_ptr<FilterGraphGroup> >,
304 ax::NodeEditor::NodeId,
310 void RenderForceVector(ImDrawList* list, ImVec2 pos, ImVec2 size, ImVec2 vec);
315 static bool SaveSettingsCallback(
318 ax::NodeEditor::SaveReasonFlags flags,
Declaration of Bijection.
A strict one-to-one mapping from objects of type T1 to type T2 (which must be different types).
Definition: Bijection.h:48
Generic dialog box or other popup window.
Definition: Dialog.h:44
Definition: EmbeddableDialog.h:41
Definition: FilterGraphEditor.h:155
void DoNodeForChannel(InstrumentChannel *channel, std::shared_ptr< Instrument > inst, bool multiInst, int64_t runtime)
Make a node for a single channel, of any type.
Definition: FilterGraphEditor.cpp:1972
ax::NodeEditor::Config m_config
Graph editor setup.
Definition: FilterGraphEditor.h:226
ax::NodeEditor::EditorContext * m_context
Context containing current state of the graph editor.
Definition: FilterGraphEditor.h:229
Bijection< std::shared_ptr< FilterGraphGroup >, ax::NodeEditor::NodeId, std::less< std::shared_ptr< FilterGraphGroup > >, lessID< ax::NodeEditor::NodeId > > m_groups
Groups.
Definition: FilterGraphEditor.h:300
void CreateChannelMenu()
Runs the "add input" menu.
Definition: FilterGraphEditor.cpp:1596
std::map< std::shared_ptr< Instrument >, std::vector< InstrumentChannel * > > GetAllVisibleChannels()
Get a list of all channels that we are displaying nodes for.
Definition: FilterGraphEditor.cpp:252
void NodeIcon(InstrumentChannel *chan, ImVec2 iconpos, ImVec2 iconsize, ImDrawList *list)
Draws an icon showing the function of a node.
Definition: FilterGraphEditor.cpp:2268
Bijection< std::pair< FlowGraphNode *, int >, ax::NodeEditor::PinId, std::less< std::pair< FlowGraphNode *, int > >, lessID< ax::NodeEditor::PinId > > m_inputIDMap
Map of (channel, input number) to input port IDs.
Definition: FilterGraphEditor.h:243
virtual bool Render()
Renders the dialog and handles UI events.
Definition: FilterGraphEditor.cpp:235
std::pair< FlowGraphNode *, int > m_createInput
Input we're considering hooking a new channel up to.
Definition: FilterGraphEditor.h:292
ax::NodeEditor::NodeId GetID(FlowGraphNode *node)
Gets the ID for an arbitrary node.
Definition: FilterGraphEditor.cpp:662
ax::NodeEditor::PinId CanonicalizePin(ax::NodeEditor::PinId port)
Gets the actual source/sink pin given a pin which might be a hierarchical port.
Definition: FilterGraphEditor.cpp:1359
MainWindow * m_parent
Top level window.
Definition: FilterGraphEditor.h:223
uintptr_t AllocateID()
Allocate an ID, avoiding collisions with the session IDTable.
Definition: FilterGraphEditor.cpp:2572
std::map< ax::NodeEditor::NodeId, std::shared_ptr< EmbeddableDialog >, lessID< ax::NodeEditor::NodeId > > m_propertiesDialogs
Properties dialogs for channels to be displayed inside nodes.
Definition: FilterGraphEditor.h:284
void DoNodeForTrigger(Trigger *trig)
Make a node for a trigger.
Definition: FilterGraphEditor.cpp:1880
void OutputPortTooltip(StreamDescriptor stream)
Display tooltips when mousing over interesting stuff.
Definition: FilterGraphEditor.cpp:1038
Session & m_session
Session being manipulated.
Definition: FilterGraphEditor.h:220
void ApplyNodeForces(const std::vector< ax::NodeEditor::NodeId > &nodes, const std::vector< bool > &isgroup, const std::vector< bool > &dragging, const std::vector< ImVec2 > &positions, std::vector< ImVec2 > &forces)
Once forces are calculated, actually move the nodes (unless being dragged)
Definition: FilterGraphEditor.cpp:1178
virtual bool DoRender()
Renders the dialog and handles UI events.
Definition: FilterGraphEditor.cpp:428
static bool IsBackEdge(FlowGraphNode *src, FlowGraphNode *dst)
Determine if a proposed edge in the filter graph is a back edge (one whose creation would lead to a c...
Definition: FilterGraphEditor.cpp:1574
std::map< uintptr_t, std::string > GetGroupIDs()
Return a list of group IDs and names.
Definition: FilterGraphEditor.cpp:2662
ax::NodeEditor::NodeId m_selectedProperties
Node whose properties we're currently interacting with.
Definition: FilterGraphEditor.h:287
static size_t LoadSettingsCallback(char *data, void *pThis)
Definition: FilterGraphEditor.cpp:2646
StreamDescriptor m_newFilterSourceStream
Source stream of the newly created filter.
Definition: FilterGraphEditor.h:278
void DoAddMenu()
Implement the add menu.
Definition: FilterGraphEditor.cpp:2496
uintptr_t m_nextID
Next link/port ID to be allocated.
Definition: FilterGraphEditor.h:256
void ClearOldPropertiesDialogs()
Delete old properties dialogs for no-longer-extant nodes.
Definition: FilterGraphEditor.cpp:1008
void RefreshGroupPorts()
Figure out which source/sink ports are within each group.
Definition: FilterGraphEditor.cpp:678
void HandleLinkDeletionRequests(Filter *&fReconfigure)
Handle requests to delete a link.
Definition: FilterGraphEditor.cpp:1787
std::vector< FlowGraphNode * > GetAllNodes()
Get a list of all objects we're displaying nodes for (channels, filters, triggers,...
Definition: FilterGraphEditor.cpp:333
void FilterSubmenu(StreamDescriptor src, const std::string &name, Filter::Category cat)
Run the submenu for a single filter category.
Definition: FilterGraphEditor.cpp:1734
void FilterMenu(StreamDescriptor src)
Runs the "create filter" menu.
Definition: FilterGraphEditor.cpp:1701
void CalculateNodeForces(const std::vector< ax::NodeEditor::NodeId > &nodes, const std::vector< bool > &isgroup, const std::vector< bool > &dragging, const std::vector< bool > &nocollide, const std::vector< ImVec2 > &positions, const std::vector< ImVec2 > &sizes, std::vector< ImVec2 > &forces)
Calculates the forces applied to each node in the graph based on interaction physics.
Definition: FilterGraphEditor.cpp:1095
void HandleBackgroundContextMenu()
Show add menu when background is right clicked.
Definition: FilterGraphEditor.cpp:2472
ax::NodeEditor::PinId GetSourcePinForLink(StreamDescriptor source, FlowGraphNode *sink)
Gets the source pin we should use for drawing a connection.
Definition: FilterGraphEditor.cpp:371
Bijection< std::pair< ax::NodeEditor::PinId, ax::NodeEditor::PinId >, ax::NodeEditor::LinkId, lessIDPair, lessID< ax::NodeEditor::LinkId > > m_linkMap
Map of (ID, ID) to link IDs.
Definition: FilterGraphEditor.h:250
bool HandleNodeProperties()
Open the properties window when a node is right clicked.
Definition: FilterGraphEditor.cpp:2363
ax::NodeEditor::PinId GetSinkPinForLink(StreamDescriptor source, std::pair< FlowGraphNode *, int > sink)
Gets the sink pin we should use for drawing a connection.
Definition: FilterGraphEditor.cpp:399
void DoInternalLinksForGroup(std::shared_ptr< FilterGraphGroup > group)
Handle links between nodes in a group and the hierarchical ports.
Definition: FilterGraphEditor.cpp:962
void HandleLinkCreationRequests(Filter *&fReconfigure)
Handle requests to create a new link.
Definition: FilterGraphEditor.cpp:1390
Bijection< FlowGraphNode *, std::shared_ptr< FilterGraphGroup > > m_nodeGroupMap
Map of signal sources to the group the source node is in (if there is one)
Definition: FilterGraphEditor.h:253
void HandleOverlaps()
Find nodes that are intersecting, and apply forces to resolve collisions.
Definition: FilterGraphEditor.cpp:1270
void HandleDoubleClicks()
Opens a persistent properties window when a node is double clicked.
Definition: FilterGraphEditor.cpp:2323
Bijection< StreamDescriptor, ax::NodeEditor::PinId, std::less< StreamDescriptor >, lessID< ax::NodeEditor::PinId > > m_streamIDMap
Map of streams to output port IDs.
Definition: FilterGraphEditor.h:236
Definition: FilterGraphEditor.h:78
void MoveBy(ImVec2 displacement)
Moves this node and all of its child nodes.
Definition: FilterGraphEditor.cpp:182
Bijection< StreamDescriptor, ax::NodeEditor::PinId, std::less< StreamDescriptor >, lessID< ax::NodeEditor::PinId > > m_hierOutputMap
Map of streams to hierarchial output port IDs.
Definition: FilterGraphEditor.h:109
void RefreshChildren()
Refreshes the list of child nodes within this node.
Definition: FilterGraphEditor.cpp:63
ax::NodeEditor::NodeId m_id
ID of the group.
Definition: FilterGraphEditor.h:87
ax::NodeEditor::NodeId m_inputId
ID of the dummy node for input ports.
Definition: FilterGraphEditor.h:93
std::string m_name
Display name of the group.
Definition: FilterGraphEditor.h:84
Bijection< std::pair< FlowGraphNode *, int >, ax::NodeEditor::PinId, std::less< std::pair< FlowGraphNode *, int > >, lessID< ax::NodeEditor::PinId > > m_hierInputMap
Map of streams to hierarchial input port IDs.
Definition: FilterGraphEditor.h:130
std::set< ax::NodeEditor::PinId, lessID< ax::NodeEditor::PinId > > m_childSourcePins
List of output pins we contain on our child nodes.
Definition: FilterGraphEditor.h:99
std::set< ax::NodeEditor::PinId, lessID< ax::NodeEditor::PinId > > m_childSinkPins
List of input pins we contain on our child nodes.
Definition: FilterGraphEditor.h:102
void RefreshLinks()
Refreshes the list of links between this group and the outside world.
Definition: FilterGraphEditor.cpp:88
Bijection< std::pair< FlowGraphNode *, int >, ax::NodeEditor::LinkId, std::less< std::pair< FlowGraphNode *, int > >, lessID< ax::NodeEditor::LinkId > > m_hierInputLinkMap
Map of streams to internal link IDs.
Definition: FilterGraphEditor.h:144
Bijection< std::pair< FlowGraphNode *, int >, ax::NodeEditor::PinId, std::less< std::pair< FlowGraphNode *, int > >, lessID< ax::NodeEditor::PinId > > m_hierInputInternalMap
Map of streams to hierarchial input port internal-facing port IDs.
Definition: FilterGraphEditor.h:137
ax::NodeEditor::NodeId m_outputId
ID of the dummy node for output ports.
Definition: FilterGraphEditor.h:90
Bijection< StreamDescriptor, ax::NodeEditor::LinkId, std::less< StreamDescriptor >, lessID< ax::NodeEditor::LinkId > > m_hierOutputLinkMap
Map of streams to internal link IDs.
Definition: FilterGraphEditor.h:123
Bijection< StreamDescriptor, ax::NodeEditor::PinId, std::less< StreamDescriptor >, lessID< ax::NodeEditor::PinId > > m_hierOutputInternalMap
Map of streams to hierarchial output port internal-facing port IDs.
Definition: FilterGraphEditor.h:116
std::set< ax::NodeEditor::NodeId, lessID< ax::NodeEditor::NodeId > > m_children
List of nodes we contain (by ID)
Definition: FilterGraphEditor.h:96
Abstract base class for all filter graph blocks which are not physical instrument channels.
Definition: Filter.h:95
Category
Category the filter should be displayed under in the GUI.
Definition: Filter.h:108
Abstract base class for a node in the signal flow graph.
Definition: FlowGraphNode.h:55
uintptr_t emplace(SerializableObject *p)
Store a new object in the table.
Definition: IDTable.h:66
A single channel of an instrument.
Definition: InstrumentChannel.h:63
Top level application window.
Definition: MainWindow.h:114
Definition: SerializableObject.h:40
A Session stores all of the instrument configuration and other state the user has open.
Definition: Session.h:95
IDTable m_idtable
ID mapping used for serialization.
Definition: Session.h:284
Descriptor for a single stream coming off a channel.
Definition: StreamDescriptor.h:46
Abstract base class for oscilloscope / logic analyzer trigger inputs.
Definition: Trigger.h:46
Definition: FilterGraphEditor.h:58
Definition: FilterGraphEditor.h:51