@@ -0,0 +1,42 | |||
|
1 | #ifndef SCIQLOP_RESCALEAXEOPERATION_H | |
|
2 | #define SCIQLOP_RESCALEAXEOPERATION_H | |
|
3 | ||
|
4 | #include "Visualization/IVisualizationWidgetVisitor.h" | |
|
5 | #include <Data/SqpDateTime.h> | |
|
6 | ||
|
7 | #include <Common/spimpl.h> | |
|
8 | ||
|
9 | #include <QLoggingCategory> | |
|
10 | ||
|
11 | #include <memory> | |
|
12 | ||
|
13 | class Variable; | |
|
14 | ||
|
15 | Q_DECLARE_LOGGING_CATEGORY(LOG_RescaleAxeOperation) | |
|
16 | ||
|
17 | /** | |
|
18 | * @brief The RescaleAxeOperation class defines an operation that traverses all of visualization | |
|
19 | * widgets to remove a variable if they contain it | |
|
20 | */ | |
|
21 | class RescaleAxeOperation : public IVisualizationWidgetVisitor { | |
|
22 | public: | |
|
23 | /** | |
|
24 | * Ctor | |
|
25 | * @param variable the variable to remove from widgets | |
|
26 | */ | |
|
27 | explicit RescaleAxeOperation(std::shared_ptr<Variable> variable, const SqpDateTime &range); | |
|
28 | ||
|
29 | void visitEnter(VisualizationWidget *widget) override final; | |
|
30 | void visitLeave(VisualizationWidget *widget) override final; | |
|
31 | void visitEnter(VisualizationTabWidget *tabWidget) override final; | |
|
32 | void visitLeave(VisualizationTabWidget *tabWidget) override final; | |
|
33 | void visitEnter(VisualizationZoneWidget *zoneWidget) override final; | |
|
34 | void visitLeave(VisualizationZoneWidget *zoneWidget) override final; | |
|
35 | void visit(VisualizationGraphWidget *graphWidget) override final; | |
|
36 | ||
|
37 | private: | |
|
38 | class RescaleAxeOperationPrivate; | |
|
39 | spimpl::unique_impl_ptr<RescaleAxeOperationPrivate> impl; | |
|
40 | }; | |
|
41 | ||
|
42 | #endif // SCIQLOP_RESCALEAXEOPERATION_H |
@@ -0,0 +1,71 | |||
|
1 | #include "Visualization/operations/RescaleAxeOperation.h" | |
|
2 | #include "Visualization/VisualizationGraphWidget.h" | |
|
3 | ||
|
4 | Q_LOGGING_CATEGORY(LOG_RescaleAxeOperation, "RescaleAxeOperation") | |
|
5 | ||
|
6 | struct RescaleAxeOperation::RescaleAxeOperationPrivate { | |
|
7 | explicit RescaleAxeOperationPrivate(std::shared_ptr<Variable> variable, | |
|
8 | const SqpDateTime &range) | |
|
9 | : m_Variable(variable), m_Range(range) | |
|
10 | { | |
|
11 | } | |
|
12 | ||
|
13 | std::shared_ptr<Variable> m_Variable; | |
|
14 | SqpDateTime m_Range; | |
|
15 | }; | |
|
16 | ||
|
17 | RescaleAxeOperation::RescaleAxeOperation(std::shared_ptr<Variable> variable, | |
|
18 | const SqpDateTime &range) | |
|
19 | : impl{spimpl::make_unique_impl<RescaleAxeOperationPrivate>(variable, range)} | |
|
20 | { | |
|
21 | } | |
|
22 | ||
|
23 | void RescaleAxeOperation::visitEnter(VisualizationWidget *widget) | |
|
24 | { | |
|
25 | // VisualizationWidget is not intended to contain a variable | |
|
26 | Q_UNUSED(widget) | |
|
27 | } | |
|
28 | ||
|
29 | void RescaleAxeOperation::visitLeave(VisualizationWidget *widget) | |
|
30 | { | |
|
31 | // VisualizationWidget is not intended to contain a variable | |
|
32 | Q_UNUSED(widget) | |
|
33 | } | |
|
34 | ||
|
35 | void RescaleAxeOperation::visitEnter(VisualizationTabWidget *tabWidget) | |
|
36 | { | |
|
37 | // VisualizationTabWidget is not intended to contain a variable | |
|
38 | Q_UNUSED(tabWidget) | |
|
39 | } | |
|
40 | ||
|
41 | void RescaleAxeOperation::visitLeave(VisualizationTabWidget *tabWidget) | |
|
42 | { | |
|
43 | // VisualizationTabWidget is not intended to contain a variable | |
|
44 | Q_UNUSED(tabWidget) | |
|
45 | } | |
|
46 | ||
|
47 | void RescaleAxeOperation::visitEnter(VisualizationZoneWidget *zoneWidget) | |
|
48 | { | |
|
49 | // VisualizationZoneWidget is not intended to contain a variable | |
|
50 | Q_UNUSED(zoneWidget) | |
|
51 | } | |
|
52 | ||
|
53 | void RescaleAxeOperation::visitLeave(VisualizationZoneWidget *zoneWidget) | |
|
54 | { | |
|
55 | // VisualizationZoneWidget is not intended to contain a variable | |
|
56 | Q_UNUSED(zoneWidget) | |
|
57 | } | |
|
58 | ||
|
59 | void RescaleAxeOperation::visit(VisualizationGraphWidget *graphWidget) | |
|
60 | { | |
|
61 | if (graphWidget) { | |
|
62 | // If the widget contains the variable, removes it | |
|
63 | if (impl->m_Variable && graphWidget->contains(*impl->m_Variable)) { | |
|
64 | graphWidget->setRange(impl->m_Variable, impl->m_Range); | |
|
65 | } | |
|
66 | } | |
|
67 | else { | |
|
68 | qCCritical(LOG_RescaleAxeOperation(), | |
|
69 | "Can't visit VisualizationGraphWidget : the widget is null"); | |
|
70 | } | |
|
71 | } |
General Comments 0
You need to be logged in to leave comments.
Login now