@@ -0,0 +1,42 | |||
|
1 | #ifndef SCIQLOP_FINDVARIABLEOPERATION_H | |
|
2 | #define SCIQLOP_FINDVARIABLEOPERATION_H | |
|
3 | ||
|
4 | #include "Visualization/IVisualizationWidgetVisitor.h" | |
|
5 | ||
|
6 | #include <Common/spimpl.h> | |
|
7 | ||
|
8 | #include <set> | |
|
9 | ||
|
10 | class IVisualizationWidget; | |
|
11 | class Variable; | |
|
12 | ||
|
13 | /** | |
|
14 | * @brief The FindVariableOperation class defines an operation that traverses all of visualization | |
|
15 | * widgets to determine which ones contain the variable passed as parameter. The result of the | |
|
16 | * operation is the list of widgets that contain the variable. | |
|
17 | */ | |
|
18 | class FindVariableOperation : public IVisualizationWidgetVisitor { | |
|
19 | public: | |
|
20 | /** | |
|
21 | * Ctor | |
|
22 | * @param variable the variable to find | |
|
23 | */ | |
|
24 | explicit FindVariableOperation(std::shared_ptr<Variable> variable); | |
|
25 | ||
|
26 | void visitEnter(VisualizationWidget *widget) override final; | |
|
27 | void visitLeave(VisualizationWidget *widget) override final; | |
|
28 | void visitEnter(VisualizationTabWidget *tabWidget) override final; | |
|
29 | void visitLeave(VisualizationTabWidget *tabWidget) override final; | |
|
30 | void visitEnter(VisualizationZoneWidget *zoneWidget) override final; | |
|
31 | void visitLeave(VisualizationZoneWidget *zoneWidget) override final; | |
|
32 | void visit(VisualizationGraphWidget *graphWidget) override final; | |
|
33 | ||
|
34 | /// @return the widgets that contain the variable | |
|
35 | std::set<IVisualizationWidget *> result() const noexcept; | |
|
36 | ||
|
37 | private: | |
|
38 | class FindVariableOperationPrivate; | |
|
39 | spimpl::unique_impl_ptr<FindVariableOperationPrivate> impl; | |
|
40 | }; | |
|
41 | ||
|
42 | #endif // SCIQLOP_FINDVARIABLEOPERATION_H |
@@ -0,0 +1,72 | |||
|
1 | #include "Visualization/operations/FindVariableOperation.h" | |
|
2 | ||
|
3 | #include "Visualization/VisualizationGraphWidget.h" | |
|
4 | #include "Visualization/VisualizationTabWidget.h" | |
|
5 | #include "Visualization/VisualizationWidget.h" | |
|
6 | #include "Visualization/VisualizationZoneWidget.h" | |
|
7 | ||
|
8 | #include <Variable/Variable.h> | |
|
9 | ||
|
10 | struct FindVariableOperation::FindVariableOperationPrivate { | |
|
11 | explicit FindVariableOperationPrivate(std::shared_ptr<Variable> variable) : m_Variable{variable} | |
|
12 | { | |
|
13 | } | |
|
14 | ||
|
15 | void visit(IVisualizationWidget *widget) | |
|
16 | { | |
|
17 | if (m_Variable && widget && widget->contains(*m_Variable)) { | |
|
18 | m_Containers.insert(widget); | |
|
19 | } | |
|
20 | } | |
|
21 | ||
|
22 | std::shared_ptr<Variable> m_Variable; ///< Variable to find | |
|
23 | std::set<IVisualizationWidget *> m_Containers; ///< Containers found for the variable | |
|
24 | }; | |
|
25 | ||
|
26 | FindVariableOperation::FindVariableOperation(std::shared_ptr<Variable> variable) | |
|
27 | : impl{spimpl::make_unique_impl<FindVariableOperationPrivate>(variable)} | |
|
28 | { | |
|
29 | } | |
|
30 | ||
|
31 | void FindVariableOperation::visitEnter(VisualizationWidget *widget) | |
|
32 | { | |
|
33 | impl->visit(widget); | |
|
34 | } | |
|
35 | ||
|
36 | void FindVariableOperation::visitLeave(VisualizationWidget *widget) | |
|
37 | { | |
|
38 | // Does nothing | |
|
39 | Q_UNUSED(widget); | |
|
40 | } | |
|
41 | ||
|
42 | void FindVariableOperation::visitEnter(VisualizationTabWidget *tabWidget) | |
|
43 | { | |
|
44 | impl->visit(tabWidget); | |
|
45 | } | |
|
46 | ||
|
47 | void FindVariableOperation::visitLeave(VisualizationTabWidget *tabWidget) | |
|
48 | { | |
|
49 | // Does nothing | |
|
50 | Q_UNUSED(tabWidget); | |
|
51 | } | |
|
52 | ||
|
53 | void FindVariableOperation::visitEnter(VisualizationZoneWidget *zoneWidget) | |
|
54 | { | |
|
55 | impl->visit(zoneWidget); | |
|
56 | } | |
|
57 | ||
|
58 | void FindVariableOperation::visitLeave(VisualizationZoneWidget *zoneWidget) | |
|
59 | { | |
|
60 | // Does nothing | |
|
61 | Q_UNUSED(zoneWidget); | |
|
62 | } | |
|
63 | ||
|
64 | void FindVariableOperation::visit(VisualizationGraphWidget *graphWidget) | |
|
65 | { | |
|
66 | impl->visit(graphWidget); | |
|
67 | } | |
|
68 | ||
|
69 | std::set<IVisualizationWidget *> FindVariableOperation::result() const noexcept | |
|
70 | { | |
|
71 | return impl->m_Containers; | |
|
72 | } |
@@ -54,6 +54,7 gui_sources = [ | |||
|
54 | 54 | 'src/Visualization/VisualizationZoneWidget.cpp', |
|
55 | 55 | 'src/Visualization/qcustomplot.cpp', |
|
56 | 56 | 'src/Visualization/QCustomPlotSynchronizer.cpp', |
|
57 | 'src/Visualization/operations/FindVariableOperation.cpp', | |
|
57 | 58 | 'src/Visualization/operations/GenerateVariableMenuOperation.cpp', |
|
58 | 59 | 'src/Visualization/operations/MenuBuilder.cpp', |
|
59 | 60 | 'src/Visualization/operations/RemoveVariableOperation.cpp', |
General Comments 0
You need to be logged in to leave comments.
Login now