Medical Imaging Interaction Toolkit  2024.12.99-0da743f6
Medical Imaging Interaction Toolkit
QmitkSynchronizedWidgetConnector.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #ifndef QmitkSynchronizedWidgetConnector_h
14 #define QmitkSynchronizedWidgetConnector_h
15 
16 #include <MitkQtWidgetsExports.h>
17 
18 // mitk core
19 #include <mitkDataNode.h>
20 
21 // mitk qt widgets
23 
24 // qt
25 #include <QList>
26 
27 /*
28 * @brief This class connects different 'QmitkSynchronizedNodeSelectionWidget', such that
29 * they can synchronize their current node selection and their current selection mode.
30 *
31 * In order to synchronize a new node selection widget with other already connected
32 * node selection widgets, 'ConnectWidget(const QmitkSynchronizedNodeSelectionWidget*)' has to be used.
33 * In order to desynchronize a node selection widget,
34 * 'DisconnectWidget(const QmitkSynchronizedNodeSelectionWidget*)' has to be used.
35 * If a new node selection has been connected / synchronized,
36 * 'SynchronizeWidget(QmitkSynchronizedNodeSelectionWidget*' can be used to initialy set
37 * the current selection and the current selection mode.
38 * For this, both values are stored in this class internally.
39 */
41 {
42  Q_OBJECT
43 
44 public:
45 
47 
49 
50  /*
51  * @brief This function connects the different signals and slots of this instance and the given
52  * given node selection widget, such that changes to the current list of nodes
53  * and the selection mode can be forwarded or received.
54  * The connections are as follows:
55  * - QmitkAbstractNodeSelectionWidget::CurrentSelectionChanged
56  * -> QmitkSynchronizedWidgetConnector::ChangeSelection
57  * - QmitkSynchronizedWidgetConnector::NodeSelectionChanged
58  * -> QmitkAbstractNodeSelectionWidget::SetCurrentSelection
59  * - QmitkSynchronizedNodeSelectionWidget::SelectionModeChanged
60  * -> QmitkSynchronizedWidgetConnector::ChangeSelectionMode
61  * - QmitkSynchronizedWidgetConnector::SelectionModeChanged
62  * -> QmitkSynchronizedNodeSelectionWidget::SetSelectAll
63  *
64  * @param nodeSelectionWidget The synchronized node selection widget to be connected / synchronized.
65  */
66  void ConnectWidget(const QmitkSynchronizedNodeSelectionWidget* nodeSelectionWidget);
67  /*
68  * @brief This function disconnects the different signals and slot of this instance and the given
69  * given node selection widget, such that changes to the current list of nodes
70  * and the selection mode cannot be forwarded or received anymore.
71  *
72  * @param nodeSelectionWidget The synchronized node selection widget to be disconnected / desynchronized.
73  */
74  void DisconnectWidget(const QmitkSynchronizedNodeSelectionWidget* nodeSelectionWidget);
75  /*
76  * @brief This function sets the current selection and the selection mode of the given node selection widget
77  * to the values of this instance. The required values are stored in this class internally.
78  * It can be used to newly initialize the given node selection widget.
79  *
80  * @param nodeSelectionWidget The synchronized node selection widget for which the
81  * current selection and the selection mode should be set.
82  */
83  void SynchronizeWidget(QmitkSynchronizedNodeSelectionWidget* nodeSelectionWidget) const;
84  /*
85  * @brief Get the current internal node selection.
86  *
87  * @return NodeList The current internal node selection stored as a member variable.
88  */
89  NodeList GetNodeSelection() const;
90  /*
91  * @brief Get the current internal selection mode.
92  *
93  * @return The current internal selection mode stored as a member variable.
94  */
95  bool GetSelectionMode() const;
96 
97 Q_SIGNALS:
98  /*
99  * @brief A signal that will be emitted by the 'ChangeSelection'-slot.
100  * This happens if a new selection / list of nodes is set from outside of this class,
101  * e.g. from a QmitkSynchronizedNodeSelectionWidget.
102  * This signal is connected to the 'SetCurrentSelection'-slot of each
103  * QmitkSynchronizedNodeSelectionWidget to propagate the new selection.
104  *
105  * @param nodes A list of data nodes that are newly selected.
106  */
107  void NodeSelectionChanged(NodeList nodes);
108  /*
109  * @brief A signal that will be emitted by the 'ChangeSelectionMode'-slot.
110  * This happens if the selection mode is change from outside of this class,
111  * e.g. from a QmitkSynchronizedNodeSelectionWidget.
112  * This signal is connected to the 'SetSelectAll'-slot of each
113  * QmitkSynchronizedNodeSelectionWidget to propagate the selection mode.
114  *
115  * @param selectAll True, if the selection mode is changed to "select all" nodes.
116  * False otherwise.
117  */
118  void SelectionModeChanged(bool selectAll);
119 
120 public Q_SLOTS:
121  /*
122  * @brief Set a new internal selection and send this new selection to connected
123  * QmitkSynchronizedNodeSelectionWidgets using the 'NodeSelectionChanged'-signal.
124  *
125  * This slot itself is connected to the 'CurrentSelectionChanged'-signal of each
126  * QmitkSynchronizedNodeSelectionWidget to receive a new selection.
127  *
128  * @param nodes A list of data nodes that are newly selected.
129  */
130  void ChangeSelection(NodeList nodes);
131  /*
132  * @brief Set a new selection mode and send this new selection mode to connected
133  * QmitkSynchronizedNodeSelectionWidgets using the 'SelectionModeChanged'-signal.
134  *
135  * This slot itself is connected to the 'SelectionModeChanged'-signal of each
136  * QmitkSynchronizedNodeSelectionWidget to receive a new selection mode.
137  *
138  * @param selectAll True, if the selection mode is changed to "select all" nodes.
139  * False otherwise.
140  */
141  void ChangeSelectionMode(bool selectAll);
142  /*
143  * @brief Decrease the internal counter of connections to keep track of how many
144  * QmitkSynchronizedNodeSelectionWidgets are synchronized.
145  *
146  * This slot itself is connected to the 'DeregisterSynchronization'-signal of each
147  * QmitkSynchronizedNodeSelectionWidget to get notified when a synchronized
148  * widget is deleted.
149  */
150  void DeregisterWidget();
151 
152 private:
153 
154  NodeList m_InternalSelection;
155  bool m_SelectAll;
156  unsigned int m_ConnectionCounter;
157 
158 };
159 
160 #endif
MITKQTWIDGETS_EXPORT
#define MITKQTWIDGETS_EXPORT
Definition: MitkQtWidgetsExports.h:15
QmitkSynchronizedNodeSelectionWidget::NodeList
QmitkAbstractNodeSelectionWidget::NodeList NodeList
Definition: QmitkSynchronizedNodeSelectionWidget.h:51
QmitkSynchronizedWidgetConnector::NodeList
QmitkSynchronizedNodeSelectionWidget::NodeList NodeList
Definition: QmitkSynchronizedWidgetConnector.h:46
QmitkSynchronizedWidgetConnector
Definition: QmitkSynchronizedWidgetConnector.h:40
QmitkSynchronizedNodeSelectionWidget.h
QmitkSynchronizedNodeSelectionWidget
Definition: QmitkSynchronizedNodeSelectionWidget.h:42
MitkQtWidgetsExports.h
mitkDataNode.h