##// END OF EJS Templates
Add the visualization gui classes
perrinel -
r118:58d173e4af62
parent child
Show More
@@ -0,0 +1,24
1 #ifndef SCIQLOP_IVISUALIZATIONWIDGET_H
2 #define SCIQLOP_IVISUALIZATIONWIDGET_H
3
4 #include "Visualization/IVisualizationWidgetVisitor.h"
5
6 #include <QString>
7 #include <memory>
8
9 /**
10 * @brief The IVisualizationWidget handles the visualization widget.
11 */
12 class IVisualizationWidget {
13
14 public:
15 virtual ~IVisualizationWidget() = default;
16
17 /// Initializes the plugin
18 virtual void accept(IVisualizationWidget *visitor) = 0;
19 virtual void close() = 0;
20 virtual QString name() = 0;
21 };
22
23
24 #endif // SCIQLOP_IVISUALIZATIONWIDGET_H
@@ -0,0 +1,25
1 #ifndef SCIQLOP_IVISUALIZATIONWIDGETVISITOR_H
2 #define SCIQLOP_IVISUALIZATIONWIDGETVISITOR_H
3
4
5 class VisualizationWidget;
6 class VisualizationTabWidget;
7 class VisualizationZoneWidget;
8 class VisualizationGraphWidget;
9
10 /**
11 * @brief The IVisualizationWidgetVisitor handles the visualization widget vistor pattern.
12 */
13 class IVisualizationWidgetVisitor {
14
15 public:
16 virtual ~IVisualizationWidgetVisitor() = default;
17
18 virtual void visit(VisualizationWidget *widget) = 0;
19 virtual void visit(VisualizationTabWidget *tabWidget) = 0;
20 virtual void visit(VisualizationZoneWidget *zoneWidget) = 0;
21 virtual void visit(VisualizationGraphWidget *graphWidget) = 0;
22 };
23
24
25 #endif // SCIQLOP_IVISUALIZATIONWIDGETVISITOR_H
@@ -1,21 +1,39
1 1 #ifndef SCIQLOP_VISUALIZATIONGRAPHWIDGET_H
2 2 #define SCIQLOP_VISUALIZATIONGRAPHWIDGET_H
3 3
4 #include "Visualization/IVisualizationWidget.h"
5
4 6 #include <QWidget>
5 7
8 #include <memory>
9
10 #include <Common/spimpl.h>
11
12 class Variable;
13
6 14 namespace Ui {
7 15 class VisualizationGraphWidget;
8 16 } // namespace Ui
9 17
10 class VisualizationGraphWidget : public QWidget {
18 class VisualizationGraphWidget : public QWidget, public IVisualizationWidget {
11 19 Q_OBJECT
12 20
13 21 public:
14 22 explicit VisualizationGraphWidget(QWidget *parent = 0);
15 23 virtual ~VisualizationGraphWidget();
16 24
25 void addVariable(std::shared_ptr<Variable> variable);
26
27 // IVisualizationWidget interface
28 void accept(IVisualizationWidget *visitor);
29 void close();
30 QString name();
31
17 32 private:
18 33 Ui::VisualizationGraphWidget *ui;
34
35 class VisualizationGraphWidgetPrivate;
36 spimpl::unique_impl_ptr<VisualizationGraphWidgetPrivate> impl;
19 37 };
20 38
21 39 #endif // SCIQLOP_VISUALIZATIONGRAPHWIDGET_H
@@ -1,21 +1,39
1 1 #ifndef SCIQLOP_VISUALIZATIONTABWIDGET_H
2 2 #define SCIQLOP_VISUALIZATIONTABWIDGET_H
3 3
4 #include "Visualization/IVisualizationWidget.h"
5
4 6 #include <QWidget>
5 7
8 class VisualizationZoneWidget;
9
6 10 namespace Ui {
7 11 class VisualizationTabWidget;
8 12 } // namespace Ui
9 13
10 class VisualizationTabWidget : public QWidget {
14 class VisualizationTabWidget : public QWidget, public IVisualizationWidget {
11 15 Q_OBJECT
12 16
13 17 public:
14 18 explicit VisualizationTabWidget(QWidget *parent = 0);
15 19 virtual ~VisualizationTabWidget();
16 20
21 /// Add a zone widget
22 void addZone(VisualizationZoneWidget *zoneWidget);
23
24 /// Create a zone using a Variable
25 VisualizationZoneWidget *createZone();
26
27 /// Remove a zone
28 void removeZone(VisualizationZoneWidget *zone);
29
30 // IVisualizationWidget interface
31 void accept(IVisualizationWidget *visitor);
32 void close();
33 QString name();
34
17 35 private:
18 36 Ui::VisualizationTabWidget *ui;
19 37 };
20 38
21 39 #endif // SCIQLOP_VISUALIZATIONTABWIDGET_H
@@ -1,24 +1,42
1 1 #ifndef SCIQLOP_VISUALIZATIONWIDGET_H
2 2 #define SCIQLOP_VISUALIZATIONWIDGET_H
3 3
4 #include "Visualization/IVisualizationWidget.h"
5
4 6 #include <QLoggingCategory>
5 7 #include <QWidget>
6 8
9 class VisualizationTabWidget;
10
7 11 Q_DECLARE_LOGGING_CATEGORY(LOG_VisualizationWidget)
8 12
9 13 namespace Ui {
10 14 class VisualizationWidget;
11 15 } // namespace Ui
12 16
13 class VisualizationWidget : public QWidget {
17 class VisualizationWidget : public QWidget, public IVisualizationWidget {
14 18 Q_OBJECT
15 19
16 20 public:
17 21 explicit VisualizationWidget(QWidget *parent = 0);
18 22 virtual ~VisualizationWidget();
19 23
24 /// Add a zone widget
25 virtual void addTab(VisualizationTabWidget *tabWidget);
26
27 /// Create a tab using a Variable
28 VisualizationTabWidget *createTab();
29
30 /// Remove a tab
31 void removeTab(VisualizationTabWidget *tab);
32
33 // IVisualizationWidget interface
34 void accept(IVisualizationWidget *visitor);
35 void close();
36 QString name();
37
20 38 private:
21 39 Ui::VisualizationWidget *ui;
22 40 };
23 41
24 42 #endif // VISUALIZATIONWIDGET_H
@@ -1,21 +1,39
1 1 #ifndef SCIQLOP_VISUALIZATIONZONEWIDGET_H
2 2 #define SCIQLOP_VISUALIZATIONZONEWIDGET_H
3 3
4 #include "Visualization/IVisualizationWidget.h"
5
6 class VisualizationGraphWidget;
7
4 8 #include <QWidget>
5 9
6 10 namespace Ui {
7 11 class VisualizationZoneWidget;
8 12 } // Ui
9 13
10 class VisualizationZoneWidget : public QWidget {
14 class VisualizationZoneWidget : public QWidget, public IVisualizationWidget {
11 15 Q_OBJECT
12 16
13 17 public:
14 18 explicit VisualizationZoneWidget(QWidget *parent = 0);
15 19 virtual ~VisualizationZoneWidget();
16 20
21 /// Add a graph widget
22 void addGraph(VisualizationGraphWidget *graphWidget);
23
24 /// Create a graph using a Variable
25 VisualizationGraphWidget *createGraph();
26
27 /// Remove a graph
28 void removeGraph(VisualizationGraphWidget *graph);
29
30 // IVisualizationWidget interface
31 void accept(IVisualizationWidget *visitor);
32 void close();
33 QString name();
34
17 35 private:
18 36 Ui::VisualizationZoneWidget *ui;
19 37 };
20 38
21 39 #endif // SCIQLOP_VISUALIZATIONZONEWIDGET_H
@@ -1,13 +1,47
1 1 #include "Visualization/VisualizationGraphWidget.h"
2 2 #include "ui_VisualizationGraphWidget.h"
3 3
4 #include <Variable/Variable.h>
5
6 #include <unordered_map>
7
8 struct VisualizationGraphWidget::VisualizationGraphWidgetPrivate {
9
10 // 1 variable -> n qcpplot
11 std::unordered_map<std::shared_ptr<Variable>, std::unique_ptr<QCPAbstractPlottable> >
12 m_VariableToPlotMap;
13 };
14
4 15 VisualizationGraphWidget::VisualizationGraphWidget(QWidget *parent)
5 : QWidget(parent), ui(new Ui::VisualizationGraphWidget)
16 : QWidget(parent),
17 ui(new Ui::VisualizationGraphWidget),
18 impl{spimpl::make_unique_impl<VisualizationGraphWidgetPrivate>()}
6 19 {
7 20 ui->setupUi(this);
8 21 }
9 22
10 23 VisualizationGraphWidget::~VisualizationGraphWidget()
11 24 {
12 25 delete ui;
13 26 }
27
28 void VisualizationGraphWidget::addVariable(std::shared_ptr<Variable> variable)
29 {
30 // todo: first check is variable contains data then check how many plot have to be created
31 }
32
33 void VisualizationGraphWidget::accept(IVisualizationWidget *visitor)
34 {
35 // TODO: manage the visitor
36 }
37
38 void VisualizationGraphWidget::close()
39 {
40 // The main view cannot be directly closed.
41 return;
42 }
43
44 QString VisualizationGraphWidget::name()
45 {
46 return QStringLiteral("MainView");
47 }
@@ -1,13 +1,50
1 1 #include "Visualization/VisualizationTabWidget.h"
2 2 #include "ui_VisualizationTabWidget.h"
3 3
4 #include "Visualization/VisualizationZoneWidget.h"
5
6
4 7 VisualizationTabWidget::VisualizationTabWidget(QWidget *parent)
5 8 : QWidget{parent}, ui{new Ui::VisualizationTabWidget}
6 9 {
7 10 ui->setupUi(this);
11
8 12 }
9 13
10 14 VisualizationTabWidget::~VisualizationTabWidget()
11 15 {
12 16 delete ui;
13 17 }
18
19 void VisualizationTabWidget::addZone(VisualizationZoneWidget *zoneWidget)
20 {
21 this->layout()->addWidget(zoneWidget);
22 }
23
24 VisualizationZoneWidget *VisualizationTabWidget::createZone()
25 {
26 auto zoneWidget = new VisualizationZoneWidget(this);
27 this->addZone(zoneWidget);
28
29 return zoneWidget;
30 }
31
32 void VisualizationTabWidget::removeZone(VisualizationZoneWidget *zone)
33 {
34 }
35
36 void VisualizationTabWidget::accept(IVisualizationWidget *visitor)
37 {
38 // TODO: manage the visitor
39 }
40
41 void VisualizationTabWidget::close()
42 {
43 // The main view cannot be directly closed.
44 return;
45 }
46
47 QString VisualizationTabWidget::name()
48 {
49 return QStringLiteral("MainView");
50 }
@@ -1,43 +1,74
1 1 #include "Visualization/VisualizationWidget.h"
2 2 #include "Visualization/VisualizationTabWidget.h"
3 #include "Visualization/qcustomplot.h"
4
3 5 #include "ui_VisualizationWidget.h"
4 6
5 #include <QDebug>
6 7 #include <QToolButton>
7 8
8 #include "iostream"
9
10 9 Q_LOGGING_CATEGORY(LOG_VisualizationWidget, "VisualizationWidget")
11 10
12 11 VisualizationWidget::VisualizationWidget(QWidget *parent)
13 12 : QWidget{parent}, ui{new Ui::VisualizationWidget}
14 13 {
15 14 ui->setupUi(this);
16 15
17 16 auto addTabViewButton = new QToolButton{ui->tabWidget};
18 17 addTabViewButton->setText(tr("Add View"));
19 18 addTabViewButton->setCursor(Qt::ArrowCursor);
20 19 addTabViewButton->setAutoRaise(true);
21 20 ui->tabWidget->setCornerWidget(addTabViewButton, Qt::TopRightCorner);
22 21
23 22 auto addTabView = [&]() {
24 23 auto index = ui->tabWidget->addTab(new VisualizationTabWidget(ui->tabWidget),
25 24 QString("View %1").arg(ui->tabWidget->count() + 1));
26 25 qCInfo(LOG_VisualizationWidget()) << tr("add the tab of index %1").arg(index);
27 26 };
28 27
29 28 auto removeTabView = [&](int index) {
30 29 ui->tabWidget->removeTab(index);
31 30 qCInfo(LOG_VisualizationWidget()) << tr("remove the tab of index %1").arg(index);
32 31 };
33 32
34 33 ui->tabWidget->setTabsClosable(true);
35 34
36 35 connect(addTabViewButton, &QToolButton::clicked, addTabView);
37 36 connect(ui->tabWidget, &QTabWidget::tabCloseRequested, removeTabView);
38 37 }
39 38
40 39 VisualizationWidget::~VisualizationWidget()
41 40 {
42 41 delete ui;
43 42 }
43
44 void VisualizationWidget::addTab(VisualizationTabWidget *tabWidget)
45 {
46 // NOTE: check is this method has to be deleted because of its dupplicated version visible as
47 // lambda function (in the constructor)
48 }
49
50 VisualizationTabWidget *VisualizationWidget::createTab()
51 {
52 }
53
54 void VisualizationWidget::removeTab(VisualizationTabWidget *tab)
55 {
56 // NOTE: check is this method has to be deleted because of its dupplicated version visible as
57 // lambda function (in the constructor)
58 }
59
60 void VisualizationWidget::accept(IVisualizationWidget *visitor)
61 {
62 // TODO: manage the visitor
63 }
64
65 void VisualizationWidget::close()
66 {
67 // The main view cannot be directly closed.
68 return;
69 }
70
71 QString VisualizationWidget::name()
72 {
73 return QStringLiteral("MainView");
74 }
@@ -1,13 +1,48
1 1 #include "Visualization/VisualizationZoneWidget.h"
2 2 #include "ui_VisualizationZoneWidget.h"
3 3
4 #include "Visualization/VisualizationGraphWidget.h"
5
4 6 VisualizationZoneWidget::VisualizationZoneWidget(QWidget *parent)
5 7 : QWidget{parent}, ui{new Ui::VisualizationZoneWidget}
6 8 {
7 9 ui->setupUi(this);
8 10 }
9 11
10 12 VisualizationZoneWidget::~VisualizationZoneWidget()
11 13 {
12 14 delete ui;
13 15 }
16
17 void VisualizationZoneWidget::addGraph(VisualizationGraphWidget *graphWidget)
18 {
19 ui->visualizationZoneFrame->layout()->addWidget(graphWidget);
20 }
21
22 VisualizationGraphWidget *VisualizationZoneWidget::createGraph()
23 {
24 auto graphWidget = new VisualizationGraphWidget(this);
25 this->addGraph(graphWidget);
26
27 return graphWidget;
28 }
29
30 void VisualizationZoneWidget::removeGraph(VisualizationGraphWidget *graph)
31 {
32 }
33
34 void VisualizationZoneWidget::accept(IVisualizationWidget *visitor)
35 {
36 // TODO: manage the visitor
37 }
38
39 void VisualizationZoneWidget::close()
40 {
41 // The main view cannot be directly closed.
42 return;
43 }
44
45 QString VisualizationZoneWidget::name()
46 {
47 return QStringLiteral("MainView");
48 }
1 NO CONTENT: file renamed from gui/ui/sidepane/SqpSidePane.ui to gui/ui/Sidepane/SqpSidePane.ui
@@ -1,21 +1,32
1 <?xml version="1.0" encoding="UTF-8"?>
1 2 <ui version="4.0">
2 <author/>
3 <comment/>
4 <exportmacro/>
5 3 <class>VisualizationGraphWidget</class>
6 <widget name="VisualizationGraphWidget" class="QWidget">
4 <widget class="QWidget" name="VisualizationGraphWidget">
7 5 <property name="geometry">
8 6 <rect>
9 7 <x>0</x>
10 8 <y>0</y>
11 9 <width>400</width>
12 10 <height>300</height>
13 11 </rect>
14 12 </property>
15 13 <property name="windowTitle">
16 14 <string>Form</string>
17 15 </property>
16 <layout class="QVBoxLayout" name="verticalLayout">
17 <item>
18 <widget class="QCustomPlot" name="widget" native="true"/>
19 </item>
20 </layout>
18 21 </widget>
19 <pixmapfunction/>
22 <customwidgets>
23 <customwidget>
24 <class>QCustomPlot</class>
25 <extends>QWidget</extends>
26 <header>Visualization/qcustomplot.h</header>
27 <container>1</container>
28 </customwidget>
29 </customwidgets>
30 <resources/>
20 31 <connections/>
21 32 </ui>
@@ -1,21 +1,20
1 <?xml version="1.0" encoding="UTF-8"?>
1 2 <ui version="4.0">
2 <author/>
3 <comment/>
4 <exportmacro/>
5 3 <class>VisualizationTabWidget</class>
6 <widget name="VisualizationTabWidget" class="QWidget">
4 <widget class="QWidget" name="VisualizationTabWidget">
7 5 <property name="geometry">
8 6 <rect>
9 7 <x>0</x>
10 8 <y>0</y>
11 9 <width>400</width>
12 10 <height>300</height>
13 11 </rect>
14 12 </property>
15 13 <property name="windowTitle">
16 14 <string>Form</string>
17 15 </property>
16 <layout class="QVBoxLayout" name="verticalLayout"/>
18 17 </widget>
19 <pixmapfunction/>
18 <resources/>
20 19 <connections/>
21 20 </ui>
1 NO CONTENT: file renamed from gui/ui/visualization/VisualizationWidget.ui to gui/ui/Visualization/VisualizationWidget.ui
@@ -1,21 +1,32
1 <?xml version="1.0" encoding="UTF-8"?>
1 2 <ui version="4.0">
2 <author/>
3 <comment/>
4 <exportmacro/>
5 3 <class>VisualizationZoneWidget</class>
6 <widget name="VisualizationZoneWidget" class="QWidget">
4 <widget class="QWidget" name="VisualizationZoneWidget">
7 5 <property name="geometry">
8 6 <rect>
9 7 <x>0</x>
10 8 <y>0</y>
11 9 <width>400</width>
12 10 <height>300</height>
13 11 </rect>
14 12 </property>
15 13 <property name="windowTitle">
16 14 <string>Form</string>
17 15 </property>
16 <layout class="QVBoxLayout" name="verticalLayout_2">
17 <item>
18 <widget class="QFrame" name="visualizationZoneFrame">
19 <property name="frameShape">
20 <enum>QFrame::StyledPanel</enum>
21 </property>
22 <property name="frameShadow">
23 <enum>QFrame::Raised</enum>
24 </property>
25 <layout class="QVBoxLayout" name="verticalLayout"/>
26 </widget>
27 </item>
28 </layout>
18 29 </widget>
19 <pixmapfunction/>
30 <resources/>
20 31 <connections/>
21 32 </ui>
General Comments 0
You need to be logged in to leave comments. Login now