cisst-saw
Loading...
Searching...
No Matches
mtsComponentViewerQt.h
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/* ex: set filetype=cpp softtabstop=4 shiftwidth=4 tabstop=4 cindent expandtab: */
3
4/*
5 Author(s): Anton Deguet
6 Created on: 2025-10-28
7
8 (C) Copyright 2025-2026 Johns Hopkins University (JHU), All Rights Reserved.
9
10--- begin cisst license - do not edit ---
11
12This software is provided "as is" under an open source license, with
13no warranty. The complete license can be found in license.txt and
14http://www.cisst.org/cisst/license.txt.
15
16--- end cisst license ---
17*/
18
19#ifndef _mtsComponentViewerQt_h
20#define _mtsComponentViewerQt_h
21
22#include <cisstConfig.h>
23#if !CISST_HAS_QTNODES
24#error "mtsComponentViewerQt.h requires CISST_HAS_QTNODES"
25#endif
26
28
31
32#include <QTimer>
33#include <QWidget>
34
35class QToolBar;
36
37namespace QtNodes {
38 class NodeDelegateModelRegistry;
39 class DataFlowGraphModel;
40 class DataFlowGraphicsScene;
41 class GraphicsView;
42} // namespace QtNodes
43
44// Always include last
46
47class CISST_EXPORT mtsComponentViewerQt : public QWidget,
48 public mtsTaskFromSignal {
49 Q_OBJECT
51
52 public:
53 mtsComponentViewerQt(const std::string &componentName = "ComponentViewer");
55
56 void Configure(const std::string &filename = "") override;
57 void Startup(void) override;
58 void Cleanup(void) override;
59 void Run(void) override;
60
61 protected slots:
62 void onExportDOT(void);
63 void onAutoLayout(void);
64
65 void AddComponentHandler(const mtsDescriptionComponent &component_description);
66 void AddConnectionHandler(const mtsDescriptionConnection &connection_description);
67 void RemoveConnectionHandler(const mtsDescriptionConnection &connection_description);
69
70 protected:
71 QToolBar *ToolBar;
72
73 void setupUi(void);
74
75 // Qt Nodes objects
76 std::shared_ptr<QtNodes::NodeDelegateModelRegistry> Registry;
77 QtNodes::DataFlowGraphModel *GraphModel;
78 QtNodes::DataFlowGraphicsScene *Scene;
79 QtNodes::GraphicsView *View;
80
81 // Keep track of components and their node IDs.
82 typedef std::pair<std::string, std::string> ComponentKey;
83 std::vector<ComponentKey> m_components;
84
85 // Keep NodeId as an unsigned int in the public header to avoid pulling
86 // QtNodes types into all translation units; the implementation will use
87 // QtNodes::NodeId where needed.
88 std::map<ComponentKey, unsigned int> NodeIds;
89
90 // Track interface to port index mapping.
91 std::map<ComponentKey, std::map<std::string, unsigned int>>
93 std::map<ComponentKey, std::map<std::string, unsigned int>>
95
96 // Cache for rebuilding graph
97 std::vector<mtsDescriptionComponent> m_component_infos;
98 std::vector<mtsDescriptionConnection> m_connection_infos;
99
100 std::set<std::string> m_show_component_tags;
101 std::set<std::string> m_show_interface_tags;
102
103 void UpdateGraph(void);
104
105 protected slots:
106 void onFilterComponents(bool checked);
107 void onFilterInterfaces(bool checked);
108
109 private:
110 // no copy constructor
111 mtsComponentViewerQt(const mtsComponentViewerQt &other) = delete;
112};
113
115
116#endif // _mtsComponentViewerQt_h
Definition mtsParameterTypes.h:869
Definition mtsComponentViewerQt.h:48
void AddComponentHandler(const mtsDescriptionComponent &component_description)
void onFilterInterfaces(bool checked)
void onAutoLayout(void)
mtsComponentViewerQt(const std::string &componentName="ComponentViewer")
QToolBar * ToolBar
Definition mtsComponentViewerQt.h:71
std::map< ComponentKey, std::map< std::string, unsigned int > > m_provided_interface_to_port
Definition mtsComponentViewerQt.h:92
std::pair< std::string, std::string > ComponentKey
Definition mtsComponentViewerQt.h:82
QtNodes::GraphicsView * View
Definition mtsComponentViewerQt.h:79
void onFilterComponents(bool checked)
QtNodes::DataFlowGraphModel * GraphModel
Definition mtsComponentViewerQt.h:77
void ChangeStateHandler(const mtsComponentStateChange &state_change)
~mtsComponentViewerQt()=default
QtNodes::DataFlowGraphicsScene * Scene
Definition mtsComponentViewerQt.h:78
std::vector< mtsDescriptionComponent > m_component_infos
Definition mtsComponentViewerQt.h:97
std::set< std::string > m_show_interface_tags
Definition mtsComponentViewerQt.h:101
std::vector< mtsDescriptionConnection > m_connection_infos
Definition mtsComponentViewerQt.h:98
void Cleanup(void) override
std::shared_ptr< QtNodes::NodeDelegateModelRegistry > Registry
Definition mtsComponentViewerQt.h:76
std::vector< ComponentKey > m_components
Definition mtsComponentViewerQt.h:83
void onExportDOT(void)
std::map< ComponentKey, unsigned int > NodeIds
Definition mtsComponentViewerQt.h:88
void AddConnectionHandler(const mtsDescriptionConnection &connection_description)
std::set< std::string > m_show_component_tags
Definition mtsComponentViewerQt.h:100
void Configure(const std::string &filename="") override
void RemoveConnectionHandler(const mtsDescriptionConnection &connection_description)
void Startup(void) override
void UpdateGraph(void)
void Run(void) override
std::map< ComponentKey, std::map< std::string, unsigned int > > m_required_interface_to_port
Definition mtsComponentViewerQt.h:94
Definition mtsParameterTypes.h:58
Definition mtsParameterTypes.h:624
mtsTaskFromSignal(const std::string &name, unsigned int sizeStateTable=256)
const int CMN_DYNAMIC_CREATION_ONEARG
Definition cmnClassRegisterMacros.h:330
#define CMN_DECLARE_SERVICES_INSTANTIATION(className)
Definition cmnClassRegisterMacros.h:199
#define CISST_EXPORT
Definition cmnExportMacros.h:50
#define CMN_LOG_ALLOW_DEFAULT
Definition cmnLogLoD.h:76
Rules of exporting.
Defines a task with a Run method trigger by signals (any queued command or event).
Definition mtsComponentViewerQt.h:37