diff --git a/gui/include/Visualization/IVisualizationWidget.h b/gui/include/Visualization/IVisualizationWidget.h new file mode 100644 index 0000000..1db67c2 --- /dev/null +++ b/gui/include/Visualization/IVisualizationWidget.h @@ -0,0 +1,24 @@ +#ifndef SCIQLOP_IVISUALIZATIONWIDGET_H +#define SCIQLOP_IVISUALIZATIONWIDGET_H + +#include "Visualization/IVisualizationWidgetVisitor.h" + +#include +#include + +/** + * @brief The IVisualizationWidget handles the visualization widget. + */ +class IVisualizationWidget { + +public: + virtual ~IVisualizationWidget() = default; + + /// Initializes the plugin + virtual void accept(IVisualizationWidget *visitor) = 0; + virtual void close() = 0; + virtual QString name() = 0; +}; + + +#endif // SCIQLOP_IVISUALIZATIONWIDGET_H diff --git a/gui/include/Visualization/IVisualizationWidgetVisitor.h b/gui/include/Visualization/IVisualizationWidgetVisitor.h new file mode 100644 index 0000000..33ce5b9 --- /dev/null +++ b/gui/include/Visualization/IVisualizationWidgetVisitor.h @@ -0,0 +1,25 @@ +#ifndef SCIQLOP_IVISUALIZATIONWIDGETVISITOR_H +#define SCIQLOP_IVISUALIZATIONWIDGETVISITOR_H + + +class VisualizationWidget; +class VisualizationTabWidget; +class VisualizationZoneWidget; +class VisualizationGraphWidget; + +/** + * @brief The IVisualizationWidgetVisitor handles the visualization widget vistor pattern. + */ +class IVisualizationWidgetVisitor { + +public: + virtual ~IVisualizationWidgetVisitor() = default; + + virtual void visit(VisualizationWidget *widget) = 0; + virtual void visit(VisualizationTabWidget *tabWidget) = 0; + virtual void visit(VisualizationZoneWidget *zoneWidget) = 0; + virtual void visit(VisualizationGraphWidget *graphWidget) = 0; +}; + + +#endif // SCIQLOP_IVISUALIZATIONWIDGETVISITOR_H diff --git a/gui/include/Visualization/VisualizationGraphWidget.h b/gui/include/Visualization/VisualizationGraphWidget.h index b1f5e7f..093325a 100644 --- a/gui/include/Visualization/VisualizationGraphWidget.h +++ b/gui/include/Visualization/VisualizationGraphWidget.h @@ -1,21 +1,39 @@ #ifndef SCIQLOP_VISUALIZATIONGRAPHWIDGET_H #define SCIQLOP_VISUALIZATIONGRAPHWIDGET_H +#include "Visualization/IVisualizationWidget.h" + #include +#include + +#include + +class Variable; + namespace Ui { class VisualizationGraphWidget; } // namespace Ui -class VisualizationGraphWidget : public QWidget { +class VisualizationGraphWidget : public QWidget, public IVisualizationWidget { Q_OBJECT public: explicit VisualizationGraphWidget(QWidget *parent = 0); virtual ~VisualizationGraphWidget(); + void addVariable(std::shared_ptr variable); + + // IVisualizationWidget interface + void accept(IVisualizationWidget *visitor); + void close(); + QString name(); + private: Ui::VisualizationGraphWidget *ui; + + class VisualizationGraphWidgetPrivate; + spimpl::unique_impl_ptr impl; }; #endif // SCIQLOP_VISUALIZATIONGRAPHWIDGET_H diff --git a/gui/include/Visualization/VisualizationTabWidget.h b/gui/include/Visualization/VisualizationTabWidget.h index a3a9d49..b61678e 100644 --- a/gui/include/Visualization/VisualizationTabWidget.h +++ b/gui/include/Visualization/VisualizationTabWidget.h @@ -1,19 +1,37 @@ #ifndef SCIQLOP_VISUALIZATIONTABWIDGET_H #define SCIQLOP_VISUALIZATIONTABWIDGET_H +#include "Visualization/IVisualizationWidget.h" + #include +class VisualizationZoneWidget; + namespace Ui { class VisualizationTabWidget; } // namespace Ui -class VisualizationTabWidget : public QWidget { +class VisualizationTabWidget : public QWidget, public IVisualizationWidget { Q_OBJECT public: explicit VisualizationTabWidget(QWidget *parent = 0); virtual ~VisualizationTabWidget(); + /// Add a zone widget + void addZone(VisualizationZoneWidget *zoneWidget); + + /// Create a zone using a Variable + VisualizationZoneWidget *createZone(); + + /// Remove a zone + void removeZone(VisualizationZoneWidget *zone); + + // IVisualizationWidget interface + void accept(IVisualizationWidget *visitor); + void close(); + QString name(); + private: Ui::VisualizationTabWidget *ui; }; diff --git a/gui/include/Visualization/VisualizationWidget.h b/gui/include/Visualization/VisualizationWidget.h index 280783a..7f54756 100644 --- a/gui/include/Visualization/VisualizationWidget.h +++ b/gui/include/Visualization/VisualizationWidget.h @@ -1,22 +1,40 @@ #ifndef SCIQLOP_VISUALIZATIONWIDGET_H #define SCIQLOP_VISUALIZATIONWIDGET_H +#include "Visualization/IVisualizationWidget.h" + #include #include +class VisualizationTabWidget; + Q_DECLARE_LOGGING_CATEGORY(LOG_VisualizationWidget) namespace Ui { class VisualizationWidget; } // namespace Ui -class VisualizationWidget : public QWidget { +class VisualizationWidget : public QWidget, public IVisualizationWidget { Q_OBJECT public: explicit VisualizationWidget(QWidget *parent = 0); virtual ~VisualizationWidget(); + /// Add a zone widget + virtual void addTab(VisualizationTabWidget *tabWidget); + + /// Create a tab using a Variable + VisualizationTabWidget *createTab(); + + /// Remove a tab + void removeTab(VisualizationTabWidget *tab); + + // IVisualizationWidget interface + void accept(IVisualizationWidget *visitor); + void close(); + QString name(); + private: Ui::VisualizationWidget *ui; }; diff --git a/gui/include/Visualization/VisualizationZoneWidget.h b/gui/include/Visualization/VisualizationZoneWidget.h index ba591f1..a8f67e1 100644 --- a/gui/include/Visualization/VisualizationZoneWidget.h +++ b/gui/include/Visualization/VisualizationZoneWidget.h @@ -1,19 +1,37 @@ #ifndef SCIQLOP_VISUALIZATIONZONEWIDGET_H #define SCIQLOP_VISUALIZATIONZONEWIDGET_H +#include "Visualization/IVisualizationWidget.h" + +class VisualizationGraphWidget; + #include namespace Ui { class VisualizationZoneWidget; } // Ui -class VisualizationZoneWidget : public QWidget { +class VisualizationZoneWidget : public QWidget, public IVisualizationWidget { Q_OBJECT public: explicit VisualizationZoneWidget(QWidget *parent = 0); virtual ~VisualizationZoneWidget(); + /// Add a graph widget + void addGraph(VisualizationGraphWidget *graphWidget); + + /// Create a graph using a Variable + VisualizationGraphWidget *createGraph(); + + /// Remove a graph + void removeGraph(VisualizationGraphWidget *graph); + + // IVisualizationWidget interface + void accept(IVisualizationWidget *visitor); + void close(); + QString name(); + private: Ui::VisualizationZoneWidget *ui; }; diff --git a/gui/src/Visualization/VisualizationGraphWidget.cpp b/gui/src/Visualization/VisualizationGraphWidget.cpp index 275198e..da69420 100644 --- a/gui/src/Visualization/VisualizationGraphWidget.cpp +++ b/gui/src/Visualization/VisualizationGraphWidget.cpp @@ -1,8 +1,21 @@ #include "Visualization/VisualizationGraphWidget.h" #include "ui_VisualizationGraphWidget.h" +#include + +#include + +struct VisualizationGraphWidget::VisualizationGraphWidgetPrivate { + + // 1 variable -> n qcpplot + std::unordered_map, std::unique_ptr > + m_VariableToPlotMap; +}; + VisualizationGraphWidget::VisualizationGraphWidget(QWidget *parent) - : QWidget(parent), ui(new Ui::VisualizationGraphWidget) + : QWidget(parent), + ui(new Ui::VisualizationGraphWidget), + impl{spimpl::make_unique_impl()} { ui->setupUi(this); } @@ -11,3 +24,24 @@ VisualizationGraphWidget::~VisualizationGraphWidget() { delete ui; } + +void VisualizationGraphWidget::addVariable(std::shared_ptr variable) +{ + // todo: first check is variable contains data then check how many plot have to be created +} + +void VisualizationGraphWidget::accept(IVisualizationWidget *visitor) +{ + // TODO: manage the visitor +} + +void VisualizationGraphWidget::close() +{ + // The main view cannot be directly closed. + return; +} + +QString VisualizationGraphWidget::name() +{ + return QStringLiteral("MainView"); +} diff --git a/gui/src/Visualization/VisualizationTabWidget.cpp b/gui/src/Visualization/VisualizationTabWidget.cpp index 7a3655a..0718406 100644 --- a/gui/src/Visualization/VisualizationTabWidget.cpp +++ b/gui/src/Visualization/VisualizationTabWidget.cpp @@ -1,13 +1,50 @@ #include "Visualization/VisualizationTabWidget.h" #include "ui_VisualizationTabWidget.h" +#include "Visualization/VisualizationZoneWidget.h" + + VisualizationTabWidget::VisualizationTabWidget(QWidget *parent) : QWidget{parent}, ui{new Ui::VisualizationTabWidget} { ui->setupUi(this); + } VisualizationTabWidget::~VisualizationTabWidget() { delete ui; } + +void VisualizationTabWidget::addZone(VisualizationZoneWidget *zoneWidget) +{ + this->layout()->addWidget(zoneWidget); +} + +VisualizationZoneWidget *VisualizationTabWidget::createZone() +{ + auto zoneWidget = new VisualizationZoneWidget(this); + this->addZone(zoneWidget); + + return zoneWidget; +} + +void VisualizationTabWidget::removeZone(VisualizationZoneWidget *zone) +{ +} + +void VisualizationTabWidget::accept(IVisualizationWidget *visitor) +{ + // TODO: manage the visitor +} + +void VisualizationTabWidget::close() +{ + // The main view cannot be directly closed. + return; +} + +QString VisualizationTabWidget::name() +{ + return QStringLiteral("MainView"); +} diff --git a/gui/src/Visualization/VisualizationWidget.cpp b/gui/src/Visualization/VisualizationWidget.cpp index 91c1f61..d09a4f1 100644 --- a/gui/src/Visualization/VisualizationWidget.cpp +++ b/gui/src/Visualization/VisualizationWidget.cpp @@ -1,12 +1,11 @@ #include "Visualization/VisualizationWidget.h" #include "Visualization/VisualizationTabWidget.h" +#include "Visualization/qcustomplot.h" + #include "ui_VisualizationWidget.h" -#include #include -#include "iostream" - Q_LOGGING_CATEGORY(LOG_VisualizationWidget, "VisualizationWidget") VisualizationWidget::VisualizationWidget(QWidget *parent) @@ -41,3 +40,35 @@ VisualizationWidget::~VisualizationWidget() { delete ui; } + +void VisualizationWidget::addTab(VisualizationTabWidget *tabWidget) +{ + // NOTE: check is this method has to be deleted because of its dupplicated version visible as + // lambda function (in the constructor) +} + +VisualizationTabWidget *VisualizationWidget::createTab() +{ +} + +void VisualizationWidget::removeTab(VisualizationTabWidget *tab) +{ + // NOTE: check is this method has to be deleted because of its dupplicated version visible as + // lambda function (in the constructor) +} + +void VisualizationWidget::accept(IVisualizationWidget *visitor) +{ + // TODO: manage the visitor +} + +void VisualizationWidget::close() +{ + // The main view cannot be directly closed. + return; +} + +QString VisualizationWidget::name() +{ + return QStringLiteral("MainView"); +} diff --git a/gui/src/Visualization/VisualizationZoneWidget.cpp b/gui/src/Visualization/VisualizationZoneWidget.cpp index ea7a0fb..3c7393e 100644 --- a/gui/src/Visualization/VisualizationZoneWidget.cpp +++ b/gui/src/Visualization/VisualizationZoneWidget.cpp @@ -1,6 +1,8 @@ #include "Visualization/VisualizationZoneWidget.h" #include "ui_VisualizationZoneWidget.h" +#include "Visualization/VisualizationGraphWidget.h" + VisualizationZoneWidget::VisualizationZoneWidget(QWidget *parent) : QWidget{parent}, ui{new Ui::VisualizationZoneWidget} { @@ -11,3 +13,36 @@ VisualizationZoneWidget::~VisualizationZoneWidget() { delete ui; } + +void VisualizationZoneWidget::addGraph(VisualizationGraphWidget *graphWidget) +{ + ui->visualizationZoneFrame->layout()->addWidget(graphWidget); +} + +VisualizationGraphWidget *VisualizationZoneWidget::createGraph() +{ + auto graphWidget = new VisualizationGraphWidget(this); + this->addGraph(graphWidget); + + return graphWidget; +} + +void VisualizationZoneWidget::removeGraph(VisualizationGraphWidget *graph) +{ +} + +void VisualizationZoneWidget::accept(IVisualizationWidget *visitor) +{ + // TODO: manage the visitor +} + +void VisualizationZoneWidget::close() +{ + // The main view cannot be directly closed. + return; +} + +QString VisualizationZoneWidget::name() +{ + return QStringLiteral("MainView"); +} diff --git a/gui/ui/sidepane/SqpSidePane.ui b/gui/ui/Sidepane/SqpSidePane.ui similarity index 100% rename from gui/ui/sidepane/SqpSidePane.ui rename to gui/ui/Sidepane/SqpSidePane.ui diff --git a/gui/ui/visualization/VisualizationGraphWidget.ui b/gui/ui/Visualization/VisualizationGraphWidget.ui similarity index 60% rename from gui/ui/visualization/VisualizationGraphWidget.ui rename to gui/ui/Visualization/VisualizationGraphWidget.ui index c7c4fd0..bcecbc4 100644 --- a/gui/ui/visualization/VisualizationGraphWidget.ui +++ b/gui/ui/Visualization/VisualizationGraphWidget.ui @@ -1,9 +1,7 @@ + - - - VisualizationGraphWidget - + 0 @@ -15,7 +13,20 @@ Form + + + + + - + + + QCustomPlot + QWidget +
Visualization/qcustomplot.h
+ 1 +
+
+
diff --git a/gui/ui/visualization/VisualizationTabWidget.ui b/gui/ui/Visualization/VisualizationTabWidget.ui similarity index 78% rename from gui/ui/visualization/VisualizationTabWidget.ui rename to gui/ui/Visualization/VisualizationTabWidget.ui index 543adda..96002e1 100644 --- a/gui/ui/visualization/VisualizationTabWidget.ui +++ b/gui/ui/Visualization/VisualizationTabWidget.ui @@ -1,9 +1,7 @@ + - - - VisualizationTabWidget - + 0 @@ -15,7 +13,8 @@ Form + - + diff --git a/gui/ui/visualization/VisualizationWidget.ui b/gui/ui/Visualization/VisualizationWidget.ui similarity index 100% rename from gui/ui/visualization/VisualizationWidget.ui rename to gui/ui/Visualization/VisualizationWidget.ui diff --git a/gui/ui/visualization/VisualizationZoneWidget.ui b/gui/ui/Visualization/VisualizationZoneWidget.ui similarity index 60% rename from gui/ui/visualization/VisualizationZoneWidget.ui rename to gui/ui/Visualization/VisualizationZoneWidget.ui index ca440d1..fa0dae3 100644 --- a/gui/ui/visualization/VisualizationZoneWidget.ui +++ b/gui/ui/Visualization/VisualizationZoneWidget.ui @@ -1,9 +1,7 @@ + - - - VisualizationZoneWidget - + 0 @@ -15,7 +13,20 @@ Form + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + - +